FreeBSD kernel usb device Code
ukbd.c File Reference
#include <sys/cdefs.h>
#include "opt_kbd.h"
#include "opt_ukbd.h"
#include "opt_evdev.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/proc.h>
#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/quirk/usb_quirk.h>
#include <sys/ioccom.h>
#include <sys/filio.h>
#include <sys/kbio.h>
#include <dev/kbd/kbdreg.h>
#include <dev/kbd/kbdtables.h>
Include dependency graph for ukbd.c:

Go to the source code of this file.

Data Structures

struct  ukbd_data
 
struct  ukbd_softc
 

Macros

#define USB_DEBUG_VAR   ukbd_debug
 
#define UKBD_EMULATE_ATSCANCODE   1
 
#define UKBD_DRIVER_NAME   "ukbd"
 
#define UKBD_NKEYCODE   256 /* units */
 
#define UKBD_IN_BUF_SIZE   (4 * UKBD_NKEYCODE) /* scancodes */
 
#define UKBD_IN_BUF_FULL   ((UKBD_IN_BUF_SIZE / 2) - 1) /* scancodes */
 
#define UKBD_NFKEY   (sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* units */
 
#define UKBD_BUFFER_SIZE   64 /* bytes */
 
#define UKBD_KEY_PRESSED(map, key)
 
#define MOD_EJECT   0x01
 
#define MOD_FN   0x02
 
#define UKBD_FLAG_COMPOSE   0x00000001
 
#define UKBD_FLAG_POLLING   0x00000002
 
#define UKBD_FLAG_SET_LEDS   0x00000004
 
#define UKBD_FLAG_ATTACHED   0x00000010
 
#define UKBD_FLAG_GONE   0x00000020
 
#define UKBD_FLAG_HID_MASK   0x003fffc0
 
#define UKBD_FLAG_APPLE_EJECT   0x00000040
 
#define UKBD_FLAG_APPLE_FN   0x00000080
 
#define UKBD_FLAG_APPLE_SWAP   0x00000100
 
#define UKBD_FLAG_NUMLOCK   0x00080000
 
#define UKBD_FLAG_CAPSLOCK   0x00100000
 
#define UKBD_FLAG_SCROLLLOCK   0x00200000
 
#define KEY_NONE   0x00
 
#define KEY_ERROR   0x01
 
#define KEY_PRESS   0
 
#define KEY_RELEASE   0x400
 
#define KEY_INDEX(c)   ((c) & 0xFF)
 
#define SCAN_PRESS   0
 
#define SCAN_RELEASE   0x80
 
#define SCAN_PREFIX_E0   0x100
 
#define SCAN_PREFIX_E1   0x200
 
#define SCAN_PREFIX_CTL   0x400
 
#define SCAN_PREFIX_SHIFT   0x800
 
#define SCAN_PREFIX
 
#define SCAN_CHAR(c)   ((c) & 0x7f)
 
#define UKBD_LOCK()   USB_MTX_LOCK(&Giant)
 
#define UKBD_UNLOCK()   USB_MTX_UNLOCK(&Giant)
 
#define UKBD_LOCK_ASSERT()   USB_MTX_ASSERT(&Giant, MA_OWNED)
 
#define NN   0 /* no translation */
 

Enumerations

