cbmem.h: Change return type of cbmem_get_region
The underlying IMD function already returns an integer which indicates success or failure. This removes the need to have initialized variables that need to be checked for NULL later. In some cases this actually adds the appropriate check for returned values. Dying is appropriate if cbmem is not found as it is essential to the bootflow. Change-Id: Ib3e09a75380faf9f533601368993261f042422ef Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/84039 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
parent
86dadcd52a
commit
aa75ee1a71
7 changed files with 23 additions and 15 deletions
|
|
@ -147,7 +147,8 @@ static void postcar_flush_cache(void)
|
|||
uintptr_t stage_cache_base;
|
||||
size_t stage_cache_size;
|
||||
|
||||
cbmem_get_region((void **)&cbmem_base, &cbmem_size);
|
||||
if (cbmem_get_region((void **)&cbmem_base, &cbmem_size))
|
||||
die("Could not find cbmem region");
|
||||
prog_segment_loaded(cbmem_base, cbmem_size, SEG_FINAL);
|
||||
if (CONFIG(TSEG_STAGE_CACHE) && !romstage_handoff_is_resume()) {
|
||||
stage_cache_external_region((void **)&stage_cache_base, &stage_cache_size);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void cbmem_run_init_hooks(int is_recovery);
|
|||
/* Add the cbmem memory used to the memory map at boot. */
|
||||
void cbmem_add_bootmem(void);
|
||||
/* Return the cbmem memory used */
|
||||
void cbmem_get_region(void **baseptr, size_t *size);
|
||||
int cbmem_get_region(void **baseptr, size_t *size);
|
||||
void cbmem_list(void);
|
||||
void cbmem_add_records_to_cbtable(struct lb_header *header);
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ static void add_cb_fdt_data(struct device_tree *tree)
|
|||
{
|
||||
u32 addr_cells = 1, size_cells = 1;
|
||||
u64 reg_addrs[2], reg_sizes[2];
|
||||
void *baseptr = NULL;
|
||||
size_t size = 0;
|
||||
void *baseptr;
|
||||
size_t size;
|
||||
|
||||
static const char *firmware_path[] = {"firmware", NULL};
|
||||
struct device_tree_node *firmware_node = dt_find_node(tree->root,
|
||||
|
|
@ -140,8 +140,7 @@ static void add_cb_fdt_data(struct device_tree *tree)
|
|||
|
||||
/* Second is the CBMEM area (which usually includes the coreboot
|
||||
table). */
|
||||
cbmem_get_region(&baseptr, &size);
|
||||
if (!baseptr || size == 0) {
|
||||
if (cbmem_get_region(&baseptr, &size)) {
|
||||
printk(BIOS_WARNING, "FIT: CBMEM pointer/size not found!\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,16 +193,19 @@ void *cbmem_entry_start(const struct cbmem_entry *entry)
|
|||
|
||||
void cbmem_add_bootmem(void)
|
||||
{
|
||||
void *baseptr = NULL;
|
||||
size_t size = 0;
|
||||
void *baseptr;
|
||||
size_t size;
|
||||
|
||||
cbmem_get_region(&baseptr, &size);
|
||||
if (cbmem_get_region(&baseptr, &size)) {
|
||||
printk(BIOS_ERR, "CBMEM pointer/size not found!\n");
|
||||
return;
|
||||
}
|
||||
bootmem_add_range((uintptr_t)baseptr, size, BM_MEM_TABLE);
|
||||
}
|
||||
|
||||
void cbmem_get_region(void **baseptr, size_t *size)
|
||||
int cbmem_get_region(void **baseptr, size_t *size)
|
||||
{
|
||||
imd_region_used(&imd, baseptr, size);
|
||||
return imd_region_used(&imd, baseptr, size);
|
||||
}
|
||||
|
||||
#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) && ENV_HAS_CBMEM)
|
||||
|
|
|
|||
|
|
@ -74,12 +74,13 @@ static void clear_memory(void *unused)
|
|||
BM_MEM_RAM);
|
||||
|
||||
/* Add reserved entries */
|
||||
void *baseptr = NULL;
|
||||
size_t size = 0;
|
||||
void *baseptr;
|
||||
size_t size;
|
||||
|
||||
/* Only skip CBMEM, stage program, stack and heap are included there. */
|
||||
|
||||
cbmem_get_region(&baseptr, &size);
|
||||
if (cbmem_get_region(&baseptr, &size))
|
||||
die("Could not find cbmem region");
|
||||
memranges_insert(&mem, (uintptr_t)baseptr, size, BM_MEM_TABLE);
|
||||
|
||||
if (ENV_X86) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
|||
size_t cbmem_size;
|
||||
|
||||
/* Try account for the CBMEM region currently used and for future use */
|
||||
cbmem_get_region((void **)&cbmem_base, &cbmem_size);
|
||||
if (cbmem_get_region((void **)&cbmem_base, &cbmem_size))
|
||||
die("Could not find cbmem region");
|
||||
printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram);
|
||||
printk(BIOS_DEBUG, "cbmem base_ptr: 0x%lx, size: 0x%zx\n", cbmem_base, cbmem_size);
|
||||
/* Assume 4MiB will be enough for future cbmem objects (FSP-S, ramstage, ...) */
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ hexstrtobin-test-srcs += src/lib/hexstrtobin.c
|
|||
imd-test-srcs += tests/lib/imd-test.c
|
||||
imd-test-srcs += tests/stubs/console.c
|
||||
imd-test-srcs += src/lib/imd.c
|
||||
imd-test-srcs += tests/stubs/die.c
|
||||
|
||||
timestamp-test-srcs += tests/lib/timestamp-test.c
|
||||
timestamp-test-srcs += tests/stubs/timestamp.c
|
||||
|
|
@ -85,12 +86,14 @@ imd_cbmem-ramstage-test-srcs += tests/lib/imd_cbmem-test.c
|
|||
imd_cbmem-ramstage-test-srcs += tests/stubs/console.c
|
||||
imd_cbmem-ramstage-test-srcs += src/lib/imd.c
|
||||
imd_cbmem-ramstage-test-mocks += cbmem_top_chipset
|
||||
imd_cbmem-ramstage-test-srcs += tests/stubs/die.c
|
||||
|
||||
imd_cbmem-romstage-test-stage := romstage
|
||||
imd_cbmem-romstage-test-srcs += tests/lib/imd_cbmem-test.c
|
||||
imd_cbmem-romstage-test-srcs += tests/stubs/console.c
|
||||
imd_cbmem-romstage-test-srcs += src/lib/imd.c
|
||||
imd_cbmem-romstage-test-mocks += cbmem_top_chipset
|
||||
imd_cbmem-romstage-test-srcs += tests/stubs/die.c
|
||||
|
||||
region_file-test-srcs += tests/lib/region_file-test.c
|
||||
region_file-test-srcs += src/commonlib/region.c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue