diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exoparg1.c')
-rw-r--r-- | sys/contrib/dev/acpica/exoparg1.c | 156 |
1 files changed, 95 insertions, 61 deletions
diff --git a/sys/contrib/dev/acpica/exoparg1.c b/sys/contrib/dev/acpica/exoparg1.c index 30ed7e0..cee66e0 100644 --- a/sys/contrib/dev/acpica/exoparg1.c +++ b/sys/contrib/dev/acpica/exoparg1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * $Revision: 163 $ + * $Revision: 1.172 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -171,7 +171,8 @@ AcpiExOpcode_0A_0T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -188,8 +189,9 @@ AcpiExOpcode_0A_0T_1R ( Status = AE_NO_MEMORY; goto Cleanup; } - +#if ACPI_MACHINE_WIDTH != 16 ReturnDesc->Integer.Value = AcpiOsGetTimer (); +#endif break; default: /* Unknown opcode */ @@ -202,17 +204,18 @@ AcpiExOpcode_0A_0T_1R ( Cleanup: - if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } - /* Delete return object on error */ - if (ACPI_FAILURE (Status)) + if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); } + else + { + /* Save the return value */ + + WalkState->ResultObj = ReturnDesc; + } return_ACPI_STATUS (Status); } @@ -239,7 +242,8 @@ AcpiExOpcode_1A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -315,7 +319,8 @@ AcpiExOpcode_1A_1T_0R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -369,7 +374,8 @@ AcpiExOpcode_1A_1T_1R ( ACPI_INTEGER Digit; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -418,7 +424,7 @@ AcpiExOpcode_1A_1T_1R ( break; - case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ ReturnDesc->Integer.Value = Operand[0]->Integer.Value; @@ -497,8 +503,10 @@ AcpiExOpcode_1A_1T_1R ( { (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); - /* Insert the BCD digit that resides in the remainder from above */ - + /* + * Insert the BCD digit that resides in the + * remainder from above + */ ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); } @@ -535,7 +543,8 @@ AcpiExOpcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -575,10 +584,10 @@ AcpiExOpcode_1A_1T_1R ( if (!WalkState->ResultObj) { /* - * Normally, we would remove a reference on the Operand[0] parameter; - * But since it is being used as the internal return object - * (meaning we would normally increment it), the two cancel out, - * and we simply don't do anything. + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. */ WalkState->ResultObj = Operand[0]; WalkState->Operands[0] = NULL; /* Prevent deletion */ @@ -600,6 +609,11 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToString (Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; @@ -607,12 +621,22 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToString (Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; @@ -620,15 +644,19 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ - /* - * These are two obsolete opcodes - */ + /* These are two obsolete opcodes */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", AcpiPsGetOpcodeName (WalkState->Opcode))); @@ -644,10 +672,12 @@ AcpiExOpcode_1A_1T_1R ( goto Cleanup; } - /* - * Store the return value computed above into the target object - */ - Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } Cleanup: @@ -692,7 +722,8 @@ AcpiExOpcode_1A_0T_1R ( ACPI_INTEGER Value; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -791,9 +822,9 @@ AcpiExOpcode_1A_0T_1R ( /* * Note: The operand is not resolved at this point because we want to - * get the associated object, not its value. For example, we don't want - * to resolve a FieldUnit to its value, we want the actual FieldUnit - * object. + * get the associated object, not its value. For example, we don't + * want to resolve a FieldUnit to its value, we want the actual + * FieldUnit object. */ /* Get the type of the base object */ @@ -825,7 +856,8 @@ AcpiExOpcode_1A_0T_1R ( /* Get the base object */ - Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -912,8 +944,10 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ - Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, WalkState, &TempDesc); + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, + WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -947,22 +981,27 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_STRING: /* - * This is a DerefOf (String). The string is a reference to a named ACPI object. + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. * * 1) Find the owning Node - * 2) Dereference the node to an actual object. Could be a Field, so we nee - * to resolve the node to a value. + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. */ Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, - WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc)); + WalkState->ScopeInfo->Scope.Node, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState); + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); goto Cleanup; @@ -980,15 +1019,18 @@ AcpiExOpcode_1A_0T_1R ( /* * This is a DerefOf (ObjectReference) * Get the actual object from the Node (This is the dereference). - * -- This case may only happen when a LocalX or ArgX is dereferenced above. + * This case may only happen when a LocalX or ArgX is + * dereferenced above. */ - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + AcpiUtAddReference (ReturnDesc); } else { /* - * This must be a reference object produced by either the Index() or - * RefOf() operator + * This must be a reference object produced by either the + * Index() or RefOf() operator */ switch (Operand[0]->Reference.Opcode) { @@ -1032,25 +1074,15 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_PACKAGE: /* - * Return the referenced element of the package. We must add - * another reference to the referenced object, however. + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. */ ReturnDesc = *(Operand[0]->Reference.Where); - if (!ReturnDesc) + if (ReturnDesc) { - /* - * We can't return a NULL dereferenced value. This is - * an uninitialized package element and is thus a - * severe error. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "NULL package element obj %p\n", - Operand[0])); - Status = AE_AML_UNINITIALIZED_ELEMENT; - goto Cleanup; + AcpiUtAddReference (ReturnDesc); } - AcpiUtAddReference (ReturnDesc); break; @@ -1069,10 +1101,12 @@ AcpiExOpcode_1A_0T_1R ( ReturnDesc = Operand[0]->Reference.Object; - if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) { - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); } /* Add another reference to the object! */ |