1 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/hypertransport.h>
11 #include "northbridge.h"
15 printk_err("Hard_RESET!!!\n");
18 #define BRIDGE_IO_MASK (IORESOURCE_IO | IORESOURCE_MEM)
20 static void pci_domain_read_resources(device_t dev)
22 struct resource *resource;
25 /* Initialize the system wide io space constraints */
26 resource = new_resource(dev, 0);
27 resource->base = 0x400;
28 resource->limit = 0xffffUL;
29 resource->flags = IORESOURCE_IO;
30 compute_allocate_resource(&dev->link[0], resource,
31 IORESOURCE_IO, IORESOURCE_IO);
33 /* Initialize the system wide memory resources constraints */
34 resource = new_resource(dev, 1);
35 resource->limit = 0xffffffffULL;
36 resource->flags = IORESOURCE_MEM;
37 compute_allocate_resource(&dev->link[0], resource,
38 IORESOURCE_MEM, IORESOURCE_MEM);
41 static void ram_resource(device_t dev, unsigned long index,
42 unsigned long basek, unsigned long sizek)
44 struct resource *resource;
49 resource = new_resource(dev, index);
50 resource->base = ((resource_t)basek) << 10;
51 resource->size = ((resource_t)sizek) << 10;
52 resource->flags = IORESOURCE_MEM | IORESOURCE_CACHEABLE | \
53 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
57 static void pci_domain_set_resources(device_t dev)
59 struct resource *resource, *last;
64 pci_tolm = 0xffffffffUL;
65 last = &dev->resource[dev->resources];
66 for(resource = &dev->resource[0]; resource < last; resource++)
68 compute_allocate_resource(&dev->link[0], resource,
69 BRIDGE_IO_MASK, resource->flags & BRIDGE_IO_MASK);
71 resource->flags |= IORESOURCE_STORED;
72 report_resource_stored(dev, resource, "");
74 if ((resource->flags & IORESOURCE_MEM) &&
75 (pci_tolm > resource->base))
77 pci_tolm = resource->base;
82 mc_dev = dev->link[0].children;
84 unsigned long tomk, tolmk;
85 /* Hard code the Top of memory for now */
87 /* Compute the top of Low memory */
88 tolmk = pci_tolm >> 10;
90 /* The PCI hole does not overlap memory.
95 /* Report the memory regions */
97 ram_resource(dev, idx++, 0, 640);
98 ram_resource(dev, idx++, 768, tolmk - 768);
99 if (tomk > 4*1024*1024) {
100 ram_resource(dev, idx++, 4096*1024, tomk - 4*1024*1024);
103 assign_resources(&dev->link[0]);
106 static unsigned int pci_domain_scan_bus(device_t dev, unsigned int max)
108 max = pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, max);
112 static struct device_operations pci_domain_ops = {
113 .read_resources = pci_domain_read_resources,
114 .set_resources = pci_domain_set_resources,
115 .enable_resources = enable_childrens_resources,
117 .scan_bus = pci_domain_scan_bus,
120 static void enable_dev(struct device *dev)
122 struct device_path path;
124 /* Set the operations if it is a special bus type */
125 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
126 dev->ops = &pci_domain_ops;
130 struct chip_operations northbridge_emulation_qemu_i386_ops = {
131 // .name = "QEMU Northbridge",
132 .enable_dev = enable_dev,