kernel/acpica/compiler/aslcodegen.c
/*******************************************************************************
 *
 * FUNCTION:    CgWriteAmlOpcode
 *
 * PARAMETERS:  Op            - Parse node with an AML opcode
 *
 * RETURN:      None.
 *
 * DESCRIPTION: Write the AML opcode corresponding to a parse node.
 *
 ******************************************************************************/
CgWriteAmlOpcode
PARAMETERS:  Op            - Parse node with an AML opcode

None.

Write the AML opcode corresponding to a parse node.
CgWriteAmlOpcode PARAMETERS : Op - Parse node with an AML opcode None . Write the AML opcode corresponding to a parse node .
static void
CgWriteAmlOpcode (
    ACPI_PARSE_OBJECT       *Op)
{
    UINT8                   PkgLenFirstByte;
    UINT32                  i;
    union {
        UINT16                  Opcode;
        UINT8                   OpcodeBytes[2];
    } Aml;
    union {
        UINT32                  Len;
        UINT8                   LenBytes[4];
    } PkgLen;
    if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
    {
        return;
    }
    if (Gbl_CaptureComments)
    {
        CgWriteAmlComment(Op);
    }
    switch (Op->Asl.AmlOpcode)
    {
    case AML_UNASSIGNED_OPCODE:
        printf ("Found a node with an unassigned AML opcode\n");
        FlPrintFile (ASL_FILE_STDERR,
            "Found a node with an unassigned AML opcode\n");
        return;
    case AML_INT_RESERVEDFIELD_OP:
        Aml.Opcode = AML_FIELD_OFFSET_OP;
        break;
    case AML_INT_ACCESSFIELD_OP:
        Aml.Opcode = AML_FIELD_ACCESS_OP;
        break;
    case AML_INT_CONNECTION_OP:
        Aml.Opcode = AML_FIELD_CONNECTION_OP;
        break;
    default:
        Aml.Opcode = Op->Asl.AmlOpcode;
        break;
    }
    switch (Aml.Opcode)
    {
    case AML_PACKAGE_LENGTH:
        PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
        break;
    default:
        if (Aml.Opcode > 0x00FF)
        {
            CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
        }
        CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
        PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
        break;
    }
    if (Op->Asl.CompileFlags & OP_AML_PACKAGE)
    {
        if (Op->Asl.AmlPkgLenBytes == 1)
        {
            CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
        }
        else if (Op->Asl.AmlPkgLenBytes != 0)
        {
            PkgLenFirstByte = (UINT8)
                (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
                (PkgLen.LenBytes[0] & 0x0F));
            CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
            PkgLen.Len >>= 4;
            for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
            {
                CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
            }
        }
    }
    switch (Aml.Opcode)
    {
    case AML_BYTE_OP:
        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
        break;
    case AML_WORD_OP:
        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
       break;
    case AML_DWORD_OP:
        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
        break;
    case AML_QWORD_OP:
        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
        break;
    case AML_STRING_OP:
        CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
        break;
    default:
        break;
    }
}
static void CgWriteAmlOpcode ( ACPI_PARSE_OBJECT * Op ) { UINT8 PkgLenFirstByte ; UINT32 i ; union { UINT16 Opcode ; UINT8 OpcodeBytes [ 2 ] ; } Aml ; union { UINT32 Len ; UINT8 LenBytes [ 4 ] ; } PkgLen ; if ( Op -> Asl . ParseOpcode == PARSEOP_DEFAULT_ARG ) { return ; } if ( Gbl_CaptureComments ) { CgWriteAmlComment ( Op ) ; } switch ( Op -> Asl . AmlOpcode ) { case AML_UNASSIGNED_OPCODE : printf ( " \n " ) ; FlPrintFile ( ASL_FILE_STDERR , " \n " ) ; return ; case AML_INT_RESERVEDFIELD_OP : Aml . Opcode = AML_FIELD_OFFSET_OP ; break ; case AML_INT_ACCESSFIELD_OP : Aml . Opcode = AML_FIELD_ACCESS_OP ; break ; case AML_INT_CONNECTION_OP : Aml . Opcode = AML_FIELD_CONNECTION_OP ; break ; default : Aml . Opcode = Op -> Asl . AmlOpcode ; break ; } switch ( Aml . Opcode ) { case AML_PACKAGE_LENGTH : PkgLen . Len = ( UINT32 ) Op -> Asl . Value . Integer ; break ; default : if ( Aml . Opcode > 0x00FF ) { CgLocalWriteAmlData ( Op , & Aml . OpcodeBytes [ 1 ] , 1 ) ; } CgLocalWriteAmlData ( Op , & Aml . OpcodeBytes [ 0 ] , 1 ) ; PkgLen . Len = Op -> Asl . AmlSubtreeLength + Op -> Asl . AmlPkgLenBytes ; break ; } if ( Op -> Asl . CompileFlags & OP_AML_PACKAGE ) { if ( Op -> Asl . AmlPkgLenBytes == 1 ) { CgLocalWriteAmlData ( Op , & PkgLen . LenBytes [ 0 ] , 1 ) ; } else if ( Op -> Asl . AmlPkgLenBytes != 0 ) { PkgLenFirstByte = ( UINT8 ) ( ( ( UINT32 ) ( Op -> Asl . AmlPkgLenBytes - 1 ) << 6 ) | ( PkgLen . LenBytes [ 0 ] & 0x0F ) ) ; CgLocalWriteAmlData ( Op , & PkgLenFirstByte , 1 ) ; PkgLen . Len >>= 4 ; for ( i = 0 ; i < ( UINT32 ) ( Op -> Asl . AmlPkgLenBytes - 1 ) ; i ++ ) { CgLocalWriteAmlData ( Op , & PkgLen . LenBytes [ i ] , 1 ) ; } } } switch ( Aml . Opcode ) { case AML_BYTE_OP : CgLocalWriteAmlData ( Op , & Op -> Asl . Value . Integer , 1 ) ; break ; case AML_WORD_OP : CgLocalWriteAmlData ( Op , & Op -> Asl . Value . Integer , 2 ) ; break ; case AML_DWORD_OP : CgLocalWriteAmlData ( Op , & Op -> Asl . Value . Integer , 4 ) ; break ; case AML_QWORD_OP : CgLocalWriteAmlData ( Op , & Op -> Asl . Value . Integer , 8 ) ; break ; case AML_STRING_OP : CgLocalWriteAmlData ( Op , Op -> Asl . Value . String , Op -> Asl . AmlLength ) ; break ; default : break ; } }
FUNCTION:    CgWriteAmlOpcode
 PARAMETERS:  Op            - Parse node with an AML opcode
FUNCTION : CgWriteAmlOpcode PARAMETERS : Op - Parse node with an AML opcode
/* We expect some DEFAULT_ARGs, just ignore them */ /*
     * Before printing the bytecode, generate comment byte codes
     * associated with this node.
     */ /* These opcodes should not get here */ /* Special opcodes for within a field definition */ /* Value is the length to be encoded (Used in field definitions) */ /* Check for two-byte opcode */ /* Write the high byte first */ /* Subtreelength doesn't include length of package length bytes */ /* Does this opcode have an associated "PackageLength" field? */ /* Simplest case -- no bytes to follow, just write the count */ /*
             * Encode the "bytes to follow" in the first byte, top two bits.
             * The low-order nybble of the length is in the bottom 4 bits
             */ /*
             * Shift the length over by the 4 bits we just stuffed
             * in the first byte
             */ /*
             * Now we can write the remaining bytes -
             * either 1, 2, or 3 bytes
             */ /* All data opcodes must appear above */