From 14adb7eaa9f31e9db346f7b9de61e3a63905b03e Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 18 Jul 2020 14:23:41 +0200 Subject: libpayload: Cache physical cbmem console address Same as with other consoles and drivers that cache an address outside the payload (e.g. video/corebootfb), we should store the physical address, so we can derive the virtual address on demand. This makes it save to use the address across relocations. As a first step in migrating `libsysinfo` to `uintptr_t`, we also switch to the physical address there. Fixes the default build of FILO, tested with Qemu/i440FX and Qemu/Q35. Change-Id: I4b8434af69e0526f78523ae61981a15abb1295b0 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/37478 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Angel Pons --- payloads/libpayload/libc/coreboot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'payloads/libpayload/libc') diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index c6fb57fde9..25812e5a95 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -47,6 +47,12 @@ void *get_cbmem_ptr(unsigned char *ptr) return phys_to_virt(cbmem->cbmem_tab); } +uintptr_t get_cbmem_addr(const void *const cbmem_tab_entry) +{ + const struct cb_cbmem_tab *const cbmem = cbmem_tab_entry; + return cbmem->cbmem_tab; +} + static void cb_parse_memory(void *ptr, struct sysinfo_t *info) { struct cb_memory *mem = ptr; @@ -135,7 +141,7 @@ static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info) { - info->cbmem_cons = get_cbmem_ptr(ptr); + info->cbmem_cons = get_cbmem_addr(ptr); } static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info) -- cgit v1.2.3