From owner-p4-projects Thu Aug 29 22:23:13 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C40AD37B401; Thu, 29 Aug 2002 22:22:34 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5E93D37B400 for ; Thu, 29 Aug 2002 22:22:34 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 93CC843E42 for ; Thu, 29 Aug 2002 22:22:33 -0700 (PDT) (envelope-from mini@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g7U5MXJU055368 for ; Thu, 29 Aug 2002 22:22:33 -0700 (PDT) (envelope-from mini@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g7U5MXuq055365 for perforce@freebsd.org; Thu, 29 Aug 2002 22:22:33 -0700 (PDT) Date: Thu, 29 Aug 2002 22:22:33 -0700 (PDT) Message-Id: <200208300522.g7U5MXuq055365@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to mini@freebsd.org using -f From: Jonathan Mini Subject: PERFORCE change 16788 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16788 Change 16788 by mini@freefall on 2002/08/29 22:22:14 Fix corruption from previous integ. Affected files ... .. //depot/projects/kse/sys/cam/scsi/scsi_da.c#22 edit .. //depot/projects/kse/sys/dev/ppbus/ppi.c#6 edit .. //depot/projects/kse/sys/dev/usb/ugen.c#14 edit Differences ... ==== //depot/projects/kse/sys/cam/scsi/scsi_da.c#22 (text+ko) ==== @@ -1753,79 +1753,64 @@ if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { if (((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR) - && (ccb.csio.scsi_status == SCSI_STATUS_CHECK_COND)that a tag must be sent. - */ -#ifndef DA_ORDEREDTAG_INTERVAL -#define DA_ORDEREDTAG_INTERVAL 4 -#endif + && (ccb.csio.scsi_status == SCSI_STATUS_CHECK_COND)){ + int error_code, sense_key, asc, ascq; -static struct periph_driver dadriver = -{ - dainit, "da", - TAILQ_HEAD_INITIALIZER(dadriver.units), /* generation */ 0 -}; + scsi_extract_sense(&ccb.csio.sense_data, + &error_code, &sense_key, + &asc, &ascq); -PERIPHDRIVER_DECLARE(da, dadriver); + if (sense_key != SSD_KEY_ILLEGAL_REQUEST) + scsi_sense_print(&ccb.csio); + } else { + xpt_print_path(periph->path); + printf("Synchronize cache failed, status " + "== 0x%x, scsi status == 0x%x\n", + ccb.ccb_h.status, ccb.csio.scsi_status); + } + } -#define DA_CDEV_MAJOR 13 + if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0) + cam_release_devq(ccb.ccb_h.path, + /*relsim_flags*/0, + /*reduction*/0, + /*timeout*/0, + /*getcount_only*/0); -/* For 2.2-stable support */ -#ifndef D_DISK -#define D_DISK 0 -#endif + } +} -static struct cdevsw da_cdevsw = { - /* open */ daopen, - /* close */ daclose, - /* read */ physread, - /* write */ physwrite, - /* ioctl */ daioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ dastrategy, - /* name */ "da", - /* maj */ DA_CDEV_MAJOR, - /* dump */ dadump, - /* psize */ nopsize, - /* flags */ D_DISK, -}; +#else /* !_KERNEL */ -static struct cdevsw dadisk_cdevsw; - -static SLIST_HEAD(,da_softc) softc_list; -static struct extend_array *daperiphs; - -static int -daopen(dev_t dev, int flags __unused, int fmt __unused, struct thread *td __unused) +/* + * XXX This is only left out of the kernel build to silence warnings. If, + * for some reason this function is used in the kernel, the ifdefs should + * be moved so it is included both in the kernel and userland. + */ +void +scsi_format_unit(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t byte2, u_int16_t ileave, + u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout) { - struct cam_periph *periph; - struct da_softc *softc; - struct disklabel *label; - struct scsi_read_capacity_data *rcap; - union ccb *ccb; - int unit; - int part; - int error; - int s; + struct scsi_format_unit *scsi_cmd; - unit = dkunit(dev); - part = dkpart(dev); - s = splsoftcam(); - periph = cam_extend_get(daperiphs, unit); - if (periph == NULL) { - splx(s); - return (ENXIO); - } + scsi_cmd = (struct scsi_format_unit *)&csio->cdb_io.cdb_bytes; + scsi_cmd->opcode = FORMAT_UNIT; + scsi_cmd->byte2 = byte2; + scsi_ulto2b(ileave, scsi_cmd->interleave); - softc = (struct da_softc *)periph->softc; + cam_fill_csio(csio, + retries, + cbfcnp, + /*flags*/ (dxfer_len > 0) ? CAM_DIR_OUT : CAM_DIR_NONE, + tag_action, + data_ptr, + dxfer_len, + sense_len, + sizeof(*scsi_cmd), + timeout); +} - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, - ("daopen: dev=%s (unit %d , partition %d)\n", devtoname(dev), - unit, part)); - - if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) - return (error); /* error code from tsleep */ - - if (cam_periph_acquire(periph) != CAM_REQ_CMP) - return(ENXIO); - softc-+#endif /* _KERNEL */ ==== //depot/projects/kse/sys/dev/ppbus/ppi.c#6 (text+ko) ==== @@ -544,20 +544,35 @@ case PPISECR: /* set ECP bits */ ppb_wecr(ppbus, *val); break; - case PPISFIFO: /* write FIFO (pdq->pdq_host_smt_info.rx_completion << 8)); - } - pdq->pdq_command_info.ci_pending_commands = PDQ_BITMASK(PDQC_FILTER_SET) - | PDQ_BITMASK(PDQC_ADDR_FILTER_SET) - | PDQ_BITMASK(PDQC_SNMP_SET) - | PDQ_BITMASK(PDQC_START); - if (pdq->pdq_flags & PDQ_PRINTCHARS) - pdq->pdq_command_info.ci_pending_commands |= PDQ_BITMASK(PDQC_STATUS_CHARS_GET); - pdq_queue_commands(pdq); - break; + case PPISFIFO: /* write FIFO */ + ppb_wfifo(ppbus, *val); + break; + case PPIGEPPA: /* get EPP address bits */ + *val = ppb_repp_A(ppbus); + break; + case PPISEPPA: /* set EPP address bits */ + ppb_wepp_A(ppbus, *val); + break; + default: + error = ENOTTY; + break; } - case PDQS_LINK_UNAVAILABLE: - case PDQS_LINK_AVAILABLE: { - pdq->pdq_command_info.ci_pending_commands = PDQ_BITMASK(PDQC_FILTER_SET) - | PDQ_BITMASK(PDQC_ADDR_FILTER_SET) - | PDQ_BITMASK(PDQC_SNMP_SET); - + + return (error); +} + +static device_method_t ppi_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, ppi_identify), + DEVMETHOD(device_probe, ppi_probe), + DEVMETHOD(device_attach, ppi_attach), + + { 0, 0 } +}; + +static driver_t ppi_driver = { + "ppi", + ppi_methods, + sizeof(struct ppi_data), +}; +DRIVER_MODULE(ppi, ppbus, ppi_driver, ppi_devclass, 0, 0); ==== //depot/projects/kse/sys/dev/usb/ugen.c#14 (text+ko) ==== @@ -953,145 +953,169 @@ buf += n; actlen -= n; sce->fill += n; - if(sce->fi - u_int8_t ret; - - if (ufm_do_req(sc, UT_READ_VENDOR_DEVICE, FM_CMD0, 0x16, 0x1C, - 1, &ret)) - return (EIO); - if (ufm_do_req(sc, UT_READ_VENDOR_DEVICE, FM_CMD2, 0x00, 0x00, - 1, &ret)) - return (EIO); - return (0); + if(sce->fill == sce->limit) + sce->fill = sce->ibuf; + } + + /* setup size for next transfer */ + req->sizes[i] = isize; + } + + usbd_setup_isoc_xfer(xfer, sce->pipeh, req, req->sizes, UGEN_NISORFRMS, + USBD_NO_COPY, ugen_isoc_rintr); + (void)usbd_transfer(xfer); + + if (sce->state & UGEN_ASLP) { + sce->state &= ~UGEN_ASLP; + DPRINTFN(5, ("ugen_isoc_rintr: waking %p\n", sce)); + wakeup(sce); + } + selwakeup(&sce->rsel); } -static int -ufm_get_stat(struct ufm_softc *sc, caddr_t addr) +Static usbd_status +ugen_set_interface(struct ugen_softc *sc, int ifaceidx, int altno) { - u_int8_t ret; - - /* - * Note, there's a 240ms settle time before the status - * will be valid, so tsleep that amount. hz/4 is a good - * approximation of that. Since this is a short sleep - * we don't try to catch any signals to keep things - * simple. - */ - tsleep(sc, 0, "ufmwait", hz/4); - if (ufm_do_req(sc, UT_READ_VENDOR_DEVICE, FM_CMD0, 0x00, 0x24, - 1, &ret)) - return (EIO); - *(int *)addr = ret; - - return (0); -} + usbd_interface_handle iface; + usb_endpoint_descriptor_t *ed; + usbd_status err; + struct ugen_endpoint *sce; + u_int8_t niface, nendpt, endptno, endpt; + int dir; -int -ufmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, usb_proc_ptr td) -{ - struct ufm_softc *sc; + DPRINTFN(15, ("ugen_set_interface %d %d\n", ifaceidx, altno)); - int unit = UFMUNIT(dev); - int error = 0; + err = usbd_interface_count(sc->sc_udev, &niface); + if (err) + return (err); + if (ifaceidx < 0 || ifaceidx >= niface) + return (USBD_INVAL); + + err = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface); + if (err) + return (err); + err = usbd_endpoint_count(iface, &nendpt); + if (err) + return (err); + /* XXX should only do this after setting new altno has succeeded */ + for (endptno = 0; endptno < nendpt; endptno++) { + ed = usbd_interface2endpoint_descriptor(iface,endptno); + endpt = ed->bEndpointAddress; + dir = UE_GET_DIR(endpt) == UE_DIR_IN ? IN : OUT; + sce = &sc->sc_endpoints[UE_GET_ADDR(endpt)][dir]; + sce->sc = 0; + sce->edesc = 0; + sce->iface = 0; + } - USB_GET_SC(ufm, unit, sc); + /* change setting */ + err = usbd_set_interface(iface, altno); + if (err) + return (err); - switch (cmd) { - case FM_SET_FREQ: - error = ufm_set_freq(sc, addr); - break; - case FM_GET_FREQ: - error = ufm_get_freq(sc, addr); - break; - case FM_START: - error = ufm_start(sc, addr); - break; - case FM_STOP: - error = ufm_stop(sc, addr); - break; - case FM_GET_STAT: - error = ufm_get_stat(sc, addr); - break; - default: - return ENOTTY; - break; + err = usbd_endpoint_count(iface, &nendpt); + if (err) + return (err); + for (endptno = 0; endptno < nendpt; endptno++) { + ed = usbd_interface2endpoint_descriptor(iface,endptno); + endpt = ed->bEndpointAddress; + dir = UE_GET_DIR(endpt) == UE_DIR_IN ? IN : OUT; + sce = &sc->sc_endpoints[UE_GET_ADDR(endpt)][dir]; + sce->sc = sc; + sce->edesc = ed; + sce->iface = iface; } - return error; + return (0); } - -#if defined(__NetBSD__) || defined(__OpenBSD__) -int -ufm_activate(device_ptr_t self, enum devact act) +/* Retrieve a complete descriptor for a certain device and index. */ +Static usb_config_descriptor_t * +ugen_get_cdesc(struct ugen_softc *sc, int index, int *lenp) { - struct ufm_softc *sc = (struct ufm_softc *)self; + usb_config_descriptor_t *cdesc, *tdesc, cdescr; + int len; + usbd_status err; - switch (act) { - case DVACT_ACTIVATE: - return (EOPNOTSUPP); - break; - - case DVACT_DEACTIVATE: - sc->sc_dying = 1; - break; + if (index == USB_CURRENT_CONFIG_INDEX) { + tdesc = usbd_get_config_descriptor(sc->sc_udev); + len = UGETW(tdesc->wTotalLength); + if (lenp) + *lenp = len; + cdesc = malloc(len, M_TEMP, M_WAITOK); + memcpy(cdesc, tdesc, len); + DPRINTFN(5,("ugen_get_cdesc: current, len=%d\n", len)); + } else { + err = usbd_get_config_desc(sc->sc_udev, index, &cdescr); + if (err) + return (0); + len = UGETW(cdescr.wTotalLength); + DPRINTFN(5,("ugen_get_cdesc: index=%d, len=%d\n", index, len)); + if (lenp) + *lenp = len; + cdesc = malloc(len, M_TEMP, M_WAITOK); + err = usbd_get_config_desc_full(sc->sc_udev, index, cdesc, len); + if (err) { + free(cdesc, M_TEMP); + return (0); + } } - return (0); + return (cdesc); } -USB_DETACH(ufm) +Static int +ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx) { - USB_DETACH_START(ufm, sc); - struct ufm_endpoint *sce; - int i, dir; - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - int maj, mn; + usbd_interface_handle iface; + usbd_status err; - DPRINTF(("ufm_detach: sc=%p flags=%d\n", sc, flags)); -#elif defined(__FreeBSD__) - DPRINTF(("ufm_detach: sc=%p\n", sc)); -#endif + err = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface); + if (err) + return (-1); + return (usbd_get_interface_altindex(iface)); +} - sc->sc_dying = 1; +Static int +ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, + caddr_t addr, int flag, usb_proc_ptr p) +{ + struct ugen_endpoint *sce; + usbd_status err; + usbd_interface_handle iface; + struct usb_config_desc *cd; + usb_config_descriptor_t *cdesc; + struct usb_interface_desc *id; + usb_interface_descriptor_t *idesc; + struct usb_endpoint_desc *ed; + usb_endpoint_descriptor_t *edesc; + struct usb_alt_interface *ai; + struct usb_string_desc *si; + u_int8_t conf, alt; - s = splusb(); - if (--sc->sc_refcnt >= 0) { - /* Wait for processes to go away. */ - usb_detach_wait(USBDEV(sc->sc_dev)); - } - splx(s); + DPRINTFN(5, ("ugenioctl: cmd=%08lx\n", cmd)); + if (sc->sc_dying) + return (EIO); -#if defined(__NetBSD__) || defined(__OpenBSD__) - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == ufmopen) - break; + switch (cmd) { + case FIONBIO: + /* All handled in the upper FS layer. */ + return (0); + case USB_SET_SHORT_XFER: + /* This flag only affects read */ + if (endpt == USB_CONTROL_ENDPOINT) + return (EINVAL); + sce = &sc->sc_endpoints[endpt][IN]; + if (sce == NULL) + return (EINVAL); - /* Nuke the vnodes for any open instances (calls close). */ - mn = self->dv_unit * USB_MAX_ENDPOINTS; - vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR); -#elif defined(__FreeBSD__) - /* XXX not implemented yet */ -#endif + if (sce->pipeh == NULL) { + printf("ugenioctl: USB_SET_SHORT_XFER, no pipe\n"); + return (EIO); + } - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, - USBDEV(sc->sc_dev)); - - return (0); -} -#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ - -#if defined(__FreeBSD__) -Static int -ufm_detach(device_t self) -{ - DPRINTF(("%s: disconnected\n", USBDEVNAME(self))); - return 0; -} - -DRIVER_MODULE(ufm, uhub, ufm_driver, ufm_devclass, usbd_driver_load, 0); -#endif - state &= ~UGEN_SHORT_OK; + if (*(int *)addr) + sce->state |= UGEN_SHORT_OK; + else + sce->state &= ~UGEN_SHORT_OK; return (0); case USB_SET_TIMEOUT: sce = &sc->sc_endpoints[endpt][IN]; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message