iPXE
|
USB keyboard driver. More...
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/console.h>
#include <ipxe/keys.h>
#include <ipxe/keymap.h>
#include <ipxe/usb.h>
#include "usbkbd.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static | LIST_HEAD (usb_keyboards) |
List of USB keyboards. More... | |
static unsigned int | usbkbd_map (unsigned int keycode, unsigned int modifiers, unsigned int leds) |
Map USB keycode to iPXE key. More... | |
static void | usbkbd_produce (struct usb_keyboard *kbd, unsigned int keycode, unsigned int modifiers) |
Insert keypress into keyboard buffer. More... | |
static unsigned int | usbkbd_consume (struct usb_keyboard *kbd) |
Consume character from keyboard buffer. More... | |
static int | usbkbd_has_keycode (struct usb_keyboard_report *report, unsigned int keycode) |
Check for presence of keycode in report. More... | |
static void | usbkbd_report (struct usb_keyboard *kbd, struct usb_keyboard_report *new) |
Handle keyboard report. More... | |
static void | usbkbd_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete interrupt transfer. More... | |
static int | usbkbd_set_leds (struct usb_keyboard *kbd) |
Set keyboard LEDs. More... | |
static int | usbkbd_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | usbkbd_remove (struct usb_function *func) |
Remove device. More... | |
static int | usbkbd_getchar (void) |
Read a character from the console. More... | |
static int | usbkbd_iskey (void) |
Check for available input. More... | |
Variables | |
static struct usb_endpoint_driver_operations | usbkbd_operations |
Interrupt endpoint operations. More... | |
static struct usb_device_id | usbkbd_ids [] |
USB keyboard device IDs. More... | |
struct usb_driver usbkbd_driver | __usb_driver |
USB keyboard driver. More... | |
struct console_driver usbkbd_console | __console_driver |
USB keyboard console. More... | |
USB keyboard driver.
Definition in file usbkbd.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
List of USB keyboards.
|
static |
Map USB keycode to iPXE key.
keycode | Keycode |
modifiers | Modifiers |
leds | LED state |
key | iPXE key |
Key codes are defined in the USB HID Usage Tables Keyboard/Keypad page.
Definition at line 64 of file usbkbd.c.
References BACKSPACE, ESC, key, KEY_DC, KEY_DOWN, KEY_END, KEY_F10, KEY_F11, KEY_F12, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_HOME, KEY_IC, KEY_LEFT, KEY_NPAGE, KEY_PPAGE, key_remap(), KEY_RIGHT, KEY_UP, KEYMAP_ALTGR, KEYMAP_CAPSLOCK, KEYMAP_CTRL, KEYMAP_PSEUDO, keypad(), LF, TAB, USBKBD_ALT_RIGHT, USBKBD_CTRL, USBKBD_KEY_0, USBKBD_KEY_1, USBKBD_KEY_A, USBKBD_KEY_CAPS_LOCK, USBKBD_KEY_ENTER, USBKBD_KEY_MINUS, USBKBD_KEY_NON_US, USBKBD_KEY_NUM_LOCK, USBKBD_KEY_PAD_1, USBKBD_KEY_PAD_DOT, USBKBD_KEY_PAD_ENTER, USBKBD_KEY_SLASH, USBKBD_KEY_SPACE, USBKBD_KEY_UP, USBKBD_KEY_Z, USBKBD_LED_CAPS_LOCK, USBKBD_LED_NUM_LOCK, and USBKBD_SHIFT.
Referenced by usbkbd_produce().
|
static |
Insert keypress into keyboard buffer.
kbd | USB keyboard |
keycode | Keycode |
modifiers | Modifiers |
Definition at line 161 of file usbkbd.c.
References DBGC, DBGC2, key, usb_keyboard::key, usb_keyboard::leds, usb_keyboard::leds_changed, usb_keyboard::name, usb_keyboard::prod, USBKBD_BUFSIZE, usbkbd_fill(), USBKBD_KEY_CAPS_LOCK, USBKBD_KEY_NUM_LOCK, USBKBD_LED_CAPS_LOCK, USBKBD_LED_NUM_LOCK, and usbkbd_map().
Referenced by usbkbd_report().
|
static |
Consume character from keyboard buffer.
kbd | USB keyboard |
character | Character |
Definition at line 208 of file usbkbd.c.
References assert(), usb_keyboard::cons, DBGC2, key, usb_keyboard::key, KEY_ANSI_N, KEY_ANSI_TERMINATOR, KEY_MIN, len, usb_keyboard::name, sprintf, usb_keyboard::subcons, tmp, USBKBD_BUFSIZE, and usbkbd_fill().
Referenced by usbkbd_getchar().
|
static |
Check for presence of keycode in report.
report | Keyboard report |
keycode | Keycode (must be non-zero) |
has_keycode | Keycode is present in report |
Definition at line 269 of file usbkbd.c.
References usb_keyboard_report::keycode.
Referenced by usbkbd_report().
|
static |
Handle keyboard report.
kbd | USB keyboard |
new | New keyboard report |
Definition at line 289 of file usbkbd.c.
References DBGC2, usb_keyboard::holdoff, usb_keyboard_report::keycode, usb_keyboard::keycode, memcpy(), usb_keyboard::name, old, usb_keyboard::report, usbkbd_has_keycode(), USBKBD_HOLDOFF, and usbkbd_produce().
Referenced by usbkbd_complete().
|
static |
Complete interrupt transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 349 of file usbkbd.c.
References container_of, io_buffer::data, DBGC, DBGC_HDA, usb_keyboard::hid, usb_hid::in, iob_len(), usb_keyboard::name, usb_endpoint::open, rc, strerror(), usb_recycle(), and usbkbd_report().
|
static |
Set keyboard LEDs.
kbd | USB keyboard |
rc | Return status code |
Definition at line 400 of file usbkbd.c.
References DBGC, DBGC2, usb_hid::func, usb_keyboard::hid, usb_function::interface, usb_keyboard::leds, usb_keyboard::name, rc, strerror(), usb_function::usb, USBHID_REPORT_OUTPUT, and usbhid_set_report().
Referenced by usbkbd_iskey(), and usbkbd_probe().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 432 of file usbkbd.c.
References usb_keyboard::bus, usb_hub::bus, DBGC, ENOMEM, free, usb_keyboard::hid, usb_port::hub, usb_hid::in, usb_function::interface, usb_keyboard::list, list_add_tail, usb_endpoint::mtu, usb_keyboard::name, usb_function::name, NULL, usb_device::port, rc, usb_keyboard::report, strerror(), usb_function::usb, usb_endpoint_name(), usb_func_set_drvdata(), usb_refill_init(), usbhid_close(), usbhid_describe(), usbhid_init(), usbhid_open(), USBHID_PROTOCOL_BOOT, usbhid_set_idle(), usbhid_set_protocol(), USBKBD_IDLE_DURATION, USBKBD_INTR_MAX_FILL, usbkbd_operations, usbkbd_set_leds(), and zalloc().
|
static |
Remove device.
func | USB function |
Definition at line 506 of file usbkbd.c.
References free, usb_keyboard::hid, usb_keyboard::list, list_del, usb_func_get_drvdata(), and usbhid_close().
|
static |
Read a character from the console.
character | Character read |
Definition at line 551 of file usbkbd.c.
References usb_keyboard::list, list_for_each_entry, usbkbd_consume(), and usbkbd_fill().
|
static |
Check for available input.
is_available | Input is available |
Definition at line 568 of file usbkbd.c.
References usb_keyboard::bus, fill, usb_keyboard::hid, usb_hid::in, usb_keyboard::leds_changed, usb_keyboard::list, list_for_each_entry, usb_poll(), usb_refill(), usbkbd_fill(), and usbkbd_set_leds().
|
static |
Interrupt endpoint operations.
Definition at line 383 of file usbkbd.c.
Referenced by usbkbd_probe().
|
static |
USB keyboard device IDs.
struct usb_driver usbkbd_driver __usb_driver |
USB keyboard driver.
struct console_driver usbkbd_console __console_driver |
USB keyboard console.