aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/cpu
diff options
context:
space:
mode:
authorBin Meng2019-08-29 02:53:05 -0700
committerBin Meng2019-09-10 14:19:39 +0800
commitea67d549b89dbfee2bc78ba75c5b1406950f5e46 (patch)
treeead0dec3dc4a0c41b7dc3450236020f678e6f5ed /arch/x86/cpu
parentf4c0030074544e8d3105bc9e4debb82e964ab126 (diff)
x86: qemu: Support getting high memory size
At present only size of memory that is below 4GiB is retrieved from QEMU. Add a function that gets size of memory that is above 4GiB. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Aiden Park <aiden.park@intel.com>
Diffstat (limited to 'arch/x86/cpu')
-rw-r--r--arch/x86/cpu/qemu/dram.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c
index c29b073d7c4..6707b7b3634 100644
--- a/arch/x86/cpu/qemu/dram.c
+++ b/arch/x86/cpu/qemu/dram.c
@@ -22,9 +22,24 @@ u32 qemu_get_low_memory_size(void)
return ram * 1024;
}
+u64 qemu_get_high_memory_size(void)
+{
+ u64 ram;
+
+ outb(HIGH_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+ ram = ((u64)inb(CMOS_DATA_PORT)) << 22;
+ outb(MID_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+ ram |= ((u64)inb(CMOS_DATA_PORT)) << 14;
+ outb(LOW_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+ ram |= ((u64)inb(CMOS_DATA_PORT)) << 6;
+
+ return ram * 1024;
+}
+
int dram_init(void)
{
gd->ram_size = qemu_get_low_memory_size();
+ gd->ram_size += qemu_get_high_memory_size();
post_code(POST_DRAM);
return 0;
@@ -32,8 +47,16 @@ int dram_init(void)
int dram_init_banksize(void)
{
+ u64 high_mem_size;
+
gd->bd->bi_dram[0].start = 0;
- gd->bd->bi_dram[0].size = gd->ram_size;
+ gd->bd->bi_dram[0].size = qemu_get_low_memory_size();
+
+ high_mem_size = qemu_get_high_memory_size();
+ if (high_mem_size) {
+ gd->bd->bi_dram[1].start = SZ_4G;
+ gd->bd->bi_dram[1].size = high_mem_size;
+ }
return 0;
}
@@ -48,5 +71,5 @@ int dram_init_banksize(void)
*/
ulong board_get_usable_ram_top(ulong total_size)
{
- return gd->ram_size;
+ return qemu_get_low_memory_size();
}