diff options
author | jkim <jkim@FreeBSD.org> | 2007-03-22 17:24:05 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2007-03-22 17:24:05 +0000 |
commit | e031ab5da47b5f6c28c3cc5d576128b2d8d202e6 (patch) | |
tree | 69d0fa3b3760b0abcc0335ff748e39701a8bf064 /sys/contrib/dev/acpica/exoparg2.c | |
parent | dbc8115981195155aec9304dd8f0ee570bd3d32c (diff) | |
download | FreeBSD-src-e031ab5da47b5f6c28c3cc5d576128b2d8d202e6.zip FreeBSD-src-e031ab5da47b5f6c28c3cc5d576128b2d8d202e6.tar.gz |
Vendor import of Intel ACPI-CA 20070320
Diffstat (limited to 'sys/contrib/dev/acpica/exoparg2.c')
-rw-r--r-- | sys/contrib/dev/acpica/exoparg2.c | 142 |
1 files changed, 81 insertions, 61 deletions
diff --git a/sys/contrib/dev/acpica/exoparg2.c b/sys/contrib/dev/acpica/exoparg2.c index 880a45c..f7f05e4 100644 --- a/sys/contrib/dev/acpica/exoparg2.c +++ b/sys/contrib/dev/acpica/exoparg2.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * $Revision: 1.134 $ + * $Revision: 1.143 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -176,7 +176,7 @@ AcpiExOpcode_2A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_0R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -198,9 +198,9 @@ AcpiExOpcode_2A_0T_0R ( if (!AcpiEvIsNotifyObject (Node)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unexpected notify object type [%s]\n", - AcpiUtGetTypeName (Node->Type))); + ACPI_ERROR ((AE_INFO, + "Unexpected notify object type [%s]", + AcpiUtGetTypeName (Node->Type))); Status = AE_AML_OPERAND_TYPE; break; @@ -246,8 +246,8 @@ AcpiExOpcode_2A_0T_0R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_0R: Unknown opcode %X\n", - WalkState->Opcode)); + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; } @@ -278,7 +278,7 @@ AcpiExOpcode_2A_2T_1R ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -319,8 +319,8 @@ AcpiExOpcode_2A_2T_1R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_2A_2T_1R: Unknown opcode %X\n", - WalkState->Opcode)); + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -339,11 +339,6 @@ AcpiExOpcode_2A_2T_1R ( goto Cleanup; } - /* Return the remainder */ - - WalkState->ResultObj = ReturnDesc1; - - Cleanup: /* * Since the remainder is not returned indirectly, remove a reference to @@ -358,6 +353,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc1); } + /* Save return object (the remainder) on success */ + + else + { + WalkState->ResultObj = ReturnDesc1; + } + return_ACPI_STATUS (Status); } @@ -386,7 +388,7 @@ AcpiExOpcode_2A_1T_1R ( ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -459,11 +461,6 @@ AcpiExOpcode_2A_1T_1R ( (Operand[0]->Buffer.Pointer[Length])) { Length++; - if (Length > ACPI_MAX_STRING_CONVERSION) - { - Status = AE_AML_STRING_LIMIT; - goto Cleanup; - } } /* Allocate a new string object */ @@ -475,8 +472,10 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - /* Copy the raw buffer data with no transform. NULL terminated already*/ - + /* + * Copy the raw buffer data with no transform. + * (NULL terminated already) + */ ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); break; @@ -502,56 +501,72 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - Index = Operand[1]->Integer.Value; + /* Initialize the Index reference object */ - /* At this point, the Source operand is a Package, Buffer, or String */ + Index = Operand[1]->Integer.Value; + ReturnDesc->Reference.Offset = (UINT32) Index; + ReturnDesc->Reference.Opcode = AML_INDEX_OP; - if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE) + /* + * At this point, the Source operand is a String, Buffer, or Package. + * Verify that the index is within range. + */ + switch (ACPI_GET_OBJECT_TYPE (Operand[0])) { - /* Object to be indexed is a Package */ + case ACPI_TYPE_STRING: - if (Index >= Operand[0]->Package.Count) + if (Index >= Operand[0]->String.Length) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond package end (%X)\n", - ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); - Status = AE_AML_PACKAGE_LIMIT; - goto Cleanup; + Status = AE_AML_STRING_LIMIT; } - ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - ReturnDesc->Reference.Object = Operand[0]; - ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [ - Index]; - } - else - { - /* Object to be indexed is a Buffer/String */ + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_BUFFER: if (Index >= Operand[0]->Buffer.Length) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond end of buffer (%X)\n", - ACPI_FORMAT_UINT64 (Index), Operand[0]->Buffer.Length)); Status = AE_AML_BUFFER_LIMIT; - goto Cleanup; } ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - ReturnDesc->Reference.Object = Operand[0]; + break; + + case ACPI_TYPE_PACKAGE: + + if (Index >= Operand[0]->Package.Count) + { + Status = AE_AML_PACKAGE_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + break; + + default: + + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Failure means that the Index was beyond the end of the object */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Index (%X%8.8X) is beyond end of object", + ACPI_FORMAT_UINT64 (Index))); + goto Cleanup; } /* - * Add a reference to the target package/buffer/string for the life - * of the index. + * Save the target object and add a reference to it for the life + * of the index */ + ReturnDesc->Reference.Object = Operand[0]; AcpiUtAddReference (Operand[0]); - /* Complete the Index reference object */ - - ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.Offset = (UINT32) Index; - /* Store the reference to the Target */ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); @@ -564,8 +579,8 @@ AcpiExOpcode_2A_1T_1R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_2A_1T_1R: Unknown opcode %X\n", - WalkState->Opcode)); + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; } @@ -599,6 +614,7 @@ Cleanup: if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; } return_ACPI_STATUS (Status); @@ -627,7 +643,7 @@ AcpiExOpcode_2A_0T_1R ( BOOLEAN LogicalResult = FALSE; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -686,7 +702,7 @@ AcpiExOpcode_2A_0T_1R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_1R: Unknown opcode %X\n", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -703,9 +719,6 @@ StoreLogicalResult: ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; } - WalkState->ResultObj = ReturnDesc; - - Cleanup: /* Delete return object on error */ @@ -715,6 +728,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); } + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); } |