x86: Drop weak version board_get_usable_ram_top()
PATCH 1/4 x86: Drop weak version board_get_usable_ram_top()
Every x86 platform provides board_get_usable_ram_top(), hence there is no need to provide a weak version board_get_usable_ram_top(), not to mention there is another weak version board_get_usable_ram_top() in common/board_f.c.
---
arch/x86/lib/init_helpers.c | 6 ------ 1 file changed, 6 deletions(-)
arch/x86/lib/init_helpers.c +0 -6
@@ -10,12 +10,6 @@DECLARE_GLOBAL_DATA_PTR ; -/* Get the top of usable RAM */ -__weak ulong board_get_usable_ram_top (ulong total_size) -{ -return gd->ram_size; -} -int init_cache_f_r (void ) { #if CONFIG_IS_ENABLED(X86_32BIT_INIT) && !defined(CONFIG_HAVE_FSP) && \
Signature · 1 line
2.7.4
PATCH 2/4 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.
---
arch/x86/cpu/qemu/dram.c | 9 +++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
arch/x86/cpu/qemu/dram.c +7 -2
@@ -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 ;
arch/x86/include/asm/arch-qemu/qemu.h +7 -0
@@ -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_ */
Signature · 1 line
2.7.4
Park
PATCH 2/4 x86: qemu: Extract getting memory size to a separate routine
Quoted 66 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 2/4] x86: qemu: Extract getting memory size to a separate routineThis extracts getting memory size logic in
dram_init()to a separate routineqemu_get_low_memory_size(). No functional changes.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/dram.c | 9 +++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-)arch/x86/cpu/qemu/dram.c index renamed from arch/x86/cpu/qemu/dram.c +0
-0736c4c3..c29b073 100644
arch/x86/cpu/qemu/dram.c +7
-2@@ -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 ;arch/x86/include/asm/arch-qemu/qemu.h +7
-1@@ -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_ */ --
Quoted 1 line
2.7.4
PATCH 2/4 x86: qemu: Extract getting memory size to a separate routine
Quoted 58 lines · Aiden
Quoted 58 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 2/4] x86: qemu: Extract getting memory size to a separate routineThis extracts getting memory size logic in
dram_init()to a separate routineqemu_get_low_memory_size(). No functional changes.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/dram.c | 9 +++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-)arch/x86/cpu/qemu/dram.c index renamed from arch/x86/cpu/qemu/dram.c +0
-0736c4c3..c29b073 100644
arch/x86/cpu/qemu/dram.c +7
-2@@ -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 ;arch/x86/include/asm/arch-qemu/qemu.h +0
-0@@ -37,4 +37,11 @@#define PMREGMISC 0x80#define PMIOSE (1 << 0)
Quoted 12 lines
Quoted 10 lines
arch/x86/include/asm/arch-qemu/qemu.h +7
-1+/** +* 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_ */ --2.7.4
Reviewed-by Aiden Park <[email protected]>
applied to u-boot-x86, thanks!
PATCH 3/4 x86: qemu: Support getting high memory size
In reply to Bin MengAt 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.
---
arch/x86/cpu/qemu/dram.c | 27 +++++++++++++++++++++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 11 +++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-)
arch/x86/cpu/qemu/dram.c +25 -2
@@ -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 (); }
arch/x86/include/asm/arch-qemu/qemu.h +11 -0
@@ -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_ */
Signature · 1 line
2.7.4
Park
PATCH 3/4 x86: qemu: Support getting high memory size
Quoted 102 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 3/4] x86: qemu: Support getting high memory sizeAt 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 <[email protected]>---
arch/x86/cpu/qemu/dram.c | 27 +++++++++++++++++++++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 11 +++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-)arch/x86/cpu/qemu/dram.c index renamed from arch/x86/cpu/qemu/dram.c +0
-0c29b073..6707b7b 100644
arch/x86/cpu/qemu/dram.c +25
-2@@ -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 (); }arch/x86/include/asm/arch-qemu/qemu.h +11
-1@@ -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_ */ --
Quoted 1 line
2.7.4
PATCH 3/4 x86: qemu: Support getting high memory size
Quoted 94 lines · Aiden
Quoted 94 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 3/4] x86: qemu: Support getting high memory sizeAt 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 <[email protected]>---
arch/x86/cpu/qemu/dram.c | 27 +++++++++++++++++++++++++-- arch/x86/include/asm/arch-qemu/qemu.h | 11 +++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-)arch/x86/cpu/qemu/dram.c index renamed from arch/x86/cpu/qemu/dram.c +0
-0c29b073..6707b7b 100644
arch/x86/cpu/qemu/dram.c +25
-2@@ -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 (); }arch/x86/include/asm/arch-qemu/qemu.h +4
-0@@ -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 );
Quoted 12 lines
Quoted 10 lines
arch/x86/include/asm/arch-qemu/qemu.h +7
-1+/** +* 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 <[email protected]>
applied to u-boot-x86, thanks!
PATCH 4/4 x86: qemu: Report high memory in the E820 table
In reply to Bin MengNow that we are able to get the size of high memory from QEMU, report its memory range as usable ram.
---
arch/x86/cpu/qemu/e820.c | 59 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 19 deletions(-)
arch/x86/cpu/qemu/e820.c +40 -19
@@ -1,46 +1,67 @@// SPDX-License-Identifier: GPL-2.0+ /* +* QEMU x86 specific E820 table generation +* * (C) Copyright 2015 Miao Yan <[email protected]> +* (C) Copyright 2019 Bin Meng <[email protected]> */ #include <common.h> #include <env_internal.h> #include <asm/e820.h> +#include <asm/arch/qemu.h> DECLARE_GLOBAL_DATA_PTR ;unsigned int install_e820_map (unsigned int max_entries,struct e820_entry *entries) { - entries[0 ].addr =0 ; - entries[0 ].size =ISA_START_ADDRESS ; - entries[0 ].type =E820_RAM ; +u64 high_mem_size; +int n =0 ; - entries[1 ].addr =ISA_START_ADDRESS ; - entries[1 ].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; - entries[1 ].type =E820_RESERVED ; + entries[n].addr =0 ; + entries[n].size =ISA_START_ADDRESS ; + entries[n].type =E820_RAM ; + n++; + + entries[n].addr =ISA_START_ADDRESS ; + entries[n].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; + entries[n].type =E820_RESERVED ; + n++;/* * since we use memalign(malloc) to allocate high memory for * storing ACPI tables, we need to reserve them in e820 tables, * otherwise kernel will reclaim them and data will be corrupted */ - entries[2 ].addr =ISA_END_ADDRESS ; - entries[2 ].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; - entries[2 ].type =E820_RAM ; + entries[n].addr =ISA_END_ADDRESS ; + entries[n].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; + entries[n].type =E820_RAM ; + n++;/* for simplicity, reserve entire malloc space */ - entries[3 ].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; - entries[3 ].size =TOTAL_MALLOC_LEN ; - entries[3 ].type =E820_RESERVED ; + entries[n].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; + entries[n].size =TOTAL_MALLOC_LEN ; + entries[n].type =E820_RESERVED ; + n++; + + entries[n].addr = gd->relocaddr; + entries[n].size =qemu_get_low_memory_size () - gd->relocaddr; + entries[n].type =E820_RESERVED ; + n++; - entries[4 ].addr = gd->relocaddr; - entries[4 ].size = gd->ram_size - gd->relocaddr; - entries[4 ].type =E820_RESERVED ; + entries[n].addr =CONFIG_PCIE_ECAM_BASE ; + entries[n].size =CONFIG_PCIE_ECAM_SIZE ; + entries[n].type =E820_RESERVED ; + n++; - entries[5 ].addr =CONFIG_PCIE_ECAM_BASE ; - entries[5 ].size =CONFIG_PCIE_ECAM_SIZE ; - entries[5 ].type =E820_RESERVED ; + high_mem_size =qemu_get_high_memory_size (); +if (high_mem_size) { + entries[n].addr =SZ_4G ; + entries[n].size = high_mem_size; + entries[n].type =E820_RAM ; + n++; + } -return 6 ; +return n; }
Signature · 1 line
2.7.4
Park
PATCH 4/4 x86: qemu: Report high memory in the E820 table
Quoted 114 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 4/4] x86: qemu: Report high memory in the E820 tableNow that we are able to get the size of high memory from QEMU, report its memory range as usable ram.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/e820.c | 59 ++++++++++++++++++++++++++++++++-- -------------- 1 file changed, 40 insertions(+), 19 deletions(-)arch/x86/cpu/qemu/e820.c index renamed from arch/x86/cpu/qemu/e820.c +0
-0e682486..a4136eb 100644
arch/x86/cpu/qemu/e820.c +40
-20@@ -1,46 +1,67 @@// SPDX-License-Identifier: GPL-2.0+ /* +* QEMU x86 specific E820 table generation +* * (C) Copyright 2015 Miao Yan <[email protected]> +* (C) Copyright 2019 Bin Meng <[email protected]> */ #include <common.h> #include <env_internal.h> #include <asm/e820.h> +#include <asm/arch/qemu.h> DECLARE_GLOBAL_DATA_PTR ;unsigned int install_e820_map (unsigned int max_entries,struct e820_entry *entries) { - entries[0 ].addr =0 ; - entries[0 ].size =ISA_START_ADDRESS ; - entries[0 ].type =E820_RAM ; +u64 high_mem_size; +int n =0 ; - entries[1 ].addr =ISA_START_ADDRESS ; - entries[1 ].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; - entries[1 ].type =E820_RESERVED ; + entries[n].addr =0 ; + entries[n].size =ISA_START_ADDRESS ; + entries[n].type =E820_RAM ; + n++; + + entries[n].addr =ISA_START_ADDRESS ; + entries[n].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; + entries[n].type =E820_RESERVED ; + n++;/* * since we use memalign(malloc) to allocate high memory for * storing ACPI tables, we need to reserve them in e820 tables, * otherwise kernel will reclaim them and data will be corrupted */ - entries[2 ].addr =ISA_END_ADDRESS ; - entries[2 ].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; - entries[2 ].type =E820_RAM ; + entries[n].addr =ISA_END_ADDRESS ; + entries[n].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; + entries[n].type =E820_RAM ; + n++;/* for simplicity, reserve entire malloc space */ - entries[3 ].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; - entries[3 ].size =TOTAL_MALLOC_LEN ; - entries[3 ].type =E820_RESERVED ; + entries[n].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; + entries[n].size =TOTAL_MALLOC_LEN ; + entries[n].type =E820_RESERVED ; + n++; + + entries[n].addr = gd->relocaddr; + entries[n].size =qemu_get_low_memory_size () - gd->relocaddr; + entries[n].type =E820_RESERVED ; + n++; - entries[4 ].addr = gd->relocaddr; - entries[4 ].size = gd->ram_size - gd->relocaddr; - entries[4 ].type =E820_RESERVED ; + entries[n].addr =CONFIG_PCIE_ECAM_BASE ; + entries[n].size =CONFIG_PCIE_ECAM_SIZE ; + entries[n].type =E820_RESERVED ; + n++; - entries[5 ].addr =CONFIG_PCIE_ECAM_BASE ; - entries[5 ].size =CONFIG_PCIE_ECAM_SIZE ; - entries[5 ].type =E820_RESERVED ; + high_mem_size =qemu_get_high_memory_size (); +if (high_mem_size) { + entries[n].addr =SZ_4G ; + entries[n].size = high_mem_size; + entries[n].type =E820_RAM ; + n++; + } -return 6 ; +return n; } --
Quoted 1 line
2.7.4
PATCH 4/4 x86: qemu: Report high memory in the E820 table
Quoted 111 lines · Aiden
Quoted 111 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Thursday, August 29, 2019 2:53 AM
To: Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Subject: [PATCH 4/4] x86: qemu: Report high memory in the E820 tableNow that we are able to get the size of high memory from QEMU, report its memory range as usable ram.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/e820.c | 59 ++++++++++++++++++++++++++++++++-- -------------- 1 file changed, 40 insertions(+), 19 deletions(-)arch/x86/cpu/qemu/e820.c index renamed from arch/x86/cpu/qemu/e820.c +0
-0e682486..a4136eb 100644
arch/x86/cpu/qemu/e820.c +39
-18@@ -1,46 +1,67 @@// SPDX-License-Identifier: GPL-2.0+ /* +* QEMU x86 specific E820 table generation +* * (C) Copyright 2015 Miao Yan <[email protected]> +* (C) Copyright 2019 Bin Meng <[email protected]> */ #include <common.h> #include <env_internal.h> #include <asm/e820.h> +#include <asm/arch/qemu.h> DECLARE_GLOBAL_DATA_PTR ;unsigned int install_e820_map (unsigned int max_entries,struct e820_entry *entries) { - entries[0 ].addr =0 ; - entries[0 ].size =ISA_START_ADDRESS ; - entries[0 ].type =E820_RAM ; +u64 high_mem_size; +int n =0 ; - entries[1 ].addr =ISA_START_ADDRESS ; - entries[1 ].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; - entries[1 ].type =E820_RESERVED ; + entries[n].addr =0 ; + entries[n].size =ISA_START_ADDRESS ; + entries[n].type =E820_RAM ; + n++; + + entries[n].addr =ISA_START_ADDRESS ; + entries[n].size =ISA_END_ADDRESS -ISA_START_ADDRESS ; + entries[n].type =E820_RESERVED ; + n++;/* * since we use memalign(malloc) to allocate high memory for * storing ACPI tables, we need to reserve them in e820 tables, * otherwise kernel will reclaim them and data will be corrupted */ - entries[2 ].addr =ISA_END_ADDRESS ; - entries[2 ].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; - entries[2 ].type =E820_RAM ; + entries[n].addr =ISA_END_ADDRESS ; + entries[n].size = gd->relocaddr -TOTAL_MALLOC_LEN -ISA_END_ADDRESS ; + entries[n].type =E820_RAM ; + n++;/* for simplicity, reserve entire malloc space */ - entries[3 ].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; - entries[3 ].size =TOTAL_MALLOC_LEN ; - entries[3 ].type =E820_RESERVED ; + entries[n].addr = gd->relocaddr -TOTAL_MALLOC_LEN ; + entries[n].size =TOTAL_MALLOC_LEN ; + entries[n].type =E820_RESERVED ; + n++; + + entries[n].addr = gd->relocaddr; + entries[n].size =qemu_get_low_memory_size () - gd->relocaddr; + entries[n].type =E820_RESERVED ; + n++; - entries[4 ].addr = gd->relocaddr; - entries[4 ].size = gd->ram_size - gd->relocaddr; - entries[4 ].type =E820_RESERVED ; + entries[n].addr =CONFIG_PCIE_ECAM_BASE ; + entries[n].size =CONFIG_PCIE_ECAM_SIZE ; + entries[n].type =E820_RESERVED ; + n++; - entries[5 ].addr =CONFIG_PCIE_ECAM_BASE ; - entries[5 ].size =CONFIG_PCIE_ECAM_SIZE ; - entries[5 ].type =E820_RESERVED ; + high_mem_size =qemu_get_high_memory_size (); +if (high_mem_size) { + entries[n].addr =SZ_4G ; + entries[n].size = high_mem_size; + entries[n].type =E820_RAM ; + n++; + }
Quoted 7 lines
Quoted 5 lines
arch/x86/cpu/qemu/e820.c +1
-2-return 6 ; +return n; } --2.7.4
Reviewed-by Aiden Park <[email protected]>
applied to u-boot-x86, thanks!
PATCH 1/4 x86: Drop weak version board_get_usable_ram_top()
In reply to Bin MengQuoted 6 lines · Bin Meng
Every x86 platform provides
board_get_usable_ram_top(), hence there is no need to provide a weak versionboard_get_usable_ram_top(), not to mention there is another weak versionboard_get_usable_ram_top()incommon/board_f.c.Signed-off-by Bin Meng <[email protected]>
Quoted 23 lines
---
arch/x86/lib/init_helpers.c | 6 ------ 1 file changed, 6 deletions(-)arch/x86/lib/init_helpers.c +0
-6@@ -10,12 +10,6 @@DECLARE_GLOBAL_DATA_PTR ; -/* Get the top of usable RAM */ -__weak ulong board_get_usable_ram_top (ulong total_size) -{ -return gd->ram_size; -} -int init_cache_f_r (void ) { #if CONFIG_IS_ENABLED(X86_32BIT_INIT) && !defined(CONFIG_HAVE_FSP) && \
Park
PATCH 1/4 x86: Drop weak version board_get_usable_ram_top()
Quoted 8 lines
-----Original Message-----
From: Heinrich Schuchardt [mailto:xypron.glpk at gmx.de]
Sent: Thursday, August 29, 2019 12:27 PM
To: Bin Meng <[email protected]>; Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Subject: Re: [PATCH 1/4] x86: Drop weak versionboard_get_usable_ram_top()On 8/29/19 11:53 AM, Bin Meng wrote:
Quoted 9 lines
Quoted 6 lines
Every x86 platform provides
board_get_usable_ram_top(), hence there is no need to provide a weak versionboard_get_usable_ram_top(), not to mention there is another weak versionboard_get_usable_ram_top()incommon/board_f.c.Signed-off-by Bin Meng <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>
Quoted 23 lines
Quoted 23 lines
---
arch/x86/lib/init_helpers.c | 6 ------ 1 file changed, 6 deletions(-)arch/x86/lib/init_helpers.c +0
-5@@ -10,12 +10,6 @@DECLARE_GLOBAL_DATA_PTR ; -/* Get the top of usable RAM */ -__weak ulong board_get_usable_ram_top(ulong total_size) -{ -return gd->ram_size; -} -int init_cache_f_r (void ) {#if CONFIG_IS_ENABLED (X86_32BIT_INIT ) && !defined(CONFIG_HAVE_FSP )&& \
PATCH 1/4 x86: Drop weak version board_get_usable_ram_top()
Quoted 14 lines · Aiden
Quoted 14 lines
-----Original Message-----
From: Heinrich Schuchardt [mailto:xypron.glpk at gmx.de]
Sent: Thursday, August 29, 2019 12:27 PM
To: Bin Meng <[email protected]>; Simon Glass <[email protected]>; Park, Aiden <[email protected]>; U-Boot Mailing List <[email protected]>
Subject: Re: [PATCH 1/4] x86: Drop weak versionboard_get_usable_ram_top()Quoted 5 lines · Bin Meng
Every x86 platform provides
board_get_usable_ram_top(), hence there is no need to provide a weak versionboard_get_usable_ram_top(), not to mention there is another weak versionboard_get_usable_ram_top()incommon/board_f.c.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Bin Meng <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>Reviewed-by Aiden Park <[email protected]>
applied to u-boot-x86, thanks!