diff options
Diffstat (limited to 'source/tools/acpidump')
-rw-r--r-- | source/tools/acpidump/acpidump.h | 4 | ||||
-rw-r--r-- | source/tools/acpidump/apdump.c | 44 | ||||
-rw-r--r-- | source/tools/acpidump/apfiles.c | 42 | ||||
-rw-r--r-- | source/tools/acpidump/apmain.c | 2 |
4 files changed, 29 insertions, 63 deletions
diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index e3b705bdce50d..4b0f01c11f486 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -142,10 +142,6 @@ ApGetTableLength ( /* * apfiles - File I/O utilities */ -UINT32 -ApGetFileSize ( - FILE *File); - int ApOpenOutputFile ( char *Pathname); diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index d11919b7db619..0bd0294988b4c 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -69,6 +69,7 @@ BOOLEAN ApIsValidHeader ( ACPI_TABLE_HEADER *Table) { + if (!ACPI_VALIDATE_RSDP_SIG (Table->Signature)) { /* Make sure signature is all ASCII and a valid ACPI name */ @@ -100,9 +101,9 @@ ApIsValidHeader ( * * PARAMETERS: Table - Pointer to table to be validated * - * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise + * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise. * - * DESCRIPTION: Check for a valid ACPI table checksum + * DESCRIPTION: Check for a valid ACPI table checksum. * ******************************************************************************/ @@ -120,7 +121,6 @@ ApIsValidChecksum ( * Checksum for RSDP. * Note: Other checksums are computed during the table dump. */ - Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); Status = AcpiTbValidateRsdp (Rsdp); } @@ -131,7 +131,7 @@ ApIsValidChecksum ( if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%4.4s: Warning: wrong checksum\n", + fprintf (stderr, "%4.4s: Warning: wrong checksum in table\n", Table->Signature); } @@ -147,7 +147,7 @@ ApIsValidChecksum ( * * RETURN: Table length * - * DESCRIPTION: Obtain table length according to table signature + * DESCRIPTION: Obtain table length according to table signature. * ******************************************************************************/ @@ -170,10 +170,10 @@ ApGetTableLength ( Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); return (Rsdp->Length); } - else - { - return (Table->Length); - } + + /* Normal ACPI table */ + + return (Table->Length); } @@ -219,7 +219,7 @@ ApDumpTableBuffer ( } /* - * Dump the table with header for use with acpixtract utility + * Dump the table with header for use with acpixtract utility. * Note: simplest to just always emit a 64-bit address. AcpiXtract * utility can handle this. */ @@ -254,6 +254,7 @@ ApDumpAllTables ( UINT32 Instance = 0; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; + int TableStatus; UINT32 i; @@ -284,11 +285,13 @@ ApDumpAllTables ( } } - if (ApDumpTableBuffer (Table, Instance, Address)) + TableStatus = ApDumpTableBuffer (Table, Instance, Address); + free (Table); + + if (TableStatus) { - return (-1); + break; } - free (Table); } /* Something seriously bad happened if the loop terminates here */ @@ -368,6 +371,7 @@ ApDumpTableByName ( ACPI_TABLE_HEADER *Table; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; + int TableStatus; if (strlen (Signature) != ACPI_NAME_SIZE) @@ -415,11 +419,13 @@ ApDumpTableByName ( return (-1); } - if (ApDumpTableBuffer (Table, Instance, Address)) + TableStatus = ApDumpTableBuffer (Table, Instance, Address); + free (Table); + + if (TableStatus) { - return (-1); + break; } - free (Table); } /* Something seriously bad happened if the loop terminates here */ @@ -446,7 +452,7 @@ ApDumpTableFromFile ( { ACPI_TABLE_HEADER *Table; UINT32 FileSize = 0; - int TableStatus; + int TableStatus = -1; /* Get the entire ACPI table from the file */ @@ -464,7 +470,7 @@ ApDumpTableFromFile ( fprintf (stderr, "Table length (0x%X) is too large for input file (0x%X) %s\n", Table->Length, FileSize, Pathname); - return (-1); + goto Exit; } if (Gbl_VerboseMode) @@ -475,6 +481,8 @@ ApDumpTableFromFile ( } TableStatus = ApDumpTableBuffer (Table, 0, 0); + +Exit: free (Table); return (TableStatus); } diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index e719f54f17f48..1588f2ef74cab 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -215,8 +215,8 @@ ApGetTableFromFile ( /* Need file size to allocate a buffer */ - FileSize = ApGetFileSize (File); - if (!FileSize) + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) { fprintf (stderr, "Could not get input file size: %s\n", Pathname); @@ -251,41 +251,3 @@ Cleanup: fclose (File); return (Buffer); } - - -/****************************************************************************** - * - * FUNCTION: ApGetFileSize - * - * PARAMETERS: File - Open file descriptor - * - * RETURN: File size in bytes - * - * DESCRIPTION: Get the size of an open file - * - ******************************************************************************/ - -UINT32 -ApGetFileSize ( - FILE *File) -{ - UINT32 FileSize; - long Offset; - - - Offset = ftell (File); - if (fseek (File, 0, SEEK_END)) - { - return (0); - } - - /* Get size and restore file pointer */ - - FileSize = (UINT32) ftell (File); - if (fseek (File, Offset, SEEK_SET)) - { - return (0); - } - - return (FileSize); -} diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 38c6d925666a7..a16f5830dd91a 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -358,7 +358,7 @@ main ( { /* Summary for the output file */ - FileSize = ApGetFileSize (Gbl_OutputFile); + FileSize = CmGetFileSize (Gbl_OutputFile); fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } |