usb.patch, with conflicts and some warnings fixed
[pintos-anon] / src / devices / usb_ehci.c
1 /**
2  *
3  * Actual EHCI will be implemented later
4  *
5  * For now, we just deactivate the EHCI controller and routing circuitry
6  * so that any USB2.0 devices activated by the BIOS will show up on the 
7  * USB1.1 controllers instead of being routed to EHCI and therefore "invisible"
8  * to the system.
9  *
10  */
11
12 #include "devices/pci.h"
13 #include "devices/usb.h"
14 #include <stdlib.h>
15 #include <stdio.h>
16
17 /* capability registers */
18 #define EHCI_REG_CAPLENGTH      0x00
19
20 /* operational regisers - must be offset by op_base */
21 #define EHCI_REG_CONFIGFLAG     0x40
22
23 void ehci_init (void);
24
25
26 void
27 ehci_init (void)
28 {
29   struct pci_dev *pd;
30   int dev_num;
31
32   dev_num = 0;
33   while ((pd = pci_get_dev_by_class (PCI_MAJOR_SERIALBUS, PCI_MINOR_USB,
34                                      PCI_USB_IFACE_EHCI, dev_num)) != NULL)
35     {
36       struct pci_io *io;
37       uint8_t op_base;
38
39       dev_num++;
40       io = pci_io_enum (pd, NULL);
41       if (io == NULL)
42         {
43           printf ("IO not found on EHCI device?\n");
44           continue;
45         }
46       printf ("Disabling the EHCI controller #%d\n", dev_num - 1);
47       op_base = pci_reg_read8 (io, EHCI_REG_CAPLENGTH);
48
49       /* turn off EHCI routing */
50       pci_reg_write32 (io, EHCI_REG_CONFIGFLAG + op_base, 0);
51     }
52 }