BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / 1628fcfdfdf2978ed9ccac96ee7d13bb3dc43a01 / drivers / usb / xhci.c

// Related

Orion

Barry Keyboard/Mouse drivers + POSIX names for structs 1628fcf (2 years, 4 months ago)
/*
 * 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;
}