FreeBSD/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c
/******************************************************************************
 *
 * FUNCTION:    AcpiDmDeferredParse
 *
 * PARAMETERS:  Op                  - Root Op of the deferred opcode
 *              Aml                 - Pointer to the raw AML
 *              AmlLength           - Length of the AML
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Parse one deferred opcode
 *              (Methods, operation regions, etc.)
 *
 *****************************************************************************/
AcpiDmDeferredParse
PARAMETERS:  Op                  - Root Op of the deferred opcode
Aml                 - Pointer to the raw AML
AmlLength           - Length of the AML

Status

Parse one deferred opcode
(Methods, operation regions, etc.)
AcpiDmDeferredParse PARAMETERS : Op - Root Op of the deferred opcode Aml - Pointer to the raw AML AmlLength - Length of the AML Status Parse one deferred opcode ( Methods operation regions etc . )
static ACPI_STATUS
AcpiDmDeferredParse (
    ACPI_PARSE_OBJECT       *Op,
    UINT8                   *Aml,
    UINT32                  AmlLength)
{
    ACPI_WALK_STATE         *WalkState;
    ACPI_STATUS             Status;
    ACPI_PARSE_OBJECT       *SearchOp;
    ACPI_PARSE_OBJECT       *StartOp;
    ACPI_PARSE_OBJECT       *NewRootOp;
    ACPI_PARSE_OBJECT       *ExtraOp;
    ACPI_FUNCTION_TRACE (DmDeferredParse);
    if (!Aml || !AmlLength)
    {
        return_ACPI_STATUS (AE_OK);
    }
    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Parsing deferred opcode %s [%4.4s]\n",
        Op->Common.AmlOpName, (char *) &Op->Named.Name));
    WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
    if (!WalkState)
    {
        return_ACPI_STATUS (AE_NO_MEMORY);
    }
    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, Aml,
        AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
    WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
    Status = AcpiPsParseAml (WalkState);
    StartOp = (Op->Common.Value.Arg)->Common.Next;
    SearchOp = StartOp;
    while (SearchOp)
    {
        SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
    }
    switch (Op->Common.AmlOpcode)
    {
    case AML_BUFFER_OP:
    case AML_PACKAGE_OP:
    case AML_VAR_PACKAGE_OP:
        switch (Op->Common.AmlOpcode)
        {
        case AML_PACKAGE_OP:
            ExtraOp = Op->Common.Value.Arg;
            NewRootOp = ExtraOp->Common.Next;
            ACPI_FREE (ExtraOp);
            break;
        case AML_VAR_PACKAGE_OP:
        case AML_BUFFER_OP:
        default:
            NewRootOp = Op->Common.Value.Arg;
            break;
        }
        Op->Common.Value.Arg = NewRootOp->Common.Value.Arg;
        StartOp = Op;
        SearchOp = StartOp;
        while (SearchOp)
        {
            if (SearchOp->Common.Parent == NewRootOp)
            {
                SearchOp->Common.Parent = Op;
            }
            SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
        }
        ACPI_FREE (NewRootOp);
        break;
    default:
        break;
    }
    return_ACPI_STATUS (AE_OK);
}
static ACPI_STATUS AcpiDmDeferredParse ( ACPI_PARSE_OBJECT * Op , UINT8 * Aml , UINT32 AmlLength ) { ACPI_WALK_STATE * WalkState ; ACPI_STATUS Status ; ACPI_PARSE_OBJECT * SearchOp ; ACPI_PARSE_OBJECT * StartOp ; ACPI_PARSE_OBJECT * NewRootOp ; ACPI_PARSE_OBJECT * ExtraOp ; ACPI_FUNCTION_TRACE ( DmDeferredParse ) ; if ( ! Aml || ! AmlLength ) { return_ACPI_STATUS ( AE_OK ) ; } ACPI_DEBUG_PRINT ( ( ACPI_DB_INFO , " \n " , Op -> Common . AmlOpName , ( char * ) & Op -> Named . Name ) ) ; WalkState = AcpiDsCreateWalkState ( 0 , Op , NULL , NULL ) ; if ( ! WalkState ) { return_ACPI_STATUS ( AE_NO_MEMORY ) ; } Status = AcpiDsInitAmlWalk ( WalkState , Op , NULL , Aml , AmlLength , NULL , ACPI_IMODE_LOAD_PASS1 ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } WalkState -> ParseFlags &= ~ ACPI_PARSE_DELETE_TREE ; WalkState -> ParseFlags |= ACPI_PARSE_DISASSEMBLE ; Status = AcpiPsParseAml ( WalkState ) ; StartOp = ( Op -> Common . Value . Arg ) -> Common . Next ; SearchOp = StartOp ; while ( SearchOp ) { SearchOp = AcpiPsGetDepthNext ( StartOp , SearchOp ) ; } switch ( Op -> Common . AmlOpcode ) { case AML_BUFFER_OP : case AML_PACKAGE_OP : case AML_VAR_PACKAGE_OP : switch ( Op -> Common . AmlOpcode ) { case AML_PACKAGE_OP : ExtraOp = Op -> Common . Value . Arg ; NewRootOp = ExtraOp -> Common . Next ; ACPI_FREE ( ExtraOp ) ; break ; case AML_VAR_PACKAGE_OP : case AML_BUFFER_OP : default : NewRootOp = Op -> Common . Value . Arg ; break ; } Op -> Common . Value . Arg = NewRootOp -> Common . Value . Arg ; StartOp = Op ; SearchOp = StartOp ; while ( SearchOp ) { if ( SearchOp -> Common . Parent == NewRootOp ) { SearchOp -> Common . Parent = Op ; } SearchOp = AcpiPsGetDepthNext ( StartOp , SearchOp ) ; } ACPI_FREE ( NewRootOp ) ; break ; default : break ; } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiDmDeferredParse
 PARAMETERS:  Op                  - Root Op of the deferred opcode
              Aml                 - Pointer to the raw AML
              AmlLength           - Length of the AML
FUNCTION : AcpiDmDeferredParse PARAMETERS : Op - Root Op of the deferred opcode Aml - Pointer to the raw AML AmlLength - Length of the AML
/* Need a new walk state to parse the AML */ /* Parse the AML for this deferred opcode */ /*
     * For Buffer and Package opcodes, link the newly parsed subtree
     * into the main parse tree
     */ /* Must point all parents to the main tree */