x86: qemu: Extract getting memory size to a separate routine
authorBin Meng <bmeng.cn@gmail.com>
Thu, 29 Aug 2019 09:53:04 +0000 (02:53 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Tue, 10 Sep 2019 06:19:39 +0000 (14:19 +0800)
This extracts getting memory size logic in dram_init() to a separate
routine qemu_get_low_memory_size(). No functional changes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Aiden Park <aiden.park@intel.com>
arch/x86/cpu/qemu/dram.c
arch/x86/include/asm/arch-qemu/qemu.h

index 736c4c3ace36749aab9ea6160c86125a9589bf43..c29b073d7c4eaed5b9fa7b973ea931361a3ee2d0 100644 (file)
@@ -9,7 +9,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int dram_init(void)
+u32 qemu_get_low_memory_size(void)
 {
        u32 ram;
 
@@ -19,7 +19,12 @@ int dram_init(void)
        ram |= ((u32)inb(CMOS_DATA_PORT)) << 6;
        ram += 16 * 1024;
 
-       gd->ram_size = ram * 1024;
+       return ram * 1024;
+}
+
+int dram_init(void)
+{
+       gd->ram_size = qemu_get_low_memory_size();
        post_code(POST_DRAM);
 
        return 0;
index 100eb8e646304e922659d74acab44f8b9e674690..c98deb2cd2f76ca753fb5fcb6f1447286f91d5f1 100644 (file)
 #define PMREGMISC      0x80
 #define PMIOSE         (1 << 0)
 
+/**
+ * qemu_get_low_memory_size() - Get low memory size
+ *
+ * @return:    size of memory below 4GiB
+ */
+u32 qemu_get_low_memory_size(void);
+
 #endif /* _ARCH_QEMU_H_ */