mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
x86: Add error checking for csrt table generation
Generation of this table can fail, so update the function to return an error code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
This commit is contained in:
@@ -212,13 +212,14 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
|
|||||||
|
|
||||||
__weak u32 acpi_fill_csrt(u32 current)
|
__weak u32 acpi_fill_csrt(u32 current)
|
||||||
{
|
{
|
||||||
return current;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_create_csrt(struct acpi_csrt *csrt)
|
static int acpi_create_csrt(struct acpi_csrt *csrt)
|
||||||
{
|
{
|
||||||
struct acpi_table_header *header = &(csrt->header);
|
struct acpi_table_header *header = &(csrt->header);
|
||||||
u32 current = (u32)csrt + sizeof(struct acpi_csrt);
|
u32 current = (u32)csrt + sizeof(struct acpi_csrt);
|
||||||
|
uint ptr;
|
||||||
|
|
||||||
memset((void *)csrt, 0, sizeof(struct acpi_csrt));
|
memset((void *)csrt, 0, sizeof(struct acpi_csrt));
|
||||||
|
|
||||||
@@ -227,11 +228,16 @@ static void acpi_create_csrt(struct acpi_csrt *csrt)
|
|||||||
header->length = sizeof(struct acpi_csrt);
|
header->length = sizeof(struct acpi_csrt);
|
||||||
header->revision = 0;
|
header->revision = 0;
|
||||||
|
|
||||||
current = acpi_fill_csrt(current);
|
ptr = acpi_fill_csrt(current);
|
||||||
|
if (!ptr)
|
||||||
|
return -ENOENT;
|
||||||
|
current = ptr;
|
||||||
|
|
||||||
/* (Re)calculate length and checksum */
|
/* (Re)calculate length and checksum */
|
||||||
header->length = current - (u32)csrt;
|
header->length = current - (u32)csrt;
|
||||||
header->checksum = table_compute_checksum((void *)csrt, header->length);
|
header->checksum = table_compute_checksum((void *)csrt, header->length);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_create_spcr(struct acpi_spcr *spcr)
|
static void acpi_create_spcr(struct acpi_spcr *spcr)
|
||||||
@@ -482,9 +488,10 @@ ulong write_acpi_tables(ulong start_addr)
|
|||||||
|
|
||||||
debug("ACPI: * CSRT\n");
|
debug("ACPI: * CSRT\n");
|
||||||
csrt = ctx->current;
|
csrt = ctx->current;
|
||||||
acpi_create_csrt(csrt);
|
if (!acpi_create_csrt(csrt)) {
|
||||||
acpi_inc_align(ctx, csrt->header.length);
|
acpi_inc_align(ctx, csrt->header.length);
|
||||||
acpi_add_table(ctx, csrt);
|
acpi_add_table(ctx, csrt);
|
||||||
|
}
|
||||||
|
|
||||||
debug("ACPI: * SPCR\n");
|
debug("ACPI: * SPCR\n");
|
||||||
spcr = ctx->current;
|
spcr = ctx->current;
|
||||||
|
Reference in New Issue
Block a user