1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "nvidia.h"␊ |
6 | #include "ati.h"␊ |
7 | ␊ |
8 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
9 | extern int ehci_acquire(pci_dt_t *pci_dev);␊ |
10 | extern int uhci_reset(pci_dt_t *pci_dev);␊ |
11 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
12 | ␊ |
13 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
14 | {␊ |
15 | ␉char *devicepath;␊ |
16 | ␉bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_uhci, fix_usb, do_enable_hpet;␊ |
17 | ␉pci_dt_t *current = pci_dt;␊ |
18 | ␊ |
19 | ␉do_eth_devprop = do_gfx_devprop = fix_ehci = fix_uhci = fix_usb = do_enable_hpet = false;␊ |
20 | ␊ |
21 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);␊ |
22 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig);␊ |
23 | ␉if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig) && fix_usb) {␊ |
24 | ␉␉fix_ehci = fix_uhci = true;␊ |
25 | ␉} else {␊ |
26 | ␉␉getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig);␊ |
27 | ␉␉getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig);␊ |
28 | ␉}␊ |
29 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig);␊ |
30 | ␊ |
31 | ␉while (current)␊ |
32 | ␉{␊ |
33 | ␉␉devicepath = get_pci_dev_path(current);␊ |
34 | ␊ |
35 | ␉␉switch (current->class_id)␊ |
36 | ␉␉{␊ |
37 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
38 | ␉␉␉␉if (do_eth_devprop)␊ |
39 | ␉␉␉␉␉set_eth_builtin(current);␊ |
40 | ␉␉␉␉break;␊ |
41 | ␉␉␉␉␊ |
42 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
43 | ␉␉␉␉if (do_gfx_devprop)␊ |
44 | ␉␉␉␉␉switch (current->vendor_id)␊ |
45 | ␉␉␉␉␉{␊ |
46 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
47 | ␉␉␉␉␉␉␉verbose("ATI VGA Controller [%04x:%04x] :: %s \n", ␊ |
48 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
49 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
50 | ␉␉␉␉␉␉␉break;␊ |
51 | ␉␉␉␉␉␊ |
52 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL: ␊ |
53 | ␉␉␉␉␉␉␉/* message to be removed once support for these cards is added */␊ |
54 | ␉␉␉␉␉␉␉verbose("Intel VGA Controller [%04x:%04x] :: %s (currently NOT SUPPORTED)\n", ␊ |
55 | ␉␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
56 | ␉␉␉␉␉␉␉break;␊ |
57 | ␉␉␉␉␉␊ |
58 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
59 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
60 | ␉␉␉␉␉␉␉break;␊ |
61 | ␉␉␉␉␉}␊ |
62 | ␉␉␉␉break;␊ |
63 | ␊ |
64 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
65 | ␉␉␉␉switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))␊ |
66 | ␉␉␉␉{␊ |
67 | ␉␉␉␉␉/* EHCI */␊ |
68 | ␉␉␉␉␉case 0x20:␊ |
69 | ␉␉␉␉ ␉if (fix_ehci)␊ |
70 | ␉␉␉␉␉␉␉ehci_acquire(current);␊ |
71 | ␉␉␉␉␉␉break;␊ |
72 | ␊ |
73 | ␉␉␉␉␉/* UHCI */␊ |
74 | ␉␉␉␉␉case 0x00:␊ |
75 | ␉␉␉␉ ␉if (fix_uhci)␊ |
76 | ␉␉␉␉␉␉␉uhci_reset(current);␊ |
77 | ␉␉␉␉␉␉break;␊ |
78 | ␉␉␉␉}␊ |
79 | ␉␉␉␉break;␊ |
80 | ␊ |
81 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
82 | ␉␉␉␉if (do_enable_hpet)␊ |
83 | ␉␉␉␉␉force_enable_hpet(current);␊ |
84 | ␉␉␉␉break;␊ |
85 | ␉␉}␊ |
86 | ␉␉␊ |
87 | ␉␉setup_pci_devs(current->children);␊ |
88 | ␉␉current = current->next;␊ |
89 | ␉}␊ |
90 | }␊ |
91 | |