enum  { UKBD_INTR_DT_0 , UKBD_INTR_DT_1 , UKBD_CTRL_LED , UKBD_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ukbd_timeout (void *)
 
static void ukbd_set_leds (struct ukbd_softc *, uint8_t)
 
static int ukbd_set_typematic (keyboard_t *, int)
 
static uint32_t ukbd_atkeycode (int, const uint64_t *)
 
static int ukbd_key2scan (struct ukbd_softc *, int, const uint64_t *, int)
 
static uint32_t ukbd_read_char (keyboard_t *, int)
 
static void ukbd_clear_state (keyboard_t *)
 
static int ukbd_ioctl (keyboard_t *, u_long, caddr_t)
 
static int ukbd_enable (keyboard_t *)
 
static int ukbd_disable (keyboard_t *)
 
static void ukbd_interrupt (struct ukbd_softc *)
 
static void ukbd_event_keyinput (struct ukbd_softc *)
 
static bool ukbd_any_key_pressed (struct ukbd_softc *sc)
 
static bool ukbd_any_key_valid (struct ukbd_softc *sc)
 
static bool ukbd_is_modifier_key (uint32_t key)
 
static void ukbd_start_timer (struct ukbd_softc *sc)
 
static void ukbd_put_key (struct ukbd_softc *sc, uint32_t key)
 
static void ukbd_do_poll (struct ukbd_softc *sc, uint8_t wait)
 
static int32_t ukbd_get_key (struct ukbd_softc *sc, uint8_t wait)
 
static uint32_t ukbd_apple_fn (uint32_t keycode)
 
static uint32_t ukbd_apple_swap (uint32_t keycode)
 
static void ukbd_intr_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void ukbd_set_leds_callback (struct usb_xfer *xfer, usb_error_t error)
 
static int ukbd_probe (device_t dev)
 
static void ukbd_parse_hid (struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len)
 
static int ukbd_attach (device_t dev)
 
static int ukbd_detach (device_t dev)
 
static int ukbd_resume (device_t dev)
 
static int ukbd_configure (int flags)
 
static int ukbd__probe (int unit, void *arg, int flags)
 
static int ukbd_init (int unit, keyboard_t **kbdp, void *arg, int flags)
 
static int ukbd_test_if (keyboard_t *kbd)
 
static int ukbd_term (keyboard_t *kbd)
 
static int ukbd_intr (keyboard_t *kbd, void *arg)
 
static int ukbd_lock (keyboard_t *kbd, int lock)
 
static int ukbd_check (keyboard_t *kbd)
 
static int ukbd_check_char_locked (keyboard_t *kbd)
 
static int ukbd_check_char (keyboard_t *kbd)
 
static int ukbd_read (keyboard_t *kbd, int wait)
 
static uint32_t ukbd_read_char_locked (keyboard_t *kbd, int wait)
 
static int ukbd_ioctl_locked (keyboard_t *kbd, u_long cmd, caddr_t arg)
 
static int ukbd_get_state (keyboard_t *kbd, void *buf, size_t len)
 
static int ukbd_set_state (keyboard_t *kbd, void *buf, size_t len)
 
static int ukbd_poll (keyboard_t *kbd, int on)
 
 KEYBOARD_DRIVER (ukbd, ukbdsw, ukbd_configure)
 
static int ukbd_driver_load (module_t mod, int what, void *arg)
 
 DRIVER_MODULE (ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0)
 
 MODULE_DEPEND (ukbd, usb, 1, 1, 1)
 
 MODULE_DEPEND (ukbd, hid, 1, 1, 1)
 
 MODULE_VERSION (ukbd, 1)
 
 USB_PNP_HOST_INFO (ukbd_devs)
 

Variables

static const uint8_t ukbd_trtab [256]
 
static const uint8_t ukbd_boot_desc []
 
static device_probe_t ukbd_probe
 
static device_attach_t ukbd_attach
 
static device_detach_t ukbd_detach
 
static device_resume_t ukbd_resume
 
static const struct usb_config ukbd_config [UKBD_N_TRANSFER]
 
static const STRUCT_USB_HOST_ID __used ukbd_devs []
 
static keyboard_switch_t ukbdsw
 
static devclass_t ukbd_devclass
 
static device_method_t ukbd_methods []
 
static driver_t ukbd_driver
 

Macro Definition Documentation

◆ KEY_ERROR

#define KEY_ERROR   0x01

Definition at line 213 of file ukbd.c.

◆ KEY_INDEX

#define KEY_INDEX (   c)    ((c) & 0xFF)

Definition at line 217 of file ukbd.c.

◆ KEY_NONE

#define KEY_NONE   0x00

Definition at line 212 of file ukbd.c.

◆ KEY_PRESS

#define KEY_PRESS   0

Definition at line 215 of file ukbd.c.

◆ KEY_RELEASE

#define KEY_RELEASE   0x400

Definition at line 216 of file ukbd.c.

◆ MOD_EJECT

#define MOD_EJECT   0x01

Definition at line 124 of file ukbd.c.

◆ MOD_FN

#define MOD_FN   0x02

Definition at line 125 of file ukbd.c.

◆ NN

#define NN   0 /* no translation */

Definition at line 233 of file ukbd.c.

◆ SCAN_CHAR

#define SCAN_CHAR (   c)    ((c) & 0x7f)

Definition at line 227 of file ukbd.c.

◆ SCAN_PREFIX

#define SCAN_PREFIX
Value:
SCAN_PREFIX_CTL | SCAN_PREFIX_SHIFT)
#define SCAN_PREFIX_SHIFT
Definition: ukbd.c:224
#define SCAN_PREFIX_E0
Definition: ukbd.c:221
#define SCAN_PREFIX_E1
Definition: ukbd.c:222

