From: Bin Meng Date: Thu, 29 Aug 2019 09:53:04 +0000 (-0700) Subject: x86: qemu: Extract getting memory size to a separate routine X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=f4c0030074544e8d3105bc9e4debb82e964ab126;p=u-boot.git x86: qemu: Extract getting memory size to a separate routine 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 Reviewed-by: Aiden Park --- diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c index 736c4c3ace..c29b073d7c 100644 --- a/arch/x86/cpu/qemu/dram.c +++ b/arch/x86/cpu/qemu/dram.c @@ -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; diff --git a/arch/x86/include/asm/arch-qemu/qemu.h b/arch/x86/include/asm/arch-qemu/qemu.h index 100eb8e646..c98deb2cd2 100644 --- a/arch/x86/include/asm/arch-qemu/qemu.h +++ b/arch/x86/include/asm/arch-qemu/qemu.h @@ -37,4 +37,11 @@ #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_ */