diff options
Diffstat (limited to 'source/tools')
| -rw-r--r-- | source/tools/acpiexec/aecommon.h | 18 | ||||
| -rw-r--r-- | source/tools/acpiexec/aeinitfile.c | 147 | ||||
| -rw-r--r-- | source/tools/acpiexec/aemain.c | 11 | ||||
| -rw-r--r-- | source/tools/acpiexec/aeregion.c | 8 |
4 files changed, 119 insertions, 65 deletions
diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index 233edc2b4877..8ada9021f67e 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -189,11 +189,22 @@ typedef struct ae_debug_regions } AE_DEBUG_REGIONS; +/* + * Init file entry + */ +typedef struct init_file_entry +{ + char *Name; + UINT64 Value; +} INIT_FILE_ENTRY; + extern BOOLEAN AcpiGbl_UseLocalFaultHandler; extern BOOLEAN AcpiGbl_VerboseHandlers; extern BOOLEAN AcpiGbl_IgnoreErrors; extern BOOLEAN AcpiGbl_AbortLoopOnTimeout; extern UINT8 AcpiGbl_RegionFillValue; +extern INIT_FILE_ENTRY *AcpiGbl_InitEntries; +extern UINT32 AcpiGbl_InitFileLineCount; extern UINT8 AcpiGbl_UseHwReducedFadt; extern BOOLEAN AcpiGbl_DisplayRegionAccess; extern BOOLEAN AcpiGbl_DoInterfaceTests; @@ -331,13 +342,18 @@ AeOpenInitializationFile ( char *Filename); void -AeDoObjectOverrides ( +AeProcessInitFile ( void); ACPI_STATUS AeSetupConfiguration ( void *RegionAddr); +ACPI_STATUS +AeLookupInitFileEntry ( + char *Pathname, + UINT64 *Value); + /* aeexec */ void diff --git a/source/tools/acpiexec/aeinitfile.c b/source/tools/acpiexec/aeinitfile.c index 804a2cbcd6c9..79b797e094bc 100644 --- a/source/tools/acpiexec/aeinitfile.c +++ b/source/tools/acpiexec/aeinitfile.c @@ -159,10 +159,8 @@ /* Local prototypes */ static void -AeDoOneOverride ( - char *Pathname, - char *ValueString, - ACPI_OPERAND_OBJECT *ObjDesc, +AeEnterInitFileEntry ( + INIT_FILE_ENTRY InitEntry, ACPI_WALK_STATE *WalkState); @@ -206,13 +204,15 @@ AeOpenInitializationFile ( /****************************************************************************** * - * FUNCTION: AeDoObjectOverrides + * FUNCTION: AeProcessInitFile * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Read the initialization file and perform all overrides + * DESCRIPTION: Read the initialization file and perform all namespace + * initializations. AcpiGbl_InitEntries will be used for region + * field initialization. * * NOTE: The format of the file is multiple lines, each of format: * <ACPI-pathname> <Integer Value> @@ -220,12 +220,13 @@ AeOpenInitializationFile ( *****************************************************************************/ void -AeDoObjectOverrides ( +AeProcessInitFile( void) { - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_WALK_STATE *WalkState; int i; + UINT64 idx; + ACPI_STATUS Status; if (!InitFile) @@ -235,14 +236,19 @@ AeDoObjectOverrides ( /* Create needed objects to be reused for each init entry */ - ObjDesc = AcpiUtCreateIntegerObject (0); WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); NameBuffer[0] = '\\'; - /* Read the entire file line-by-line */ - while (fgets (LineBuffer, AE_FILE_BUFFER_SIZE, InitFile) != NULL) { + ++AcpiGbl_InitFileLineCount; + } + rewind (InitFile); + + AcpiGbl_InitEntries = + AcpiOsAllocate (sizeof (INIT_FILE_ENTRY) * AcpiGbl_InitFileLineCount); + for (idx = 0; fgets (LineBuffer, AE_FILE_BUFFER_SIZE, InitFile); ++idx) + { if (sscanf (LineBuffer, "%s %s\n", &NameBuffer[1], ValueBuffer) != 2) { @@ -257,7 +263,20 @@ AeDoObjectOverrides ( i = 1; } - AeDoOneOverride (&NameBuffer[i], ValueBuffer, ObjDesc, WalkState); + AcpiGbl_InitEntries[idx].Name = + AcpiOsAllocateZeroed (strnlen (NameBuffer + i, AE_FILE_BUFFER_SIZE) + 1); + + strcpy (AcpiGbl_InitEntries[idx].Name, NameBuffer + i); + + Status = AcpiUtStrtoul64 (ValueBuffer, &AcpiGbl_InitEntries[idx].Value); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("%s %s\n", ValueBuffer, + AcpiFormatException (Status)); + goto CleanupAndExit; + } + + AeEnterInitFileEntry (AcpiGbl_InitEntries[idx], WalkState); } /* Cleanup */ @@ -265,77 +284,97 @@ AeDoObjectOverrides ( CleanupAndExit: fclose (InitFile); AcpiDsDeleteWalkState (WalkState); - AcpiUtRemoveReference (ObjDesc); } /****************************************************************************** * - * FUNCTION: AeDoOneOverride + * FUNCTION: AeInitFileEntry * - * PARAMETERS: Pathname - AML namepath - * ValueString - New integer value to be stored - * ObjDesc - Descriptor with integer override value + * PARAMETERS: InitEntry - Entry of the init file * WalkState - Used for the Store operation * * RETURN: None * - * DESCRIPTION: Perform an override for a single namespace object + * DESCRIPTION: Perform initialization of a single namespace object + * + * Note: namespace of objects are limited to integers and region + * fields units of 8 bytes at this time. * *****************************************************************************/ static void -AeDoOneOverride ( - char *Pathname, - char *ValueString, - ACPI_OPERAND_OBJECT *ObjDesc, +AeEnterInitFileEntry ( + INIT_FILE_ENTRY InitEntry, ACPI_WALK_STATE *WalkState) { - ACPI_HANDLE Handle; + char *Pathname = InitEntry.Name; + UINT64 Value = InitEntry.Value; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *NewNode; ACPI_STATUS Status; - UINT64 Value; - - AcpiOsPrintf ("Value Override: %s, ", Pathname); - /* - * Get the namespace node associated with the override - * pathname from the init file. - */ - Status = AcpiGetHandle (NULL, Pathname, &Handle); + AcpiOsPrintf ("Initializing namespace element: %s\n", Pathname); + Status = AcpiNsLookup (NULL, Pathname, ACPI_TYPE_INTEGER, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_ERROR_IF_FOUND | ACPI_NS_NO_UPSEARCH | + ACPI_NS_EARLY_INIT, NULL, &NewNode); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("%s\n", AcpiFormatException (Status)); + ACPI_EXCEPTION ((AE_INFO, Status, + "While creating name from namespace initialization file: %s", + Pathname)); return; } - /* Extract the 64-bit integer */ + ObjDesc = AcpiUtCreateIntegerObject (Value); - Status = AcpiUtStrtoul64 (ValueString, &Value); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("%s %s\n", ValueString, - AcpiFormatException (Status)); - return; - } + AcpiOsPrintf ("New value: 0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Value)); - ObjDesc->Integer.Value = Value; + /* Store pointer to value descriptor in the Node */ - /* - * At the point this function is called, the namespace is fully - * built and initialized. We can simply store the new object to - * the target node. - */ - AcpiExEnterInterpreter (); - Status = AcpiExStore (ObjDesc, Handle, WalkState); - AcpiExExitInterpreter (); + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ACPI_TYPE_INTEGER); - if (ACPI_FAILURE (Status)) + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); +} + + +/****************************************************************************** + * + * FUNCTION: AeLookupInitFileEntry + * + * PARAMETERS: Pathname - AML namepath in external format + * ValueString - value of the namepath if it exitst + * + * RETURN: None + * + * DESCRIPTION: Search the init file for a particular name and its value. + * + *****************************************************************************/ + +ACPI_STATUS +AeLookupInitFileEntry ( + char *Pathname, + UINT64 *Value) +{ + UINT32 i; + + if (!AcpiGbl_InitEntries) { - AcpiOsPrintf ("%s\n", AcpiFormatException (Status)); - return; + return AE_NOT_FOUND; } - AcpiOsPrintf ("New value: 0x%8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Value)); + for (i = 0; i < AcpiGbl_InitFileLineCount; ++i) + { + if (!strcmp(AcpiGbl_InitEntries[i].Name, Pathname)) + { + *Value = AcpiGbl_InitEntries[i].Value; + return AE_OK; + } + } + return AE_NOT_FOUND; } diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 2db2cef5d8ed..b1781b565861 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -199,6 +199,8 @@ 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 */ +INIT_FILE_ENTRY *AcpiGbl_InitEntries = NULL; +UINT32 AcpiGbl_InitFileLineCount = 0; #define ACPIEXEC_NAME "AML Execution/Debug Utility" #define AE_SUPPORTED_OPTIONS "?b:d:e:f^ghlm^rt^v^:x:" @@ -677,6 +679,8 @@ main ( signal (SIGSEGV, AeSignalHandler); } + AeProcessInitFile(); + /* The remaining arguments are filenames for ACPI tables */ if (!argv[AcpiGbl_Optind]) @@ -785,12 +789,6 @@ main ( */ AeInstallLateHandlers (); - /* - * This call implements the "initialization file" option for AcpiExec. - * This is the precise point that we want to perform the overrides. - */ - AeDoObjectOverrides (); - /* Finish the ACPICA initialization */ Status = AcpiInitializeObjects (InitFlags); @@ -848,5 +846,6 @@ NormalExit: ErrorExit: (void) AcpiTerminate (); AcDeleteTableList (ListHead); + AcpiOsFree (AcpiGbl_InitEntries); return (ExitCode); } diff --git a/source/tools/acpiexec/aeregion.c b/source/tools/acpiexec/aeregion.c index 56f939463c1e..5bad83591e65 100644 --- a/source/tools/acpiexec/aeregion.c +++ b/source/tools/acpiexec/aeregion.c @@ -234,9 +234,9 @@ AeRegionHandler ( SpaceId = RegionObject->Region.SpaceId; ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Operation Region request on %s at 0x%X\n", + "Operation Region request on %s at 0x%X, BitWidth 0x%X, RegionLength 0x%X\n", AcpiUtGetRegionName (RegionObject->Region.SpaceId), - (UINT32) Address)); + (UINT32) Address, BitWidth, (UINT32) Length)); /* * Region support can be disabled with the -do option. @@ -410,7 +410,7 @@ AeRegionHandler ( if (AcpiGbl_DisplayRegionAccess) { AcpiOsPrintf ("AcpiExec: %s " - "%s: Attr %X Addr %.4X BaseAddr %.4X Len %.2X Width %X BufLen %X", + "%s: Attr %X Addr %.4X BaseAddr %.4X Length %.2X BitWidth %X BufLen %X", AcpiUtGetRegionName (SpaceId), (Function & ACPI_IO_MASK) ? "Write" : "Read ", (UINT32) (Function >> 16), @@ -424,7 +424,7 @@ AeRegionHandler ( Status = AcpiBufferToResource (MyContext->Connection, MyContext->Length, &Resource); - AcpiOsPrintf (" [AccLen %.2X Conn %p]", + AcpiOsPrintf (" [AccessLength %.2X Connnection %p]", MyContext->AccessLength, MyContext->Connection); } AcpiOsPrintf ("\n"); |
