diff options
Diffstat (limited to 'source/tools/acpidump')
| -rw-r--r-- | source/tools/acpidump/acpidump.h | 18 | ||||
| -rw-r--r-- | source/tools/acpidump/apdump.c | 145 | ||||
| -rw-r--r-- | source/tools/acpidump/apfiles.c | 40 | ||||
| -rw-r--r-- | source/tools/acpidump/apmain.c | 23 |
4 files changed, 178 insertions, 48 deletions
diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index 44fd7d3a9fbb..203108fc3f6f 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -67,9 +67,10 @@ EXTERN BOOLEAN INIT_GLOBAL (Gbl_SummaryMode, FALSE); EXTERN BOOLEAN INIT_GLOBAL (Gbl_VerboseMode, FALSE); EXTERN BOOLEAN INIT_GLOBAL (Gbl_BinaryMode, FALSE); -EXTERN UINT32 INIT_GLOBAL (Gbl_SsdtCount, 0); +EXTERN BOOLEAN INIT_GLOBAL (Gbl_DumpCustomizedTables, FALSE); EXTERN FILE INIT_GLOBAL (*Gbl_OutputFile, NULL); EXTERN char INIT_GLOBAL (*Gbl_OutputFilename, NULL); +EXTERN UINT64 INIT_GLOBAL (Gbl_RsdpBase, 0); /* Globals required for use with ACPICA modules */ @@ -89,6 +90,10 @@ typedef struct ap_dump_action } AP_DUMP_ACTION; +/* Local RSDP signature (Not the same as the actual signature which is "RSD PTR ") */ + +#define AP_DUMP_SIG_RSDP "RSDP" + #define AP_MAX_ACTIONS 32 #define AP_DUMP_ALL_TABLES 0 @@ -129,6 +134,14 @@ BOOLEAN ApIsValidHeader ( ACPI_TABLE_HEADER *Table); +BOOLEAN +ApIsValidChecksum ( + ACPI_TABLE_HEADER *Table); + +UINT32 +ApGetTableLength ( + ACPI_TABLE_HEADER *Table); + /* * apfiles - File I/O utilities @@ -143,7 +156,8 @@ ApOpenOutputFile ( int ApWriteToBinaryFile ( - ACPI_TABLE_HEADER *Table); + ACPI_TABLE_HEADER *Table, + UINT32 Instance); ACPI_TABLE_HEADER * ApGetTableFromFile ( diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index 5000e4db7f87..6317b25d223e 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -49,6 +49,7 @@ static int ApDumpTableBuffer ( ACPI_TABLE_HEADER *Table, + UINT32 Instance, ACPI_PHYSICAL_ADDRESS Address); @@ -68,26 +69,111 @@ BOOLEAN ApIsValidHeader ( ACPI_TABLE_HEADER *Table) { + if (!ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + /* Make sure signature is all ASCII and a valid ACPI name */ + + if (!AcpiUtValidAcpiName (Table->Signature)) + { + fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", + *(UINT32 *) Table->Signature); + return (FALSE); + } + + /* Check for minimum table length */ + + if (Table->Length <= sizeof (ACPI_TABLE_HEADER)) + { + fprintf (stderr, "Table length (0x%8.8X) is invalid\n", + Table->Length); + return (FALSE); + } + } - /* Make sure signature is all ASCII and a valid ACPI name */ + return (TRUE); +} + + +/****************************************************************************** + * + * FUNCTION: ApIsValidChecksum + * + * PARAMETERS: Table - Pointer to table to be validated + * + * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI table checksum + * + ******************************************************************************/ + +BOOLEAN +ApIsValidChecksum ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_TABLE_RSDP *Rsdp; + + + if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + /* + * Checksum for RSDP. + * Note: Other checksums are computed during the table dump. + */ + + Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); + Status = AcpiTbValidateRsdp (Rsdp); + } + else + { + Status = AcpiTbVerifyChecksum (Table, Table->Length); + } - if (!AcpiUtValidAcpiName (Table->Signature)) + if (ACPI_FAILURE (Status)) { - fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", - *(UINT32 *) Table->Signature); - return (FALSE); + fprintf (stderr, "%4.4s: Warning: wrong checksum\n", + Table->Signature); } - /* Check for minimum table length */ + return (AE_OK); +} + - if (Table->Length <= sizeof (ACPI_TABLE_HEADER)) +/****************************************************************************** + * + * FUNCTION: ApGetTableLength + * + * PARAMETERS: Table - Pointer to the table + * + * RETURN: Table length + * + * DESCRIPTION: Obtain table length according to table signature + * + ******************************************************************************/ + +UINT32 +ApGetTableLength ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_TABLE_RSDP *Rsdp; + + + /* Check if table is valid */ + + if (!ApIsValidHeader (Table)) { - fprintf (stderr, "Table length (0x%8.8X) is invalid\n", - Table->Length); - return (FALSE); + return (0); } - return (TRUE); + if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); + return (Rsdp->Length); + } + else + { + return (Table->Length); + } } @@ -96,6 +182,7 @@ ApIsValidHeader ( * FUNCTION: ApDumpTableBuffer * * PARAMETERS: Table - ACPI table to be dumped + * Instance - ACPI table instance no. to be dumped * Address - Physical address of the table * * RETURN: None @@ -108,22 +195,13 @@ ApIsValidHeader ( static int ApDumpTableBuffer ( ACPI_TABLE_HEADER *Table, + UINT32 Instance, ACPI_PHYSICAL_ADDRESS Address) { + UINT32 TableLength; - /* Check if the table header appears to be valid */ - - if (!ApIsValidHeader (Table)) - { - return (-1); - } - - /* Validate the table checksum (except FACS - has no checksum) */ - if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) - { - (void) AcpiTbVerifyChecksum (Table, Table->Length); - } + TableLength = ApGetTableLength (Table); /* Print only the header if requested */ @@ -137,7 +215,7 @@ ApDumpTableBuffer ( if (Gbl_BinaryMode) { - return (ApWriteToBinaryFile (Table)); + return (ApWriteToBinaryFile (Table, Instance)); } /* @@ -148,7 +226,7 @@ ApDumpTableBuffer ( printf ("%4.4s @ 0x%8.8X%8.8X\n", Table->Signature, ACPI_FORMAT_UINT64 (Address)); - AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), Table->Length, + AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), TableLength, DB_BYTE_DISPLAY, 0); printf ("\n"); return (0); @@ -173,6 +251,7 @@ ApDumpAllTables ( void) { ACPI_TABLE_HEADER *Table; + UINT32 Instance = 0; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; UINT32 i; @@ -182,7 +261,7 @@ ApDumpAllTables ( for (i = 0; i < AP_MAX_ACPI_FILES; i++) { - Status = AcpiOsGetTableByIndex (i, &Table, &Address); + Status = AcpiOsGetTableByIndex (i, &Table, &Instance, &Address); if (ACPI_FAILURE (Status)) { /* AE_LIMIT means that no more tables are available */ @@ -205,7 +284,7 @@ ApDumpAllTables ( } } - if (ApDumpTableBuffer (Table, Address)) + if (ApDumpTableBuffer (Table, Instance, Address)) { return (-1); } @@ -261,7 +340,7 @@ ApDumpTableByAddress ( return (-1); } - TableStatus = ApDumpTableBuffer (Table, Address); + TableStatus = ApDumpTableBuffer (Table, 0, Address); free (Table); return (TableStatus); } @@ -306,7 +385,11 @@ ApDumpTableByName ( /* To be friendly, handle tables whose signatures do not match the name */ - if (ACPI_COMPARE_NAME (LocalSignature, "FADT")) + if (ACPI_COMPARE_NAME (LocalSignature, AP_DUMP_SIG_RSDP)) + { + strcpy (LocalSignature, AP_DUMP_SIG_RSDP); + } + else if (ACPI_COMPARE_NAME (LocalSignature, "FADT")) { strcpy (LocalSignature, ACPI_SIG_FADT); } @@ -336,7 +419,7 @@ ApDumpTableByName ( return (-1); } - if (ApDumpTableBuffer (Table, Address)) + if (ApDumpTableBuffer (Table, Instance, Address)) { return (-1); } @@ -395,7 +478,7 @@ ApDumpTableFromFile ( Pathname, Table->Signature, FileSize, FileSize); } - TableStatus = ApDumpTableBuffer (Table, 0); + TableStatus = ApDumpTableBuffer (Table, 0, 0); free (Table); return (TableStatus); } diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index fd17423d665b..5c4b0dce4dc5 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -100,6 +100,7 @@ ApOpenOutputFile ( * FUNCTION: ApWriteToBinaryFile * * PARAMETERS: Table - ACPI table to be written + * Instance - ACPI table instance no. to be written * * RETURN: Status * @@ -110,29 +111,42 @@ ApOpenOutputFile ( int ApWriteToBinaryFile ( - ACPI_TABLE_HEADER *Table) + ACPI_TABLE_HEADER *Table, + UINT32 Instance) { char Filename[ACPI_NAME_SIZE + 16]; - char SsdtInstance [16]; + char InstanceStr [16]; FILE *File; size_t Actual; + UINT32 TableLength; - /* Construct lower-case filename from the table signature */ + /* Obtain table length */ - Filename[0] = (char) ACPI_TOLOWER (Table->Signature[0]); - Filename[1] = (char) ACPI_TOLOWER (Table->Signature[1]); - Filename[2] = (char) ACPI_TOLOWER (Table->Signature[2]); - Filename[3] = (char) ACPI_TOLOWER (Table->Signature[3]); + TableLength = ApGetTableLength (Table); + + /* Construct lower-case filename from the table local signature */ + + if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + ACPI_MOVE_NAME (Filename, AP_DUMP_SIG_RSDP); + } + else + { + ACPI_MOVE_NAME (Filename, Table->Signature); + } + Filename[0] = (char) ACPI_TOLOWER (Filename[0]); + Filename[1] = (char) ACPI_TOLOWER (Filename[1]); + Filename[2] = (char) ACPI_TOLOWER (Filename[2]); + Filename[3] = (char) ACPI_TOLOWER (Filename[3]); Filename[ACPI_NAME_SIZE] = 0; /* Handle multiple SSDTs - create different filenames for each */ - if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + if (Instance > 0) { - sprintf (SsdtInstance, "%u", Gbl_SsdtCount); - strcat (Filename, SsdtInstance); - Gbl_SsdtCount++; + sprintf (InstanceStr, "%u", Instance); + strcat (Filename, InstanceStr); } strcat (Filename, ACPI_TABLE_FILE_SUFFIX); @@ -153,8 +167,8 @@ ApWriteToBinaryFile ( return (-1); } - Actual = fwrite (Table, 1, Table->Length, File); - if (Actual != Table->Length) + Actual = fwrite (Table, 1, TableLength, File); + if (Actual != TableLength) { perror ("Error writing binary output file"); fclose (File); diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 4c90cb7dcc85..b9e62eb17e8f 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -92,7 +92,7 @@ UINT32 CurrentAction = 0; #define AP_UTILITY_NAME "ACPI Binary Table Dump Utility" -#define AP_SUPPORTED_OPTIONS "?a:bf:hn:o:svz" +#define AP_SUPPORTED_OPTIONS "?a:bcf:hn:o:r:svz" /****************************************************************************** @@ -111,10 +111,12 @@ ApDisplayUsage ( ACPI_USAGE_HEADER ("acpidump [options]"); ACPI_OPTION ("-b", "Dump tables to binary files"); + ACPI_OPTION ("-c", "Dump customized tables"); ACPI_OPTION ("-h -?", "This help message"); ACPI_OPTION ("-o <File>", "Redirect output to file"); + ACPI_OPTION ("-r <Address>", "Dump tables from specified RSDP"); ACPI_OPTION ("-s", "Print table summaries only"); - ACPI_OPTION ("-v", "Version of this utility"); + ACPI_OPTION ("-v", "Display version information"); ACPI_OPTION ("-z", "Verbose mode"); printf ("\nTable Options:\n"); @@ -182,6 +184,7 @@ ApDoOptions ( char **argv) { int j; + ACPI_STATUS Status; /* Command line options */ @@ -196,6 +199,11 @@ ApDoOptions ( Gbl_BinaryMode = TRUE; continue; + case 'c': /* Dump customized tables */ + + Gbl_DumpCustomizedTables = TRUE; + continue; + case 'h': case '?': @@ -210,6 +218,17 @@ ApDoOptions ( } continue; + case 'r': /* Dump tables from specified RSDP */ + + Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, 0, &Gbl_RsdpBase); + if (ACPI_FAILURE (Status)) + { + fprintf (stderr, "%s: Could not convert to a physical address\n", + AcpiGbl_Optarg); + exit (-1); + } + continue; + case 's': /* Print table summaries only */ Gbl_SummaryMode = TRUE; |
