FreeBSD/sys/contrib/dev/acpica/components/parser/psobject.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiPsBuildNamedOp
 *
 * PARAMETERS:  WalkState           - Current state
 *              AmlOpStart          - Begin of named Op in AML
 *              UnnamedOp           - Early Op (not a named Op)
 *              Op                  - Returned Op
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Parse a named Op
 *
 ******************************************************************************/
AcpiPsBuildNamedOp
PARAMETERS:  WalkState           - Current state
AmlOpStart          - Begin of named Op in AML
UnnamedOp           - Early Op (not a named Op)
Op                  - Returned Op

Status

Parse a named Op
AcpiPsBuildNamedOp PARAMETERS : WalkState - Current state AmlOpStart - Begin of named Op in AML UnnamedOp - Early Op ( not a named Op ) Op - Returned Op Status Parse a named Op
ACPI_STATUS
AcpiPsBuildNamedOp (
    ACPI_WALK_STATE         *WalkState,
    UINT8                   *AmlOpStart,
    ACPI_PARSE_OBJECT       *UnnamedOp,
    ACPI_PARSE_OBJECT       **Op)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_PARSE_OBJECT       *Arg = NULL;
    ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
    UnnamedOp->Common.Value.Arg = NULL;
    UnnamedOp->Common.ArgListLength = 0;
    UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
    while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
          (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
    {
        Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
            GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
        AcpiPsAppendArg (UnnamedOp, Arg);
        INCREMENT_ARG_LIST (WalkState->ArgTypes);
    }
    if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
    {
        return_ACPI_STATUS (AE_AML_NO_OPERAND);
    }
    INCREMENT_ARG_LIST (WalkState->ArgTypes);
    WalkState->Op = NULL;
    Status = WalkState->DescendingCallback (WalkState, Op);
    if (ACPI_FAILURE (Status))
    {
        if (Status != AE_CTRL_TERMINATE)
        {
            ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
        }
        return_ACPI_STATUS (Status);
    }
    if (!*Op)
    {
        return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
    }
    Status = AcpiPsNextParseState (WalkState, *Op, Status);
    if (ACPI_FAILURE (Status))
    {
        if (Status == AE_CTRL_PENDING)
        {
            Status = AE_CTRL_PARSE_PENDING;
        }
        return_ACPI_STATUS (Status);
    }
    AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
    if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
        (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
    {
        (*Op)->Named.Data = AmlOpStart;
        (*Op)->Named.Length = 0;
    }
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiPsBuildNamedOp ( ACPI_WALK_STATE * WalkState , UINT8 * AmlOpStart , ACPI_PARSE_OBJECT * UnnamedOp , ACPI_PARSE_OBJECT * * Op ) { ACPI_STATUS Status = AE_OK ; ACPI_PARSE_OBJECT * Arg = NULL ; ACPI_FUNCTION_TRACE_PTR ( PsBuildNamedOp , WalkState ) ; UnnamedOp -> Common . Value . Arg = NULL ; UnnamedOp -> Common . ArgListLength = 0 ; UnnamedOp -> Common . AmlOpcode = WalkState -> Opcode ; while ( GET_CURRENT_ARG_TYPE ( WalkState -> ArgTypes ) && ( GET_CURRENT_ARG_TYPE ( WalkState -> ArgTypes ) != ARGP_NAME ) ) { Status = AcpiPsGetNextArg ( WalkState , & ( WalkState -> ParserState ) , GET_CURRENT_ARG_TYPE ( WalkState -> ArgTypes ) , & Arg ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } AcpiPsAppendArg ( UnnamedOp , Arg ) ; INCREMENT_ARG_LIST ( WalkState -> ArgTypes ) ; } if ( ! GET_CURRENT_ARG_TYPE ( WalkState -> ArgTypes ) ) { return_ACPI_STATUS ( AE_AML_NO_OPERAND ) ; } INCREMENT_ARG_LIST ( WalkState -> ArgTypes ) ; WalkState -> Op = NULL ; Status = WalkState -> DescendingCallback ( WalkState , Op ) ; if ( ACPI_FAILURE ( Status ) ) { if ( Status != AE_CTRL_TERMINATE ) { ACPI_EXCEPTION ( ( AE_INFO , Status , " " ) ) ; } return_ACPI_STATUS ( Status ) ; } if ( ! * Op ) { return_ACPI_STATUS ( AE_CTRL_PARSE_CONTINUE ) ; } Status = AcpiPsNextParseState ( WalkState , * Op , Status ) ; if ( ACPI_FAILURE ( Status ) ) { if ( Status == AE_CTRL_PENDING ) { Status = AE_CTRL_PARSE_PENDING ; } return_ACPI_STATUS ( Status ) ; } AcpiPsAppendArg ( * Op , UnnamedOp -> Common . Value . Arg ) ; if ( ( * Op ) -> Common . AmlOpcode == AML_REGION_OP || ( * Op ) -> Common . AmlOpcode == AML_DATA_REGION_OP ) { ( * Op ) -> Named . Data = AmlOpStart ; ( * Op ) -> Named . Length = 0 ; } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiPsBuildNamedOp
 PARAMETERS:  WalkState           - Current state
              AmlOpStart          - Begin of named Op in AML
              UnnamedOp           - Early Op (not a named Op)
              Op                  - Returned Op
FUNCTION : AcpiPsBuildNamedOp PARAMETERS : WalkState - Current state AmlOpStart - Begin of named Op in AML UnnamedOp - Early Op ( not a named Op ) Op - Returned Op
/*
     * Get and append arguments until we find the node that contains
     * the name (the type ARGP_NAME).
     */ /*
     * Make sure that we found a NAME and didn't run out of arguments
     */ /* We know that this arg is a name, move to next arg */ /*
     * Find the object. This will either insert the object into
     * the namespace or simply look it up
     */ /*
         * Defer final parsing of an OperationRegion body, because we don't
         * have enough info in the first pass to parse it correctly (i.e.,
         * there may be method calls within the TermArg elements of the body.)
         *
         * However, we must continue parsing because the opregion is not a
         * standalone package -- we don't know where the end is at this point.
         *
         * (Length is unknown until parse of the body complete)
         */