stub usb-uhci module

This commit is contained in:
Kevin Lange 2014-04-10 23:22:10 -07:00
parent 75a7d5e7f2
commit 62f0afa077

45
modules/usbuhci.c Normal file
View File

@ -0,0 +1,45 @@
#include <module.h>
#include <pci.h>
#include <printf.h>
#include <logging.h>
#include <mod/shell.h>
static uint32_t hub_device = 0;
static void find_usb_device(uint32_t device, uint16_t vendorid, uint16_t deviceid) {
if (pci_find_type(device) == 0xc03) {
int prog_if = (int)pci_read_field(device, PCI_PROG_IF, 1);
if (prog_if == 0) {
hub_device = device;
}
}
}
DEFINE_SHELL_FUNCTION(usb, "Enumerate USB devices (UHCI)") {
pci_scan(&find_usb_device, -1);
if (!hub_device) {
fprintf(tty, "Failed to locate a UHCI controller.\n");
return 1;
}
fprintf(tty, "Located UHCI controller: %2x:%2x.%d\n",
(int)pci_extract_bus (hub_device),
(int)pci_extract_slot(hub_device),
(int)pci_extract_func(hub_device));
return 0;
}
static int install(void) {
BIND_SHELL_FUNCTION(usb);
return 0;
}
static int uninstall(void) {
return 0;
}
MODULE_DEF(usbuhci, install, uninstall);
MODULE_DEPENDS(debugshell);