64 static unsigned int usbkbd_map (
unsigned int keycode,
unsigned int modifiers,
86 static const uint8_t unmodifable[] =
99 0, 0, 0, 0, 0,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
162 unsigned int modifiers ) {
163 unsigned int leds = 0;
185 DBGC ( kbd,
"KBD %s has no key for keycode %#02x:%#02x\n",
186 kbd->
name, modifiers, keycode );
192 DBGC ( kbd,
"KBD %s buffer overrun (key %#02x)\n",
199 DBGC2 ( kbd,
"KBD %s key %#02x produced\n", kbd->
name,
key );
209 static char buf[] =
"\x1b[xx~";
212 unsigned int character;
225 DBGC2 ( kbd,
"KBD %s key %#02x consumed\n", kbd->
name,
key );
238 DBGC2 ( kbd,
"KBD %s key %#02x consumed as ^[%s\n",
244 character = buf[ kbd->
subcons++ ];
270 unsigned int keycode ) {
274 for ( i = 0 ; i < (
sizeof ( report->
keycode ) /
275 sizeof ( report->
keycode[0] ) ) ; i++ ) {
276 if ( report->
keycode[i] == keycode )
297 DBGC2 ( kbd,
"KBD %s keycode %#02x released\n",
307 for ( i = 0 ; i < (
sizeof (
new->keycode ) /
308 sizeof ( new->keycode[0] ) ) ; i++ ) {
314 DBGC2 ( kbd,
"KBD %s keycode %#02x pressed\n",
361 DBGC ( kbd,
"KBD %s interrupt IN failed: %s\n",
367 if (
iob_len ( iobuf ) <
sizeof ( *report ) ) {
368 DBGC ( kbd,
"KBD %s underlength report:\n", kbd->
name );
372 report = iobuf->
data;
404 DBGC2 ( kbd,
"KBD %s setting LEDs to %#02x\n", kbd->
name, kbd->
leds );
409 sizeof ( kbd->
leds ) ) ) != 0 ) {
410 DBGC ( kbd,
"KBD %s could not set LEDs to %#02x: %s\n",
439 kbd =
zalloc (
sizeof ( *kbd ) );
452 DBGC ( kbd,
"KBD %s could not describe: %s\n",
456 DBGC ( kbd,
"KBD %s using %s (len %zd)\n",
462 DBGC ( kbd,
"KBD %s could not set boot protocol: %s\n",
464 goto err_set_protocol;
470 DBGC ( kbd,
"KBD %s could not set idle time: %s\n",
477 DBGC ( kbd,
"KBD %s could not open: %s\n",
#define USB_SUBCLASS_HID_BOOT
Subclass code for boot devices.
static int usbkbd_has_keycode(struct usb_keyboard_report *report, unsigned int keycode)
Check for presence of keycode in report.
static int usbkbd_getchar(void)
Read a character from the console.
uint8_t keycode[6]
Keycodes.
struct arbelprm_rc_send_wqe rc
#define KEYMAP_CAPSLOCK
CapsLock key flag.
unsigned int prod
Keyboard buffer producer counter.
static unsigned int usbkbd_map(unsigned int keycode, unsigned int modifiers, unsigned int leds)
Map USB keycode to iPXE key.
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
static struct usb_device_id usbkbd_ids[]
USB keyboard device IDs.
uint8_t interface[0]
List of interface numbers.
struct list_head list
List of all USB keyboards.
#define KEYMAP_CTRL
Ctrl key flag.
unsigned int subcons
Keyboard buffer sub-consumer counter.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
#define KEY_F8
F8 (for PXE)
static void usbkbd_produce(struct usb_keyboard *kbd, unsigned int keycode, unsigned int modifiers)
Insert keypress into keyboard buffer.
struct usb_endpoint in
Interrupt IN endpoint.
static struct usb_endpoint_driver_operations usbkbd_operations
Interrupt endpoint operations.
static int usbkbd_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
int usbhid_describe(struct usb_hid *hid, struct usb_configuration_descriptor *config)
Describe USB human interface device.
unsigned int key[USBKBD_BUFSIZE]
Keyboard buffer.
#define USBKBD_INTR_MAX_FILL
Interrupt endpoint maximum fill level.
#define KEY_NPAGE
Page down.
#define KEY_ANSI_TERMINATOR(key)
static unsigned int usbkbd_fill(struct usb_keyboard *kbd)
Calculate keyboard buffer fill level.
int open
Endpoint is open.
int usb_refill(struct usb_endpoint *ep)
Refill endpoint.
#define USBKBD_PROTOCOL
Keyboard protocol.
#define USBKBD_SHIFT
Either Shift key.
#define KEY_DOWN
Down arrow.
#define list_del(list)
Delete an entry from a list.
void usbhid_close(struct usb_hid *hid)
Close USB human interface device.
struct usb_bus * bus
USB bus.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t leds
Keyboard LED state.
static LIST_HEAD(usb_keyboards)
List of USB keyboards.
static int usbhid_set_idle(struct usb_device *usb, unsigned int interface, unsigned int report, unsigned int duration)
Set idle time.
struct usb_port * port
USB port.
static void usb_recycle(struct usb_endpoint *ep, struct io_buffer *iobuf)
Recycle I/O buffer.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
#define KEYMAP_ALTGR
AltGr key flag.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
static void usbkbd_report(struct usb_keyboard *kbd, struct usb_keyboard_report *new)
Handle keyboard report.
unsigned int keycode
Most recently pressed non-modifier key (if any)
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
#define KEYMAP_PSEUDO
Pseudo key flag.
struct usb_hid hid
USB human interface device.
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
static int usbkbd_iskey(void)
Check for available input.
#define ESC
Escape character.
int keypad(WINDOW *, bool)
#define USBKBD_HOLDOFF
Keyboard auto-repeat hold-off (in units of USBKBD_IDLE_DURATION)
struct usb_driver usbkbd_driver __usb_driver
USB keyboard driver.
#define USBKBD_CTRL
Either Ctrl key.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
uint8_t leds_changed
Keyboard LEDs changed.
unsigned int key_remap(unsigned int character)
Remap a key.
#define KEY_PPAGE
Page up.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
static int usbhid_set_protocol(struct usb_device *usb, unsigned int interface, unsigned int protocol)
Set protocol.
void * zalloc(size_t size)
Allocate cleared memory.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define USBHID_REPORT_OUTPUT
Output report type.
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
unsigned int holdoff
Autorepeat hold-off time (in number of completions reported)
#define USBKBD_BUFSIZE
Keyboard buffer size.
struct usb_device * usb
USB device.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
static void usbkbd_remove(struct usb_function *func)
Remove device.
size_t mtu
Maximum transfer size.
struct console_driver usbkbd_console __console_driver
USB keyboard console.
struct usb_keyboard_report report
Most recent keyboard report.
unsigned int cons
Keyboard buffer consumer counter.
A USB configuration descriptor.
#define USB_ANY_ID
Match-anything ID.
Universal Serial Bus (USB)
void * data
Start of data.
static int usbkbd_set_leds(struct usb_keyboard *kbd)
Set keyboard LEDs.
struct usb_hub * hub
USB hub.
static int usbhid_set_report(struct usb_device *usb, unsigned int interface, unsigned int type, unsigned int report, void *data, size_t len)
Set report.
#define USB_CLASS_HID
Class code for human interface devices.
#define KEY_RIGHT
Right arrow.
static void usbkbd_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
static void usbhid_init(struct usb_hid *hid, struct usb_function *func, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB human interface device.
#define USBHID_PROTOCOL_BOOT
Boot protocol.
struct usb_function * func
USB function.
USB endpoint driver operations.
struct usb_bus * bus
USB bus.
int(* getchar)(void)
Read a character from the console.
#define NULL
NULL pointer (VOID *)
int usbhid_open(struct usb_hid *hid)
Open USB human interface device.
#define KEY_LEFT
Left arrow.
static unsigned int usbkbd_consume(struct usb_keyboard *kbd)
Consume character from keyboard buffer.
struct usb_device_id * ids
USB ID table.
#define USBKBD_IDLE_DURATION
Keyboard idle duration (in 4ms units)