diff options
Diffstat (limited to 'source/tools/acpiexec/aeinitfile.c')
| -rw-r--r-- | source/tools/acpiexec/aeinitfile.c | 147 |
1 files changed, 93 insertions, 54 deletions
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; } |
