diff options
Diffstat (limited to 'source/tools/acpidump/apfiles.c')
-rw-r--r-- | source/tools/acpidump/apfiles.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index fd17423..5c4b0dc 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); |