forked from pool/acpica
333 lines
11 KiB
Diff
333 lines
11 KiB
Diff
Adjust acpidump to latest acpica headers and make it compile in acpica env
|
|
|
|
From: Thomas Renninger <trenn@suse.de>
|
|
|
|
--- x/acpidump/acpidump.c 2009-04-08 14:18:29.000000000 +0200
|
|
+++ y/acpidump/acpidump.c 2009-04-08 14:11:52.000000000 +0200
|
|
@@ -45,12 +45,16 @@
|
|
#include <getopt.h>
|
|
|
|
|
|
-#include <acpi/acconfig.h>
|
|
-#include <acpi/platform/acenv.h>
|
|
-#include <acpi/actypes.h>
|
|
-#include <acpi/actbl.h>
|
|
+#include "acconfig.h"
|
|
+#include "platform/acenv.h"
|
|
+#include "actypes.h"
|
|
+#include "actbl.h"
|
|
+
|
|
+typedef unsigned char u8;
|
|
+typedef UINT32 u32;
|
|
+typedef UINT64 u64;
|
|
|
|
-static inline u8 checksum(u8 * buffer, u32 length)
|
|
+static u8 checksum(u8 * buffer, u8 length)
|
|
{
|
|
u8 sum = 0, *i = buffer;
|
|
buffer += length;
|
|
@@ -105,28 +109,28 @@ static struct acpi_table_header *acpi_ma
|
|
unsigned size;
|
|
struct acpi_table_header *tbl = (struct acpi_table_header *)
|
|
acpi_map_memory(where, sizeof(struct acpi_table_header));
|
|
- if (!tbl || (sig && memcmp(sig, tbl->signature, 4))) return 0;
|
|
- size = tbl->length;
|
|
+ if (!tbl || (sig && memcmp(sig, tbl->Signature, 4))) return 0;
|
|
+ size = tbl->Length;
|
|
acpi_unmap_memory((u8 *) tbl, sizeof(struct acpi_table_header));
|
|
return (struct acpi_table_header *)acpi_map_memory(where, size);
|
|
}
|
|
|
|
static void acpi_unmap_table(struct acpi_table_header *tbl)
|
|
{
|
|
- acpi_unmap_memory((u8 *)tbl, tbl->length);
|
|
+ acpi_unmap_memory((u8 *)tbl, tbl->Length);
|
|
}
|
|
|
|
-static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
|
|
+static struct acpi_table_rsdp *acpi_scan_for_rsdp(u8 *begin, u32 length)
|
|
{
|
|
- struct acpi_rsdp_descriptor *rsdp;
|
|
+ struct acpi_table_rsdp *rsdp;
|
|
u8 *i, *end = begin + length;
|
|
/* Search from given start address for the requested length */
|
|
for (i = begin; i < end; i += ACPI_RSDP_SCAN_STEP) {
|
|
/* The signature and checksum must both be correct */
|
|
if (memcmp((char *)i, "RSD PTR ", 8)) continue;
|
|
- rsdp = (struct acpi_rsdp_descriptor *)i;
|
|
+ rsdp = (struct acpi_table_rsdp *)i;
|
|
/* Signature matches, check the appropriate checksum */
|
|
- if (!checksum((u8 *) rsdp, (rsdp->revision < 2) ?
|
|
+ if (!checksum((u8 *) rsdp, (rsdp->Revision < 2) ?
|
|
ACPI_RSDP_CHECKSUM_LENGTH :
|
|
ACPI_RSDP_XCHECKSUM_LENGTH))
|
|
/* Checksum valid, we have found a valid RSDP */
|
|
@@ -204,9 +208,9 @@ check_table_dumped(u64 address) {
|
|
static void acpi_show_table(int fd, struct acpi_table_header *table, unsigned long addr)
|
|
{
|
|
char buff[80];
|
|
- int len = snprintf(buff, 80, "%.4s @ %p\n", table->signature, (void *)addr);
|
|
+ int len = snprintf(buff, 80, "%.4s @ %p\n", table->Signature, (void *)addr);
|
|
write(fd, buff, len);
|
|
- acpi_show_data(fd, (u8 *) table, table->length);
|
|
+ acpi_show_data(fd, (u8 *) table, table->Length);
|
|
buff[0] = '\n';
|
|
write(fd, buff, 1);
|
|
}
|
|
@@ -222,9 +226,9 @@ static void write_table(int fd, struct a
|
|
if (print) {
|
|
acpi_show_table(fd, tbl, addr);
|
|
} else {
|
|
- write(fd, tbl, tbl->length);
|
|
+ write(fd, tbl, tbl->Length);
|
|
}
|
|
- } else if (!select_done && !memcmp(select_sig, tbl->signature, 4)) {
|
|
+ } else if (!select_done && !memcmp(select_sig, tbl->Signature, 4)) {
|
|
if (skip > 0) {
|
|
--skip;
|
|
return;
|
|
@@ -232,7 +236,7 @@ static void write_table(int fd, struct a
|
|
if (print) {
|
|
acpi_show_table(fd, tbl, addr);
|
|
} else {
|
|
- write(fd, tbl, tbl->length);
|
|
+ write(fd, tbl, tbl->Length);
|
|
}
|
|
select_done = 1;
|
|
}
|
|
@@ -240,51 +244,51 @@ static void write_table(int fd, struct a
|
|
}
|
|
|
|
static void acpi_dump_FADT(int fd, struct acpi_table_header *tbl, unsigned long xaddr) {
|
|
- struct acpi_fadt_descriptor x;
|
|
+ struct acpi_table_fadt x;
|
|
unsigned long addr;
|
|
- size_t len = sizeof(struct acpi_fadt_descriptor);
|
|
- if (len > tbl->length) len = tbl->length;
|
|
+ size_t len = sizeof(struct acpi_table_fadt);
|
|
+ if (len > tbl->Length) len = tbl->Length;
|
|
memcpy(&x, tbl, len);
|
|
- x.header.length = len;
|
|
+ x.Header.Length = len;
|
|
if (checksum((u8 *)tbl, len)) {
|
|
fprintf(stderr, "Wrong checksum for FADT!\n");
|
|
}
|
|
- if (x.header.length >= 148 && x.Xdsdt) {
|
|
- addr = (unsigned long)x.Xdsdt;
|
|
+ if (x.Header.Length >= 148 && x.XDsdt) {
|
|
+ addr = (unsigned long)x.XDsdt;
|
|
if (connect) {
|
|
- x.Xdsdt = lseek(fd, 0, SEEK_CUR);
|
|
+ x.XDsdt = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
- } else if (x.header.length >= 44 && x.dsdt) {
|
|
- addr = (unsigned long)x.dsdt;
|
|
+ } else if (x.Header.Length >= 44 && x.Dsdt) {
|
|
+ addr = (unsigned long)x.Dsdt;
|
|
if (connect) {
|
|
- x.dsdt = lseek(fd, 0, SEEK_CUR);
|
|
+ x.Dsdt = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
} else {
|
|
fprintf(stderr, "No DSDT in FADT!\n");
|
|
goto no_dsdt;
|
|
}
|
|
- tbl = acpi_map_table(addr, DSDT_SIG);
|
|
+ tbl = acpi_map_table(addr, ACPI_SIG_DSDT);
|
|
if (!tbl) goto no_dsdt;
|
|
- if (checksum((u8 *)tbl, tbl->length))
|
|
+ if (checksum((u8 *)tbl, tbl->Length))
|
|
fprintf(stderr, "Wrong checksum for DSDT!\n");
|
|
write_table(fd, tbl, addr);
|
|
acpi_unmap_table(tbl);
|
|
no_dsdt:
|
|
- if (x.header.length >= 140 && x.xfirmware_ctrl) {
|
|
- addr = (unsigned long)x.xfirmware_ctrl;
|
|
+ if (x.Header.Length >= 140 && x.XFacs) {
|
|
+ addr = (unsigned long)x.XFacs;
|
|
if (connect) {
|
|
- x.xfirmware_ctrl = lseek(fd, 0, SEEK_CUR);
|
|
+ x.XFacs = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
- } else if (x.header.length >= 40 && x.firmware_ctrl) {
|
|
- addr = (unsigned long)x.firmware_ctrl;
|
|
+ } else if (x.Header.Length >= 40 && x.Facs) {
|
|
+ addr = (unsigned long)x.Facs;
|
|
if (connect) {
|
|
- x.firmware_ctrl = lseek(fd, 0, SEEK_CUR);
|
|
+ x.Facs = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
} else {
|
|
fprintf(stderr, "No FACS in FADT!\n");
|
|
goto no_facs;
|
|
}
|
|
- tbl = acpi_map_table(addr, FACS_SIG);
|
|
+ tbl = acpi_map_table(addr, ACPI_SIG_FACS);
|
|
if (!tbl) goto no_facs;
|
|
/* do not checksum FACS */
|
|
write_table(fd, tbl, addr);
|
|
@@ -294,22 +298,22 @@ no_facs:
|
|
}
|
|
|
|
|
|
-static int acpi_dump_RSDT(int fd, struct acpi_rsdp_descriptor *rsdp)
|
|
+static int acpi_dump_RSDT(int fd, struct acpi_table_rsdp *rsdp)
|
|
{
|
|
struct acpi_table_header *sdt, *tbl = 0;
|
|
int i, num;
|
|
char *offset;
|
|
unsigned long addr;
|
|
|
|
- tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
|
|
+ tbl = acpi_map_table(rsdp->RsdtPhysicalAddress, "RSDT");
|
|
if (!tbl) return 0;
|
|
|
|
- sdt = malloc(tbl->length);
|
|
- memcpy(sdt, tbl, tbl->length);
|
|
+ sdt = malloc(tbl->Length);
|
|
+ memcpy(sdt, tbl, tbl->Length);
|
|
acpi_unmap_table(tbl);
|
|
- if (checksum((u8 *)sdt, sdt->length))
|
|
+ if (checksum((u8 *)sdt, sdt->Length))
|
|
fprintf(stderr, "Wrong checksum for %s!\n", "RSDT");
|
|
- num = (sdt->length - sizeof(struct acpi_table_header))/sizeof(u32);
|
|
+ num = (sdt->Length - sizeof(struct acpi_table_header))/sizeof(u32);
|
|
offset = (char *)sdt + sizeof(struct acpi_table_header);
|
|
for (i = 0; i < num; ++i, offset += sizeof(u32)) {
|
|
u32 tmp;
|
|
@@ -319,11 +323,11 @@ static int acpi_dump_RSDT(int fd, struct
|
|
if (!addr) continue;
|
|
tbl = acpi_map_table(addr, 0);
|
|
if (!tbl) continue;
|
|
- if (!memcmp(tbl->signature, FADT_SIG, 4)) {
|
|
+ if (!memcmp(tbl->Signature, ACPI_SIG_FADT, 4)) {
|
|
acpi_dump_FADT(fd, tbl, addr);
|
|
} else {
|
|
- if (checksum((u8 *)tbl, tbl->length))
|
|
- fprintf(stderr, "Wrong checksum for %.4s!\n", tbl->signature);
|
|
+ if (checksum((u8 *)tbl, tbl->Length))
|
|
+ fprintf(stderr, "Wrong checksum for %.4s!\n", tbl->Signature);
|
|
write_table(fd, tbl, addr);
|
|
}
|
|
acpi_unmap_table(tbl);
|
|
@@ -332,9 +336,9 @@ static int acpi_dump_RSDT(int fd, struct
|
|
memcpy(offset, &tmp, sizeof(tmp));
|
|
}
|
|
}
|
|
- addr = (unsigned long)rsdp->rsdt_physical_address;
|
|
+ addr = (unsigned long)rsdp->RsdtPhysicalAddress;
|
|
if (connect) {
|
|
- rsdp->rsdt_physical_address = lseek(fd, 0, SEEK_CUR);
|
|
+ rsdp->RsdtPhysicalAddress = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
write_table(fd, sdt, addr);
|
|
free (sdt);
|
|
@@ -342,23 +346,23 @@ static int acpi_dump_RSDT(int fd, struct
|
|
}
|
|
|
|
|
|
-static int acpi_dump_XSDT(int fd, struct acpi_rsdp_descriptor *rsdp)
|
|
+static int acpi_dump_XSDT(int fd, struct acpi_table_rsdp *rsdp)
|
|
{
|
|
struct acpi_table_header *sdt, *tbl = 0;
|
|
int i, num;
|
|
char *offset;
|
|
unsigned long addr;
|
|
- if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
|
|
- tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
|
|
+ if (rsdp->Revision > 1 && rsdp->XsdtPhysicalAddress) {
|
|
+ tbl = acpi_map_table(rsdp->XsdtPhysicalAddress, "XSDT");
|
|
}
|
|
if (!tbl) return 0;
|
|
|
|
- sdt = malloc(tbl->length);
|
|
- memcpy(sdt, tbl, tbl->length);
|
|
+ sdt = malloc(tbl->Length);
|
|
+ memcpy(sdt, tbl, tbl->Length);
|
|
acpi_unmap_table(tbl);
|
|
- if (checksum((u8 *)sdt, sdt->length))
|
|
+ if (checksum((u8 *)sdt, sdt->Length))
|
|
fprintf(stderr, "Wrong checksum for %s!\n", "XSDT");
|
|
- num = (sdt->length - sizeof(struct acpi_table_header))/sizeof(u64);
|
|
+ num = (sdt->Length - sizeof(struct acpi_table_header))/sizeof(u64);
|
|
offset = (char *)sdt + sizeof(struct acpi_table_header);
|
|
for (i = 0; i < num; ++i, offset += sizeof(u64)) {
|
|
u64 tmp;
|
|
@@ -367,11 +371,11 @@ static int acpi_dump_XSDT(int fd, struct
|
|
if (!addr) continue;
|
|
tbl = acpi_map_table(addr, 0);
|
|
if (!tbl) continue;
|
|
- if (!memcmp(tbl->signature, FADT_SIG, 4)) {
|
|
+ if (!memcmp(tbl->Signature, ACPI_SIG_FADT, 4)) {
|
|
acpi_dump_FADT(fd, tbl, addr);
|
|
} else {
|
|
- if (checksum((u8 *)tbl, tbl->length))
|
|
- fprintf(stderr, "Wrong checksum for %.4s\n", tbl->signature);
|
|
+ if (checksum((u8 *)tbl, tbl->Length))
|
|
+ fprintf(stderr, "Wrong checksum for %.4s\n", tbl->Signature);
|
|
write_table(fd, tbl, addr);
|
|
}
|
|
acpi_unmap_table(tbl);
|
|
@@ -380,9 +384,9 @@ static int acpi_dump_XSDT(int fd, struct
|
|
memcpy(offset, &tmp, sizeof(tmp));
|
|
}
|
|
}
|
|
- addr = (unsigned long)rsdp->xsdt_physical_address;
|
|
+ addr = (unsigned long)rsdp->XsdtPhysicalAddress;
|
|
if (connect) {
|
|
- rsdp->xsdt_physical_address = lseek(fd, 0, SEEK_CUR);
|
|
+ rsdp->XsdtPhysicalAddress = lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
write_table(fd, sdt, addr);
|
|
free (sdt);
|
|
@@ -419,7 +423,7 @@ int main(int argc, char **argv)
|
|
{
|
|
int option_index, c, fd;
|
|
u8 *raw;
|
|
- struct acpi_rsdp_descriptor rsdpx, *x = 0;
|
|
+ struct acpi_table_rsdp rsdpx, *x = 0;
|
|
char *filename = 0;
|
|
char buff[80];
|
|
memset(select_sig, 0, 4);
|
|
@@ -483,7 +487,7 @@ int main(int argc, char **argv)
|
|
return 0;
|
|
}
|
|
|
|
- length = sizeof(struct acpi_rsdp_descriptor);
|
|
+ length = sizeof(struct acpi_table_rsdp);
|
|
if (!addr) {
|
|
addr = read_efi_systab();
|
|
if (!addr) {
|
|
@@ -497,12 +501,12 @@ int main(int argc, char **argv)
|
|
goto not_found;
|
|
|
|
/* Find RSDP and print all found tables */
|
|
- memcpy(&rsdpx, x, sizeof(struct acpi_rsdp_descriptor));
|
|
+ memcpy(&rsdpx, x, sizeof(struct acpi_table_rsdp));
|
|
acpi_unmap_memory(raw, length);
|
|
if (connect) {
|
|
- lseek(fd, sizeof(struct acpi_rsdp_descriptor), SEEK_SET);
|
|
+ lseek(fd, sizeof(struct acpi_table_rsdp), SEEK_SET);
|
|
}
|
|
- if (rsdpx.revision > 1 && rsdpx.xsdt_physical_address) {
|
|
+ if (rsdpx.Revision > 1 && rsdpx.XsdtPhysicalAddress) {
|
|
/* ACPIDUMP uses xsdt table */
|
|
if (!acpi_dump_XSDT(fd, &rsdpx))
|
|
goto not_found;
|
|
@@ -511,13 +515,13 @@ int main(int argc, char **argv)
|
|
goto not_found;
|
|
if (connect) {
|
|
lseek(fd, 0, SEEK_SET);
|
|
- write(fd, x, (rsdpx.revision < 2) ?
|
|
+ write(fd, x, (rsdpx.Revision < 2) ?
|
|
ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
|
|
} else if (!select_sig[0] || !memcmp("RSD PTR ", select_sig, 4)) {
|
|
addr += (long)x - (long)raw;
|
|
length = snprintf(buff, 80, "RSD PTR @ %p\n", (void *)addr);
|
|
write(fd, buff, length);
|
|
- acpi_show_data(fd, (u8 *) & rsdpx, (rsdpx.revision < 2) ?
|
|
+ acpi_show_data(fd, (u8 *) & rsdpx, (rsdpx.Revision < 2) ?
|
|
ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
|
|
buff[0] = '\n';
|
|
write(fd, buff, 1);
|