summaryrefslogtreecommitdiff
path: root/source/tools
diff options
context:
space:
mode:
Diffstat (limited to 'source/tools')
-rw-r--r--source/tools/acpibin/abcompare.c361
-rw-r--r--source/tools/acpibin/abmain.c15
-rw-r--r--source/tools/acpibin/acpibin.h6
-rw-r--r--source/tools/acpidump/acpidump.h4
-rw-r--r--source/tools/acpidump/apdump.c44
-rw-r--r--source/tools/acpidump/apfiles.c42
-rw-r--r--source/tools/acpidump/apmain.c2
-rw-r--r--source/tools/acpiexec/aecommon.h5
-rw-r--r--source/tools/acpiexec/aehandlers.c6
-rw-r--r--source/tools/acpihelp/acpihelp.h14
-rw-r--r--source/tools/acpihelp/ahamlops.c2
-rw-r--r--source/tools/acpihelp/ahdecode.c140
-rw-r--r--source/tools/acpihelp/ahmain.c41
-rw-r--r--source/tools/acpisrc/asfile.c10
-rw-r--r--source/tools/acpisrc/astable.c9
15 files changed, 255 insertions, 446 deletions
diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c
index 6bf5f9638cd8..d843400ffb95 100644
--- a/source/tools/acpibin/abcompare.c
+++ b/source/tools/acpibin/abcompare.c
@@ -42,10 +42,9 @@
*/
#include "acpibin.h"
+#include "acapps.h"
-FILE *File1;
-FILE *File2;
ACPI_TABLE_HEADER Header1;
ACPI_TABLE_HEADER Header2;
@@ -69,10 +68,6 @@ AbGetFile (
char *Filename,
UINT32 *FileSize);
-static UINT32
-AbGetFileSize (
- FILE *File);
-
static void
AbPrintHeaderInfo (
ACPI_TABLE_HEADER *Header);
@@ -87,68 +82,6 @@ AeLocalGetRootPointer (
void);
-/*******************************************************************************
- *
- * FUNCTION: UtHexCharToValue
- *
- * PARAMETERS: HexChar - Hex character in Ascii
- *
- * RETURN: The binary value of the hex character
- *
- * DESCRIPTION: Perform ascii-to-hex translation
- *
- ******************************************************************************/
-
-static UINT8
-UtHexCharToValue (
- int HexChar,
- UINT8 *OutBinary)
-{
-
- if (HexChar >= 0x30 && HexChar <= 0x39)
- {
- *OutBinary = (UINT8) (HexChar - 0x30);
- return (1);
- }
-
- else if (HexChar >= 0x41 && HexChar <= 0x46)
- {
- *OutBinary = (UINT8) (HexChar - 0x37);
- return (1);
- }
-
- else if (HexChar >= 0x61 && HexChar <= 0x66)
- {
- *OutBinary = (UINT8) (HexChar - 0x57);
- return (1);
- }
- return (0);
-}
-
-static UINT8
-AbHexByteToBinary (
- char *HexString,
- char *OutBinary)
-{
- UINT8 Local1;
- UINT8 Local2;
-
-
- if (!UtHexCharToValue (HexString[0], &Local1))
- {
- return (0);
- }
- if (!UtHexCharToValue (HexString[1], &Local2))
- {
- return (0);
- }
-
- *OutBinary = (UINT8) ((Local1 << 4) | Local2);
- return (2);
-
-}
-
-
/******************************************************************************
*
* FUNCTION: AbValidateHeader
@@ -190,23 +123,24 @@ AcpiTbSumTable (
void *Buffer,
UINT32 Length)
{
- const UINT8 *limit;
- const UINT8 *rover;
- UINT8 sum = 0;
+ const UINT8 *Limit;
+ const UINT8 *Rover;
+ UINT8 Sum = 0;
if (Buffer && Length)
{
/* Buffer and Length are valid */
- limit = (UINT8 *) Buffer + Length;
+ Limit = (UINT8 *) Buffer + Length;
- for (rover = Buffer; rover < limit; rover++)
+ for (Rover = Buffer; Rover < Limit; Rover++)
{
- sum = (UINT8) (sum + *rover);
+ Sum = (UINT8) (Sum + *Rover);
}
}
- return (sum);
+
+ return (Sum);
}
@@ -233,10 +167,10 @@ AbPrintHeaderInfo (
printf ("Length : %8.8X\n", Header->Length);
printf ("Revision : %2.2X\n", Header->Revision);
printf ("Checksum : %2.2X\n", Header->Checksum);
- printf ("OEM ID : %6.6s\n", Header->OemId);
- printf ("OEM Table ID : %8.8s\n", Header->OemTableId);
+ printf ("OEM ID : %.6s\n", Header->OemId);
+ printf ("OEM Table ID : %.8s\n", Header->OemTableId);
printf ("OEM Revision : %8.8X\n", Header->OemRevision);
- printf ("ASL Compiler ID : %4.4s\n", Header->AslCompilerId);
+ printf ("ASL Compiler ID : %.4s\n", Header->AslCompilerId);
printf ("Compiler Revision : %8.8X\n", Header->AslCompilerRevision);
printf ("\n");
}
@@ -253,10 +187,10 @@ AbPrintHeadersInfo (
printf ("Length %8.8X : %8.8X\n", Header->Length, Header2->Length);
printf ("Revision %8.2X : %2.2X\n", Header->Revision, Header2->Revision);
printf ("Checksum %8.2X : %2.2X\n", Header->Checksum, Header2->Checksum);
- printf ("OEM ID %8.6s : %6.6s\n", Header->OemId, Header2->OemId);
- printf ("OEM Table ID %8.8s : %8.8s\n", Header->OemTableId, Header2->OemTableId);
+ printf ("OEM ID %8.6s : %.6s\n", Header->OemId, Header2->OemId);
+ printf ("OEM Table ID %8.8s : %.8s\n", Header->OemTableId, Header2->OemTableId);
printf ("OEM Revision %8.8X : %8.8X\n", Header->OemRevision, Header2->OemRevision);
- printf ("ASL Compiler ID %8.4s : %4.4s\n", Header->AslCompilerId, Header2->AslCompilerId);
+ printf ("ASL Compiler ID %8.4s : %.4s\n", Header->AslCompilerId, Header2->AslCompilerId);
printf ("Compiler Revision %8.8X : %8.8X\n", Header->AslCompilerRevision, Header2->AslCompilerRevision);
printf ("\n");
}
@@ -272,22 +206,25 @@ AbPrintHeadersInfo (
void
AbDisplayHeader (
- char *File1Path)
+ char *FilePath)
{
UINT32 Actual;
+ FILE *File;
- File1 = fopen (File1Path, "rb");
- if (!File1)
+ File = fopen (FilePath, "rb");
+ if (!File)
{
- printf ("Could not open file %s\n", File1Path);
+ printf ("Could not open file %s\n", FilePath);
return;
}
- Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
+ Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File);
+ fclose (File);
+
if (Actual != sizeof (ACPI_TABLE_HEADER))
{
- printf ("File %s does not contain an ACPI table header\n", File1Path);
+ printf ("File %s does not contain a valid ACPI table header\n", FilePath);
return;
}
@@ -310,30 +247,31 @@ AbDisplayHeader (
void
AbComputeChecksum (
- char *File1Path)
+ char *FilePath)
{
UINT32 Actual;
ACPI_TABLE_HEADER *Table;
UINT8 Checksum;
+ FILE *File;
- File1 = fopen (File1Path, "rb");
- if (!File1)
+ File = fopen (FilePath, "rb");
+ if (!File)
{
- printf ("Could not open file %s\n", File1Path);
+ printf ("Could not open file %s\n", FilePath);
return;
}
- Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
+ Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File);
if (Actual < sizeof (ACPI_TABLE_HEADER))
{
- printf ("File %s does not contain an ACPI table header\n", File1Path);
- return;
+ printf ("File %s does not contain a valid ACPI table header\n", FilePath);
+ goto Exit1;
}
if (!AbValidateHeader (&Header1))
{
- return;
+ goto Exit1;
}
if (!Gbl_TerseMode)
@@ -346,18 +284,18 @@ AbComputeChecksum (
Table = AcpiOsAllocate (Header1.Length);
if (!Table)
{
- printf ("could not allocate\n");
- return;
+ printf ("Could not allocate buffer for table\n");
+ goto Exit1;
}
/* Read the entire table, including header */
- fseek (File1, 0, SEEK_SET);
- Actual = fread (Table, 1, Header1.Length, File1);
+ fseek (File, 0, SEEK_SET);
+ Actual = fread (Table, 1, Header1.Length, File);
if (Actual != Header1.Length)
{
- printf ("could not read table, length %u\n", Header1.Length);
- return;
+ printf ("Could not read table, length %u\n", Header1.Length);
+ goto Exit2;
}
/* Compute the checksum for the table */
@@ -369,32 +307,41 @@ AbComputeChecksum (
if (Header1.Checksum == Checksum)
{
- printf ("Checksum ok in AML file, not updating\n");
- return;
+ printf ("Checksum OK in AML file, not updating\n");
+ goto Exit2;
}
/* Open the target file for writing, to update checksum */
- fclose (File1);
- File1 = fopen (File1Path, "r+b");
- if (!File1)
+ fclose (File);
+ File = fopen (FilePath, "r+b");
+ if (!File)
{
- printf ("Could not open file %s for writing\n", File1Path);
- return;
+ printf ("Could not open file %s for writing\n", FilePath);
+ goto Exit2;
}
/* Set the checksum, write the new header */
Header1.Checksum = Checksum;
- Actual = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
+ Actual = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File);
if (Actual != sizeof (ACPI_TABLE_HEADER))
{
printf ("Could not write updated table header\n");
- return;
+ goto Exit2;
}
printf ("Wrote new checksum\n");
+
+Exit2:
+ AcpiOsFree (Table);
+
+Exit1:
+ if (File)
+ {
+ fclose (File);
+ }
return;
}
@@ -419,6 +366,9 @@ AbCompareAmlFiles (
UINT8 Char2;
UINT8 Mismatches = 0;
BOOLEAN HeaderMismatch = FALSE;
+ FILE *File1;
+ FILE *File2;
+ int Status = -1;
File1 = fopen (File1Path, "rb");
@@ -432,7 +382,7 @@ AbCompareAmlFiles (
if (!File2)
{
printf ("Could not open file %s\n", File2Path);
- return (-1);
+ goto Exit1;
}
/* Read the ACPI header from each file */
@@ -441,20 +391,20 @@ AbCompareAmlFiles (
if (Actual1 != sizeof (ACPI_TABLE_HEADER))
{
printf ("File %s does not contain an ACPI table header\n", File1Path);
- return (-1);
+ goto Exit2;
}
Actual2 = fread (&Header2, 1, sizeof (ACPI_TABLE_HEADER), File2);
if (Actual2 != sizeof (ACPI_TABLE_HEADER))
{
printf ("File %s does not contain an ACPI table header\n", File2Path);
- return (-1);
+ goto Exit2;
}
if ((!AbValidateHeader (&Header1)) ||
(!AbValidateHeader (&Header2)))
{
- return (-1);
+ goto Exit2;
}
/* Table signatures must match */
@@ -462,7 +412,7 @@ AbCompareAmlFiles (
if (*((UINT32 *) Header1.Signature) != *((UINT32 *) Header2.Signature))
{
printf ("Table signatures do not match\n");
- return (-1);
+ goto Exit2;
}
if (!Gbl_TerseMode)
@@ -494,7 +444,7 @@ AbCompareAmlFiles (
if (Mismatches > 100)
{
printf ("100 Mismatches: Too many mismatches\n");
- return (-1);
+ goto Exit2;
}
}
@@ -526,43 +476,14 @@ AbCompareAmlFiles (
}
printf ("%u Mismatches found\n", Mismatches);
- return (0);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AbGetFileSize
- *
- * DESCRIPTION: Get the size of an open file
- *
- ******************************************************************************/
+ Status = 0;
-static UINT32
-AbGetFileSize (
- FILE *File)
-{
- UINT32 FileSize;
- long Offset;
-
-
- Offset = ftell (File);
+Exit2:
+ fclose (File2);
- if (fseek (File, 0, SEEK_END))
- {
- return (0);
- }
-
- FileSize = (UINT32) ftell (File);
-
- /* Restore file pointer */
-
- if (fseek (File, Offset, SEEK_SET))
- {
- return (0);
- }
-
- return (FileSize);
+Exit1:
+ fclose (File1);
+ return (Status);
}
@@ -596,8 +517,8 @@ AbGetFile (
/* Need file size to allocate a buffer */
- Size = AbGetFileSize (File);
- if (!Size)
+ Size = CmGetFileSize (File);
+ if (Size == ACPI_UINT32_MAX)
{
printf ("Could not get file size (seek) for %s\n", Filename);
goto ErrorExit;
@@ -647,6 +568,7 @@ AbDumpAmlFile (
char *FileBuffer;
FILE *FileOutHandle;
UINT32 FileSize = 0;
+ int Status = -1;
/* Get the entire AML file, validate header */
@@ -664,12 +586,12 @@ AbDumpAmlFile (
if (!FileOutHandle)
{
printf ("Could not open file %s\n", File2Path);
- return (-1);
+ goto Exit1;
}
if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer))
{
- return (-1);
+ goto Exit2;
}
/* Convert binary AML to text, using common dump buffer routine */
@@ -684,133 +606,18 @@ AbDumpAmlFile (
/* Summary for the output file */
- FileSize = AbGetFileSize (FileOutHandle);
+ FileSize = CmGetFileSize (FileOutHandle);
printf ("Output file: %s contains %u (0x%X) bytes\n\n",
File2Path, FileSize, FileSize);
- return (0);
-}
-
+ Status = 0;
-/******************************************************************************
- *
- * FUNCTION: AbExtractAmlFile
- *
- * DESCRIPTION: Extract a binary AML file from a text file (as produced by the
- * DumpAmlFile procedure or the "acpidump" table utility.
- *
- ******************************************************************************/
-
-int
-AbExtractAmlFile (
- char *TableSig,
- char *File1Path,
- char *File2Path)
-{
- char *Table;
- char Value;
- UINT32 i;
- FILE *FileHandle;
- FILE *FileOutHandle;
- UINT32 Count = 0;
- int Scanned;
-
-
- /* Open in/out files. input is in text mode, output is in binary mode */
-
- FileHandle = fopen (File1Path, "rt");
- if (!FileHandle)
- {
- printf ("Could not open file %s\n", File1Path);
- return (-1);
- }
-
- FileOutHandle = fopen (File2Path, "w+b");
- if (!FileOutHandle)
- {
- printf ("Could not open file %s\n", File2Path);
- return (-1);
- }
-
- /* Force input table sig to uppercase */
-
- AcpiUtStrupr (TableSig);
-
-
- /* TBD: examine input for ASCII */
-
-
- /* We have an ascii file, grab one line at a time */
-
- while (fgets (Buffer, BUFFER_SIZE, FileHandle))
- {
- /* The 4-char ACPI signature appears at the beginning of a line */
-
- if (ACPI_COMPARE_NAME (Buffer, TableSig))
- {
- printf ("Found table [%4.4s]\n", TableSig);
-
- /*
- * Eat all lines in the table, of the form:
- * <offset>: <16 bytes of hex data, separated by spaces> <ASCII representation> <newline>
- *
- * Example:
- *
- * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........
- *
- */
- while (fgets (Buffer, BUFFER_SIZE, FileHandle))
- {
- /* Get past the offset, terminated by a colon */
-
- Table = strchr (Buffer, ':');
- if (!Table)
- {
- /* No colon, all done */
- goto Exit;
- }
-
- Table += 2; /* Eat the colon + space */
-
- for (i = 0; i < 16; i++)
- {
- Scanned = AbHexByteToBinary (Table, &Value);
- if (!Scanned)
- {
- goto Exit;
- }
-
- Table += 3; /* Go past this hex byte and space */
-
- /* Write the converted (binary) byte */
-
- if (fwrite (&Value, 1, 1, FileOutHandle) != 1)
- {
- printf ("Error writing byte %u to output file: %s\n",
- Count, File2Path);
- goto Exit;
- }
- Count++;
- }
- }
-
- /* No more lines, EOF, all done */
-
- goto Exit;
- }
- }
-
- /* Searched entire file, no match to table signature */
-
- printf ("Could not match table signature\n");
- fclose (FileHandle);
- return (-1);
-
-Exit:
- printf ("%u (0x%X) bytes written to %s\n", Count, Count, File2Path);
- fclose (FileHandle);
+Exit2:
fclose (FileOutHandle);
- return (0);
+
+Exit1:
+ free (FileBuffer);
+ return (Status);
}
diff --git a/source/tools/acpibin/abmain.c b/source/tools/acpibin/abmain.c
index 6eb6eb195d2d..d8c740cd75e2 100644
--- a/source/tools/acpibin/abmain.c
+++ b/source/tools/acpibin/abmain.c
@@ -54,7 +54,7 @@ AbDisplayUsage (
#define AB_UTILITY_NAME "ACPI Binary Table Dump Utility"
-#define AB_SUPPORTED_OPTIONS "c:d:e:h:s:tv"
+#define AB_SUPPORTED_OPTIONS "c:d:h:s:tv"
/******************************************************************************
@@ -79,7 +79,6 @@ AbDisplayUsage (
ACPI_OPTION ("-c <File1><File2>", "Compare two binary AML files");
ACPI_OPTION ("-d <In><Out>", "Dump AML binary to text file");
- ACPI_OPTION ("-e <Sig><In><Out>", "Extract binary AML table from AcpiDump file");
ACPI_OPTION ("-h <File>", "Display table header for binary AML file");
ACPI_OPTION ("-s <File>", "Update checksum for binary AML file");
ACPI_OPTION ("-t", "Terse mode");
@@ -144,18 +143,6 @@ main (
Status = AbDumpAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind]);
break;
- case 'e': /* Extract AML text file */
-
- if (argc < 5)
- {
- AbDisplayUsage (3);
- return (-1);
- }
-
- Status = AbExtractAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind],
- argv[AcpiGbl_Optind+1]);
- break;
-
case 'h': /* Display ACPI table header */
if (argc < 3)
diff --git a/source/tools/acpibin/acpibin.h b/source/tools/acpibin/acpibin.h
index 515f155fea91..7f93d43e72b2 100644
--- a/source/tools/acpibin/acpibin.h
+++ b/source/tools/acpibin/acpibin.h
@@ -76,12 +76,6 @@ AbCompareAmlFiles (
char *File2Path);
int
-AbExtractAmlFile (
- char *TableSig,
- char *File1Path,
- char *File2Path);
-
-int
AbDumpAmlFile (
char *File1Path,
char *File2Path);
diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h
index e3b705bdce50..4b0f01c11f48 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 d11919b7db61..0bd0294988b4 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 e719f54f17f4..1588f2ef74ca 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 38c6d925666a..a16f5830dd91 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);
}
diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h
index 5f657959291a..c27338d3d5a0 100644
--- a/source/tools/acpiexec/aecommon.h
+++ b/source/tools/acpiexec/aecommon.h
@@ -63,8 +63,6 @@
#include <string.h>
#include <signal.h>
-#pragma pack(push) /* Set default struct packing */
-
extern BOOLEAN AcpiGbl_IgnoreErrors;
extern UINT8 AcpiGbl_RegionFillValue;
extern UINT8 AcpiGbl_UseHwReducedFadt;
@@ -198,7 +196,4 @@ AeGlobalEventHandler (
UINT32 EventNumber,
void *Context);
-
-#pragma pack(pop) /* Restore original struct packing */
-
#endif /* _AECOMMON */
diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c
index faffdd9f26cf..ee2d2cf4fa3f 100644
--- a/source/tools/acpiexec/aehandlers.c
+++ b/source/tools/acpiexec/aehandlers.c
@@ -312,7 +312,7 @@ AeCommonNotifyHandler (
printf ("[AcpiExec] Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value,
- AcpiUtGetNotifyName (Value));
+ AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
if (AcpiGbl_DebugFile)
{
AcpiOsPrintf ("[AcpiExec] Handler %u: Received a %s notify, Value 0x%2.2X\n",
@@ -348,7 +348,7 @@ AeSystemNotifyHandler (
printf ("[AcpiExec] Global: Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
AcpiUtGetNodeName (Device), Device, Value,
- AcpiUtGetNotifyName (Value));
+ AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
if (AcpiGbl_DebugFile)
{
AcpiOsPrintf ("[AcpiExec] Global: Received a System Notify, Value 0x%2.2X\n", Value);
@@ -381,7 +381,7 @@ AeDeviceNotifyHandler (
printf ("[AcpiExec] Global: Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
AcpiUtGetNodeName (Device), Device, Value,
- AcpiUtGetNotifyName (Value));
+ AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
if (AcpiGbl_DebugFile)
{
AcpiOsPrintf ("[AcpiExec] Global: Received a Device Notify, Value 0x%2.2X\n", Value);
diff --git a/source/tools/acpihelp/acpihelp.h b/source/tools/acpihelp/acpihelp.h
index fba275466ee4..da15e4ef89f8 100644
--- a/source/tools/acpihelp/acpihelp.h
+++ b/source/tools/acpihelp/acpihelp.h
@@ -70,6 +70,7 @@
#define AH_DECODE_AML_OPCODE 5
#define AH_DISPLAY_DEVICE_IDS 6
#define AH_DECODE_EXCEPTION 7
+#define AH_DECODE_ASL_AML 8
#define AH_MAX_ASL_LINE_LENGTH 70
#define AH_MAX_AML_LINE_LENGTH 100
@@ -104,13 +105,6 @@ typedef struct ah_asl_keyword
} AH_ASL_KEYWORD;
-typedef struct ah_device_id
-{
- char *Name;
- char *Description;
-
-} AH_DEVICE_ID;
-
extern const AH_AML_OPCODE AmlOpcodeInfo[];
extern const AH_ASL_OPERATOR AslOperatorInfo[];
@@ -138,6 +132,10 @@ AhFindPredefinedNames (
char *Name);
void
+AhFindAslAndAmlOperators (
+ char *Name);
+
+UINT32
AhFindAslOperators (
char *Name);
@@ -147,6 +145,6 @@ AhFindAslKeywords (
void
AhDisplayDeviceIds (
- void);
+ char *Name);
#endif /* __ACPIHELP_H */
diff --git a/source/tools/acpihelp/ahamlops.c b/source/tools/acpihelp/ahamlops.c
index faa4c196fd8c..9ac13513dace 100644
--- a/source/tools/acpihelp/ahamlops.c
+++ b/source/tools/acpihelp/ahamlops.c
@@ -141,7 +141,7 @@ const AH_AML_OPCODE AmlOpcodeInfo[] =
"DefFatal := FatalOp FatalType FatalCode FatalArg"},
{0x5B33, 0x5B33, "0x5B33", "TimerOp", "TermObject", NULL, NULL,
"DefTimer := TimerOp"},
- {0x5B80, 0x5B80, "0x5B80", "OpRegionOp", "TermObject", "NameString ByteData TermArg TermArg", NULL,
+ {0x5B80, 0x5B80, "0x5B80", "OperationRegionOp", "TermObject", "NameString ByteData TermArg TermArg", NULL,
"DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen"},
{0x5B81, 0x5B81, "0x5B81", "FieldOp", "TermObject", "NameString ByteData", "FieldList",
"DefField := FieldOp PkgLength NameString FieldFlags FieldList"},
diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c
index 556dc6c98bf7..60e38081253b 100644
--- a/source/tools/acpihelp/ahdecode.c
+++ b/source/tools/acpihelp/ahdecode.c
@@ -48,41 +48,6 @@
#include "acpredef.h"
-/* Device IDs defined in the ACPI specification */
-
-static const AH_DEVICE_ID AhDeviceIds[] =
-{
- {"PNP0A05", "Generic Container Device"},
- {"PNP0A06", "Generic Container Device"},
- {"PNP0C08", "ACPI core hardware"},
- {"PNP0C09", "Embedded Controller Device"},
- {"PNP0C0A", "Control Method Battery"},
- {"PNP0C0B", "Fan"},
- {"PNP0C0C", "Power Button Device"},
- {"PNP0C0D", "Lid Device"},
- {"PNP0C0E", "Sleep Button Device"},
- {"PNP0C0F", "PCI Interrupt Link Device"},
- {"PNP0C80", "Memory Device"},
-
- {"ACPI0001", "SMBus 1.0 Host Controller"},
- {"ACPI0002", "Smart Battery Subsystem"},
- {"ACPI0003", "Power Source Device"},
- {"ACPI0004", "Module Device"},
- {"ACPI0005", "SMBus 2.0 Host Controller"},
- {"ACPI0006", "GPE Block Device"},
- {"ACPI0007", "Processor Device"},
- {"ACPI0008", "Ambient Light Sensor Device"},
- {"ACPI0009", "I/O xAPIC Device"},
- {"ACPI000A", "I/O APIC Device"},
- {"ACPI000B", "I/O SAPIC Device"},
- {"ACPI000C", "Processor Aggregator Device"},
- {"ACPI000D", "Power Meter Device"},
- {"ACPI000E", "Time/Alarm Device"},
- {"ACPI000F", "User Presence Detection Device"},
-
- {NULL, NULL}
-};
-
#define AH_DISPLAY_EXCEPTION(Status, Name) \
printf ("%.4X: %s\n", Status, Name)
@@ -589,7 +554,7 @@ AhDisplayAslKeyword (
/*******************************************************************************
*
- * FUNCTION: AhFindAslOperators (entry point for ASL operator search)
+ * FUNCTION: AhFindAslAndAmlOperators
*
* PARAMETERS: Name - Name or prefix for an ASL operator.
* NULL means "find all"
@@ -597,16 +562,46 @@ AhDisplayAslKeyword (
* RETURN: None
*
* DESCRIPTION: Find all ASL operators that match the input Name or name
- * prefix.
+ * prefix. Also displays the AML information if only one entry
+ * matches.
*
******************************************************************************/
void
+AhFindAslAndAmlOperators (
+ char *Name)
+{
+ UINT32 MatchCount;
+
+
+ MatchCount = AhFindAslOperators (Name);
+ if (MatchCount == 1)
+ {
+ AhFindAmlOpcode (Name);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AhFindAslOperators (entry point for ASL operator search)
+ *
+ * PARAMETERS: Name - Name or prefix for an ASL operator.
+ * NULL means "find all"
+ *
+ * RETURN: Number of operators that matched the name prefix.
+ *
+ * DESCRIPTION: Find all ASL operators that match the input Name or name
+ * prefix.
+ *
+ ******************************************************************************/
+
+UINT32
AhFindAslOperators (
char *Name)
{
const AH_ASL_OPERATOR *Operator;
- BOOLEAN Found = FALSE;
+ BOOLEAN MatchCount = 0;
AhStrupr (Name);
@@ -618,7 +613,7 @@ AhFindAslOperators (
if (!Name)
{
AhDisplayAslOperator (Operator);
- Found = TRUE;
+ MatchCount++;
continue;
}
@@ -630,14 +625,16 @@ AhFindAslOperators (
if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
{
AhDisplayAslOperator (Operator);
- Found = TRUE;
+ MatchCount++;
}
}
- if (!Found)
+ if (!MatchCount)
{
printf ("%s, no matching ASL operators\n", Name);
}
+
+ return (MatchCount);
}
@@ -805,26 +802,71 @@ AhPrintOneField (
*
* FUNCTION: AhDisplayDeviceIds
*
- * PARAMETERS: None
+ * PARAMETERS: Name - Device Hardware ID string.
+ * NULL means "find all"
*
* RETURN: None
*
- * DESCRIPTION: Display all PNP* and ACPI* device IDs defined in the ACPI spec.
+ * DESCRIPTION: Display PNP* and ACPI* device IDs.
*
******************************************************************************/
void
AhDisplayDeviceIds (
- void)
+ char *Name)
{
- const AH_DEVICE_ID *DeviceId = AhDeviceIds;
+ const AH_DEVICE_ID *Info;
+ UINT32 Length;
+ BOOLEAN Matched;
+ UINT32 i;
+ BOOLEAN Found = FALSE;
+
+
+ /* Null input name indicates "display all" */
+
+ if (!Name)
+ {
+ printf ("ACPI and PNP Device/Hardware IDs:\n\n");
+ for (Info = AslDeviceIds; Info->Name; Info++)
+ {
+ printf ("%8s %s\n", Info->Name, Info->Description);
+ }
+
+ return;
+ }
+ Length = strlen (Name);
+ if (Length > 8)
+ {
+ printf ("%.8s: Hardware ID must be 8 characters maximum\n", Name);
+ return;
+ }
- printf ("ACPI and PNP Device IDs defined in the ACPI specification:\n\n");
- while (DeviceId->Name)
+ /* Find/display all names that match the input name prefix */
+
+ AhStrupr (Name);
+ for (Info = AslDeviceIds; Info->Name; Info++)
+ {
+ Matched = TRUE;
+ for (i = 0; i < Length; i++)
+ {
+ if (Info->Name[i] != Name[i])
+ {
+ Matched = FALSE;
+ break;
+ }
+ }
+
+ if (Matched)
+ {
+ Found = TRUE;
+ printf ("%8s %s\n", Info->Name, Info->Description);
+ }
+ }
+
+ if (!Found)
{
- printf ("%8s %s\n", DeviceId->Name, DeviceId->Description);
- DeviceId++;
+ printf ("%s, Hardware ID not found\n", Name);
}
}
diff --git a/source/tools/acpihelp/ahmain.c b/source/tools/acpihelp/ahmain.c
index 1a8de1e4bade..a34059802838 100644
--- a/source/tools/acpihelp/ahmain.c
+++ b/source/tools/acpihelp/ahmain.c
@@ -51,7 +51,7 @@ AhDisplayUsage (
void);
#define AH_UTILITY_NAME "ACPI Help Utility"
-#define AH_SUPPORTED_OPTIONS "ehikmopsv"
+#define AH_SUPPORTED_OPTIONS "aehikmopsv"
/******************************************************************************
@@ -67,24 +67,29 @@ AhDisplayUsage (
void)
{
- ACPI_USAGE_HEADER ("acpihelp <options> [NamePrefix | HexValue]");
+ ACPI_USAGE_HEADER ("acpihelp <options> [Name/Prefix | HexValue]");
ACPI_OPTION ("-h", "Display help");
ACPI_OPTION ("-v", "Display version information");
- printf ("\nACPI Names and Symbols:\n");
- ACPI_OPTION ("-k [NamePrefix]", "Find/Display ASL non-operator keyword(s)");
- ACPI_OPTION ("-m [NamePrefix]", "Find/Display AML opcode name(s)");
- ACPI_OPTION ("-p [NamePrefix]", "Find/Display ASL predefined method name(s)");
- ACPI_OPTION ("-s [NamePrefix]", "Find/Display ASL operator name(s)");
+ printf ("\nAML (ACPI Machine Language) Names and Encodings:\n");
+ ACPI_OPTION ("-a [Name/Prefix]", "Find/Display both ASL operator and AML opcode name(s)");
+ ACPI_OPTION ("-m [Name/Prefix]", "Find/Display AML opcode name(s)");
+
+ printf ("\nASL (ACPI Source Language) Names and Symbols:\n");
+ ACPI_OPTION ("-k [Name/Prefix]", "Find/Display ASL non-operator keyword(s)");
+ ACPI_OPTION ("-p [Name/Prefix]", "Find/Display ASL predefined method name(s)");
+ ACPI_OPTION ("-s [Name/Prefix]", "Find/Display ASL operator name(s)");
+
+ printf ("\nOther ACPI Names:\n");
+ ACPI_OPTION ("-i [Name/Prefix]", "Find/Display ACPI/PNP Hardware ID(s)");
printf ("\nACPI Values:\n");
ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code");
- ACPI_OPTION ("-i", "Display known ACPI Device IDs (_HID)");
ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode");
- printf ("\nNamePrefix/HexValue not specified means \"Display All\"\n");
- printf ("\nDefault search with NamePrefix and no options:\n");
- printf (" Find ASL operator names - if NamePrefix does not start with underscore\n");
+ printf ("\nName/Prefix or HexValue not specified means \"Display All\"\n");
+ printf ("\nDefault search with valid Name/Prefix and no options:\n");
+ printf (" Find ASL/AML operator names - if NamePrefix does not start with underscore\n");
printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n");
}
@@ -121,6 +126,11 @@ main (
while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != EOF) switch (j)
{
+ case 'a':
+
+ DecodeType = AH_DECODE_ASL_AML;
+ break;
+
case 'e':
DecodeType = AH_DECODE_EXCEPTION;
@@ -173,6 +183,11 @@ main (
switch (DecodeType)
{
+ case AH_DECODE_ASL_AML:
+
+ AhFindAslAndAmlOperators (Name);
+ break;
+
case AH_DECODE_AML:
AhFindAmlOpcode (Name);
@@ -200,7 +215,7 @@ main (
case AH_DISPLAY_DEVICE_IDS:
- AhDisplayDeviceIds ();
+ AhDisplayDeviceIds (Name);
break;
case AH_DECODE_EXCEPTION:
@@ -222,7 +237,7 @@ main (
}
else
{
- AhFindAslOperators (Name);
+ AhFindAslAndAmlOperators (Name);
}
break;
}
diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c
index 42cefa46e88e..d3b72de798b2 100644
--- a/source/tools/acpisrc/asfile.c
+++ b/source/tools/acpisrc/asfile.c
@@ -42,6 +42,7 @@
*/
#include "acpisrc.h"
+#include "acapps.h"
/* Local prototypes */
@@ -714,8 +715,6 @@ AsGetFile (
FILE *File;
UINT32 Size;
char *Buffer;
- int Seek1;
- int Seek2;
size_t Actual;
@@ -730,11 +729,8 @@ AsGetFile (
/* Need file size to allocate a buffer */
- Seek1 = fseek (File, 0L, SEEK_END);
- Size = ftell (File);
- Seek2 = fseek (File, 0L, SEEK_SET);
-
- if (Seek1 || Seek2 || (Size == -1))
+ Size = CmGetFileSize (File);
+ if (Size == ACPI_UINT32_MAX)
{
printf ("Could not get file size for %s\n", Filename);
goto ErrorExit;
diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c
index 7c3d663695c9..0073128b631a 100644
--- a/source/tools/acpisrc/astable.c
+++ b/source/tools/acpisrc/astable.c
@@ -637,6 +637,10 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"PR_MACRO_ARG", SRC_TYPE_STRUCT},
{"PR_OPERATOR_INFO", SRC_TYPE_STRUCT},
+ /* AcpiDump utility */
+
+ {"AP_DUMP_ACTION", SRC_TYPE_STRUCT},
+
/* AcpiHelp utility */
{"AH_AML_OPCODE", SRC_TYPE_STRUCT},
@@ -648,6 +652,11 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"AX_TABLE_INFO", SRC_TYPE_STRUCT},
+ /* OS service layers */
+
+ {"EXTERNAL_FIND_INFO", SRC_TYPE_STRUCT},
+ {"OSL_TABLE_INFO", SRC_TYPE_STRUCT},
+
{NULL, 0}
};