diff options
author | Mike Smith <msmith@FreeBSD.org> | 2001-07-21 03:55:17 +0000 |
---|---|---|
committer | Mike Smith <msmith@FreeBSD.org> | 2001-07-21 03:55:17 +0000 |
commit | 9d5c013ca4e5dbd28bd8af000fb72649e20b08ec (patch) | |
tree | ace3ff94f32745a26e8a131379a4320fd8795556 /sys/contrib/dev/acpica/exmisc.c | |
parent | 2e5c56cb6b4128c20342c3912bb3e8eb095c663f (diff) | |
download | src-9d5c013ca4e5dbd28bd8af000fb72649e20b08ec.tar.gz src-9d5c013ca4e5dbd28bd8af000fb72649e20b08ec.zip |
Vendor import of the Intel ACPI CA 20010717 snapshot.
Notes
Notes:
svn path=/vendor-sys/acpica/dist/; revision=80062
Diffstat (limited to 'sys/contrib/dev/acpica/exmisc.c')
-rw-r--r-- | sys/contrib/dev/acpica/exmisc.c | 483 |
1 files changed, 264 insertions, 219 deletions
diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c index 58bc81556bd4..f4a510caf5fa 100644 --- a/sys/contrib/dev/acpica/exmisc.c +++ b/sys/contrib/dev/acpica/exmisc.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 77 $ + * $Revision: 79 $ * *****************************************************************************/ @@ -214,40 +214,37 @@ Cleanup: /******************************************************************************* * - * FUNCTION: AcpiExIndex + * FUNCTION: AcpiExTriadic * - * PARAMETERS: none + * PARAMETERS: Opcode - The opcode to be executed + * WalkState - Current walk state + * ReturnDesc - Where to store the return object * * RETURN: Status * - * DESCRIPTION: Execute Index operator + * DESCRIPTION: Execute Triadic operator (3 operands) * * ALLOCATION: Deletes one operand descriptor -- other remains on stack * - * ACPI SPECIFICATION REFERENCES: - * DefIndex := IndexOp BuffPkgObj IndexValue Result - * IndexValue := TermArg=>Integer - * NameString := <RootChar NamePath> | <PrefixPath NamePath> - * Result := SuperName - * SuperName := NameString | ArgObj | LocalObj | DebugObj | DefIndex - * Local4Op | Local5Op | Local6Op | Local7Op - * ******************************************************************************/ ACPI_STATUS -AcpiExIndex ( +AcpiExTriadic ( + UINT16 Opcode, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *IdxDesc; + ACPI_OPERAND_OBJECT *ObjDesc1; + ACPI_OPERAND_OBJECT *ObjDesc2; ACPI_OPERAND_OBJECT *ResDesc; ACPI_OPERAND_OBJECT *RetDesc = NULL; ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_SIGNAL_FATAL_INFO *Fatal; ACPI_STATUS Status; - FUNCTION_TRACE ("ExIndex"); + + FUNCTION_TRACE ("ExTriadic"); /* Resolve operands */ @@ -261,8 +258,8 @@ AcpiExIndex ( /* Get all operands */ Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc1, WalkState); if (ACPI_FAILURE (Status)) { /* Invalid parameters on object stack */ @@ -273,94 +270,139 @@ AcpiExIndex ( } - /* Create the internal return object */ - RetDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!RetDesc) + switch (Opcode) { - Status = AE_NO_MEMORY; - goto Cleanup; - } + case AML_FATAL_OP: - /* - * At this point, the ObjDesc operand is either a Package or a Buffer - */ + /* DefFatal := FatalOp FatalType FatalCode FatalArg */ - if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Object to be indexed is a Package */ + DEBUG_PRINTP (ACPI_INFO, + ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (UINT32) ObjDesc1->Integer.Value, (UINT32) ObjDesc2->Integer.Value, + (UINT32) ResDesc->Integer.Value)); - if (IdxDesc->Integer.Value >= ObjDesc->Package.Count) + + Fatal = ACPI_MEM_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); + if (Fatal) { - DEBUG_PRINTP (ACPI_ERROR, ("Index value beyond package end\n")); - Status = AE_AML_PACKAGE_LIMIT; - goto Cleanup; + Fatal->Type = (UINT32) ObjDesc1->Integer.Value; + Fatal->Code = (UINT32) ObjDesc2->Integer.Value; + Fatal->Argument = (UINT32) ResDesc->Integer.Value; } - if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && - (ResDesc->Reference.Opcode == AML_ZERO_OP)) - { - /* - * There is no actual result descriptor (the ZeroOp Result - * descriptor is a placeholder), so just delete the placeholder and - * return a reference to the package element - */ + /* + * Signal the OS + */ + AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); - AcpiUtRemoveReference (ResDesc); - } + /* Might return while OS is shutting down */ - else - { - /* - * Each element of the package is an internal object. Get the one - * we are after. - */ + ACPI_MEM_FREE (Fatal); + break; - TmpDesc = ObjDesc->Package.Elements[IdxDesc->Integer.Value]; - RetDesc->Reference.Opcode = AML_INDEX_OP; - RetDesc->Reference.TargetType = TmpDesc->Common.Type; - RetDesc->Reference.Object = TmpDesc; - Status = AcpiExStore (RetDesc, ResDesc, WalkState); - RetDesc->Reference.Object = NULL; - } - /* - * The local return object must always be a reference to the package element, - * not the element itself. - */ - RetDesc->Reference.Opcode = AML_INDEX_OP; - RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Integer.Value]; - } + case AML_MID_OP: + + /* DefMid := MidOp Source Index Length Result */ + + /* Create the internal return object (string or buffer) */ + + break; - else - { - /* Object to be indexed is a Buffer */ - if (IdxDesc->Integer.Value >= ObjDesc->Buffer.Length) + case AML_INDEX_OP: + + /* DefIndex := IndexOp Source Index Destination */ + + /* Create the internal return object */ + + RetDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!RetDesc) { - DEBUG_PRINTP (ACPI_ERROR, ("Index value beyond end of buffer\n")); - Status = AE_AML_BUFFER_LIMIT; + Status = AE_NO_MEMORY; goto Cleanup; } + /* + * At this point, the ObjDesc1 operand is either a Package or a Buffer + */ + if (ObjDesc1->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Object to be indexed is a Package */ + + if (ObjDesc2->Integer.Value >= ObjDesc1->Package.Count) + { + DEBUG_PRINTP (ACPI_ERROR, ("Index value beyond package end\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && + (ResDesc->Reference.Opcode == AML_ZERO_OP)) + { + /* + * There is no actual result descriptor (the ZeroOp Result + * descriptor is a placeholder), so just delete the placeholder and + * return a reference to the package element + */ + AcpiUtRemoveReference (ResDesc); + } + + else + { + /* + * Each element of the package is an internal object. Get the one + * we are after. + */ + TmpDesc = ObjDesc1->Package.Elements[ObjDesc2->Integer.Value]; + RetDesc->Reference.Opcode = AML_INDEX_OP; + RetDesc->Reference.TargetType = TmpDesc->Common.Type; + RetDesc->Reference.Object = TmpDesc; + + Status = AcpiExStore (RetDesc, ResDesc, WalkState); + RetDesc->Reference.Object = NULL; + } + + /* + * The local return object must always be a reference to the package element, + * not the element itself. + */ + RetDesc->Reference.Opcode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + RetDesc->Reference.Where = &ObjDesc1->Package.Elements[ObjDesc2->Integer.Value]; + } + + else + { + /* Object to be indexed is a Buffer */ - RetDesc->Reference.Opcode = AML_INDEX_OP; - RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - RetDesc->Reference.Object = ObjDesc; - RetDesc->Reference.Offset = (UINT32) IdxDesc->Integer.Value; + if (ObjDesc2->Integer.Value >= ObjDesc1->Buffer.Length) + { + DEBUG_PRINTP (ACPI_ERROR, ("Index value beyond end of buffer\n")); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } - Status = AcpiExStore (RetDesc, ResDesc, WalkState); + RetDesc->Reference.Opcode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + RetDesc->Reference.Object = ObjDesc1; + RetDesc->Reference.Offset = (UINT32) ObjDesc2->Integer.Value; + + Status = AcpiExStore (RetDesc, ResDesc, WalkState); + } + break; } + Cleanup: /* Always delete operands */ - AcpiUtRemoveReference (ObjDesc); - AcpiUtRemoveReference (IdxDesc); + AcpiUtRemoveReference (ObjDesc1); + AcpiUtRemoveReference (ObjDesc2); /* Delete return object on error */ @@ -384,28 +426,21 @@ Cleanup: /******************************************************************************* * - * FUNCTION: AcpiExMatch + * FUNCTION: AcpiExHexadic * - * PARAMETERS: none + * PARAMETERS: Opcode - The opcode to be executed + * WalkState - Current walk state + * ReturnDesc - Where to store the return object * * RETURN: Status * * DESCRIPTION: Execute Match operator * - * ACPI SPECIFICATION REFERENCES: - * DefMatch := MatchOp SearchPkg Opcode1 Operand1 - * Opcode2 Operand2 StartIndex - * Opcode1 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT - * Opcode2 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT - * Operand1 := TermArg=>Integer - * Operand2 := TermArg=>Integer - * SearchPkg := TermArg=>PackageObject - * StartIndex := TermArg=>Integer - * ******************************************************************************/ ACPI_STATUS -AcpiExMatch ( +AcpiExHexadic ( + UINT16 Opcode, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc) { @@ -421,7 +456,7 @@ AcpiExMatch ( UINT32 MatchValue = (UINT32) -1; - FUNCTION_TRACE ("ExMatch"); + FUNCTION_TRACE ("ExHexadic"); /* Resolve all operands */ @@ -449,197 +484,207 @@ AcpiExMatch ( goto Cleanup; } - /* Validate match comparison sub-opcodes */ - if ((Op1Desc->Integer.Value > MAX_MATCH_OPERATOR) || - (Op2Desc->Integer.Value > MAX_MATCH_OPERATOR)) + switch (Opcode) { - DEBUG_PRINTP (ACPI_ERROR, ("operation encoding out of range\n")); - Status = AE_AML_OPERAND_VALUE; - goto Cleanup; - } - Index = (UINT32) StartDesc->Integer.Value; - if (Index >= (UINT32) PkgDesc->Package.Count) - { - DEBUG_PRINTP (ACPI_ERROR, ("Start position value out of range\n")); - Status = AE_AML_PACKAGE_LIMIT; - goto Cleanup; - } + case AML_MATCH_OP: - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; + /* Validate match comparison sub-opcodes */ - } + if ((Op1Desc->Integer.Value > MAX_MATCH_OPERATOR) || + (Op2Desc->Integer.Value > MAX_MATCH_OPERATOR)) + { + DEBUG_PRINTP (ACPI_ERROR, ("operation encoding out of range\n")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } - /* - * Examine each element until a match is found. Within the loop, - * "continue" signifies that the current element does not match - * and the next should be examined. - * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", MatchValue will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. - */ + Index = (UINT32) StartDesc->Integer.Value; + if (Index >= (UINT32) PkgDesc->Package.Count) + { + DEBUG_PRINTP (ACPI_ERROR, ("Start position value out of range\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } - for ( ; Index < PkgDesc->Package.Count; ++Index) - { - /* - * Treat any NULL or non-numeric elements as non-matching. - * TBD [Unhandled] - if an element is a Name, - * should we examine its value? - */ - if (!PkgDesc->Package.Elements[Index] || - ACPI_TYPE_INTEGER != PkgDesc->Package.Elements[Index]->Common.Type) + RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!RetDesc) { - continue; + Status = AE_NO_MEMORY; + goto Cleanup; + } /* - * Within these switch statements: - * "break" (exit from the switch) signifies a match; - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. + * Examine each element until a match is found. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be -1 + * (its initial value) indicating that no match was found. When + * returned as a Number, this will produce the Ones value as specified. */ - switch (Op1Desc->Integer.Value) + + for ( ; Index < PkgDesc->Package.Count; ++Index) { + /* + * Treat any NULL or non-numeric elements as non-matching. + * TBD [Unhandled] - if an element is a Name, + * should we examine its value? + */ + if (!PkgDesc->Package.Elements[Index] || + ACPI_TYPE_INTEGER != PkgDesc->Package.Elements[Index]->Common.Type) + { + continue; + } - case MATCH_MTR: /* always true */ + /* + * Within these switch statements: + * "break" (exit from the switch) signifies a match; + * "continue" (proceed to next iteration of enclosing + * "for" loop) signifies a non-match. + */ + switch (Op1Desc->Integer.Value) + { - break; + case MATCH_MTR: /* always true */ + break; - case MATCH_MEQ: /* true if equal */ - if (PkgDesc->Package.Elements[Index]->Integer.Value - != V1Desc->Integer.Value) - { - continue; - } - break; + case MATCH_MEQ: /* true if equal */ + if (PkgDesc->Package.Elements[Index]->Integer.Value + != V1Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MLE: /* true if less than or equal */ - if (PkgDesc->Package.Elements[Index]->Integer.Value - > V1Desc->Integer.Value) - { - continue; - } - break; + case MATCH_MLE: /* true if less than or equal */ + if (PkgDesc->Package.Elements[Index]->Integer.Value + > V1Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MLT: /* true if less than */ - if (PkgDesc->Package.Elements[Index]->Integer.Value - >= V1Desc->Integer.Value) - { - continue; - } - break; + case MATCH_MLT: /* true if less than */ + if (PkgDesc->Package.Elements[Index]->Integer.Value + >= V1Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MGE: /* true if greater than or equal */ - if (PkgDesc->Package.Elements[Index]->Integer.Value - < V1Desc->Integer.Value) - { - continue; - } - break; + case MATCH_MGE: /* true if greater than or equal */ + if (PkgDesc->Package.Elements[Index]->Integer.Value + < V1Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MGT: /* true if greater than */ - if (PkgDesc->Package.Elements[Index]->Integer.Value - <= V1Desc->Integer.Value) - { + case MATCH_MGT: /* true if greater than */ + + if (PkgDesc->Package.Elements[Index]->Integer.Value + <= V1Desc->Integer.Value) + { + continue; + } + break; + + + default: /* undefined */ + continue; } - break; - default: /* undefined */ + switch(Op2Desc->Integer.Value) + { - continue; - } + case MATCH_MTR: + break; - switch(Op2Desc->Integer.Value) - { - case MATCH_MTR: + case MATCH_MEQ: - break; + if (PkgDesc->Package.Elements[Index]->Integer.Value + != V2Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MEQ: + case MATCH_MLE: - if (PkgDesc->Package.Elements[Index]->Integer.Value - != V2Desc->Integer.Value) - { - continue; - } - break; + if (PkgDesc->Package.Elements[Index]->Integer.Value + > V2Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MLE: + case MATCH_MLT: - if (PkgDesc->Package.Elements[Index]->Integer.Value - > V2Desc->Integer.Value) - { - continue; - } - break; + if (PkgDesc->Package.Elements[Index]->Integer.Value + >= V2Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MLT: + case MATCH_MGE: - if (PkgDesc->Package.Elements[Index]->Integer.Value - >= V2Desc->Integer.Value) - { - continue; - } - break; + if (PkgDesc->Package.Elements[Index]->Integer.Value + < V2Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MGE: + case MATCH_MGT: - if (PkgDesc->Package.Elements[Index]->Integer.Value - < V2Desc->Integer.Value) - { - continue; - } - break; + if (PkgDesc->Package.Elements[Index]->Integer.Value + <= V2Desc->Integer.Value) + { + continue; + } + break; - case MATCH_MGT: + default: - if (PkgDesc->Package.Elements[Index]->Integer.Value - <= V2Desc->Integer.Value) - { continue; } - break; + /* Match found: exit from loop */ - default: - - continue; + MatchValue = Index; + break; } - /* Match found: exit from loop */ + /* MatchValue is the return value */ - MatchValue = Index; + RetDesc->Integer.Value = MatchValue; break; - } - /* MatchValue is the return value */ + } - RetDesc->Integer.Value = MatchValue; Cleanup: |