summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2022-04-25 09:20:02 +0200
committerGerd Hoffmann <kraxel@redhat.com>2022-04-27 09:15:25 +0200
commit3b91e8e9fe93d5ff7edf17f984c401f9e6ba55fe (patch)
tree9c5ccd2145e39f2b437290874a17a4450726db15
parent01774004c7f7fdc9c1e8f1715f70d3b913f8d491 (diff)
downloadqemu-seabios-3b91e8e9fe93d5ff7edf17f984c401f9e6ba55fe.tar.gz
malloc: use variable for ZoneHigh size
Use the variable highram_size instead of the BUILD_MAX_HIGHTABLE #define for the ZoneHigh size. Initialize the new variable with the old #define, so behavior does not change. This allows to easily adjust the ZoneHigh size at runtime in a followup patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--src/malloc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 3733855..ecd8c9a 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -422,7 +422,8 @@ malloc_preinit(void)
e820_add(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED);
// Populate temp high ram
- u32 highram = 0;
+ u32 highram_start = 0;
+ u32 highram_size = BUILD_MAX_HIGHTABLE;
int i;
for (i=e820_count-1; i>=0; i--) {
struct e820entry *en = &e820_list[i];
@@ -432,10 +433,10 @@ malloc_preinit(void)
if (en->type != E820_RAM || end > 0xffffffff)
continue;
u32 s = en->start, e = end;
- if (!highram) {
- u32 newe = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN);
+ if (!highram_start) {
+ u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN);
if (newe <= e && newe >= s) {
- highram = newe;
+ highram_start = newe;
e = newe;
}
}
@@ -444,9 +445,9 @@ malloc_preinit(void)
// Populate regions
alloc_add(&ZoneTmpLow, BUILD_STACK_ADDR, BUILD_EBDA_MINIMUM);
- if (highram) {
- alloc_add(&ZoneHigh, highram, highram + BUILD_MAX_HIGHTABLE);
- e820_add(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED);
+ if (highram_start) {
+ alloc_add(&ZoneHigh, highram_start, highram_start + highram_size);
+ e820_add(highram_start, highram_size, E820_RESERVED);
}
}