From: Alex Williamson Subject: [PATCH 2/5] bios: reformat ram_probe() to match the surrounding code Date: Tue, 23 Sep 2008 10:42:14 -0600 Message-ID: <1222188134.8138.103.camel@2710p.home> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Avi Kivity To: kvm-devel Return-path: Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:41270 "EHLO g5t0007.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752284AbYIWQmR (ORCPT ); Tue, 23 Sep 2008 12:42:17 -0400 Sender: kvm-owner@vger.kernel.org List-ID: kvm: bios: reformat ram_probe() to match the surrounding code Also fixes mem_top to always report the top of memory. Signed-off-by: Alex Williamson --- bios/rombios32.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bios/rombios32.c b/bios/rombios32.c index 41025a0..4821ec4 100755 --- a/bios/rombios32.c +++ b/bios/rombios32.c @@ -544,25 +544,26 @@ void setup_mtrr(void) void ram_probe(void) { - if (cmos_readb(0x34) | cmos_readb(0x35)) - low_ram_size = (cmos_readb(0x34) | (cmos_readb(0x35) << 8)) * 65536 + - 16 * 1024 * 1024; - else - low_ram_size = (cmos_readb(0x17) | (cmos_readb(0x18) << 8)) * 1024; - - if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d)) - mem_top = ((uint64_t)cmos_readb(0x5b) << 16) | - ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32); + if (cmos_readb(0x34) | cmos_readb(0x35)) + low_ram_size = (cmos_readb(0x34) | (cmos_readb(0x35) << 8)) * + 65536 + 16 * 1024 * 1024; + else + low_ram_size = (cmos_readb(0x17) | (cmos_readb(0x18) << 8)) * 1024; - if (mem_top) - mem_top += 1ull << 32; + if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d)) { + mem_top = ((uint64_t)cmos_readb(0x5b) << 16) | + ((uint64_t)cmos_readb(0x5c) << 24) | + ((uint64_t)cmos_readb(0x5d) << 32); + mem_top += 1ull << 32; + } else + mem_top = low_ram_size; #ifdef BX_USE_EBDA_TABLES ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380; #endif BX_INFO("low_ram_size=0x%08lx\n", low_ram_size); - BX_INFO("top of ram %ldMB\n", mem_top >> 20); - setup_mtrr(); + BX_INFO("top of ram %ldMB\n", mem_top / (1024 * 1024)); + setup_mtrr(); } /****************************************************/