Add support for USB hubs.

This refactors the USB driver code into a more object-oriented design,
with usbkbd.c being the base class and ohci.c and xhci.c being subclasses.
This makes the code that performs USB device enumeration independent of
the host controller.
This commit is contained in:
Martin Whitaker
2022-01-08 23:00:28 +00:00
parent 84da9f7553
commit 52a87c5d40
7 changed files with 1335 additions and 759 deletions

View File

@@ -4,23 +4,20 @@
/*
* Provides support for USB keyboards connected via an XHCI controller.
*
* Copyright (C) 2021 Martin Whitaker.
* Copyright (C) 2021-2022 Martin Whitaker.
*/
#include <stdint.h>
#include "usbkbd.h"
/*
* Initialises the XHCI device found at base_addr, scans all the attached USB
* devices, and configures any HID USB keyboard devices it finds to generate
* periodic interrupt transfers that report key presses.
* periodic interrupt transfers that report key presses. Initialises hcd and
* returns true if the device was successfully initialised and one or more
* keyboards were found.
*/
void *xhci_init(uintptr_t base_addr);
/*
* Polls the completed periodic interrupt transfers, stores the keycodes from
* any new key press events in an internal queue, and if the keycode queue is
* not empty, pops and returns the keycode from the front of the queue.
*/
uint8_t xhci_get_keycode(void *ws);
bool xhci_init(uintptr_t base_addr, usb_hcd_t *hcd);
#endif // XHCI_H