Commit Graph

17 Commits

Author SHA1 Message Date
José Martínez 4db444b9a7 Fix high memory zone initialization in CSM mode
malloc_high() cannot allocate any memory in CSM mode due to an empty
ZoneHigh. SeaBIOS cannot find any disk to boot from because device
initialization fails.

The bug was introduced in 1.16.1 (commit dc88f9b) when the meaning of
BUILD_MAX_HIGHTABLE changed but CSM code was not updated. This patch
reverts to the previous behavior by using BUILD_MIN_HIGHTABLE in CSM
methods.

Signed-off-by: José Martínez <xose@google.com>
2023-06-13 11:01:34 -04:00
Gerd Hoffmann dc88f9b72d malloc: use large ZoneHigh when there is enough memory
In case there is enough memory installed use a large ZoneHigh.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2022-04-27 09:16:05 +02:00
Gerd Hoffmann 3b91e8e9fe 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>
2022-04-27 09:15:25 +02:00
Kevin O'Connor 7d0393d5af malloc: Rename csm_malloc_preinit() to malloc_csm_preinit()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 14:15:26 -04:00
Kevin O'Connor 5d91226e89 memmap: Introduce SYMBOL() macro to access linker script symbols
Use a macro to define and obtain the value of a symbol introduced by
the linker scripts (scripts/layoutrom.py).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor fe6682da0b malloc: Don't mix virtual and physical addresses
Consistently use 'u32' for physical addresses and pointers for virtual
addresses in the malloc code.  Introduce and use memremap() where a
physical address needs to be converted to a virtual address.  Use
virt_to_phys() for the inverse.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor 3c6ae7c1ee malloc: Add warning if free() called on invalid memory
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor 7af8d120fb malloc: Introduce common helper alloc_new_detail()
Introduce helper for finding temp space to hold an "allocation detail
struct" and use it in both alloc_add() and _malloc().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor 41acaa8274 malloc: Use consistent naming for internal low-level "alloc" functions
Use the "alloc_" prefix for all the low-level allocation functions and
avoid camelCase naming.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor c167e54533 e820: Rename memmap.c to e820map.c and use consistent "e820_" prefix
Rename memmap.c to e820map.c as the code in that file only deals with
maintaining the e820 map.  Move all the e820 definitions to new file
e820map.h and use a consistent "e820_" prefix on all exported
functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor 8e385143b7 e820: Introduce e820_remove() and avoid exporting E820_HOLE
The E820_HOLE definition is used internally in the e820 manipulation
code to remove entries from the e820 map.  Introduce the e820_remove()
function so that the E820_HOLE definition does not need to be exported
from the memmap.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:52:13 -04:00
Kevin O'Connor 743c157539 Remove the pmm handle argument from _malloc().
The PMM handle argument will almost always be 0xffffffff.  Use
separate code for the few rare cases where it may not be the default
value.  Gcc produces better code if _malloc() only requires three
parameters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-27 12:40:02 -05:00
Kevin O'Connor b94170cc4b Separate out sec32init sections even when not doing code relocation.
The current code does not boot on QEMU with 256K roms when code
relocation is disabled, because QEMU only maps the last 128K of the
rom to low memory.  The seabios make_bios_writable() call copies the
full rom to low memory.

This patch separates out the init sections even if code relocations
are disabled.  This effectively ensures that make_bios_writable() code
is in the last 128K of the rom.

This also introduces a new build symbol (final_readonly_start) which
stores the address of where the final runtime read-only memory begins.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-07 12:59:35 -05:00
Kevin O'Connor 3061815f41 Minor - update file comments in src/malloc.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28 22:10:49 -04:00
Kevin O'Connor 8fb3a5edf3 Move optionroms.h to std/optionrom.h and util.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 2d2fa31b37 Move function definitions for output.c from util.h to new file output.h.
Also, sort the order of include files in the c files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 9dea59025f Move malloc code from pmm.c to new files malloc.c and malloc.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00