📄 exconfig.c
字号:
StartNode = ParentNode; } /* Find the node referenced by the ParameterPathString */ Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* Load the table into the namespace */ Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Parameter Data (optional) */ if (ParameterNode) { /* Store the parameter data into the optional parameter object */ Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); return_ACPI_STATUS (Status); } } Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", Table->Signature, Table->OemId, Table->OemTableId)); } /* Invoke table handler if present */ if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, AcpiGbl_TableHandlerContext); } *ReturnDesc = DdbHandle; return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiExLoadOp * * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be * obtained * Target - Where a handle to the table will be stored * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Load an ACPI table from a field or operation region * * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer * objects before this code is reached. * * If source is an operation region, it must refer to SystemMemory, as * per the ACPI specification. * ******************************************************************************/ACPI_STATUSAcpiExLoadOp ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState){ ACPI_OPERAND_OBJECT *DdbHandle; ACPI_TABLE_DESC TableDesc; ACPI_NATIVE_UINT TableIndex; ACPI_STATUS Status; UINT32 Length; ACPI_FUNCTION_TRACE (ExLoadOp); ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); /* Source Object can be either an OpRegion or a Buffer/Field */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_REGION: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); /* Region must be SystemMemory (from ACPI spec) */ if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * If the Region Address and Length have not been previously evaluated, * evaluate them now and save the results. */ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) { Status = AcpiDsGetRegionArguments (ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * We will simply map the memory region for the table. However, the * memory region is technically not guaranteed to remain stable and * we may eventually have to copy the table to a local buffer. */ TableDesc.Address = ObjDesc->Region.Address; TableDesc.Length = ObjDesc->Region.Length; TableDesc.Flags = ACPI_TABLE_ORIGIN_MAPPED; break; case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Buffer or Field %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); Length = ObjDesc->Buffer.Length; /* Must have at least an ACPI table header */ if (Length < sizeof (ACPI_TABLE_HEADER)) { return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } /* Validate checksum here. It won't get validated in TbAddTable */ Status = AcpiTbVerifyChecksum ( ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer), Length); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * We need to copy the buffer since the original buffer could be * changed or deleted in the future */ TableDesc.Pointer = ACPI_ALLOCATE (Length); if (!TableDesc.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); } ACPI_MEMCPY (TableDesc.Pointer, ObjDesc->Buffer.Pointer, Length); TableDesc.Length = Length; TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; break; default: return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * Install the new table into the local data structures */ Status = AcpiTbAddTable (&TableDesc, &TableIndex); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExAddTable (TableIndex, WalkState->ScopeInfo->Scope.Node, &DdbHandle); if (ACPI_FAILURE (Status)) { /* On error, TablePtr was deallocated above */ return_ACPI_STATUS (Status); } /* Store the DdbHandle into the Target operand */ Status = AcpiExStore (DdbHandle, Target, WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); /* TablePtr was deallocated above */ AcpiUtRemoveReference (DdbHandle); return_ACPI_STATUS (Status); } /* Invoke table handler if present */ if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, AcpiGbl_TableHandlerContext); }Cleanup: if (ACPI_FAILURE (Status)) { /* Delete allocated buffer or mapping */ AcpiTbDeleteTable (&TableDesc); } return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiExUnloadTable * * PARAMETERS: DdbHandle - Handle to a previously loaded table * * RETURN: Status * * DESCRIPTION: Unload an ACPI table * ******************************************************************************/ACPI_STATUSAcpiExUnloadTable ( ACPI_OPERAND_OBJECT *DdbHandle){ ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; ACPI_NATIVE_UINT TableIndex; ACPI_TABLE_HEADER *Table; ACPI_FUNCTION_TRACE (ExUnloadTable); /* * Validate the handle * Although the handle is partially validated in AcpiExReconfiguration(), * when it calls AcpiExResolveOperands(), the handle is more completely * validated here. */ if ((!DdbHandle) || (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (DdbHandle) != ACPI_TYPE_LOCAL_REFERENCE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the table index from the DdbHandle */ TableIndex = (ACPI_NATIVE_UINT) TableDesc->Reference.Object; /* Invoke table handler if present */ if (AcpiGbl_TableHandler) { Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, AcpiGbl_TableHandlerContext); } } /* * Delete the entire namespace under this table Node * (Offset contains the TableId) */ AcpiTbDeleteNamespaceByOwner (TableIndex); (void) AcpiTbReleaseOwnerId (TableIndex); AcpiTbSetTableLoadedFlag (TableIndex, FALSE); return_ACPI_STATUS (AE_OK);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -