这篇教程C++ DPRINTFN函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DPRINTFN函数的典型用法代码示例。如果您正苦于以下问题:C++ DPRINTFN函数的具体用法?C++ DPRINTFN怎么用?C++ DPRINTFN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DPRINTFN函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: urioioctlinturioioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p){ struct urio_softc * sc; int unit = URIOUNIT(dev); struct urio_command *rcmd; int requesttype, len; struct iovec iov; struct uio uio; usb_device_request_t req; usbd_status err; u_int32_t req_actlen = 0; void *ptr = NULL; int error = 0; sc = urio_cd.cd_devs[unit]; if (usbd_is_dying(sc->sc_udev)) return (EIO); rcmd = (struct urio_command *)addr; switch (cmd) { case URIO_RECV_COMMAND: requesttype = rcmd->requesttype | UT_READ_VENDOR_DEVICE; break; case URIO_SEND_COMMAND: requesttype = rcmd->requesttype | UT_WRITE_VENDOR_DEVICE; break; default: return (EINVAL); break; } if (!(flag & FWRITE)) return (EPERM); len = rcmd->length; DPRINTFN(1,("urio_ioctl: cmd=0x%08lx reqtype=0x%0x req=0x%0x " "value=0x%0x index=0x%0x len=0x%0x/n", cmd, requesttype, rcmd->request, rcmd->value, rcmd->index, len)); /* Send rio control message */ req.bmRequestType = requesttype; req.bRequest = rcmd->request; USETW(req.wValue, rcmd->value); USETW(req.wIndex, rcmd->index); USETW(req.wLength, len); if (len < 0 || len > 32767) return (EINVAL); if (len != 0) { iov.iov_base = (caddr_t)rcmd->buffer; iov.iov_len = len; uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_resid = len; uio.uio_offset = 0; uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = req.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; uio.uio_procp = p; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); if (error) goto ret; } } sc->sc_refcnt++; err = usbd_do_request_flags(sc->sc_udev, &req, ptr, 0, &req_actlen, USBD_DEFAULT_TIMEOUT); if (--sc->sc_refcnt < 0) usb_detach_wakeup(&sc->sc_dev); if (err) { error = EIO; } else { if (req_actlen != 0 && uio.uio_rw == UIO_READ) error = uiomove(ptr, req_actlen, &uio); }ret: if (ptr != NULL) free(ptr, M_TEMP); return (error);}
开发者ID:appleorange1,项目名称:bitrig,代码行数:93,
示例2: usb_pc_common_mem_cb/*------------------------------------------------------------------------* * usb_pc_common_mem_cb - BUS-DMA callback function *------------------------------------------------------------------------*/static voidusb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error, uint8_t isload){ struct usb_dma_parent_tag *uptag; struct usb_page_cache *pc; struct usb_page *pg; usb_size_t rem; bus_size_t off; uint8_t owned; pc = arg; uptag = pc->tag_parent; /* * XXX There is sometimes recursive locking here. * XXX We should try to find a better solution. * XXX Until further the "owned" variable does * XXX the trick. */ if (error) { goto done; } off = 0; pg = pc->page_start; pg->physaddr = segs->ds_addr & ~(USB_PAGE_SIZE - 1); rem = segs->ds_addr & (USB_PAGE_SIZE - 1); pc->page_offset_buf = rem; pc->page_offset_end += rem;#ifdef USB_DEBUG if (rem != (USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1))) { /* * This check verifies that the physical address is correct: */ DPRINTFN(0, "Page offset was not preserved/n"); error = 1; goto done; }#endif while (pc->ismultiseg) { off += USB_PAGE_SIZE; if (off >= (segs->ds_len + rem)) { /* page crossing */ nseg--; segs++; off = 0; rem = 0; if (nseg == 0) break; } pg++; pg->physaddr = (segs->ds_addr + off) & ~(USB_PAGE_SIZE - 1); }done: owned = mtx_owned(uptag->mtx); if (!owned) mtx_lock(uptag->mtx); uptag->dma_error = (error ? 1 : 0); if (isload) { (uptag->func) (uptag); } else { cv_broadcast(uptag->cv); } if (!owned) mtx_unlock(uptag->mtx);}
开发者ID:ragunath3252,项目名称:patch-rtems,代码行数:73,
示例3: udsir_read/* ARGSUSED */static intudsir_read(void *h, struct uio *uio, int flag){ struct udsir_softc *sc = h; int s; int error; u_int uframelen; DPRINTFN(1, ("%s: sc=%p/n", __func__, sc)); if (sc->sc_dying) return EIO;#ifdef DIAGNOSTIC if (sc->sc_rd_buf == NULL) return EINVAL;#endif sc->sc_refcnt++; if (!sc->sc_rd_readinprogress && !UDSIR_BLOCK_RX_DATA(sc)) /* Possibly wake up polling thread */ wakeup(&sc->sc_thread); do { s = splusb(); while (sc->sc_ur_framelen == 0) { DPRINTFN(5, ("%s: calling tsleep()/n", __func__)); error = tsleep(&sc->sc_ur_framelen, PZERO | PCATCH, "usirrd", 0); if (sc->sc_dying) error = EIO; if (error) { splx(s); DPRINTFN(0, ("%s: tsleep() = %d/n", __func__, error)); goto ret; } } splx(s); uframelen = sc->sc_ur_framelen; DPRINTFN(1, ("%s: sc=%p framelen=%u, hdr=0x%02x/n", __func__, sc, uframelen, sc->sc_ur_buf[0])); if (uframelen > uio->uio_resid) error = EINVAL; else error = uiomove(sc->sc_ur_buf, uframelen, uio); sc->sc_ur_framelen = 0; if (deframe_rd_ur(sc) == 0 && uframelen > 0) { /* * Need to wait for another read to obtain a * complete frame... If we also obtained * actual data, wake up the possibly sleeping * thread immediately... */ wakeup(&sc->sc_thread); } } while (uframelen == 0); DPRINTFN(1, ("%s: return %d/n", __func__, error)); ret: if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); return error;}
开发者ID:ryo,项目名称:netbsd-src,代码行数:69,
示例4: udsir_rd_cbstatic voidudsir_rd_cb(struct usbd_xfer *xfer, void * priv, usbd_status status){ struct udsir_softc *sc = priv; uint32_t size; DPRINTFN(60, ("%s: sc=%p/n", __func__, sc)); /* Read is no longer in progress */ sc->sc_rd_readinprogress = 0; if (status == USBD_CANCELLED || sc->sc_closing) /* this is normal */ return; if (status) { size = 0; sc->sc_rd_err = 1; if (sc->sc_direction == udir_input || sc->sc_direction == udir_idle) { /* * Receive error, probably need to clear error * condition. */ sc->sc_direction = udir_stalled; } } else usbd_get_xfer_status(xfer, NULL, NULL, &size, NULL); sc->sc_rd_index = 0; sc->sc_rd_count = size; DPRINTFN(((size > 0 || sc->sc_rd_err != 0) ? 20 : 60), ("%s: sc=%p size=%u, err=%d/n", __func__, sc, size, sc->sc_rd_err));#ifdef UDSIR_DEBUG if (udsirdebug >= 20 && size > 0) udsir_dumpdata(sc->sc_rd_buf, size, __func__);#endif if (deframe_rd_ur(sc) == 0) { if (!deframe_isclear(&sc->sc_framestate) && size == 0 && sc->sc_rd_expectdataticks == 0) { /* * Expected data, but didn't get it * within expected time... */ DPRINTFN(5,("%s: incoming packet timeout/n", __func__)); deframe_clear(&sc->sc_framestate); } else if (size > 0) { /* * If we also received actual data, reset the * data read timeout and wake up the possibly * sleeping thread... */ sc->sc_rd_expectdataticks = 2; wakeup(&sc->sc_thread); } } /* * Check if incoming data has stopped, or that we cannot * safely read any more data. In the case of the latter we * must switch to idle so that a write will not block... */ if (sc->sc_direction == udir_input && ((size == 0 && sc->sc_rd_expectdataticks == 0) || UDSIR_BLOCK_RX_DATA(sc))) { DPRINTFN(8, ("%s: idling on packet timeout, " "complete frame, or no data/n", __func__)); sc->sc_direction = udir_idle; /* Wake up for possible output */ wakeup(&sc->sc_wr_buf); selnotify(&sc->sc_wr_sel, 0, 0); }}
开发者ID:ryo,项目名称:netbsd-src,代码行数:78,
示例5: cdce_attachstatic intcdce_attach(device_t dev){ struct cdce_softc *sc = device_get_softc(dev); struct usb_ether *ue = &sc->sc_ue; struct usb_attach_arg *uaa = device_get_ivars(dev); struct usb_interface *iface; const struct usb_cdc_union_descriptor *ud; const struct usb_interface_descriptor *id; const struct usb_cdc_ethernet_descriptor *ued; const struct usb_config *pcfg; int error; uint8_t i; uint8_t data_iface_no; char eaddr_str[5 * ETHER_ADDR_LEN]; /* approx */ sc->sc_flags = USB_GET_DRIVER_INFO(uaa); sc->sc_ue.ue_udev = uaa->device; device_set_usb_desc(dev); mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); ud = usbd_find_descriptor (uaa->device, NULL, uaa->info.bIfaceIndex, UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_UNION, 0 - 1); if ((ud == NULL) || (ud->bLength < sizeof(*ud)) || (sc->sc_flags & CDCE_FLAG_NO_UNION)) { DPRINTFN(1, "No union descriptor!/n"); sc->sc_ifaces_index[0] = uaa->info.bIfaceIndex; sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex; goto alloc_transfers; } data_iface_no = ud->bSlaveInterface[0]; for (i = 0;; i++) { iface = usbd_get_iface(uaa->device, i); if (iface) { id = usbd_get_interface_descriptor(iface); if (id && (id->bInterfaceNumber == data_iface_no)) { sc->sc_ifaces_index[0] = i; sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex; usbd_set_parent_iface(uaa->device, i, uaa->info.bIfaceIndex); break; } } else { device_printf(dev, "no data interface found/n"); goto detach; } } /* * <quote> * * The Data Class interface of a networking device shall have * a minimum of two interface settings. The first setting * (the default interface setting) includes no endpoints and * therefore no networking traffic is exchanged whenever the * default interface setting is selected. One or more * additional interface settings are used for normal * operation, and therefore each includes a pair of endpoints * (one IN, and one OUT) to exchange network traffic. Select * an alternate interface setting to initialize the network * aspects of the device and to enable the exchange of * network traffic. * * </quote> * * Some devices, most notably cable modems, include interface * settings that have no IN or OUT endpoint, therefore loop * through the list of all available interface settings * looking for one with both IN and OUT endpoints. */alloc_transfers: pcfg = cdce_config; /* Default Configuration */ for (i = 0; i != 32; i++) { error = usbd_set_alt_interface_index(uaa->device, sc->sc_ifaces_index[0], i); if (error) break;#if CDCE_HAVE_NCM if ((i == 0) && (cdce_ncm_init(sc) == 0)) pcfg = cdce_ncm_config;#endif error = usbd_transfer_setup(uaa->device, sc->sc_ifaces_index, sc->sc_xfer, pcfg, CDCE_N_TRANSFER, sc, &sc->sc_mtx); if (error == 0) break; }//.........这里部分代码省略.........
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:101,
示例6: cdce_bulk_write_callbackstatic voidcdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error){ struct cdce_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct mbuf *m; struct mbuf *mt; uint32_t crc; uint8_t x; int actlen, aframes; usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL); DPRINTFN(1, "/n"); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete: %u bytes in %u frames/n", actlen, aframes); ifp->if_opackets++; /* free all previous TX buffers */ cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); /* FALLTHROUGH */ case USB_ST_SETUP:tr_setup: for (x = 0; x != CDCE_FRAMES_MAX; x++) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m); if (m == NULL) break; if (sc->sc_flags & CDCE_FLAG_ZAURUS) { /* * Zaurus wants a 32-bit CRC appended * to every frame */ crc = cdce_m_crc32(m, 0, m->m_pkthdr.len); crc = htole32(crc); if (!m_append(m, 4, (void *)&crc)) { m_freem(m); ifp->if_oerrors++; continue; } } if (m->m_len != m->m_pkthdr.len) { mt = m_defrag(m, M_DONTWAIT); if (mt == NULL) { m_freem(m); ifp->if_oerrors++; continue; } m = mt; } if (m->m_pkthdr.len > MCLBYTES) { m->m_pkthdr.len = MCLBYTES; } sc->sc_tx_buf[x] = m; usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len); /* * If there's a BPF listener, bounce a copy of * this frame to him: */ BPF_MTAP(ifp, m); } if (x != 0) { usbd_xfer_set_frames(xfer, x); usbd_transfer_submit(xfer); } break; default: /* Error */ DPRINTFN(11, "transfer error, %s/n", usbd_errstr(error)); /* free all previous TX buffers */ cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); /* count output errors */ ifp->if_oerrors++; if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ usbd_xfer_set_stall(xfer); goto tr_setup; } break; }}
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:96,
示例7: cdce_ncm_bulk_read_callbackstatic voidcdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error){ struct cdce_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0); struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct mbuf *m; int sumdata; int sumlen; int actlen; int aframes; int temp; int nframes; int x; int offset; switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: usbd_xfer_status(xfer, &actlen, &sumlen, &aframes, NULL); DPRINTFN(1, "received %u bytes in %u frames/n", actlen, aframes); if (actlen < (sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt))) { DPRINTFN(1, "frame too short/n"); goto tr_setup; } usbd_copy_out(pc, 0, &(sc->sc_ncm.hdr), sizeof(sc->sc_ncm.hdr)); if ((sc->sc_ncm.hdr.dwSignature[0] != 'N') || (sc->sc_ncm.hdr.dwSignature[1] != 'C') || (sc->sc_ncm.hdr.dwSignature[2] != 'M') || (sc->sc_ncm.hdr.dwSignature[3] != 'H')) { DPRINTFN(1, "invalid HDR signature: " "0x%02x:0x%02x:0x%02x:0x%02x/n", sc->sc_ncm.hdr.dwSignature[0], sc->sc_ncm.hdr.dwSignature[1], sc->sc_ncm.hdr.dwSignature[2], sc->sc_ncm.hdr.dwSignature[3]); goto tr_stall; } temp = UGETW(sc->sc_ncm.hdr.wBlockLength); if (temp > sumlen) { DPRINTFN(1, "unsupported block length %u/%u/n", temp, sumlen); goto tr_stall; } temp = UGETW(sc->sc_ncm.hdr.wDptIndex); if ((temp + sizeof(sc->sc_ncm.dpt)) > actlen) { DPRINTFN(1, "invalid DPT index: 0x%04x/n", temp); goto tr_stall; } usbd_copy_out(pc, temp, &(sc->sc_ncm.dpt), sizeof(sc->sc_ncm.dpt)); if ((sc->sc_ncm.dpt.dwSignature[0] != 'N') || (sc->sc_ncm.dpt.dwSignature[1] != 'C') || (sc->sc_ncm.dpt.dwSignature[2] != 'M') || (sc->sc_ncm.dpt.dwSignature[3] != '0')) { DPRINTFN(1, "invalid DPT signature" "0x%02x:0x%02x:0x%02x:0x%02x/n", sc->sc_ncm.dpt.dwSignature[0], sc->sc_ncm.dpt.dwSignature[1], sc->sc_ncm.dpt.dwSignature[2], sc->sc_ncm.dpt.dwSignature[3]); goto tr_stall; } nframes = UGETW(sc->sc_ncm.dpt.wLength) / 4; /* Subtract size of header and last zero padded entry */ if (nframes >= (2 + 1)) nframes -= (2 + 1); else nframes = 0; DPRINTFN(1, "nframes = %u/n", nframes); temp += sizeof(sc->sc_ncm.dpt); if ((temp + (4 * nframes)) > actlen) goto tr_stall; if (nframes > CDCE_NCM_SUBFRAMES_MAX) { DPRINTFN(1, "Truncating number of frames from %u to %u/n", nframes, CDCE_NCM_SUBFRAMES_MAX); nframes = CDCE_NCM_SUBFRAMES_MAX; } usbd_copy_out(pc, temp, &(sc->sc_ncm.dp), (4 * nframes)); sumdata = 0; for (x = 0; x != nframes; x++) { offset = UGETW(sc->sc_ncm.dp[x].wFrameIndex); temp = UGETW(sc->sc_ncm.dp[x].wFrameLength); if ((offset == 0) ||//.........这里部分代码省略.........
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:101,
示例8: cdce_ncm_init/*------------------------------------------------------------------------* * cdce_ncm_init * * Return values: * 0: Success * Else: Failure *------------------------------------------------------------------------*/static uint8_tcdce_ncm_init(struct cdce_softc *sc){ struct usb_ncm_parameters temp; struct usb_device_request req; struct usb_ncm_func_descriptor *ufd; uint8_t value[8]; int err; ufd = usbd_find_descriptor(sc->sc_ue.ue_udev, NULL, sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0 - 1, UCDC_NCM_FUNC_DESC_SUBTYPE, 0 - 1); /* verify length of NCM functional descriptor */ if (ufd != NULL) { if (ufd->bLength < sizeof(*ufd)) ufd = NULL; else DPRINTFN(1, "Found NCM functional descriptor./n"); } req.bmRequestType = UT_READ_CLASS_INTERFACE; req.bRequest = UCDC_NCM_GET_NTB_PARAMETERS; USETW(req.wValue, 0); req.wIndex[0] = sc->sc_ifaces_index[1]; req.wIndex[1] = 0; USETW(req.wLength, sizeof(temp)); err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req, &temp, 0, NULL, 1000 /* ms */); if (err) return (1); /* Read correct set of parameters according to device mode */ if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { sc->sc_ncm.rx_max = UGETDW(temp.dwNtbInMaxSize); sc->sc_ncm.tx_max = UGETDW(temp.dwNtbOutMaxSize); sc->sc_ncm.tx_remainder = UGETW(temp.wNdpOutPayloadRemainder); sc->sc_ncm.tx_modulus = UGETW(temp.wNdpOutDivisor); sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpOutAlignment); sc->sc_ncm.tx_nframe = UGETW(temp.wNtbOutMaxDatagrams); } else { sc->sc_ncm.rx_max = UGETDW(temp.dwNtbOutMaxSize); sc->sc_ncm.tx_max = UGETDW(temp.dwNtbInMaxSize); sc->sc_ncm.tx_remainder = UGETW(temp.wNdpInPayloadRemainder); sc->sc_ncm.tx_modulus = UGETW(temp.wNdpInDivisor); sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpInAlignment); sc->sc_ncm.tx_nframe = UGETW(temp.wNtbOutMaxDatagrams); } /* Verify maximum receive length */ if ((sc->sc_ncm.rx_max < 32) || (sc->sc_ncm.rx_max > CDCE_NCM_RX_MAXLEN)) { DPRINTFN(1, "Using default maximum receive length/n"); sc->sc_ncm.rx_max = CDCE_NCM_RX_MAXLEN; } /* Verify maximum transmit length */ if ((sc->sc_ncm.tx_max < 32) || (sc->sc_ncm.tx_max > CDCE_NCM_TX_MAXLEN)) { DPRINTFN(1, "Using default maximum transmit length/n"); sc->sc_ncm.tx_max = CDCE_NCM_TX_MAXLEN; } /* * Verify that the structure alignment is: * - power of two * - not greater than the maximum transmit length * - not less than four bytes */ if ((sc->sc_ncm.tx_struct_align < 4) || (sc->sc_ncm.tx_struct_align != ((-sc->sc_ncm.tx_struct_align) & sc->sc_ncm.tx_struct_align)) || (sc->sc_ncm.tx_struct_align >= sc->sc_ncm.tx_max)) { DPRINTFN(1, "Using default other alignment: 4 bytes/n"); sc->sc_ncm.tx_struct_align = 4; } /* * Verify that the payload alignment is: * - power of two * - not greater than the maximum transmit length * - not less than four bytes */ if ((sc->sc_ncm.tx_modulus < 4) || (sc->sc_ncm.tx_modulus != ((-sc->sc_ncm.tx_modulus) & sc->sc_ncm.tx_modulus)) || (sc->sc_ncm.tx_modulus >= sc->sc_ncm.tx_max)) { DPRINTFN(1, "Using default transmit modulus: 4 bytes/n"); sc->sc_ncm.tx_modulus = 4;//.........这里部分代码省略.........
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:101,
示例9: cdce_ncm_fill_tx_framesstatic uint8_tcdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index){ struct cdce_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, index); struct mbuf *m; uint32_t rem; uint32_t offset; uint32_t last_offset; uint16_t n; uint8_t retval; usbd_xfer_set_frame_offset(xfer, index * CDCE_NCM_TX_MAXLEN, index); offset = sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt) + sizeof(sc->sc_ncm.dp); /* Store last valid offset before alignment */ last_offset = offset; /* Align offset */ offset = CDCE_NCM_ALIGN(sc->sc_ncm.tx_remainder, offset, sc->sc_ncm.tx_modulus); /* Zero pad */ cdce_ncm_tx_zero(pc, last_offset, offset); /* buffer full */ retval = 2; for (n = 0; n != sc->sc_ncm.tx_nframe; n++) { /* check if end of transmit buffer is reached */ if (offset >= sc->sc_ncm.tx_max) break; /* compute maximum buffer size */ rem = sc->sc_ncm.tx_max - offset; IFQ_DRV_DEQUEUE(&(ifp->if_snd), m); if (m == NULL) { /* buffer not full */ retval = 1; break; } if (m->m_pkthdr.len > rem) { if (n == 0) { /* The frame won't fit in our buffer */ DPRINTFN(1, "Frame too big to be transmitted!/n"); m_freem(m); ifp->if_oerrors++; n--; continue; } /* Wait till next buffer becomes ready */ IFQ_DRV_PREPEND(&(ifp->if_snd), m); break; } usbd_m_copy_in(pc, offset, m, 0, m->m_pkthdr.len); USETW(sc->sc_ncm.dp[n].wFrameLength, m->m_pkthdr.len); USETW(sc->sc_ncm.dp[n].wFrameIndex, offset); /* Update offset */ offset += m->m_pkthdr.len; /* Store last valid offset before alignment */ last_offset = offset; /* Align offset */ offset = CDCE_NCM_ALIGN(sc->sc_ncm.tx_remainder, offset, sc->sc_ncm.tx_modulus); /* Zero pad */ cdce_ncm_tx_zero(pc, last_offset, offset); /* * If there's a BPF listener, bounce a copy * of this frame to him: */ BPF_MTAP(ifp, m); /* Free mbuf */ m_freem(m); /* Pre-increment interface counter */ ifp->if_opackets++; } if (n == 0) return (0); rem = (sizeof(sc->sc_ncm.dpt) + (4 * n) + 4);//.........这里部分代码省略.........
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:101,
示例10: udsir_detachstatic intudsir_detach(device_t self, int flags){ struct udsir_softc *sc = device_private(self); int s; int rv = 0; DPRINTFN(0, ("udsir_detach: sc=%p flags=%d/n", sc, flags)); sc->sc_closing = sc->sc_dying = 1; wakeup(&sc->sc_thread); while (sc->sc_thread != NULL) tsleep(&sc->sc_closing, PWAIT, "usircl", 0); /* Abort all pipes. Causes processes waiting for transfer to wake. */ if (sc->sc_rd_pipe != NULL) { usbd_abort_pipe(sc->sc_rd_pipe); } if (sc->sc_wr_pipe != NULL) { usbd_abort_pipe(sc->sc_wr_pipe); } if (sc->sc_rd_xfer != NULL) { usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } /* Close pipes. */ if (sc->sc_rd_pipe != NULL) { usbd_close_pipe(sc->sc_rd_pipe); sc->sc_rd_pipe = NULL; } if (sc->sc_wr_pipe != NULL) { usbd_close_pipe(sc->sc_wr_pipe); sc->sc_wr_pipe = NULL; } wakeup(&sc->sc_ur_framelen); wakeup(&sc->sc_wr_buf); s = splusb(); if (--sc->sc_refcnt >= 0) { /* Wait for processes to go away. */ usb_detach_waitold(sc->sc_dev); } splx(s); if (sc->sc_child != NULL) rv = config_detach(sc->sc_child, flags); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); seldestroy(&sc->sc_rd_sel); seldestroy(&sc->sc_wr_sel); return rv;}
开发者ID:ryo,项目名称:netbsd-src,代码行数:62,
示例11: uftdi_paramintuftdi_param(void *vsc, int portno, struct termios *t){ struct uftdi_softc *sc = vsc; usb_device_request_t req; usbd_status err; int rate, data, flow; DPRINTF(("uftdi_param: sc=%p/n", sc)); if (usbd_is_dying(sc->sc_udev)) return (EIO); switch (sc->sc_type) { case UFTDI_TYPE_SIO: switch (t->c_ospeed) { case 300: rate = ftdi_sio_b300; break; case 600: rate = ftdi_sio_b600; break; case 1200: rate = ftdi_sio_b1200; break; case 2400: rate = ftdi_sio_b2400; break; case 4800: rate = ftdi_sio_b4800; break; case 9600: rate = ftdi_sio_b9600; break; case 19200: rate = ftdi_sio_b19200; break; case 38400: rate = ftdi_sio_b38400; break; case 57600: rate = ftdi_sio_b57600; break; case 115200: rate = ftdi_sio_b115200; break; default: return (EINVAL); } break; case UFTDI_TYPE_8U232AM: if (uftdi_8u232am_getrate(t->c_ospeed, &rate) == -1) return (EINVAL); break; case UFTDI_TYPE_2232H: if (uftdi_2232h_getrate(t->c_ospeed, &rate) == -1) return (EINVAL); break; } req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = FTDI_SIO_SET_BAUD_RATE; USETW(req.wValue, rate); USETW(req.wIndex, ((rate >> 8) & 0xFF00) | portno); USETW(req.wLength, 0); DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x " "index=0x%04x len=%d/n", req.bmRequestType, req.bRequest, UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength))); err = usbd_do_request(sc->sc_udev, &req, NULL); if (err) return (EIO); if (ISSET(t->c_cflag, CSTOPB)) data = FTDI_SIO_SET_DATA_STOP_BITS_2; else data = FTDI_SIO_SET_DATA_STOP_BITS_1; if (ISSET(t->c_cflag, PARENB)) { if (ISSET(t->c_cflag, PARODD)) data |= FTDI_SIO_SET_DATA_PARITY_ODD; else data |= FTDI_SIO_SET_DATA_PARITY_EVEN; } else data |= FTDI_SIO_SET_DATA_PARITY_NONE; switch (ISSET(t->c_cflag, CSIZE)) { case CS5: data |= FTDI_SIO_SET_DATA_BITS(5); break; case CS6: data |= FTDI_SIO_SET_DATA_BITS(6); break; case CS7: data |= FTDI_SIO_SET_DATA_BITS(7); break; case CS8: data |= FTDI_SIO_SET_DATA_BITS(8); break; } sc->last_lcr = data; req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = FTDI_SIO_SET_DATA; USETW(req.wValue, data); USETW(req.wIndex, portno); USETW(req.wLength, 0); DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x " "index=0x%04x len=%d/n", req.bmRequestType, req.bRequest, UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength))); err = usbd_do_request(sc->sc_udev, &req, NULL); if (err) return (EIO); if (ISSET(t->c_cflag, CRTSCTS)) { flow = FTDI_SIO_RTS_CTS_HS; USETW(req.wValue, 0); } else if (ISSET(t->c_iflag, IXON|IXOFF)) { flow = FTDI_SIO_XON_XOFF_HS; USETW2(req.wValue, t->c_cc[VSTOP], t->c_cc[VSTART]); } else { flow = FTDI_SIO_DISABLE_FLOW_CTRL; USETW(req.wValue, 0);//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,
示例12: udsir_open/* ARGSUSED */static intudsir_open(void *h, int flag, int mode, struct lwp *l){ struct udsir_softc *sc = h; int error; usbd_status err; DPRINTFN(0, ("%s: sc=%p/n", __func__, sc)); err = usbd_open_pipe(sc->sc_iface, sc->sc_rd_addr, 0, &sc->sc_rd_pipe); if (err != USBD_NORMAL_COMPLETION) { error = EIO; goto bad1; } err = usbd_open_pipe(sc->sc_iface, sc->sc_wr_addr, 0, &sc->sc_wr_pipe); if (err != USBD_NORMAL_COMPLETION) { error = EIO; goto bad2; } error = usbd_create_xfer(sc->sc_rd_pipe, sc->sc_rd_maxpsz, USBD_SHORT_XFER_OK, 0, &sc->sc_rd_xfer); if (error) goto bad3; error = usbd_create_xfer(sc->sc_wr_pipe, IRDA_MAX_FRAME_SIZE, USBD_FORCE_SHORT_XFER, 0, &sc->sc_wr_xfer); if (error) goto bad4; sc->sc_rd_buf = usbd_get_buffer(sc->sc_rd_xfer); sc->sc_wr_buf = usbd_get_buffer(sc->sc_wr_xfer); sc->sc_ur_buf = kmem_alloc(IRDA_MAX_FRAME_SIZE, KM_SLEEP); if (sc->sc_ur_buf == NULL) { error = ENOMEM; goto bad5; } sc->sc_rd_index = sc->sc_rd_count = 0; sc->sc_closing = 0; sc->sc_rd_readinprogress = 0; sc->sc_rd_expectdataticks = 0; sc->sc_ur_framelen = 0; sc->sc_rd_err = 0; sc->sc_wr_stalewrite = 0; sc->sc_direction = udir_idle; sc->sc_params.speed = 0; sc->sc_params.ebofs = 0; sc->sc_params.maxsize = min(sc->sc_rd_maxpsz, sc->sc_wr_maxpsz); deframe_init(&sc->sc_framestate, sc->sc_ur_buf, IRDA_MAX_FRAME_SIZE); /* Increment reference for thread */ sc->sc_refcnt++; error = kthread_create(PRI_NONE, 0, NULL, udsir_thread, sc, &sc->sc_thread, "%s", device_xname(sc->sc_dev)); if (error) { sc->sc_refcnt--; goto bad5; } return 0; bad5: usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; bad4: usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; bad3: usbd_close_pipe(sc->sc_wr_pipe); sc->sc_wr_pipe = NULL; bad2: usbd_close_pipe(sc->sc_rd_pipe); sc->sc_rd_pipe = NULL; bad1: return error;}
开发者ID:ryo,项目名称:netbsd-src,代码行数:80,
示例13: uftdi_attachvoiduftdi_attach(struct device *parent, struct device *self, void *aux){ struct uftdi_softc *sc = (struct uftdi_softc *)self; struct usb_attach_arg *uaa = aux; struct usbd_device *dev = uaa->device; struct usbd_interface *iface; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; char *devname = sc->sc_dev.dv_xname; int i; usbd_status err; struct ucom_attach_args uca; DPRINTFN(10,("/nuftdi_attach: sc=%p/n", sc)); sc->sc_udev = dev; if (uaa->iface == NULL) { /* Move the device into the configured state. */ err = usbd_set_config_index(dev, UFTDI_CONFIG_INDEX, 1); if (err) { printf("%s: failed to set configuration, err=%s/n", sc->sc_dev.dv_xname, usbd_errstr(err)); goto bad; } err = usbd_device2interface_handle(dev, UFTDI_IFACE_INDEX, &iface); if (err) { printf("%s: failed to get interface, err=%s/n", sc->sc_dev.dv_xname, usbd_errstr(err)); goto bad; } } else iface = uaa->iface; id = usbd_get_interface_descriptor(iface); sc->sc_iface = iface; if (uaa->release < 0x0200) { sc->sc_type = UFTDI_TYPE_SIO; sc->sc_hdrlen = 1; } else if (uaa->release == 0x0700 || uaa->release == 0x0800) { sc->sc_type = UFTDI_TYPE_2232H; sc->sc_hdrlen = 0; } else { sc->sc_type = UFTDI_TYPE_8U232AM; sc->sc_hdrlen = 0; } uca.bulkin = uca.bulkout = -1; for (i = 0; i < id->bNumEndpoints; i++) { int addr, dir, attr; ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { printf("%s: could not read endpoint descriptor/n", devname); goto bad; } addr = ed->bEndpointAddress; dir = UE_GET_DIR(ed->bEndpointAddress); attr = ed->bmAttributes & UE_XFERTYPE; if (dir == UE_DIR_IN && attr == UE_BULK) { uca.bulkin = addr; uca.ibufsize = (UGETW(ed->wMaxPacketSize) > 0) ? UGETW(ed->wMaxPacketSize) : UFTDIIBUFSIZE; } else if (dir == UE_DIR_OUT && attr == UE_BULK) { uca.bulkout = addr; uca.obufsize = (UGETW(ed->wMaxPacketSize) > 0) ? UGETW(ed->wMaxPacketSize) : UFTDIOBUFSIZE; uca.obufsize-= sc->sc_hdrlen; } else { printf("%s: unexpected endpoint/n", devname); goto bad; } } if (uca.bulkin == -1) { printf("%s: Could not find data bulk in/n", sc->sc_dev.dv_xname); goto bad; } if (uca.bulkout == -1) { printf("%s: Could not find data bulk out/n", sc->sc_dev.dv_xname); goto bad; } if (uaa->iface == NULL) uca.portno = FTDI_PIT_SIOA; else uca.portno = FTDI_PIT_SIOA + id->bInterfaceNumber; /* bulkin, bulkout set above */ uca.ibufsizepad = uca.ibufsize; uca.opkthdrlen = sc->sc_hdrlen; uca.device = dev; uca.iface = iface; uca.methods = &uftdi_methods; uca.arg = sc;//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,
示例14: udsir_write/* ARGSUSED */static intudsir_write(void *h, struct uio *uio, int flag){ struct udsir_softc *sc = h; usbd_status err; uint32_t wrlen; int error, sirlength; uint8_t *wrbuf; int s; DPRINTFN(1, ("%s: sc=%p/n", __func__, sc)); if (sc->sc_dying) return EIO;#ifdef DIAGNOSTIC if (sc->sc_wr_buf == NULL) return EINVAL;#endif wrlen = uio->uio_resid; if (wrlen > sc->sc_wr_maxpsz) return EINVAL; sc->sc_refcnt++; if (!UDSIR_BLOCK_RX_DATA(sc)) { /* * If reads are not blocked, determine what action we * should potentially take... */ if (sc->sc_direction == udir_output) { /* * If the last operation was an output, wait for the * polling thread to check for incoming data. */ sc->sc_wr_stalewrite = 1; wakeup(&sc->sc_thread); } else if (!sc->sc_rd_readinprogress && (sc->sc_direction == udir_idle || sc->sc_direction == udir_input)) { /* If idle, check for input before outputting */ udsir_start_read(sc); } } s = splusb(); while (sc->sc_wr_stalewrite || (sc->sc_direction != udir_output && sc->sc_direction != udir_idle)) { DPRINTFN(5, ("%s: sc=%p stalewrite=%d direction=%d, " "calling tsleep()/n", __func__, sc, sc->sc_wr_stalewrite, sc->sc_direction)); error = tsleep(&sc->sc_wr_buf, PZERO | PCATCH, "usirwr", 0); if (sc->sc_dying) error = EIO; if (error) { splx(s); DPRINTFN(0, ("%s: tsleep() = %d/n", __func__, error)); goto ret; } } splx(s); wrbuf = sc->sc_wr_buf; sirlength = irda_sir_frame(wrbuf, MAX_UDSIR_OUTPUT_FRAME, uio, sc->sc_params.ebofs); if (sirlength < 0) error = -sirlength; else { uint32_t btlen; DPRINTFN(1, ("%s: transfer %u bytes/n", __func__, (unsigned int)wrlen)); btlen = sirlength; sc->sc_direction = udir_output;#ifdef UDSIR_DEBUG if (udsirdebug >= 20) udsir_dumpdata(wrbuf, btlen, __func__);#endif err = usbd_intr_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, USBD_FORCE_SHORT_XFER, UDSIR_WR_TIMEOUT, wrbuf, &btlen); DPRINTFN(2, ("%s: err=%d/n", __func__, err)); if (err != USBD_NORMAL_COMPLETION) { if (err == USBD_INTERRUPTED) error = EINTR; else if (err == USBD_TIMEOUT) error = ETIMEDOUT; else error = EIO; } else error = 0;//.........这里部分代码省略.........
开发者ID:ryo,项目名称:netbsd-src,代码行数:101,
示例15: hidms_inputvoidhidms_input(struct hidms *ms, uint8_t *data, u_int len){ int dx, dy, dz, dw; u_int32_t buttons = 0; int flags; int i, s; DPRINTFN(5,("hidms_input: len=%d/n", len)); /* * The Microsoft Wireless Intellimouse 2.0 sends one extra leading * byte of data compared to most USB mice. This byte frequently * switches from 0x01 (usual state) to 0x02. It may be used to * report non-standard events (such as battery life). However, * at the same time, it generates a left click event on the * button byte, where there shouldn't be any. We simply discard * the packet in this case. * * This problem affects the MS Wireless Notebook Optical Mouse, too. * However, the leading byte for this mouse is normally 0x11, and * the phantom mouse click occurs when it's 0x14. */ if (ms->sc_flags & HIDMS_LEADINGBYTE) { if (*data++ == 0x02) return; /* len--; */ } else if (ms->sc_flags & HIDMS_SPUR_BUT_UP) { if (*data == 0x14 || *data == 0x15) return; } flags = WSMOUSE_INPUT_DELTA; if (ms->sc_flags & HIDMS_ABSX) flags |= WSMOUSE_INPUT_ABSOLUTE_X; if (ms->sc_flags & HIDMS_ABSY) flags |= WSMOUSE_INPUT_ABSOLUTE_Y; dx = hid_get_data(data, len, &ms->sc_loc_x); dy = -hid_get_data(data, len, &ms->sc_loc_y); dz = hid_get_data(data, len, &ms->sc_loc_z); dw = hid_get_data(data, len, &ms->sc_loc_w); if (ms->sc_flags & HIDMS_ABSY) dy = -dy; if (ms->sc_flags & HIDMS_REVZ) dz = -dz; if (ms->sc_flags & HIDMS_REVW) dw = -dw; if (ms->sc_tsscale.swapxy && !ms->sc_rawmode) { int tmp = dx; dx = dy; dy = tmp; } if (!ms->sc_rawmode && (ms->sc_tsscale.maxx - ms->sc_tsscale.minx) != 0 && (ms->sc_tsscale.maxy - ms->sc_tsscale.miny) != 0) { /* Scale down to the screen resolution. */ dx = ((dx - ms->sc_tsscale.minx) * ms->sc_tsscale.resx) / (ms->sc_tsscale.maxx - ms->sc_tsscale.minx); dy = ((dy - ms->sc_tsscale.miny) * ms->sc_tsscale.resy) / (ms->sc_tsscale.maxy - ms->sc_tsscale.miny); } for (i = 0; i < ms->sc_num_buttons; i++) if (hid_get_data(data, len, &ms->sc_loc_btn[i])) buttons |= (1 << HIDMS_BUT(i)); if (dx != 0 || dy != 0 || dz != 0 || dw != 0 || buttons != ms->sc_buttons) { DPRINTFN(10, ("hidms_input: x:%d y:%d z:%d w:%d buttons:0x%x/n", dx, dy, dz, dw, buttons)); ms->sc_buttons = buttons; if (ms->sc_wsmousedev != NULL) { s = spltty(); wsmouse_input(ms->sc_wsmousedev, buttons, dx, dy, dz, dw, flags); splx(s); } }}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:83,
示例16: ukbd_decodevoidukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud){ int mod, omod; u_int16_t ibuf[MAXKEYS]; /* chars events */ int s; int nkeys, i, j; int key;#define ADDKEY(c) ibuf[nkeys++] = (c)#ifdef UKBD_DEBUG /* * Keep a trace of the last events. Using printf changes the * timing, so this can be useful sometimes. */ if (ukbdtrace) { struct ukbdtraceinfo *p = &ukbdtracedata[ukbdtraceindex]; p->unit = sc->sc_hdev.sc_dev.dv_unit; microtime(&p->tv); p->ud = *ud; if (++ukbdtraceindex >= UKBDTRACESIZE) ukbdtraceindex = 0; } if (ukbddebug > 5) { struct timeval tv; microtime(&tv); DPRINTF((" at %lu.%06lu mod=0x%02x key0=0x%02x key1=0x%02x " "key2=0x%02x key3=0x%02x/n", tv.tv_sec, tv.tv_usec, ud->modifiers, ud->keycode[0], ud->keycode[1], ud->keycode[2], ud->keycode[3])); }#endif if (ud->keycode[0] == KEY_ERROR) { DPRINTF(("ukbd_intr: KEY_ERROR/n")); return; /* ignore */ } nkeys = 0; mod = ud->modifiers; omod = sc->sc_odata.modifiers; if (mod != omod) for (i = 0; i < sc->sc_nmod; i++) if (( mod & sc->sc_mods[i].mask) != (omod & sc->sc_mods[i].mask)) ADDKEY(sc->sc_mods[i].key | (mod & sc->sc_mods[i].mask ? PRESS : RELEASE)); if (memcmp(ud->keycode, sc->sc_odata.keycode, sc->sc_nkeycode) != 0) { /* Check for released keys. */ for (i = 0; i < sc->sc_nkeycode; i++) { key = sc->sc_odata.keycode[i]; if (key == 0) continue; for (j = 0; j < sc->sc_nkeycode; j++) if (key == ud->keycode[j]) goto rfound; DPRINTFN(3,("ukbd_intr: relse key=0x%02x/n", key)); ADDKEY(key | RELEASE); rfound: ; } /* Check for pressed keys. */ for (i = 0; i < sc->sc_nkeycode; i++) { key = ud->keycode[i]; if (key == 0) continue; for (j = 0; j < sc->sc_nkeycode; j++) if (key == sc->sc_odata.keycode[j]) goto pfound; DPRINTFN(2,("ukbd_intr: press key=0x%02x/n", key)); ADDKEY(key | PRESS); pfound: ; } } sc->sc_odata = *ud; if (nkeys == 0) return; if (sc->sc_polling) { DPRINTFN(1,("ukbd_intr: pollchar = 0x%03x/n", ibuf[0])); memcpy(sc->sc_pollchars, ibuf, nkeys * sizeof(u_int16_t)); sc->sc_npollchar = nkeys; return; }#ifdef WSDISPLAY_COMPAT_RAWKBD if (sc->sc_rawkbd) { u_char cbuf[MAXKEYS * 2]; int c; int npress; for (npress = i = j = 0; i < nkeys; i++) { key = ibuf[i]; c = ukbd_trtab[key & CODEMASK]; if (c == NN) continue; if (c & 0x80)//.........这里部分代码省略.........
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:101,
示例17: usie_if_rx_callbackstatic voidusie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error){ struct usie_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = sc->sc_ifp; struct mbuf *m0; struct mbuf *m = NULL; struct usie_desc *rxd; uint32_t actlen; uint16_t err; uint16_t pkt; uint16_t ipl; uint16_t len; uint16_t diff; uint8_t pad; uint8_t ipv; usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(15, "rx done, actlen=%u/n", actlen); if (actlen < sizeof(struct usie_hip)) { DPRINTF("data too short %u/n", actlen); goto tr_setup; } m = sc->sc_rxm; sc->sc_rxm = NULL; /* fall though */ case USB_ST_SETUP:tr_setup: if (sc->sc_rxm == NULL) { sc->sc_rxm = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE /* could be bigger than MCLBYTES */ ); } if (sc->sc_rxm == NULL) { DPRINTF("could not allocate Rx mbuf/n"); ifp->if_ierrors++; usbd_xfer_set_stall(xfer); usbd_xfer_set_frames(xfer, 0); } else { /* * Directly loading a mbuf cluster into DMA to * save some data copying. This works because * there is only one cluster. */ usbd_xfer_set_frame_data(xfer, 0, mtod(sc->sc_rxm, caddr_t), MIN(MJUMPAGESIZE, USIE_RXSZ_MAX)); usbd_xfer_set_frames(xfer, 1); } usbd_transfer_submit(xfer); break; default: /* Error */ DPRINTF("USB transfer error, %s/n", usbd_errstr(error)); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ usbd_xfer_set_stall(xfer); ifp->if_ierrors++; goto tr_setup; } if (sc->sc_rxm != NULL) { m_freem(sc->sc_rxm); sc->sc_rxm = NULL; } break; } if (m == NULL) return; mtx_unlock(&sc->sc_mtx); m->m_pkthdr.len = m->m_len = actlen; err = pkt = 0; /* HW can aggregate multiple frames in a single USB xfer */ for (;;) { rxd = mtod(m, struct usie_desc *); len = be16toh(rxd->hip.len) & USIE_HIP_IP_LEN_MASK; pad = (rxd->hip.id & USIE_HIP_PAD) ? 1 : 0; ipl = (len - pad - ETHER_HDR_LEN); if (ipl >= len) { DPRINTF("Corrupt frame/n"); m_freem(m); break; } diff = sizeof(struct usie_desc) + ipl + pad; if (((rxd->hip.id & USIE_HIP_MASK) != USIE_HIP_IP) || (be16toh(rxd->desc_type) & USIE_TYPE_MASK) != USIE_IP_RX) { DPRINTF("received wrong type of packet/n"); m->m_data += diff; m->m_pkthdr.len = (m->m_len -= diff);//.........这里部分代码省略.........
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:101,
示例18: usie_if_tx_callbackstatic voidusie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error){ struct usie_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc; struct ifnet *ifp = sc->sc_ifp; struct mbuf *m; uint16_t size; switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete/n"); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; ifp->if_opackets++; /* fall though */ case USB_ST_SETUP:tr_setup: if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) break; IFQ_DRV_DEQUEUE(&ifp->if_snd, m); if (m == NULL) break; if (m->m_pkthdr.len > (MCLBYTES - ETHER_HDR_LEN + ETHER_CRC_LEN - sizeof(sc->sc_txd))) { DPRINTF("packet len is too big: %d/n", m->m_pkthdr.len); break; } pc = usbd_xfer_get_frame(xfer, 0); sc->sc_txd.hip.len = htobe16(m->m_pkthdr.len + ETHER_HDR_LEN + ETHER_CRC_LEN); size = sizeof(sc->sc_txd); usbd_copy_in(pc, 0, &sc->sc_txd, size); usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len); usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len + size + ETHER_CRC_LEN); BPF_MTAP(ifp, m); m_freem(m); usbd_transfer_submit(xfer); break; default: /* Error */ DPRINTF("USB transfer error, %s/n", usbd_errstr(error)); ifp->if_oerrors++; if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); ifp->if_ierrors++; goto tr_setup; } break; }}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:63,
示例19: udsir_attachstatic voidudsir_attach(device_t parent, device_t self, void *aux){ struct udsir_softc *sc = device_private(self); struct usbif_attach_arg *uiaa = aux; struct usbd_device *dev = uiaa->uiaa_device; struct usbd_interface *iface = uiaa->uiaa_iface; char *devinfop; usb_endpoint_descriptor_t *ed; uint8_t epcount; int i; struct ir_attach_args ia; DPRINTFN(10, ("udsir_attach: sc=%p/n", sc)); sc->sc_dev = self; aprint_naive("/n"); aprint_normal("/n"); devinfop = usbd_devinfo_alloc(dev, 0); aprint_normal_dev(self, "%s/n", devinfop); usbd_devinfo_free(devinfop); sc->sc_udev = dev; sc->sc_iface = iface; epcount = 0; (void)usbd_endpoint_count(iface, &epcount); sc->sc_rd_addr = -1; sc->sc_wr_addr = -1; for (i = 0; i < epcount; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { aprint_error_dev(self, "couldn't get ep %d/n", i); return; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) { sc->sc_rd_addr = ed->bEndpointAddress; sc->sc_rd_maxpsz = UGETW(ed->wMaxPacketSize); } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) { sc->sc_wr_addr = ed->bEndpointAddress; sc->sc_wr_maxpsz = UGETW(ed->wMaxPacketSize); } } if (sc->sc_rd_addr == -1 || sc->sc_wr_addr == -1) { aprint_error_dev(self, "missing endpoint/n"); return; } DPRINTFN(10, ("udsir_attach: %p/n", sc->sc_udev)); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); ia.ia_type = IR_TYPE_IRFRAME; ia.ia_methods = &udsir_methods; ia.ia_handle = sc; sc->sc_child = config_found(self, &ia, ir_print); selinit(&sc->sc_rd_sel); selinit(&sc->sc_wr_sel); return;}
开发者ID:ryo,项目名称:netbsd-src,代码行数:67,
示例20: wsmouse_inputvoidwsmouse_input(device_t wsmousedev, u_int btns /* 0 is up */, int x, int y, int z, int w, u_int flags){ struct wsmouse_softc *sc = device_private(wsmousedev); struct wseventvar *evar; int mb, ub, d, nevents; /* one for each dimension (4) + a bit for each button */ struct wscons_event events[4 + sizeof(d) * 8]; /* * Discard input if not open. */ evar = sc->sc_base.me_evp; if (evar == NULL) return;#ifdef DIAGNOSTIC if (evar->q == NULL) { printf("wsmouse_input: evar->q=NULL/n"); return; }#endif#if NWSMUX > 0 DPRINTFN(5,("wsmouse_input: %s mux=%p, evar=%p/n", device_xname(sc->sc_base.me_dv), sc->sc_base.me_parent, evar));#endif sc->sc_mb = btns; if (!(flags & WSMOUSE_INPUT_ABSOLUTE_X)) sc->sc_dx += x; if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Y)) sc->sc_dy += y; if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Z)) sc->sc_dz += z; if (!(flags & WSMOUSE_INPUT_ABSOLUTE_W)) sc->sc_dw += w; /* * We have at least one event (mouse button, delta-X, or * delta-Y; possibly all three, and possibly three separate * button events). Deliver these events until we are out * of changes or out of room. As events get delivered, * mark them `unchanged'. */ ub = sc->sc_ub; nevents = 0; if (flags & WSMOUSE_INPUT_ABSOLUTE_X) { if (sc->sc_x != x) { events[nevents].type = WSCONS_EVENT_MOUSE_ABSOLUTE_X; events[nevents].value = x; nevents++; } } else { if (sc->sc_dx) { events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_X; events[nevents].value = sc->sc_dx; nevents++; } } if (flags & WSMOUSE_INPUT_ABSOLUTE_Y) { if (sc->sc_y != y) { events[nevents].type = WSCONS_EVENT_MOUSE_ABSOLUTE_Y; events[nevents].value = y; nevents++; } } else { if (sc->sc_dy) { events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_Y; events[nevents].value = sc->sc_dy; nevents++; } } if (flags & WSMOUSE_INPUT_ABSOLUTE_Z) { if (sc->sc_z != z) { events[nevents].type = WSCONS_EVENT_MOUSE_ABSOLUTE_Z; events[nevents].value = z; nevents++; } } else { if (sc->sc_dz) { events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_Z; events[nevents].value = sc->sc_dz; nevents++; } } if (flags & WSMOUSE_INPUT_ABSOLUTE_W) { if (sc->sc_w != w) { events[nevents].type = WSCONS_EVENT_MOUSE_ABSOLUTE_W; events[nevents].value = w; nevents++; } } else { if (sc->sc_dw) { events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_W; events[nevents].value = sc->sc_dw; nevents++;//.........这里部分代码省略.........
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:101,
示例21: wi_write_record_usbintwi_write_record_usb(struct wi_softc *wsc, struct wi_ltv_gen *ltv){ struct wi_usb_chain *c; struct wi_usb_softc *sc = wsc->wi_usb_cdata; struct wi_wridreq *prid; int total_len, rnd_len; int err; struct wi_ltv_gen p2ltv; u_int16_t val = 0; int i; DPRINTFN(5,("%s: %s: enter rid=%x wi_len %d copying %x/n", sc->wi_usb_dev.dv_xname, __func__, ltv->wi_type, ltv->wi_len, (ltv->wi_len-1)*2 )); /* Do we need to deal with these here, as in _io version? * WI_PORTTYPE_IBSS -> WI_RID_PORTTYPE * RID_TX_RATE munging * RID_ENCRYPTION * WI_RID_TX_CRYPT_KEY * WI_RID_DEFLT_CRYPT_KEYS */ if (ltv->wi_type == WI_RID_PORTTYPE && letoh16(ltv->wi_val) == WI_PORTTYPE_IBSS) { /* Convert WI_PORTTYPE_IBSS to vendor IBSS port type. */ p2ltv.wi_type = WI_RID_PORTTYPE; p2ltv.wi_len = 2; p2ltv.wi_val = wsc->wi_ibss_port; ltv = &p2ltv; } else if (wsc->sc_firmware_type != WI_LUCENT) { int v; switch (ltv->wi_type) { case WI_RID_TX_RATE: p2ltv.wi_type = WI_RID_TX_RATE; p2ltv.wi_len = 2; switch (letoh16(ltv->wi_val)) { case 1: v = 1; break; case 2: v = 2; break; case 3: v = 15; break; case 5: v = 4; break; case 6: v = 3; break; case 7: v = 7; break; case 11: v = 8; break; default: return EINVAL; } p2ltv.wi_val = htole16(v); ltv = &p2ltv; break; case WI_RID_ENCRYPTION: p2ltv.wi_type = WI_RID_P2_ENCRYPTION; p2ltv.wi_len = 2; if (ltv->wi_val & htole16(0x01)) { val = PRIVACY_INVOKED; /* * If using shared key WEP we must set the * EXCLUDE_UNENCRYPTED bit. Symbol cards * need this bit set even when not using * shared key. We can't just test for * IEEE80211_AUTH_SHARED since Symbol cards * have 2 shared key modes. */ if (wsc->wi_authtype != IEEE80211_AUTH_OPEN || wsc->sc_firmware_type == WI_SYMBOL) val |= EXCLUDE_UNENCRYPTED; switch (wsc->wi_crypto_algorithm) { case WI_CRYPTO_FIRMWARE_WEP: /* * TX encryption is broken in * Host AP mode. */ if (wsc->wi_ptype == WI_PORTTYPE_HOSTAP) val |= HOST_ENCRYPT; break; case WI_CRYPTO_SOFTWARE_WEP: val |= HOST_ENCRYPT|HOST_DECRYPT; break; } p2ltv.wi_val = htole16(val); } else p2ltv.wi_val = htole16(HOST_ENCRYPT | HOST_DECRYPT); ltv = &p2ltv; break; case WI_RID_TX_CRYPT_KEY: if (ltv->wi_val > WI_NLTV_KEYS) return (EINVAL); p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY; p2ltv.wi_len = 2; p2ltv.wi_val = ltv->wi_val; ltv = &p2ltv; break; case WI_RID_DEFLT_CRYPT_KEYS: { int error; int keylen; struct wi_ltv_str ws; struct wi_ltv_keys *wk; wk = (struct wi_ltv_keys *)ltv;//.........这里部分代码省略.........
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:101,
注:本文中的DPRINTFN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ DPRINTK函数代码示例 C++ DPRINT2函数代码示例 |