[U-Boot] [PATCH 3/4] x86: qemu: Support getting high memory size

Park, Aiden aiden.park at intel.com
Tue Sep 3 16:55:38 UTC 2019



> -----Original Message-----
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Thursday, August 29, 2019 2:53 AM
> To: Simon Glass <sjg at chromium.org>; Park, Aiden <aiden.park at intel.com>;
> U-Boot Mailing List <u-boot at lists.denx.de>
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Subject: [PATCH 3/4] 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 at gmail.com>
> ---
> 
>  arch/x86/cpu/qemu/dram.c              | 27 +++++++++++++++++++++++++--
>  arch/x86/include/asm/arch-qemu/qemu.h | 11 +++++++++++
>  2 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c index
> c29b073..6707b7b 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();
>  }
> diff --git a/arch/x86/include/asm/arch-qemu/qemu.h
> b/arch/x86/include/asm/arch-qemu/qemu.h
> index c98deb2..061735b 100644
> --- a/arch/x86/include/asm/arch-qemu/qemu.h
> +++ b/arch/x86/include/asm/arch-qemu/qemu.h
> @@ -32,6 +32,10 @@
>  #define LOW_RAM_ADDR		0x34
>  #define HIGH_RAM_ADDR		0x35
> 
> +#define LOW_HIGHRAM_ADDR	0x5b
> +#define MID_HIGHRAM_ADDR	0x5c
> +#define HIGH_HIGHRAM_ADDR	0x5d
> +
>  /* PM registers */
>  #define PMBA		0x40
>  #define PMREGMISC	0x80
> @@ -44,4 +48,11 @@
>   */
>  u32 qemu_get_low_memory_size(void);
> 
> +/**
> + * qemu_get_high_memory_size() - Get high memory size
> + *
> + * @return:	size of memory above 4GiB
> + */
> +u64 qemu_get_high_memory_size(void);
> +
>  #endif /* _ARCH_QEMU_H_ */
> --
> 2.7.4

Reviewed-by: Aiden Park <aiden.park at intel.com>


More information about the U-Boot mailing list