FreeBSD kernel usb device Code
|
#include <sys/cdefs.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_ioctl.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/serial/usb_serial.h>
Go to the source code of this file.
Data Structures | |
struct | uslcom_softc |
Macros | |
#define | USB_DEBUG_VAR uslcom_debug |
#define | USLCOM_BULK_BUF_SIZE 1024 |
#define | USLCOM_CONFIG_INDEX 0 |
#define | USLCOM_WRITE 0x41 |
#define | USLCOM_READ 0xc1 |
#define | USLCOM_IFC_ENABLE 0x00 |
#define | USLCOM_SET_BAUDDIV 0x01 |
#define | USLCOM_SET_LINE_CTL 0x03 |
#define | USLCOM_SET_BREAK 0x05 |
#define | USLCOM_SET_MHS 0x07 |
#define | USLCOM_GET_MDMSTS 0x08 |
#define | USLCOM_SET_FLOW 0x13 |
#define | USLCOM_SET_BAUDRATE 0x1e |
#define | USLCOM_VENDOR_SPECIFIC 0xff |
#define | USLCOM_IFC_ENABLE_DIS 0x00 |
#define | USLCOM_IFC_ENABLE_EN 0x01 |
#define | USLCOM_MHS_DTR_ON 0x0001 |
#define | USLCOM_MHS_DTR_SET 0x0100 |
#define | USLCOM_MHS_RTS_ON 0x0002 |
#define | USLCOM_MHS_RTS_SET 0x0200 |
#define | USLCOM_MHS_CTS 0x0010 |
#define | USLCOM_MHS_DSR 0x0020 |
#define | USLCOM_MHS_RI 0x0040 |
#define | USLCOM_MHS_DCD 0x0080 |
#define | USLCOM_BAUDDIV_REF 3686400 /* 3.6864 MHz */ |
#define | USLCOM_STOP_BITS_1 0x00 |
#define | USLCOM_STOP_BITS_2 0x02 |
#define | USLCOM_PARITY_NONE 0x00 |
#define | USLCOM_PARITY_ODD 0x10 |
#define | USLCOM_PARITY_EVEN 0x20 |
#define | USLCOM_SET_DATA_BITS(x) ((x) << 8) |
#define | USLCOM_SET_BREAK_OFF 0x00 |
#define | USLCOM_SET_BREAK_ON 0x01 |
#define | USLCOM_FLOW_DTR_ON 0x00000001 /* DTR static active */ |
#define | USLCOM_FLOW_CTS_HS 0x00000008 /* CTS handshake */ |
#define | USLCOM_FLOW_RTS_ON 0x00000040 /* RTS static active */ |
#define | USLCOM_FLOW_RTS_HS 0x00000080 /* RTS handshake */ |
#define | USLCOM_GET_PARTNUM 0x370B |
#define | USLCOM_WRITE_LATCH 0x37E1 |
#define | USLCOM_READ_LATCH 0x00C2 |
#define | USLCOM_PARTNUM_CP2101 1 |
#define | USLCOM_PARTNUM_CP2102 2 |
#define | USLCOM_PARTNUM_CP2103 3 |
#define | USLCOM_PARTNUM_CP2104 4 |
#define | USLCOM_PARTNUM_CP2105 5 |
#define | USLCOM_DEV(v, p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } |
Enumerations | |
enum | { USLCOM_BULK_DT_WR , USLCOM_BULK_DT_RD , USLCOM_CTRL_DT_RD , USLCOM_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | uslcom_free_softc (struct uslcom_softc *) |
static void | uslcom_free (struct ucom_softc *) |
static uint8_t | uslcom_get_partnum (struct uslcom_softc *) |
static void | uslcom_cfg_open (struct ucom_softc *) |
static void | uslcom_cfg_close (struct ucom_softc *) |
static void | uslcom_cfg_set_dtr (struct ucom_softc *, uint8_t) |
static void | uslcom_cfg_set_rts (struct ucom_softc *, uint8_t) |
static void | uslcom_cfg_set_break (struct ucom_softc *, uint8_t) |
static void | uslcom_cfg_param (struct ucom_softc *, struct termios *) |
static void | uslcom_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *) |
static int | uslcom_ioctl (struct ucom_softc *, uint32_t, caddr_t, int, struct thread *) |
static int | uslcom_pre_param (struct ucom_softc *, struct termios *) |
static void | uslcom_start_read (struct ucom_softc *) |
static void | uslcom_stop_read (struct ucom_softc *) |
static void | uslcom_start_write (struct ucom_softc *) |
static void | uslcom_stop_write (struct ucom_softc *) |
static void | uslcom_poll (struct ucom_softc *ucom) |
DRIVER_MODULE (uslcom, uhub, uslcom_driver, uslcom_devclass, NULL, 0) | |
MODULE_DEPEND (uslcom, ucom, 1, 1, 1) | |
MODULE_DEPEND (uslcom, usb, 1, 1, 1) | |
MODULE_VERSION (uslcom, 1) | |
USB_PNP_HOST_INFO (uslcom_devs) | |
static void | uslcom_watchdog (void *arg) |
static int | uslcom_probe (device_t dev) |
static int | uslcom_attach (device_t dev) |
static int | uslcom_detach (device_t dev) |
UCOM_UNLOAD_DRAIN (uslcom) | |
static void | uslcom_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | uslcom_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | uslcom_control_callback (struct usb_xfer *xfer, usb_error_t error) |
Variables | |
static device_probe_t | uslcom_probe |
static device_attach_t | uslcom_attach |
static device_detach_t | uslcom_detach |
static usb_callback_t | uslcom_write_callback |
static usb_callback_t | uslcom_read_callback |
static usb_callback_t | uslcom_control_callback |
static const struct usb_config | uslcom_config [USLCOM_N_TRANSFER] |
static struct ucom_callback | uslcom_callback |
static const STRUCT_USB_HOST_ID | uslcom_devs [] |
static device_method_t | uslcom_methods [] |
static devclass_t | uslcom_devclass |
static driver_t | uslcom_driver |
#define USLCOM_DEV | ( | v, | |
p | |||
) | { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } |
#define USLCOM_FLOW_DTR_ON 0x00000001 /* DTR static active */ |
#define USLCOM_FLOW_RTS_ON 0x00000040 /* RTS static active */ |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | uslcom | , |
uhub | , | ||
uslcom_driver | , | ||
uslcom_devclass | , | ||
NULL | , | ||
0 | |||
) |
MODULE_DEPEND | ( | uslcom | , |
ucom | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | uslcom | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | uslcom | , |
1 | |||
) |
UCOM_UNLOAD_DRAIN | ( | uslcom | ) |
USB_PNP_HOST_INFO | ( | uslcom_devs | ) |
|
static |
Definition at line 419 of file uslcom.c.
References usbd_lookup_info::bIfaceIndex, usbd_lookup_info::bIfaceNum, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, error, usb_attach_arg::info, uslcom_softc::sc_iface_no, uslcom_softc::sc_mtx, uslcom_softc::sc_partnum, uslcom_softc::sc_super_ucom, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, uslcom_softc::sc_watchdog, uslcom_softc::sc_xfer, ucom_attach(), ucom_ref(), ucom_set_pnpinfo_usb(), usb_callout_init_mtx, usbd_errstr(), usbd_transfer_setup(), usbd_xfer_set_stall(), USLCOM_BULK_DT_RD, USLCOM_BULK_DT_WR, uslcom_callback, uslcom_config, uslcom_detach, uslcom_get_partnum(), and USLCOM_N_TRANSFER.
|
static |
Definition at line 524 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, uslcom_softc::sc_watchdog, ucom_cfg_do_request, usb_callout_stop, USETW, USLCOM_IFC_ENABLE, USLCOM_IFC_ENABLE_DIS, and USLCOM_WRITE.
|
static |
Definition at line 722 of file uslcom.c.
References DPRINTF, uslcom_softc::sc_lsr, uslcom_softc::sc_msr, and ucom_softc::sc_parent.
|
static |
Definition at line 503 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USETW, USLCOM_IFC_ENABLE, USLCOM_IFC_ENABLE_EN, uslcom_watchdog(), and USLCOM_WRITE.
|
static |
Definition at line 642 of file uslcom.c.
References data, DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USETW, USLCOM_FLOW_CTS_HS, USLCOM_FLOW_DTR_ON, USLCOM_FLOW_RTS_HS, USLCOM_FLOW_RTS_ON, USLCOM_PARITY_EVEN, USLCOM_PARITY_NONE, USLCOM_PARITY_ODD, USLCOM_SET_BAUDRATE, USLCOM_SET_DATA_BITS, USLCOM_SET_FLOW, USLCOM_SET_LINE_CTL, USLCOM_STOP_BITS_1, USLCOM_STOP_BITS_2, and USLCOM_WRITE.
|
static |
Definition at line 734 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USETW, USLCOM_SET_BREAK, USLCOM_SET_BREAK_OFF, USLCOM_SET_BREAK_ON, and USLCOM_WRITE.
|
static |
Definition at line 567 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USETW, USLCOM_MHS_DTR_ON, USLCOM_MHS_DTR_SET, USLCOM_SET_MHS, and USLCOM_WRITE.
|
static |
Definition at line 591 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USETW, USLCOM_MHS_RTS_ON, USLCOM_MHS_RTS_SET, USLCOM_SET_MHS, and USLCOM_WRITE.
|
static |
Definition at line 873 of file uslcom.c.
References DPRINTF, error, req, uslcom_softc::sc_iface_no, uslcom_softc::sc_msr, uslcom_softc::sc_ucom, ucom_status_change(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_in(), usbd_copy_out(), usbd_errstr(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_frames(), usbd_xfer_softc(), USETW, USLCOM_GET_MDMSTS, USLCOM_MHS_CTS, USLCOM_MHS_DCD, USLCOM_MHS_DSR, USLCOM_MHS_RI, and USLCOM_READ.
|
static |
Definition at line 467 of file uslcom.c.
References dev, DPRINTF, uslcom_softc::sc_super_ucom, uslcom_softc::sc_ucom, uslcom_softc::sc_watchdog, uslcom_softc::sc_xfer, ucom_detach(), usb_callout_drain, usbd_transfer_unsetup(), uslcom_free_softc(), and USLCOM_N_TRANSFER.
|
static |
Definition at line 497 of file uslcom.c.
References ucom_softc::sc_parent, and uslcom_free_softc().
|
static |
Definition at line 488 of file uslcom.c.
References uslcom_softc::sc_mtx, uslcom_softc::sc_super_ucom, and ucom_unref().
Referenced by uslcom_detach(), and uslcom_free().
|
static |
Definition at line 545 of file uslcom.c.
References DPRINTF, req, uslcom_softc::sc_iface_no, uslcom_softc::sc_udev, usbd_do_request_flags(), USETW, USLCOM_GET_PARTNUM, USLCOM_READ, and USLCOM_VENDOR_SPECIFIC.
Referenced by uslcom_attach().
|
static |
Definition at line 753 of file uslcom.c.
References data, DPRINTF, error, req, uslcom_softc::sc_iface_no, ucom_softc::sc_parent, uslcom_softc::sc_partnum, uslcom_softc::sc_ucom, uslcom_softc::sc_udev, ucom_cfg_do_request, USB_GET_GPIO, USB_SET_GPIO, USETW, USLCOM_PARTNUM_CP2103, USLCOM_PARTNUM_CP2104, USLCOM_READ, USLCOM_READ_LATCH, USLCOM_VENDOR_SPECIFIC, USLCOM_WRITE, and USLCOM_WRITE_LATCH.
|
static |
Definition at line 960 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_xfer, usbd_transfer_poll(), and USLCOM_N_TRANSFER.
|
static |
Definition at line 615 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_partnum, USLCOM_PARTNUM_CP2101, USLCOM_PARTNUM_CP2102, USLCOM_PARTNUM_CP2103, USLCOM_PARTNUM_CP2104, and USLCOM_PARTNUM_CP2105.
|
static |
Definition at line 403 of file uslcom.c.
References usbd_lookup_info::bConfigIndex, dev, usb_attach_arg::info, usb_attach_arg::usb_mode, USB_MODE_HOST, usbd_lookup_id_by_uaa(), USLCOM_CONFIG_INDEX, and uslcom_devs.
|
static |
Definition at line 843 of file uslcom.c.
References error, uslcom_softc::sc_ucom, ucom_put_data(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 926 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_xfer, usbd_transfer_start(), and USLCOM_BULK_DT_RD.
|
static |
Definition at line 944 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_xfer, usbd_transfer_start(), and USLCOM_BULK_DT_WR.
|
static |
Definition at line 935 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_xfer, usbd_transfer_stop(), and USLCOM_BULK_DT_RD.
|
static |
Definition at line 952 of file uslcom.c.
References ucom_softc::sc_parent, uslcom_softc::sc_xfer, usbd_transfer_stop(), and USLCOM_BULK_DT_WR.
|
static |
Definition at line 390 of file uslcom.c.
References uslcom_softc::sc_mtx, uslcom_softc::sc_watchdog, uslcom_softc::sc_xfer, usb_callout_reset, usbd_transfer_start(), USLCOM_CTRL_DT_RD, and uslcom_watchdog().
Referenced by uslcom_cfg_open(), and uslcom_watchdog().
|
static |
Definition at line 812 of file uslcom.c.
References DPRINTF, error, uslcom_softc::sc_ucom, ucom_get_data(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and USLCOM_BULK_BUF_SIZE.
|
static |
Definition at line 212 of file uslcom.c.
Referenced by uslcom_attach().
|
static |
Definition at line 183 of file uslcom.c.
Referenced by uslcom_attach().
|
static |
|
static |
Definition at line 158 of file uslcom.c.
Referenced by uslcom_attach().
|
static |
Definition at line 230 of file uslcom.c.
Referenced by uslcom_probe().
|
static |
|
static |
|
static |
|
static |