1 /******************************************************************************
3 * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
4 * Declarations and definitions contained herein are derived
5 * directly from the ACPI specification.
8 *****************************************************************************/
11 * Copyright (C) 2000, 2001 R. Byron Moore
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define AML_NULL_CHAR (u16) 0x00
36 #define AML_ZERO_OP (u16) 0x00
37 #define AML_ONE_OP (u16) 0x01
38 #define AML_UNASSIGNED (u16) 0x02
39 #define AML_ALIAS_OP (u16) 0x06
40 #define AML_NAME_OP (u16) 0x08
41 #define AML_BYTE_OP (u16) 0x0a
42 #define AML_WORD_OP (u16) 0x0b
43 #define AML_DWORD_OP (u16) 0x0c
44 #define AML_STRING_OP (u16) 0x0d
45 #define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */
46 #define AML_SCOPE_OP (u16) 0x10
47 #define AML_BUFFER_OP (u16) 0x11
48 #define AML_PACKAGE_OP (u16) 0x12
49 #define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */
50 #define AML_METHOD_OP (u16) 0x14
51 #define AML_DUAL_NAME_PREFIX (u16) 0x2e
52 #define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f
53 #define AML_NAME_CHAR_SUBSEQ (u16) 0x30
54 #define AML_NAME_CHAR_FIRST (u16) 0x41
55 #define AML_OP_PREFIX (u16) 0x5b
56 #define AML_ROOT_PREFIX (u16) 0x5c
57 #define AML_PARENT_PREFIX (u16) 0x5e
58 #define AML_LOCAL_OP (u16) 0x60
59 #define AML_LOCAL0 (u16) 0x60
60 #define AML_LOCAL1 (u16) 0x61
61 #define AML_LOCAL2 (u16) 0x62
62 #define AML_LOCAL3 (u16) 0x63
63 #define AML_LOCAL4 (u16) 0x64
64 #define AML_LOCAL5 (u16) 0x65
65 #define AML_LOCAL6 (u16) 0x66
66 #define AML_LOCAL7 (u16) 0x67
67 #define AML_ARG_OP (u16) 0x68
68 #define AML_ARG0 (u16) 0x68
69 #define AML_ARG1 (u16) 0x69
70 #define AML_ARG2 (u16) 0x6a
71 #define AML_ARG3 (u16) 0x6b
72 #define AML_ARG4 (u16) 0x6c
73 #define AML_ARG5 (u16) 0x6d
74 #define AML_ARG6 (u16) 0x6e
75 #define AML_STORE_OP (u16) 0x70
76 #define AML_REF_OF_OP (u16) 0x71
77 #define AML_ADD_OP (u16) 0x72
78 #define AML_CONCAT_OP (u16) 0x73
79 #define AML_SUBTRACT_OP (u16) 0x74
80 #define AML_INCREMENT_OP (u16) 0x75
81 #define AML_DECREMENT_OP (u16) 0x76
82 #define AML_MULTIPLY_OP (u16) 0x77
83 #define AML_DIVIDE_OP (u16) 0x78
84 #define AML_SHIFT_LEFT_OP (u16) 0x79
85 #define AML_SHIFT_RIGHT_OP (u16) 0x7a
86 #define AML_BIT_AND_OP (u16) 0x7b
87 #define AML_BIT_NAND_OP (u16) 0x7c
88 #define AML_BIT_OR_OP (u16) 0x7d
89 #define AML_BIT_NOR_OP (u16) 0x7e
90 #define AML_BIT_XOR_OP (u16) 0x7f
91 #define AML_BIT_NOT_OP (u16) 0x80
92 #define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81
93 #define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82
94 #define AML_DEREF_OF_OP (u16) 0x83
95 #define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */
96 #define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */
97 #define AML_NOTIFY_OP (u16) 0x86
98 #define AML_SIZE_OF_OP (u16) 0x87
99 #define AML_INDEX_OP (u16) 0x88
100 #define AML_MATCH_OP (u16) 0x89
101 #define AML_DWORD_FIELD_OP (u16) 0x8a
102 #define AML_WORD_FIELD_OP (u16) 0x8b
103 #define AML_BYTE_FIELD_OP (u16) 0x8c
104 #define AML_BIT_FIELD_OP (u16) 0x8d
105 #define AML_TYPE_OP (u16) 0x8e
106 #define AML_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */
107 #define AML_LAND_OP (u16) 0x90
108 #define AML_LOR_OP (u16) 0x91
109 #define AML_LNOT_OP (u16) 0x92
110 #define AML_LEQUAL_OP (u16) 0x93
111 #define AML_LGREATER_OP (u16) 0x94
112 #define AML_LLESS_OP (u16) 0x95
113 #define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */
114 #define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */
115 #define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */
116 #define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */
117 #define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */
118 #define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */
119 #define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */
120 #define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */
121 #define AML_IF_OP (u16) 0xa0
122 #define AML_ELSE_OP (u16) 0xa1
123 #define AML_WHILE_OP (u16) 0xa2
124 #define AML_NOOP_OP (u16) 0xa3
125 #define AML_RETURN_OP (u16) 0xa4
126 #define AML_BREAK_OP (u16) 0xa5
127 #define AML_BREAK_POINT_OP (u16) 0xcc
128 #define AML_ONES_OP (u16) 0xff
130 /* prefixed opcodes */
132 #define AML_EXTOP (u16) 0x005b
135 #define AML_MUTEX_OP (u16) 0x5b01
136 #define AML_EVENT_OP (u16) 0x5b02
137 #define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10
138 #define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11
139 #define AML_COND_REF_OF_OP (u16) 0x5b12
140 #define AML_CREATE_FIELD_OP (u16) 0x5b13
141 #define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */
142 #define AML_LOAD_OP (u16) 0x5b20
143 #define AML_STALL_OP (u16) 0x5b21
144 #define AML_SLEEP_OP (u16) 0x5b22
145 #define AML_ACQUIRE_OP (u16) 0x5b23
146 #define AML_SIGNAL_OP (u16) 0x5b24
147 #define AML_WAIT_OP (u16) 0x5b25
148 #define AML_RESET_OP (u16) 0x5b26
149 #define AML_RELEASE_OP (u16) 0x5b27
150 #define AML_FROM_BCD_OP (u16) 0x5b28
151 #define AML_TO_BCD_OP (u16) 0x5b29
152 #define AML_UNLOAD_OP (u16) 0x5b2a
153 #define AML_REVISION_OP (u16) 0x5b30
154 #define AML_DEBUG_OP (u16) 0x5b31
155 #define AML_FATAL_OP (u16) 0x5b32
156 #define AML_REGION_OP (u16) 0x5b80
157 #define AML_DEF_FIELD_OP (u16) 0x5b81
158 #define AML_DEVICE_OP (u16) 0x5b82
159 #define AML_PROCESSOR_OP (u16) 0x5b83
160 #define AML_POWER_RES_OP (u16) 0x5b84
161 #define AML_THERMAL_ZONE_OP (u16) 0x5b85
162 #define AML_INDEX_FIELD_OP (u16) 0x5b86
163 #define AML_BANK_FIELD_OP (u16) 0x5b87
164 #define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */
167 /* Bogus opcodes (they are actually two separate opcodes) */
169 #define AML_LGREATEREQUAL_OP (u16) 0x9295
170 #define AML_LLESSEQUAL_OP (u16) 0x9294
171 #define AML_LNOTEQUAL_OP (u16) 0x9293
176 * Use only "Unknown" AML opcodes, don't attempt to use
177 * any valid ACPI ASCII values (A-Z, 0-9, '-')
180 #define AML_NAMEPATH_OP (u16) 0x002d
181 #define AML_NAMEDFIELD_OP (u16) 0x0030
182 #define AML_RESERVEDFIELD_OP (u16) 0x0031
183 #define AML_ACCESSFIELD_OP (u16) 0x0032
184 #define AML_BYTELIST_OP (u16) 0x0033
185 #define AML_STATICSTRING_OP (u16) 0x0034
186 #define AML_METHODCALL_OP (u16) 0x0035
187 #define AML_RETURN_VALUE_OP (u16) 0x0036
193 * Argument types for the AML Parser
194 * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
195 * There can be up to 31 unique argument types
198 #define ARGP_BYTEDATA 0x01
199 #define ARGP_BYTELIST 0x02
200 #define ARGP_CHARLIST 0x03
201 #define ARGP_DATAOBJ 0x04
202 #define ARGP_DATAOBJLIST 0x05
203 #define ARGP_DWORDDATA 0x06
204 #define ARGP_FIELDLIST 0x07
205 #define ARGP_NAME 0x08
206 #define ARGP_NAMESTRING 0x09
207 #define ARGP_OBJLIST 0x0A
208 #define ARGP_PKGLENGTH 0x0B
209 #define ARGP_SUPERNAME 0x0C
210 #define ARGP_TARGET 0x0D
211 #define ARGP_TERMARG 0x0E
212 #define ARGP_TERMLIST 0x0F
213 #define ARGP_WORDDATA 0x10
214 #define ARGP_QWORDDATA 0x11
215 #define ARGP_SIMPLENAME 0x12
218 * Resolved argument types for the AML Interpreter
219 * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
220 * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
223 /* "Standard" ACPI types are 1-15 (0x0F) */
225 #define ARGI_INTEGER ACPI_TYPE_INTEGER /* 1 */
226 #define ARGI_STRING ACPI_TYPE_STRING /* 2 */
227 #define ARGI_BUFFER ACPI_TYPE_BUFFER /* 3 */
228 #define ARGI_PACKAGE ACPI_TYPE_PACKAGE /* 4 */
229 #define ARGI_EVENT ACPI_TYPE_EVENT
230 #define ARGI_MUTEX ACPI_TYPE_MUTEX
231 #define ARGI_REGION ACPI_TYPE_REGION
232 #define ARGI_DDBHANDLE ACPI_TYPE_DDB_HANDLE
234 /* Custom types are 0x10 through 0x1F */
237 #define ARGI_ANYOBJECT 0x11
238 #define ARGI_ANYTYPE 0x12
239 #define ARGI_COMPUTEDATA 0x13 /* Buffer, String, or Integer */
240 #define ARGI_DATAOBJECT 0x14 /* Buffer, string, package or reference to a Node - Used only by Size_of operator*/
241 #define ARGI_COMPLEXOBJ 0x15 /* Buffer or package */
242 #define ARGI_INTEGER_REF 0x16
243 #define ARGI_OBJECT_REF 0x17
244 #define ARGI_DEVICE_REF 0x18
245 #define ARGI_REFERENCE 0x19
246 #define ARGI_TARGETREF 0x1A /* Target, subject to implicit conversion */
247 #define ARGI_FIXED_TARGET 0x1B /* Target, no implicit conversion */
248 #define ARGI_SIMPLE_TARGET 0x1C /* Name, Local, Arg -- no implicit conversion */
249 #define ARGI_BUFFERSTRING 0x1D
251 #define ARGI_INVALID_OPCODE 0xFFFFFFFF
257 #define AML_EXTOP_HASH_OFFSET 22
258 #define AML_LNOT_HASH_OFFSET 19
262 * opcode groups and types
265 #define OPGRP_NAMED 0x01
266 #define OPGRP_FIELD 0x02
267 #define OPGRP_BYTELIST 0x04
269 #define OPTYPE_UNDEFINED 0
272 #define OPTYPE_LITERAL 1
273 #define OPTYPE_CONSTANT 2
274 #define OPTYPE_METHOD_ARGUMENT 3
275 #define OPTYPE_LOCAL_VARIABLE 4
276 #define OPTYPE_DATA_TERM 5
280 #define OPTYPE_MONADIC1 6
281 #define OPTYPE_DYADIC1 7
286 #define OPTYPE_MONADIC2 8
287 #define OPTYPE_MONADIC2_r 9
288 #define OPTYPE_DYADIC2 10
289 #define OPTYPE_DYADIC2_r 11
290 #define OPTYPE_DYADIC2_s 12
291 #define OPTYPE_INDEX 13
292 #define OPTYPE_MATCH 14
294 /* Generic for an op that returns a value */
296 #define OPTYPE_METHOD_CALL 15
301 #define OPTYPE_CREATE_FIELD 16
302 #define OPTYPE_FATAL 17
303 #define OPTYPE_CONTROL 18
304 #define OPTYPE_RECONFIGURATION 19
305 #define OPTYPE_NAMED_OBJECT 20
306 #define OPTYPE_RETURN 21
308 #define OPTYPE_BOGUS 22
311 /* Predefined Operation Region Space_iDs */
326 /* Comparison operation codes for Match_op operator */
337 } AML_MATCH_OPERATOR
;
339 #define MAX_MATCH_OPERATOR 5
342 /* Field Access Types */
344 #define ACCESS_TYPE_MASK 0x0f
345 #define ACCESS_TYPE_SHIFT 0
352 ACCESS_DWORD_ACC
= 3,
353 ACCESS_BLOCK_ACC
= 4,
354 ACCESS_SMBSEND_RECV_ACC
= 5,
355 ACCESS_SMBQUICK_ACC
= 6
360 /* Field Lock Rules */
362 #define LOCK_RULE_MASK 0x10
363 #define LOCK_RULE_SHIFT 4
367 GLOCK_NEVER_LOCK
= 0,
368 GLOCK_ALWAYS_LOCK
= 1
373 /* Field Update Rules */
375 #define UPDATE_RULE_MASK 0x060
376 #define UPDATE_RULE_SHIFT 5
381 UPDATE_WRITE_AS_ONES
= 1,
382 UPDATE_WRITE_AS_ZEROS
= 2
387 /* bit fields in Method_flags byte */
389 #define METHOD_FLAGS_ARG_COUNT 0x07
390 #define METHOD_FLAGS_SERIALIZED 0x08
391 #define METHOD_FLAGS_SYNCH_LEVEL 0xF0
394 /* Array sizes. Used for range checking also */
396 #define NUM_REGION_TYPES 7
397 #define NUM_ACCESS_TYPES 7
398 #define NUM_UPDATE_RULES 3
399 #define NUM_MATCH_OPS 7
400 #define NUM_OPCODES 256
401 #define NUM_FIELD_NAMES 2
404 #define USER_REGION_BEGIN 0x80
410 #ifdef DEFINE_AML_GLOBALS
412 /* External declarations of the AML tables */
414 extern u8 acpi_gbl_aml
[NUM_OPCODES
];
415 extern u16 acpi_gbl_pfx
[NUM_OPCODES
];
418 #endif /* DEFINE_AML_GLOBALS */
420 #endif /* __AMLCODE_H__ */