Definition at line 225 of file ukbd.c.

◆ SCAN_PREFIX_CTL

#define SCAN_PREFIX_CTL   0x400

Definition at line 223 of file ukbd.c.

◆ SCAN_PREFIX_E0

#define SCAN_PREFIX_E0   0x100

Definition at line 221 of file ukbd.c.

◆ SCAN_PREFIX_E1

#define SCAN_PREFIX_E1   0x200

Definition at line 222 of file ukbd.c.

◆ SCAN_PREFIX_SHIFT

#define SCAN_PREFIX_SHIFT   0x800

Definition at line 224 of file ukbd.c.

◆ SCAN_PRESS

#define SCAN_PRESS   0

Definition at line 219 of file ukbd.c.

◆ SCAN_RELEASE

#define SCAN_RELEASE   0x80

Definition at line 220 of file ukbd.c.

◆ UKBD_BUFFER_SIZE

#define UKBD_BUFFER_SIZE   64 /* bytes */

Definition at line 118 of file ukbd.c.

◆ UKBD_DRIVER_NAME

#define UKBD_DRIVER_NAME   "ukbd"

Definition at line 113 of file ukbd.c.

◆ UKBD_EMULATE_ATSCANCODE

#define UKBD_EMULATE_ATSCANCODE   1

Definition at line 112 of file ukbd.c.

◆ UKBD_FLAG_APPLE_EJECT

#define UKBD_FLAG_APPLE_EJECT   0x00000040

Definition at line 179 of file ukbd.c.

◆ UKBD_FLAG_APPLE_FN

#define UKBD_FLAG_APPLE_FN   0x00000080

Definition at line 180 of file ukbd.c.

◆ UKBD_FLAG_APPLE_SWAP

#define UKBD_FLAG_APPLE_SWAP   0x00000100

Definition at line 181 of file ukbd.c.

◆ UKBD_FLAG_ATTACHED

#define UKBD_FLAG_ATTACHED   0x00000010

Definition at line 175 of file ukbd.c.

◆ UKBD_FLAG_CAPSLOCK

#define UKBD_FLAG_CAPSLOCK   0x00100000

Definition at line 183 of file ukbd.c.

◆ UKBD_FLAG_COMPOSE

#define UKBD_FLAG_COMPOSE   0x00000001

Definition at line 172 of file ukbd.c.

◆ UKBD_FLAG_GONE

#define UKBD_FLAG_GONE   0x00000020

Definition at line 176 of file ukbd.c.

◆ UKBD_FLAG_HID_MASK

#define UKBD_FLAG_HID_MASK   0x003fffc0

Definition at line 178 of file ukbd.c.

◆ UKBD_FLAG_NUMLOCK

#define UKBD_FLAG_NUMLOCK   0x00080000

Definition at line 182 of file ukbd.c.

◆ UKBD_FLAG_POLLING

#define UKBD_FLAG_POLLING   0x00000002

Definition at line 173 of file ukbd.c.

◆ UKBD_FLAG_SCROLLLOCK

