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/*
10306536Sjkim * Copyright (C) 2000 - 2016, 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
68281687Sjkim#define AML_EXTERNAL_OP             (UINT16) 0x15     /* ACPI 6.0 */
6967754Smsmith#define AML_DUAL_NAME_PREFIX        (UINT16) 0x2e
7067754Smsmith#define AML_MULTI_NAME_PREFIX_OP    (UINT16) 0x2f
7167754Smsmith#define AML_NAME_CHAR_SUBSEQ        (UINT16) 0x30
7267754Smsmith#define AML_NAME_CHAR_FIRST         (UINT16) 0x41
73151937Sjkim#define AML_EXTENDED_OP_PREFIX      (UINT16) 0x5b
7467754Smsmith#define AML_ROOT_PREFIX             (UINT16) 0x5c
7567754Smsmith#define AML_PARENT_PREFIX           (UINT16) 0x5e
7667754Smsmith#define AML_LOCAL_OP                (UINT16) 0x60
7767754Smsmith#define AML_LOCAL0                  (UINT16) 0x60
7867754Smsmith#define AML_LOCAL1                  (UINT16) 0x61
7967754Smsmith#define AML_LOCAL2                  (UINT16) 0x62
8067754Smsmith#define AML_LOCAL3                  (UINT16) 0x63
8167754Smsmith#define AML_LOCAL4                  (UINT16) 0x64
8267754Smsmith#define AML_LOCAL5                  (UINT16) 0x65
8367754Smsmith#define AML_LOCAL6                  (UINT16) 0x66
8467754Smsmith#define AML_LOCAL7                  (UINT16) 0x67
8567754Smsmith#define AML_ARG_OP                  (UINT16) 0x68
8667754Smsmith#define AML_ARG0                    (UINT16) 0x68
8767754Smsmith#define AML_ARG1                    (UINT16) 0x69
8867754Smsmith#define AML_ARG2                    (UINT16) 0x6a
8967754Smsmith#define AML_ARG3                    (UINT16) 0x6b
9067754Smsmith#define AML_ARG4                    (UINT16) 0x6c
9167754Smsmith#define AML_ARG5                    (UINT16) 0x6d
9267754Smsmith#define AML_ARG6                    (UINT16) 0x6e
9367754Smsmith#define AML_STORE_OP                (UINT16) 0x70
9467754Smsmith#define AML_REF_OF_OP               (UINT16) 0x71
9567754Smsmith#define AML_ADD_OP                  (UINT16) 0x72
9667754Smsmith#define AML_CONCAT_OP               (UINT16) 0x73
9767754Smsmith#define AML_SUBTRACT_OP             (UINT16) 0x74
9867754Smsmith#define AML_INCREMENT_OP            (UINT16) 0x75
9967754Smsmith#define AML_DECREMENT_OP            (UINT16) 0x76
10067754Smsmith#define AML_MULTIPLY_OP             (UINT16) 0x77
10167754Smsmith#define AML_DIVIDE_OP               (UINT16) 0x78
10267754Smsmith#define AML_SHIFT_LEFT_OP           (UINT16) 0x79
10367754Smsmith#define AML_SHIFT_RIGHT_OP          (UINT16) 0x7a
10467754Smsmith#define AML_BIT_AND_OP              (UINT16) 0x7b
10567754Smsmith#define AML_BIT_NAND_OP             (UINT16) 0x7c
10667754Smsmith#define AML_BIT_OR_OP               (UINT16) 0x7d
10767754Smsmith#define AML_BIT_NOR_OP              (UINT16) 0x7e
10867754Smsmith#define AML_BIT_XOR_OP              (UINT16) 0x7f
10967754Smsmith#define AML_BIT_NOT_OP              (UINT16) 0x80
11067754Smsmith#define AML_FIND_SET_LEFT_BIT_OP    (UINT16) 0x81
11167754Smsmith#define AML_FIND_SET_RIGHT_BIT_OP   (UINT16) 0x82
11267754Smsmith#define AML_DEREF_OF_OP             (UINT16) 0x83
11367754Smsmith#define AML_CONCAT_RES_OP           (UINT16) 0x84     /* ACPI 2.0 */
11467754Smsmith#define AML_MOD_OP                  (UINT16) 0x85     /* ACPI 2.0 */
11567754Smsmith#define AML_NOTIFY_OP               (UINT16) 0x86
11667754Smsmith#define AML_SIZE_OF_OP              (UINT16) 0x87
11767754Smsmith#define AML_INDEX_OP                (UINT16) 0x88
11867754Smsmith#define AML_MATCH_OP                (UINT16) 0x89
11977424Smsmith#define AML_CREATE_DWORD_FIELD_OP   (UINT16) 0x8a
12077424Smsmith#define AML_CREATE_WORD_FIELD_OP    (UINT16) 0x8b
12177424Smsmith#define AML_CREATE_BYTE_FIELD_OP    (UINT16) 0x8c
12277424Smsmith#define AML_CREATE_BIT_FIELD_OP     (UINT16) 0x8d
123306536Sjkim#define AML_OBJECT_TYPE_OP          (UINT16) 0x8e
12477424Smsmith#define AML_CREATE_QWORD_FIELD_OP   (UINT16) 0x8f     /* ACPI 2.0 */
12567754Smsmith#define AML_LAND_OP                 (UINT16) 0x90
12667754Smsmith#define AML_LOR_OP                  (UINT16) 0x91
12767754Smsmith#define AML_LNOT_OP                 (UINT16) 0x92
12867754Smsmith#define AML_LEQUAL_OP               (UINT16) 0x93
12967754Smsmith#define AML_LGREATER_OP             (UINT16) 0x94
13067754Smsmith#define AML_LLESS_OP                (UINT16) 0x95
13169746Smsmith#define AML_TO_BUFFER_OP            (UINT16) 0x96     /* ACPI 2.0 */
13269746Smsmith#define AML_TO_DECSTRING_OP         (UINT16) 0x97     /* ACPI 2.0 */
13369746Smsmith#define AML_TO_HEXSTRING_OP         (UINT16) 0x98     /* ACPI 2.0 */
13469746Smsmith#define AML_TO_INTEGER_OP           (UINT16) 0x99     /* ACPI 2.0 */
13569746Smsmith#define AML_TO_STRING_OP            (UINT16) 0x9c     /* ACPI 2.0 */
13667754Smsmith#define AML_COPY_OP                 (UINT16) 0x9d     /* ACPI 2.0 */
13767754Smsmith#define AML_MID_OP                  (UINT16) 0x9e     /* ACPI 2.0 */
13867754Smsmith#define AML_CONTINUE_OP             (UINT16) 0x9f     /* ACPI 2.0 */
13967754Smsmith#define AML_IF_OP                   (UINT16) 0xa0
14067754Smsmith#define AML_ELSE_OP                 (UINT16) 0xa1
14167754Smsmith#define AML_WHILE_OP                (UINT16) 0xa2
14267754Smsmith#define AML_NOOP_OP                 (UINT16) 0xa3
14367754Smsmith#define AML_RETURN_OP               (UINT16) 0xa4
14467754Smsmith#define AML_BREAK_OP                (UINT16) 0xa5
14567754Smsmith#define AML_BREAK_POINT_OP          (UINT16) 0xcc
14667754Smsmith#define AML_ONES_OP                 (UINT16) 0xff
14767754Smsmith
14867754Smsmith/* prefixed opcodes */
14967754Smsmith
150151937Sjkim#define AML_EXTENDED_OPCODE         (UINT16) 0x5b00     /* prefix for 2-byte opcodes */
15167754Smsmith
15267754Smsmith#define AML_MUTEX_OP                (UINT16) 0x5b01
15367754Smsmith#define AML_EVENT_OP                (UINT16) 0x5b02
15467754Smsmith#define AML_SHIFT_RIGHT_BIT_OP      (UINT16) 0x5b10
15567754Smsmith#define AML_SHIFT_LEFT_BIT_OP       (UINT16) 0x5b11
15667754Smsmith#define AML_COND_REF_OF_OP          (UINT16) 0x5b12
15767754Smsmith#define AML_CREATE_FIELD_OP         (UINT16) 0x5b13
15867754Smsmith#define AML_LOAD_TABLE_OP           (UINT16) 0x5b1f     /* ACPI 2.0 */
15967754Smsmith#define AML_LOAD_OP                 (UINT16) 0x5b20
16067754Smsmith#define AML_STALL_OP                (UINT16) 0x5b21
16167754Smsmith#define AML_SLEEP_OP                (UINT16) 0x5b22
16267754Smsmith#define AML_ACQUIRE_OP              (UINT16) 0x5b23
16367754Smsmith#define AML_SIGNAL_OP               (UINT16) 0x5b24
16467754Smsmith#define AML_WAIT_OP                 (UINT16) 0x5b25
16567754Smsmith#define AML_RESET_OP                (UINT16) 0x5b26
16667754Smsmith#define AML_RELEASE_OP              (UINT16) 0x5b27
16767754Smsmith#define AML_FROM_BCD_OP             (UINT16) 0x5b28
16867754Smsmith#define AML_TO_BCD_OP               (UINT16) 0x5b29
16967754Smsmith#define AML_UNLOAD_OP               (UINT16) 0x5b2a
17067754Smsmith#define AML_REVISION_OP             (UINT16) 0x5b30
17167754Smsmith#define AML_DEBUG_OP                (UINT16) 0x5b31
17267754Smsmith#define AML_FATAL_OP                (UINT16) 0x5b32
173138287Smarks#define AML_TIMER_OP                (UINT16) 0x5b33     /* ACPI 3.0 */
17467754Smsmith#define AML_REGION_OP               (UINT16) 0x5b80
17577424Smsmith#define AML_FIELD_OP                (UINT16) 0x5b81
17667754Smsmith#define AML_DEVICE_OP               (UINT16) 0x5b82
17767754Smsmith#define AML_PROCESSOR_OP            (UINT16) 0x5b83
17867754Smsmith#define AML_POWER_RES_OP            (UINT16) 0x5b84
17967754Smsmith#define AML_THERMAL_ZONE_OP         (UINT16) 0x5b85
18067754Smsmith#define AML_INDEX_FIELD_OP          (UINT16) 0x5b86
18167754Smsmith#define AML_BANK_FIELD_OP           (UINT16) 0x5b87
18267754Smsmith#define AML_DATA_REGION_OP          (UINT16) 0x5b88     /* ACPI 2.0 */
18367754Smsmith
18467754Smsmith
185167802Sjkim/*
186167802Sjkim * Combination opcodes (actually two one-byte opcodes)
187167802Sjkim * Used by the disassembler and iASL compiler
188167802Sjkim */
18967754Smsmith#define AML_LGREATEREQUAL_OP        (UINT16) 0x9295
19067754Smsmith#define AML_LLESSEQUAL_OP           (UINT16) 0x9294
19167754Smsmith#define AML_LNOTEQUAL_OP            (UINT16) 0x9293
19267754Smsmith
19367754Smsmith
19467754Smsmith/*
195228110Sjkim * Opcodes for "Field" operators
196228110Sjkim */
197228110Sjkim#define AML_FIELD_OFFSET_OP         (UINT8) 0x00
198228110Sjkim#define AML_FIELD_ACCESS_OP         (UINT8) 0x01
199228110Sjkim#define AML_FIELD_CONNECTION_OP     (UINT8) 0x02        /* ACPI 5.0 */
200228110Sjkim#define AML_FIELD_EXT_ACCESS_OP     (UINT8) 0x03        /* ACPI 5.0 */
201228110Sjkim
202228110Sjkim
203228110Sjkim/*
20467754Smsmith * Internal opcodes
20567754Smsmith * Use only "Unknown" AML opcodes, don't attempt to use
20667754Smsmith * any valid ACPI ASCII values (A-Z, 0-9, '-')
20767754Smsmith */
20877424Smsmith#define AML_INT_NAMEPATH_OP         (UINT16) 0x002d
20977424Smsmith#define AML_INT_NAMEDFIELD_OP       (UINT16) 0x0030
21077424Smsmith#define AML_INT_RESERVEDFIELD_OP    (UINT16) 0x0031
21177424Smsmith#define AML_INT_ACCESSFIELD_OP      (UINT16) 0x0032
21277424Smsmith#define AML_INT_BYTELIST_OP         (UINT16) 0x0033
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
244306536Sjkim#define ARGP_SIMPLENAME             0x12 /* NameString | LocalTerm | ArgTerm */
245306536Sjkim#define ARGP_NAME_OR_REF            0x13 /* For ObjectType only */
24667754Smsmith
24767754Smsmith/*
24867754Smsmith * Resolved argument types for the AML Interpreter
24967754Smsmith * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments.
25071867Smsmith * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
25191116Smsmith *
252114237Snjl * Note1: These values are completely independent from the ACPI_TYPEs
253114237Snjl *        i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
254114237Snjl *
255114237Snjl * Note2: If and when 5 bits becomes insufficient, it would probably be best
25691116Smsmith * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
25767754Smsmith */
25867754Smsmith
259114237Snjl/* Single, simple types */
26067754Smsmith
261114237Snjl#define ARGI_ANYTYPE                0x01    /* Don't care */
262114237Snjl#define ARGI_PACKAGE                0x02
263114237Snjl#define ARGI_EVENT                  0x03
264114237Snjl#define ARGI_MUTEX                  0x04
265114237Snjl#define ARGI_DDBHANDLE              0x05
26671867Smsmith
267114237Snjl/* Interchangeable types (via implicit conversion) */
26871867Smsmith
269114237Snjl#define ARGI_INTEGER                0x06
270114237Snjl#define ARGI_STRING                 0x07
271114237Snjl#define ARGI_BUFFER                 0x08
272114237Snjl#define ARGI_BUFFER_OR_STRING       0x09    /* Used by MID op only */
273114237Snjl#define ARGI_COMPUTEDATA            0x0A    /* Buffer, String, or Integer */
27471867Smsmith
275114237Snjl/* Reference objects */
276114237Snjl
277114237Snjl#define ARGI_INTEGER_REF            0x0B
278114237Snjl#define ARGI_OBJECT_REF             0x0C
279114237Snjl#define ARGI_DEVICE_REF             0x0D
280114237Snjl#define ARGI_REFERENCE              0x0E
281114237Snjl#define ARGI_TARGETREF              0x0F    /* Target, subject to implicit conversion */
282114237Snjl#define ARGI_FIXED_TARGET           0x10    /* Target, no implicit conversion */
283114237Snjl#define ARGI_SIMPLE_TARGET          0x11    /* Name, Local, Arg -- no implicit conversion */
284306536Sjkim#define ARGI_STORE_TARGET           0x12    /* Target for store is TARGETREF + package objects */
285114237Snjl
286114237Snjl/* Multiple/complex types */
287114237Snjl
288306536Sjkim#define ARGI_DATAOBJECT             0x13    /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/
289306536Sjkim#define ARGI_COMPLEXOBJ             0x14    /* Buffer, String, or package (Used by INDEX op only) */
290306536Sjkim#define ARGI_REF_OR_STRING          0x15    /* Reference or String (Used by DEREFOF op only) */
291306536Sjkim#define ARGI_REGION_OR_BUFFER       0x16    /* Used by LOAD op only */
292306536Sjkim#define ARGI_DATAREFOBJ             0x17
293114237Snjl
294114237Snjl/* Note: types above can expand to 0x1F maximum */
295114237Snjl
29667754Smsmith#define ARGI_INVALID_OPCODE         0xFFFFFFFF
29767754Smsmith
29867754Smsmith
29967754Smsmith/*
30067754Smsmith * hash offsets
30167754Smsmith */
30267754Smsmith#define AML_EXTOP_HASH_OFFSET       22
30367754Smsmith#define AML_LNOT_HASH_OFFSET        19
30467754Smsmith
30567754Smsmith
30667754Smsmith/*
30767754Smsmith * opcode groups and types
30867754Smsmith */
30967754Smsmith#define OPGRP_NAMED                 0x01
31067754Smsmith#define OPGRP_FIELD                 0x02
31167754Smsmith#define OPGRP_BYTELIST              0x04
31267754Smsmith
31367754Smsmith
31487031Smsmith/*
31587031Smsmith * Opcode information
31685756Smsmith */
31767754Smsmith
31885756Smsmith/* Opcode flags */
31967754Smsmith
32085756Smsmith#define AML_LOGICAL                 0x0001
321138287Smarks#define AML_LOGICAL_NUMERIC         0x0002
322138287Smarks#define AML_MATH                    0x0004
323138287Smarks#define AML_CREATE                  0x0008
324138287Smarks#define AML_FIELD                   0x0010
325138287Smarks#define AML_DEFER                   0x0020
326138287Smarks#define AML_NAMED                   0x0040
327138287Smarks#define AML_NSNODE                  0x0080
328138287Smarks#define AML_NSOPCODE                0x0100
329138287Smarks#define AML_NSOBJECT                0x0200
330138287Smarks#define AML_HAS_RETVAL              0x0400
331138287Smarks#define AML_HAS_TARGET              0x0800
332138287Smarks#define AML_HAS_ARGS                0x1000
333138287Smarks#define AML_CONSTANT                0x2000
334151937Sjkim#define AML_NO_OPERAND_RESOLVE      0x4000
33567754Smsmith
33685756Smsmith/* Convenient flag groupings */
33767754Smsmith
338138287Smarks#define AML_FLAGS_EXEC_0A_0T_1R                                     AML_HAS_RETVAL
33985756Smsmith#define AML_FLAGS_EXEC_1A_0T_0R     AML_HAS_ARGS                                   /* Monadic1  */
34085756Smsmith#define AML_FLAGS_EXEC_1A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Monadic2  */
34185756Smsmith#define AML_FLAGS_EXEC_1A_1T_0R     AML_HAS_ARGS | AML_HAS_TARGET
34285756Smsmith#define AML_FLAGS_EXEC_1A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */
34385756Smsmith#define AML_FLAGS_EXEC_2A_0T_0R     AML_HAS_ARGS                                   /* Dyadic1   */
34485756Smsmith#define AML_FLAGS_EXEC_2A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Dyadic2   */
34585756Smsmith#define AML_FLAGS_EXEC_2A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R  */
34685756Smsmith#define AML_FLAGS_EXEC_2A_2T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34785756Smsmith#define AML_FLAGS_EXEC_3A_0T_0R     AML_HAS_ARGS
34885756Smsmith#define AML_FLAGS_EXEC_3A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
34985756Smsmith#define AML_FLAGS_EXEC_6A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL
35067754Smsmith
35167754Smsmith
35285756Smsmith/*
35385756Smsmith * The opcode Type is used in a dispatch table, do not change
35485756Smsmith * without updating the table.
35585756Smsmith */
356138287Smarks#define AML_TYPE_EXEC_0A_0T_1R      0x00
357138287Smarks#define AML_TYPE_EXEC_1A_0T_0R      0x01 /* Monadic1  */
358138287Smarks#define AML_TYPE_EXEC_1A_0T_1R      0x02 /* Monadic2  */
359138287Smarks#define AML_TYPE_EXEC_1A_1T_0R      0x03
360138287Smarks#define AML_TYPE_EXEC_1A_1T_1R      0x04 /* Monadic2R */
361138287Smarks#define AML_TYPE_EXEC_2A_0T_0R      0x05 /* Dyadic1   */
362138287Smarks#define AML_TYPE_EXEC_2A_0T_1R      0x06 /* Dyadic2   */
363138287Smarks#define AML_TYPE_EXEC_2A_1T_1R      0x07 /* Dyadic2R  */
364138287Smarks#define AML_TYPE_EXEC_2A_2T_1R      0x08
365138287Smarks#define AML_TYPE_EXEC_3A_0T_0R      0x09
366138287Smarks#define AML_TYPE_EXEC_3A_1T_1R      0x0A
367138287Smarks#define AML_TYPE_EXEC_6A_0T_1R      0x0B
36885756Smsmith/* End of types used in dispatch table */
36980062Smsmith
37085756Smsmith#define AML_TYPE_LITERAL            0x0B
37185756Smsmith#define AML_TYPE_CONSTANT           0x0C
37285756Smsmith#define AML_TYPE_METHOD_ARGUMENT    0x0D
37385756Smsmith#define AML_TYPE_LOCAL_VARIABLE     0x0E
37485756Smsmith#define AML_TYPE_DATA_TERM          0x0F
37580062Smsmith
37667754Smsmith/* Generic for an op that returns a value */
37767754Smsmith
37885756Smsmith#define AML_TYPE_METHOD_CALL        0x10
37967754Smsmith
38067754Smsmith/* Misc */
38167754Smsmith
38285756Smsmith#define AML_TYPE_CREATE_FIELD       0x11
38399146Siwasaki#define AML_TYPE_CREATE_OBJECT      0x12
38499146Siwasaki#define AML_TYPE_CONTROL            0x13
38599146Siwasaki#define AML_TYPE_NAMED_NO_OBJ       0x14
38699146Siwasaki#define AML_TYPE_NAMED_FIELD        0x15
38799146Siwasaki#define AML_TYPE_NAMED_SIMPLE       0x16
38899146Siwasaki#define AML_TYPE_NAMED_COMPLEX      0x17
38999146Siwasaki#define AML_TYPE_RETURN             0x18
39067754Smsmith
39199146Siwasaki#define AML_TYPE_UNDEFINED          0x19
39299146Siwasaki#define AML_TYPE_BOGUS              0x1A
39367754Smsmith
394151937Sjkim/* AML Package Length encodings */
39567754Smsmith
396151937Sjkim#define ACPI_AML_PACKAGE_TYPE1      0x40
397151937Sjkim#define ACPI_AML_PACKAGE_TYPE2      0x4000
398151937Sjkim#define ACPI_AML_PACKAGE_TYPE3      0x400000
399151937Sjkim#define ACPI_AML_PACKAGE_TYPE4      0x40000000
400151937Sjkim
40187031Smsmith/*
40287031Smsmith * Opcode classes
40385756Smsmith */
40485756Smsmith#define AML_CLASS_EXECUTE           0x00
40585756Smsmith#define AML_CLASS_CREATE            0x01
40685756Smsmith#define AML_CLASS_ARGUMENT          0x02
40785756Smsmith#define AML_CLASS_NAMED_OBJECT      0x03
40885756Smsmith#define AML_CLASS_CONTROL           0x04
40985756Smsmith#define AML_CLASS_ASCII             0x05
41085756Smsmith#define AML_CLASS_PREFIX            0x06
41185756Smsmith#define AML_CLASS_INTERNAL          0x07
41285756Smsmith#define AML_CLASS_RETURN_VALUE      0x08
41385756Smsmith#define AML_CLASS_METHOD_CALL       0x09
41485756Smsmith#define AML_CLASS_UNKNOWN           0x0A
41585756Smsmith
41685756Smsmith
41767754Smsmith/* Comparison operation codes for MatchOp operator */
41867754Smsmith
41967754Smsmithtypedef enum
42067754Smsmith{
42177424Smsmith    MATCH_MTR                       = 0,
42277424Smsmith    MATCH_MEQ                       = 1,
42377424Smsmith    MATCH_MLE                       = 2,
42477424Smsmith    MATCH_MLT                       = 3,
42577424Smsmith    MATCH_MGE                       = 4,
42677424Smsmith    MATCH_MGT                       = 5
42767754Smsmith
42867754Smsmith} AML_MATCH_OPERATOR;
42967754Smsmith
43077424Smsmith#define MAX_MATCH_OPERATOR          5
43167754Smsmith
43267754Smsmith
43387031Smsmith/*
43487031Smsmith * FieldFlags
43587031Smsmith *
43687031Smsmith * This byte is extracted from the AML and includes three separate
43787031Smsmith * pieces of information about the field:
43887031Smsmith * 1) The field access type
43987031Smsmith * 2) The field update rule
44087031Smsmith * 3) The lock rule for the field
44187031Smsmith *
44287031Smsmith * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.)
44387031Smsmith *      04      : LockRule (1 == Lock)
44487031Smsmith *      05 - 06 : UpdateRule
44587031Smsmith */
44687031Smsmith#define AML_FIELD_ACCESS_TYPE_MASK  0x0F
44787031Smsmith#define AML_FIELD_LOCK_RULE_MASK    0x10
44887031Smsmith#define AML_FIELD_UPDATE_RULE_MASK  0x60
44967754Smsmith
45067754Smsmith
45187031Smsmith/* 1) Field Access Types */
45287031Smsmith
45367754Smsmithtypedef enum
45467754Smsmith{
45587031Smsmith    AML_FIELD_ACCESS_ANY            = 0x00,
45687031Smsmith    AML_FIELD_ACCESS_BYTE           = 0x01,
45787031Smsmith    AML_FIELD_ACCESS_WORD           = 0x02,
45887031Smsmith    AML_FIELD_ACCESS_DWORD          = 0x03,
45987031Smsmith    AML_FIELD_ACCESS_QWORD          = 0x04,    /* ACPI 2.0 */
46091116Smsmith    AML_FIELD_ACCESS_BUFFER         = 0x05     /* ACPI 2.0 */
46167754Smsmith
46267754Smsmith} AML_ACCESS_TYPE;
46367754Smsmith
46467754Smsmith
46587031Smsmith/* 2) Field Lock Rules */
46667754Smsmith
46767754Smsmithtypedef enum
46867754Smsmith{
46987031Smsmith    AML_FIELD_LOCK_NEVER            = 0x00,
47091116Smsmith    AML_FIELD_LOCK_ALWAYS           = 0x10
47167754Smsmith
47267754Smsmith} AML_LOCK_RULE;
47367754Smsmith
47467754Smsmith
47587031Smsmith/* 3) Field Update Rules */
47667754Smsmith
47767754Smsmithtypedef enum
47867754Smsmith{
47987031Smsmith    AML_FIELD_UPDATE_PRESERVE       = 0x00,
48087031Smsmith    AML_FIELD_UPDATE_WRITE_AS_ONES  = 0x20,
48191116Smsmith    AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
48267754Smsmith
48367754Smsmith} AML_UPDATE_RULE;
48467754Smsmith
48567754Smsmith
48691116Smsmith/*
48787031Smsmith * Field Access Attributes.
48887031Smsmith * This byte is extracted from the AML via the
48991116Smsmith * AccessAs keyword
49087031Smsmith */
49187031Smsmithtypedef enum
49287031Smsmith{
493228110Sjkim    AML_FIELD_ATTRIB_QUICK          = 0x02,
494228110Sjkim    AML_FIELD_ATTRIB_SEND_RCV       = 0x04,
495228110Sjkim    AML_FIELD_ATTRIB_BYTE           = 0x06,
496228110Sjkim    AML_FIELD_ATTRIB_WORD           = 0x08,
497228110Sjkim    AML_FIELD_ATTRIB_BLOCK          = 0x0A,
498228110Sjkim    AML_FIELD_ATTRIB_MULTIBYTE      = 0x0B,
499228110Sjkim    AML_FIELD_ATTRIB_WORD_CALL      = 0x0C,
500228110Sjkim    AML_FIELD_ATTRIB_BLOCK_CALL     = 0x0D,
501228110Sjkim    AML_FIELD_ATTRIB_RAW_BYTES      = 0x0E,
502228110Sjkim    AML_FIELD_ATTRIB_RAW_PROCESS    = 0x0F
50387031Smsmith
50487031Smsmith} AML_ACCESS_ATTRIBUTE;
50587031Smsmith
50687031Smsmith
507217365Sjkim/* Bit fields in the AML MethodFlags byte */
50867754Smsmith
509127175Snjl#define AML_METHOD_ARG_COUNT        0x07
510127175Snjl#define AML_METHOD_SERIALIZED       0x08
511193267Sjkim#define AML_METHOD_SYNC_LEVEL       0xF0
51267754Smsmith
51367754Smsmith
51467754Smsmith#endif /* __AMLCODE_H__ */
515