Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/libsaio/pci_setup.c

1#include "libsaio.h"
2#include "boot.h"
3#include "bootstruct.h"
4#include "pci.h"
5#include "gma.h"
6#include "nvidia.h"
7#include "modules.h"
8
9#define DEBUG_PCI 0
10
11#if DEBUG_PCI
12#define DBG(x...) msglog(x)
13#else
14#define DBG(x...)
15#endif
16
17extern bool setup_ati_devprop(pci_dt_t *ati_dev);
18extern void set_eth_builtin(pci_dt_t *eth_dev);
19extern void notify_usb_dev(pci_dt_t *pci_dev);
20extern void force_enable_hpet(pci_dt_t *lpc_dev);
21
22extern pci_dt_t *dram_controller_dev;
23
24uint16_t vgaVendor;
25
26void setup_pci_devs(pci_dt_t *pci_dt)
27{
28char *devicepath;
29bool do_eth_devprop, do_gfx_devprop, do_enable_hpet;
30pci_dt_t *current = pci_dt;
31
32do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;
33
34getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);
35getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);
36getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);
37
38while (current)
39{
40devicepath = get_pci_dev_path(current);
41
42switch (current->class_id)
43{
44case PCI_CLASS_BRIDGE_HOST:
45DBG("Setup BRIDGE_HOST \n");
46if (current->dev.addr == PCIADDR(0, 0, 0))
47{
48dram_controller_dev = current;
49}
50break;
51
52case PCI_CLASS_NETWORK_ETHERNET:
53DBG("Setup ETHERNET %s enabled\n", do_eth_devprop?"":"no");
54if (do_eth_devprop)
55{
56set_eth_builtin(current);
57}
58break;
59
60case PCI_CLASS_DISPLAY_VGA:
61DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop?"":"no");
62if (do_gfx_devprop)
63{
64vgaVendor = current->vendor_id;
65switch (vgaVendor)
66{
67case PCI_VENDOR_ID_ATI:
68setup_ati_devprop(current);
69break;
70
71case PCI_VENDOR_ID_INTEL:
72setup_gma_devprop(current);
73break;
74
75case PCI_VENDOR_ID_NVIDIA:
76setup_nvidia_devprop(current);
77break;
78}
79}
80break;
81
82case PCI_CLASS_SERIAL_USB:
83DBG("USB fix \n");
84notify_usb_dev(current);
85break;
86
87case PCI_CLASS_BRIDGE_ISA:
88DBG("Force HPET %s enabled\n", do_enable_hpet?"":"no");
89if (do_enable_hpet)
90{
91force_enable_hpet(current);
92}
93break;
94}
95
96execute_hook("PCIDevice", current, NULL, NULL, NULL);
97DBG("setup_pci_devs current devID=%08x\n", current->device_id);
98setup_pci_devs(current->children);
99current = current->next;
100}
101}
102

Archive Download this file

Revision: 2045