37#include <sys/stdint.h>
38#include <sys/stddef.h>
41#include <sys/kernel.h>
43#include <sys/linker_set.h>
44#include <sys/module.h>
47#include <sys/condvar.h>
48#include <sys/sysctl.h>
50#include <sys/unistd.h>
51#include <sys/callout.h>
52#include <sys/malloc.h>
62#define USB_DEBUG_VAR g_modem_debug
95static SYSCTL_NODE(_hw_usb, OID_AUTO, g_modem, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
99static int g_modem_debug = 0;
102 &g_modem_debug, 0,
"Debug level");
112SYSCTL_INT(_hw_usb_g_modem, OID_AUTO, pattern_interval, CTLFLAG_RWTUN,
163 .flags = {.ext_buffer = 1,.pipe_bof = 1,},
175 .flags = {.ext_buffer = 1,.pipe_bof = 1,.short_xfer_ok = 1,},
187 .flags = {.ext_buffer = 1,.pipe_bof = 1,},
281 uint8_t iface_index[2];
287 mtx_init(&sc->
sc_mtx,
"g_modem", NULL, MTX_DEF);
350 DPRINTF(
"st=%d aframes=%d actlen=%d bytes\n",
385 DPRINTF(
"st=%d aframes=%d actlen=%d bytes\n",
409 for (x = 0; x != max; x++)
412 for (x = 0; x != max; x++)
462 DPRINTF(
"st=%d aframes=%d actlen=%d bytes\n",
502 const void *preq,
void **
pptr, uint16_t *
plen,
507 uint8_t is_complete = *
pstate;
512 (
req->wValue[0] == 0x00) &&
513 (
req->wValue[1] == 0x00)) {
static usb_callback_t g_modem_bulk_read_callback
static usb_callback_t g_modem_bulk_write_callback
static usb_callback_t g_modem_intr_callback
static device_detach_t g_modem_detach
SYSCTL_INT(_hw_usb_g_modem, OID_AUTO, mode, CTLFLAG_RWTUN, &g_modem_mode, 0, "Mode selection")
static void g_modem_timeout(void *arg)
static device_method_t g_modem_methods[]
static int g_modem_pattern_interval
static void g_modem_watchdog_reset(struct g_modem_softc *sc)
MODULE_DEPEND(g_modem, usb, 1, 1, 1)
static void g_modem_watchdog(void *arg)
static char g_modem_pattern_data[G_MODEM_MAX_STRLEN]
static SYSCTL_NODE(_hw_usb, OID_AUTO, g_modem, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB modem gadget")
static usb_handle_request_t g_modem_handle_request
static driver_t g_modem_driver
SYSCTL_STRING(_hw_usb_g_modem, OID_AUTO, pattern, CTLFLAG_RW, &g_modem_pattern_data, sizeof(g_modem_pattern_data), "Data pattern")
static device_attach_t g_modem_attach
static int g_modem_throughput
static void g_modem_timeout_reset(struct g_modem_softc *sc)
static const struct usb_config g_modem_config[G_MODEM_N_TRANSFER]
DRIVER_MODULE(g_modem, uhub, g_modem_driver, g_modem_devclass, 0, 0)
static devclass_t g_modem_devclass
static device_probe_t g_modem_probe
#define G_MODEM_MODE_PATTERN
#define G_MODEM_MAX_STRLEN
#define G_MODEM_MODE_LOOP
#define G_MODEM_MODE_SILENT
char sc_pattern[G_MODEM_MAX_STRLEN]
uint8_t sc_abstract_state[32]
uint8_t sc_data_buf[G_MODEM_BUFSIZE]
struct usb_callout sc_watchdog
struct usb_xfer * sc_xfer[G_MODEM_N_TRANSFER]
struct usb_callout sc_callout
uint8_t sc_line_coding[32]
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_device * device
uint8_t bInterfaceSubClass
uint8_t bInterfaceProtocol
#define UT_WRITE_CLASS_INTERFACE
#define UISUBCLASS_ABSTRACT_CONTROL_MODEL
#define UCDC_SET_LINE_CODING
#define UCDC_SET_CONTROL_LINE_STATE
#define UCDC_SET_COMM_FEATURE
void usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index, uint8_t parent_index)
const char * usbd_errstr(usb_error_t err)
static usb_error_t usb_handle_request(struct usb_xfer *)
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, void *ptr, usb_frlength_t len)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
void usbd_transfer_start(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_xfer_set_interval(struct usb_xfer *xfer, int i)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
void device_set_usb_desc(device_t dev)
#define usb_callout_init_mtx(c, m, f)
#define usb_callout_reset(c,...)
#define usb_callout_drain(c)
#define USB_ST_TRANSFERRED
#define USB_MS_TO_TICKS(ms)
void() usb_callback_t(struct usb_xfer *, usb_error_t)
#define usb_callout_stop(c)
#define USB_GET_STATE(xfer)