diff mbox

kvm_unit_tests: vm.c - Retrieve RAM size from fwcfg

Message ID 1314825072-27967-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Aug. 31, 2011, 9:11 p.m. UTC
Rather than letting the test dev do it.

CC: Avi Kivity <avi@redhat.com>
CC: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 lib/x86/fwcfg.c |    5 +++++
 lib/x86/fwcfg.h |    1 +
 lib/x86/vm.c    |    2 +-
 3 files changed, 7 insertions(+), 1 deletions(-)

Comments

Avi Kivity Sept. 1, 2011, 8:05 a.m. UTC | #1
On 09/01/2011 12:11 AM, Lucas Meneghel Rodrigues wrote:
> Rather than letting the test dev do it.

> +
> +unsigned fwcfg_get_ram_size(void)
> +{
> +    return fwcfg_get_u64(FW_CFG_RAM_SIZE);
> +}

Should return a 64-bit type here.
diff mbox

Patch

diff --git a/lib/x86/fwcfg.c b/lib/x86/fwcfg.c
index e2cdd15..df8548c 100644
--- a/lib/x86/fwcfg.c
+++ b/lib/x86/fwcfg.c
@@ -43,3 +43,8 @@  unsigned fwcfg_get_nb_cpus(void)
 {
     return fwcfg_get_u16(FW_CFG_NB_CPUS);
 }
+
+unsigned fwcfg_get_ram_size(void)
+{
+    return fwcfg_get_u64(FW_CFG_RAM_SIZE);
+}
diff --git a/lib/x86/fwcfg.h b/lib/x86/fwcfg.h
index e0836ca..96c75b8 100644
--- a/lib/x86/fwcfg.h
+++ b/lib/x86/fwcfg.h
@@ -39,6 +39,7 @@  uint32_t fwcfg_get_u32(unsigned index);
 uint64_t fwcfg_get_u64(unsigned index);
 
 unsigned fwcfg_get_nb_cpus(void);
+unsigned fwcfg_get_ram_size(void);
 
 #endif
 
diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index abbb0c9..5b31892 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -194,7 +194,7 @@  static unsigned int inl(unsigned short port)
 
 void setup_vm()
 {
-    end_of_memory = inl(0xd1);
+    end_of_memory = fwcfg_get_ram_size();
     free_memory(&edata, end_of_memory - (unsigned long)&edata);
     setup_mmu(end_of_memory);
 }