Jakub Czapiga has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59491 )
Change subject: libpayload: Add CBMEM_IMD_ENTRY support to coreboot tables parser ......................................................................
libpayload: Add CBMEM_IMD_ENTRY support to coreboot tables parser
coreboot stores many informations in the CBMEM IMD. Until now it was ignored. This patch adds CBMEM_ID_* defines as well as parses CBMEM_ID_CBFS_RO/RW_MCACHE entries and stores them in the lib_sysinfo.
Change-Id: I5bd02a98ba2631f34014bc0f8e7ebd5a5ddd2321 Signed-off-by: Jakub Czapiga jacz@semihalf.com --- A payloads/libpayload/include/cbmem_id.h M payloads/libpayload/include/coreboot_tables.h M payloads/libpayload/include/sysinfo.h M payloads/libpayload/libc/coreboot.c 4 files changed, 121 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/59491/1
diff --git a/payloads/libpayload/include/cbmem_id.h b/payloads/libpayload/include/cbmem_id.h new file mode 100644 index 0000000..ac3890f --- /dev/null +++ b/payloads/libpayload/include/cbmem_id.h @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +#ifndef _CBMEM_ID_H_ +#define _CBMEM_ID_H_ + +#define CBMEM_ID_ACPI 0x41435049 +#define CBMEM_ID_ACPI_BERT 0x42455254 +#define CBMEM_ID_ACPI_CNVS 0x434e5653 +#define CBMEM_ID_ACPI_GNVS 0x474e5653 +#define CMBMEM_ID_ACPI_HEST 0x48455354 +#define CBMEM_ID_ACPI_UCSI 0x55435349 +#define CBMEM_ID_AFTER_CAR 0xc4787a93 +#define CBMEM_ID_AGESA_RUNTIME 0x41474553 +#define CBMEM_ID_AMDMCT_MEMINFO 0x494D454E +#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3 +#define CBMEM_ID_CBTABLE 0x43425442 +#define CBMEM_ID_CBTABLE_FWD 0x43425443 +#define CBMEM_ID_CB_EARLY_DRAM 0x4544524D +#define CBMEM_ID_CONSOLE 0x434f4e53 +#define CBMEM_ID_CPU_CRASHLOG 0x4350555f +#define CBMEM_ID_COVERAGE 0x47434f56 +#define CBMEM_ID_EHCI_DEBUG 0xe4c1deb9 +#define CBMEM_ID_ELOG 0x454c4f47 +#define CBMEM_ID_FREESPACE 0x46524545 +#define CBMEM_ID_FSP_RESERVED_MEMORY 0x46535052 +#define CBMEM_ID_FSP_RUNTIME 0x52505346 +#define CBMEM_ID_GDT 0x4c474454 +#define CBMEM_ID_HOB_POINTER 0x484f4221 +#define CBMEM_ID_IGD_OPREGION 0x4f444749 +#define CBMEM_ID_IMD_ROOT 0xff4017ff +#define CBMEM_ID_IMD_SMALL 0x53a11439 +#define CBMEM_ID_MDATA_HASH 0x6873484D +#define CBMEM_ID_MEMINFO 0x494D454D +#define CBMEM_ID_MMA_DATA 0x4D4D4144 +#define CBMEM_ID_MMC_STATUS 0x4d4d4353 +#define CBMEM_ID_MPTABLE 0x534d5054 +#define CBMEM_ID_MRCDATA 0x4d524344 +#define CBMEM_ID_PMC_CRASHLOG 0x504d435f +#define CBMEM_ID_VAR_MRCDATA 0x4d524345 +#define CBMEM_ID_MTC 0xcb31d31c +#define CBMEM_ID_NONE 0x00000000 +#define CBMEM_ID_PIRQ 0x49525154 +#define CBMEM_ID_POWER_STATE 0x50535454 +#define CBMEM_ID_RAM_OOPS 0x05430095 +#define CBMEM_ID_RAMSTAGE 0x9a357a9e +#define CBMEM_ID_RAMSTAGE_CACHE 0x9a3ca54e +#define CBMEM_ID_REFCODE 0x04efc0de +#define CBMEM_ID_REFCODE_CACHE 0x4efc0de5 +#define CBMEM_ID_RESUME 0x5245534d +#define CBMEM_ID_RESUME_SCRATCH 0x52455343 +#define CBMEM_ID_ROMSTAGE_INFO 0x47545352 +#define CBMEM_ID_ROMSTAGE_RAM_STACK 0x90357ac4 +#define CBMEM_ID_ROOT 0xff4007ff +#define CBMEM_ID_SMBIOS 0x534d4254 +#define CBMEM_ID_SMM_SAVE_SPACE 0x07e9acee +#define CBMEM_ID_STAGEx_META 0x57a9e000 +#define CBMEM_ID_STAGEx_CACHE 0x57a9e100 +#define CBMEM_ID_STAGEx_RAW 0x57a9e200 +#define CBMEM_ID_STORAGE_DATA 0x53746f72 +#define CBMEM_ID_TCPA_LOG 0x54435041 +#define CBMEM_ID_TCPA_TCG_LOG 0x54445041 +#define CBMEM_ID_TIMESTAMP 0x54494d45 +#define CBMEM_ID_TPM2_TCG_LOG 0x54504d32 +#define CBMEM_ID_TPM_PPI 0x54505049 +#define CBMEM_ID_VBOOT_WORKBUF 0x78007343 +#define CBMEM_ID_VPD 0x56504420 +#define CBMEM_ID_WIFI_CALIBRATION 0x57494649 +#define CBMEM_ID_EXT_VBT 0x69866684 +#define CBMEM_ID_ROM0 0x524f4d30 +#define CBMEM_ID_ROM1 0x524f4d31 +#define CBMEM_ID_ROM2 0x524f4d32 +#define CBMEM_ID_ROM3 0x524f4d33 +#define CBMEM_ID_FMAP 0x464d4150 +#define CBMEM_ID_CBFS_RO_MCACHE 0x524d5346 +#define CBMEM_ID_CBFS_RW_MCACHE 0x574d5346 +#define CBMEM_ID_FSP_LOGO 0x4c4f474f +#define CBMEM_ID_SMM_COMBUFFER 0x53534d32 +#define CBMEM_ID_TYPE_C_INFO 0x54595045 + +#endif /* _CBMEM_ID_H_ */ diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 914cfa5..7dd7645 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -321,6 +321,16 @@ uint64_t boot_media_size; };
+ +struct cb_cbmem_entry { + uint32_t tag; + uint32_t size; + + uint64_t address; + uint32_t entry_size; + uint32_t id; +}; + struct cb_tsc_info { uint32_t tag; uint32_t size; diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index b34476d..376f298 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -150,6 +150,12 @@ #endif /* USB Type-C Port Configuration Info */ uintptr_t type_c_info; + + /* CBFS RW/RO Metadata Cache */ + uintptr_t cbfs_ro_mcache_offset; + uint32_t cbfs_ro_mcache_size; + uintptr_t cbfs_rw_mcache_offset; + uint32_t cbfs_rw_mcache_size; };
extern struct sysinfo_t lib_sysinfo; diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index bd10411..ebb8962 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -29,6 +29,7 @@
#include <libpayload-config.h> #include <libpayload.h> +#include <cbmem_id.h> #include <coreboot_tables.h> #include <stdint.h>
@@ -264,6 +265,27 @@ } #endif
+static void cb_parse_cbmem_entry(void *ptr, struct sysinfo_t *info) +{ + const struct cb_cbmem_entry *cbmem_entry = ptr; + + if (cbmem_entry->size != sizeof(*cbmem_entry)) + return; + + switch (cbmem_entry->id) { + case CBMEM_ID_CBFS_RO_MCACHE: + info->cbfs_ro_mcache_offset = cbmem_entry->address; + info->cbfs_ro_mcache_size = cbmem_entry->size; + break; + case CBMEM_ID_CBFS_RW_MCACHE: + info->cbfs_rw_mcache_offset = cbmem_entry->address; + info->cbfs_rw_mcache_size = cbmem_entry->size; + break; + default: + break; + } +} + int cb_parse_header(void *addr, int len, struct sysinfo_t *info) { struct cb_header *header; @@ -414,6 +436,9 @@ case CB_TAG_BOOT_MEDIA_PARAMS: cb_parse_boot_media_params(ptr, info); break; + case CB_TAG_CBMEM_ENTRY: + cb_parse_cbmem_entry(ptr, info); + break; #if CONFIG(LP_TIMER_RDTSC) case CB_TAG_TSC_INFO: cb_parse_tsc_info(ptr, info);