Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 69