diff options
Diffstat (limited to 'source/tools')
23 files changed, 1275 insertions, 934 deletions
diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index d27d4876462e..ea42171428f0 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -615,12 +615,3 @@ Exit1: free (FileBuffer); return (Status); } - - -/****************************************************************************** - * - * FUNCTION: Stubs - * - * DESCRIPTION: For linkage - * - ******************************************************************************/ diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index 4e866ef10e00..d8ad86795b85 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -52,6 +52,18 @@ ApIsExistingFile ( char *Pathname); +/****************************************************************************** + * + * FUNCTION: ApIsExistingFile + * + * PARAMETERS: Pathname - Output filename + * + * RETURN: 0 on success + * + * DESCRIPTION: Query for file overwrite if it already exists. + * + ******************************************************************************/ + static int ApIsExistingFile ( char *Pathname) @@ -159,6 +171,7 @@ ApWriteToBinaryFile ( { ACPI_MOVE_NAME (Filename, Table->Signature); } + Filename[0] = (char) tolower ((int) Filename[0]); Filename[1] = (char) tolower ((int) Filename[1]); Filename[2] = (char) tolower ((int) Filename[2]); diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index 162bc3fd0ceb..bc30acf0ea11 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -64,34 +64,6 @@ #include <string.h> #include <signal.h> -extern BOOLEAN AcpiGbl_IgnoreErrors; -extern UINT8 AcpiGbl_RegionFillValue; -extern UINT8 AcpiGbl_UseHwReducedFadt; -extern BOOLEAN AcpiGbl_DisplayRegionAccess; -extern BOOLEAN AcpiGbl_DoInterfaceTests; -extern BOOLEAN AcpiGbl_LoadTestTables; -extern FILE *AcpiGbl_NamespaceInitFile; -extern ACPI_CONNECTION_INFO AeMyContext; - -/* Check for unexpected exceptions */ - -#define AE_CHECK_STATUS(Name, Status, Expected) \ - if (Status != Expected) \ - { \ - AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \ - AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \ - } - -/* Check for unexpected non-AE_OK errors */ - -#define AE_CHECK_OK(Name, Status) AE_CHECK_STATUS (Name, Status, AE_OK); - -typedef struct ae_table_desc -{ - ACPI_TABLE_HEADER *Table; - struct ae_table_desc *Next; - -} AE_TABLE_DESC; /* * Debug Regions @@ -114,6 +86,16 @@ typedef struct ae_debug_regions } AE_DEBUG_REGIONS; +extern BOOLEAN AcpiGbl_IgnoreErrors; +extern UINT8 AcpiGbl_RegionFillValue; +extern UINT8 AcpiGbl_UseHwReducedFadt; +extern BOOLEAN AcpiGbl_DisplayRegionAccess; +extern BOOLEAN AcpiGbl_DoInterfaceTests; +extern BOOLEAN AcpiGbl_LoadTestTables; +extern FILE *AcpiGbl_NamespaceInitFile; +extern ACPI_CONNECTION_INFO AeMyContext; + + #define TEST_OUTPUT_LEVEL(lvl) if ((lvl) & OutputLevel) #define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\ @@ -125,8 +107,7 @@ AeCtrlCHandler ( ACPI_STATUS AeBuildLocalTables ( - UINT32 TableCount, - AE_TABLE_DESC *TableList); + ACPI_NEW_TABLE_DESC *TableList); ACPI_STATUS AeInstallTables ( diff --git a/source/tools/acpiexec/aeexec.c b/source/tools/acpiexec/aeexec.c index 518c20e94520..b428cde0f96a 100644 --- a/source/tools/acpiexec/aeexec.c +++ b/source/tools/acpiexec/aeexec.c @@ -158,7 +158,7 @@ AfInstallGpeBlock ( /* _GPE should always exist */ Status = AcpiGetHandle (NULL, "\\_GPE", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); if (ACPI_FAILURE (Status)) { return; @@ -181,29 +181,29 @@ AfInstallGpeBlock ( } Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 7, 8); - AE_CHECK_OK (AcpiInstallGpeBlock, Status); + ACPI_CHECK_OK (AcpiInstallGpeBlock, Status); Status = AcpiInstallGpeHandler (Handle, 8, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (Handle, 8); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); Status = AcpiGetGpeDevice (0x30, &GpeDevice); - AE_CHECK_OK (AcpiGetGpeDevice, Status); + ACPI_CHECK_OK (AcpiGetGpeDevice, Status); Status = AcpiGetGpeDevice (0x42, &GpeDevice); - AE_CHECK_OK (AcpiGetGpeDevice, Status); + ACPI_CHECK_OK (AcpiGetGpeDevice, Status); Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice); - AE_CHECK_OK (AcpiGetGpeDevice, Status); + ACPI_CHECK_OK (AcpiGetGpeDevice, Status); Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice); - AE_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST); + ACPI_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST); Status = AcpiRemoveGpeHandler (Handle, 8, AeGpeHandler); - AE_CHECK_OK (AcpiRemoveGpeHandler, Status); + ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status); } /* Attempt to install a GPE block on GPE3 (if present) */ @@ -219,7 +219,7 @@ AfInstallGpeBlock ( } Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 8, 11); - AE_CHECK_OK (AcpiInstallGpeBlock, Status); + ACPI_CHECK_OK (AcpiInstallGpeBlock, Status); } } #endif /* !ACPI_REDUCED_HARDWARE */ @@ -233,10 +233,12 @@ AeTestBufferArgument ( { ACPI_OBJECT_LIST Params; ACPI_OBJECT BufArg; - UINT8 Buffer[] = { + UINT8 Buffer[] = + { 0,0,0,0, 4,0,0,0, - 1,2,3,4}; + 1,2,3,4 + }; BufArg.Type = ACPI_TYPE_BUFFER; @@ -359,7 +361,8 @@ ExecuteOSI ( if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not execute _OSI method, %s\n", + AcpiOsPrintf ( + "Could not execute _OSI method, %s\n", AcpiFormatException (Status)); return (Status); } @@ -368,7 +371,8 @@ ExecuteOSI ( if (ReturnValue.Length < sizeof (ACPI_OBJECT)) { - AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n", + AcpiOsPrintf ( + "Return value from _OSI method too small, %.8X\n", ReturnValue.Length); goto ErrorExit; } @@ -376,13 +380,15 @@ ExecuteOSI ( Obj = ReturnValue.Pointer; if (Obj->Type != ACPI_TYPE_INTEGER) { - AcpiOsPrintf ("Invalid return type from _OSI method, %.2X\n", Obj->Type); + AcpiOsPrintf ( + "Invalid return type from _OSI method, %.2X\n", Obj->Type); goto ErrorExit; } if (Obj->Integer.Value != ExpectedResult) { - AcpiOsPrintf ("Invalid return value from _OSI, expected %.8X found %.8X\n", + AcpiOsPrintf ( + "Invalid return value from _OSI, expected %.8X found %.8X\n", ExpectedResult, (UINT32) Obj->Integer.Value); goto ErrorExit; } @@ -398,7 +404,6 @@ ErrorExit: /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ AcpiOsFree (ReturnValue.Pointer); - return (Status); } @@ -427,20 +432,20 @@ AeGenericRegisters ( GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; Status = AcpiRead (&Value, &GenericRegister); - AE_CHECK_OK (AcpiRead, Status); + ACPI_CHECK_OK (AcpiRead, Status); Status = AcpiWrite (Value, &GenericRegister); - AE_CHECK_OK (AcpiWrite, Status); + ACPI_CHECK_OK (AcpiWrite, Status); GenericRegister.Address = 0x12345678; GenericRegister.BitOffset = 0; GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY; Status = AcpiRead (&Value, &GenericRegister); - AE_CHECK_OK (AcpiRead, Status); + ACPI_CHECK_OK (AcpiRead, Status); Status = AcpiWrite (Value, &GenericRegister); - AE_CHECK_OK (AcpiWrite, Status); + ACPI_CHECK_OK (AcpiWrite, Status); } @@ -468,7 +473,7 @@ AeMutexInterfaces ( return; } - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); if (ACPI_FAILURE (Status)) { return; @@ -477,7 +482,7 @@ AeMutexInterfaces ( /* Acquire the mutex */ Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF); - AE_CHECK_OK (AcpiAcquireMutex, Status); + ACPI_CHECK_OK (AcpiAcquireMutex, Status); if (ACPI_FAILURE (Status)) { return; @@ -486,7 +491,7 @@ AeMutexInterfaces ( /* Release mutex with different parameters */ Status = AcpiReleaseMutex (MutexHandle, NULL); - AE_CHECK_OK (AcpiReleaseMutex, Status); + ACPI_CHECK_OK (AcpiReleaseMutex, Status); } @@ -516,29 +521,29 @@ AeHardwareInterfaces ( } Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1); - AE_CHECK_OK (AcpiWriteBitRegister, Status); + ACPI_CHECK_OK (AcpiWriteBitRegister, Status); Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1); - AE_CHECK_OK (AcpiWriteBitRegister, Status); + ACPI_CHECK_OK (AcpiWriteBitRegister, Status); Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1); - AE_CHECK_OK (AcpiWriteBitRegister, Status); + ACPI_CHECK_OK (AcpiWriteBitRegister, Status); Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); - AE_CHECK_OK (AcpiWriteBitRegister, Status); + ACPI_CHECK_OK (AcpiWriteBitRegister, Status); Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value); - AE_CHECK_OK (AcpiReadBitRegister, Status); + ACPI_CHECK_OK (AcpiReadBitRegister, Status); Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value); - AE_CHECK_OK (AcpiReadBitRegister, Status); + ACPI_CHECK_OK (AcpiReadBitRegister, Status); Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value); - AE_CHECK_OK (AcpiReadBitRegister, Status); + ACPI_CHECK_OK (AcpiReadBitRegister, Status); Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value); - AE_CHECK_OK (AcpiReadBitRegister, Status); + ACPI_CHECK_OK (AcpiReadBitRegister, Status); #endif /* !ACPI_REDUCED_HARDWARE */ } @@ -563,14 +568,15 @@ AeMiscellaneousTests ( ACPI_HANDLE Handle; #if (!ACPI_REDUCED_HARDWARE) - ACPI_VENDOR_UUID Uuid = {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}}; UINT32 LockHandle1; UINT32 LockHandle2; + ACPI_VENDOR_UUID Uuid = + {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}}; #endif /* !ACPI_REDUCED_HARDWARE */ Status = AcpiGetHandle (NULL, "\\", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); if (AcpiGbl_DoInterfaceTests) { @@ -581,42 +587,42 @@ AeMiscellaneousTests ( /* Attempt unload of DSDT, should fail */ Status = AcpiGetHandle (NULL, "\\_SB_", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); Status = AcpiUnloadParentTable (Handle); - AE_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE); + ACPI_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE); /* Load and unload SSDT4 */ Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code); - AE_CHECK_OK (AcpiLoadTable, Status); + ACPI_CHECK_OK (AcpiLoadTable, Status); Status = AcpiGetHandle (NULL, "\\_T96", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); Status = AcpiUnloadParentTable (Handle); - AE_CHECK_OK (AcpiUnloadParentTable, Status); + ACPI_CHECK_OK (AcpiUnloadParentTable, Status); /* Re-load SSDT4 */ Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code); - AE_CHECK_OK (AcpiLoadTable, Status); + ACPI_CHECK_OK (AcpiLoadTable, Status); /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */ Status = AcpiGetHandle (NULL, "\\_T99", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); Status = AcpiUnloadParentTable (Handle); - AE_CHECK_OK (AcpiUnloadParentTable, Status); + ACPI_CHECK_OK (AcpiUnloadParentTable, Status); Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code); - AE_CHECK_OK (AcpiLoadTable, Status); + ACPI_CHECK_OK (AcpiLoadTable, Status); /* Load OEM9 table (causes table override) */ Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code); - AE_CHECK_OK (AcpiLoadTable, Status); + ACPI_CHECK_OK (AcpiLoadTable, Status); } AeHardwareInterfaces (); @@ -630,36 +636,36 @@ AeMiscellaneousTests ( /* Test _OSI install/remove */ Status = AcpiInstallInterface (""); - AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER); + ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER); Status = AcpiInstallInterface ("TestString"); - AE_CHECK_OK (AcpiInstallInterface, Status); + ACPI_CHECK_OK (AcpiInstallInterface, Status); Status = AcpiInstallInterface ("TestString"); - AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS); + ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS); Status = AcpiRemoveInterface ("Windows 2006"); - AE_CHECK_OK (AcpiRemoveInterface, Status); + ACPI_CHECK_OK (AcpiRemoveInterface, Status); Status = AcpiRemoveInterface ("TestString"); - AE_CHECK_OK (AcpiRemoveInterface, Status); + ACPI_CHECK_OK (AcpiRemoveInterface, Status); Status = AcpiRemoveInterface ("XXXXXX"); - AE_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST); + ACPI_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST); Status = AcpiInstallInterface ("AnotherTestString"); - AE_CHECK_OK (AcpiInstallInterface, Status); + ACPI_CHECK_OK (AcpiInstallInterface, Status); /* Test _OSI execution */ Status = ExecuteOSI ("Extended Address Space Descriptor", 0xFFFFFFFF); - AE_CHECK_OK (ExecuteOSI, Status); + ACPI_CHECK_OK (ExecuteOSI, Status); Status = ExecuteOSI ("Windows 2001", 0xFFFFFFFF); - AE_CHECK_OK (ExecuteOSI, Status); + ACPI_CHECK_OK (ExecuteOSI, Status); Status = ExecuteOSI ("MichiganTerminalSystem", 0); - AE_CHECK_OK (ExecuteOSI, Status); + ACPI_CHECK_OK (ExecuteOSI, Status); ReturnBuf.Length = 32; @@ -667,21 +673,21 @@ AeMiscellaneousTests ( Status = AcpiGetName (ACPI_ROOT_OBJECT, ACPI_FULL_PATHNAME_NO_TRAILING, &ReturnBuf); - AE_CHECK_OK (AcpiGetName, Status); + ACPI_CHECK_OK (AcpiGetName, Status); /* Get Devices */ Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL); - AE_CHECK_OK (AcpiGetDevices, Status); + ACPI_CHECK_OK (AcpiGetDevices, Status); Status = AcpiGetStatistics (&Stats); - AE_CHECK_OK (AcpiGetStatistics, Status); + ACPI_CHECK_OK (AcpiGetStatistics, Status); #if (!ACPI_REDUCED_HARDWARE) Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL); - AE_CHECK_OK (AcpiInstallGlobalEventHandler, Status); + ACPI_CHECK_OK (AcpiInstallGlobalEventHandler, Status); /* If Hardware Reduced flag is set, we are all done */ @@ -691,98 +697,107 @@ AeMiscellaneousTests ( } Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0); - AE_CHECK_OK (AcpiEnableEvent, Status); + ACPI_CHECK_OK (AcpiEnableEvent, Status); /* * GPEs: Handlers, enable/disable, etc. */ - Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 0, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 0); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler); - AE_CHECK_OK (AcpiRemoveGpeHandler, Status); + ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status); - Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 0, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 0); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE); - AE_CHECK_OK (AcpiSetGpe, Status); + ACPI_CHECK_OK (AcpiSetGpe, Status); Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE); - AE_CHECK_OK (AcpiSetGpe, Status); + ACPI_CHECK_OK (AcpiSetGpe, Status); - Status = AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 1, + ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 1); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); - Status = AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 2, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 2); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); - Status = AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 3, + ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); - Status = AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 4, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); - Status = AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 5, + ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiGetHandle (NULL, "\\_SB", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); Status = AcpiSetupGpeForWake (Handle, NULL, 5); - AE_CHECK_OK (AcpiSetupGpeForWake, Status); + ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE); - AE_CHECK_OK (AcpiSetGpeWakeMask, Status); + ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status); Status = AcpiSetupGpeForWake (Handle, NULL, 6); - AE_CHECK_OK (AcpiSetupGpeForWake, Status); + ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6); - AE_CHECK_OK (AcpiSetupGpeForWake, Status); + ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); Status = AcpiSetupGpeForWake (Handle, NULL, 9); - AE_CHECK_OK (AcpiSetupGpeForWake, Status); + ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); - Status = AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 0x19, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 0x19); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); /* GPE block 1 */ - Status = AcpiInstallGpeHandler (NULL, 101, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AE_CHECK_OK (AcpiInstallGpeHandler, Status); + Status = AcpiInstallGpeHandler (NULL, 101, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); Status = AcpiEnableGpe (NULL, 101); - AE_CHECK_OK (AcpiEnableGpe, Status); + ACPI_CHECK_OK (AcpiEnableGpe, Status); Status = AcpiDisableGpe (NULL, 101); - AE_CHECK_OK (AcpiDisableGpe, Status); + ACPI_CHECK_OK (AcpiDisableGpe, Status); AfInstallGpeBlock (); /* Here is where the GPEs are actually "enabled" */ Status = AcpiUpdateAllGpes (); - AE_CHECK_OK (AcpiUpdateAllGpes, Status); + ACPI_CHECK_OK (AcpiUpdateAllGpes, Status); Status = AcpiGetHandle (NULL, "RSRC", &Handle); if (ACPI_SUCCESS (Status)) @@ -799,16 +814,16 @@ AeMiscellaneousTests ( /* Test global lock */ Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1); - AE_CHECK_OK (AcpiAcquireGlobalLock, Status); + ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status); Status = AcpiAcquireGlobalLock (0x5, &LockHandle2); - AE_CHECK_OK (AcpiAcquireGlobalLock, Status); + ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status); Status = AcpiReleaseGlobalLock (LockHandle1); - AE_CHECK_OK (AcpiReleaseGlobalLock, Status); + ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status); Status = AcpiReleaseGlobalLock (LockHandle2); - AE_CHECK_OK (AcpiReleaseGlobalLock, Status); + ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status); #endif /* !ACPI_REDUCED_HARDWARE */ } diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index 9fce63d1bb24..625cf5704d4f 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -363,6 +363,7 @@ AeExceptionHandler ( { AcpiOsPrintf ("at module level (table load)"); } + AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset); /* @@ -458,7 +459,7 @@ AeTableHandler ( /* Enable any GPEs associated with newly-loaded GPE methods */ Status = AcpiUpdateAllGpes (); - AE_CHECK_OK (AcpiUpdateAllGpes, Status); + ACPI_CHECK_OK (AcpiUpdateAllGpes, Status); printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); @@ -528,7 +529,8 @@ AeGlobalEventHandler ( break; } - AcpiOsPrintf ("[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", + AcpiOsPrintf ( + "[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", TypeName, EventNumber, Device); } @@ -699,15 +701,17 @@ AeInstallLateHandlers ( /* Install a user SCI handler */ Status = AeInstallSciHandler (); - AE_CHECK_OK (AeInstallSciHandler, Status); + ACPI_CHECK_OK (AeInstallSciHandler, Status); /* Install some fixed event handlers */ - Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AeEventHandler, NULL); - AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); + Status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_GLOBAL, AeEventHandler, NULL); + ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status); - Status = AcpiInstallFixedEventHandler (ACPI_EVENT_RTC, AeEventHandler, NULL); - AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); + Status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_RTC, AeEventHandler, NULL); + ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status); } #endif /* !ACPI_REDUCED_HARDWARE */ @@ -817,11 +821,11 @@ AeInstallEarlyHandlers ( Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler1, NULL); - AE_CHECK_OK (AcpiInstallNotifyHandler, Status); + ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status); Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler1); - AE_CHECK_OK (AcpiRemoveNotifyHandler, Status); + ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status); #if 0 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, @@ -847,35 +851,34 @@ AeInstallEarlyHandlers ( AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777)); Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); - AE_CHECK_OK (AcpiAttachData, Status); + ACPI_CHECK_OK (AcpiAttachData, Status); Status = AcpiDetachData (Handle, AeAttachedDataHandler); - AE_CHECK_OK (AcpiDetachData, Status); + ACPI_CHECK_OK (AcpiDetachData, Status); /* Test attach data at the root object */ Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, AcpiGbl_RootNode); - AE_CHECK_OK (AcpiAttachData, Status); + ACPI_CHECK_OK (AcpiAttachData, Status); Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, AcpiGbl_RootNode); - AE_CHECK_OK (AcpiAttachData, Status); + ACPI_CHECK_OK (AcpiAttachData, Status); /* Test support for multiple attaches */ Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); - AE_CHECK_OK (AcpiAttachData, Status); + ACPI_CHECK_OK (AcpiAttachData, Status); Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); - AE_CHECK_OK (AcpiAttachData, Status); + ACPI_CHECK_OK (AcpiAttachData, Status); } else { printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); } - Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle); if (ACPI_SUCCESS (Status)) { diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 861cb49bae75..bc35036df4b4 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -42,6 +42,7 @@ */ #include "aecommon.h" +#include "errno.h" #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("aemain") @@ -93,7 +94,6 @@ BOOLEAN AcpiGbl_LoadTestTables = FALSE; BOOLEAN AcpiGbl_AeLoadOnly = FALSE; static UINT8 AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP; static char BatchBuffer[AE_BUFFER_SIZE]; /* Batch command buffer */ -static AE_TABLE_DESC *AeTableListHead = NULL; #define ACPIEXEC_NAME "AML Execution/Debug Utility" #define AE_SUPPORTED_OPTIONS "?b:d:e:f^ghi:lm^rv^:x:" @@ -440,11 +440,9 @@ main ( int argc, char **argv) { + ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; UINT32 InitFlags; - ACPI_TABLE_HEADER *Table = NULL; - UINT32 TableCount; - AE_TABLE_DESC *TableDesc; int ExitCode = 0; @@ -459,7 +457,7 @@ main ( /* Init ACPICA and start debugger thread */ Status = AcpiInitializeSubsystem (); - AE_CHECK_OK (AcpiInitializeSubsystem, Status); + ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -473,7 +471,7 @@ main ( /* Initialize the AML debugger */ Status = AcpiInitializeDebugger (); - AE_CHECK_OK (AcpiInitializeDebugger, Status); + ACPI_CHECK_OK (AcpiInitializeDebugger, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -496,6 +494,7 @@ main ( { ExitCode = 0; } + goto ErrorExit; } @@ -507,44 +506,21 @@ main ( } AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ - TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { - /* Get one entire table */ + /* Get all ACPI AML tables in this file */ - Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table); + Status = AcpiAcGetAllTablesFromFile (argv[AcpiGbl_Optind], + ACPI_GET_ONLY_AML_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { - fprintf (stderr, "**** Could not get table from file %s, %s\n", - argv[AcpiGbl_Optind], AcpiFormatException (Status)); + ExitCode = -1; goto ErrorExit; } - /* Ignore non-AML tables, we can't use them. Except for an FADT */ - - if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && - !AcpiUtIsAmlTable (Table)) - { - fprintf (stderr, " %s: [%4.4s] is not an AML table - ignoring\n", - argv[AcpiGbl_Optind], Table->Signature); - - AcpiOsFree (Table); - } - else - { - /* Allocate and link a table descriptor */ - - TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); - TableDesc->Table = Table; - TableDesc->Next = AeTableListHead; - AeTableListHead = TableDesc; - - TableCount++; - } - AcpiGbl_Optind++; } @@ -552,7 +528,7 @@ main ( /* Build a local RSDT with all tables and let ACPICA process the RSDT */ - Status = AeBuildLocalTables (TableCount, AeTableListHead); + Status = AeBuildLocalTables (ListHead); if (ACPI_FAILURE (Status)) { goto ErrorExit; diff --git a/source/tools/acpiexec/aeregion.c b/source/tools/acpiexec/aeregion.c index 311b6ae61756..a33e9e70def1 100644 --- a/source/tools/acpiexec/aeregion.c +++ b/source/tools/acpiexec/aeregion.c @@ -165,8 +165,8 @@ AeInstallRegionHandlers ( /* Install handler at the root object */ Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT, - SpaceIdList[i], AeRegionHandler, - AeRegionInit, &AeMyContext); + SpaceIdList[i], AeRegionHandler, + AeRegionInit, &AeMyContext); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -194,8 +194,8 @@ AeOverrideRegionHandlers ( /* Install handler at the root object */ Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT, - DefaultSpaceIdList[i], AeRegionHandler, - AeRegionInit, &AeMyContext); + DefaultSpaceIdList[i], AeRegionHandler, + AeRegionInit, &AeMyContext); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -373,9 +373,10 @@ AeRegionHandler ( Length = (ACPI_SIZE) RegionObject->Region.Length; SpaceId = RegionObject->Region.SpaceId; - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n", - AcpiUtGetRegionName (RegionObject->Region.SpaceId), - (UINT32) Address)); + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Operation Region request on %s at 0x%X\n", + AcpiUtGetRegionName (RegionObject->Region.SpaceId), + (UINT32) Address)); /* * Region support can be disabled with the -do option. @@ -410,16 +411,16 @@ AeRegionHandler ( /* Split the 64-bit request into two 32-bit requests */ Status = AcpiHwReadPort (Address, &Value1, 32); - AE_CHECK_OK (AcpiHwReadPort, Status); + ACPI_CHECK_OK (AcpiHwReadPort, Status); Status = AcpiHwReadPort (Address+4, &Value2, 32); - AE_CHECK_OK (AcpiHwReadPort, Status); + ACPI_CHECK_OK (AcpiHwReadPort, Status); *Value = Value1 | ((UINT64) Value2 << 32); } else { Status = AcpiHwReadPort (Address, &Value1, BitWidth); - AE_CHECK_OK (AcpiHwReadPort, Status); + ACPI_CHECK_OK (AcpiHwReadPort, Status); *Value = (UINT64) Value1; } break; @@ -431,14 +432,14 @@ AeRegionHandler ( /* Split the 64-bit request into two 32-bit requests */ Status = AcpiHwWritePort (Address, ACPI_LODWORD (*Value), 32); - AE_CHECK_OK (AcpiHwWritePort, Status); + ACPI_CHECK_OK (AcpiHwWritePort, Status); Status = AcpiHwWritePort (Address+4, ACPI_HIDWORD (*Value), 32); - AE_CHECK_OK (AcpiHwWritePort, Status); + ACPI_CHECK_OK (AcpiHwWritePort, Status); } else { Status = AcpiHwWritePort (Address, (UINT32) *Value, BitWidth); - AE_CHECK_OK (AcpiHwWritePort, Status); + ACPI_CHECK_OK (AcpiHwWritePort, Status); } break; @@ -819,7 +820,8 @@ AeRegionHandler ( ((UINT64)(RegionElement->Address) + RegionElement->Length)) { ACPI_WARNING ((AE_INFO, - "Request on [%4.4s] is beyond region limit Req-0x%X+0x%X, Base=0x%X, Len-0x%X", + "Request on [%4.4s] is beyond region limit " + "Req-0x%X+0x%X, Base=0x%X, Len-0x%X", (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address, ByteWidth, (UINT32)(RegionElement->Address), RegionElement->Length)); @@ -831,7 +833,7 @@ AeRegionHandler ( * Get BufferValue to point to the "address" in the buffer */ BufferValue = ((UINT8 *) RegionElement->Buffer + - ((UINT64) Address - (UINT64) RegionElement->Address)); + ((UINT64) Address - (UINT64) RegionElement->Address)); DoFunction: /* diff --git a/source/tools/acpiexec/aetables.c b/source/tools/acpiexec/aetables.c index 75dea6127327..7e81fc3cefd0 100644 --- a/source/tools/acpiexec/aetables.c +++ b/source/tools/acpiexec/aetables.c @@ -169,7 +169,7 @@ AeInitializeTableHeader ( * FUNCTION: AeBuildLocalTables * * PARAMETERS: TableCount - Number of tables on the command line - * TableList - List of actual tables from files + * ListHead - List of actual tables from files * * RETURN: Status * @@ -180,12 +180,12 @@ AeInitializeTableHeader ( ACPI_STATUS AeBuildLocalTables ( - UINT32 TableCount, - AE_TABLE_DESC *TableList) + ACPI_NEW_TABLE_DESC *ListHead) { + UINT32 TableCount = 1; ACPI_PHYSICAL_ADDRESS DsdtAddress = 0; UINT32 XsdtSize; - AE_TABLE_DESC *NextTable; + ACPI_NEW_TABLE_DESC *NextTable; UINT32 NextIndex; ACPI_TABLE_FADT *ExternalFadt = NULL; @@ -195,18 +195,20 @@ AeBuildLocalTables ( * For the FADT, this table is already accounted for since we usually * install a local FADT. */ - NextTable = TableList; + NextTable = ListHead; while (NextTable) { - if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) || - ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) + if (!ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) { - TableCount--; + TableCount++; } + NextTable = NextTable->Next; } - XsdtSize = (((TableCount + 1) * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER)); + XsdtSize = (((TableCount + 1) * sizeof (UINT64)) + + sizeof (ACPI_TABLE_HEADER)); if (AcpiGbl_LoadTestTables) { XsdtSize += BASE_XSDT_SIZE; @@ -231,7 +233,7 @@ AeBuildLocalTables ( * Note: The tables are loaded in reverse order from the incoming * input, which makes it match the command line order. */ - NextTable = TableList; + NextTable = ListHead; while (NextTable) { /* @@ -489,10 +491,10 @@ AeInstallTables ( Status = AcpiInitializeTables (NULL, ACPI_MAX_INIT_TABLES, TRUE); - AE_CHECK_OK (AcpiInitializeTables, Status); + ACPI_CHECK_OK (AcpiInitializeTables, Status); Status = AcpiLoadTables (); - AE_CHECK_OK (AcpiLoadTables, Status); + ACPI_CHECK_OK (AcpiLoadTables, Status); /* * Test run-time control method installation. Do it twice to test code @@ -517,24 +519,24 @@ AeInstallTables ( /* Test multiple table/UEFI support. First, get the headers */ Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 1, &Header); - AE_CHECK_OK (AcpiGetTableHeader, Status); + ACPI_CHECK_OK (AcpiGetTableHeader, Status); Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 2, &Header); - AE_CHECK_OK (AcpiGetTableHeader, Status); + ACPI_CHECK_OK (AcpiGetTableHeader, Status); Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 3, &Header); - AE_CHECK_STATUS (AcpiGetTableHeader, Status, AE_NOT_FOUND); + ACPI_CHECK_STATUS (AcpiGetTableHeader, Status, AE_NOT_FOUND); /* Now get the actual tables */ Status = AcpiGetTable (ACPI_SIG_UEFI, 1, &Table); - AE_CHECK_OK (AcpiGetTable, Status); + ACPI_CHECK_OK (AcpiGetTable, Status); Status = AcpiGetTable (ACPI_SIG_UEFI, 2, &Table); - AE_CHECK_OK (AcpiGetTable, Status); + ACPI_CHECK_OK (AcpiGetTable, Status); Status = AcpiGetTable (ACPI_SIG_UEFI, 3, &Table); - AE_CHECK_STATUS (AcpiGetTable, Status, AE_NOT_FOUND); + ACPI_CHECK_STATUS (AcpiGetTable, Status, AE_NOT_FOUND); } /* Check that we can get all of the ACPI tables */ @@ -546,7 +548,8 @@ AeInstallTables ( { break; } - AE_CHECK_OK (AcpiGetTableByIndex, Status); + + ACPI_CHECK_OK (AcpiGetTableByIndex, Status); } return (AE_OK); diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c index 8684c6a1c042..bca1eeb8b891 100644 --- a/source/tools/acpihelp/ahdecode.c +++ b/source/tools/acpihelp/ahdecode.c @@ -827,6 +827,7 @@ AhPrintOneField ( { printf ("\n%*s", (int) Indent, " "); } + printf ("%s", This); } } @@ -1014,7 +1015,8 @@ AhDecodeException ( if (!HexString) { printf ("All defined ACPICA exception codes:\n\n"); - AH_DISPLAY_EXCEPTION (0, "AE_OK (No error occurred)"); + AH_DISPLAY_EXCEPTION (0, + "AE_OK (No error occurred)"); /* Display codes in each block of exception types */ @@ -1028,6 +1030,7 @@ AhDecodeException ( { AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo); } + Status++; } while (ExceptionInfo); diff --git a/source/tools/acpinames/acpinames.h b/source/tools/acpinames/acpinames.h index 62d006974f92..8abf41386a33 100644 --- a/source/tools/acpinames/acpinames.h +++ b/source/tools/acpinames/acpinames.h @@ -48,11 +48,19 @@ #include "accommon.h" #include "acapps.h" #include "acutils.h" -#include "../acpiexec/aecommon.h" +#include "acnamesp.h" +#include "actables.h" +#include "acinterp.h" #include <stdio.h> #define ACPI_MAX_INIT_TABLES (32) extern BOOLEAN AcpiGbl_NsLoadOnly; + + +ACPI_STATUS +AnBuildLocalTables ( + ACPI_NEW_TABLE_DESC *TableList); + #endif diff --git a/source/tools/acpinames/anmain.c b/source/tools/acpinames/anmain.c index a613ac2613c3..8b0e0220aa01 100644 --- a/source/tools/acpinames/anmain.c +++ b/source/tools/acpinames/anmain.c @@ -43,6 +43,7 @@ #include "acpinames.h" #include "actables.h" +#include "errno.h" #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("anmain") @@ -51,8 +52,9 @@ /* Local prototypes */ static int -NsDumpEntireNamespace ( - UINT32 TableCount); +AnDumpEntireNamespace ( + ACPI_NEW_TABLE_DESC *ListHead); + /* * Main routine for the ACPI user-space namespace utility. @@ -65,8 +67,7 @@ NsDumpEntireNamespace ( * Windows: The setargv.obj module must be linked in to automatically * expand wildcards. */ -static AE_TABLE_DESC *AeTableListHead = NULL; -BOOLEAN AcpiGbl_NsLoadOnly = FALSE; +BOOLEAN AcpiGbl_NsLoadOnly = FALSE; #define AN_UTILITY_NAME "ACPI Namespace Dump Utility" @@ -100,7 +101,103 @@ usage ( /****************************************************************************** * - * FUNCTION: NsDumpEntireNamespace + * FUNCTION: main + * + * PARAMETERS: argc, argv + * + * RETURN: Status (pass/fail) + * + * DESCRIPTION: Main routine for NsDump utility + * + *****************************************************************************/ + +int ACPI_SYSTEM_XFACE +main ( + int argc, + char **argv) +{ + ACPI_NEW_TABLE_DESC *ListHead = NULL; + ACPI_STATUS Status; + int j; + + + ACPI_DEBUG_INITIALIZE (); /* For debug version only */ + + /* Init debug globals and ACPICA */ + + AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; + AcpiDbgLayer = 0xFFFFFFFF; + + Status = AcpiInitializeSubsystem (); + ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + + printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); + if (argc < 2) + { + usage (); + return (0); + } + + /* Get the command line options */ + + while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) + { + case 'l': + + AcpiGbl_NsLoadOnly = TRUE; + break; + + case 'v': /* -v: (Version): signon already emitted, just exit */ + + return (0); + + case 'x': + + AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); + printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); + break; + + case '?': + case 'h': + default: + + usage(); + return (0); + } + + /* Get each of the ACPI table files on the command line */ + + while (argv[AcpiGbl_Optind]) + { + /* Get all ACPI AML tables in this file */ + + Status = AcpiAcGetAllTablesFromFile (argv[AcpiGbl_Optind], + ACPI_GET_ONLY_AML_TABLES, &ListHead); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + + AcpiGbl_Optind++; + } + + printf ("\n"); + + /* + * The next argument is the filename for the DSDT or SSDT. + * Open the file, build namespace and dump it. + */ + return (AnDumpEntireNamespace (ListHead)); +} + + +/****************************************************************************** + * + * FUNCTION: AnDumpEntireNamespace * * PARAMETERS: AmlFilename - Filename for DSDT or SSDT AML table * @@ -112,8 +209,8 @@ usage ( *****************************************************************************/ static int -NsDumpEntireNamespace ( - UINT32 TableCount) +AnDumpEntireNamespace ( + ACPI_NEW_TABLE_DESC *ListHead) { ACPI_STATUS Status; ACPI_HANDLE Handle; @@ -123,7 +220,7 @@ NsDumpEntireNamespace ( * Build a local XSDT with all tables. Normally, here is where the * RSDP search is performed to find the ACPI tables */ - Status = AeBuildLocalTables (TableCount, AeTableListHead); + Status = AnBuildLocalTables (ListHead); if (ACPI_FAILURE (Status)) { return (-1); @@ -168,10 +265,10 @@ NsDumpEntireNamespace ( * hardware or event manager code underneath. */ Status = AcpiEnableSubsystem ( - ACPI_NO_ACPI_ENABLE | - ACPI_NO_ADDRESS_SPACE_INIT | - ACPI_NO_EVENT_INIT | - ACPI_NO_HANDLER_INIT); + ACPI_NO_ACPI_ENABLE | + ACPI_NO_ADDRESS_SPACE_INIT | + ACPI_NO_EVENT_INIT | + ACPI_NO_HANDLER_INIT); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", @@ -180,9 +277,9 @@ NsDumpEntireNamespace ( } Status = AcpiInitializeObjects ( - ACPI_NO_ADDRESS_SPACE_INIT | - ACPI_NO_DEVICE_INIT | - ACPI_NO_EVENT_INIT); + ACPI_NO_ADDRESS_SPACE_INIT | + ACPI_NO_DEVICE_INIT | + ACPI_NO_EVENT_INIT); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", @@ -195,137 +292,14 @@ NsDumpEntireNamespace ( */ AcpiOsPrintf ("\nACPI Namespace:\n"); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, ACPI_UINT32_MAX, - ACPI_OWNER_ID_MAX, AcpiGbl_RootNode); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, + ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode); /* Example: get a handle to the _GPE scope */ Status = AcpiGetHandle (NULL, "\\_GPE", &Handle); - AE_CHECK_OK (AcpiGetHandle, Status); + ACPI_CHECK_OK (AcpiGetHandle, Status); return (0); } - - -/****************************************************************************** - * - * FUNCTION: main - * - * PARAMETERS: argc, argv - * - * RETURN: Status (pass/fail) - * - * DESCRIPTION: Main routine for NsDump utility - * - *****************************************************************************/ - -int ACPI_SYSTEM_XFACE -main ( - int argc, - char **argv) -{ - AE_TABLE_DESC *TableDesc; - ACPI_TABLE_HEADER *Table = NULL; - ACPI_STATUS Status; - UINT32 TableCount; - int j; - - - ACPI_DEBUG_INITIALIZE (); /* For debug version only */ - - /* Init debug globals and ACPICA */ - - AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; - AcpiDbgLayer = 0xFFFFFFFF; - - Status = AcpiInitializeSubsystem (); - AE_CHECK_OK (AcpiInitializeSubsystem, Status); - if (ACPI_FAILURE (Status)) - { - return (-1); - } - - printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); - if (argc < 2) - { - usage (); - return (0); - } - - /* Get the command line options */ - - while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) - { - case 'l': - - AcpiGbl_NsLoadOnly = TRUE; - break; - - case 'v': /* -v: (Version): signon already emitted, just exit */ - - return (0); - - case 'x': - - AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); - printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); - break; - - case '?': - case 'h': - default: - - usage(); - return (0); - } - - TableCount = 0; - - /* Get each of the ACPI table files on the command line */ - - while (argv[AcpiGbl_Optind]) - { - /* Get one entire table */ - - Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table); - if (ACPI_FAILURE (Status)) - { - fprintf (stderr, "**** Could not get table from file %s, %s\n", - argv[AcpiGbl_Optind], AcpiFormatException (Status)); - return (-1); - } - - /* Ignore non-AML tables, we can't use them. Except for an FADT */ - - if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && - !AcpiUtIsAmlTable (Table)) - { - fprintf (stderr, " %s: [%4.4s] is not an AML table - ignoring\n", - argv[AcpiGbl_Optind], Table->Signature); - - AcpiOsFree (Table); - } - else - { - /* Allocate and link a table descriptor */ - - TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); - TableDesc->Table = Table; - TableDesc->Next = AeTableListHead; - AeTableListHead = TableDesc; - - TableCount++; - } - - AcpiGbl_Optind++; - } - - printf ("\n"); - - /* - * The next argument is the filename for the DSDT or SSDT. - * Open the file, build namespace and dump it. - */ - return (NsDumpEntireNamespace (TableCount)); -} diff --git a/source/tools/acpinames/antables.c b/source/tools/acpinames/antables.c index 1dbf692992cf..300d521788ba 100644 --- a/source/tools/acpinames/antables.c +++ b/source/tools/acpinames/antables.c @@ -49,7 +49,7 @@ /* Local prototypes */ static void -AeInitializeTableHeader ( +AnInitializeTableHeader ( ACPI_TABLE_HEADER *Header, char *Signature, UINT32 Length); @@ -79,7 +79,7 @@ static ACPI_TABLE_XSDT *LocalXSDT; /****************************************************************************** * - * FUNCTION: AeInitializeTableHeader + * FUNCTION: AnInitializeTableHeader * * PARAMETERS: Header - A valid standard ACPI table header * Signature - Signature to insert @@ -92,7 +92,7 @@ static ACPI_TABLE_XSDT *LocalXSDT; *****************************************************************************/ static void -AeInitializeTableHeader ( +AnInitializeTableHeader ( ACPI_TABLE_HEADER *Header, char *Signature, UINT32 Length) @@ -117,7 +117,7 @@ AeInitializeTableHeader ( /****************************************************************************** * - * FUNCTION: AeBuildLocalTables + * FUNCTION: AnBuildLocalTables * * PARAMETERS: TableCount - Number of tables on the command line * TableList - List of actual tables from files @@ -130,13 +130,13 @@ AeInitializeTableHeader ( *****************************************************************************/ ACPI_STATUS -AeBuildLocalTables ( - UINT32 TableCount, - AE_TABLE_DESC *TableList) +AnBuildLocalTables ( + ACPI_NEW_TABLE_DESC *TableList) { + UINT32 TableCount = 0; ACPI_PHYSICAL_ADDRESS DsdtAddress = 0; UINT32 XsdtSize; - AE_TABLE_DESC *NextTable; + ACPI_NEW_TABLE_DESC *NextTable; UINT32 NextIndex; ACPI_TABLE_FADT *ExternalFadt = NULL; @@ -149,11 +149,12 @@ AeBuildLocalTables ( NextTable = TableList; while (NextTable) { - if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) || - ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) + if (!ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) { - TableCount--; + TableCount++; } + NextTable = NextTable->Next; } @@ -199,8 +200,10 @@ AeBuildLocalTables ( } else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) { - ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table); - LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (NextTable->Table); + ExternalFadt = + ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table); + LocalXSDT->TableOffsetEntry[0] = + ACPI_PTR_TO_PHYSADDR (NextTable->Table); } else { @@ -226,7 +229,7 @@ AeBuildLocalTables ( /* Set checksums for both XSDT and RSDP */ - AeInitializeTableHeader ((void *) LocalXSDT, ACPI_SIG_XSDT, XsdtSize); + AnInitializeTableHeader ((void *) LocalXSDT, ACPI_SIG_XSDT, XsdtSize); LocalRSDP.Checksum = 0; LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ( @@ -317,7 +320,7 @@ AeBuildLocalTables ( ACPI_MUL_8 (LocalFADT.Pm1EventLength); } - AeInitializeTableHeader ((void *) &LocalFADT, + AnInitializeTableHeader ((void *) &LocalFADT, ACPI_SIG_FADT, sizeof (ACPI_TABLE_FADT)); /* Build a FACS */ diff --git a/source/tools/acpisrc/ascase.c b/source/tools/acpisrc/ascase.c index 53e61ad7ad4f..9c33362f5a82 100644 --- a/source/tools/acpisrc/ascase.c +++ b/source/tools/acpisrc/ascase.c @@ -241,6 +241,7 @@ AsMixedCaseToUnderscores ( SubBuffer++; } + SubBuffer++; continue; } @@ -260,6 +261,7 @@ AsMixedCaseToUnderscores ( LineNumber, Filename); return; } + continue; } @@ -535,6 +537,7 @@ AsLowerCaseIdentifiers ( SubBuffer++; break; } + SubBuffer++; } } diff --git a/source/tools/acpisrc/asconvrt.c b/source/tools/acpisrc/asconvrt.c index 5a82167c13af..a277264b96d2 100644 --- a/source/tools/acpisrc/asconvrt.c +++ b/source/tools/acpisrc/asconvrt.c @@ -252,6 +252,7 @@ AsMatchValidToken ( { SubBuffer++; } + SubBuffer++; continue; } @@ -283,6 +284,7 @@ AsMatchValidToken ( { SubBuffer++; } + SubBuffer++; } @@ -1154,6 +1156,7 @@ AsTabify8 ( LastLineTabCount = TabCount; TabCount = 0; } + FirstNonBlank = NULL; LastLineColumnStart = ThisColumnStart; SubBuffer++; @@ -1190,6 +1193,7 @@ AsTabify8 ( LastLineTabCount = TabCount; TabCount = 0; } + FirstNonBlank = NULL; LastLineColumnStart = ThisColumnStart; } @@ -1208,6 +1212,7 @@ AsTabify8 ( { return; } + SpaceCount = 0; } @@ -1396,8 +1401,8 @@ AsCountSourceLines ( /* Find end of comment */ while (SubBuffer[0] && SubBuffer[1] && - !(((SubBuffer[0] == '*') && - (SubBuffer[1] == '/')))) + !(((SubBuffer[0] == '*') && + (SubBuffer[1] == '/')))) { if (SubBuffer[0] == '\n') { diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index cd1843057085..c59f9d7ff471 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -123,7 +123,7 @@ AsDoWildcard ( /* If we actually have a dir, process the subtree */ if (!AsCheckForDirectory (SourcePath, TargetPath, Filename, - &SourceDirPath, &TargetDirPath)) + &SourceDirPath, &TargetDirPath)) { VERBOSE_PRINT (("Subdirectory: %s\n", Filename)); @@ -140,7 +140,7 @@ AsDoWildcard ( VERBOSE_PRINT (("File: %s\n", Filename)); AsProcessOneFile (ConversionTable, SourcePath, TargetPath, - MaxPathLength, Filename, FileType); + MaxPathLength, Filename, FileType); break; default: @@ -197,32 +197,32 @@ AsProcessTree ( /* Do the C source files */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_SOURCE, "*.c"); + FILE_TYPE_SOURCE, "*.c"); /* Do the C header files */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_HEADER, "*.h"); + FILE_TYPE_HEADER, "*.h"); /* Do the Lex file(s) */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_SOURCE, "*.l"); + FILE_TYPE_SOURCE, "*.l"); /* Do the yacc file(s) */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_SOURCE, "*.y"); + FILE_TYPE_SOURCE, "*.y"); /* Do any ASL files */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_HEADER, "*.asl"); + FILE_TYPE_HEADER, "*.asl"); /* Do any subdirectories */ AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength, - FILE_TYPE_DIRECTORY, "*"); + FILE_TYPE_DIRECTORY, "*"); return (0); } @@ -259,6 +259,7 @@ AsDetectLoneLineFeeds ( { LfCount++; } + LineCount++; } i++; @@ -278,6 +279,7 @@ AsDetectLoneLineFeeds ( { printf ("%s: %u lone linefeeds in file\n", Filename, LfCount); } + return (TRUE); } @@ -365,7 +367,7 @@ AsConvertFile ( for (i = 0; ConversionTable->LowerCaseTable[i].Identifier; i++) { AsLowerCaseString (ConversionTable->LowerCaseTable[i].Identifier, - FileBuffer); + FileBuffer); } } @@ -376,7 +378,7 @@ AsConvertFile ( for (i = 0; StringTable[i].Target; i++) { AsReplaceString (StringTable[i].Target, StringTable[i].Replacement, - StringTable[i].Type, FileBuffer); + StringTable[i].Type, FileBuffer); } } @@ -410,7 +412,8 @@ AsConvertFile ( { for (i = 0; StructTable[i].Identifier; i++) { - AsInsertPrefix (FileBuffer, StructTable[i].Identifier, StructTable[i].Type); + AsInsertPrefix (FileBuffer, StructTable[i].Identifier, + StructTable[i].Type); } } @@ -610,7 +613,8 @@ AsProcessOneFile ( { /* Generate the target pathname and write the file */ - OutPathname = calloc (MaxPathLength + strlen (Filename) + 2 + strlen (TargetPath), 1); + OutPathname = calloc (MaxPathLength + + strlen (Filename) + 2 + strlen (TargetPath), 1); if (!OutPathname) { printf ("Could not allocate buffer for file pathnames\n"); diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 4da3cdd5c5a3..40d0cd47853d 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -221,7 +221,8 @@ AsDisplayStats ( if ((Gbl_CommentLines + Gbl_NonAnsiComments) > 0) { printf ("%8.1f Ratio of code to comments\n", - ((float) Gbl_SourceLines / (float) (Gbl_CommentLines + Gbl_NonAnsiComments))); + ((float) Gbl_SourceLines / + (float) (Gbl_CommentLines + Gbl_NonAnsiComments))); } if (!Gbl_TotalLines) @@ -456,15 +457,18 @@ main ( if (strstr (SourcePath, ".h")) { - AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_HEADER); + AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, + SourcePath, FILE_TYPE_HEADER); } else if (strstr (SourcePath, ".c")) { - AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_SOURCE); + AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, + SourcePath, FILE_TYPE_SOURCE); } else if (strstr (SourcePath, ".patch")) { - AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_PATCH); + AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, + SourcePath, FILE_TYPE_PATCH); } else { @@ -475,6 +479,5 @@ main ( /* Always display final summary and stats */ AsDisplayStats (); - return (0); } diff --git a/source/tools/acpisrc/asremove.c b/source/tools/acpisrc/asremove.c index 9a4e57c2fae0..358430a482b5 100644 --- a/source/tools/acpisrc/asremove.c +++ b/source/tools/acpisrc/asremove.c @@ -78,7 +78,6 @@ AsRemoveStatement ( SubBuffer = Buffer; SubString = Buffer; - while (SubString) { SubString = strstr (SubBuffer, Keyword); @@ -160,7 +159,6 @@ AsRemoveConditionalCompile ( SubBuffer = Buffer; SubString = Buffer; - while (SubString) { SubBuffer = strstr (SubString, Keyword); @@ -225,6 +223,7 @@ AsRemoveConditionalCompile ( { SubString--; } + SubString++; /* Find the "#ifxxxx" */ @@ -327,7 +326,6 @@ AsRemoveMacro ( SubBuffer = Buffer; SubString = Buffer; - while (SubString) { SubString = strstr (SubBuffer, Keyword); @@ -397,7 +395,6 @@ AsRemoveLine ( SubBuffer = Buffer; SubString = Buffer; - while (SubString) { SubString = strstr (SubBuffer, Keyword); @@ -451,7 +448,6 @@ AsReduceTypedefs ( SubBuffer = Buffer; SubString = Buffer; - while (SubString) { SubString = strstr (SubBuffer, Keyword); @@ -555,6 +551,7 @@ AsRemoveEmptyBlocks ( EmptyBlock = FALSE; break; } + SubBuffer++; } @@ -664,6 +661,7 @@ AsCleanupSpecialMacro ( { SubString++; } + SubString++; NestLevel = 1; @@ -697,6 +695,7 @@ SkipLine: { NewLine = TRUE; } + SubString++; } diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 8781c80e2595..494df3ce7d37 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -276,6 +276,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_NAMESTRING_INFO", SRC_TYPE_STRUCT}, {"ACPI_NATIVE_INT", SRC_TYPE_SIMPLE}, {"ACPI_NATIVE_UINT", SRC_TYPE_SIMPLE}, + {"ACPI_NEW_TABLE_DESC", SRC_TYPE_STRUCT}, {"ACPI_NOTIFY_HANDLER", SRC_TYPE_SIMPLE}, {"ACPI_NOTIFY_INFO", SRC_TYPE_STRUCT}, {"ACPI_NS_SEARCH_DATA", SRC_TYPE_STRUCT}, @@ -346,6 +347,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_PREDEFINED_DATA", SRC_TYPE_STRUCT}, {"ACPI_PREDEFINED_INFO", SRC_TYPE_UNION}, {"ACPI_PREDEFINED_NAMES", SRC_TYPE_STRUCT}, + {"ACPI_PRUNE_INFO", SRC_TYPE_STRUCT}, {"ACPI_PSCOPE_STATE", SRC_TYPE_STRUCT}, {"ACPI_RASF_PARAMETER_BLOCK", SRC_TYPE_STRUCT}, {"ACPI_RASF_PATROL_SCRUB_PARAMETER", SRC_TYPE_STRUCT}, @@ -484,7 +486,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"APIC_HEADER", SRC_TYPE_STRUCT}, {"AE_DEBUG_REGIONS", SRC_TYPE_STRUCT}, {"AE_REGION", SRC_TYPE_STRUCT}, - {"AE_TABLE_DESC", SRC_TYPE_STRUCT}, {"ASL_ANALYSIS_WALK_INFO", SRC_TYPE_STRUCT}, {"ASL_ERROR_MSG", SRC_TYPE_STRUCT}, {"ASL_ERROR_MSG", SRC_TYPE_STRUCT}, @@ -796,8 +797,8 @@ ACPI_IDENTIFIER_TABLE LinuxSpecialMacros[] = { }; -ACPI_CONVERSION_TABLE LinuxConversionTable = { - +ACPI_CONVERSION_TABLE LinuxConversionTable = +{ DualLicenseHeader, FLG_NO_CARRIAGE_RETURNS | FLG_LOWERCASE_DIRNAMES, @@ -849,8 +850,8 @@ ACPI_CONVERSION_TABLE LinuxConversionTable = { * ******************************************************************************/ -ACPI_CONVERSION_TABLE CleanupConversionTable = { - +ACPI_CONVERSION_TABLE CleanupConversionTable = +{ NULL, FLG_DEFAULT_FLAGS, NULL, @@ -888,8 +889,8 @@ ACPI_CONVERSION_TABLE CleanupConversionTable = { }; -ACPI_CONVERSION_TABLE StatsConversionTable = { - +ACPI_CONVERSION_TABLE StatsConversionTable = +{ NULL, FLG_NO_FILE_OUTPUT, NULL, @@ -935,8 +936,8 @@ ACPI_CONVERSION_TABLE StatsConversionTable = { * ******************************************************************************/ -ACPI_CONVERSION_TABLE LicenseConversionTable = { - +ACPI_CONVERSION_TABLE LicenseConversionTable = +{ DualLicenseHeader, FLG_DEFAULT_FLAGS, NULL, @@ -982,9 +983,8 @@ ACPI_CONVERSION_TABLE LicenseConversionTable = { * ******************************************************************************/ -ACPI_STRING_TABLE CustomReplacements[] = { - - +ACPI_STRING_TABLE CustomReplacements[] = +{ {"(c) 1999 - 2014", "(c) 1999 - 2015", REPLACE_WHOLE_WORD}, /* Main ACPICA source */ {"(c) 2006 - 2014", "(c) 2006 - 2015", REPLACE_WHOLE_WORD}, /* Test suites */ @@ -1037,8 +1037,8 @@ ACPI_STRING_TABLE CustomReplacements[] = { }; -ACPI_CONVERSION_TABLE CustomConversionTable = { - +ACPI_CONVERSION_TABLE CustomConversionTable = +{ NULL, FLG_DEFAULT_FLAGS, NULL, @@ -1083,8 +1083,8 @@ ACPI_CONVERSION_TABLE CustomConversionTable = { * ******************************************************************************/ -ACPI_CONVERSION_TABLE IndentConversionTable = { - +ACPI_CONVERSION_TABLE IndentConversionTable = +{ NULL, FLG_NO_CARRIAGE_RETURNS, diff --git a/source/tools/acpixtract/acpixtract.c b/source/tools/acpixtract/acpixtract.c index 373c9cd95bc7..4641c712a30e 100644 --- a/source/tools/acpixtract/acpixtract.c +++ b/source/tools/acpixtract/acpixtract.c @@ -41,579 +41,307 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include "acpi.h" -#include "accommon.h" -#include "acapps.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -/* Local prototypes */ - -static void -AxCheckAscii ( - char *Name, - int Count); - -static void -AxNormalizeSignature ( - char *Signature); - -static unsigned int -AxGetNextInstance ( - char *InputPathname, - char *Signature); - -static size_t -AxGetTableHeader ( - FILE *InputFile, - unsigned char *OutputData); - -static unsigned int -AxCountTableInstances ( - char *InputPathname, - char *Signature); - -int -AxExtractTables ( - char *InputPathname, - char *Signature, - unsigned int MinimumInstances); - -int -AxListTables ( - char *InputPathname); - -static size_t -AxConvertLine ( - char *InputLine, - unsigned char *OutputData); - -static int -AxIsEmptyLine ( - char *Buffer); - -typedef struct AxTableInfo -{ - UINT32 Signature; - unsigned int Instances; - unsigned int NextInstance; - struct AxTableInfo *Next; - -} AX_TABLE_INFO; - -/* Extraction states */ - -#define AX_STATE_FIND_HEADER 0 -#define AX_STATE_EXTRACT_DATA 1 - -/* Miscellaneous constants */ - -#define AX_LINE_BUFFER_SIZE 256 -#define AX_MIN_TABLE_NAME_LENGTH 6 /* strlen ("DSDT @") */ - - -static AX_TABLE_INFO *AxTableListHead = NULL; -static char Filename[16]; -static unsigned char Data[16]; -static char LineBuffer[AX_LINE_BUFFER_SIZE]; -static char HeaderBuffer[AX_LINE_BUFFER_SIZE]; -static char InstanceBuffer[AX_LINE_BUFFER_SIZE]; - - -/******************************************************************************* - * - * FUNCTION: AxCheckAscii - * - * PARAMETERS: Name - Ascii string, at least as long as Count - * Count - Number of characters to check - * - * RETURN: None - * - * DESCRIPTION: Ensure that the requested number of characters are printable - * Ascii characters. Sets non-printable and null chars to <space>. - * - ******************************************************************************/ - -static void -AxCheckAscii ( - char *Name, - int Count) -{ - int i; - - - for (i = 0; i < Count; i++) - { - if (!Name[i] || !isprint ((int) Name[i])) - { - Name[i] = ' '; - } - } -} +#include "acpixtract.h" /****************************************************************************** * - * FUNCTION: AxIsEmptyLine + * FUNCTION: AxExtractTables * - * PARAMETERS: Buffer - Line from input file + * PARAMETERS: InputPathname - Filename for input acpidump file + * Signature - Requested ACPI signature to extract. + * NULL means extract ALL tables. + * MinimumInstances - Min instances that are acceptable * - * RETURN: TRUE if line is empty (zero or more blanks only) + * RETURN: Status * - * DESCRIPTION: Determine if an input line is empty. + * DESCRIPTION: Convert text ACPI tables to binary * ******************************************************************************/ -static int -AxIsEmptyLine ( - char *Buffer) +int +AxExtractTables ( + char *InputPathname, + char *Signature, + unsigned int MinimumInstances) { + FILE *InputFile; + FILE *OutputFile = NULL; + unsigned int BytesConverted; + unsigned int ThisTableBytesWritten = 0; + unsigned int FoundTable = 0; + unsigned int Instances = 0; + unsigned int ThisInstance; + char ThisSignature[4]; + int Status = 0; + unsigned int State = AX_STATE_FIND_HEADER; - /* Skip all spaces */ - - while (*Buffer == ' ') - { - Buffer++; - } - /* If end-of-line, this line is empty */ + /* Open input in text mode, output is in binary mode */ - if (*Buffer == '\n') + InputFile = fopen (InputPathname, "rt"); + if (!InputFile) { - return (1); + printf ("Could not open input file %s\n", InputPathname); + return (-1); } - return (0); -} - - -/******************************************************************************* - * - * FUNCTION: AxNormalizeSignature - * - * PARAMETERS: Name - Ascii string containing an ACPI signature - * - * RETURN: None - * - * DESCRIPTION: Change "RSD PTR" to "RSDP" - * - ******************************************************************************/ - -static void -AxNormalizeSignature ( - char *Signature) -{ - - if (!strncmp (Signature, "RSD ", 4)) + if (Signature) { - Signature[3] = 'P'; - } -} - + /* Are there enough instances of the table to continue? */ -/****************************************************************************** - * - * FUNCTION: AxConvertLine - * - * PARAMETERS: InputLine - One line from the input acpidump file - * OutputData - Where the converted data is returned - * - * RETURN: The number of bytes actually converted - * - * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes) - * - ******************************************************************************/ + AxNormalizeSignature (Signature); -static size_t -AxConvertLine ( - char *InputLine, - unsigned char *OutputData) -{ - char *End; - int BytesConverted; - int Converted[16]; - int i; + Instances = AxCountTableInstances (InputPathname, Signature); + if (Instances < MinimumInstances) + { + printf ("Table [%s] was not found in %s\n", + Signature, InputPathname); + fclose (InputFile); + return (-1); + } + if (Instances == 0) + { + fclose (InputFile); + return (-1); + } + } - /* Terminate the input line at the end of the actual data (for sscanf) */ + /* Convert all instances of the table to binary */ - End = strstr (InputLine + 2, " "); - if (!End) + while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile)) { - return (0); /* Don't understand the format */ - } - *End = 0; - - /* - * Convert one line of table data, of the form: - * <offset>: <up to 16 bytes of hex data> <ASCII representation> <newline> - * - * Example: - * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........ - */ - BytesConverted = sscanf (InputLine, - "%*s %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", - &Converted[0], &Converted[1], &Converted[2], &Converted[3], - &Converted[4], &Converted[5], &Converted[6], &Converted[7], - &Converted[8], &Converted[9], &Converted[10], &Converted[11], - &Converted[12], &Converted[13], &Converted[14], &Converted[15]); - - /* Pack converted data into a byte array */ - - for (i = 0; i < BytesConverted; i++) - { - OutputData[i] = (unsigned char) Converted[i]; - } + switch (State) + { + case AX_STATE_FIND_HEADER: - return ((size_t) BytesConverted); -} + if (!AxIsDataBlockHeader ()) + { + continue; + } + ACPI_MOVE_NAME (ThisSignature, Gbl_LineBuffer); + if (Signature) + { + /* Ignore signatures that don't match */ -/****************************************************************************** - * - * FUNCTION: AxGetTableHeader - * - * PARAMETERS: InputFile - Handle for the input acpidump file - * OutputData - Where the table header is returned - * - * RETURN: The actual number of bytes converted - * - * DESCRIPTION: Extract and convert an ACPI table header - * - ******************************************************************************/ + if (!ACPI_COMPARE_NAME (ThisSignature, Signature)) + { + continue; + } + } -static size_t -AxGetTableHeader ( - FILE *InputFile, - unsigned char *OutputData) -{ - size_t BytesConverted; - size_t TotalConverted = 0; - int i; + /* + * Get the instance number for this signature. Only the + * SSDT and PSDT tables can have multiple instances. + */ + ThisInstance = AxGetNextInstance (InputPathname, ThisSignature); + /* Build an output filename and create/open the output file */ - /* Get the full 36 byte ACPI table header, requires 3 input text lines */ + if (ThisInstance > 0) + { + /* Add instance number to the output filename */ - for (i = 0; i < 3; i++) - { - if (!fgets (HeaderBuffer, AX_LINE_BUFFER_SIZE, InputFile)) - { - return (TotalConverted); - } + sprintf (Gbl_OutputFilename, "%4.4s%u.dat", + ThisSignature, ThisInstance); + } + else + { + sprintf (Gbl_OutputFilename, "%4.4s.dat", + ThisSignature); + } - BytesConverted = AxConvertLine (HeaderBuffer, OutputData); - TotalConverted += BytesConverted; - OutputData += 16; + AcpiUtStrlwr (Gbl_OutputFilename); + OutputFile = fopen (Gbl_OutputFilename, "w+b"); + if (!OutputFile) + { + printf ("Could not open output file %s\n", + Gbl_OutputFilename); + fclose (InputFile); + return (-1); + } - if (BytesConverted != 16) - { - return (TotalConverted); - } - } + /* + * Toss this block header of the form "<sig> @ <addr>" line + * and move on to the actual data block + */ + Gbl_TableCount++; + FoundTable = 1; + ThisTableBytesWritten = 0; + State = AX_STATE_EXTRACT_DATA; + continue; - return (TotalConverted); -} + case AX_STATE_EXTRACT_DATA: + /* Empty line or non-data line terminates the data block */ -/****************************************************************************** - * - * FUNCTION: AxCountTableInstances - * - * PARAMETERS: InputPathname - Filename for acpidump file - * Signature - Requested signature to count - * - * RETURN: The number of instances of the signature - * - * DESCRIPTION: Count the instances of tables with the given signature within - * the input acpidump file. - * - ******************************************************************************/ + BytesConverted = AxProcessOneTextLine ( + OutputFile, ThisSignature, ThisTableBytesWritten); + switch (BytesConverted) + { + case 0: -static unsigned int -AxCountTableInstances ( - char *InputPathname, - char *Signature) -{ - FILE *InputFile; - unsigned int Instances = 0; + State = AX_STATE_FIND_HEADER; /* No more data block lines */ + continue; + case -1: - InputFile = fopen (InputPathname, "rt"); - if (!InputFile) - { - printf ("Could not open file %s\n", InputPathname); - return (0); - } + goto CleanupAndExit; /* There was a write error */ - /* Count the number of instances of this signature */ + default: /* Normal case, get next line */ - while (fgets (InstanceBuffer, AX_LINE_BUFFER_SIZE, InputFile)) - { - /* Ignore empty lines and lines that start with a space */ + ThisTableBytesWritten += BytesConverted; + continue; + } - if (AxIsEmptyLine (InstanceBuffer) || - (InstanceBuffer[0] == ' ')) - { - continue; - } + default: - AxNormalizeSignature (InstanceBuffer); - if (ACPI_COMPARE_NAME (InstanceBuffer, Signature)) - { - Instances++; + Status = -1; + goto CleanupAndExit; } } - fclose (InputFile); - return (Instances); -} - - -/****************************************************************************** - * - * FUNCTION: AxGetNextInstance - * - * PARAMETERS: InputPathname - Filename for acpidump file - * Signature - Requested ACPI signature - * - * RETURN: The next instance number for this signature. Zero if this - * is the first instance of this signature. - * - * DESCRIPTION: Get the next instance number of the specified table. If this - * is the first instance of the table, create a new instance - * block. Note: only SSDT and PSDT tables can have multiple - * instances. - * - ******************************************************************************/ + if (!FoundTable) + { + printf ("Table [%s] was not found in %s\n", + Signature, InputPathname); + } -static unsigned int -AxGetNextInstance ( - char *InputPathname, - char *Signature) -{ - AX_TABLE_INFO *Info; +CleanupAndExit: - Info = AxTableListHead; - while (Info) + if (State == AX_STATE_EXTRACT_DATA) { - if (*(UINT32 *) Signature == Info->Signature) - { - break; - } + /* Received an input file EOF while extracting data */ - Info = Info->Next; + printf (AX_TABLE_INFO_FORMAT, + ThisSignature, ThisTableBytesWritten, Gbl_OutputFilename); } - if (!Info) + if (Gbl_TableCount > 1) { - /* Signature not found, create new table info block */ - - Info = malloc (sizeof (AX_TABLE_INFO)); - if (!Info) - { - printf ("Could not allocate memory\n"); - exit (0); - } - - Info->Signature = *(UINT32 *) Signature; - Info->Instances = AxCountTableInstances (InputPathname, Signature); - Info->NextInstance = 1; - Info->Next = AxTableListHead; - AxTableListHead = Info; + printf ("\n%d binary ACPI tables extracted\n", + Gbl_TableCount); } - if (Info->Instances > 1) + if (OutputFile) { - return (Info->NextInstance++); + fclose (OutputFile); } - return (0); + fclose (InputFile); + return (Status); } /****************************************************************************** * - * FUNCTION: AxExtractTables + * FUNCTION: AxExtractToMultiAmlFile * - * PARAMETERS: InputPathname - Filename for acpidump file - * Signature - Requested ACPI signature to extract. - * NULL means extract ALL tables. - * MinimumInstances - Min instances that are acceptable + * PARAMETERS: InputPathname - Filename for input acpidump file * * RETURN: Status * - * DESCRIPTION: Convert text ACPI tables to binary + * DESCRIPTION: Convert all DSDT/SSDT tables to binary and append them all + * into a single output file. Used to simplify the loading of + * multiple/many SSDTs into a utility like acpiexec -- instead + * of creating many separate output files. * ******************************************************************************/ int -AxExtractTables ( - char *InputPathname, - char *Signature, - unsigned int MinimumInstances) +AxExtractToMultiAmlFile ( + char *InputPathname) { FILE *InputFile; - FILE *OutputFile = NULL; - size_t BytesWritten; - size_t TotalBytesWritten = 0; - size_t BytesConverted; - unsigned int State = AX_STATE_FIND_HEADER; - unsigned int FoundTable = 0; - unsigned int Instances = 0; - unsigned int ThisInstance; - char ThisSignature[4]; + FILE *OutputFile; int Status = 0; + unsigned int TotalBytesWritten = 0; + unsigned int ThisTableBytesWritten = 0; + unsigned int BytesConverted; + char ThisSignature[4]; + unsigned int State = AX_STATE_FIND_HEADER; - /* Open input in text mode, output is in binary mode */ + strcpy (Gbl_OutputFilename, AX_MULTI_TABLE_FILENAME); + + /* Open the input file in text mode */ InputFile = fopen (InputPathname, "rt"); if (!InputFile) { - printf ("Could not open file %s\n", InputPathname); + printf ("Could not open input file %s\n", InputPathname); return (-1); } - if (Signature) - { - /* Are there enough instances of the table to continue? */ - - AxNormalizeSignature (Signature); + /* Open the output file in binary mode */ - Instances = AxCountTableInstances (InputPathname, Signature); - if (Instances < MinimumInstances) - { - printf ("Table %s was not found in %s\n", Signature, InputPathname); - Status = -1; - goto CleanupAndExit; - } - - if (Instances == 0) - { - goto CleanupAndExit; - } + OutputFile = fopen (Gbl_OutputFilename, "w+b"); + if (!OutputFile) + { + printf ("Could not open output file %s\n", Gbl_OutputFilename); + fclose (InputFile); + return (-1); } - /* Convert all instances of the table to binary */ + /* Convert the DSDT and all SSDTs to binary */ - while (fgets (LineBuffer, AX_LINE_BUFFER_SIZE, InputFile)) + while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile)) { switch (State) { case AX_STATE_FIND_HEADER: - /* Ignore lines that are too short to be header lines */ - - if (strlen (LineBuffer) < AX_MIN_TABLE_NAME_LENGTH) + if (!AxIsDataBlockHeader ()) { continue; } - /* Ignore empty lines and lines that start with a space */ + ACPI_MOVE_NAME (ThisSignature, Gbl_LineBuffer); - if (AxIsEmptyLine (LineBuffer) || - (LineBuffer[0] == ' ')) - { - continue; - } + /* Only want DSDT and SSDTs */ - /* - * Ignore lines that are not of the form <sig> @ <addr>. - * Examples of lines that must be supported: - * - * DSDT @ 0x737e4000 - * XSDT @ 0x737f2fff - * RSD PTR @ 0xf6cd0 - * SSDT @ (nil) - */ - if (!strstr (LineBuffer, " @ ")) + if (!ACPI_COMPARE_NAME (ThisSignature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (ThisSignature, ACPI_SIG_SSDT)) { continue; } - AxNormalizeSignature (LineBuffer); - ACPI_MOVE_NAME (ThisSignature, LineBuffer); - - if (Signature) - { - /* Ignore signatures that don't match */ - - if (!ACPI_COMPARE_NAME (ThisSignature, Signature)) - { - continue; - } - } - /* - * Get the instance number for this signature. Only the - * SSDT and PSDT tables can have multiple instances. + * Toss this block header of the form "<sig> @ <addr>" line + * and move on to the actual data block */ - ThisInstance = AxGetNextInstance (InputPathname, ThisSignature); - - /* Build an output filename and create/open the output file */ - - if (ThisInstance > 0) - { - sprintf (Filename, "%4.4s%u.dat", ThisSignature, ThisInstance); - } - else - { - sprintf (Filename, "%4.4s.dat", ThisSignature); - } - - AcpiUtStrlwr (Filename); - OutputFile = fopen (Filename, "w+b"); - if (!OutputFile) - { - printf ("Could not open file %s\n", Filename); - Status = -1; - goto CleanupAndExit; - } - + Gbl_TableCount++; + ThisTableBytesWritten = 0; State = AX_STATE_EXTRACT_DATA; - TotalBytesWritten = 0; - FoundTable = 1; continue; case AX_STATE_EXTRACT_DATA: - /* Empty line or non-data line terminates the data */ + /* Empty line or non-data line terminates the data block */ - if (AxIsEmptyLine (LineBuffer) || - (LineBuffer[0] != ' ')) + BytesConverted = AxProcessOneTextLine ( + OutputFile, ThisSignature, ThisTableBytesWritten); + switch (BytesConverted) { - fclose (OutputFile); - OutputFile = NULL; - State = AX_STATE_FIND_HEADER; + case 0: - printf ("Acpi table [%4.4s] - %u bytes written to %s\n", - ThisSignature, (unsigned int) TotalBytesWritten, Filename); + State = AX_STATE_FIND_HEADER; /* No more data block lines */ continue; - } - /* Convert the ascii data (one line of text) to binary */ + case -1: - BytesConverted = AxConvertLine (LineBuffer, Data); + goto CleanupAndExit; /* There was a write error */ - /* Write the binary data */ + default: /* Normal case, get next line */ - BytesWritten = fwrite (Data, 1, BytesConverted, OutputFile); - if (BytesWritten != BytesConverted) - { - printf ("Error when writing file %s\n", Filename); - fclose (OutputFile); - OutputFile = NULL; - Status = -1; - goto CleanupAndExit; + ThisTableBytesWritten += BytesConverted; + TotalBytesWritten += BytesConverted; + continue; } - TotalBytesWritten += BytesConverted; - continue; - default: Status = -1; @@ -621,27 +349,22 @@ AxExtractTables ( } } - if (!FoundTable) - { - printf ("Table %s was not found in %s\n", Signature, InputPathname); - } - CleanupAndExit: - if (OutputFile) + if (State == AX_STATE_EXTRACT_DATA) { - fclose (OutputFile); - if (State == AX_STATE_EXTRACT_DATA) - { - /* Received an EOF while extracting data */ + /* Received an input file EOF or error while writing data */ - printf ("Acpi table [%4.4s] - %u bytes written to %s\n", - ThisSignature, (unsigned int) TotalBytesWritten, Filename); - } + printf (AX_TABLE_INFO_FORMAT, + ThisSignature, ThisTableBytesWritten, Gbl_OutputFilename); } + printf ("\n%d binary ACPI tables extracted and written to %s (%u bytes)\n", + Gbl_TableCount, Gbl_OutputFilename, TotalBytesWritten); + fclose (InputFile); + fclose (OutputFile); return (Status); } @@ -666,7 +389,6 @@ AxListTables ( FILE *InputFile; size_t HeaderSize; unsigned char Header[48]; - unsigned int TableCount = 0; ACPI_TABLE_HEADER *TableHeader = (ACPI_TABLE_HEADER *) (void *) Header; @@ -675,21 +397,21 @@ AxListTables ( InputFile = fopen (InputPathname, "rt"); if (!InputFile) { - printf ("Could not open file %s\n", InputPathname); + printf ("Could not open input file %s\n", InputPathname); return (-1); } /* Dump the headers for all tables found in the input file */ printf ("\nSignature Length Revision OemId OemTableId" - " OemRevision CompilerId CompilerRevision\n\n"); + " OemRevision CompilerId CompilerRevision\n\n"); - while (fgets (LineBuffer, AX_LINE_BUFFER_SIZE, InputFile)) + while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile)) { /* Ignore empty lines and lines that start with a space */ - if (AxIsEmptyLine (LineBuffer) || - (LineBuffer[0] == ' ')) + if (AxIsEmptyLine (Gbl_LineBuffer) || + (Gbl_LineBuffer[0] == ' ')) { continue; } @@ -707,8 +429,9 @@ AxListTables ( if (!strncmp (TableHeader->Signature, "RSD PTR ", 8)) { AxCheckAscii ((char *) &Header[9], 6); - printf ("%7.4s \"%6.6s\"\n", "RSDP", &Header[9]); - TableCount++; + printf ("%7.4s \"%6.6s\"\n", "RSDP", + &Header[9]); + Gbl_TableCount++; continue; } @@ -721,8 +444,9 @@ AxListTables ( /* Signature and Table length */ - TableCount++; - printf ("%7.4s 0x%8.8X", TableHeader->Signature, TableHeader->Length); + Gbl_TableCount++; + printf ("%7.4s 0x%8.8X", TableHeader->Signature, + TableHeader->Length); /* FACS has only signature and length */ @@ -738,13 +462,15 @@ AxListTables ( AxCheckAscii (TableHeader->OemTableId, 8); AxCheckAscii (TableHeader->AslCompilerId, 4); - printf (" 0x%2.2X \"%6.6s\" \"%8.8s\" 0x%8.8X \"%4.4s\" 0x%8.8X\n", + printf ( + " 0x%2.2X \"%6.6s\" \"%8.8s\" 0x%8.8X" + " \"%4.4s\" 0x%8.8X\n", TableHeader->Revision, TableHeader->OemId, TableHeader->OemTableId, TableHeader->OemRevision, TableHeader->AslCompilerId, TableHeader->AslCompilerRevision); } - printf ("\nFound %u ACPI tables\n", TableCount); + printf ("\nFound %u ACPI tables\n", Gbl_TableCount); fclose (InputFile); return (0); } diff --git a/source/tools/acpixtract/acpixtract.h b/source/tools/acpixtract/acpixtract.h new file mode 100644 index 000000000000..304693bbb113 --- /dev/null +++ b/source/tools/acpixtract/acpixtract.h @@ -0,0 +1,173 @@ +/****************************************************************************** + * + * Module Name: acpixtract.h - Include for acpixtract utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" +#include <stdio.h> + + +#undef ACPI_GLOBAL + +#ifdef DEFINE_ACPIXTRACT_GLOBALS +#define ACPI_GLOBAL(type,name) \ + extern type name; \ + type name + +#else +#define ACPI_GLOBAL(type,name) \ + extern type name +#endif + + +/* Options */ + +#define AX_EXTRACT_ALL 0 +#define AX_LIST_ALL 1 +#define AX_EXTRACT_SIGNATURE 2 +#define AX_EXTRACT_AML_TABLES 3 +#define AX_EXTRACT_MULTI_TABLE 4 + +#define AX_OPTIONAL_TABLES 0 +#define AX_REQUIRED_TABLE 1 + +#define AX_UTILITY_NAME "ACPI Binary Table Extraction Utility" +#define AX_SUPPORTED_OPTIONS "ahlms:v" +#define AX_MULTI_TABLE_FILENAME "amltables.dat" +#define AX_TABLE_INFO_FORMAT "Acpi table [%4.4s] - %7u bytes written to %s\n" + +/* Extraction states */ + +#define AX_STATE_FIND_HEADER 0 +#define AX_STATE_EXTRACT_DATA 1 + +/* Miscellaneous constants */ + +#define AX_LINE_BUFFER_SIZE 256 +#define AX_MIN_BLOCK_HEADER_LENGTH 6 /* strlen ("DSDT @") */ + + +typedef struct AxTableInfo +{ + UINT32 Signature; + unsigned int Instances; + unsigned int NextInstance; + struct AxTableInfo *Next; + +} AX_TABLE_INFO; + + +/* Globals */ + +ACPI_GLOBAL (char, Gbl_LineBuffer[AX_LINE_BUFFER_SIZE]); +ACPI_GLOBAL (char, Gbl_HeaderBuffer[AX_LINE_BUFFER_SIZE]); +ACPI_GLOBAL (char, Gbl_InstanceBuffer[AX_LINE_BUFFER_SIZE]); + +ACPI_GLOBAL (AX_TABLE_INFO, *Gbl_TableListHead); +ACPI_GLOBAL (char, Gbl_OutputFilename[32]); +ACPI_GLOBAL (unsigned char, Gbl_BinaryData[16]); +ACPI_GLOBAL (unsigned int, Gbl_TableCount); + +/* + * acpixtract.c + */ +int +AxExtractTables ( + char *InputPathname, + char *Signature, + unsigned int MinimumInstances); + +int +AxExtractToMultiAmlFile ( + char *InputPathname); + +int +AxListTables ( + char *InputPathname); + + +/* + * axutils.c + */ +size_t +AxGetTableHeader ( + FILE *InputFile, + unsigned char *OutputData); + +unsigned int +AxCountTableInstances ( + char *InputPathname, + char *Signature); + +unsigned int +AxGetNextInstance ( + char *InputPathname, + char *Signature); + +void +AxNormalizeSignature ( + char *Signature); + +void +AxCheckAscii ( + char *Name, + int Count); + +int +AxIsEmptyLine ( + char *Buffer); + +int +AxIsDataBlockHeader ( + void); + +long +AxProcessOneTextLine ( + FILE *OutputFile, + char *ThisSignature, + unsigned int ThisTableBytesWritten); + +size_t +AxConvertLine ( + char *InputLine, + unsigned char *OutputData); diff --git a/source/tools/acpixtract/axmain.c b/source/tools/acpixtract/axmain.c index 905787a3c725..3fa179940f4a 100644 --- a/source/tools/acpixtract/axmain.c +++ b/source/tools/acpixtract/axmain.c @@ -41,42 +41,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include "acpi.h" -#include "accommon.h" -#include "acapps.h" -#include <stdio.h> +#define DEFINE_ACPIXTRACT_GLOBALS +#include "acpixtract.h" +/* Local prototypes */ + static void DisplayUsage ( void); -int -AxExtractTables ( - char *InputPathname, - char *Signature, - unsigned int MinimumInstances); - -int -AxListTables ( - char *InputPathname); - - -/* Options */ - -#define AX_EXTRACT_ALL 0 -#define AX_LIST_ALL 1 -#define AX_EXTRACT_SIGNATURE 2 -#define AX_EXTRACT_AML_TABLES 3 - -static int AxAction = AX_EXTRACT_AML_TABLES; /* DSDT & SSDTs */ - -#define AX_OPTIONAL_TABLES 0 -#define AX_REQUIRED_TABLE 1 - -#define AX_UTILITY_NAME "ACPI Binary Table Extraction Utility" -#define AX_SUPPORTED_OPTIONS "ahls:v" - /****************************************************************************** * @@ -95,6 +69,7 @@ DisplayUsage ( ACPI_OPTION ("-a", "Extract all tables, not just DSDT/SSDT"); ACPI_OPTION ("-l", "List table summaries, do not extract"); + ACPI_OPTION ("-m", "Extract multiple DSDT/SSDTs to a single file"); ACPI_OPTION ("-s <signature>", "Extract all tables with <signature>"); ACPI_OPTION ("-v", "Display version information"); @@ -117,10 +92,15 @@ main ( char *argv[]) { char *Filename; + int AxAction; int Status; int j; + Gbl_TableCount = 0; + Gbl_TableListHead = NULL; + AxAction = AX_EXTRACT_AML_TABLES; /* Default: DSDT & SSDTs */ + ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AX_UTILITY_NAME)); @@ -145,6 +125,11 @@ main ( AxAction = AX_LIST_ALL; /* List tables only, do not extract */ break; + case 'm': + + AxAction = AX_EXTRACT_MULTI_TABLE; /* Make single file for all DSDT/SSDTs */ + break; + case 's': AxAction = AX_EXTRACT_SIGNATURE; /* Extract only tables with this sig */ @@ -179,6 +164,11 @@ main ( Status = AxExtractTables (Filename, NULL, AX_OPTIONAL_TABLES); break; + case AX_EXTRACT_MULTI_TABLE: + + Status = AxExtractToMultiAmlFile (Filename); + break; + case AX_LIST_ALL: Status = AxListTables (Filename); diff --git a/source/tools/acpixtract/axutils.c b/source/tools/acpixtract/axutils.c new file mode 100644 index 000000000000..eb7dd15139a2 --- /dev/null +++ b/source/tools/acpixtract/axutils.c @@ -0,0 +1,463 @@ +/****************************************************************************** + * + * Module Name: axutils - Utility functions for acpixtract tool. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpixtract.h" + + +/******************************************************************************* + * + * FUNCTION: AxCheckAscii + * + * PARAMETERS: Name - Ascii string, at least as long as Count + * Count - Number of characters to check + * + * RETURN: None + * + * DESCRIPTION: Ensure that the requested number of characters are printable + * Ascii characters. Sets non-printable and null chars to <space>. + * + ******************************************************************************/ + +void +AxCheckAscii ( + char *Name, + int Count) +{ + int i; + + + for (i = 0; i < Count; i++) + { + if (!Name[i] || !isprint ((int) Name[i])) + { + Name[i] = ' '; + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AxIsEmptyLine + * + * PARAMETERS: Buffer - Line from input file + * + * RETURN: TRUE if line is empty (zero or more blanks only) + * + * DESCRIPTION: Determine if an input line is empty. + * + ******************************************************************************/ + +int +AxIsEmptyLine ( + char *Buffer) +{ + + /* Skip all spaces */ + + while (*Buffer == ' ') + { + Buffer++; + } + + /* If end-of-line, this line is empty */ + + if (*Buffer == '\n') + { + return (1); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AxNormalizeSignature + * + * PARAMETERS: Name - Ascii string containing an ACPI signature + * + * RETURN: None + * + * DESCRIPTION: Change "RSD PTR" to "RSDP" + * + ******************************************************************************/ + +void +AxNormalizeSignature ( + char *Signature) +{ + + if (!strncmp (Signature, "RSD ", 4)) + { + Signature[3] = 'P'; + } +} + + +/****************************************************************************** + * + * FUNCTION: AxConvertLine + * + * PARAMETERS: InputLine - One line from the input acpidump file + * OutputData - Where the converted data is returned + * + * RETURN: The number of bytes actually converted + * + * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes) + * + ******************************************************************************/ + +size_t +AxConvertLine ( + char *InputLine, + unsigned char *OutputData) +{ + char *End; + int BytesConverted; + int Converted[16]; + int i; + + + /* Terminate the input line at the end of the actual data (for sscanf) */ + + End = strstr (InputLine + 2, " "); + if (!End) + { + return (0); /* Don't understand the format */ + } + *End = 0; + + /* + * Convert one line of table data, of the form: + * <offset>: <up to 16 bytes of hex data> <ASCII representation> <newline> + * + * Example: + * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........ + */ + BytesConverted = sscanf (InputLine, + "%*s %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", + &Converted[0], &Converted[1], &Converted[2], &Converted[3], + &Converted[4], &Converted[5], &Converted[6], &Converted[7], + &Converted[8], &Converted[9], &Converted[10], &Converted[11], + &Converted[12], &Converted[13], &Converted[14], &Converted[15]); + + /* Pack converted data into a byte array */ + + for (i = 0; i < BytesConverted; i++) + { + OutputData[i] = (unsigned char) Converted[i]; + } + + return ((size_t) BytesConverted); +} + + +/****************************************************************************** + * + * FUNCTION: AxGetTableHeader + * + * PARAMETERS: InputFile - Handle for the input acpidump file + * OutputData - Where the table header is returned + * + * RETURN: The actual number of bytes converted + * + * DESCRIPTION: Extract and convert an ACPI table header + * + ******************************************************************************/ + +size_t +AxGetTableHeader ( + FILE *InputFile, + unsigned char *OutputData) +{ + size_t BytesConverted; + size_t TotalConverted = 0; + int i; + + + /* Get the full 36 byte ACPI table header, requires 3 input text lines */ + + for (i = 0; i < 3; i++) + { + if (!fgets (Gbl_HeaderBuffer, AX_LINE_BUFFER_SIZE, InputFile)) + { + return (TotalConverted); + } + + BytesConverted = AxConvertLine (Gbl_HeaderBuffer, OutputData); + TotalConverted += BytesConverted; + OutputData += 16; + + if (BytesConverted != 16) + { + return (TotalConverted); + } + } + + return (TotalConverted); +} + + +/****************************************************************************** + * + * FUNCTION: AxCountTableInstances + * + * PARAMETERS: InputPathname - Filename for acpidump file + * Signature - Requested signature to count + * + * RETURN: The number of instances of the signature + * + * DESCRIPTION: Count the instances of tables with the given signature within + * the input acpidump file. + * + ******************************************************************************/ + +unsigned int +AxCountTableInstances ( + char *InputPathname, + char *Signature) +{ + FILE *InputFile; + unsigned int Instances = 0; + + + InputFile = fopen (InputPathname, "rt"); + if (!InputFile) + { + printf ("Could not open input file %s\n", InputPathname); + return (0); + } + + /* Count the number of instances of this signature */ + + while (fgets (Gbl_InstanceBuffer, AX_LINE_BUFFER_SIZE, InputFile)) + { + /* Ignore empty lines and lines that start with a space */ + + if (AxIsEmptyLine (Gbl_InstanceBuffer) || + (Gbl_InstanceBuffer[0] == ' ')) + { + continue; + } + + AxNormalizeSignature (Gbl_InstanceBuffer); + if (ACPI_COMPARE_NAME (Gbl_InstanceBuffer, Signature)) + { + Instances++; + } + } + + fclose (InputFile); + return (Instances); +} + + +/****************************************************************************** + * + * FUNCTION: AxGetNextInstance + * + * PARAMETERS: InputPathname - Filename for acpidump file + * Signature - Requested ACPI signature + * + * RETURN: The next instance number for this signature. Zero if this + * is the first instance of this signature. + * + * DESCRIPTION: Get the next instance number of the specified table. If this + * is the first instance of the table, create a new instance + * block. Note: only SSDT and PSDT tables can have multiple + * instances. + * + ******************************************************************************/ + +unsigned int +AxGetNextInstance ( + char *InputPathname, + char *Signature) +{ + AX_TABLE_INFO *Info; + + + Info = Gbl_TableListHead; + while (Info) + { + if (*(UINT32 *) Signature == Info->Signature) + { + break; + } + + Info = Info->Next; + } + + if (!Info) + { + /* Signature not found, create new table info block */ + + Info = malloc (sizeof (AX_TABLE_INFO)); + if (!Info) + { + printf ("Could not allocate memory (0x%X bytes)\n", + (unsigned int) sizeof (AX_TABLE_INFO)); + exit (0); + } + + Info->Signature = *(UINT32 *) Signature; + Info->Instances = AxCountTableInstances (InputPathname, Signature); + Info->NextInstance = 1; + Info->Next = Gbl_TableListHead; + Gbl_TableListHead = Info; + } + + if (Info->Instances > 1) + { + return (Info->NextInstance++); + } + + return (0); +} + + +/****************************************************************************** + * + * FUNCTION: AxIsDataBlockHeader + * + * PARAMETERS: None + * + * RETURN: Status. 1 if the table header is valid, 0 otherwise. + * + * DESCRIPTION: Check if the ACPI table identifier in the input acpidump text + * file is valid (of the form: <sig> @ <addr>). + * + ******************************************************************************/ + +int +AxIsDataBlockHeader ( + void) +{ + + /* Ignore lines that are too short to be header lines */ + + if (strlen (Gbl_LineBuffer) < AX_MIN_BLOCK_HEADER_LENGTH) + { + return (0); + } + + /* Ignore empty lines and lines that start with a space */ + + if (AxIsEmptyLine (Gbl_LineBuffer) || + (Gbl_LineBuffer[0] == ' ')) + { + return (0); + } + + /* + * Ignore lines that are not headers of the form <sig> @ <addr>. + * Basically, just look for the '@' symbol, surrounded by spaces. + * + * Examples of headers that must be supported: + * + * DSDT @ 0x737e4000 + * XSDT @ 0x737f2fff + * RSD PTR @ 0xf6cd0 + * SSDT @ (nil) + */ + if (!strstr (Gbl_LineBuffer, " @ ")) + { + return (0); + } + + AxNormalizeSignature (Gbl_LineBuffer); + return (1); +} + + +/****************************************************************************** + * + * FUNCTION: AxProcessOneTextLine + * + * PARAMETERS: OutputFile - Where to write the binary data + * ThisSignature - Signature of current ACPI table + * ThisTableBytesWritten - Total count of data written + * + * RETURN: Length of the converted line + * + * DESCRIPTION: Convert one line of input hex ascii text to binary, and write + * the binary data to the table output file. + * + ******************************************************************************/ + +long +AxProcessOneTextLine ( + FILE *OutputFile, + char *ThisSignature, + unsigned int ThisTableBytesWritten) +{ + size_t BytesWritten; + size_t BytesConverted; + + + /* Check for the end of this table data block */ + + if (AxIsEmptyLine (Gbl_LineBuffer) || + (Gbl_LineBuffer[0] != ' ')) + { + printf (AX_TABLE_INFO_FORMAT, + ThisSignature, ThisTableBytesWritten, Gbl_OutputFilename); + return (0); + } + + /* Convert one line of ascii hex data to binary */ + + BytesConverted = AxConvertLine (Gbl_LineBuffer, Gbl_BinaryData); + + /* Write the binary data */ + + BytesWritten = fwrite (Gbl_BinaryData, 1, BytesConverted, OutputFile); + if (BytesWritten != BytesConverted) + { + printf ("Error while writing file %s\n", Gbl_OutputFilename); + return (-1); + } + + return (BytesWritten); +} diff --git a/source/tools/examples/examples.c b/source/tools/examples/examples.c index ef9cbf0e7a72..98d7bbcb908b 100644 --- a/source/tools/examples/examples.c +++ b/source/tools/examples/examples.c @@ -152,7 +152,8 @@ main ( ACPI_INFO ((AE_INFO, "Example ACPICA info message")); ACPI_WARNING ((AE_INFO, "Example ACPICA warning message")); ACPI_ERROR ((AE_INFO, "Example ACPICA error message")); - ACPI_EXCEPTION ((AE_INFO, AE_AML_OPERAND_TYPE, "Example ACPICA exception message")); + ACPI_EXCEPTION ((AE_INFO, AE_AML_OPERAND_TYPE, + "Example ACPICA exception message")); ExecuteOSI (); ExecuteMAIN (); @@ -395,16 +396,16 @@ InstallHandlers (void) /* Install global notify handler */ - Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, - NotifyHandler, NULL); + Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, NotifyHandler, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While installing Notify handler")); return (Status); } - Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY, - RegionHandler, RegionInit, NULL); + Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_SYSTEM_MEMORY, RegionHandler, RegionInit, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While installing an OpRegion handler")); @@ -480,7 +481,8 @@ ExecuteOSI (void) AcpiOsPrintf ("Invalid return type from _OSI, %.2X\n", Object->Type); } - ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", (UINT32) Object->Integer.Value)); + ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", + (UINT32) Object->Integer.Value)); ErrorExit: @@ -536,7 +538,8 @@ ExecuteMAIN (void) Object = ReturnValue.Pointer; if (Object->Type == ACPI_TYPE_STRING) { - AcpiOsPrintf ("Method [MAIN] returned: \"%s\"\n", Object->String.Pointer); + AcpiOsPrintf ("Method [MAIN] returned: \"%s\"\n", + Object->String.Pointer); } ACPI_FREE (ReturnValue.Pointer); |