summaryrefslogtreecommitdiff
path: root/bios
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2008-09-30 15:11:29 -0600
committerAvi Kivity <avi@redhat.com>2008-10-02 15:33:28 +0300
commit1fb73013fd17f960e595ef899142ddeaadcf70b3 (patch)
tree78192d8f6ade0a204abc0c3a7945039faef4b20f /bios
parent1c025f40ef2247045f8995dd01e76f02ebb4397e (diff)
kvm: bios: cleanup/consolidate above 4G memory parsing
kvm: bios: cleanup/consolidate above 4G memory parsing Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'bios')
-rwxr-xr-xbios/rombios32.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/bios/rombios32.c b/bios/rombios32.c
index befebb9d..bb33cb34 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -416,7 +416,7 @@ uint32_t cpuid_signature;
uint32_t cpuid_features;
uint32_t cpuid_ext_features;
unsigned long ram_size;
-uint64_t above4g_ram_size;
+uint64_t ram_end;
uint8_t bios_uuid[16];
#ifdef BX_USE_EBDA_TABLES
unsigned long ebda_cur_addr;
@@ -531,9 +531,9 @@ void setup_mtrr(void)
wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
vbase += vmask + 1;
}
- for (vbase = 1ull << 32; i < vcnt && vbase < above4g_ram_size; ++i) {
+ for (vbase = 1ull << 32; i < vcnt && vbase < ram_end; ++i) {
vmask = (1ull << 40) - 1;
- while (vbase + vmask + 1 > above4g_ram_size)
+ while (vbase + vmask + 1 > ram_end)
vmask >>= 1;
wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6);
wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
@@ -551,18 +551,19 @@ void ram_probe(void)
ram_size = (cmos_readb(0x17) | (cmos_readb(0x18) << 8)) * 1024;
if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d))
- above4g_ram_size = ((uint64_t)cmos_readb(0x5b) << 16) |
- ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32);
+ ram_end = (((uint64_t)cmos_readb(0x5b) << 16) |
+ ((uint64_t)cmos_readb(0x5c) << 24) |
+ ((uint64_t)cmos_readb(0x5d) << 32)) + (1ull << 32);
+ else
+ ram_end = ram_size;
- if (above4g_ram_size)
- above4g_ram_size += 1ull << 32;
+ BX_INFO("end of ram=%ldMB\n", ram_end >> 20);
BX_INFO("ram_size=0x%08lx\n", ram_size);
#ifdef BX_USE_EBDA_TABLES
ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380;
BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr);
#endif
- BX_INFO("top of ram %ldMB\n", above4g_ram_size >> 20);
setup_mtrr();
}