xref: /netbsd-src/sys/external/bsd/acpica/dist/include/amlcode.h (revision 046a29855e04359424fd074e8313af6b6be8cfb6)
128c506b8Sjruoho /******************************************************************************
228c506b8Sjruoho  *
328c506b8Sjruoho  * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
428c506b8Sjruoho  *                   Declarations and definitions contained herein are derived
528c506b8Sjruoho  *                   directly from the ACPI specification.
628c506b8Sjruoho  *
728c506b8Sjruoho  *****************************************************************************/
828c506b8Sjruoho 
9124f4c82Sjruoho /*
10*046a2985Schristos  * Copyright (C) 2000 - 2023, Intel Corp.
1128c506b8Sjruoho  * All rights reserved.
1228c506b8Sjruoho  *
13124f4c82Sjruoho  * Redistribution and use in source and binary forms, with or without
14124f4c82Sjruoho  * modification, are permitted provided that the following conditions
15124f4c82Sjruoho  * are met:
16124f4c82Sjruoho  * 1. Redistributions of source code must retain the above copyright
17124f4c82Sjruoho  *    notice, this list of conditions, and the following disclaimer,
18124f4c82Sjruoho  *    without modification.
19124f4c82Sjruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20124f4c82Sjruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
21124f4c82Sjruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
22124f4c82Sjruoho  *    including a substantially similar Disclaimer requirement for further
23124f4c82Sjruoho  *    binary redistribution.
24124f4c82Sjruoho  * 3. Neither the names of the above-listed copyright holders nor the names
25124f4c82Sjruoho  *    of any contributors may be used to endorse or promote products derived
26124f4c82Sjruoho  *    from this software without specific prior written permission.
2728c506b8Sjruoho  *
28124f4c82Sjruoho  * Alternatively, this software may be distributed under the terms of the
29124f4c82Sjruoho  * GNU General Public License ("GPL") version 2 as published by the Free
30124f4c82Sjruoho  * Software Foundation.
3128c506b8Sjruoho  *
32124f4c82Sjruoho  * NO WARRANTY
33124f4c82Sjruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34124f4c82Sjruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3546a330b4Schristos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
36124f4c82Sjruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37124f4c82Sjruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38124f4c82Sjruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39124f4c82Sjruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40124f4c82Sjruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41124f4c82Sjruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42124f4c82Sjruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43124f4c82Sjruoho  * POSSIBILITY OF SUCH DAMAGES.
44124f4c82Sjruoho  */
4528c506b8Sjruoho 
4628c506b8Sjruoho #ifndef __AMLCODE_H__
4728c506b8Sjruoho #define __AMLCODE_H__
4828c506b8Sjruoho 
4928c506b8Sjruoho /* primary opcodes */
5028c506b8Sjruoho 
5128c506b8Sjruoho #define AML_ZERO_OP                 (UINT16) 0x00
5228c506b8Sjruoho #define AML_ONE_OP                  (UINT16) 0x01
5328c506b8Sjruoho #define AML_ALIAS_OP                (UINT16) 0x06
5428c506b8Sjruoho #define AML_NAME_OP                 (UINT16) 0x08
5528c506b8Sjruoho #define AML_BYTE_OP                 (UINT16) 0x0a
5628c506b8Sjruoho #define AML_WORD_OP                 (UINT16) 0x0b
5728c506b8Sjruoho #define AML_DWORD_OP                (UINT16) 0x0c
5828c506b8Sjruoho #define AML_STRING_OP               (UINT16) 0x0d
5928c506b8Sjruoho #define AML_QWORD_OP                (UINT16) 0x0e     /* ACPI 2.0 */
6028c506b8Sjruoho #define AML_SCOPE_OP                (UINT16) 0x10
6128c506b8Sjruoho #define AML_BUFFER_OP               (UINT16) 0x11
6228c506b8Sjruoho #define AML_PACKAGE_OP              (UINT16) 0x12
63835858a6Schristos #define AML_VARIABLE_PACKAGE_OP     (UINT16) 0x13     /* ACPI 2.0 */
6428c506b8Sjruoho #define AML_METHOD_OP               (UINT16) 0x14
65679c17fdSchristos #define AML_EXTERNAL_OP             (UINT16) 0x15     /* ACPI 6.0 */
6628c506b8Sjruoho #define AML_DUAL_NAME_PREFIX        (UINT16) 0x2e
67835858a6Schristos #define AML_MULTI_NAME_PREFIX       (UINT16) 0x2f
68835858a6Schristos #define AML_EXTENDED_PREFIX         (UINT16) 0x5b
6928c506b8Sjruoho #define AML_ROOT_PREFIX             (UINT16) 0x5c
7028c506b8Sjruoho #define AML_PARENT_PREFIX           (UINT16) 0x5e
71835858a6Schristos #define AML_FIRST_LOCAL_OP          (UINT16) 0x60     /* Used for Local op # calculations */
7228c506b8Sjruoho #define AML_LOCAL0                  (UINT16) 0x60
7328c506b8Sjruoho #define AML_LOCAL1                  (UINT16) 0x61
7428c506b8Sjruoho #define AML_LOCAL2                  (UINT16) 0x62
7528c506b8Sjruoho #define AML_LOCAL3                  (UINT16) 0x63
7628c506b8Sjruoho #define AML_LOCAL4                  (UINT16) 0x64
7728c506b8Sjruoho #define AML_LOCAL5                  (UINT16) 0x65
7828c506b8Sjruoho #define AML_LOCAL6                  (UINT16) 0x66
7928c506b8Sjruoho #define AML_LOCAL7                  (UINT16) 0x67
80835858a6Schristos #define AML_FIRST_ARG_OP            (UINT16) 0x68     /* Used for Arg op # calculations */
8128c506b8Sjruoho #define AML_ARG0                    (UINT16) 0x68
8228c506b8Sjruoho #define AML_ARG1                    (UINT16) 0x69
8328c506b8Sjruoho #define AML_ARG2                    (UINT16) 0x6a
8428c506b8Sjruoho #define AML_ARG3                    (UINT16) 0x6b
8528c506b8Sjruoho #define AML_ARG4                    (UINT16) 0x6c
8628c506b8Sjruoho #define AML_ARG5                    (UINT16) 0x6d
8728c506b8Sjruoho #define AML_ARG6                    (UINT16) 0x6e
8828c506b8Sjruoho #define AML_STORE_OP                (UINT16) 0x70
8928c506b8Sjruoho #define AML_REF_OF_OP               (UINT16) 0x71
9028c506b8Sjruoho #define AML_ADD_OP                  (UINT16) 0x72
91835858a6Schristos #define AML_CONCATENATE_OP          (UINT16) 0x73
9228c506b8Sjruoho #define AML_SUBTRACT_OP             (UINT16) 0x74
9328c506b8Sjruoho #define AML_INCREMENT_OP            (UINT16) 0x75
9428c506b8Sjruoho #define AML_DECREMENT_OP            (UINT16) 0x76
9528c506b8Sjruoho #define AML_MULTIPLY_OP             (UINT16) 0x77
9628c506b8Sjruoho #define AML_DIVIDE_OP               (UINT16) 0x78
9728c506b8Sjruoho #define AML_SHIFT_LEFT_OP           (UINT16) 0x79
9828c506b8Sjruoho #define AML_SHIFT_RIGHT_OP          (UINT16) 0x7a
9928c506b8Sjruoho #define AML_BIT_AND_OP              (UINT16) 0x7b
10028c506b8Sjruoho #define AML_BIT_NAND_OP             (UINT16) 0x7c
10128c506b8Sjruoho #define AML_BIT_OR_OP               (UINT16) 0x7d
10228c506b8Sjruoho #define AML_BIT_NOR_OP              (UINT16) 0x7e
10328c506b8Sjruoho #define AML_BIT_XOR_OP              (UINT16) 0x7f
10428c506b8Sjruoho #define AML_BIT_NOT_OP              (UINT16) 0x80
10528c506b8Sjruoho #define AML_FIND_SET_LEFT_BIT_OP    (UINT16) 0x81
10628c506b8Sjruoho #define AML_FIND_SET_RIGHT_BIT_OP   (UINT16) 0x82
10728c506b8Sjruoho #define AML_DEREF_OF_OP             (UINT16) 0x83
108835858a6Schristos #define AML_CONCATENATE_TEMPLATE_OP (UINT16) 0x84     /* ACPI 2.0 */
10928c506b8Sjruoho #define AML_MOD_OP                  (UINT16) 0x85     /* ACPI 2.0 */
11028c506b8Sjruoho #define AML_NOTIFY_OP               (UINT16) 0x86
11128c506b8Sjruoho #define AML_SIZE_OF_OP              (UINT16) 0x87
11228c506b8Sjruoho #define AML_INDEX_OP                (UINT16) 0x88
11328c506b8Sjruoho #define AML_MATCH_OP                (UINT16) 0x89
11428c506b8Sjruoho #define AML_CREATE_DWORD_FIELD_OP   (UINT16) 0x8a
11528c506b8Sjruoho #define AML_CREATE_WORD_FIELD_OP    (UINT16) 0x8b
11628c506b8Sjruoho #define AML_CREATE_BYTE_FIELD_OP    (UINT16) 0x8c
11728c506b8Sjruoho #define AML_CREATE_BIT_FIELD_OP     (UINT16) 0x8d
11871e38f1dSchristos #define AML_OBJECT_TYPE_OP          (UINT16) 0x8e
11928c506b8Sjruoho #define AML_CREATE_QWORD_FIELD_OP   (UINT16) 0x8f     /* ACPI 2.0 */
120835858a6Schristos #define AML_LOGICAL_AND_OP          (UINT16) 0x90
121835858a6Schristos #define AML_LOGICAL_OR_OP           (UINT16) 0x91
122835858a6Schristos #define AML_LOGICAL_NOT_OP          (UINT16) 0x92
123835858a6Schristos #define AML_LOGICAL_EQUAL_OP        (UINT16) 0x93
124835858a6Schristos #define AML_LOGICAL_GREATER_OP      (UINT16) 0x94
125835858a6Schristos #define AML_LOGICAL_LESS_OP         (UINT16) 0x95
12628c506b8Sjruoho #define AML_TO_BUFFER_OP            (UINT16) 0x96     /* ACPI 2.0 */
127835858a6Schristos #define AML_TO_DECIMAL_STRING_OP    (UINT16) 0x97     /* ACPI 2.0 */
128835858a6Schristos #define AML_TO_HEX_STRING_OP        (UINT16) 0x98     /* ACPI 2.0 */
12928c506b8Sjruoho #define AML_TO_INTEGER_OP           (UINT16) 0x99     /* ACPI 2.0 */
13028c506b8Sjruoho #define AML_TO_STRING_OP            (UINT16) 0x9c     /* ACPI 2.0 */
131835858a6Schristos #define AML_COPY_OBJECT_OP          (UINT16) 0x9d     /* ACPI 2.0 */
13228c506b8Sjruoho #define AML_MID_OP                  (UINT16) 0x9e     /* ACPI 2.0 */
13328c506b8Sjruoho #define AML_CONTINUE_OP             (UINT16) 0x9f     /* ACPI 2.0 */
13428c506b8Sjruoho #define AML_IF_OP                   (UINT16) 0xa0
13528c506b8Sjruoho #define AML_ELSE_OP                 (UINT16) 0xa1
13628c506b8Sjruoho #define AML_WHILE_OP                (UINT16) 0xa2
13728c506b8Sjruoho #define AML_NOOP_OP                 (UINT16) 0xa3
13828c506b8Sjruoho #define AML_RETURN_OP               (UINT16) 0xa4
13928c506b8Sjruoho #define AML_BREAK_OP                (UINT16) 0xa5
140835858a6Schristos #define AML_COMMENT_OP              (UINT16) 0xa9
141835858a6Schristos #define AML_BREAKPOINT_OP          (UINT16) 0xcc
14228c506b8Sjruoho #define AML_ONES_OP                 (UINT16) 0xff
14328c506b8Sjruoho 
14428c506b8Sjruoho 
145835858a6Schristos /*
146835858a6Schristos  * Combination opcodes (actually two one-byte opcodes)
147835858a6Schristos  * Used by the disassembler and iASL compiler
148835858a6Schristos  */
149835858a6Schristos #define AML_LOGICAL_GREATER_EQUAL_OP (UINT16) 0x9295    /* LNot (LLess) */
150835858a6Schristos #define AML_LOGICAL_LESS_EQUAL_OP    (UINT16) 0x9294    /* LNot (LGreater) */
151835858a6Schristos #define AML_LOGICAL_NOT_EQUAL_OP     (UINT16) 0x9293    /* LNot (LEqual) */
152835858a6Schristos 
153835858a6Schristos 
154835858a6Schristos /* Prefixed (2-byte) opcodes (with AML_EXTENDED_PREFIX) */
155835858a6Schristos 
156835858a6Schristos #define AML_EXTENDED_OPCODE         (UINT16) 0x5b00     /* Prefix for 2-byte opcodes */
15728c506b8Sjruoho 
15828c506b8Sjruoho #define AML_MUTEX_OP                (UINT16) 0x5b01
15928c506b8Sjruoho #define AML_EVENT_OP                (UINT16) 0x5b02
160835858a6Schristos #define AML_SHIFT_RIGHT_BIT_OP      (UINT16) 0x5b10     /* Obsolete, not in ACPI spec */
161835858a6Schristos #define AML_SHIFT_LEFT_BIT_OP       (UINT16) 0x5b11     /* Obsolete, not in ACPI spec */
162835858a6Schristos #define AML_CONDITIONAL_REF_OF_OP   (UINT16) 0x5b12
16328c506b8Sjruoho #define AML_CREATE_FIELD_OP         (UINT16) 0x5b13
16428c506b8Sjruoho #define AML_LOAD_TABLE_OP           (UINT16) 0x5b1f     /* ACPI 2.0 */
16528c506b8Sjruoho #define AML_LOAD_OP                 (UINT16) 0x5b20
16628c506b8Sjruoho #define AML_STALL_OP                (UINT16) 0x5b21
16728c506b8Sjruoho #define AML_SLEEP_OP                (UINT16) 0x5b22
16828c506b8Sjruoho #define AML_ACQUIRE_OP              (UINT16) 0x5b23
16928c506b8Sjruoho #define AML_SIGNAL_OP               (UINT16) 0x5b24
17028c506b8Sjruoho #define AML_WAIT_OP                 (UINT16) 0x5b25
17128c506b8Sjruoho #define AML_RESET_OP                (UINT16) 0x5b26
17228c506b8Sjruoho #define AML_RELEASE_OP              (UINT16) 0x5b27
17328c506b8Sjruoho #define AML_FROM_BCD_OP             (UINT16) 0x5b28
17428c506b8Sjruoho #define AML_TO_BCD_OP               (UINT16) 0x5b29
17528c506b8Sjruoho #define AML_UNLOAD_OP               (UINT16) 0x5b2a
17628c506b8Sjruoho #define AML_REVISION_OP             (UINT16) 0x5b30
17728c506b8Sjruoho #define AML_DEBUG_OP                (UINT16) 0x5b31
17828c506b8Sjruoho #define AML_FATAL_OP                (UINT16) 0x5b32
17928c506b8Sjruoho #define AML_TIMER_OP                (UINT16) 0x5b33     /* ACPI 3.0 */
18028c506b8Sjruoho #define AML_REGION_OP               (UINT16) 0x5b80
18128c506b8Sjruoho #define AML_FIELD_OP                (UINT16) 0x5b81
18228c506b8Sjruoho #define AML_DEVICE_OP               (UINT16) 0x5b82
18328c506b8Sjruoho #define AML_PROCESSOR_OP            (UINT16) 0x5b83
184835858a6Schristos #define AML_POWER_RESOURCE_OP       (UINT16) 0x5b84
18528c506b8Sjruoho #define AML_THERMAL_ZONE_OP         (UINT16) 0x5b85
18628c506b8Sjruoho #define AML_INDEX_FIELD_OP          (UINT16) 0x5b86
18728c506b8Sjruoho #define AML_BANK_FIELD_OP           (UINT16) 0x5b87
18828c506b8Sjruoho #define AML_DATA_REGION_OP          (UINT16) 0x5b88     /* ACPI 2.0 */
18928c506b8Sjruoho 
19028c506b8Sjruoho 
19128c506b8Sjruoho /*
192ff4a156dSchristos  * Opcodes for "Field" operators
193ff4a156dSchristos  */
194ff4a156dSchristos #define AML_FIELD_OFFSET_OP         (UINT8) 0x00
195ff4a156dSchristos #define AML_FIELD_ACCESS_OP         (UINT8) 0x01
196ff4a156dSchristos #define AML_FIELD_CONNECTION_OP     (UINT8) 0x02        /* ACPI 5.0 */
197ff4a156dSchristos #define AML_FIELD_EXT_ACCESS_OP     (UINT8) 0x03        /* ACPI 5.0 */
198ff4a156dSchristos 
199ff4a156dSchristos 
200ff4a156dSchristos /*
20128c506b8Sjruoho  * Internal opcodes
20228c506b8Sjruoho  * Use only "Unknown" AML opcodes, don't attempt to use
20328c506b8Sjruoho  * any valid ACPI ASCII values (A-Z, 0-9, '-')
20428c506b8Sjruoho  */
20528c506b8Sjruoho #define AML_INT_NAMEPATH_OP         (UINT16) 0x002d
20628c506b8Sjruoho #define AML_INT_NAMEDFIELD_OP       (UINT16) 0x0030
20728c506b8Sjruoho #define AML_INT_RESERVEDFIELD_OP    (UINT16) 0x0031
20828c506b8Sjruoho #define AML_INT_ACCESSFIELD_OP      (UINT16) 0x0032
20928c506b8Sjruoho #define AML_INT_BYTELIST_OP         (UINT16) 0x0033
21028c506b8Sjruoho #define AML_INT_METHODCALL_OP       (UINT16) 0x0035
21128c506b8Sjruoho #define AML_INT_RETURN_VALUE_OP     (UINT16) 0x0036
21228c506b8Sjruoho #define AML_INT_EVAL_SUBTREE_OP     (UINT16) 0x0037
213ff4a156dSchristos #define AML_INT_CONNECTION_OP       (UINT16) 0x0038
214ff4a156dSchristos #define AML_INT_EXTACCESSFIELD_OP   (UINT16) 0x0039
21528c506b8Sjruoho 
21628c506b8Sjruoho #define ARG_NONE                    0x0
21728c506b8Sjruoho 
21828c506b8Sjruoho /*
21928c506b8Sjruoho  * Argument types for the AML Parser
22028c506b8Sjruoho  * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments.
22128c506b8Sjruoho  * There can be up to 31 unique argument types
22228c506b8Sjruoho  * Zero is reserved as end-of-list indicator
22328c506b8Sjruoho  */
22428c506b8Sjruoho #define ARGP_BYTEDATA               0x01
22528c506b8Sjruoho #define ARGP_BYTELIST               0x02
22628c506b8Sjruoho #define ARGP_CHARLIST               0x03
22728c506b8Sjruoho #define ARGP_DATAOBJ                0x04
22828c506b8Sjruoho #define ARGP_DATAOBJLIST            0x05
22928c506b8Sjruoho #define ARGP_DWORDDATA              0x06
23028c506b8Sjruoho #define ARGP_FIELDLIST              0x07
23128c506b8Sjruoho #define ARGP_NAME                   0x08
23228c506b8Sjruoho #define ARGP_NAMESTRING             0x09
23328c506b8Sjruoho #define ARGP_OBJLIST                0x0A
23428c506b8Sjruoho #define ARGP_PKGLENGTH              0x0B
23528c506b8Sjruoho #define ARGP_SUPERNAME              0x0C
23628c506b8Sjruoho #define ARGP_TARGET                 0x0D
23728c506b8Sjruoho #define ARGP_TERMARG                0x0E
23828c506b8Sjruoho #define ARGP_TERMLIST               0x0F
23928c506b8Sjruoho #define ARGP_WORDDATA               0x10
24028c506b8Sjruoho #define ARGP_QWORDDATA              0x11
24171e38f1dSchristos #define ARGP_SIMPLENAME             0x12 /* NameString | LocalTerm | ArgTerm */
24271e38f1dSchristos #define ARGP_NAME_OR_REF            0x13 /* For ObjectType only */
2430b89cdedSchristos #define ARGP_MAX                    0x13
244835858a6Schristos #define ARGP_COMMENT                0x14
24528c506b8Sjruoho 
24628c506b8Sjruoho /*
24728c506b8Sjruoho  * Resolved argument types for the AML Interpreter
24828c506b8Sjruoho  * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments.
24928c506b8Sjruoho  * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
25028c506b8Sjruoho  *
25128c506b8Sjruoho  * Note1: These values are completely independent from the ACPI_TYPEs
25228c506b8Sjruoho  *        i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
25328c506b8Sjruoho  *
25428c506b8Sjruoho  * Note2: If and when 5 bits becomes insufficient, it would probably be best
25528c506b8Sjruoho  * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
25628c506b8Sjruoho  */
25728c506b8Sjruoho 
25828c506b8Sjruoho /* Single, simple types */
25928c506b8Sjruoho 
26028c506b8Sjruoho #define ARGI_ANYTYPE                0x01    /* Don't care */
26128c506b8Sjruoho #define ARGI_PACKAGE                0x02
26228c506b8Sjruoho #define ARGI_EVENT                  0x03
26328c506b8Sjruoho #define ARGI_MUTEX                  0x04
26428c506b8Sjruoho #define ARGI_DDBHANDLE              0x05
26528c506b8Sjruoho 
26628c506b8Sjruoho /* Interchangeable types (via implicit conversion) */
26728c506b8Sjruoho 
26828c506b8Sjruoho #define ARGI_INTEGER                0x06
26928c506b8Sjruoho #define ARGI_STRING                 0x07
27028c506b8Sjruoho #define ARGI_BUFFER                 0x08
27128c506b8Sjruoho #define ARGI_BUFFER_OR_STRING       0x09    /* Used by MID op only */
27228c506b8Sjruoho #define ARGI_COMPUTEDATA            0x0A    /* Buffer, String, or Integer */
27328c506b8Sjruoho 
27428c506b8Sjruoho /* Reference objects */
27528c506b8Sjruoho 
27628c506b8Sjruoho #define ARGI_INTEGER_REF            0x0B
27728c506b8Sjruoho #define ARGI_OBJECT_REF             0x0C
27828c506b8Sjruoho #define ARGI_DEVICE_REF             0x0D
27928c506b8Sjruoho #define ARGI_REFERENCE              0x0E
28028c506b8Sjruoho #define ARGI_TARGETREF              0x0F    /* Target, subject to implicit conversion */
281062782b3Schristos #define ARGI_FIXED_TARGET           0x10    /* Target, no implicit conversion */
282062782b3Schristos #define ARGI_SIMPLE_TARGET          0x11    /* Name, Local, Arg -- no implicit conversion */
283062782b3Schristos #define ARGI_STORE_TARGET           0x12    /* Target for store is TARGETREF + package objects */
28428c506b8Sjruoho 
28528c506b8Sjruoho /* Multiple/complex types */
28628c506b8Sjruoho 
28771e38f1dSchristos #define ARGI_DATAOBJECT             0x13    /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/
28871e38f1dSchristos #define ARGI_COMPLEXOBJ             0x14    /* Buffer, String, or package (Used by INDEX op only) */
28971e38f1dSchristos #define ARGI_REF_OR_STRING          0x15    /* Reference or String (Used by DEREFOF op only) */
29071e38f1dSchristos #define ARGI_REGION_OR_BUFFER       0x16    /* Used by LOAD op only */
29171e38f1dSchristos #define ARGI_DATAREFOBJ             0x17
29228c506b8Sjruoho 
29328c506b8Sjruoho /* Note: types above can expand to 0x1F maximum */
29428c506b8Sjruoho 
29528c506b8Sjruoho #define ARGI_INVALID_OPCODE         0xFFFFFFFF
29628c506b8Sjruoho 
29728c506b8Sjruoho 
29828c506b8Sjruoho /*
299835858a6Schristos  * Some of the flags and types below are of the form:
300835858a6Schristos  *
301835858a6Schristos  * AML_FLAGS_EXEC_#A_#T,#R, or
302835858a6Schristos  * AML_TYPE_EXEC_#A_#T,#R where:
303835858a6Schristos  *
304835858a6Schristos  *      #A is the number of required arguments
305835858a6Schristos  *      #T is the number of target operands
306835858a6Schristos  *      #R indicates whether there is a return value
30789b8eb6cSchristos  *
30889b8eb6cSchristos  * These types are used for the top-level dispatch of the AML
30989b8eb6cSchristos  * opcode. They group similar operators that can share common
31089b8eb6cSchristos  * front-end code before dispatch to the final code that implements
31189b8eb6cSchristos  * the operator.
31228c506b8Sjruoho  */
31328c506b8Sjruoho 
31428c506b8Sjruoho /*
315835858a6Schristos  * Opcode information flags
31628c506b8Sjruoho  */
31728c506b8Sjruoho #define AML_LOGICAL                 0x0001
31828c506b8Sjruoho #define AML_LOGICAL_NUMERIC         0x0002
31928c506b8Sjruoho #define AML_MATH                    0x0004
32028c506b8Sjruoho #define AML_CREATE                  0x0008
32128c506b8Sjruoho #define AML_FIELD                   0x0010
32228c506b8Sjruoho #define AML_DEFER                   0x0020
32328c506b8Sjruoho #define AML_NAMED                   0x0040
32428c506b8Sjruoho #define AML_NSNODE                  0x0080
32528c506b8Sjruoho #define AML_NSOPCODE                0x0100
32628c506b8Sjruoho #define AML_NSOBJECT                0x0200
32728c506b8Sjruoho #define AML_HAS_RETVAL              0x0400
32828c506b8Sjruoho #define AML_HAS_TARGET              0x0800
32928c506b8Sjruoho #define AML_HAS_ARGS                0x1000
33028c506b8Sjruoho #define AML_CONSTANT                0x2000
33128c506b8Sjruoho #define AML_NO_OPERAND_RESOLVE      0x4000
33228c506b8Sjruoho 
333835858a6Schristos /* Convenient flag groupings of the flags above */
33428c506b8Sjruoho 
33528c506b8Sjruoho #define AML_FLAGS_EXEC_0A_0T_1R                                     AML_HAS_RETVAL
33628c506b8Sjruoho #define AML_FLAGS_EXEC_1A_0T_0R     AML_HAS_ARGS                                   /* Monadic1  */
33728c506b8Sjruoho #define AML_FLAGS_EXEC_1A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Monadic2  */
33828c506b8Sjruoho #define AML_FLAGS_EXEC_1A_1T_0R     AML_HAS_ARGS | AML_HAS_TARGET
33928c506b8Sjruoho #define AML_FLAGS_EXEC_1A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */
34028c506b8Sjruoho #define AML_FLAGS_EXEC_2A_0T_0R     AML_HAS_ARGS                                   /* Dyadic1   */
34128c506b8Sjruoho #define AML_FLAGS_EXEC_2A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Dyadic2   */
34228c506b8Sjruoho #define AML_FLAGS_EXEC_2A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R  */
34328c506b8Sjruoho #define AML_FLAGS_EXEC_2A_2T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34428c506b8Sjruoho #define AML_FLAGS_EXEC_3A_0T_0R     AML_HAS_ARGS
34528c506b8Sjruoho #define AML_FLAGS_EXEC_3A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34628c506b8Sjruoho #define AML_FLAGS_EXEC_6A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL
34728c506b8Sjruoho 
34828c506b8Sjruoho 
34928c506b8Sjruoho /*
35028c506b8Sjruoho  * The opcode Type is used in a dispatch table, do not change
351835858a6Schristos  * or add anything new without updating the table.
35228c506b8Sjruoho  */
35389b8eb6cSchristos #define AML_TYPE_EXEC_0A_0T_1R      0x00 /* 0 Args, 0 Target, 1 RetVal */
35489b8eb6cSchristos #define AML_TYPE_EXEC_1A_0T_0R      0x01 /* 1 Args, 0 Target, 0 RetVal */
35589b8eb6cSchristos #define AML_TYPE_EXEC_1A_0T_1R      0x02 /* 1 Args, 0 Target, 1 RetVal */
35689b8eb6cSchristos #define AML_TYPE_EXEC_1A_1T_0R      0x03 /* 1 Args, 1 Target, 0 RetVal */
35789b8eb6cSchristos #define AML_TYPE_EXEC_1A_1T_1R      0x04 /* 1 Args, 1 Target, 1 RetVal */
35889b8eb6cSchristos #define AML_TYPE_EXEC_2A_0T_0R      0x05 /* 2 Args, 0 Target, 0 RetVal */
35989b8eb6cSchristos #define AML_TYPE_EXEC_2A_0T_1R      0x06 /* 2 Args, 0 Target, 1 RetVal */
36089b8eb6cSchristos #define AML_TYPE_EXEC_2A_1T_1R      0x07 /* 2 Args, 1 Target, 1 RetVal */
36189b8eb6cSchristos #define AML_TYPE_EXEC_2A_2T_1R      0x08 /* 2 Args, 2 Target, 1 RetVal */
36289b8eb6cSchristos #define AML_TYPE_EXEC_3A_0T_0R      0x09 /* 3 Args, 0 Target, 0 RetVal */
36389b8eb6cSchristos #define AML_TYPE_EXEC_3A_1T_1R      0x0A /* 3 Args, 1 Target, 1 RetVal */
36489b8eb6cSchristos #define AML_TYPE_EXEC_6A_0T_1R      0x0B /* 6 Args, 0 Target, 1 RetVal */
36528c506b8Sjruoho /* End of types used in dispatch table */
36628c506b8Sjruoho 
36789b8eb6cSchristos #define AML_TYPE_LITERAL            0x0C
36889b8eb6cSchristos #define AML_TYPE_CONSTANT           0x0D
36989b8eb6cSchristos #define AML_TYPE_METHOD_ARGUMENT    0x0E
37089b8eb6cSchristos #define AML_TYPE_LOCAL_VARIABLE     0x0F
37189b8eb6cSchristos #define AML_TYPE_DATA_TERM          0x10
37228c506b8Sjruoho 
37328c506b8Sjruoho /* Generic for an op that returns a value */
37428c506b8Sjruoho 
37589b8eb6cSchristos #define AML_TYPE_METHOD_CALL        0x11
37628c506b8Sjruoho 
377835858a6Schristos /* Miscellaneous types */
37828c506b8Sjruoho 
37989b8eb6cSchristos #define AML_TYPE_CREATE_FIELD       0x12
38089b8eb6cSchristos #define AML_TYPE_CREATE_OBJECT      0x13
38189b8eb6cSchristos #define AML_TYPE_CONTROL            0x14
38289b8eb6cSchristos #define AML_TYPE_NAMED_NO_OBJ       0x15
38389b8eb6cSchristos #define AML_TYPE_NAMED_FIELD        0x16
38489b8eb6cSchristos #define AML_TYPE_NAMED_SIMPLE       0x17
38589b8eb6cSchristos #define AML_TYPE_NAMED_COMPLEX      0x18
38689b8eb6cSchristos #define AML_TYPE_RETURN             0x19
38789b8eb6cSchristos #define AML_TYPE_UNDEFINED          0x1A
38889b8eb6cSchristos #define AML_TYPE_BOGUS              0x1B
38928c506b8Sjruoho 
39028c506b8Sjruoho /* AML Package Length encodings */
39128c506b8Sjruoho 
39228c506b8Sjruoho #define ACPI_AML_PACKAGE_TYPE1      0x40
39328c506b8Sjruoho #define ACPI_AML_PACKAGE_TYPE2      0x4000
39428c506b8Sjruoho #define ACPI_AML_PACKAGE_TYPE3      0x400000
39528c506b8Sjruoho #define ACPI_AML_PACKAGE_TYPE4      0x40000000
39628c506b8Sjruoho 
39728c506b8Sjruoho /*
39828c506b8Sjruoho  * Opcode classes
39928c506b8Sjruoho  */
40028c506b8Sjruoho #define AML_CLASS_EXECUTE           0x00
40128c506b8Sjruoho #define AML_CLASS_CREATE            0x01
40228c506b8Sjruoho #define AML_CLASS_ARGUMENT          0x02
40328c506b8Sjruoho #define AML_CLASS_NAMED_OBJECT      0x03
40428c506b8Sjruoho #define AML_CLASS_CONTROL           0x04
40528c506b8Sjruoho #define AML_CLASS_ASCII             0x05
40628c506b8Sjruoho #define AML_CLASS_PREFIX            0x06
40728c506b8Sjruoho #define AML_CLASS_INTERNAL          0x07
40828c506b8Sjruoho #define AML_CLASS_RETURN_VALUE      0x08
40928c506b8Sjruoho #define AML_CLASS_METHOD_CALL       0x09
41028c506b8Sjruoho #define AML_CLASS_UNKNOWN           0x0A
41128c506b8Sjruoho 
41228c506b8Sjruoho 
41328c506b8Sjruoho /* Comparison operation codes for MatchOp operator */
41428c506b8Sjruoho 
41528c506b8Sjruoho typedef enum
41628c506b8Sjruoho {
41728c506b8Sjruoho     MATCH_MTR                       = 0,
41828c506b8Sjruoho     MATCH_MEQ                       = 1,
41928c506b8Sjruoho     MATCH_MLE                       = 2,
42028c506b8Sjruoho     MATCH_MLT                       = 3,
42128c506b8Sjruoho     MATCH_MGE                       = 4,
42228c506b8Sjruoho     MATCH_MGT                       = 5
42328c506b8Sjruoho 
42428c506b8Sjruoho } AML_MATCH_OPERATOR;
42528c506b8Sjruoho 
42628c506b8Sjruoho #define MAX_MATCH_OPERATOR          5
42728c506b8Sjruoho 
42828c506b8Sjruoho 
42928c506b8Sjruoho /*
43028c506b8Sjruoho  * FieldFlags
43128c506b8Sjruoho  *
43228c506b8Sjruoho  * This byte is extracted from the AML and includes three separate
43328c506b8Sjruoho  * pieces of information about the field:
43428c506b8Sjruoho  * 1) The field access type
43528c506b8Sjruoho  * 2) The field update rule
43628c506b8Sjruoho  * 3) The lock rule for the field
43728c506b8Sjruoho  *
43828c506b8Sjruoho  * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.)
43928c506b8Sjruoho  *      04      : LockRule (1 == Lock)
44028c506b8Sjruoho  *      05 - 06 : UpdateRule
44128c506b8Sjruoho  */
44228c506b8Sjruoho #define AML_FIELD_ACCESS_TYPE_MASK  0x0F
44328c506b8Sjruoho #define AML_FIELD_LOCK_RULE_MASK    0x10
44428c506b8Sjruoho #define AML_FIELD_UPDATE_RULE_MASK  0x60
44528c506b8Sjruoho 
44628c506b8Sjruoho 
44728c506b8Sjruoho /* 1) Field Access Types */
44828c506b8Sjruoho 
44928c506b8Sjruoho typedef enum
45028c506b8Sjruoho {
45128c506b8Sjruoho     AML_FIELD_ACCESS_ANY            = 0x00,
45228c506b8Sjruoho     AML_FIELD_ACCESS_BYTE           = 0x01,
45328c506b8Sjruoho     AML_FIELD_ACCESS_WORD           = 0x02,
45428c506b8Sjruoho     AML_FIELD_ACCESS_DWORD          = 0x03,
45528c506b8Sjruoho     AML_FIELD_ACCESS_QWORD          = 0x04,    /* ACPI 2.0 */
45628c506b8Sjruoho     AML_FIELD_ACCESS_BUFFER         = 0x05     /* ACPI 2.0 */
45728c506b8Sjruoho 
45828c506b8Sjruoho } AML_ACCESS_TYPE;
45928c506b8Sjruoho 
46028c506b8Sjruoho 
46128c506b8Sjruoho /* 2) Field Lock Rules */
46228c506b8Sjruoho 
46328c506b8Sjruoho typedef enum
46428c506b8Sjruoho {
46528c506b8Sjruoho     AML_FIELD_LOCK_NEVER            = 0x00,
46628c506b8Sjruoho     AML_FIELD_LOCK_ALWAYS           = 0x10
46728c506b8Sjruoho 
46828c506b8Sjruoho } AML_LOCK_RULE;
46928c506b8Sjruoho 
47028c506b8Sjruoho 
47128c506b8Sjruoho /* 3) Field Update Rules */
47228c506b8Sjruoho 
47328c506b8Sjruoho typedef enum
47428c506b8Sjruoho {
47528c506b8Sjruoho     AML_FIELD_UPDATE_PRESERVE       = 0x00,
47628c506b8Sjruoho     AML_FIELD_UPDATE_WRITE_AS_ONES  = 0x20,
47728c506b8Sjruoho     AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
47828c506b8Sjruoho 
47928c506b8Sjruoho } AML_UPDATE_RULE;
48028c506b8Sjruoho 
48128c506b8Sjruoho 
48228c506b8Sjruoho /*
48328c506b8Sjruoho  * Field Access Attributes.
48428c506b8Sjruoho  * This byte is extracted from the AML via the
48528c506b8Sjruoho  * AccessAs keyword
48628c506b8Sjruoho  */
48728c506b8Sjruoho typedef enum
48828c506b8Sjruoho {
489ff4a156dSchristos     AML_FIELD_ATTRIB_QUICK              = 0x02,
4904c4e8184Schristos     AML_FIELD_ATTRIB_SEND_RECEIVE       = 0x04,
491ff4a156dSchristos     AML_FIELD_ATTRIB_BYTE               = 0x06,
492ff4a156dSchristos     AML_FIELD_ATTRIB_WORD               = 0x08,
493ff4a156dSchristos     AML_FIELD_ATTRIB_BLOCK              = 0x0A,
4944c4e8184Schristos     AML_FIELD_ATTRIB_BYTES              = 0x0B,
4954c4e8184Schristos     AML_FIELD_ATTRIB_PROCESS_CALL       = 0x0C,
4964c4e8184Schristos     AML_FIELD_ATTRIB_BLOCK_PROCESS_CALL = 0x0D,
497ff4a156dSchristos     AML_FIELD_ATTRIB_RAW_BYTES          = 0x0E,
4984c4e8184Schristos     AML_FIELD_ATTRIB_RAW_PROCESS_BYTES  = 0x0F
49928c506b8Sjruoho 
50028c506b8Sjruoho } AML_ACCESS_ATTRIBUTE;
50128c506b8Sjruoho 
50228c506b8Sjruoho 
503124f4c82Sjruoho /* Bit fields in the AML MethodFlags byte */
50428c506b8Sjruoho 
50528c506b8Sjruoho #define AML_METHOD_ARG_COUNT        0x07
50628c506b8Sjruoho #define AML_METHOD_SERIALIZED       0x08
50728c506b8Sjruoho #define AML_METHOD_SYNC_LEVEL       0xF0
50828c506b8Sjruoho 
50928c506b8Sjruoho 
51028c506b8Sjruoho #endif /* __AMLCODE_H__ */
511