Chameleon

Chameleon Svn Source Tree

Root/branches/rekursor/i386/libsaio/pci_setup.c

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

Archive Download this file

Revision: 62