#define UKBD_FLAG_SCROLLLOCK   0x00200000

Definition at line 184 of file ukbd.c.

◆ UKBD_FLAG_SET_LEDS

#define UKBD_FLAG_SET_LEDS   0x00000004

Definition at line 174 of file ukbd.c.

◆ UKBD_IN_BUF_FULL

#define UKBD_IN_BUF_FULL   ((UKBD_IN_BUF_SIZE / 2) - 1) /* scancodes */

Definition at line 116 of file ukbd.c.

◆ UKBD_IN_BUF_SIZE

#define UKBD_IN_BUF_SIZE   (4 * UKBD_NKEYCODE) /* scancodes */

Definition at line 115 of file ukbd.c.

◆ UKBD_KEY_PRESSED

#define UKBD_KEY_PRESSED (   map,
  key 
)
Value:
({ \
CTASSERT((key) >= 0 && (key) < UKBD_NKEYCODE); \
((map)[(key) / 64] & (1ULL << ((key) % 64))); \
})
#define UKBD_NKEYCODE
Definition: ukbd.c:114

Definition at line 119 of file ukbd.c.

◆ UKBD_LOCK

#define UKBD_LOCK ( )    USB_MTX_LOCK(&Giant)

Definition at line 229 of file ukbd.c.

◆ UKBD_LOCK_ASSERT

#define UKBD_LOCK_ASSERT ( )    USB_MTX_ASSERT(&Giant, MA_OWNED)

Definition at line 231 of file ukbd.c.

◆ UKBD_NFKEY

#define UKBD_NFKEY   (sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* units */

Definition at line 117 of file ukbd.c.

◆ UKBD_NKEYCODE

#define UKBD_NKEYCODE   256 /* units */

Definition at line 114 of file ukbd.c.

◆ UKBD_UNLOCK

#define UKBD_UNLOCK ( )    USB_MTX_UNLOCK(&Giant)

Definition at line 230 of file ukbd.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   ukbd_debug

Definition at line 72 of file ukbd.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UKBD_INTR_DT_0 
UKBD_INTR_DT_1 
UKBD_CTRL_LED 
UKBD_N_TRANSFER 

Definition at line 131 of file ukbd.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ukbd  ,
uhub  ,
ukbd_driver  ,
ukbd_devclass  ,
ukbd_driver_load  ,
 
)

◆ KEYBOARD_DRIVER()

