Home | History | Annotate | Line # | Download | only in compiler
asldefine.h revision 1.1.1.23
      1 /******************************************************************************
      2  *
      3  * Module Name: asldefine.h - Common defines for the iASL compiler
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2023, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #ifndef __ASLDEFINE_H
     45 #define __ASLDEFINE_H
     46 
     47 
     48 /*
     49  * Compiler versions and names
     50  */
     51 #define ASL_COMPILER_NAME           "ASL+ Optimizing Compiler/Disassembler"
     52 #define AML_DISASSEMBLER_NAME       "AML/ASL+ Disassembler"
     53 #define ASL_INVOCATION_NAME         "iasl"
     54 #define ASL_CREATOR_ID              "INTL"
     55 #define ASL_DEFINE                  "__IASL__"
     56 #define ASL_PREFIX                  "iASL: "
     57 #define ASL_COMPLIANCE              "Supports ACPI Specification Revision 6.5"
     58 
     59 
     60 /* Configuration constants */
     61 
     62 #define ASL_MAX_ERROR_COUNT         200
     63 #define ASL_PARSEOP_CACHE_SIZE      (1024 * 16)
     64 #define ASL_STRING_CACHE_SIZE       (1024 * 64)
     65 
     66 #define ASL_FIRST_PARSE_OPCODE      PARSEOP_ACCESSAS
     67 #define ASL_PARSE_OPCODE_BASE       PARSEOP_ACCESSAS        /* First Lex type */
     68 
     69 
     70 /*
     71  * Per-parser-generator configuration. These values are used to cheat and
     72  * directly access the bison/yacc token name table (yyname or yytname).
     73  * Note: These values are the index in yyname for the first lex token
     74  * (PARSEOP_ACCCESSAS).
     75  */
     76 #if defined (YYBISON)
     77 #define ASL_YYTNAME_START           3   /* Bison */
     78 #elif defined (YYBYACC)
     79 #define ASL_YYTNAME_START           257 /* Berkeley yacc */
     80 #endif
     81 
     82 
     83 /*
     84  * Macros
     85  */
     86 #define ASL_RESDESC_OFFSET(m)       ACPI_OFFSET (AML_RESOURCE, m)
     87 #define ASL_PTR_DIFF(a,b)           ((UINT8 *)(b) - (UINT8 *)(a))
     88 #define ASL_PTR_ADD(a,b)            ((UINT8 *)(a) = ((UINT8 *)(a) + (b)))
     89 #define ASL_GET_CHILD_NODE(a)       (a)->Asl.Child
     90 #define ASL_GET_PEER_NODE(a)        (a)->Asl.Next
     91 #define OP_TABLE_ENTRY(a,b,c,d)     {b,d,a,c}
     92 
     93 
     94 /* Internal AML opcodes */
     95 
     96 #define AML_RAW_DATA_BYTE           (UINT16) 0xAA01 /* write one raw byte */
     97 #define AML_RAW_DATA_WORD           (UINT16) 0xAA02 /* write 2 raw bytes */
     98 #define AML_RAW_DATA_DWORD          (UINT16) 0xAA04 /* write 4 raw bytes */
     99 #define AML_RAW_DATA_QWORD          (UINT16) 0xAA08 /* write 8 raw bytes */
    100 #define AML_RAW_DATA_BUFFER         (UINT16) 0xAA0B /* raw buffer with length */
    101 #define AML_RAW_DATA_CHAIN          (UINT16) 0xAA0C /* chain of raw buffers */
    102 #define AML_PACKAGE_LENGTH          (UINT16) 0xAA10
    103 #define AML_UNASSIGNED_OPCODE       (UINT16) 0xEEEE
    104 #define AML_DEFAULT_ARG_OP          (UINT16) 0xDDDD
    105 
    106 
    107 /* Types for input files */
    108 
    109 #define ASL_INPUT_TYPE_BINARY               0
    110 #define ASL_INPUT_TYPE_BINARY_ACPI_TABLE    1
    111 #define ASL_INPUT_TYPE_ASCII_ASL            2
    112 #define ASL_INPUT_TYPE_ASCII_DATA           3
    113 
    114 
    115 /* Misc */
    116 
    117 #define ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS  255
    118 #define ASL_ABORT                           TRUE
    119 #define ASL_NO_ABORT                        FALSE
    120 #define ASL_EOF                             ACPI_UINT32_MAX
    121 #define ASL_IGNORE_LINE                     (ACPI_UINT32_MAX -1)
    122 #define ASL_ERROR_CODE_LENGTH               4
    123 
    124 
    125 /* Listings */
    126 
    127 #define ASL_LISTING_LINE_PREFIX         ":  "
    128 
    129 
    130 /* Support for reserved method names */
    131 
    132 #define ACPI_VALID_RESERVED_NAME_MAX    0x80000000
    133 #define ACPI_NOT_RESERVED_NAME          ACPI_UINT32_MAX
    134 #define ACPI_PREDEFINED_NAME            (ACPI_UINT32_MAX - 1)
    135 #define ACPI_EVENT_RESERVED_NAME        (ACPI_UINT32_MAX - 2)
    136 #define ACPI_COMPILER_RESERVED_NAME     (ACPI_UINT32_MAX - 3)
    137 
    138 
    139 /* Helper macros for resource tag creation */
    140 
    141 #define RsCreateMultiBitField \
    142     RsCreateResourceField
    143 
    144 #define RsCreateBitField(Op, Name, ByteOffset, BitOffset) \
    145     RsCreateResourceField (Op, Name, ByteOffset, BitOffset, 1)
    146 
    147 #define RsCreateByteField(Op, Name, ByteOffset) \
    148     RsCreateResourceField (Op, Name, ByteOffset, 0, 8);
    149 
    150 #define RsCreateWordField(Op, Name, ByteOffset) \
    151     RsCreateResourceField (Op, Name, ByteOffset, 0, 16);
    152 
    153 #define RsCreateDwordField(Op, Name, ByteOffset) \
    154     RsCreateResourceField (Op, Name, ByteOffset, 0, 32);
    155 
    156 #define RsCreateQwordField(Op, Name, ByteOffset) \
    157     RsCreateResourceField (Op, Name, ByteOffset, 0, 64);
    158 
    159 
    160 /*
    161  * Macros for debug output
    162  */
    163 #define DEBUG_MAX_LINE_LENGTH       61
    164 #define DEBUG_SPACES_PER_INDENT     3
    165 #define DEBUG_FULL_LINE_LENGTH      71
    166 
    167 #define ASL_PARSE_TREE_FULL_LINE    "\n%71.71s"
    168 
    169 /* Header/Trailer for original parse tree directly from the parser */
    170 
    171 #define ASL_PARSE_TREE_HEADER1 \
    172     "%*s Value P_Op Flags     Line#  End# LogL# EndL#\n", 65, " "
    173 
    174 #define ASL_PARSE_TREE_DEBUG1 \
    175     " %4.4X %8.8X %5d %5d %5d %5d"
    176 
    177 /* Header/Trailer for processed parse tree used for AML generation */
    178 
    179 #define ASL_PARSE_TREE_HEADER2 \
    180     "%*s NameString Value    P_Op A_Op OpLen PByts Len  SubLen PSubLen OpPtr"\
    181     "    Parent   Child    Next     Flags    AcTyp    Final Col"\
    182     " Line#  End# LogL# EndL#\n", 60, " "
    183 
    184 #define ASL_PARSE_TREE_DEBUG2 \
    185     " %08X %04X %04X %01X     %04X  %04X %05X  %05X   "\
    186     "%8p %8p %8p %8p %08X %08X %04X  %02d  %5d %5d %5d %5d"
    187 
    188 /*
    189  * Macros for ASL/ASL+ converter
    190  */
    191 #define COMMENT_CAPTURE_ON    AslGbl_CommentState.CaptureComments = TRUE;
    192 #define COMMENT_CAPTURE_OFF   AslGbl_CommentState.CaptureComments = FALSE;
    193 
    194 /*
    195  * Special name segments - these must only be declared at the root scope
    196  */
    197 #define NAMESEG__PTS    "_PTS"
    198 #define NAMESEG__WAK    "_WAK"
    199 #define NAMESEG__S0     "_S0_"
    200 #define NAMESEG__S1     "_S1_"
    201 #define NAMESEG__S2     "_S2_"
    202 #define NAMESEG__S3     "_S3_"
    203 #define NAMESEG__S4     "_S4_"
    204 #define NAMESEG__S5     "_S5_"
    205 #define NAMESEG__TTS    "_TTS"
    206 
    207 #define MAX_SPECIAL_NAMES      9
    208 
    209 
    210 #endif /* ASLDEFINE.H */
    211