x86: Allow writing tables to fail

At present write_tables() can fail but does not report this problem to its
caller. Fix this by changing the return type.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Simon Glass 2020-11-04 09:57:18 -07:00 committed by Bin Meng
parent 653554b40a
commit 38e498c3a2
3 changed files with 15 additions and 3 deletions

View file

@ -18,6 +18,8 @@
* src/arch/x86/lib/cpu.c * src/arch/x86/lib/cpu.c
*/ */
#define LOG_CATEGORY UCLASS_CPU
#include <common.h> #include <common.h>
#include <bootstage.h> #include <bootstage.h>
#include <command.h> #include <command.h>
@ -200,6 +202,7 @@ __weak void board_final_cleanup(void)
int last_stage_init(void) int last_stage_init(void)
{ {
struct acpi_fadt __maybe_unused *fadt; struct acpi_fadt __maybe_unused *fadt;
int ret;
board_final_init(); board_final_init();
@ -210,7 +213,11 @@ int last_stage_init(void)
acpi_resume(fadt); acpi_resume(fadt);
} }
write_tables(); ret = write_tables();
if (ret) {
log_err("Failed to write tables\n");
return log_msg_ret("table", ret);
}
if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) { if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
fadt = acpi_find_fadt(); fadt = acpi_find_fadt();

View file

@ -49,8 +49,10 @@ void table_fill_string(char *dest, const char *src, size_t n, char pad);
* This writes x86 configuration tables, including PIRQ routing table, * This writes x86 configuration tables, including PIRQ routing table,
* Multi-Processor table and ACPI table. Whether a specific type of * Multi-Processor table and ACPI table. Whether a specific type of
* configuration table is written is controlled by a Kconfig option. * configuration table is written is controlled by a Kconfig option.
*
* @return 0 if OK, -ENOSPC if table too large
*/ */
void write_tables(void); int write_tables(void);
/** /**
* write_pirq_routing_table() - Write PIRQ routing table * write_pirq_routing_table() - Write PIRQ routing table

View file

@ -64,7 +64,7 @@ void table_fill_string(char *dest, const char *src, size_t n, char pad)
dest[i] = pad; dest[i] = pad;
} }
void write_tables(void) int write_tables(void)
{ {
u32 rom_table_start = ROM_TABLE_ADDR; u32 rom_table_start = ROM_TABLE_ADDR;
u32 rom_table_end; u32 rom_table_end;
@ -91,6 +91,7 @@ void write_tables(void)
cfg_tables[i].size = table_size; cfg_tables[i].size = table_size;
} else { } else {
printf("%d: no memory for configuration tables\n", i); printf("%d: no memory for configuration tables\n", i);
return -ENOSPC;
} }
#endif #endif
@ -105,4 +106,6 @@ void write_tables(void)
write_coreboot_table(CB_TABLE_ADDR, cfg_tables); write_coreboot_table(CB_TABLE_ADDR, cfg_tables);
#endif #endif
debug("- done writing tables\n"); debug("- done writing tables\n");
return 0;
} }