KEYBOARD_DRIVER ( ukbd  ,
ukbdsw  ,
ukbd_configure   
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( ukbd  ,
hid  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( ukbd  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ukbd  ,
 
)

◆ ukbd__probe()

static int ukbd__probe ( int  unit,
void *  arg,
int  flags 
)
static

Definition at line 1363 of file ukbd.c.

◆ ukbd_any_key_pressed()

static bool ukbd_any_key_pressed ( struct ukbd_softc sc)
static

Definition at line 331 of file ukbd.c.

References ukbd_data::bitmap, ukbd_softc::sc_odata, and UKBD_NKEYCODE.

Referenced by ukbd_do_poll(), and ukbd_timeout().

Here is the caller graph for this function:

◆ ukbd_any_key_valid()

static bool ukbd_any_key_valid ( struct ukbd_softc sc)
static

Definition at line 342 of file ukbd.c.

References ukbd_softc::sc_loc_key_valid, and UKBD_NKEYCODE.

Referenced by ukbd_attach().

Here is the caller graph for this function:

◆ ukbd_apple_fn()

static uint32_t ukbd_apple_fn ( uint32_t  keycode)
static

Definition at line 618 of file ukbd.c.

Referenced by ukbd_intr_callback().

Here is the caller graph for this function:

◆ ukbd_apple_swap()

static uint32_t ukbd_apple_swap ( uint32_t  keycode)
static

Definition at line 632 of file ukbd.c.

Referenced by ukbd_intr_callback().

Here is the caller graph for this function:

◆ ukbd_atkeycode()

static uint32_t ukbd_atkeycode ( int  usbcode,
const uint64_t *  bitmap 
)
static

Definition at line 2017 of file ukbd.c.

References KEY_INDEX, UKBD_KEY_PRESSED, and ukbd_trtab.

Referenced by ukbd_read(), and ukbd_read_char_locked().

Here is the caller graph for this function:

◆ ukbd_attach()

◆ ukbd_check()

static int ukbd_check ( keyboard_t *  kbd)
static

Definition at line 1433 of file ukbd.c.

References ukbd_softc::sc_buffered_char, ukbd_softc::sc_flags, ukbd_softc::sc_inputs, ukbd_do_poll(), UKBD_FLAG_POLLING, and UKBD_LOCK_ASSERT.

Referenced by ukbd_check_char_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_check_char()

static int ukbd_check_char ( keyboard_t *  kbd)
static

Definition at line 1475 of file ukbd.c.

References ukbd_check_char_locked(), UKBD_LOCK, and UKBD_UNLOCK.

Here is the call graph for this function:

◆ ukbd_check_char_locked()

static int ukbd_check_char_locked ( keyboard_t *  kbd)
static

Definition at line 1458 of file ukbd.c.

References ukbd_softc::sc_composed_char, ukbd_softc::sc_flags, ukbd_check(), UKBD_FLAG_COMPOSE, and UKBD_LOCK_ASSERT.

Referenced by ukbd_check_char().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_clear_state()

◆ ukbd_configure()

static int ukbd_configure ( int  flags)
static

Definition at line 1356 of file ukbd.c.

◆ ukbd_detach()

◆ ukbd_disable()

static int ukbd_disable ( keyboard_t *  kbd)
static

Definition at line 1420 of file ukbd.c.

References UKBD_LOCK, and UKBD_UNLOCK.

Referenced by ukbd_detach().

Here is the caller graph for this function:

◆ ukbd_do_poll()

static void ukbd_do_poll ( struct ukbd_softc sc,
uint8_t  wait 
)
static

Definition at line 412 of file ukbd.c.

References ukbd_softc::sc_flags, ukbd_softc::sc_inputs, ukbd_softc::sc_time_ms, ukbd_softc::sc_xfer, ukbd_any_key_pressed(), UKBD_FLAG_POLLING, ukbd_interrupt(), UKBD_LOCK_ASSERT, UKBD_N_TRANSFER, USB_IN_POLLING_MODE_FUNC, and usbd_transfer_poll().

Referenced by ukbd_check(), and ukbd_get_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_driver_load()

static int ukbd_driver_load ( module_t  mod,
int  what,
void *  arg 
)
static

Definition at line 2163 of file ukbd.c.

◆ ukbd_enable()

static int ukbd_enable ( keyboard_t *  kbd)
static

Definition at line 1408 of file ukbd.c.

References UKBD_LOCK, and UKBD_UNLOCK.

Referenced by ukbd_attach().

Here is the caller graph for this function:

◆ ukbd_event_keyinput()

static void ukbd_event_keyinput ( struct ukbd_softc sc)
static

Definition at line 572 of file ukbd.c.

References ukbd_softc::sc_flags, ukbd_softc::sc_inputs, ukbd_softc::sc_kbd, UKBD_FLAG_POLLING, UKBD_LOCK_ASSERT, and ukbd_read_char().

Referenced by ukbd_interrupt(), and ukbd_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_get_key()

static int32_t ukbd_get_key ( struct ukbd_softc sc,
uint8_t  wait 
)
static

◆ ukbd_get_state()

static int ukbd_get_state ( keyboard_t *  kbd,
void *  buf,
size_t  len 
)
static

Definition at line 1930 of file ukbd.c.

References len.

◆ ukbd_init()

static int ukbd_init ( int  unit,
keyboard_t **  kbdp,
void *  arg,
int  flags 
)
static

Definition at line 1370 of file ukbd.c.

◆ ukbd_interrupt()

◆ ukbd_intr()

static int ukbd_intr ( keyboard_t *  kbd,
void *  arg 
)
static

Definition at line 1391 of file ukbd.c.

◆ ukbd_intr_callback()

◆ ukbd_ioctl()

static int ukbd_ioctl ( keyboard_t *  kbd,
u_long  cmd,
caddr_t  arg 
)
static

Definition at line 1871 of file ukbd.c.

References ukbd_ioctl_locked(), UKBD_LOCK, UKBD_UNLOCK, and USB_IN_POLLING_MODE_FUNC.

Referenced by ukbd_attach(), and ukbd_ioctl_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_ioctl_locked()

static int ukbd_ioctl_locked ( keyboard_t *  kbd,
u_long  cmd,
caddr_t  arg 
)
static

Definition at line 1730 of file ukbd.c.

References ukbd_softc::sc_accents, ukbd_softc::sc_flags, ukbd_softc::sc_mode, ukbd_softc::sc_state, ukbd_clear_state(), UKBD_FLAG_POLLING, ukbd_ioctl(), UKBD_LOCK_ASSERT, ukbd_set_leds(), and ukbd_set_typematic().

Referenced by ukbd_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_is_modifier_key()

static bool ukbd_is_modifier_key ( uint32_t  key)
static

Definition at line 353 of file ukbd.c.

Referenced by ukbd_interrupt().

Here is the caller graph for this function:

◆ ukbd_key2scan()

static int ukbd_key2scan ( struct ukbd_softc sc,
int  code,
const uint64_t *  bitmap,
int  up 
)
static

Definition at line 2044 of file ukbd.c.

References ukbd_softc::sc_buffered_char, SCAN_PREFIX, SCAN_PREFIX_CTL, SCAN_PREFIX_E0, SCAN_PREFIX_E1, SCAN_PREFIX_SHIFT, SCAN_PRESS, SCAN_RELEASE, and UKBD_KEY_PRESSED.

Referenced by ukbd_read(), and ukbd_read_char_locked().

Here is the caller graph for this function:

◆ ukbd_lock()

static int ukbd_lock ( keyboard_t *  kbd,
int  lock 
)
static

Definition at line 1398 of file ukbd.c.

◆ ukbd_parse_hid()

◆ ukbd_poll()

static int ukbd_poll ( keyboard_t *  kbd,
int  on 
)
static

◆ ukbd_probe()

◆ ukbd_put_key()

static void ukbd_put_key ( struct ukbd_softc sc,
uint32_t  key 
)
static

Definition at line 385 of file ukbd.c.

References DPRINTF, KEY_INDEX, KEY_RELEASE, ukbd_softc::sc_input, ukbd_softc::sc_inputs, ukbd_softc::sc_inputtail, UKBD_IN_BUF_SIZE, and UKBD_LOCK_ASSERT.

Referenced by ukbd_interrupt().

Here is the caller graph for this function:

◆ ukbd_read()

static int ukbd_read ( keyboard_t *  kbd,
int  wait 
)
static

◆ ukbd_read_char()

static uint32_t ukbd_read_char ( keyboard_t *  kbd,
int  wait 
)
static

Definition at line 1717 of file ukbd.c.

References UKBD_LOCK, ukbd_read_char_locked(), and UKBD_UNLOCK.

Referenced by ukbd_event_keyinput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_read_char_locked()

static uint32_t ukbd_read_char_locked ( keyboard_t *  kbd,
int  wait 
)
static

◆ ukbd_resume()

static int ukbd_resume ( device_t  dev)
static

Definition at line 1327 of file ukbd.c.

References dev, ukbd_softc::sc_kbd, ukbd_clear_state(), and UKBD_LOCK_ASSERT.

Here is the call graph for this function:

◆ ukbd_set_leds()

static void ukbd_set_leds ( struct ukbd_softc sc,
uint8_t  leds 
)
static

Definition at line 1972 of file ukbd.c.

References DPRINTF, ukbd_softc::sc_flags, ukbd_softc::sc_leds, ukbd_softc::sc_xfer, UKBD_CTRL_LED, UKBD_FLAG_SET_LEDS, UKBD_LOCK_ASSERT, and usbd_transfer_start().

Referenced by ukbd_ioctl_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_set_leds_callback()

◆ ukbd_set_state()

static int ukbd_set_state ( keyboard_t *  kbd,
void *  buf,
size_t  len 
)
static

Definition at line 1937 of file ukbd.c.

◆ ukbd_set_typematic()

static int ukbd_set_typematic ( keyboard_t *  kbd,
int  code 
)
static

Definition at line 1992 of file ukbd.c.

Referenced by ukbd_ioctl_locked().

Here is the caller graph for this function:

◆ ukbd_start_timer()

static void ukbd_start_timer ( struct ukbd_softc sc)
static

Definition at line 360 of file ukbd.c.

References ukbd_softc::sc_callout, ukbd_softc::sc_co_basetime, ukbd_softc::sc_delay, ukbd_softc::sc_kbd, ukbd_timeout(), and usb_callout_reset_sbt.

Referenced by ukbd_interrupt(), and ukbd_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ukbd_term()

static int ukbd_term ( keyboard_t *  kbd)
static

Definition at line 1384 of file ukbd.c.

◆ ukbd_test_if()

static int ukbd_test_if ( keyboard_t *  kbd)
static

Definition at line 1377 of file ukbd.c.

◆ ukbd_timeout()

static void ukbd_timeout ( void *  arg)
static

Definition at line 598 of file ukbd.c.

References ukbd_softc::sc_delay, ukbd_softc::sc_inputs, ukbd_softc::sc_time_ms, ukbd_any_key_pressed(), ukbd_event_keyinput(), ukbd_interrupt(), UKBD_LOCK_ASSERT, and ukbd_start_timer().

Referenced by ukbd_start_timer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( ukbd_devs  )

Variable Documentation

◆ ukbd_attach

device_attach_t ukbd_attach
static

Definition at line 318 of file ukbd.c.

◆ ukbd_boot_desc

const uint8_t ukbd_boot_desc[]
static
Initial value:
= {
0x05, 0x01, 0x09, 0x06, 0xa1,
0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25,
0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75,
0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19,
0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91,
0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00,
0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0
}

Definition at line 285 of file ukbd.c.

Referenced by ukbd_attach().

◆ ukbd_config

const struct usb_config ukbd_config[UKBD_N_TRANSFER]
static
Initial value:
= {
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &ukbd_intr_callback,
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &ukbd_intr_callback,
},
.type = UE_CONTROL,
.endpoint = 0x00,
.direction = UE_DIR_ANY,
.bufsize = sizeof(struct usb_device_request) + UKBD_BUFFER_SIZE,
.callback = &ukbd_set_leds_callback,
.timeout = 1000,
},
}
#define UKBD_BUFFER_SIZE
Definition: ukbd.c:118
static void ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error)
Definition: ukbd.c:642
static void ukbd_set_leds_callback(struct usb_xfer *xfer, usb_error_t error)
Definition: ukbd.c:787
@ UKBD_CTRL_LED
Definition: ukbd.c:134
@ UKBD_INTR_DT_0
Definition: ukbd.c:132
@ UKBD_INTR_DT_1
Definition: ukbd.c:133
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_DIR_ANY
Definition: usb.h:535
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_DIR_IN
Definition: usb.h:531
#define UE_CONTROL
Definition: usb.h:541

Definition at line 891 of file ukbd.c.

Referenced by ukbd_attach().

◆ ukbd_detach

device_detach_t ukbd_detach
static

Definition at line 319 of file ukbd.c.

Referenced by ukbd_attach().

◆ ukbd_devclass

devclass_t ukbd_devclass
static

Definition at line 2176 of file ukbd.c.

◆ ukbd_devs

const STRUCT_USB_HOST_ID __used ukbd_devs[]
static
Initial value:
= {
}
#define UISUBCLASS_BOOT
Definition: usb.h:454
#define UICLASS_HID
Definition: usb.h:453
#define UIPROTO_BOOT_KEYBOARD
Definition: usb.h:455
#define USB_IFACE_SUBCLASS(isc)
Definition: usbdi.h:388
#define USB_IFACE_CLASS(ic)
Definition: usbdi.h:385
#define USB_IFACE_PROTOCOL(ip)
Definition: usbdi.h:391

Definition at line 921 of file ukbd.c.

◆ ukbd_driver

driver_t ukbd_driver
static
Initial value:
= {
.name = "ukbd",
.methods = ukbd_methods,
.size = sizeof(struct ukbd_softc),
}
static device_method_t ukbd_methods[]
Definition: ukbd.c:2178

Definition at line 2187 of file ukbd.c.

