ACPI_STATUS AcpiTbLoadTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *ParentNode) { ACPI_TABLE_HEADER *Table; ACPI_STATUS Status; ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (TbLoadTable); /* * Note: Now table is "INSTALLED", it must be validated before * using. */ Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiNsLoadTable (TableIndex, ParentNode); /* * This case handles the legacy option that groups all module-level * code blocks together and defers execution until all of the tables * are loaded. Execute all of these blocks at this time. * Execute any module-level code that was detected during the table * load phase. * * Note: this option is deprecated and will be eliminated in the * future. Use of this option can cause problems with AML code that * depends upon in-order immediate execution of module-level code. */ AcpiNsExecModuleCodeList (); /* * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is * responsible for discovering any new wake GPEs by running _PRW methods * that may have been loaded by this table. */ Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); if (ACPI_SUCCESS (Status)) { AcpiEvUpdateGpes (OwnerId); } /* Invoke table handler */ AcpiTbNotifyTable (ACPI_TABLE_EVENT_LOAD, Table); return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiTbLoadTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *ParentNode) { ACPI_TABLE_HEADER *Table; ACPI_STATUS Status; ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (TbLoadTable); /* * Note: Now table is "INSTALLED", it must be validated before * using. */ Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiNsLoadTable (TableIndex, ParentNode); /* Execute any module-level code that was found in the table */ if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); } /* * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is * responsible for discovering any new wake GPEs by running _PRW methods * that may have been loaded by this table. */ Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); if (ACPI_SUCCESS (Status)) { AcpiEvUpdateGpes (OwnerId); } /* Invoke table handler if present */ if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, AcpiGbl_TableHandlerContext); } return_ACPI_STATUS (Status); }
static ACPI_STATUS AcpiExAddTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE (ExAddTable); /* Create an object to be the table handle */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init the table handle */ ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; *DdbHandle = ObjDesc; /* Install the new table into the local data structures */ ObjDesc->Reference.Value = TableIndex; /* Add the table to the namespace */ Status = AcpiNsLoadTable (TableIndex, ParentNode); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); *DdbHandle = NULL; return_ACPI_STATUS (Status); } /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); AcpiNsExecModuleCodeList (); AcpiExEnterInterpreter (); return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiInitializeObjects ( UINT32 Flags) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiInitializeObjects); /* * Run all _REG methods * * Note: Any objects accessed by the _REG methods will be automatically * initialized, even if they contain executable AML (see the call to * AcpiNsInitializeObjects below). */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG OpRegion methods\n")); Status = AcpiEvInitializeOpRegions (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Execute any module-level code that was detected during the table load * phase. Although illegal since ACPI 2.0, there are many machines that * contain this type of code. Each block of detected executable AML code * outside of any control method is wrapped with a temporary control * method object and placed on a global list. The methods on this list * are executed below. */ AcpiNsExecModuleCodeList (); /* * Initialize the objects that remain uninitialized. This runs the * executable AML that may be part of the declaration of these objects: * OperationRegions, BufferFields, Buffers, and Packages. */ if (!(Flags & ACPI_NO_OBJECT_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n")); Status = AcpiNsInitializeObjects (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Initialize all device objects in the namespace. This runs the device * _STA and _INI methods. */ if (!(Flags & ACPI_NO_DEVICE_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n")); Status = AcpiNsInitializeDevices (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Empty the caches (delete the cached objects) on the assumption that * the table load filled them up more than they will be at runtime -- * thus wasting non-paged memory. */ Status = AcpiPurgeCachedObjects (); AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK; return_ACPI_STATUS (Status); }
static ACPI_STATUS AcpiExAddTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (ExAddTable); /* Create an object to be the table handle */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init the table handle */ ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; *DdbHandle = ObjDesc; /* Install the new table into the local data structures */ ObjDesc->Reference.Value = TableIndex; /* Add the table to the namespace */ Status = AcpiNsLoadTable (TableIndex, ParentNode); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); *DdbHandle = NULL; return_ACPI_STATUS (Status); } /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); AcpiNsExecModuleCodeList (); AcpiExEnterInterpreter (); /* * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is * responsible for discovering any new wake GPEs by running _PRW methods * that may have been loaded by this table. */ Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); if (ACPI_SUCCESS (Status)) { AcpiEvUpdateGpes (OwnerId); } return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiNsLoadTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE (NsLoadTable); /* If table already loaded into namespace, just return */ if (AcpiTbIsTableLoaded (TableIndex)) { Status = AE_ALREADY_EXISTS; goto Unlock; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n")); Status = AcpiTbAllocateOwnerId (TableIndex); if (ACPI_FAILURE (Status)) { goto Unlock; } /* * Parse the table and load the namespace with all named * objects found within. Control methods are NOT parsed * at this time. In fact, the control methods cannot be * parsed until the entire namespace is loaded, because * if a control method makes a forward reference (call) * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ Status = AcpiNsParseTable (TableIndex, Node); if (ACPI_SUCCESS (Status)) { AcpiTbSetTableLoadedFlag (TableIndex, TRUE); } else { /* * On error, delete any namespace objects created by this table. * We cannot initialize these objects, so delete them. There are * a couple of expecially bad cases: * AE_ALREADY_EXISTS - namespace collision. * AE_NOT_FOUND - the target of a Scope operator does not * exist. This target of Scope must already exist in the * namespace, as per the ACPI specification. */ AcpiNsDeleteNamespaceByOwner ( AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); AcpiTbReleaseOwnerId (TableIndex); return_ACPI_STATUS (Status); } Unlock: if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Now we can parse the control methods. We always parse * them here for a sanity check, and if configured for * just-in-time parsing, we delete the control method * parse trees. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Begin Table Object Initialization\n")); AcpiExEnterInterpreter (); Status = AcpiDsInitializeObjects (TableIndex, Node); AcpiExExitInterpreter (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); /* * This case handles the legacy option that groups all module-level * code blocks together and defers execution until all of the tables * are loaded. Execute all of these blocks at this time. * Execute any module-level code that was detected during the table * load phase. * * Note: this option is deprecated and will be eliminated in the * future. Use of this option can cause problems with AML code that * depends upon in-order immediate execution of module-level code. */ AcpiNsExecModuleCodeList (); return_ACPI_STATUS (Status); }
ACPI_STATUS ACPI_INIT_FUNCTION AcpiInitializeObjects ( UINT32 Flags) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiInitializeObjects); #ifdef ACPI_EXEC_APP /* * This call implements the "initialization file" option for AcpiExec. * This is the precise point that we want to perform the overrides. */ AeDoObjectOverrides (); #endif /* * Execute any module-level code that was detected during the table load * phase. Although illegal since ACPI 2.0, there are many machines that * contain this type of code. Each block of detected executable AML code * outside of any control method is wrapped with a temporary control * method object and placed on a global list. The methods on this list * are executed below. * * This case executes the module-level code for all tables only after * all of the tables have been loaded. It is a legacy option and is * not compatible with other ACPI implementations. See AcpiNsLoadTable. */ if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); /* * Initialize the objects that remain uninitialized. This * runs the executable AML that may be part of the * declaration of these objects: * OperationRegions, BufferFields, Buffers, and Packages. */ if (!(Flags & ACPI_NO_OBJECT_INIT)) { Status = AcpiNsInitializeObjects (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } /* * Initialize all device/region objects in the namespace. This runs * the device _STA and _INI methods and region _REG methods. */ if (!(Flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) { Status = AcpiNsInitializeDevices (Flags); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Empty the caches (delete the cached objects) on the assumption that * the table load filled them up more than they will be at runtime -- * thus wasting non-paged memory. */ Status = AcpiPurgeCachedObjects (); AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK; return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiNsLoadTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE (NsLoadTable); /* If table already loaded into namespace, just return */ if (AcpiTbIsTableLoaded (TableIndex)) { Status = AE_ALREADY_EXISTS; goto Unlock; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n")); Status = AcpiTbAllocateOwnerId (TableIndex); if (ACPI_FAILURE (Status)) { goto Unlock; } /* * Parse the table and load the namespace with all named * objects found within. Control methods are NOT parsed * at this time. In fact, the control methods cannot be * parsed until the entire namespace is loaded, because * if a control method makes a forward reference (call) * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ Status = AcpiNsParseTable (TableIndex, Node); if (ACPI_SUCCESS (Status)) { AcpiTbSetTableLoadedFlag (TableIndex, TRUE); } else { /* * On error, delete any namespace objects created by this table. * We cannot initialize these objects, so delete them. There are * a couple of expecially bad cases: * AE_ALREADY_EXISTS - namespace collision. * AE_NOT_FOUND - the target of a Scope operator does not * exist. This target of Scope must already exist in the * namespace, as per the ACPI specification. */ AcpiNsDeleteNamespaceByOwner ( AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); AcpiTbReleaseOwnerId (TableIndex); return_ACPI_STATUS (Status); } Unlock: if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Now we can parse the control methods. We always parse * them here for a sanity check, and if configured for * just-in-time parsing, we delete the control method * parse trees. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Begin Table Object Initialization\n")); AcpiExEnterInterpreter (); Status = AcpiDsInitializeObjects (TableIndex, Node); AcpiExExitInterpreter (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); /* * Execute any module-level code that was detected during the table load * phase. Although illegal since ACPI 2.0, there are many machines that * contain this type of code. Each block of detected executable AML code * outside of any control method is wrapped with a temporary control * method object and placed on a global list. The methods on this list * are executed below. * * This case executes the module-level code for each table immediately * after the table has been loaded. This provides compatibility with * other ACPI implementations. Optionally, the execution can be deferred * until later, see AcpiInitializeObjects. */ if (!AcpiGbl_ParseTableAsTermList && !AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiTbInstallAndLoadTable ( ACPI_TABLE_HEADER *Table, ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, BOOLEAN Override, UINT32 *TableIndex) { ACPI_STATUS Status; UINT32 i; ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (AcpiLoadTable); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); /* Install the table and load it into the namespace */ Status = AcpiTbInstallStandardTable (Address, Flags, TRUE, Override, &i); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* * Note: Now table is "INSTALLED", it must be validated before * using. */ Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); Status = AcpiNsLoadTable (i, AcpiGbl_RootNode); /* Execute any module-level code that was found in the table */ if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); } /* * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is * responsible for discovering any new wake GPEs by running _PRW methods * that may have been loaded by this table. */ Status = AcpiTbGetOwnerId (i, &OwnerId); if (ACPI_SUCCESS (Status)) { AcpiEvUpdateGpes (OwnerId); } /* Invoke table handler if present */ if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, AcpiGbl_TableHandlerContext); } (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); UnlockAndExit: *TableIndex = i; (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); }