Orion
Barry Keyboard/Mouse drivers + POSIX names for structs 1628fcf (2 years, 4 months ago)diff --git a/drivers/usb/xhci.c b/drivers/usb/xhci.c new file mode 100644 index 0000000..715c3e6 --- /dev/null +++ b/drivers/usb/xhci.c @@ -0,0 +1,74 @@ +/* + * This file implements the driver for the Bochs Graphics Adapter video card. + * It is a simple card available in virtual machines. It creates a framebuffer + * device node, and handles the reading/writing to it, and also mapping the + * framebuffer into memory. + */ + +#include <stdint.h> +#include <string.h> +#include <sys/fb.h> +#include "../drivers.h" +#include "../pci.h" +#include "../../mem/paging.h" +#include "../../vfs/vfs.h" +#include "../../io.h" + +size_t xhci_read(File *file, char *buf, size_t size, off_t offset); +size_t xhci_write(File *file, char *buf, size_t size, off_t offset); +int xhci_ioctl(File *file, unsigned long request, uintptr_t argp); + +FileOps xhciFileOps = { + .read = xhci_read, + .write = xhci_write, + .ioctl = xhci_ioctl, +}; + +Driver xhciDriver = { + .major = 9, + .ops = &xhciFileOps, + .next = NULL, +}; + +/* Initialise the USB driver */ +void +xhci_init(uint8_t bus, uint8_t slot, uint8_t func) +{ + register_driver(&xhciDriver); + + uint8_t intf, class, subclass; + intf = pci_read_byte(bus, slot, func, 9); + subclass = pci_read_byte(bus, slot, func, 10); + class = pci_read_byte(bus, slot, func, 11); + kprintf(" Initialising USB (%#.2x, %#.2x, %#.2x)", + class, subclass, intf); + + /* Map MMIO registers */ + uint32_t bar0, bar1; + bar0 = pci_read_dword(bus, slot, func, 0x10); + bar1 = pci_read_dword(bus, slot, func, 0x14); + *get_page((void *) bar0) = bar0 | PTE_PRESENT | PTE_WRITE | PTE_GLOBAL; + + +} + +/* Read from a USB device */ +size_t +xhci_read(File *file, char *buf, size_t size, off_t offset) +{ + return 0; +} + +/* Write to a USB device */ +size_t +xhci_write(File *file, char *buf, size_t size, off_t offset) +{ + return 0; +} + +/* Control a USB device */ +int +xhci_ioctl(File *file, unsigned long request, uintptr_t argp) +{ + return 0; +} diff --git a/drivers/usb/xhci.h b/drivers/usb/xhci.h new file mode 100644 index 0000000..250abf6 --- /dev/null +++ b/drivers/usb/xhci.h @@ -0,0 +1,6 @@ +#ifndef DRIVERS_USB_XHCI_H +#define DRIVERS_USB_XHCI_H + + + +#endif