diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-01-10 10:53:24 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-11-27 15:04:48 -0500 |
commit | 9ec57de1db32fc75d2acd740d4a3bf47cdf023e6 (patch) | |
tree | fe5355b64af835df28d932d404c61770e7d4f17c | |
parent | 0166993d3c47c0c9a69175b5c24166e74f9d5b07 (diff) | |
download | seabios-9ec57de1db32fc75d2acd740d4a3bf47cdf023e6.tar.gz |
acpi: Generalize find_fadt() and find_tcpa_by_rsdp() into find_acpi_table()
The find_fadt() and find_tcpa_by_rsdp() functions are very similar.
Create a new find_acpi_table() function and replace the two functions
with this new function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | src/fw/biostables.c | 18 | ||||
-rw-r--r-- | src/std/acpi.h | 7 | ||||
-rw-r--r-- | src/tcgbios.c | 34 | ||||
-rw-r--r-- | src/util.h | 1 |
4 files changed, 11 insertions, 49 deletions
diff --git a/src/fw/biostables.c b/src/fw/biostables.c index 9fb9ff9d..fe8626ef 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -134,8 +134,8 @@ void *find_acpi_rsdp(void) return NULL; } -static struct fadt_descriptor_rev1 * -find_fadt(void) +void * +find_acpi_table(u32 signature) { dprintf(4, "rsdp=%p\n", RsdpAddr); if (!RsdpAddr || RsdpAddr->signature != RSDP_SIGNATURE) @@ -147,20 +147,20 @@ find_fadt(void) void *end = (void*)rsdt + rsdt->length; int i; for (i=0; (void*)&rsdt->table_offset_entry[i] < end; i++) { - struct fadt_descriptor_rev1 *fadt = (void*)rsdt->table_offset_entry[i]; - if (!fadt || fadt->signature != FACP_SIGNATURE) + struct acpi_table_header *tbl = (void*)rsdt->table_offset_entry[i]; + if (!tbl || tbl->signature != signature) continue; - dprintf(4, "fadt=%p\n", fadt); - return fadt; + dprintf(4, "table(%x)=%p\n", signature, tbl); + return tbl; } - dprintf(4, "no fadt found\n"); + dprintf(4, "no table %x found\n", signature); return NULL; } u32 find_resume_vector(void) { - struct fadt_descriptor_rev1 *fadt = find_fadt(); + struct fadt_descriptor_rev1 *fadt = find_acpi_table(FACP_SIGNATURE); if (!fadt) return 0; struct facs_descriptor_rev1 *facs = (void*)fadt->firmware_ctrl; @@ -218,7 +218,7 @@ acpi_set_reset_reg(struct acpi_20_generic_address *reg, u8 val) void find_acpi_features(void) { - struct fadt_descriptor_rev1 *fadt = find_fadt(); + struct fadt_descriptor_rev1 *fadt = find_acpi_table(FACP_SIGNATURE); if (!fadt) return; u32 pm_tmr = le32_to_cpu(fadt->pm_tmr_blk); diff --git a/src/std/acpi.h b/src/std/acpi.h index b672bbee..c2ea7075 100644 --- a/src/std/acpi.h +++ b/src/std/acpi.h @@ -294,12 +294,6 @@ struct acpi_table_mcfg { struct acpi_mcfg_allocation allocation[0]; } PACKED; - -struct rsdt_descriptor { - ACPI_TABLE_HEADER_DEF - u32 entry[1]; -} PACKED; - #define TCPA_SIGNATURE 0x41504354 struct tcpa_descriptor_rev2 { @@ -313,5 +307,4 @@ struct tcpa_descriptor_rev2 #define TCPA_ACPI_CLASS_CLIENT 0 #define TCPA_ACPI_CLASS_SERVER 1 - #endif // acpi.h diff --git a/src/tcgbios.c b/src/tcgbios.c index 5c40d62e..5475535a 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -71,42 +71,10 @@ struct { u8 * log_area_last_entry; } tpm_state VARLOW; -static struct tcpa_descriptor_rev2 * -find_tcpa_by_rsdp(struct rsdp_descriptor *rsdp) -{ - if (!rsdp) { - dprintf(DEBUG_tcg, - "TCGBIOS: RSDP was NOT found! -- Disabling interface.\n"); - return NULL; - } - struct rsdt_descriptor *rsdt = (void*)rsdp->rsdt_physical_address; - if (!rsdt) - return NULL; - - u32 length = rsdt->length; - u16 off = offsetof(struct rsdt_descriptor, entry); - u32 ctr = 0; - while ((off + sizeof(rsdt->entry[0])) <= length) { - /* try all pointers to structures */ - struct tcpa_descriptor_rev2 *tcpa = (void*)rsdt->entry[ctr]; - - /* valid TCPA ACPI table ? */ - if (tcpa->signature == TCPA_SIGNATURE - && checksum(tcpa, tcpa->length) == 0) - return tcpa; - - off += sizeof(rsdt->entry[0]); - ctr++; - } - - dprintf(DEBUG_tcg, "TCGBIOS: TCPA ACPI was NOT found!\n"); - return NULL; -} - static int tpm_tcpa_probe(void) { - struct tcpa_descriptor_rev2 *tcpa = find_tcpa_by_rsdp(RsdpAddr); + struct tcpa_descriptor_rev2 *tcpa = find_acpi_table(TCPA_SIGNATURE); if (!tcpa) return -1; @@ -72,6 +72,7 @@ extern struct rsdp_descriptor *RsdpAddr; extern u32 acpi_pm1a_cnt; extern u16 acpi_pm_base; void *find_acpi_rsdp(void); +void *find_acpi_table(u32 signature); u32 find_resume_vector(void); void acpi_reboot(void); void find_acpi_features(void); |