mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-15 17:34:43 +00:00
Merge patch series "acpi: simplify updating ACPI table header checksum"
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> says: Introduce a new function to update ACPI table headers. This allows to simplify the existing code. Link: https://lore.kernel.org/r/20250321232121.251800-1-heinrich.schuchardt@canonical.com
This commit is contained in:
commit
fba8bfdd0b
13 changed files with 37 additions and 32 deletions
|
@ -81,7 +81,7 @@ static int acpi_write_pptt(struct acpi_ctx *ctx, const struct acpi_writer *entry
|
|||
}
|
||||
|
||||
header->length = ctx->current - ctx->tab_start;
|
||||
header->checksum = table_compute_checksum(header, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_inc(ctx, header->length);
|
||||
acpi_add_table(ctx, header);
|
||||
|
@ -116,7 +116,7 @@ static int rpi_write_gtdt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
gtdt->el2_flags = GTDT_FLAG_INT_ACTIVE_LOW;
|
||||
gtdt->cnt_read_base = 0xffffffffffffffff;
|
||||
|
||||
header->checksum = table_compute_checksum(header, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_add_table(ctx, gtdt);
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ static int apl_acpi_hb_write_tables(const struct udevice *dev,
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
header->length = ctx->current - (void *)dmar;
|
||||
header->checksum = table_compute_checksum((void *)dmar, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_align(ctx);
|
||||
acpi_add_table(ctx, dmar);
|
||||
|
|
|
@ -414,7 +414,7 @@ int nhlt_serialise_oem_overrides(struct acpi_ctx *ctx, struct nhlt *nhlt,
|
|||
cur.start = (void *)header;
|
||||
nhlt_serialise_endpoints(nhlt, &cur);
|
||||
|
||||
header->checksum = table_compute_checksum(header, sz);
|
||||
acpi_update_checksum(header);
|
||||
nhlt_free_resources(nhlt);
|
||||
assert(cur.buf - cur.start == sz);
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ int acpi_write_tcpa(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
/* (Re)calculate length and checksum */
|
||||
current = (u32)tcpa + sizeof(struct acpi_tcpa);
|
||||
header->length = current - (u32)tcpa;
|
||||
header->checksum = table_compute_checksum(tcpa, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_inc(ctx, tcpa->header.length);
|
||||
acpi_add_table(ctx, tcpa);
|
||||
|
@ -242,7 +242,7 @@ static int acpi_write_tpm2(struct acpi_ctx *ctx,
|
|||
tpm2->lasa = nomap_to_sysmem(lasa);
|
||||
|
||||
/* Calculate checksum. */
|
||||
header->checksum = table_compute_checksum(tpm2, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_inc(ctx, tpm2->header.length);
|
||||
acpi_add_table(ctx, tpm2);
|
||||
|
@ -279,9 +279,7 @@ int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
* patched the GNVS address. Set the checksum to zero since it
|
||||
* is part of the region being checksummed.
|
||||
*/
|
||||
ctx->dsdt->checksum = 0;
|
||||
ctx->dsdt->checksum = table_compute_checksum((void *)ctx->dsdt,
|
||||
ctx->dsdt->length);
|
||||
acpi_update_checksum(ctx->dsdt);
|
||||
}
|
||||
|
||||
/* Fill in platform-specific global NVS variables */
|
||||
|
@ -330,8 +328,7 @@ static int acpi_create_hpet(struct acpi_hpet *hpet)
|
|||
hpet->number = 0;
|
||||
hpet->min_tick = 0; /* HPET_MIN_TICKS */
|
||||
|
||||
header->checksum = table_compute_checksum(hpet,
|
||||
sizeof(struct acpi_hpet));
|
||||
acpi_update_checksum(header);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ static int sbsa_write_gtdt(struct acpi_ctx *ctx, const struct acpi_writer *entry
|
|||
gtdt->cnt_read_base = 0xffffffffffffffff;
|
||||
|
||||
// FIXME: VirtualPL2Timer
|
||||
header->checksum = table_compute_checksum(header, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_add_table(ctx, gtdt);
|
||||
|
||||
|
@ -186,7 +186,7 @@ static int acpi_write_pptt(struct acpi_ctx *ctx, const struct acpi_writer *entry
|
|||
}
|
||||
|
||||
header->length = ctx->current - ctx->tab_start;
|
||||
header->checksum = table_compute_checksum(header, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_inc(ctx, header->length);
|
||||
acpi_add_table(ctx, header);
|
||||
|
|
|
@ -791,7 +791,7 @@ static int rpi_acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *e
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
ssdt->length = ctx->current - (void *)ssdt;
|
||||
ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
|
||||
acpi_update_checksum(ssdt);
|
||||
log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
|
||||
|
||||
/* Drop the table if it is empty */
|
||||
|
|
|
@ -1274,6 +1274,13 @@ ulong write_acpi_tables(ulong start);
|
|||
*/
|
||||
struct acpi_table_header *acpi_find_table(const char *sig);
|
||||
|
||||
/**
|
||||
* acpi_update_checksum() - update ACPI table checksum
|
||||
*
|
||||
* @header - header of an ACPI table
|
||||
*/
|
||||
void acpi_update_checksum(struct acpi_table_header *header);
|
||||
|
||||
#endif /* !__ACPI__*/
|
||||
|
||||
#include <asm/acpi_table.h>
|
||||
|
|
|
@ -6,11 +6,18 @@
|
|||
*/
|
||||
|
||||
#include <mapmem.h>
|
||||
#include <tables_csum.h>
|
||||
#include <acpi/acpi_table.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void acpi_update_checksum(struct acpi_table_header *header)
|
||||
{
|
||||
header->checksum = 0;
|
||||
header->checksum = table_compute_checksum(header, header->length);
|
||||
}
|
||||
|
||||
struct acpi_table_header *acpi_find_table(const char *sig)
|
||||
{
|
||||
struct acpi_rsdp *rsdp;
|
||||
|
|
|
@ -196,9 +196,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
|
|||
(sizeof(u32) * (i + 1));
|
||||
|
||||
/* Re-calculate checksum */
|
||||
rsdt->header.checksum = 0;
|
||||
rsdt->header.checksum = table_compute_checksum((u8 *)rsdt,
|
||||
rsdt->header.length);
|
||||
acpi_update_checksum(&rsdt->header);
|
||||
}
|
||||
|
||||
if (ctx->xsdt) {
|
||||
|
@ -229,9 +227,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
|
|||
(sizeof(u64) * (i + 1));
|
||||
|
||||
/* Re-calculate checksum */
|
||||
xsdt->header.checksum = 0;
|
||||
xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
|
||||
xsdt->header.length);
|
||||
acpi_update_checksum(&xsdt->header);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -269,7 +265,7 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
|
||||
acpi_fill_fadt(fadt);
|
||||
|
||||
header->checksum = table_compute_checksum(fadt, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
return acpi_add_fadt(ctx, fadt);
|
||||
}
|
||||
|
@ -304,7 +300,7 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
if (IS_ENABLED(CONFIG_ACPI_PARKING_PROTOCOL))
|
||||
acpi_write_park(madt);
|
||||
|
||||
header->checksum = table_compute_checksum((void *)madt, header->length);
|
||||
acpi_update_checksum(header);
|
||||
acpi_add_table(ctx, madt);
|
||||
ctx->current = (void *)madt + madt->header.length;
|
||||
|
||||
|
@ -375,7 +371,7 @@ void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
|
|||
/* Update structure lengths and checksum */
|
||||
device->length = current - (uintptr_t)device;
|
||||
header->length = current - (uintptr_t)dbg2;
|
||||
header->checksum = table_compute_checksum(dbg2, header->length);
|
||||
acpi_update_checksum(header);
|
||||
}
|
||||
|
||||
int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
|
||||
|
@ -550,7 +546,7 @@ static int acpi_write_spcr(struct acpi_ctx *ctx, const struct acpi_writer *entry
|
|||
spcr->baud_rate = 0;
|
||||
|
||||
/* Fix checksum */
|
||||
header->checksum = table_compute_checksum((void *)spcr, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_add_table(ctx, spcr);
|
||||
acpi_inc(ctx, spcr->header.length);
|
||||
|
@ -787,7 +783,7 @@ static int acpi_write_iort(struct acpi_ctx *ctx, const struct acpi_writer *entry
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
iort->header.length = ctx->current - (void *)iort;
|
||||
iort->header.checksum = table_compute_checksum((void *)iort, iort->header.length);
|
||||
acpi_update_checksum(&iort->header);
|
||||
log_debug("IORT at %p, length %x\n", iort, iort->header.length);
|
||||
|
||||
/* Drop the table if it is empty */
|
||||
|
|
|
@ -50,8 +50,7 @@ static void acpi_write_rsdt(struct acpi_rsdt *rsdt)
|
|||
/* Entries are filled in later, we come with an empty set */
|
||||
|
||||
/* Fix checksum */
|
||||
header->checksum = table_compute_checksum(rsdt,
|
||||
sizeof(struct acpi_rsdt));
|
||||
acpi_update_checksum(header);
|
||||
}
|
||||
|
||||
static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
|
||||
|
@ -66,8 +65,7 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
|
|||
/* Entries are filled in later, we come with an empty set */
|
||||
|
||||
/* Fix checksum */
|
||||
header->checksum = table_compute_checksum(xsdt,
|
||||
sizeof(struct acpi_xsdt));
|
||||
acpi_update_checksum(header);
|
||||
}
|
||||
|
||||
static int acpi_write_base(struct acpi_ctx *ctx,
|
||||
|
|
|
@ -40,7 +40,7 @@ int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
header->length = (ulong)ctx->current - (ulong)csrt;
|
||||
header->checksum = table_compute_checksum(csrt, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_add_table(ctx, csrt);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ int acpi_write_mcfg(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
header->length = (ulong)ctx->current - (ulong)mcfg;
|
||||
header->checksum = table_compute_checksum(mcfg, header->length);
|
||||
acpi_update_checksum(header);
|
||||
|
||||
acpi_add_table(ctx, mcfg);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
|||
|
||||
/* (Re)calculate length and checksum */
|
||||
ssdt->length = ctx->current - (void *)ssdt;
|
||||
ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
|
||||
acpi_update_checksum(ssdt);
|
||||
log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
|
||||
|
||||
/* Drop the table if it is empty */
|
||||
|
|
Loading…
Add table
Reference in a new issue