diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exstore.c')
-rw-r--r-- | sys/contrib/dev/acpica/exstore.c | 277 |
1 files changed, 72 insertions, 205 deletions
diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index a49e29c..9b09a38 100644 --- a/sys/contrib/dev/acpica/exstore.c +++ b/sys/contrib/dev/acpica/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * $Revision: 154 $ + * $Revision: 162 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -127,7 +127,7 @@ #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("exstore") + ACPI_MODULE_NAME ("exstore") /******************************************************************************* @@ -145,7 +145,7 @@ * DESCRIPTION: Store the value described by SourceDesc into the location * described by DestDesc. Called by various interpreter * functions to store the result of an operation into - * the destination operand -- not just simply the actual STORE + * the destination operand -- not just simply the actual "Store" * ASL operator. * ******************************************************************************/ @@ -160,20 +160,20 @@ AcpiExStore ( ACPI_OPERAND_OBJECT *RefDesc = DestDesc; - FUNCTION_TRACE_PTR ("ExStore", DestDesc); + ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc); /* Validate parameters */ if (!SourceDesc || !DestDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* DestDesc can be either a namespace node or an ACPI object */ - if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED)) + if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) { /* * Dest is a namespace node, @@ -182,8 +182,6 @@ AcpiExStore ( Status = AcpiExStoreObjectToNode (SourceDesc, (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); - /* All done, that's it */ - return_ACPI_STATUS (Status); } @@ -196,9 +194,9 @@ AcpiExStore ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Destination is not a ReferenceObj [%p]\n", DestDesc)); - DUMP_STACK_ENTRY (SourceDesc); - DUMP_STACK_ENTRY (DestDesc); - DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "ExStore", + ACPI_DUMP_STACK_ENTRY (SourceDesc); + ACPI_DUMP_STACK_ENTRY (DestDesc); + ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore", 2, "Target is not a ReferenceObj"); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -257,15 +255,16 @@ AcpiExStore ( { case ACPI_TYPE_INTEGER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X (%d)\n", - (UINT32) SourceDesc->Integer.Value, (UINT32) SourceDesc->Integer.Value)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n", + ACPI_HIWORD (SourceDesc->Integer.Value), + ACPI_LOWORD (SourceDesc->Integer.Value))); break; case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%X\n", - (UINT32) SourceDesc->Buffer.Length)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", + (UINT32) SourceDesc->Buffer.Length)); break; @@ -277,14 +276,15 @@ AcpiExStore ( case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements - 0x%X\n", - (UINT32) SourceDesc->Package.Elements)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", + SourceDesc->Package.Elements)); break; default: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "@0x%p\n", SourceDesc)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", + AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc)); break; } @@ -298,7 +298,7 @@ AcpiExStore ( case AML_REVISION_OP: /* - * Storing to a constant is a no-op according to the ACPI + * Storing to a constant is a no-op according to the ACPI * Specification. (Delete the reference descriptor, however.) */ break; @@ -308,7 +308,7 @@ AcpiExStore ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %02x\n", RefDesc->Reference.Opcode)); - DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); + ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); Status = AE_AML_INTERNAL; break; @@ -336,22 +336,23 @@ AcpiExStore ( ACPI_STATUS AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT *IndexDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NewDesc; UINT8 Value = 0; - FUNCTION_TRACE ("ExStoreObjectToIndex"); + ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex"); /* * Destination must be a reference pointer, and * must point to either a buffer or a package */ - switch (DestDesc->Reference.TargetType) + switch (IndexDesc->Reference.TargetType) { case ACPI_TYPE_PACKAGE: /* @@ -360,86 +361,31 @@ AcpiExStoreObjectToIndex ( * source is copied into the destination - we can't just point to the * source object. */ - if (DestDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) + /* + * The object at *(IndexDesc->Reference.Where) is the + * element within the package that is to be modified. + */ + ObjDesc = *(IndexDesc->Reference.Where); + + /* Do the conversion/store */ + + Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, + WalkState); + if (ACPI_FAILURE (Status)) { - /* - * The object at *(DestDesc->Reference.Where) is the - * element within the package that is to be modified. - */ - ObjDesc = *(DestDesc->Reference.Where); - if (ObjDesc) - { - /* - * If the Destination element is a package, we will delete - * that object and construct a new one. - * - * TBD: [Investigate] Should both the src and dest be required - * to be packages? - * && (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) - */ - if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Take away the reference for being part of a package */ - - AcpiUtRemoveReference (ObjDesc); - ObjDesc = NULL; - } - } - - if (!ObjDesc) - { - /* - * If the ObjDesc is NULL, it means that an uninitialized - * package element has been used as a destination (this is OK), - * therefore, we must create the destination element to match - * the type of the source element NOTE: SourceDesc can be of - * any type. - */ - ObjDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * If the source is a package, copy the source to the new dest - */ - if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type) - { - Status = AcpiUtCopyIpackageToIpackage (SourceDesc, ObjDesc, - WalkState); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); - } - } - - /* Install the new descriptor into the package */ - - *(DestDesc->Reference.Where) = ObjDesc; - } - - if (ACPI_TYPE_PACKAGE != ObjDesc->Common.Type) - { - /* - * The destination element is not a package, so we need to - * convert the contents of the source (SourceDesc) and copy into - * the destination (ObjDesc) - */ - Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, - WalkState); - if (ACPI_FAILURE (Status)) - { - /* - * An error occurrered when copying the internal object - * so delete the reference. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unable to copy the internal object\n")); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - } + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not store object to indexed package element\n")); + return_ACPI_STATUS (Status); + } + + /* + * If a new object was created, we must install it as the new + * package element + */ + if (NewDesc != ObjDesc) + { + AcpiUtRemoveReference (ObjDesc); + *(IndexDesc->Reference.Where) = NewDesc; } break; @@ -447,7 +393,7 @@ AcpiExStoreObjectToIndex ( case ACPI_TYPE_BUFFER_FIELD: /* - * Store into a Buffer (not actually a real BufferField) at a + * Store into a Buffer (not actually a real BufferField) at a * location defined by an Index. * * The first 8-bit element of the source object is written to the @@ -458,7 +404,7 @@ AcpiExStoreObjectToIndex ( /* * Make sure the target is a Buffer */ - ObjDesc = DestDesc->Reference.Object; + ObjDesc = IndexDesc->Reference.Object; if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -495,17 +441,16 @@ AcpiExStoreObjectToIndex ( "Source must be Integer/Buffer/String type, not %s\n", AcpiUtGetTypeName (SourceDesc->Common.Type))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - break; } /* Store the source value into the target buffer byte */ - ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or BufferField\n")); Status = AE_AML_OPERAND_TYPE; break; @@ -548,10 +493,11 @@ AcpiExStoreObjectToNode ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TargetDesc; - ACPI_OBJECT_TYPE8 TargetType = ACPI_TYPE_ANY; + ACPI_OPERAND_OBJECT *NewDesc; + ACPI_OBJECT_TYPE TargetType; - FUNCTION_TRACE ("ExStoreObjectToNode"); + ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); /* @@ -561,8 +507,8 @@ AcpiExStoreObjectToNode ( TargetDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) into node %p(%s)\n", - Node, AcpiUtGetTypeName (SourceDesc->Common.Type), - SourceDesc, AcpiUtGetTypeName (TargetType))); + SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), + Node, AcpiUtGetTypeName (TargetType))); /* * Resolve the source object to an actual value @@ -601,24 +547,26 @@ AcpiExStoreObjectToNode ( * * Copy and/or convert the source object to a new target object */ - Status = AcpiExStoreObject (SourceDesc, TargetType, &TargetDesc, - WalkState); + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Store the new TargetDesc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * SourceDesc reference count is incremented by AttachObject. - */ - Status = AcpiNsAttachObject (Node, TargetDesc, TargetType); + if (NewDesc != TargetDesc) + { + /* + * Store the new NewDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * SourceDesc reference count is incremented by AttachObject. + */ + Status = AcpiNsAttachObject (Node, NewDesc, TargetType); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Store %s into %s via Convert/Attach\n", - AcpiUtGetTypeName (TargetDesc->Common.Type), - AcpiUtGetTypeName (TargetType))); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Store %s into %s via Convert/Attach\n", + AcpiUtGetTypeName (SourceDesc->Common.Type), + AcpiUtGetTypeName (NewDesc->Common.Type))); + } break; @@ -638,84 +586,3 @@ AcpiExStoreObjectToNode ( } -/******************************************************************************* - * - * FUNCTION: AcpiExStoreObjectToObject - * - * PARAMETERS: SourceDesc - Value to be stored - * DestDesc - Object to receive the value - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Store an object to another object. - * - * The Assignment of an object to another (not named) object - * is handled here. - * The val passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. - * - * This module allows destination types of Number, String, - * and Buffer. - * - * Assumes parameters are already validated. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStoreObjectToObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OBJECT_TYPE8 DestinationType = DestDesc->Common.Type; - - - FUNCTION_TRACE ("ExStoreObjectToObject"); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) to %p(%s)\n", - SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), - DestDesc, AcpiUtGetTypeName (DestDesc->Common.Type))); - - - /* - * From this interface, we only support Integers/Strings/Buffers - */ - switch (DestinationType) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - break; - - default: - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into %s not implemented\n", - AcpiUtGetTypeName (DestDesc->Common.Type))); - - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); - } - - /* - * Resolve the source object to an actual value - * (If it is a reference object) - */ - Status = AcpiExResolveObject (&SourceDesc, DestinationType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Copy and/or convert the source object to the destination object - */ - Status = AcpiExStoreObject (SourceDesc, DestinationType, &DestDesc, - WalkState); - return_ACPI_STATUS (Status); -} - |