diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exstore.c')
-rw-r--r-- | sys/contrib/dev/acpica/exstore.c | 155 |
1 files changed, 58 insertions, 97 deletions
diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 4392b7a..a49e29c 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: 150 $ + * $Revision: 154 $ * *****************************************************************************/ @@ -137,14 +137,16 @@ * PARAMETERS: *SourceDesc - Value to be stored * *DestDesc - Where to store it. Must be an NS node * or an ACPI_OPERAND_OBJECT of type - * Reference; + * Reference; + * WalkState - Current walk state * * RETURN: Status * * 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. + * the destination operand -- not just simply the actual STORE + * ASL operator. * ******************************************************************************/ @@ -185,7 +187,6 @@ AcpiExStore ( return_ACPI_STATUS (Status); } - /* Destination object must be an object of type Reference */ if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE) @@ -203,7 +204,6 @@ AcpiExStore ( return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* * Examine the Reference opcode. These cases are handled: * @@ -215,7 +215,6 @@ AcpiExStore ( */ switch (RefDesc->Reference.Opcode) { - case AML_NAME_OP: /* Storing an object into a Name "container" */ @@ -299,27 +298,23 @@ AcpiExStore ( case AML_REVISION_OP: /* - * Storing to a constant is a no-op -- see ACPI Specification - * Delete the reference descriptor, however + * Storing to a constant is a no-op according to the ACPI + * Specification. (Delete the reference descriptor, however.) */ break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - Unknown Reference subtype %02x\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %02x\n", RefDesc->Reference.Opcode)); - - /* TBD: [Restructure] use object dump routine !! */ - - DUMP_BUFFER (RefDesc, sizeof (ACPI_OPERAND_OBJECT)); + DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); Status = AE_AML_INTERNAL; break; } /* switch (RefDesc->Reference.Opcode) */ - return_ACPI_STATUS (Status); } @@ -328,12 +323,13 @@ AcpiExStore ( * * FUNCTION: AcpiExStoreObjectToIndex * - * PARAMETERS: *SourceDesc - Value to be stored - * *Node - Named object to receive the value + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Named object to receive the value + * WalkState - Current walk state * * RETURN: Status * - * DESCRIPTION: Store the object to the named object. + * DESCRIPTION: Store the object to indexed Buffer or Package element * ******************************************************************************/ @@ -345,8 +341,6 @@ AcpiExStoreObjectToIndex ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 Length; - UINT32 i; UINT8 Value = 0; @@ -395,10 +389,11 @@ AcpiExStoreObjectToIndex ( 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: SourceDesccan be of any type. + * 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) @@ -411,7 +406,8 @@ AcpiExStoreObjectToIndex ( */ if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type) { - Status = AcpiUtCopyIpackageToIpackage (SourceDesc, ObjDesc, WalkState); + Status = AcpiUtCopyIpackageToIpackage (SourceDesc, ObjDesc, + WalkState); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -450,18 +446,17 @@ AcpiExStoreObjectToIndex ( case ACPI_TYPE_BUFFER_FIELD: - - /* TBD: can probably call the generic Buffer/Field routines */ - /* - * Storing into a buffer at a location defined by an Index. + * Store into a Buffer (not actually a real BufferField) at a + * location defined by an Index. * - * Each 8-bit element of the source object is written to the - * 8-bit Buffer Field of the Index destination object. + * The first 8-bit element of the source object is written to the + * 8-bit Buffer location defined by the Index destination object, + * according to the ACPI 2.0 specification. */ /* - * Set the ObjDesc to the destination object and type check. + * Make sure the target is a Buffer */ ObjDesc = DestDesc->Reference.Object; if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER) @@ -476,68 +471,46 @@ AcpiExStoreObjectToIndex ( switch (SourceDesc->Common.Type) { case ACPI_TYPE_INTEGER: - /* - * Type is Integer, assign bytewise - * This loop to assign each of the elements is somewhat - * backward because of the Big Endian-ness of IA-64 - */ - Length = sizeof (ACPI_INTEGER); - for (i = Length; i != 0; i--) - { - Value = (UINT8)(SourceDesc->Integer.Value >> (MUL_8 (i - 1))); - ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; - } - break; + /* Use the least-significant byte of the integer */ - case ACPI_TYPE_BUFFER: - /* - * Type is Buffer, the Length is in the structure. - * Just loop through the elements and assign each one in turn. - */ - Length = SourceDesc->Buffer.Length; - for (i = 0; i < Length; i++) - { - Value = SourceDesc->Buffer.Pointer[i]; - ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; - } + Value = (UINT8) (SourceDesc->Integer.Value); break; + case ACPI_TYPE_BUFFER: - case ACPI_TYPE_STRING: - /* - * Type is String, the Length is in the structure. - * Just loop through the elements and assign each one in turn. - */ - Length = SourceDesc->String.Length; - for (i = 0; i < Length; i++) - { - Value = SourceDesc->String.Pointer[i]; - ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; - } + Value = SourceDesc->Buffer.Pointer[0]; break; + case ACPI_TYPE_STRING: + + Value = SourceDesc->String.Pointer[0]; + break; default: - /* Other types are invalid */ + /* All other types are invalid */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Source must be Number/Buffer/String type, not %X\n", - SourceDesc->Common.Type)); - Status = AE_AML_OPERAND_TYPE; + "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; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or BufferField\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Target is not a Package or BufferField\n")); Status = AE_AML_OPERAND_TYPE; break; } - return_ACPI_STATUS (Status); } @@ -546,15 +519,16 @@ AcpiExStoreObjectToIndex ( * * FUNCTION: AcpiExStoreObjectToNode * - * PARAMETERS: *SourceDesc - Value to be stored - * *Node - Named object to receive the value + * PARAMETERS: SourceDesc - Value to be stored + * Node - Named object to receive the value + * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Store the object to the named object. * * The Assignment of an object to a named object is handled here - * The val passed in will replace the current value (if any) + * The value passed in will replace the current value (if any) * with the input value. * * When storing into an object the data is converted to the @@ -562,10 +536,7 @@ AcpiExStoreObjectToIndex ( * that the target object type (for an initialized target) will * not be changed by a store operation. * - * NOTE: the global lock is acquired early. This will result - * in the global lock being held a bit longer. Also, if the - * function fails during set up we may get the lock when we - * don't really need it. I don't think we care. + * Assumes parameters are already validated. * ******************************************************************************/ @@ -584,10 +555,6 @@ AcpiExStoreObjectToNode ( /* - * Assuming the parameters were already validated - */ - - /* * Get current type of the node, and object attached to Node */ TargetType = AcpiNsGetType (Node); @@ -597,7 +564,6 @@ AcpiExStoreObjectToNode ( Node, AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc, AcpiUtGetTypeName (TargetType))); - /* * Resolve the source object to an actual value * (If it is a reference object) @@ -608,7 +574,6 @@ AcpiExStoreObjectToNode ( return_ACPI_STATUS (Status); } - /* * Do the actual store operation */ @@ -636,7 +601,8 @@ AcpiExStoreObjectToNode ( * * Copy and/or convert the source object to a new target object */ - Status = AcpiExStoreObject (SourceDesc, TargetType, &TargetDesc, WalkState); + Status = AcpiExStoreObject (SourceDesc, TargetType, &TargetDesc, + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -668,7 +634,6 @@ AcpiExStoreObjectToNode ( break; } - return_ACPI_STATUS (Status); } @@ -677,8 +642,9 @@ AcpiExStoreObjectToNode ( * * FUNCTION: AcpiExStoreObjectToObject * - * PARAMETERS: *SourceDesc - Value to be stored - * *DestDesc - Object to receive the value + * PARAMETERS: SourceDesc - Value to be stored + * DestDesc - Object to receive the value + * WalkState - Current walk state * * RETURN: Status * @@ -697,6 +663,8 @@ AcpiExStoreObjectToNode ( * This module allows destination types of Number, String, * and Buffer. * + * Assumes parameters are already validated. + * ******************************************************************************/ ACPI_STATUS @@ -711,10 +679,6 @@ AcpiExStoreObjectToObject ( FUNCTION_TRACE ("ExStoreObjectToObject"); - - /* - * Assuming the parameters are valid! - */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) to %p(%s)\n", SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), DestDesc, AcpiUtGetTypeName (DestDesc->Common.Type))); @@ -737,7 +701,6 @@ AcpiExStoreObjectToObject ( return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } - /* * Resolve the source object to an actual value * (If it is a reference object) @@ -748,13 +711,11 @@ AcpiExStoreObjectToObject ( return_ACPI_STATUS (Status); } - /* * Copy and/or convert the source object to the destination object */ - Status = AcpiExStoreObject (SourceDesc, DestinationType, &DestDesc, WalkState); - - + Status = AcpiExStoreObject (SourceDesc, DestinationType, &DestDesc, + WalkState); return_ACPI_STATUS (Status); } |