libpayload: Add CBMEM_IMD_ENTRY support to coreboot tables parser

coreboot stores much information in the CBMEM IMD. Until now it was
ignored. This patch makes use of these coreboot tables entries.
It also removes get_cbmem_addr() function as it is no longer needed.

Moreover, the coreboot tables entry CB_TAG_MRC_CACHE does not exist
anymore, as it is not created by the code. It was replaced by
CBMEM_ID_MRCDATA entry, so MRCDATA should now be accessible through
sysinfo structure field.

Change-Id: I5bd02a98ba2631f34014bc0f8e7ebd5a5ddd2321
Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59491
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
This commit is contained in:
Jakub Czapiga 2021-11-10 14:04:43 +00:00 committed by Felix Held
parent c627b0edeb
commit 2f236c232d
4 changed files with 71 additions and 88 deletions

View File

@ -47,20 +47,12 @@ static void cb_parse_x86_rom_var_mtrr(void *ptr, struct sysinfo_t *info)
info->x86_rom_var_mtrr_index = rom_mtrr->index; info->x86_rom_var_mtrr_index = rom_mtrr->index;
} }
static void cb_parse_mrc_cache(void *ptr, struct sysinfo_t *info)
{
info->mrc_cache = get_cbmem_addr(ptr);
}
int cb_parse_arch_specific(struct cb_record *rec, struct sysinfo_t *info) int cb_parse_arch_specific(struct cb_record *rec, struct sysinfo_t *info)
{ {
switch(rec->tag) { switch(rec->tag) {
case CB_TAG_X86_ROM_MTRR: case CB_TAG_X86_ROM_MTRR:
cb_parse_x86_rom_var_mtrr(rec, info); cb_parse_x86_rom_var_mtrr(rec, info);
break; break;
case CB_TAG_MRC_CACHE:
cb_parse_mrc_cache(rec, info);
break;
default: default:
return 0; return 0;
} }

View File

@ -321,6 +321,16 @@ struct cb_boot_media_params {
uint64_t boot_media_size; 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 { struct cb_tsc_info {
uint32_t tag; uint32_t tag;
uint32_t size; uint32_t size;
@ -443,6 +453,4 @@ static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
(void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \ (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \
+ (sizeof((_rec)->map[0]) * (_idx))) + (sizeof((_rec)->map[0]) * (_idx)))
/* Helper functions */
uintptr_t get_cbmem_addr(const void *cbmem_tab_entry);
#endif #endif

View File

@ -150,6 +150,12 @@ struct sysinfo_t {
#endif #endif
/* USB Type-C Port Configuration Info */ /* USB Type-C Port Configuration Info */
uintptr_t type_c_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; extern struct sysinfo_t lib_sysinfo;

View File

@ -29,6 +29,7 @@
#include <libpayload-config.h> #include <libpayload-config.h>
#include <libpayload.h> #include <libpayload.h>
#include <commonlib/bsd/cbmem_id.h>
#include <coreboot_tables.h> #include <coreboot_tables.h>
#include <stdint.h> #include <stdint.h>
@ -41,12 +42,6 @@
/* === Parsing code === */ /* === Parsing code === */
/* This is the generic parsing code. */ /* This is the generic parsing code. */
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) static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
{ {
struct cb_memory *mem = ptr; struct cb_memory *mem = ptr;
@ -83,11 +78,6 @@ static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
info->cb_serial = virt_to_phys(ptr); info->cb_serial = virt_to_phys(ptr);
} }
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
{
info->vboot_workbuf = get_cbmem_addr(ptr);
}
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
{ {
struct lb_range *vbnv = (struct lb_range *)ptr; struct lb_range *vbnv = (struct lb_range *)ptr;
@ -128,26 +118,6 @@ static void cb_parse_mac_addresses(unsigned char *ptr,
info->macs[i] = macs->mac_addrs[i]; info->macs[i] = macs->mac_addrs[i];
} }
static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info)
{
info->tstamp_table = get_cbmem_addr(ptr);
}
static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
{
info->cbmem_cons = get_cbmem_addr(ptr);
}
static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)
{
info->acpi_gnvs = get_cbmem_addr(ptr);
}
static void cb_parse_acpi_cnvs(unsigned char *ptr, struct sysinfo_t *info)
{
info->acpi_cnvs = get_cbmem_addr(ptr);
}
static void cb_parse_board_config(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_board_config(unsigned char *ptr, struct sysinfo_t *info)
{ {
struct cb_board_config *const config = (struct cb_board_config *)ptr; struct cb_board_config *const config = (struct cb_board_config *)ptr;
@ -188,11 +158,6 @@ static void cb_parse_string(const void *const ptr, uintptr_t *const info)
*info = virt_to_phys(str->string); *info = virt_to_phys(str->string);
} }
static void cb_parse_wifi_calibration(void *ptr, struct sysinfo_t *info)
{
info->wifi_calibration = get_cbmem_addr(ptr);
}
static void cb_parse_ramoops(void *ptr, struct sysinfo_t *info) static void cb_parse_ramoops(void *ptr, struct sysinfo_t *info)
{ {
struct lb_range *ramoops = (struct lb_range *)ptr; struct lb_range *ramoops = (struct lb_range *)ptr;
@ -236,21 +201,6 @@ static void cb_parse_boot_media_params(unsigned char *ptr,
info->boot_media_size = bmp->boot_media_size; info->boot_media_size = bmp->boot_media_size;
} }
static void cb_parse_vpd(void *ptr, struct sysinfo_t *info)
{
info->chromeos_vpd = get_cbmem_addr(ptr);
}
static void cb_parse_fmap_cache(void *ptr, struct sysinfo_t *info)
{
info->fmap_cache = get_cbmem_addr(ptr);
}
static void cb_parse_type_c_info(void *ptr, struct sysinfo_t *info)
{
info->type_c_info = get_cbmem_addr(ptr);
}
#if CONFIG(LP_TIMER_RDTSC) #if CONFIG(LP_TIMER_RDTSC)
static void cb_parse_tsc_info(void *ptr, struct sysinfo_t *info) static void cb_parse_tsc_info(void *ptr, struct sysinfo_t *info)
{ {
@ -264,6 +214,57 @@ static void cb_parse_tsc_info(void *ptr, struct sysinfo_t *info)
} }
#endif #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_ACPI_CNVS:
info->acpi_cnvs = cbmem_entry->address;
break;
case CBMEM_ID_ACPI_GNVS:
info->acpi_gnvs = cbmem_entry->address;
break;
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;
case CBMEM_ID_CONSOLE:
info->cbmem_cons = cbmem_entry->address;
break;
case CBMEM_ID_MRCDATA:
info->mrc_cache = cbmem_entry->address;
break;
case CBMEM_ID_VBOOT_WORKBUF:
info->vboot_workbuf = cbmem_entry->address;
break;
case CBMEM_ID_TIMESTAMP:
info->tstamp_table = cbmem_entry->address;
break;
case CBMEM_ID_VPD:
info->chromeos_vpd = cbmem_entry->address;
break;
case CBMEM_ID_FMAP:
info->fmap_cache = cbmem_entry->address;
break;
case CBMEM_ID_WIFI_CALIBRATION:
info->wifi_calibration = cbmem_entry->address;
break;
case CBMEM_ID_TYPE_C_INFO:
info->type_c_info = cbmem_entry->address;
break;
default:
break;
}
}
int cb_parse_header(void *addr, int len, struct sysinfo_t *info) int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
{ {
struct cb_header *header; struct cb_header *header;
@ -372,33 +373,15 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_VBNV: case CB_TAG_VBNV:
cb_parse_vbnv(ptr, info); cb_parse_vbnv(ptr, info);
break; break;
case CB_TAG_VBOOT_WORKBUF:
cb_parse_vboot_workbuf(ptr, info);
break;
case CB_TAG_MAC_ADDRS: case CB_TAG_MAC_ADDRS:
cb_parse_mac_addresses(ptr, info); cb_parse_mac_addresses(ptr, info);
break; break;
case CB_TAG_SERIALNO: case CB_TAG_SERIALNO:
cb_parse_string(ptr, &info->serialno); cb_parse_string(ptr, &info->serialno);
break; break;
case CB_TAG_TIMESTAMPS:
cb_parse_tstamp(ptr, info);
break;
case CB_TAG_CBMEM_CONSOLE:
cb_parse_cbmem_cons(ptr, info);
break;
case CB_TAG_ACPI_GNVS:
cb_parse_acpi_gnvs(ptr, info);
break;
case CB_TAG_ACPI_CNVS:
cb_parse_acpi_cnvs(ptr, info);
break;
case CB_TAG_BOARD_CONFIG: case CB_TAG_BOARD_CONFIG:
cb_parse_board_config(ptr, info); cb_parse_board_config(ptr, info);
break; break;
case CB_TAG_WIFI_CALIBRATION:
cb_parse_wifi_calibration(ptr, info);
break;
case CB_TAG_RAM_OOPS: case CB_TAG_RAM_OOPS:
cb_parse_ramoops(ptr, info); cb_parse_ramoops(ptr, info);
break; break;
@ -414,20 +397,14 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_BOOT_MEDIA_PARAMS: case CB_TAG_BOOT_MEDIA_PARAMS:
cb_parse_boot_media_params(ptr, info); cb_parse_boot_media_params(ptr, info);
break; break;
case CB_TAG_CBMEM_ENTRY:
cb_parse_cbmem_entry(ptr, info);
break;
#if CONFIG(LP_TIMER_RDTSC) #if CONFIG(LP_TIMER_RDTSC)
case CB_TAG_TSC_INFO: case CB_TAG_TSC_INFO:
cb_parse_tsc_info(ptr, info); cb_parse_tsc_info(ptr, info);
break; break;
#endif #endif
case CB_TAG_VPD:
cb_parse_vpd(ptr, info);
break;
case CB_TAG_FMAP:
cb_parse_fmap_cache(ptr, info);
break;
case CB_TAG_TYPE_C_INFO:
cb_parse_type_c_info(ptr, info);
break;
default: default:
cb_parse_arch_specific(rec, info); cb_parse_arch_specific(rec, info);
break; break;