1 #include <console/console.h>
5 #include <part/sizeram.h>
6 #include <device/device.h>
7 #include <device/pci.h>
13 struct mem_range *sizeram(void)
15 static struct mem_range mem[4];
16 /* the units of tolm are 64 KB */
17 /* the units of drb16 are 64 MB */
18 uint16_t tolm, remapbase, remaplimit, drb16;
19 uint16_t tolm_r, remapbase_r, remaplimit_r;
24 dev = dev_find_slot(0, 0); // d0f0
26 printk_err("Cannot find PCI: 0:0\n");
30 /* Calculate and report the top of low memory and
33 /* Test if the remap memory high option is set */
35 // if(get_option(&remap_high, "remap_memory_high")){
38 printk_debug("remap_high is %d\n", remap_high);
39 /* get out the value of the highest DRB. This tells the end of
40 * physical memory. The units are ticks of 64 MB i.e. 1 means
43 drb = pci_read_config8(dev, 0x67);
44 drb16 = (uint16_t)drb;
45 if(remap_high && (drb16 > 0x08)) {
46 /* We only come here if we have at least 512MB of memory,
47 * so it is safe to hard code tolm.
52 /* i.e 0x40 * 0x40 is 0x1000 which is 4 GB */
54 /* There is more than 4GB of memory put
55 * the remap window at the end of ram.
58 remaplimit = remapbase + 0x38;
62 remaplimit = remapbase + (drb16-8);
66 tolm = (uint16_t)((dev_root.resource[1].base >> 16)&0x0f800);
67 if((tolm>>8) >= (drb16<<2)) {
74 remaplimit = remapbase + ((0x0040-(tolm>>10))-1);
77 /* Write the ram configruation registers,
78 * preserving the reserved bits.
80 tolm_r = pci_read_config16(dev, 0xc4);
81 tolm |= (tolm_r & 0x7ff);
82 pci_write_config16(dev, 0xc4, tolm);
83 remapbase_r = pci_read_config16(dev, 0xc6);
84 remapbase |= (remapbase_r & 0xfc00);
85 pci_write_config16(dev, 0xc6, remapbase);
86 remaplimit_r = pci_read_config16(dev, 0xc8);
87 remaplimit |= (remaplimit_r & 0xfc00);
88 pci_write_config16(dev, 0xc8, remaplimit);
91 printk_debug("mem info tolm = %x, drb = %x, pci_memory_base = %x, remap = %x-%x\n",tolm,drb,pci_memory_base,remapbase,remaplimit);
97 /* Convert size in 64K bytes to size in K bytes */
98 mem[1].sizek = (tolm << 6) - mem[1].basek;
101 if ((drb << 16) > (tolm << 6)) {
102 /* We don't need to consider the remap window
103 * here because we put it immediately after the
105 * All we must do is calculate the amount
106 * of unused memory and report it at 4GB.
108 mem[2].basek = 4096*1024;
109 mem[2].sizek = (drb << 16) - (tolm << 6);
117 struct chip_operations northbridge_intel_i855pm_control = {
118 .name = "intel i855pm Northbridge",