1 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
11 #include <pc80/keyboard.h>
13 #include "northbridge.h"
16 static void northbridge_init(device_t dev)
18 printk(BIOS_SPEW, "Northbridge Init\n");
21 static struct device_operations northbridge_operations = {
22 .read_resources = pci_dev_read_resources,
23 .set_resources = pci_dev_set_resources,
24 .enable_resources = pci_dev_enable_resources,
25 .init = northbridge_init,
30 static const struct pci_driver northbridge_driver __pci_driver = {
31 .ops = &northbridge_operations,
32 .vendor = PCI_VENDOR_ID_INTEL,
36 #if CONFIG_WRITE_HIGH_TABLES==1
37 #define HIGH_TABLES_SIZE 64 // maximum size of high tables in KB
38 extern uint64_t high_tables_base, high_tables_size;
41 static void i440bx_domain_set_resources(device_t dev)
46 pci_tolm = find_pci_tolm(dev->link_list);
47 mc_dev = dev->link_list->children;
49 unsigned long tomk, tolmk;
52 /* Figure out which areas are/should be occupied by RAM. The
53 * value of the highest DRB denotes the end of the physical
54 * memory (in units of 8MB).
56 tomk = ((unsigned long)pci_read_config8(mc_dev, DRB7));
61 printk(BIOS_DEBUG, "Setting RAM size to %ld MB\n", tomk / 1024);
63 /* Compute the top of low memory. */
64 tolmk = pci_tolm / 1024;
67 /* The PCI hole does not overlap the memory. */
71 /* Report the memory regions. */
73 ram_resource(dev, idx++, 0, 640);
74 ram_resource(dev, idx++, 768, tolmk - 768);
76 #if CONFIG_WRITE_HIGH_TABLES==1
77 /* Leave some space for ACPI, PIRQ and MP tables */
78 high_tables_base = (tomk - HIGH_TABLES_SIZE) * 1024;
79 high_tables_size = HIGH_TABLES_SIZE * 1024;
82 assign_resources(dev->link_list);
85 static struct device_operations pci_domain_ops = {
86 .read_resources = pci_domain_read_resources,
87 .set_resources = i440bx_domain_set_resources,
88 .enable_resources = NULL,
90 .scan_bus = pci_domain_scan_bus,
93 static void cpu_bus_init(device_t dev)
95 initialize_cpus(dev->link_list);
98 static void cpu_bus_noop(device_t dev)
102 static struct device_operations cpu_bus_ops = {
103 .read_resources = cpu_bus_noop,
104 .set_resources = cpu_bus_noop,
105 .enable_resources = cpu_bus_noop,
106 .init = cpu_bus_init,
110 static void enable_dev(struct device *dev)
112 /* Set the operations if it is a special bus type */
113 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
114 dev->ops = &pci_domain_ops;
117 else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) {
118 dev->ops = &cpu_bus_ops;
122 struct chip_operations northbridge_intel_i440bx_ops = {
123 CHIP_NAME("Intel 82443BX (440BX) Northbridge")
124 .enable_dev = enable_dev,