FreeBSD/sys/contrib/dev/acpica/components/executer/exoparg6.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiExOpcode_6A_0T_1R
 *
 * PARAMETERS:  WalkState           - Current walk state
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
 *
 ******************************************************************************/
AcpiExOpcode_6A_0T_1R
PARAMETERS:  WalkState           - Current walk state

Status

Execute opcode with 6 arguments, no target, and a return value
AcpiExOpcode_6A_0T_1R PARAMETERS : WalkState - Current walk state Status Execute opcode with 6 arguments no target and a return value
ACPI_STATUS
AcpiExOpcode_6A_0T_1R (
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
    ACPI_STATUS             Status = AE_OK;
    UINT64                  Index;
    ACPI_OPERAND_OBJECT     *ThisElement;
    ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
        AcpiPsGetOpcodeName (WalkState->Opcode));
    switch (WalkState->Opcode)
    {
    case AML_MATCH_OP:
        if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
            (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
        {
            ACPI_ERROR ((AE_INFO, "Match operator out of range"));
            Status = AE_AML_OPERAND_VALUE;
            goto Cleanup;
        }
        Index = Operand[5]->Integer.Value;
        if (Index >= Operand[0]->Package.Count)
        {
            ACPI_ERROR ((AE_INFO,
                "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
                ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
            Status = AE_AML_PACKAGE_LIMIT;
            goto Cleanup;
        }
        ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX);
        if (!ReturnDesc)
        {
            Status = AE_NO_MEMORY;
            goto Cleanup;
        }
        for ( ; Index < Operand[0]->Package.Count; Index++)
        {
            ThisElement = Operand[0]->Package.Elements[Index];
            if (!ThisElement)
            {
                continue;
            }
            if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
                    ThisElement, Operand[2]))
            {
                continue;
            }
            if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
                    ThisElement, Operand[4]))
            {
                continue;
            }
            ReturnDesc->Integer.Value = Index;
            break;
        }
        break;
    case AML_LOAD_TABLE_OP:
        Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
        break;
    default:
        ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
            WalkState->Opcode));
        Status = AE_AML_BAD_OPCODE;
        goto Cleanup;
    }
Cleanup:
    if (ACPI_FAILURE (Status))
    {
        AcpiUtRemoveReference (ReturnDesc);
    }
    else
    {
        WalkState->ResultObj = ReturnDesc;
    }
    return_ACPI_STATUS (Status);
}
ACPI_STATUS AcpiExOpcode_6A_0T_1R ( ACPI_WALK_STATE * WalkState ) { ACPI_OPERAND_OBJECT * * Operand = & WalkState -> Operands [ 0 ] ; ACPI_OPERAND_OBJECT * ReturnDesc = NULL ; ACPI_STATUS Status = AE_OK ; UINT64 Index ; ACPI_OPERAND_OBJECT * ThisElement ; ACPI_FUNCTION_TRACE_STR ( ExOpcode_6A_0T_1R , AcpiPsGetOpcodeName ( WalkState -> Opcode ) ) ; switch ( WalkState -> Opcode ) { case AML_MATCH_OP : if ( ( Operand [ 1 ] -> Integer . Value > MAX_MATCH_OPERATOR ) || ( Operand [ 3 ] -> Integer . Value > MAX_MATCH_OPERATOR ) ) { ACPI_ERROR ( ( AE_INFO , " " ) ) ; Status = AE_AML_OPERAND_VALUE ; goto Cleanup ; } Index = Operand [ 5 ] -> Integer . Value ; if ( Index >= Operand [ 0 ] -> Package . Count ) { ACPI_ERROR ( ( AE_INFO , " " , ACPI_FORMAT_UINT64 ( Index ) , Operand [ 0 ] -> Package . Count ) ) ; Status = AE_AML_PACKAGE_LIMIT ; goto Cleanup ; } ReturnDesc = AcpiUtCreateIntegerObject ( ACPI_UINT64_MAX ) ; if ( ! ReturnDesc ) { Status = AE_NO_MEMORY ; goto Cleanup ; } for ( ; Index < Operand [ 0 ] -> Package . Count ; Index ++ ) { ThisElement = Operand [ 0 ] -> Package . Elements [ Index ] ; if ( ! ThisElement ) { continue ; } if ( ! AcpiExDoMatch ( ( UINT32 ) Operand [ 1 ] -> Integer . Value , ThisElement , Operand [ 2 ] ) ) { continue ; } if ( ! AcpiExDoMatch ( ( UINT32 ) Operand [ 3 ] -> Integer . Value , ThisElement , Operand [ 4 ] ) ) { continue ; } ReturnDesc -> Integer . Value = Index ; break ; } break ; case AML_LOAD_TABLE_OP : Status = AcpiExLoadTableOp ( WalkState , & ReturnDesc ) ; break ; default : ACPI_ERROR ( ( AE_INFO , " " , WalkState -> Opcode ) ) ; Status = AE_AML_BAD_OPCODE ; goto Cleanup ; } Cleanup : if ( ACPI_FAILURE ( Status ) ) { AcpiUtRemoveReference ( ReturnDesc ) ; } else { WalkState -> ResultObj = ReturnDesc ; } return_ACPI_STATUS ( Status ) ; }
FUNCTION:    AcpiExOpcode_6A_0T_1R
 PARAMETERS:  WalkState           - Current walk state
FUNCTION : AcpiExOpcode_6A_0T_1R PARAMETERS : WalkState - Current walk state
/*
         * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
         *                      MatchOp2[3], MatchObj2[4], StartIndex[5])
         */ /* Validate both Match Term Operators (MTR, MEQ, etc.) */ /* Get the package StartIndex, validate against the package length */ /* Create an integer for the return value */ /* Default return value is ACPI_UINT64_MAX if no match found */ /*
         * Examine each element until a match is found. Both match conditions
         * must be satisfied for a match to occur. 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
         * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
         * match was found.
         */ /* Get the current package element */ /* Treat any uninitialized (NULL) elements as non-matching */ /*
             * Both match conditions must be satisfied. Execution of a continue
             * (proceed to next iteration of enclosing for loop) signifies a
             * non-match.
             */ /* Match found: Index is the return value */ /* Delete return object on error */ /* Save return object on success */