1 | #include "libsaio.h"␊ |
2 | #include "bootstruct.h"␊ |
3 | #include "pci.h"␊ |
4 | ␊ |
5 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
6 | extern bool setup_nvidia_devprop(pci_dt_t *nvda_dev);␊ |
7 | extern bool setup_ati_devprop(pci_dt_t *ati_dev);␊ |
8 | extern bool setup_gma_devprop(pci_dt_t *gma_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("EthernetBuiltIn", &do_eth_devprop, &bootInfo->bootConfig);␊ |
22 | ␉getBoolForKey("GraphicsEnabler", &do_gfx_devprop, &bootInfo->bootConfig);␊ |
23 | ␉if (getBoolForKey("USBBusFix", &fix_usb, &bootInfo->bootConfig) && fix_usb)␊ |
24 | ␉␉fix_ehci = fix_uhci = true;␊ |
25 | ␉else␊ |
26 | ␉{␊ |
27 | ␉␉getBoolForKey("EHCIacquire", &fix_ehci, &bootInfo->bootConfig);␊ |
28 | ␉␉getBoolForKey("UHCIreset", &fix_uhci, &bootInfo->bootConfig);␊ |
29 | ␉}␊ |
30 | ␉getBoolForKey("ForceHPET", &do_enable_hpet, &bootInfo->bootConfig);␊ |
31 | ␊ |
32 | ␉while (current)␊ |
33 | ␉{␊ |
34 | ␉␉devicepath = get_pci_dev_path(current);␊ |
35 | ␊ |
36 | ␉␉switch (current->class_id)␊ |
37 | ␉␉{␊ |
38 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
39 | ␉␉␉␉if (do_eth_devprop)␊ |
40 | ␉␉␉␉␉set_eth_builtin(current);␊ |
41 | ␉␉␉␉break;␊ |
42 | ␉␉␉␉␊ |
43 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
44 | ␉␉␉␉if (do_gfx_devprop)␊ |
45 | ␉␉␉␉␉switch (current->vendor_id)␊ |
46 | ␉␉␉␉␉{␊ |
47 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
48 | ␉␉␉␉␉␉␉verbose("ATI VGA Controller [%04x:%04x] :: %s \n", ␊ |
49 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
50 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
51 | ␉␉␉␉␉␉␉break;␊ |
52 | ␉␉␉␉␉␊ |
53 | ␉␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
54 | ␉␉␉␉␉␉␉␉verbose("Intel Graphics Controller [%04x:%04x] :: %s \n", ␊ |
55 | ␉␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
56 | ␉␉␉␉␉␉␉␉setup_gma_devprop(current); ␊ |
57 | ␉␉␉␉␉␉␉␉break;␊ |
58 | ␉␉␉␉␉␊ |
59 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
60 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
61 | ␉␉␉␉␉␉␉break;␊ |
62 | ␉␉␉␉␉}␊ |
63 | ␉␉␉␉break;␊ |
64 | ␊ |
65 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
66 | ␉␉␉␉switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))␊ |
67 | ␉␉␉␉{␊ |
68 | ␉␉␉␉␉/* EHCI */␊ |
69 | ␉␉␉␉␉case 0x20:␊ |
70 | ␉␉␉␉ ␉if (fix_ehci)␊ |
71 | ␉␉␉␉␉␉␉ehci_acquire(current);␊ |
72 | ␉␉␉␉␉␉break;␊ |
73 | ␊ |
74 | ␉␉␉␉␉/* UHCI */␊ |
75 | ␉␉␉␉␉case 0x00:␊ |
76 | ␉␉␉␉ ␉if (fix_uhci)␊ |
77 | ␉␉␉␉␉␉␉uhci_reset(current);␊ |
78 | ␉␉␉␉␉␉break;␊ |
79 | ␉␉␉␉}␊ |
80 | ␉␉␉␉break;␊ |
81 | ␊ |
82 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
83 | ␉␉␉␉if (do_enable_hpet)␊ |
84 | ␉␉␉␉␉force_enable_hpet(current);␊ |
85 | ␉␉␉␉break;␊ |
86 | ␉␉}␊ |
87 | ␉␉␊ |
88 | ␉␉setup_pci_devs(current->children);␊ |
89 | ␉␉current = current->next;␊ |
90 | ␉}␊ |
91 | }␊ |
92 | |