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/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_keyboard.h>
Go to the source code of this file.
Data Structures | |
struct | g_keyboard_data |
struct | g_keyboard_softc |
Macros | |
#define | USB_DEBUG_VAR g_keyboard_debug |
#define | UPROTO_BOOT_KEYBOARD 1 |
#define | G_KEYBOARD_NMOD 8 /* units */ |
#define | G_KEYBOARD_NKEYCODE 6 /* units */ |
#define | MOD_CONTROL_L 0x01 |
#define | MOD_CONTROL_R 0x10 |
#define | MOD_SHIFT_L 0x02 |
#define | MOD_SHIFT_R 0x20 |
#define | MOD_ALT_L 0x04 |
#define | MOD_ALT_R 0x40 |
#define | MOD_WIN_L 0x08 |
#define | MOD_WIN_R 0x80 |
Enumerations | |
enum | { G_KEYBOARD_INTR_DT , G_KEYBOARD_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | SYSCTL_NODE (_hw_usb, OID_AUTO, g_keyboard, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB keyboard gadget") |
SYSCTL_INT (_hw_usb_g_keyboard, OID_AUTO, mode, CTLFLAG_RWTUN, &g_keyboard_mode, 0, "Mode selection") | |
SYSCTL_INT (_hw_usb_g_keyboard, OID_AUTO, key_press_interval, CTLFLAG_RWTUN, &g_keyboard_key_press_interval, 0, "Key Press Interval in milliseconds") | |
SYSCTL_STRING (_hw_usb_g_keyboard, OID_AUTO, key_press_pattern, CTLFLAG_RW, g_keyboard_key_press_pattern, sizeof(g_keyboard_key_press_pattern), "Key Press Patterns") | |
DRIVER_MODULE (g_keyboard, uhub, g_keyboard_driver, g_keyboard_devclass, 0, 0) | |
MODULE_DEPEND (g_keyboard, usb, 1, 1, 1) | |
static void | g_keyboard_timeout (void *arg) |
static void | g_keyboard_timeout_reset (struct g_keyboard_softc *sc) |
static int | g_keyboard_probe (device_t dev) |
static int | g_keyboard_attach (device_t dev) |
static int | g_keyboard_detach (device_t dev) |
static uint8_t | g_keyboard_get_keycode (struct g_keyboard_softc *sc, int index) |
static void | g_keyboard_intr_callback (struct usb_xfer *xfer, usb_error_t error) |
static int | g_keyboard_handle_request (device_t dev, const void *preq, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate) |
Variables | |
static int | g_keyboard_mode = 0 |
static int | g_keyboard_key_press_interval = 1000 |
static char | g_keyboard_key_press_pattern [G_KEYBOARD_MAX_STRLEN] |
static device_probe_t | g_keyboard_probe |
static device_attach_t | g_keyboard_attach |
static device_detach_t | g_keyboard_detach |
static usb_handle_request_t | g_keyboard_handle_request |
static usb_callback_t | g_keyboard_intr_callback |
static devclass_t | g_keyboard_devclass |
static device_method_t | g_keyboard_methods [] |
static driver_t | g_keyboard_driver |
static const struct usb_config | g_keyboard_config [G_KEYBOARD_N_TRANSFER] |
#define G_KEYBOARD_NKEYCODE 6 /* units */ |
Definition at line 94 of file g_keyboard.c.
#define G_KEYBOARD_NMOD 8 /* units */ |
Definition at line 93 of file g_keyboard.c.
#define MOD_ALT_L 0x04 |
Definition at line 102 of file g_keyboard.c.
#define MOD_ALT_R 0x40 |
Definition at line 103 of file g_keyboard.c.
#define MOD_CONTROL_L 0x01 |
Definition at line 98 of file g_keyboard.c.
#define MOD_CONTROL_R 0x10 |
Definition at line 99 of file g_keyboard.c.
#define MOD_SHIFT_L 0x02 |
Definition at line 100 of file g_keyboard.c.
#define MOD_SHIFT_R 0x20 |
Definition at line 101 of file g_keyboard.c.
#define MOD_WIN_L 0x08 |
Definition at line 104 of file g_keyboard.c.
#define MOD_WIN_R 0x80 |
Definition at line 105 of file g_keyboard.c.
#define UPROTO_BOOT_KEYBOARD 1 |
Definition at line 91 of file g_keyboard.c.
#define USB_DEBUG_VAR g_keyboard_debug |
Definition at line 59 of file g_keyboard.c.
anonymous enum |
Enumerator | |
---|---|
G_KEYBOARD_INTR_DT | |
G_KEYBOARD_N_TRANSFER |
Definition at line 110 of file g_keyboard.c.
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | g_keyboard | , |
uhub | , | ||
g_keyboard_driver | , | ||
g_keyboard_devclass | , | ||
0 | , | ||
0 | |||
) |
|
static |
Definition at line 228 of file g_keyboard.c.
References usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, error, g_keyboard_config, g_keyboard_detach, G_KEYBOARD_MODE_SILENT, G_KEYBOARD_N_TRANSFER, g_keyboard_timeout_reset(), usb_attach_arg::info, g_keyboard_softc::sc_callout, g_keyboard_softc::sc_mode, g_keyboard_softc::sc_mtx, g_keyboard_softc::sc_xfer, usb_callout_init_mtx, usbd_errstr(), and usbd_transfer_setup().
|
static |
Definition at line 265 of file g_keyboard.c.
References dev, DPRINTF, G_KEYBOARD_N_TRANSFER, g_keyboard_softc::sc_callout, g_keyboard_softc::sc_mtx, g_keyboard_softc::sc_xfer, usb_callout_drain, usb_callout_stop, and usbd_transfer_unsetup().
|
static |
Definition at line 285 of file g_keyboard.c.
References index, g_keyboard_softc::sc_pattern, and g_keyboard_softc::sc_pattern_len.
Referenced by g_keyboard_intr_callback().
|
static |
Definition at line 380 of file g_keyboard.c.
References dev, offset, plen, pptr, pstate, req, g_keyboard_softc::sc_led_state, UR_SET_IDLE, UR_SET_PROTOCOL, UR_SET_REPORT, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 307 of file g_keyboard.c.
References DPRINTF, error, g_keyboard_get_keycode(), G_KEYBOARD_MAX_STRLEN, G_KEYBOARD_MODE_PATTERN, G_KEYBOARD_MODE_SILENT, g_keyboard_data::keycode, g_keyboard_softc::sc_data, g_keyboard_softc::sc_mode, g_keyboard_softc::sc_state, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_errstr(), 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 210 of file g_keyboard.c.
References usbd_lookup_info::bInterfaceClass, usbd_lookup_info::bInterfaceProtocol, usbd_lookup_info::bInterfaceSubClass, dev, usb_attach_arg::info, UICLASS_HID, UISUBCLASS_BOOT, UPROTO_BOOT_KEYBOARD, usb_attach_arg::usb_mode, and USB_MODE_DEVICE.
|
static |
Definition at line 190 of file g_keyboard.c.
References G_KEYBOARD_INTR_DT, g_keyboard_key_press_pattern, G_KEYBOARD_MAX_STRLEN, g_keyboard_mode, g_keyboard_timeout_reset(), g_keyboard_softc::sc_mode, g_keyboard_softc::sc_pattern, g_keyboard_softc::sc_pattern_len, g_keyboard_softc::sc_xfer, and usbd_transfer_start().
Referenced by g_keyboard_timeout_reset().
|
static |
Definition at line 175 of file g_keyboard.c.
References g_keyboard_key_press_interval, g_keyboard_timeout(), g_keyboard_softc::sc_callout, usb_callout_reset, and USB_MS_TO_TICKS.
Referenced by g_keyboard_attach(), and g_keyboard_timeout().
MODULE_DEPEND | ( | g_keyboard | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
SYSCTL_INT | ( | _hw_usb_g_keyboard | , |
OID_AUTO | , | ||
key_press_interval | , | ||
CTLFLAG_RWTUN | , | ||
& | g_keyboard_key_press_interval, | ||
0 | , | ||
"Key Press Interval in milliseconds" | |||
) |
SYSCTL_INT | ( | _hw_usb_g_keyboard | , |
OID_AUTO | , | ||
mode | , | ||
CTLFLAG_RWTUN | , | ||
& | g_keyboard_mode, | ||
0 | , | ||
"Mode selection" | |||
) |
|
static |
SYSCTL_STRING | ( | _hw_usb_g_keyboard | , |
OID_AUTO | , | ||
key_press_pattern | , | ||
CTLFLAG_RW | , | ||
g_keyboard_key_press_pattern | , | ||
sizeof(g_keyboard_key_press_pattern) | , | ||
"Key Press Patterns" | |||
) |
|
static |
Definition at line 131 of file g_keyboard.c.
|
static |
Definition at line 159 of file g_keyboard.c.
Referenced by g_keyboard_attach().
|
static |
Definition at line 132 of file g_keyboard.c.
Referenced by g_keyboard_attach().
|
static |
Definition at line 136 of file g_keyboard.c.
|
static |
Definition at line 150 of file g_keyboard.c.
|
static |
Definition at line 133 of file g_keyboard.c.
|
static |
Definition at line 134 of file g_keyboard.c.
|
static |
Definition at line 80 of file g_keyboard.c.
Referenced by g_keyboard_timeout_reset().
|
static |
Definition at line 85 of file g_keyboard.c.
Referenced by g_keyboard_timeout().
|
static |
Definition at line 138 of file g_keyboard.c.
|
static |
Definition at line 75 of file g_keyboard.c.
Referenced by g_keyboard_timeout().
|
static |
Definition at line 130 of file g_keyboard.c.