167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
467754Smsmith *                   Declarations and definitions contained herein are derived
567754Smsmith *                   directly from the ACPI specification.
667754Smsmith *
767754Smsmith *****************************************************************************/
867754Smsmith
9217365Sjkim/*
10245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
1170243Smsmith * All rights reserved.
1267754Smsmith *
13217365Sjkim * Redistribution and use in source and binary forms, with or without
14217365Sjkim * modification, are permitted provided that the following conditions
15217365Sjkim * are met:
16217365Sjkim * 1. Redistributions of source code must retain the above copyright
17217365Sjkim *    notice, this list of conditions, and the following disclaimer,
18217365Sjkim *    without modification.
19217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
21217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
22217365Sjkim *    including a substantially similar Disclaimer requirement for further
23217365Sjkim *    binary redistribution.
24217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
25217365Sjkim *    of any contributors may be used to endorse or promote products derived
26217365Sjkim *    from this software without specific prior written permission.
2767754Smsmith *
28217365Sjkim * Alternatively, this software may be distributed under the terms of the
29217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
30217365Sjkim * Software Foundation.
3167754Smsmith *
32217365Sjkim * NO WARRANTY
33217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
44217365Sjkim */
4567754Smsmith
4667754Smsmith#ifndef __AMLCODE_H__
4767754Smsmith#define __AMLCODE_H__
4867754Smsmith
4967754Smsmith/* primary opcodes */
5067754Smsmith
5167754Smsmith#define AML_NULL_CHAR               (UINT16) 0x00
5267754Smsmith
5367754Smsmith#define AML_ZERO_OP                 (UINT16) 0x00
5467754Smsmith#define AML_ONE_OP                  (UINT16) 0x01
5567754Smsmith#define AML_UNASSIGNED              (UINT16) 0x02
5667754Smsmith#define AML_ALIAS_OP                (UINT16) 0x06
5767754Smsmith#define AML_NAME_OP                 (UINT16) 0x08
5867754Smsmith#define AML_BYTE_OP                 (UINT16) 0x0a
5967754Smsmith#define AML_WORD_OP                 (UINT16) 0x0b
6067754Smsmith#define AML_DWORD_OP                (UINT16) 0x0c
6167754Smsmith#define AML_STRING_OP               (UINT16) 0x0d
6267754Smsmith#define AML_QWORD_OP                (UINT16) 0x0e     /* ACPI 2.0 */
6367754Smsmith#define AML_SCOPE_OP                (UINT16) 0x10
6467754Smsmith#define AML_BUFFER_OP               (UINT16) 0x11
6567754Smsmith#define AML_PACKAGE_OP              (UINT16) 0x12
6667754Smsmith#define AML_VAR_PACKAGE_OP          (UINT16) 0x13     /* ACPI 2.0 */
6767754Smsmith#define AML_METHOD_OP               (UINT16) 0x14
6867754Smsmith#define AML_DUAL_NAME_PREFIX        (UINT16) 0x2e
6967754Smsmith#define AML_MULTI_NAME_PREFIX_OP    (UINT16) 0x2f
7067754Smsmith#define AML_NAME_CHAR_SUBSEQ        (UINT16) 0x30
7167754Smsmith#define AML_NAME_CHAR_FIRST         (UINT16) 0x41
72151937Sjkim#define AML_EXTENDED_OP_PREFIX      (UINT16) 0x5b
7367754Smsmith#define AML_ROOT_PREFIX             (UINT16) 0x5c
7467754Smsmith#define AML_PARENT_PREFIX           (UINT16) 0x5e
7567754Smsmith#define AML_LOCAL_OP                (UINT16) 0x60
7667754Smsmith#define AML_LOCAL0                  (UINT16) 0x60
7767754Smsmith#define AML_LOCAL1                  (UINT16) 0x61
7867754Smsmith#define AML_LOCAL2                  (UINT16) 0x62
7967754Smsmith#define AML_LOCAL3                  (UINT16) 0x63
8067754Smsmith#define AML_LOCAL4                  (UINT16) 0x64
8167754Smsmith#define AML_LOCAL5                  (UINT16) 0x65
8267754Smsmith#define AML_LOCAL6                  (UINT16) 0x66
8367754Smsmith#define AML_LOCAL7                  (UINT16) 0x67
8467754Smsmith#define AML_ARG_OP                  (UINT16) 0x68
8567754Smsmith#define AML_ARG0                    (UINT16) 0x68
8667754Smsmith#define AML_ARG1                    (UINT16) 0x69
8767754Smsmith#define AML_ARG2                    (UINT16) 0x6a
8867754Smsmith#define AML_ARG3                    (UINT16) 0x6b
8967754Smsmith#define AML_ARG4                    (UINT16) 0x6c
9067754Smsmith#define AML_ARG5                    (UINT16) 0x6d
9167754Smsmith#define AML_ARG6                    (UINT16) 0x6e
9267754Smsmith#define AML_STORE_OP                (UINT16) 0x70
9367754Smsmith#define AML_REF_OF_OP               (UINT16) 0x71
9467754Smsmith#define AML_ADD_OP                  (UINT16) 0x72
9567754Smsmith#define AML_CONCAT_OP               (UINT16) 0x73
9667754Smsmith#define AML_SUBTRACT_OP             (UINT16) 0x74
9767754Smsmith#define AML_INCREMENT_OP            (UINT16) 0x75
9867754Smsmith#define AML_DECREMENT_OP            (UINT16) 0x76
9967754Smsmith#define AML_MULTIPLY_OP             (UINT16) 0x77
10067754Smsmith#define AML_DIVIDE_OP               (UINT16) 0x78
10167754Smsmith#define AML_SHIFT_LEFT_OP           (UINT16) 0x79
10267754Smsmith#define AML_SHIFT_RIGHT_OP          (UINT16) 0x7a
10367754Smsmith#define AML_BIT_AND_OP              (UINT16) 0x7b
10467754Smsmith#define AML_BIT_NAND_OP             (UINT16) 0x7c
10567754Smsmith#define AML_BIT_OR_OP               (UINT16) 0x7d
10667754Smsmith#define AML_BIT_NOR_OP              (UINT16) 0x7e
10767754Smsmith#define AML_BIT_XOR_OP              (UINT16) 0x7f
10867754Smsmith#define AML_BIT_NOT_OP              (UINT16) 0x80
10967754Smsmith#define AML_FIND_SET_LEFT_BIT_OP    (UINT16) 0x81
11067754Smsmith#define AML_FIND_SET_RIGHT_BIT_OP   (UINT16) 0x82
11167754Smsmith#define AML_DEREF_OF_OP             (UINT16) 0x83
11267754Smsmith#define AML_CONCAT_RES_OP           (UINT16) 0x84     /* ACPI 2.0 */
11367754Smsmith#define AML_MOD_OP                  (UINT16) 0x85     /* ACPI 2.0 */
11467754Smsmith#define AML_NOTIFY_OP               (UINT16) 0x86
11567754Smsmith#define AML_SIZE_OF_OP              (UINT16) 0x87
11667754Smsmith#define AML_INDEX_OP                (UINT16) 0x88
11767754Smsmith#define AML_MATCH_OP                (UINT16) 0x89
11877424Smsmith#define AML_CREATE_DWORD_FIELD_OP   (UINT16) 0x8a
11977424Smsmith#define AML_CREATE_WORD_FIELD_OP    (UINT16) 0x8b
12077424Smsmith#define AML_CREATE_BYTE_FIELD_OP    (UINT16) 0x8c
12177424Smsmith#define AML_CREATE_BIT_FIELD_OP     (UINT16) 0x8d
12267754Smsmith#define AML_TYPE_OP                 (UINT16) 0x8e
12377424Smsmith#define AML_CREATE_QWORD_FIELD_OP   (UINT16) 0x8f     /* ACPI 2.0 */
12467754Smsmith#define AML_LAND_OP                 (UINT16) 0x90
12567754Smsmith#define AML_LOR_OP                  (UINT16) 0x91
12667754Smsmith#define AML_LNOT_OP                 (UINT16) 0x92
12767754Smsmith#define AML_LEQUAL_OP               (UINT16) 0x93
12867754Smsmith#define AML_LGREATER_OP             (UINT16) 0x94
12967754Smsmith#define AML_LLESS_OP                (UINT16) 0x95
13069746Smsmith#define AML_TO_BUFFER_OP            (UINT16) 0x96     /* ACPI 2.0 */
13169746Smsmith#define AML_TO_DECSTRING_OP         (UINT16) 0x97     /* ACPI 2.0 */
13269746Smsmith#define AML_TO_HEXSTRING_OP         (UINT16) 0x98     /* ACPI 2.0 */
13369746Smsmith#define AML_TO_INTEGER_OP           (UINT16) 0x99     /* ACPI 2.0 */
13469746Smsmith#define AML_TO_STRING_OP            (UINT16) 0x9c     /* ACPI 2.0 */
13567754Smsmith#define AML_COPY_OP                 (UINT16) 0x9d     /* ACPI 2.0 */
13667754Smsmith#define AML_MID_OP                  (UINT16) 0x9e     /* ACPI 2.0 */
13767754Smsmith#define AML_CONTINUE_OP             (UINT16) 0x9f     /* ACPI 2.0 */
13867754Smsmith#define AML_IF_OP                   (UINT16) 0xa0
13967754Smsmith#define AML_ELSE_OP                 (UINT16) 0xa1
14067754Smsmith#define AML_WHILE_OP                (UINT16) 0xa2
14167754Smsmith#define AML_NOOP_OP                 (UINT16) 0xa3
14267754Smsmith#define AML_RETURN_OP               (UINT16) 0xa4
14367754Smsmith#define AML_BREAK_OP                (UINT16) 0xa5
14467754Smsmith#define AML_BREAK_POINT_OP          (UINT16) 0xcc
14567754Smsmith#define AML_ONES_OP                 (UINT16) 0xff
14667754Smsmith
14767754Smsmith/* prefixed opcodes */
14867754Smsmith
149151937Sjkim#define AML_EXTENDED_OPCODE         (UINT16) 0x5b00     /* prefix for 2-byte opcodes */
15067754Smsmith
15167754Smsmith#define AML_MUTEX_OP                (UINT16) 0x5b01
15267754Smsmith#define AML_EVENT_OP                (UINT16) 0x5b02
15367754Smsmith#define AML_SHIFT_RIGHT_BIT_OP      (UINT16) 0x5b10
15467754Smsmith#define AML_SHIFT_LEFT_BIT_OP       (UINT16) 0x5b11
15567754Smsmith#define AML_COND_REF_OF_OP          (UINT16) 0x5b12
15667754Smsmith#define AML_CREATE_FIELD_OP         (UINT16) 0x5b13
15767754Smsmith#define AML_LOAD_TABLE_OP           (UINT16) 0x5b1f     /* ACPI 2.0 */
15867754Smsmith#define AML_LOAD_OP                 (UINT16) 0x5b20
15967754Smsmith#define AML_STALL_OP                (UINT16) 0x5b21
16067754Smsmith#define AML_SLEEP_OP                (UINT16) 0x5b22
16167754Smsmith#define AML_ACQUIRE_OP              (UINT16) 0x5b23
16267754Smsmith#define AML_SIGNAL_OP               (UINT16) 0x5b24
16367754Smsmith#define AML_WAIT_OP                 (UINT16) 0x5b25
16467754Smsmith#define AML_RESET_OP                (UINT16) 0x5b26
16567754Smsmith#define AML_RELEASE_OP              (UINT16) 0x5b27
16667754Smsmith#define AML_FROM_BCD_OP             (UINT16) 0x5b28
16767754Smsmith#define AML_TO_BCD_OP               (UINT16) 0x5b29
16867754Smsmith#define AML_UNLOAD_OP               (UINT16) 0x5b2a
16967754Smsmith#define AML_REVISION_OP             (UINT16) 0x5b30
17067754Smsmith#define AML_DEBUG_OP                (UINT16) 0x5b31
17167754Smsmith#define AML_FATAL_OP                (UINT16) 0x5b32
172138287Smarks#define AML_TIMER_OP                (UINT16) 0x5b33     /* ACPI 3.0 */
17367754Smsmith#define AML_REGION_OP               (UINT16) 0x5b80
17477424Smsmith#define AML_FIELD_OP                (UINT16) 0x5b81
17567754Smsmith#define AML_DEVICE_OP               (UINT16) 0x5b82
17667754Smsmith#define AML_PROCESSOR_OP            (UINT16) 0x5b83
17767754Smsmith#define AML_POWER_RES_OP            (UINT16) 0x5b84
17867754Smsmith#define AML_THERMAL_ZONE_OP         (UINT16) 0x5b85
17967754Smsmith#define AML_INDEX_FIELD_OP          (UINT16) 0x5b86
18067754Smsmith#define AML_BANK_FIELD_OP           (UINT16) 0x5b87
18167754Smsmith#define AML_DATA_REGION_OP          (UINT16) 0x5b88     /* ACPI 2.0 */
18267754Smsmith
18367754Smsmith
184167802Sjkim/*
185167802Sjkim * Combination opcodes (actually two one-byte opcodes)
186167802Sjkim * Used by the disassembler and iASL compiler
187167802Sjkim */
18867754Smsmith#define AML_LGREATEREQUAL_OP        (UINT16) 0x9295
18967754Smsmith#define AML_LLESSEQUAL_OP           (UINT16) 0x9294
19067754Smsmith#define AML_LNOTEQUAL_OP            (UINT16) 0x9293
19167754Smsmith
19267754Smsmith
19367754Smsmith/*
194228110Sjkim * Opcodes for "Field" operators
195228110Sjkim */
196228110Sjkim#define AML_FIELD_OFFSET_OP         (UINT8) 0x00
197228110Sjkim#define AML_FIELD_ACCESS_OP         (UINT8) 0x01
198228110Sjkim#define AML_FIELD_CONNECTION_OP     (UINT8) 0x02        /* ACPI 5.0 */
199228110Sjkim#define AML_FIELD_EXT_ACCESS_OP     (UINT8) 0x03        /* ACPI 5.0 */
200228110Sjkim
201228110Sjkim
202228110Sjkim/*
20367754Smsmith * Internal opcodes
20467754Smsmith * Use only "Unknown" AML opcodes, don't attempt to use
20567754Smsmith * any valid ACPI ASCII values (A-Z, 0-9, '-')
20667754Smsmith */
20777424Smsmith#define AML_INT_NAMEPATH_OP         (UINT16) 0x002d
20877424Smsmith#define AML_INT_NAMEDFIELD_OP       (UINT16) 0x0030
20977424Smsmith#define AML_INT_RESERVEDFIELD_OP    (UINT16) 0x0031
21077424Smsmith#define AML_INT_ACCESSFIELD_OP      (UINT16) 0x0032
21177424Smsmith#define AML_INT_BYTELIST_OP         (UINT16) 0x0033
21277424Smsmith#define AML_INT_STATICSTRING_OP     (UINT16) 0x0034
21377424Smsmith#define AML_INT_METHODCALL_OP       (UINT16) 0x0035
21477424Smsmith#define AML_INT_RETURN_VALUE_OP     (UINT16) 0x0036
21599146Siwasaki#define AML_INT_EVAL_SUBTREE_OP     (UINT16) 0x0037
216228110Sjkim#define AML_INT_CONNECTION_OP       (UINT16) 0x0038
217228110Sjkim#define AML_INT_EXTACCESSFIELD_OP   (UINT16) 0x0039
21867754Smsmith
21967754Smsmith#define ARG_NONE                    0x0
22067754Smsmith
22167754Smsmith/*
22267754Smsmith * Argument types for the AML Parser
22367754Smsmith * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments.
22467754Smsmith * There can be up to 31 unique argument types
225114237Snjl * Zero is reserved as end-of-list indicator
22667754Smsmith */
22767754Smsmith#define ARGP_BYTEDATA               0x01
22867754Smsmith#define ARGP_BYTELIST               0x02
22967754Smsmith#define ARGP_CHARLIST               0x03
23067754Smsmith#define ARGP_DATAOBJ                0x04
23167754Smsmith#define ARGP_DATAOBJLIST            0x05
23267754Smsmith#define ARGP_DWORDDATA              0x06
23367754Smsmith#define ARGP_FIELDLIST              0x07
23467754Smsmith#define ARGP_NAME                   0x08
23567754Smsmith#define ARGP_NAMESTRING             0x09
23667754Smsmith#define ARGP_OBJLIST                0x0A
23767754Smsmith#define ARGP_PKGLENGTH              0x0B
23867754Smsmith#define ARGP_SUPERNAME              0x0C
23967754Smsmith#define ARGP_TARGET                 0x0D
24067754Smsmith#define ARGP_TERMARG                0x0E
24167754Smsmith#define ARGP_TERMLIST               0x0F
24267754Smsmith#define ARGP_WORDDATA               0x10
24371867Smsmith#define ARGP_QWORDDATA              0x11
24471867Smsmith#define ARGP_SIMPLENAME             0x12
24567754Smsmith
24667754Smsmith/*
24767754Smsmith * Resolved argument types for the AML Interpreter
24867754Smsmith * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments.
24971867Smsmith * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
25091116Smsmith *
251114237Snjl * Note1: These values are completely independent from the ACPI_TYPEs
252114237Snjl *        i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
253114237Snjl *
254114237Snjl * Note2: If and when 5 bits becomes insufficient, it would probably be best
25591116Smsmith * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
25667754Smsmith */
25767754Smsmith
258114237Snjl/* Single, simple types */
25967754Smsmith
260114237Snjl#define ARGI_ANYTYPE                0x01    /* Don't care */
261114237Snjl#define ARGI_PACKAGE                0x02
262114237Snjl#define ARGI_EVENT                  0x03
263114237Snjl#define ARGI_MUTEX                  0x04
264114237Snjl#define ARGI_DDBHANDLE              0x05
26571867Smsmith
266114237Snjl/* Interchangeable types (via implicit conversion) */
26771867Smsmith
268114237Snjl#define ARGI_INTEGER                0x06
269114237Snjl#define ARGI_STRING                 0x07
270114237Snjl#define ARGI_BUFFER                 0x08
271114237Snjl#define ARGI_BUFFER_OR_STRING       0x09    /* Used by MID op only */
272114237Snjl#define ARGI_COMPUTEDATA            0x0A    /* Buffer, String, or Integer */
27371867Smsmith
274114237Snjl/* Reference objects */
275114237Snjl
276114237Snjl#define ARGI_INTEGER_REF            0x0B
277114237Snjl#define ARGI_OBJECT_REF             0x0C
278114237Snjl#define ARGI_DEVICE_REF             0x0D
279114237Snjl#define ARGI_REFERENCE              0x0E
280114237Snjl#define ARGI_TARGETREF              0x0F    /* Target, subject to implicit conversion */
281114237Snjl#define ARGI_FIXED_TARGET           0x10    /* Target, no implicit conversion */
282114237Snjl#define ARGI_SIMPLE_TARGET          0x11    /* Name, Local, Arg -- no implicit conversion */
283114237Snjl
284114237Snjl/* Multiple/complex types */
285114237Snjl
286114237Snjl#define ARGI_DATAOBJECT             0x12    /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/
287114237Snjl#define ARGI_COMPLEXOBJ             0x13    /* Buffer, String, or package (Used by INDEX op only) */
288114237Snjl#define ARGI_REF_OR_STRING          0x14    /* Reference or String (Used by DEREFOF op only) */
289167802Sjkim#define ARGI_REGION_OR_BUFFER       0x15    /* Used by LOAD op only */
290151937Sjkim#define ARGI_DATAREFOBJ             0x16
291114237Snjl
292114237Snjl/* Note: types above can expand to 0x1F maximum */
293114237Snjl
29467754Smsmith#define ARGI_INVALID_OPCODE         0xFFFFFFFF
29567754Smsmith
29667754Smsmith
29767754Smsmith/*
29867754Smsmith * hash offsets
29967754Smsmith */
30067754Smsmith#define AML_EXTOP_HASH_OFFSET       22
30167754Smsmith#define AML_LNOT_HASH_OFFSET        19
30267754Smsmith
30367754Smsmith
30467754Smsmith/*
30567754Smsmith * opcode groups and types
30667754Smsmith */
30767754Smsmith#define OPGRP_NAMED                 0x01
30867754Smsmith#define OPGRP_FIELD                 0x02
30967754Smsmith#define OPGRP_BYTELIST              0x04
31067754Smsmith
31167754Smsmith
31287031Smsmith/*
31387031Smsmith * Opcode information
31485756Smsmith */
31567754Smsmith
31685756Smsmith/* Opcode flags */
31767754Smsmith
31885756Smsmith#define AML_LOGICAL                 0x0001
319138287Smarks#define AML_LOGICAL_NUMERIC         0x0002
320138287Smarks#define AML_MATH                    0x0004
321138287Smarks#define AML_CREATE                  0x0008
322138287Smarks#define AML_FIELD                   0x0010
323138287Smarks#define AML_DEFER                   0x0020
324138287Smarks#define AML_NAMED                   0x0040
325138287Smarks#define AML_NSNODE                  0x0080
326138287Smarks#define AML_NSOPCODE                0x0100
327138287Smarks#define AML_NSOBJECT                0x0200
328138287Smarks#define AML_HAS_RETVAL              0x0400
329138287Smarks#define AML_HAS_TARGET              0x0800
330138287Smarks#define AML_HAS_ARGS                0x1000
331138287Smarks#define AML_CONSTANT                0x2000
332151937Sjkim#define AML_NO_OPERAND_RESOLVE      0x4000
33367754Smsmith
33485756Smsmith/* Convenient flag groupings */
33567754Smsmith
336138287Smarks#define AML_FLAGS_EXEC_0A_0T_1R                                     AML_HAS_RETVAL
33785756Smsmith#define AML_FLAGS_EXEC_1A_0T_0R     AML_HAS_ARGS                                   /* Monadic1  */
33885756Smsmith#define AML_FLAGS_EXEC_1A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Monadic2  */
33985756Smsmith#define AML_FLAGS_EXEC_1A_1T_0R     AML_HAS_ARGS | AML_HAS_TARGET
34085756Smsmith#define AML_FLAGS_EXEC_1A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */
34185756Smsmith#define AML_FLAGS_EXEC_2A_0T_0R     AML_HAS_ARGS                                   /* Dyadic1   */
34285756Smsmith#define AML_FLAGS_EXEC_2A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Dyadic2   */
34385756Smsmith#define AML_FLAGS_EXEC_2A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R  */
34485756Smsmith#define AML_FLAGS_EXEC_2A_2T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34585756Smsmith#define AML_FLAGS_EXEC_3A_0T_0R     AML_HAS_ARGS
34685756Smsmith#define AML_FLAGS_EXEC_3A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34785756Smsmith#define AML_FLAGS_EXEC_6A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL
34867754Smsmith
34967754Smsmith
35085756Smsmith/*
35185756Smsmith * The opcode Type is used in a dispatch table, do not change
35285756Smsmith * without updating the table.
35385756Smsmith */
354138287Smarks#define AML_TYPE_EXEC_0A_0T_1R      0x00
355138287Smarks#define AML_TYPE_EXEC_1A_0T_0R      0x01 /* Monadic1  */
356138287Smarks#define AML_TYPE_EXEC_1A_0T_1R      0x02 /* Monadic2  */
357138287Smarks#define AML_TYPE_EXEC_1A_1T_0R      0x03
358138287Smarks#define AML_TYPE_EXEC_1A_1T_1R      0x04 /* Monadic2R */
359138287Smarks#define AML_TYPE_EXEC_2A_0T_0R      0x05 /* Dyadic1   */
360138287Smarks#define AML_TYPE_EXEC_2A_0T_1R      0x06 /* Dyadic2   */
361138287Smarks#define AML_TYPE_EXEC_2A_1T_1R      0x07 /* Dyadic2R  */
362138287Smarks#define AML_TYPE_EXEC_2A_2T_1R      0x08
363138287Smarks#define AML_TYPE_EXEC_3A_0T_0R      0x09
364138287Smarks#define AML_TYPE_EXEC_3A_1T_1R      0x0A
365138287Smarks#define AML_TYPE_EXEC_6A_0T_1R      0x0B
36685756Smsmith/* End of types used in dispatch table */
36780062Smsmith
36885756Smsmith#define AML_TYPE_LITERAL            0x0B
36985756Smsmith#define AML_TYPE_CONSTANT           0x0C
37085756Smsmith#define AML_TYPE_METHOD_ARGUMENT    0x0D
37185756Smsmith#define AML_TYPE_LOCAL_VARIABLE     0x0E
37285756Smsmith#define AML_TYPE_DATA_TERM          0x0F
37380062Smsmith
37467754Smsmith/* Generic for an op that returns a value */
37567754Smsmith
37685756Smsmith#define AML_TYPE_METHOD_CALL        0x10
37767754Smsmith
37867754Smsmith/* Misc */
37967754Smsmith
38085756Smsmith#define AML_TYPE_CREATE_FIELD       0x11
38199146Siwasaki#define AML_TYPE_CREATE_OBJECT      0x12
38299146Siwasaki#define AML_TYPE_CONTROL            0x13
38399146Siwasaki#define AML_TYPE_NAMED_NO_OBJ       0x14
38499146Siwasaki#define AML_TYPE_NAMED_FIELD        0x15
38599146Siwasaki#define AML_TYPE_NAMED_SIMPLE       0x16
38699146Siwasaki#define AML_TYPE_NAMED_COMPLEX      0x17
38799146Siwasaki#define AML_TYPE_RETURN             0x18
38867754Smsmith
38999146Siwasaki#define AML_TYPE_UNDEFINED          0x19
39099146Siwasaki#define AML_TYPE_BOGUS              0x1A
39167754Smsmith
392151937Sjkim/* AML Package Length encodings */
39367754Smsmith
394151937Sjkim#define ACPI_AML_PACKAGE_TYPE1      0x40
395151937Sjkim#define ACPI_AML_PACKAGE_TYPE2      0x4000
396151937Sjkim#define ACPI_AML_PACKAGE_TYPE3      0x400000
397151937Sjkim#define ACPI_AML_PACKAGE_TYPE4      0x40000000
398151937Sjkim
39987031Smsmith/*
40087031Smsmith * Opcode classes
40185756Smsmith */
40285756Smsmith#define AML_CLASS_EXECUTE           0x00
40385756Smsmith#define AML_CLASS_CREATE            0x01
40485756Smsmith#define AML_CLASS_ARGUMENT          0x02
40585756Smsmith#define AML_CLASS_NAMED_OBJECT      0x03
40685756Smsmith#define AML_CLASS_CONTROL           0x04
40785756Smsmith#define AML_CLASS_ASCII             0x05
40885756Smsmith#define AML_CLASS_PREFIX            0x06
40985756Smsmith#define AML_CLASS_INTERNAL          0x07
41085756Smsmith#define AML_CLASS_RETURN_VALUE      0x08
41185756Smsmith#define AML_CLASS_METHOD_CALL       0x09
41285756Smsmith#define AML_CLASS_UNKNOWN           0x0A
41385756Smsmith
41485756Smsmith
41567754Smsmith/* Comparison operation codes for MatchOp operator */
41667754Smsmith
41767754Smsmithtypedef enum
41867754Smsmith{
41977424Smsmith    MATCH_MTR                       = 0,
42077424Smsmith    MATCH_MEQ                       = 1,
42177424Smsmith    MATCH_MLE                       = 2,
42277424Smsmith    MATCH_MLT                       = 3,
42377424Smsmith    MATCH_MGE                       = 4,
42477424Smsmith    MATCH_MGT                       = 5
42567754Smsmith
42667754Smsmith} AML_MATCH_OPERATOR;
42767754Smsmith
42877424Smsmith#define MAX_MATCH_OPERATOR          5
42967754Smsmith
43067754Smsmith
43187031Smsmith/*
43287031Smsmith * FieldFlags
43387031Smsmith *
43487031Smsmith * This byte is extracted from the AML and includes three separate
43587031Smsmith * pieces of information about the field:
43687031Smsmith * 1) The field access type
43787031Smsmith * 2) The field update rule
43887031Smsmith * 3) The lock rule for the field
43987031Smsmith *
44087031Smsmith * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.)
44187031Smsmith *      04      : LockRule (1 == Lock)
44287031Smsmith *      05 - 06 : UpdateRule
44387031Smsmith */
44487031Smsmith#define AML_FIELD_ACCESS_TYPE_MASK  0x0F
44587031Smsmith#define AML_FIELD_LOCK_RULE_MASK    0x10
44687031Smsmith#define AML_FIELD_UPDATE_RULE_MASK  0x60
44767754Smsmith
44867754Smsmith
44987031Smsmith/* 1) Field Access Types */
45087031Smsmith
45167754Smsmithtypedef enum
45267754Smsmith{
45387031Smsmith    AML_FIELD_ACCESS_ANY            = 0x00,
45487031Smsmith    AML_FIELD_ACCESS_BYTE           = 0x01,
45587031Smsmith    AML_FIELD_ACCESS_WORD           = 0x02,
45687031Smsmith    AML_FIELD_ACCESS_DWORD          = 0x03,
45787031Smsmith    AML_FIELD_ACCESS_QWORD          = 0x04,    /* ACPI 2.0 */
45891116Smsmith    AML_FIELD_ACCESS_BUFFER         = 0x05     /* ACPI 2.0 */
45967754Smsmith
46067754Smsmith} AML_ACCESS_TYPE;
46167754Smsmith
46267754Smsmith
46387031Smsmith/* 2) Field Lock Rules */
46467754Smsmith
46567754Smsmithtypedef enum
46667754Smsmith{
46787031Smsmith    AML_FIELD_LOCK_NEVER            = 0x00,
46891116Smsmith    AML_FIELD_LOCK_ALWAYS           = 0x10
46967754Smsmith
47067754Smsmith} AML_LOCK_RULE;
47167754Smsmith
47267754Smsmith
47387031Smsmith/* 3) Field Update Rules */
47467754Smsmith
47567754Smsmithtypedef enum
47667754Smsmith{
47787031Smsmith    AML_FIELD_UPDATE_PRESERVE       = 0x00,
47887031Smsmith    AML_FIELD_UPDATE_WRITE_AS_ONES  = 0x20,
47991116Smsmith    AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
48067754Smsmith
48167754Smsmith} AML_UPDATE_RULE;
48267754Smsmith
48367754Smsmith
48491116Smsmith/*
48587031Smsmith * Field Access Attributes.
48687031Smsmith * This byte is extracted from the AML via the
48791116Smsmith * AccessAs keyword
48887031Smsmith */
48987031Smsmithtypedef enum
49087031Smsmith{
491228110Sjkim    AML_FIELD_ATTRIB_QUICK          = 0x02,
492228110Sjkim    AML_FIELD_ATTRIB_SEND_RCV       = 0x04,
493228110Sjkim    AML_FIELD_ATTRIB_BYTE           = 0x06,
494228110Sjkim    AML_FIELD_ATTRIB_WORD           = 0x08,
495228110Sjkim    AML_FIELD_ATTRIB_BLOCK          = 0x0A,
496228110Sjkim    AML_FIELD_ATTRIB_MULTIBYTE      = 0x0B,
497228110Sjkim    AML_FIELD_ATTRIB_WORD_CALL      = 0x0C,
498228110Sjkim    AML_FIELD_ATTRIB_BLOCK_CALL     = 0x0D,
499228110Sjkim    AML_FIELD_ATTRIB_RAW_BYTES      = 0x0E,
500228110Sjkim    AML_FIELD_ATTRIB_RAW_PROCESS    = 0x0F
50187031Smsmith
50287031Smsmith} AML_ACCESS_ATTRIBUTE;
50387031Smsmith
50487031Smsmith
505217365Sjkim/* Bit fields in the AML MethodFlags byte */
50667754Smsmith
507127175Snjl#define AML_METHOD_ARG_COUNT        0x07
508127175Snjl#define AML_METHOD_SERIALIZED       0x08
509193267Sjkim#define AML_METHOD_SYNC_LEVEL       0xF0
51067754Smsmith
51167754Smsmith
51267754Smsmith#endif /* __AMLCODE_H__ */
513