FreeBSD/sys/contrib/dev/acpica/components/parser/psobject.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiPsGetAmlOpcode
 *
 * PARAMETERS:  WalkState           - Current state
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Extract the next AML opcode from the input stream.
 *
 ******************************************************************************/


Status

Extract the next AML opcode from the input stream.
Status Extract the next AML opcode from the input stream .
static ACPI_STATUS
AcpiPsGetAmlOpcode (
    ACPI_WALK_STATE         *WalkState)
{
    UINT32                  AmlOffset;
    ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
    WalkState->Aml = WalkState->ParserState.Aml;
    WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
    WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
    switch (WalkState->OpInfo->Class)
    {
    case AML_CLASS_ASCII:
    case AML_CLASS_PREFIX:
        WalkState->Opcode = AML_INT_NAMEPATH_OP;
        WalkState->ArgTypes = ARGP_NAMESTRING;
        break;
    case AML_CLASS_UNKNOWN:
        if (WalkState->PassNumber == 2)
        {
            AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
                WalkState->ParserState.AmlStart);
            ACPI_ERROR ((AE_INFO,
                "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
                WalkState->Opcode,
                (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER))));
            ACPI_DUMP_BUFFER ((WalkState->ParserState.Aml - 16), 48);
#ifdef ACPI_ASL_COMPILER
            AcpiOsPrintf (
                "/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
                WalkState->Opcode,
                (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER)));
            AcpiUtDumpBuffer (((UINT8 *) WalkState->ParserState.Aml - 16),
                48, DB_BYTE_DISPLAY,
                (AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16));
            AcpiOsPrintf (" */\n");
#endif
        }
        WalkState->ParserState.Aml++;
        if (WalkState->Opcode > 0xFF) 
        {
            WalkState->ParserState.Aml++;
        }
        return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
    default:
        WalkState->ParserState.Aml +=
            AcpiPsGetOpcodeSize (WalkState->Opcode);
        WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
        break;
    }
    return_ACPI_STATUS (AE_OK);
}
static ACPI_STATUS AcpiPsGetAmlOpcode ( ACPI_WALK_STATE * WalkState ) { UINT32 AmlOffset ; ACPI_FUNCTION_TRACE_PTR ( PsGetAmlOpcode , WalkState ) ; WalkState -> Aml = WalkState -> ParserState . Aml ; WalkState -> Opcode = AcpiPsPeekOpcode ( & ( WalkState -> ParserState ) ) ; WalkState -> OpInfo = AcpiPsGetOpcodeInfo ( WalkState -> Opcode ) ; switch ( WalkState -> OpInfo -> Class ) { case AML_CLASS_ASCII : case AML_CLASS_PREFIX : WalkState -> Opcode = AML_INT_NAMEPATH_OP ; WalkState -> ArgTypes = ARGP_NAMESTRING ; break ; case AML_CLASS_UNKNOWN : if ( WalkState -> PassNumber == 2 ) { AmlOffset = ( UINT32 ) ACPI_PTR_DIFF ( WalkState -> Aml , WalkState -> ParserState . AmlStart ) ; ACPI_ERROR ( ( AE_INFO , " " , WalkState -> Opcode , ( UINT32 ) ( AmlOffset + sizeof ( ACPI_TABLE_HEADER ) ) ) ) ; ACPI_DUMP_BUFFER ( ( WalkState -> ParserState . Aml - 16 ) , 48 ) ; #ifdef ACPI_ASL_COMPILER AcpiOsPrintf ( " \n \n " , WalkState -> Opcode , ( UINT32 ) ( AmlOffset + sizeof ( ACPI_TABLE_HEADER ) ) ) ; AcpiUtDumpBuffer ( ( ( UINT8 * ) WalkState -> ParserState . Aml - 16 ) , 48 , DB_BYTE_DISPLAY , ( AmlOffset + sizeof ( ACPI_TABLE_HEADER ) - 16 ) ) ; AcpiOsPrintf ( " \n " ) ; #endif } WalkState -> ParserState . Aml ++ ; if ( WalkState -> Opcode > 0xFF ) { WalkState -> ParserState . Aml ++ ; } return_ACPI_STATUS ( AE_CTRL_PARSE_CONTINUE ) ; default : WalkState -> ParserState . Aml += AcpiPsGetOpcodeSize ( WalkState -> Opcode ) ; WalkState -> ArgTypes = WalkState -> OpInfo -> ParseArgs ; break ; } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiPsGetAmlOpcode
 PARAMETERS:  WalkState           - Current state
FUNCTION : AcpiPsGetAmlOpcode PARAMETERS : WalkState - Current state
/*
     * First cut to determine what we have found:
     * 1) A valid AML opcode
     * 2) A name string
     * 3) An unknown/invalid opcode
     */ /*
         * Starts with a valid prefix or ASCII char, this is a name
         * string. Convert the bare name string to a namepath.
         */ /* The opcode is unrecognized. Complain and skip unknown opcodes */ /*
             * This is executed for the disassembler only. Output goes
             * to the disassembled ASL output file.
             */ /* Dump the context surrounding the invalid opcode */ /* Increment past one-byte or two-byte opcode */ /* Can only happen if first byte is 0x5B */ /* Found opcode info, this is a normal opcode */