1 #include <console/console.h>
3 #include <arch/ioapic.h>
5 #include <device/device.h>
6 #include <device/pci.h>
13 #if CONFIG_WRITE_HIGH_TABLES==1
14 #define HIGH_TABLES_SIZE 64 // maximum size of high tables in KB
15 extern uint64_t high_tables_base, high_tables_size;
18 #define CMOS_ADDR_PORT 0x70
19 #define CMOS_DATA_PORT 0x71
20 #define HIGH_RAM_ADDR 0x35
21 #define LOW_RAM_ADDR 0x34
23 static void cpu_pci_domain_set_resources(device_t dev)
25 u32 pci_tolm = find_pci_tolm(dev->link_list);
26 unsigned long tomk = 0, tolmk;
29 outb (HIGH_RAM_ADDR, CMOS_ADDR_PORT);
30 tomk = ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
31 outb (LOW_RAM_ADDR, CMOS_ADDR_PORT);
32 tomk |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
35 printk(BIOS_DEBUG, "Detected %lu Kbytes (%lu MiB) RAM.\n",
38 /* Compute the top of Low memory */
39 tolmk = pci_tolm >> 10;
41 /* The PCI hole does not overlap the memory. */
45 /* Report the memory regions. */
47 ram_resource(dev, idx++, 0, 640);
48 ram_resource(dev, idx++, 768, tolmk - 768);
50 #if CONFIG_WRITE_HIGH_TABLES==1
51 /* Leave some space for ACPI, PIRQ and MP tables */
52 high_tables_base = (tomk - HIGH_TABLES_SIZE) * 1024;
53 high_tables_size = HIGH_TABLES_SIZE * 1024;
56 assign_resources(dev->link_list);
59 static void cpu_pci_domain_read_resources(struct device *dev)
63 pci_domain_read_resources(dev);
65 /* Reserve space for the IOAPIC. This should be in the Southbridge,
66 * but I couldn't tell which device to put it in. */
67 res = new_resource(dev, 2);
68 res->base = IO_APIC_ADDR;
69 res->size = 0x100000UL;
70 res->limit = 0xffffffffUL;
71 res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
74 /* Reserve space for the LAPIC. There's one in every processor, but
75 * the space only needs to be reserved once, so we do it here. */
76 res = new_resource(dev, 3);
77 res->base = 0xfee00000UL;
78 res->size = 0x10000UL;
79 res->limit = 0xffffffffUL;
80 res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
84 static struct device_operations pci_domain_ops = {
85 .read_resources = cpu_pci_domain_read_resources,
86 .set_resources = cpu_pci_domain_set_resources,
87 .enable_resources = NULL,
89 .scan_bus = pci_domain_scan_bus,
92 static void enable_dev(struct device *dev)
94 /* Set the operations if it is a special bus type */
95 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
96 dev->ops = &pci_domain_ops;
101 struct chip_operations mainboard_emulation_qemu_x86_ops = {
102 CHIP_NAME("QEMU Northbridge")
103 .enable_dev = enable_dev,