FreeBSD kernel usb device Code
|
#include <sys/param.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/linker_set.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/usb_cdc.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include "usb_if.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/gadget/g_modem.h>
Go to the source code of this file.
Data Structures | |
struct | g_modem_softc |
Macros | |
#define | USB_DEBUG_VAR g_modem_debug |
Enumerations | |
enum | { G_MODEM_INTR_DT , G_MODEM_BULK_RD , G_MODEM_BULK_WR , G_MODEM_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | SYSCTL_NODE (_hw_usb, OID_AUTO, g_modem, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB modem gadget") |
SYSCTL_INT (_hw_usb_g_modem, OID_AUTO, mode, CTLFLAG_RWTUN, &g_modem_mode, 0, "Mode selection") | |
SYSCTL_INT (_hw_usb_g_modem, OID_AUTO, pattern_interval, CTLFLAG_RWTUN, &g_modem_pattern_interval, 0, "Pattern interval in milliseconds") | |
SYSCTL_STRING (_hw_usb_g_modem, OID_AUTO, pattern, CTLFLAG_RW, &g_modem_pattern_data, sizeof(g_modem_pattern_data), "Data pattern") | |
SYSCTL_INT (_hw_usb_g_modem, OID_AUTO, throughput, CTLFLAG_RD, &g_modem_throughput, sizeof(g_modem_throughput), "Throughput in bytes per second") | |
static void | g_modem_timeout (void *arg) |
DRIVER_MODULE (g_modem, uhub, g_modem_driver, g_modem_devclass, 0, 0) | |
MODULE_DEPEND (g_modem, usb, 1, 1, 1) | |
static void | g_modem_timeout_reset (struct g_modem_softc *sc) |
static void | g_modem_watchdog (void *arg) |
static void | g_modem_watchdog_reset (struct g_modem_softc *sc) |
static int | g_modem_probe (device_t dev) |
static int | g_modem_attach (device_t dev) |
static int | g_modem_detach (device_t dev) |
static void | g_modem_intr_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | g_modem_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | g_modem_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static int | g_modem_handle_request (device_t dev, const void *preq, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate) |
Variables | |
static int | g_modem_mode = 0 |
static int | g_modem_pattern_interval = 1000 |
static char | g_modem_pattern_data [G_MODEM_MAX_STRLEN] |
static int | g_modem_throughput |
static device_probe_t | g_modem_probe |
static device_attach_t | g_modem_attach |
static device_detach_t | g_modem_detach |
static usb_handle_request_t | g_modem_handle_request |
static usb_callback_t | g_modem_intr_callback |
static usb_callback_t | g_modem_bulk_read_callback |
static usb_callback_t | g_modem_bulk_write_callback |
static devclass_t | g_modem_devclass |
static device_method_t | g_modem_methods [] |
static driver_t | g_modem_driver |
static const struct usb_config | g_modem_config [G_MODEM_N_TRANSFER] |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | g_modem | , |
uhub | , | ||
g_modem_driver | , | ||
g_modem_devclass | , | ||
0 | , | ||
0 | |||
) |
|
static |
Definition at line 276 of file g_modem.c.
References usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, error, g_modem_config, g_modem_detach, G_MODEM_MODE_SILENT, G_MODEM_N_TRANSFER, g_modem_timeout_reset(), g_modem_watchdog_reset(), usb_attach_arg::info, g_modem_softc::sc_callout, g_modem_softc::sc_mode, g_modem_softc::sc_mtx, g_modem_softc::sc_watchdog, g_modem_softc::sc_xfer, usb_callout_init_mtx, usbd_errstr(), usbd_set_parent_iface(), and usbd_transfer_setup().
|
static |
Definition at line 454 of file g_modem.c.
References DPRINTF, error, G_MODEM_BUFSIZE, G_MODEM_BULK_WR, G_MODEM_MODE_LOOP, G_MODEM_MODE_SILENT, g_modem_softc::sc_data_buf, g_modem_softc::sc_data_len, g_modem_softc::sc_mode, g_modem_softc::sc_throughput, g_modem_softc::sc_tx_busy, g_modem_softc::sc_xfer, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_errstr(), usbd_transfer_start(), usbd_transfer_submit(), usbd_xfer_set_frame_data(), usbd_xfer_set_frames(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 374 of file g_modem.c.
References DPRINTF, error, G_MODEM_BUFSIZE, G_MODEM_BULK_RD, G_MODEM_MODE_LOOP, G_MODEM_MODE_PATTERN, g_modem_softc::sc_data_buf, g_modem_softc::sc_data_len, g_modem_softc::sc_mode, g_modem_softc::sc_pattern, g_modem_softc::sc_pattern_len, g_modem_softc::sc_throughput, g_modem_softc::sc_tx_busy, g_modem_softc::sc_tx_interval, g_modem_softc::sc_xfer, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_errstr(), usbd_transfer_start(), usbd_transfer_submit(), usbd_xfer_set_frame_data(), usbd_xfer_set_frames(), usbd_xfer_set_interval(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 321 of file g_modem.c.
References dev, DPRINTF, G_MODEM_N_TRANSFER, g_modem_softc::sc_callout, g_modem_softc::sc_mtx, g_modem_softc::sc_watchdog, g_modem_softc::sc_xfer, usb_callout_drain, usb_callout_stop, and usbd_transfer_unsetup().
|
static |
Definition at line 501 of file g_modem.c.
References dev, offset, plen, pptr, pstate, req, g_modem_softc::sc_abstract_state, g_modem_softc::sc_line_coding, UCDC_SEND_BREAK, UCDC_SET_COMM_FEATURE, UCDC_SET_CONTROL_LINE_STATE, UCDC_SET_LINE_CODING, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 343 of file g_modem.c.
References DPRINTF, error, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_errstr(), usbd_xfer_set_stall(), and usbd_xfer_status().
|
static |
Definition at line 258 of file g_modem.c.
References usbd_lookup_info::bInterfaceClass, usbd_lookup_info::bInterfaceProtocol, usbd_lookup_info::bInterfaceSubClass, dev, usb_attach_arg::info, UICLASS_CDC, UIPROTO_CDC_AT, UISUBCLASS_ABSTRACT_CONTROL_MODEL, usb_attach_arg::usb_mode, and USB_MODE_DEVICE.
|
static |
Definition at line 214 of file g_modem.c.
References G_MODEM_BULK_RD, G_MODEM_BULK_WR, G_MODEM_INTR_DT, G_MODEM_MAX_STRLEN, g_modem_mode, g_modem_pattern_data, g_modem_timeout_reset(), g_modem_softc::sc_mode, g_modem_softc::sc_pattern, g_modem_softc::sc_pattern_len, g_modem_softc::sc_xfer, and usbd_transfer_start().
Referenced by g_modem_timeout_reset().
|
static |
Definition at line 197 of file g_modem.c.
References g_modem_pattern_interval, g_modem_timeout(), g_modem_softc::sc_callout, g_modem_softc::sc_tx_interval, usb_callout_reset, and USB_MS_TO_TICKS.
Referenced by g_modem_attach(), and g_modem_timeout().
|
static |
Definition at line 243 of file g_modem.c.
References g_modem_throughput, g_modem_watchdog_reset(), and g_modem_softc::sc_throughput.
Referenced by g_modem_watchdog_reset().
|
static |
Definition at line 237 of file g_modem.c.
References g_modem_watchdog(), g_modem_softc::sc_watchdog, and usb_callout_reset.
Referenced by g_modem_attach(), and g_modem_watchdog().
MODULE_DEPEND | ( | g_modem | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
SYSCTL_INT | ( | _hw_usb_g_modem | , |
OID_AUTO | , | ||
mode | , | ||
CTLFLAG_RWTUN | , | ||
& | g_modem_mode, | ||
0 | , | ||
"Mode selection" | |||
) |
SYSCTL_INT | ( | _hw_usb_g_modem | , |
OID_AUTO | , | ||
pattern_interval | , | ||
CTLFLAG_RWTUN | , | ||
& | g_modem_pattern_interval, | ||
0 | , | ||
"Pattern interval in milliseconds" | |||
) |
SYSCTL_INT | ( | _hw_usb_g_modem | , |
OID_AUTO | , | ||
throughput | , | ||
CTLFLAG_RD | , | ||
& | g_modem_throughput, | ||
sizeof(g_modem_throughput) | , | ||
"Throughput in bytes per second" | |||
) |
|
static |
SYSCTL_STRING | ( | _hw_usb_g_modem | , |
OID_AUTO | , | ||
pattern | , | ||
CTLFLAG_RW | , | ||
& | g_modem_pattern_data, | ||
sizeof(g_modem_pattern_data) | , | ||
"Data pattern" | |||
) |
|
static |
|
static |
|
static |
Definition at line 158 of file g_modem.c.
Referenced by g_modem_attach().
|
static |
Definition at line 127 of file g_modem.c.
Referenced by g_modem_attach().
|
static |
|
static |
|
static |
|
static |
Definition at line 105 of file g_modem.c.
Referenced by g_modem_timeout().
|
static |
Definition at line 115 of file g_modem.c.
Referenced by g_modem_timeout().
|
static |
Definition at line 110 of file g_modem.c.
Referenced by g_modem_timeout_reset().
|
static |
Definition at line 120 of file g_modem.c.
Referenced by g_modem_watchdog().