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 <sys/sbuf.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.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 | ufoma_mobile_acm_descriptor |
struct | ufoma_softc |
struct | umcpc_modetostr_tab |
Macros | |
#define | UFOMA_HANDSFREE |
#define | USB_DEBUG_VAR usb_debug |
#define | UISUBCLASS_MCPC 0x88 |
#define | UDESC_VS_INTERFACE 0x44 |
#define | UDESCSUB_MCPC_ACM 0x11 |
#define | UMCPC_ACM_TYPE_AB1 0x1 |
#define | UMCPC_ACM_TYPE_AB2 0x2 |
#define | UMCPC_ACM_TYPE_AB5 0x5 |
#define | UMCPC_ACM_TYPE_AB6 0x6 |
#define | UMCPC_ACM_MODE_DEACTIVATED 0x0 |
#define | UMCPC_ACM_MODE_MODEM 0x1 |
#define | UMCPC_ACM_MODE_ATCOMMAND 0x2 |
#define | UMCPC_ACM_MODE_OBEX 0x60 |
#define | UMCPC_ACM_MODE_VENDOR1 0xc0 |
#define | UMCPC_ACM_MODE_VENDOR2 0xfe |
#define | UMCPC_ACM_MODE_UNLINKED 0xff |
#define | UMCPC_CM_MOBILE_ACM 0x0 |
#define | UMCPC_ACTIVATE_MODE 0x60 |
#define | UMCPC_GET_MODETABLE 0x61 |
#define | UMCPC_SET_LINK 0x62 |
#define | UMCPC_CLEAR_LINK 0x63 |
#define | UMCPC_REQUEST_ACKNOWLEDGE 0x31 |
#define | UFOMA_MAX_TIMEOUT 15 /* standard says 10 seconds */ |
#define | UFOMA_CMD_BUF_SIZE 64 /* bytes */ |
#define | UFOMA_BULK_BUF_SIZE 1024 /* bytes */ |
Typedefs | |
typedef struct ufoma_mobile_acm_descriptor | usb_mcpc_acm_descriptor |
Enumerations | |
enum | { UFOMA_CTRL_ENDPT_INTR , UFOMA_CTRL_ENDPT_READ , UFOMA_CTRL_ENDPT_WRITE , UFOMA_CTRL_ENDPT_MAX } |
enum | { UFOMA_BULK_ENDPT_WRITE , UFOMA_BULK_ENDPT_READ , UFOMA_BULK_ENDPT_MAX } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | ufoma_free_softc (struct ufoma_softc *) |
static void * | ufoma_get_intconf (struct usb_config_descriptor *, struct usb_interface_descriptor *, uint8_t, uint8_t) |
static void | ufoma_cfg_link_state (struct ufoma_softc *) |
static void | ufoma_cfg_activate_state (struct ufoma_softc *, uint16_t) |
static void | ufoma_free (struct ucom_softc *) |
static void | ufoma_cfg_open (struct ucom_softc *) |
static void | ufoma_cfg_close (struct ucom_softc *) |
static void | ufoma_cfg_set_break (struct ucom_softc *, uint8_t) |
static void | ufoma_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *) |
static void | ufoma_cfg_set_dtr (struct ucom_softc *, uint8_t) |
static void | ufoma_cfg_set_rts (struct ucom_softc *, uint8_t) |
static int | ufoma_pre_param (struct ucom_softc *, struct termios *) |
static void | ufoma_cfg_param (struct ucom_softc *, struct termios *) |
static int | ufoma_modem_setup (device_t, struct ufoma_softc *, struct usb_attach_arg *) |
static void | ufoma_start_read (struct ucom_softc *) |
static void | ufoma_stop_read (struct ucom_softc *) |
static void | ufoma_start_write (struct ucom_softc *) |
static void | ufoma_stop_write (struct ucom_softc *) |
static void | ufoma_poll (struct ucom_softc *ucom) |
static int | ufoma_sysctl_support (SYSCTL_HANDLER_ARGS) |
static int | ufoma_sysctl_current (SYSCTL_HANDLER_ARGS) |
static int | ufoma_sysctl_open (SYSCTL_HANDLER_ARGS) |
DRIVER_MODULE (ufoma, uhub, ufoma_driver, ufoma_devclass, NULL, 0) | |
MODULE_DEPEND (ufoma, ucom, 1, 1, 1) | |
MODULE_DEPEND (ufoma, usb, 1, 1, 1) | |
MODULE_VERSION (ufoma, 1) | |
USB_PNP_HOST_INFO (ufoma_devs) | |
static int | ufoma_probe (device_t dev) |
static int | ufoma_attach (device_t dev) |
static int | ufoma_detach (device_t dev) |
UCOM_UNLOAD_DRAIN (ufoma) | |
static void | ufoma_ctrl_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | ufoma_ctrl_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | ufoma_intr_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | ufoma_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | ufoma_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | ufoma_cfg_set_line_state (struct ufoma_softc *sc) |
static char * | ufoma_mode_to_str (int mode) |
static int | ufoma_str_to_mode (char *str) |
Variables | |
static device_probe_t | ufoma_probe |
static device_attach_t | ufoma_attach |
static device_detach_t | ufoma_detach |
static usb_callback_t | ufoma_ctrl_read_callback |
static usb_callback_t | ufoma_ctrl_write_callback |
static usb_callback_t | ufoma_intr_callback |
static usb_callback_t | ufoma_bulk_write_callback |
static usb_callback_t | ufoma_bulk_read_callback |
static const struct usb_config | ufoma_ctrl_config [UFOMA_CTRL_ENDPT_MAX] |
static const struct usb_config | ufoma_bulk_config [UFOMA_BULK_ENDPT_MAX] |
static const struct ucom_callback | ufoma_callback |
static device_method_t | ufoma_methods [] |
static devclass_t | ufoma_devclass |
static driver_t | ufoma_driver |
static const STRUCT_USB_HOST_ID | ufoma_devs [] |
static struct umcpc_modetostr_tab | umcpc_modetostr_tab [] |
typedef struct ufoma_mobile_acm_descriptor usb_mcpc_acm_descriptor |
anonymous enum |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | ufoma | , |
uhub | , | ||
ufoma_driver | , | ||
ufoma_devclass | , | ||
NULL | , | ||
0 | |||
) |
MODULE_DEPEND | ( | ufoma | , |
ucom | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | ufoma | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | ufoma | , |
1 | |||
) |
UCOM_UNLOAD_DRAIN | ( | ufoma | ) |
|
static |
Definition at line 365 of file ufoma.c.
References ufoma_mobile_acm_descriptor::bFunctionLength, usbd_lookup_info::bIfaceIndex, ufoma_mobile_acm_descriptor::bMode, ufoma_mobile_acm_descriptor::bType, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, error, id, usb_attach_arg::iface, usb_attach_arg::info, ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_iface_index, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_currentmode, ufoma_softc::sc_cv, ufoma_softc::sc_dev, ufoma_softc::sc_modetable, ufoma_softc::sc_modetoactivate, ufoma_softc::sc_mtx, ufoma_softc::sc_nobulk, ufoma_softc::sc_super_ucom, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, ufoma_softc::sc_unit, ucom_super_softc::sc_unit, ucom_attach(), ucom_ref(), ucom_set_pnpinfo_usb(), UDESC_VS_INTERFACE, UDESCSUB_MCPC_ACM, UFOMA_BULK_ENDPT_READ, UFOMA_BULK_ENDPT_WRITE, ufoma_callback, ufoma_ctrl_config, UFOMA_CTRL_ENDPT_MAX, ufoma_detach, ufoma_get_intconf(), ufoma_modem_setup(), ufoma_sysctl_current(), ufoma_sysctl_open(), ufoma_sysctl_support(), UMCPC_ACM_MODE_UNLINKED, UMCPC_ACM_TYPE_AB5, UMCPC_ACM_TYPE_AB6, usbd_get_config_descriptor(), usbd_get_interface_descriptor(), usbd_transfer_setup(), and usbd_xfer_set_stall().
|
static |
Definition at line 813 of file ufoma.c.
References error, ufoma_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 784 of file ufoma.c.
References error, ufoma_softc::sc_ucom, ucom_get_data(), UFOMA_BULK_BUF_SIZE, 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(), and usbd_xfer_softc().
|
static |
Definition at line 558 of file ufoma.c.
References DPRINTF, error, req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_cv, ufoma_softc::sc_mtx, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, state, ucom_cfg_do_request, UFOMA_MAX_TIMEOUT, UMCPC_ACTIVATE_MODE, USETW, and UT_WRITE_VENDOR_INTERFACE.
Referenced by ufoma_cfg_close(), and ufoma_cfg_open().
|
static |
Definition at line 861 of file ufoma.c.
References ucom_softc::sc_parent, ufoma_cfg_activate_state(), and UMCPC_ACM_MODE_DEACTIVATED.
|
static |
Definition at line 896 of file ufoma.c.
References ufoma_softc::sc_lsr, ufoma_softc::sc_msr, and ucom_softc::sc_parent.
|
static |
Definition at line 536 of file ufoma.c.
References DPRINTF, error, req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_cv, ufoma_softc::sc_modetable, ufoma_softc::sc_mtx, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, ucom_cfg_do_request, UMCPC_CM_MOBILE_ACM, UMCPC_SET_LINK, USETW, and UT_WRITE_VENDOR_INTERFACE.
Referenced by ufoma_cfg_open().
|
static |
Definition at line 843 of file ufoma.c.
References ufoma_softc::sc_currentmode, ufoma_softc::sc_modetoactivate, ufoma_softc::sc_num_msg, ucom_softc::sc_parent, ufoma_cfg_activate_state(), ufoma_cfg_link_state(), UMCPC_ACM_MODE_DEACTIVATED, and UMCPC_ACM_MODE_UNLINKED.
|
static |
Definition at line 964 of file ufoma.c.
References usb_cdc_line_state::bCharFormat, usb_cdc_line_state::bDataBits, usb_cdc_line_state::bParityType, DPRINTF, usb_cdc_line_state::dwDTERate, req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_currentmode, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, UCDC_LINE_STATE_LENGTH, UCDC_PARITY_EVEN, UCDC_PARITY_NONE, UCDC_PARITY_ODD, UCDC_SET_LINE_CODING, UCDC_STOP_BIT_1, UCDC_STOP_BIT_2, ucom_cfg_do_request, UMCPC_ACM_MODE_OBEX, USETDW, USETW, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 869 of file ufoma.c.
References req, ufoma_softc::sc_acm_cap, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_currentmode, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, UCDC_BREAK_OFF, UCDC_BREAK_ON, UCDC_SEND_BREAK, ucom_cfg_do_request, UMCPC_ACM_MODE_OBEX, USB_CDC_ACM_HAS_BREAK, USETW, UT_WRITE_CLASS_INTERFACE, and usb_device_request::wValue.
|
static |
Definition at line 926 of file ufoma.c.
References ufoma_softc::sc_line, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UCDC_LINE_DTR, and ufoma_cfg_set_line_state().
|
static |
Definition at line 906 of file ufoma.c.
References req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_currentmode, ufoma_softc::sc_line, ufoma_softc::sc_ucom, ufoma_softc::sc_udev, UCDC_SET_CONTROL_LINE_STATE, ucom_cfg_do_request, UMCPC_ACM_MODE_OBEX, USETW, and UT_WRITE_CLASS_INTERFACE.
Referenced by ufoma_cfg_set_dtr(), and ufoma_cfg_set_rts().
|
static |
Definition at line 942 of file ufoma.c.
References ufoma_softc::sc_line, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UCDC_LINE_RTS, and ufoma_cfg_set_line_state().
|
static |
Definition at line 580 of file ufoma.c.
References DPRINTF, error, len, req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_num_msg, ufoma_softc::sc_ucom, UCDC_GET_ENCAPSULATED_RESPONSE, ucom_put_data(), UFOMA_CMD_BUF_SIZE, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_in(), usbd_errstr(), usbd_transfer_submit(), usbd_xfer_frame_len(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_frames(), usbd_xfer_softc(), usbd_xfer_status(), USETW, and UT_READ_CLASS_INTERFACE.
|
static |
Definition at line 632 of file ufoma.c.
References DPRINTF, error, req, ufoma_softc::sc_ctrl_iface_no, ufoma_softc::sc_ucom, UCDC_SEND_ENCAPSULATED_COMMAND, ucom_get_data(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_in(), usbd_errstr(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_frames(), usbd_xfer_softc(), USETW, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 480 of file ufoma.c.
References dev, ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_cv, ufoma_softc::sc_modetable, ufoma_softc::sc_super_ucom, ufoma_softc::sc_ucom, ucom_detach(), UFOMA_BULK_ENDPT_MAX, UFOMA_CTRL_ENDPT_MAX, ufoma_free_softc(), and usbd_transfer_unsetup().
|
static |
Definition at line 512 of file ufoma.c.
References ucom_softc::sc_parent, and ufoma_free_softc().
|
static |
Definition at line 503 of file ufoma.c.
References ufoma_softc::sc_mtx, ufoma_softc::sc_super_ucom, and ucom_unref().
Referenced by ufoma_detach(), and ufoma_free().
|
static |
Definition at line 518 of file ufoma.c.
References usb_endpoint_descriptor::bDescriptorType, desc, type, UDESC_INTERFACE, and usb_desc_foreach().
Referenced by ufoma_attach(), ufoma_modem_setup(), and ufoma_probe().
|
static |
Definition at line 673 of file ufoma.c.
References usb_cdc_notification::bmRequestType, usb_cdc_notification::bNotification, usb_cdc_notification::data, DPRINTF, error, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_currentmode, ufoma_softc::sc_cv, ufoma_softc::sc_lsr, ufoma_softc::sc_msr, ufoma_softc::sc_nobulk, ufoma_softc::sc_num_msg, ufoma_softc::sc_ucom, UCDC_N_RESPONSE_AVAILABLE, UCDC_N_SERIAL_DCD, UCDC_N_SERIAL_DSR, UCDC_N_SERIAL_RI, UCDC_N_SERIAL_STATE, UCDC_NOTIFICATION, ucom_status_change(), UFOMA_CTRL_ENDPT_READ, UGETW, UMCPC_REQUEST_ACKNOWLEDGE, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_out(), usbd_transfer_start(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), usbd_xfer_status(), UT_READ_VENDOR_INTERFACE, usb_cdc_notification::wLength, and usb_cdc_notification::wValue.
|
static |
Definition at line 1161 of file ufoma.c.
References umcpc_modetostr_tab::str.
Referenced by ufoma_sysctl_current(), ufoma_sysctl_open(), and ufoma_sysctl_support().
|
static |
Definition at line 1023 of file ufoma.c.
References usb_cdc_cm_descriptor::bDataInterface, usbd_lookup_info::bIfaceIndex, usb_cdc_cm_descriptor::bLength, usb_cdc_acm_descriptor::bLength, usb_cdc_cm_descriptor::bmCapabilities, usb_cdc_acm_descriptor::bmCapabilities, dev, usb_attach_arg::device, error, id, usb_attach_arg::iface, usb_attach_arg::info, ufoma_softc::sc_acm_cap, ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_cm_cap, ufoma_softc::sc_data_iface_index, ufoma_softc::sc_data_iface_no, ufoma_softc::sc_mtx, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM, UDESCSUB_CDC_CM, ufoma_bulk_config, UFOMA_BULK_ENDPT_MAX, ufoma_get_intconf(), USB_CDC_ACM_HAS_BREAK, USB_CDC_CM_OVER_DATA, usbd_get_config_descriptor(), usbd_get_iface(), usbd_get_interface_descriptor(), usbd_set_parent_iface(), and usbd_transfer_setup().
Referenced by ufoma_attach().
|
static |
Definition at line 1258 of file ufoma.c.
References ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ucom_softc::sc_parent, UFOMA_BULK_ENDPT_MAX, UFOMA_CTRL_ENDPT_MAX, and usbd_transfer_poll().
|
static |
|
static |
Definition at line 331 of file ufoma.c.
References ufoma_mobile_acm_descriptor::bType, dev, usb_attach_arg::device, error, id, usb_attach_arg::iface, UDESC_VS_INTERFACE, UDESCSUB_MCPC_ACM, ufoma_devs, ufoma_get_intconf(), UMCPC_ACM_TYPE_AB5, UMCPC_ACM_TYPE_AB6, usb_attach_arg::usb_mode, USB_MODE_HOST, usbd_get_config_descriptor(), usbd_get_interface_descriptor(), and usbd_lookup_id_by_uaa().
|
static |
Definition at line 1092 of file ufoma.c.
References ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UFOMA_BULK_ENDPT_READ, UFOMA_CTRL_ENDPT_INTR, UFOMA_CTRL_ENDPT_READ, and usbd_transfer_start().
|
static |
Definition at line 1124 of file ufoma.c.
References ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UFOMA_BULK_ENDPT_WRITE, UFOMA_CTRL_ENDPT_WRITE, and usbd_transfer_start().
|
static |
Definition at line 1108 of file ufoma.c.
References ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UFOMA_BULK_ENDPT_READ, UFOMA_CTRL_ENDPT_INTR, UFOMA_CTRL_ENDPT_READ, and usbd_transfer_stop().
|
static |
Definition at line 1136 of file ufoma.c.
References ufoma_softc::sc_bulk_xfer, ufoma_softc::sc_ctrl_xfer, ufoma_softc::sc_nobulk, ucom_softc::sc_parent, UFOMA_BULK_ENDPT_WRITE, UFOMA_CTRL_ENDPT_WRITE, and usbd_transfer_stop().
|
static |
Definition at line 1172 of file ufoma.c.
References umcpc_modetostr_tab::mode, and umcpc_modetostr_tab::str.
Referenced by ufoma_sysctl_open().
|
static |
Definition at line 1208 of file ufoma.c.
References req, ufoma_softc::sc_currentmode, and ufoma_mode_to_str().
Referenced by ufoma_attach().
|
static |
Definition at line 1223 of file ufoma.c.
References error, req, ufoma_softc::sc_modetable, ufoma_softc::sc_modetoactivate, ufoma_mode_to_str(), and ufoma_str_to_mode().
Referenced by ufoma_attach().
|
static |
Definition at line 1183 of file ufoma.c.
References req, ufoma_softc::sc_modetable, and ufoma_mode_to_str().
Referenced by ufoma_attach().
USB_PNP_HOST_INFO | ( | ufoma_devs | ) |
|
static |
Definition at line 266 of file ufoma.c.
Referenced by ufoma_modem_setup().
|
static |
|
static |
|
static |
Definition at line 286 of file ufoma.c.
Referenced by ufoma_attach().
|
static |
Definition at line 235 of file ufoma.c.
Referenced by ufoma_attach().
|
static |
|
static |
|
static |
Definition at line 198 of file ufoma.c.
Referenced by ufoma_attach().
|
static |
|
static |
|
static |
|
static |
|
static |