◆ ukbd_methods

device_method_t ukbd_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ukbd_probe),
DEVMETHOD(device_attach, ukbd_attach),
DEVMETHOD(device_detach, ukbd_detach),
DEVMETHOD(device_resume, ukbd_resume),
DEVMETHOD_END
}
static device_detach_t ukbd_detach
Definition: ukbd.c:319
static device_resume_t ukbd_resume
Definition: ukbd.c:320
static device_probe_t ukbd_probe
Definition: ukbd.c:317
static device_attach_t ukbd_attach
Definition: ukbd.c:318

Definition at line 2178 of file ukbd.c.

◆ ukbd_probe

device_probe_t ukbd_probe
static

Definition at line 317 of file ukbd.c.

◆ ukbd_resume

device_resume_t ukbd_resume
static

Definition at line 320 of file ukbd.c.

◆ ukbd_trtab

const uint8_t ukbd_trtab[256]
static

Definition at line 250 of file ukbd.c.

Referenced by ukbd_atkeycode(), and ukbd_read_char_locked().

◆ ukbdsw

keyboard_switch_t ukbdsw
static
Initial value:
= {
.probe = &ukbd__probe,
.init = &ukbd_init,
.term = &ukbd_term,
.intr = &ukbd_intr,
.test_if = &ukbd_test_if,
.enable = &ukbd_enable,
.disable = &ukbd_disable,
.read = &ukbd_read,
.check = &ukbd_check,
.read_char = &ukbd_read_char,
.check_char = &ukbd_check_char,
.ioctl = &ukbd_ioctl,
.lock = &ukbd_lock,
.clear_state = &ukbd_clear_state,
.get_state = &ukbd_get_state,
.set_state = &ukbd_set_state,
.poll = &ukbd_poll,
}
static int ukbd_check(keyboard_t *kbd)
Definition: ukbd.c:1433
static int ukbd_get_state(keyboard_t *kbd, void *buf, size_t len)
Definition: ukbd.c:1930
static int ukbd_ioctl(keyboard_t *, u_long, caddr_t)
Definition: ukbd.c:1871
static int ukbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
Definition: ukbd.c:1370
static uint32_t ukbd_read_char(keyboard_t *, int)
Definition: ukbd.c:1717
static int ukbd_lock(keyboard_t *kbd, int lock)
Definition: ukbd.c:1398
static int ukbd_disable(keyboard_t *)
Definition: ukbd.c:1420
static int ukbd_intr(keyboard_t *kbd, void *arg)
Definition: ukbd.c:1391
static int ukbd_check_char(keyboard_t *kbd)
Definition: ukbd.c:1475
static int ukbd_test_if(keyboard_t *kbd)
Definition: ukbd.c:1377
static int ukbd_read(keyboard_t *kbd, int wait)
Definition: ukbd.c:1489
static int ukbd_poll(keyboard_t *kbd, int on)
Definition: ukbd.c:1943
static int ukbd_enable(keyboard_t *)
Definition: ukbd.c:1408
static int ukbd_term(keyboard_t *kbd)
Definition: ukbd.c:1384
static int ukbd_set_state(keyboard_t *kbd, void *buf, size_t len)
Definition: ukbd.c:1937
static void ukbd_clear_state(keyboard_t *)
Definition: ukbd.c:1908
static int ukbd__probe(int unit, void *arg, int flags)
Definition: ukbd.c:1363

Definition at line 2140 of file ukbd.c.