1#pragma once
2
3#include <uacpi/types.h>
4
5typedef uacpi_u16 uacpi_aml_op;
6
7#define UACPI_EXT_PREFIX 0x5B
8#define UACPI_EXT_OP(op) ((UACPI_EXT_PREFIX << 8) | (op))
9
10#define UACPI_DUAL_NAME_PREFIX 0x2E
11#define UACPI_MULTI_NAME_PREFIX 0x2F
12#define UACPI_NULL_NAME 0x00
13
14/*
15 * Opcodes that tell the parser VM how to take apart every AML instruction.
16 * Every AML opcode has a list of these that is executed by the parser.
17 */
18enum uacpi_parse_op {
19 UACPI_PARSE_OP_END = 0,
20
21 /*
22 * End the execution of the current instruction with a warning if the item
23 * at decode_ops[pc + 1] is NULL.
24 */
25 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL,
26
27 // SimpleName := NameString | ArgObj | LocalObj
28 UACPI_PARSE_OP_SIMPLE_NAME,
29
30 // SuperName := SimpleName | DebugObj | ReferenceTypeOpcode
31 UACPI_PARSE_OP_SUPERNAME,
32 // The resulting item will be set to null if name couldn't be resolved
33 UACPI_PARSE_OP_SUPERNAME_OR_UNRESOLVED,
34
35 // TermArg := ExpressionOpcode | DataObject | ArgObj | LocalObj
36 UACPI_PARSE_OP_TERM_ARG,
37 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL,
38
39 /*
40 * Same as TERM_ARG, but named references are passed as-is.
41 * This means methods are not invoked, fields are not read, etc.
42 */
43 UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT,
44
45 /*
46 * Same as UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT but allows unresolved
47 * name strings.
48 */
49 UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT_OR_UNRESOLVED,
50
51 // Operand := TermArg => Integer
52 UACPI_PARSE_OP_OPERAND,
53
54 // TermArg => String
55 UACPI_PARSE_OP_STRING,
56
57 /*
58 * ComputationalData := ByteConst | WordConst | DWordConst | QWordConst |
59 * String | ConstObj | RevisionOp | DefBuffer
60 */
61 UACPI_PARSE_OP_COMPUTATIONAL_DATA,
62
63 // Target := SuperName | NullName
64 UACPI_PARSE_OP_TARGET,
65
66 // Parses a pkglen
67 UACPI_PARSE_OP_PKGLEN,
68
69 /*
70 * Parses a pkglen and records it, the end of this pkglen is considered
71 * the end of the instruction. The PC is always set to the end of this
72 * package once parser reaches UACPI_PARSE_OP_END.
73 */
74 UACPI_PARSE_OP_TRACKED_PKGLEN,
75
76 /*
77 * Parse a NameString and create the last nameseg.
78 * Note that this errors out if last nameseg already exists.
79 */
80 UACPI_PARSE_OP_CREATE_NAMESTRING,
81
82 /*
83 * same as UACPI_PARSE_OP_CREATE_NAMESTRING, but attempting to create an
84 * already existing object is not fatal if currently loading a table.
85 */
86 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD,
87
88 /*
89 * Parse a NameString and put the node into the ready parts array.
90 * Note that this errors out if the referenced node doesn't exist.
91 */
92 UACPI_PARSE_OP_EXISTING_NAMESTRING,
93
94 /*
95 * Same as UACPI_PARSE_OP_EXISTING_NAMESTRING except the op doesn't error
96 * out if namestring couldn't be resolved.
97 */
98 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL,
99
100 /*
101 * Same as UACPI_PARSE_OP_EXISTING_NAMESTRING, but undefined references
102 * are not fatal if currently loading a table.
103 */
104 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL_IF_LOAD,
105
106 // Invoke a handler at op_handlers[spec->code]
107 UACPI_PARSE_OP_INVOKE_HANDLER,
108
109 // Allocate an object an put it at the front of the item list
110 UACPI_PARSE_OP_OBJECT_ALLOC,
111
112 UACPI_PARSE_OP_EMPTY_OBJECT_ALLOC,
113
114 // Convert last item into a shallow/deep copy of itself
115 UACPI_PARSE_OP_OBJECT_CONVERT_TO_SHALLOW_COPY,
116 UACPI_PARSE_OP_OBJECT_CONVERT_TO_DEEP_COPY,
117
118 /*
119 * Same as UACPI_PARSE_OP_OBJECT_ALLOC except the type of the allocated
120 * object is specified at decode_ops[pc + 1]
121 */
122 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED,
123
124 // Record current AML program counter as a QWORD immediate
125 UACPI_PARSE_OP_RECORD_AML_PC,
126
127 // Load a QWORD immediate located at decode_ops[pc + 1]
128 UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT,
129
130 // Load a decode_ops[pc + 1] byte imm at decode_ops[pc + 2]
131 UACPI_PARSE_OP_LOAD_INLINE_IMM,
132
133 // Load a QWORD zero immediate
134 UACPI_PARSE_OP_LOAD_ZERO_IMM,
135
136 // Load a decode_ops[pc + 1] byte imm from the instructions stream
137 UACPI_PARSE_OP_LOAD_IMM,
138
139 // Same as UACPI_PARSE_OP_LOAD_IMM, expect the resulting value is an object
140 UACPI_PARSE_OP_LOAD_IMM_AS_OBJECT,
141
142 // Create & Load an integer constant representing either true or false
143 UACPI_PARSE_OP_LOAD_FALSE_OBJECT,
144 UACPI_PARSE_OP_LOAD_TRUE_OBJECT,
145
146 // Truncate the last item in the list if needed
147 UACPI_PARSE_OP_TRUNCATE_NUMBER,
148
149 // Ensure the type of item is decode_ops[pc + 1]
150 UACPI_PARSE_OP_TYPECHECK,
151
152 // Install the namespace node specified in items[decode_ops[pc + 1]]
153 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE,
154
155 // Move item to the previous (preempted) op
156 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV,
157
158 /*
159 * Same as UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, but the object
160 * is copied instead. (Useful when dealing with multiple targets)
161 * TODO: optimize this so that we can optionally move the object
162 * if target was a null target.
163 */
164 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV,
165
166 // Store the last item to the target at items[decode_ops[pc + 1]]
167 UACPI_PARSE_OP_STORE_TO_TARGET,
168
169 /*
170 * Store the item at items[decode_ops[pc + 2]] to target
171 * at items[decode_ops[pc + 1]]
172 */
173 UACPI_PARSE_OP_STORE_TO_TARGET_INDIRECT,
174
175 /*
176 * Error if reached. Should be used for opcodes that are supposed to be
177 * converted at op parse time, e.g. invoking a method or referring to
178 * a named object.
179 */
180 UACPI_PARSE_OP_UNREACHABLE,
181
182 // Invalid opcode, should never be encountered in the stream
183 UACPI_PARSE_OP_BAD_OPCODE,
184
185 // Decrement the current AML instruction pointer
186 UACPI_PARSE_OP_AML_PC_DECREMENT,
187
188 // Decrement the immediate at decode_ops[pc + 1]
189 UACPI_PARSE_OP_IMM_DECREMENT,
190
191 // Remove the last item off the item stack
192 UACPI_PARSE_OP_ITEM_POP,
193
194 // Dispatch the method call from items[0] and return from current op_exec
195 UACPI_PARSE_OP_DISPATCH_METHOD_CALL,
196
197 /*
198 * Dispatch a table load with scope node at items[0] and method at items[1].
199 * The last item is expected to be an integer object that is set to 0 in
200 * case load fails.
201 */
202 UACPI_PARSE_OP_DISPATCH_TABLE_LOAD,
203
204 /*
205 * Convert the current resolved namestring to either a method call
206 * or a named object reference.
207 */
208 UACPI_PARSE_OP_CONVERT_NAMESTRING,
209
210 /*
211 * Execute the next instruction only if currently tracked package still
212 * has data left, otherwise skip decode_ops[pc + 1] bytes.
213 */
214 UACPI_PARSE_OP_IF_HAS_DATA,
215
216 /*
217 * Execute the next instruction only if the handle at
218 * items[decode_ops[pc + 1]] is null. Otherwise skip
219 * decode_ops[pc + 2] bytes.
220 */
221 UACPI_PARSE_OP_IF_NULL,
222
223 // The inverse of UACPI_PARSE_OP_IF_NULL
224 UACPI_PARSE_OP_IF_NOT_NULL,
225
226 /*
227 * Execute the next instruction only if the last immediate is equal to
228 * decode_ops[pc + 1], otherwise skip decode_ops[pc + 2] bytes.
229 */
230 UACPI_PARSE_OP_IF_EQUALS,
231
232 /*
233 * pc = decode_ops[pc + 1]
234 */
235 UACPI_PARSE_OP_JMP,
236 UACPI_PARSE_OP_MAX = UACPI_PARSE_OP_JMP,
237};
238const uacpi_char *uacpi_parse_op_to_string(enum uacpi_parse_op op);
239
240/*
241 * A few notes about op properties:
242 * Technically the spec says that RefOfOp is considered a SuperName, but NT
243 * disagrees about this. For example Store(..., RefOf) fails with
244 * "Invalid SuperName". MethodInvocation could also technically be considered
245 * a SuperName, but NT doesn't allow that either: Store(..., MethodInvocation)
246 * fails with "Invalid Target Method, expected a DataObject" error.
247 */
248
249enum uacpi_op_property {
250 UACPI_OP_PROPERTY_TERM_ARG = 1,
251 UACPI_OP_PROPERTY_SUPERNAME = 2,
252 UACPI_OP_PROPERTY_SIMPLE_NAME = 4,
253 UACPI_OP_PROPERTY_TARGET = 8,
254
255 // The ops to execute are pointed to by indirect_decode_ops
256 UACPI_OP_PROPERTY_OUT_OF_LINE = 16,
257
258 // Error if encountered in the AML byte strem
259 UACPI_OP_PROPERTY_RESERVED = 128,
260};
261
262struct uacpi_op_spec {
263 uacpi_char *name;
264 union {
265 uacpi_u8 decode_ops[16];
266 uacpi_u8 *indirect_decode_ops;
267 };
268 uacpi_u8 properties;
269 uacpi_aml_op code;
270};
271
272const struct uacpi_op_spec *uacpi_get_op_spec(uacpi_aml_op);
273
274#define UACPI_INTERNAL_OP(code) \
275 UACPI_OP(Internal_##code, code, { UACPI_PARSE_OP_UNREACHABLE })
276
277#define UACPI_BAD_OPCODE(code) \
278 UACPI_OP(Reserved_##code, code, { UACPI_PARSE_OP_BAD_OPCODE })
279
280#define UACPI_METHOD_CALL_OPCODE(nargs) \
281 UACPI_OP( \
282 InternalOpMethodCall##nargs##Args, 0xF7 + nargs, \
283 { \
284 UACPI_PARSE_OP_LOAD_INLINE_IMM, 1, nargs, \
285 UACPI_PARSE_OP_IF_NOT_NULL, 1, 6, \
286 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
287 UACPI_PARSE_OP_OBJECT_CONVERT_TO_SHALLOW_COPY, \
288 UACPI_PARSE_OP_IMM_DECREMENT, 1, \
289 UACPI_PARSE_OP_JMP, 3, \
290 UACPI_PARSE_OP_OBJECT_ALLOC, \
291 UACPI_PARSE_OP_DISPATCH_METHOD_CALL, \
292 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
293 }, \
294 UACPI_OP_PROPERTY_TERM_ARG | \
295 UACPI_OP_PROPERTY_RESERVED \
296 )
297
298/*
299 * -------------------------------------------------------------
300 * RootChar := ‘\’
301 * ParentPrefixChar := ‘^’
302 * ‘\’ := 0x5C
303 * ‘^’ := 0x5E
304 * MultiNamePrefix := 0x2F
305 * DualNamePrefix := 0x2E
306 * ------------------------------------------------------------
307 * ‘A’-‘Z’ := 0x41 - 0x5A
308 * ‘_’ := 0x5F
309 * LeadNameChar := ‘A’-‘Z’ | ‘_’
310 * NameSeg := <leadnamechar namechar namechar namechar>
311 * NameString := <rootchar namepath> | <prefixpath namepath>
312 * PrefixPath := Nothing | <’^’ prefixpath>
313 * DualNamePath := DualNamePrefix NameSeg NameSeg
314 * MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount)
315 */
316#define UACPI_UNRESOLVED_NAME_STRING_OP(character, code) \
317 UACPI_OP( \
318 UACPI_InternalOpUnresolvedNameString_##character, code, \
319 { \
320 UACPI_PARSE_OP_AML_PC_DECREMENT, \
321 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL, \
322 UACPI_PARSE_OP_CONVERT_NAMESTRING, \
323 }, \
324 UACPI_OP_PROPERTY_SIMPLE_NAME | \
325 UACPI_OP_PROPERTY_SUPERNAME | \
326 UACPI_OP_PROPERTY_TERM_ARG \
327 )
328
329#define UACPI_BUILD_LOCAL_OR_ARG_OP(prefix, base, offset) \
330UACPI_OP( \
331 prefix##offset##Op, base + offset, \
332 { \
333 UACPI_PARSE_OP_EMPTY_OBJECT_ALLOC, \
334 UACPI_PARSE_OP_INVOKE_HANDLER, \
335 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
336 }, \
337 UACPI_OP_PROPERTY_SUPERNAME | \
338 UACPI_OP_PROPERTY_TERM_ARG | \
339 UACPI_OP_PROPERTY_SIMPLE_NAME \
340) \
341
342#define UACPI_LOCALX_OP(idx) UACPI_BUILD_LOCAL_OR_ARG_OP(Local, 0x60, idx)
343#define UACPI_ARGX_OP(idx) UACPI_BUILD_LOCAL_OR_ARG_OP(Arg, 0x68, idx)
344
345#define UACPI_BUILD_PACKAGE_OP(name, code, jmp_off, ...) \
346UACPI_OP( \
347 name##Op, code, \
348 { \
349 UACPI_PARSE_OP_TRACKED_PKGLEN, \
350 __VA_ARGS__ \
351 UACPI_PARSE_OP_IF_HAS_DATA, 4, \
352 UACPI_PARSE_OP_RECORD_AML_PC, \
353 UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT_OR_UNRESOLVED, \
354 UACPI_PARSE_OP_JMP, jmp_off, \
355 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_PACKAGE, \
356 UACPI_PARSE_OP_INVOKE_HANDLER, \
357 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
358 }, \
359 UACPI_OP_PROPERTY_TERM_ARG \
360)
361
362#define UACPI_BUILD_BINARY_MATH_OP(prefix, code) \
363UACPI_OP( \
364 prefix##Op, code, \
365 { \
366 UACPI_PARSE_OP_OPERAND, \
367 UACPI_PARSE_OP_OPERAND, \
368 UACPI_PARSE_OP_TARGET, \
369 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
370 UACPI_PARSE_OP_INVOKE_HANDLER, \
371 UACPI_PARSE_OP_TRUNCATE_NUMBER, \
372 UACPI_PARSE_OP_STORE_TO_TARGET, 2, \
373 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV, \
374 }, \
375 UACPI_OP_PROPERTY_TERM_ARG \
376)
377
378#define UACPI_BUILD_UNARY_MATH_OP(type, code) \
379UACPI_OP( \
380 type##Op, code, \
381 { \
382 UACPI_PARSE_OP_OPERAND, \
383 UACPI_PARSE_OP_TARGET, \
384 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
385 UACPI_PARSE_OP_INVOKE_HANDLER, \
386 UACPI_PARSE_OP_STORE_TO_TARGET, 1, \
387 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
388 }, \
389 UACPI_OP_PROPERTY_TERM_ARG \
390)
391
392#define UACPI_DO_BUILD_BUFFER_FIELD_OP(type, code, node_idx, ...) \
393UACPI_OP( \
394 type##FieldOp, code, \
395 { \
396 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
397 UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
398 UACPI_PARSE_OP_OPERAND, \
399 __VA_ARGS__ \
400 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
401 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, node_idx, \
402 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER_FIELD, \
403 UACPI_PARSE_OP_INVOKE_HANDLER, \
404 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, node_idx, \
405 } \
406)
407
408#define UACPI_BUILD_BUFFER_FIELD_OP(type, code) \
409 UACPI_DO_BUILD_BUFFER_FIELD_OP(Create##type, code, 2)
410
411#define UACPI_INTEGER_LITERAL_OP(type, code, bytes) \
412UACPI_OP( \
413 type##Prefix, code, \
414 { \
415 UACPI_PARSE_OP_LOAD_IMM_AS_OBJECT, bytes, \
416 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
417 }, \
418 UACPI_OP_PROPERTY_TERM_ARG \
419) \
420
421#define UACPI_BUILD_BINARY_LOGIC_OP(type, code) \
422UACPI_OP( \
423 type##Op, code, \
424 { \
425 UACPI_PARSE_OP_COMPUTATIONAL_DATA, \
426 UACPI_PARSE_OP_COMPUTATIONAL_DATA, \
427 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
428 UACPI_PARSE_OP_INVOKE_HANDLER, \
429 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
430 }, \
431 UACPI_OP_PROPERTY_TERM_ARG \
432)
433
434#define UACPI_BUILD_TO_OP(kind, code, dst_type) \
435UACPI_OP( \
436 To##kind##Op, code, \
437 { \
438 UACPI_PARSE_OP_COMPUTATIONAL_DATA, \
439 UACPI_PARSE_OP_TARGET, \
440 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, dst_type, \
441 UACPI_PARSE_OP_INVOKE_HANDLER, \
442 UACPI_PARSE_OP_STORE_TO_TARGET, 1, \
443 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
444 }, \
445 UACPI_OP_PROPERTY_TERM_ARG \
446)
447
448#define UACPI_BUILD_INC_DEC_OP(prefix, code) \
449UACPI_OP( \
450 prefix##Op, code, \
451 { \
452 UACPI_PARSE_OP_SUPERNAME, \
453 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
454 UACPI_PARSE_OP_INVOKE_HANDLER, \
455 UACPI_PARSE_OP_TRUNCATE_NUMBER, \
456 UACPI_PARSE_OP_STORE_TO_TARGET, 0, \
457 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
458 }, \
459 UACPI_OP_PROPERTY_TERM_ARG \
460) \
461
462#define UACPI_ENUMERATE_OPCODES \
463UACPI_OP( \
464 ZeroOp, 0x00, \
465 { \
466 UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT, \
467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
468 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
469 }, \
470 UACPI_OP_PROPERTY_TARGET | \
471 UACPI_OP_PROPERTY_TERM_ARG \
472) \
473UACPI_OP( \
474 OneOp, 0x01, \
475 { \
476 UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT, \
477 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
478 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
479 }, \
480 UACPI_OP_PROPERTY_TERM_ARG \
481) \
482UACPI_BAD_OPCODE(0x02) \
483UACPI_BAD_OPCODE(0x03) \
484UACPI_BAD_OPCODE(0x04) \
485UACPI_BAD_OPCODE(0x05) \
486UACPI_OP( \
487 AliasOp, 0x06, \
488 { \
489 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL_IF_LOAD, \
490 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
491 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
492 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 1, \
493 UACPI_PARSE_OP_INVOKE_HANDLER, \
494 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 1, \
495 } \
496) \
497UACPI_BAD_OPCODE(0x07) \
498UACPI_OP( \
499 NameOp, 0x08, \
500 { \
501 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
502 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
503 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
504 UACPI_PARSE_OP_OBJECT_CONVERT_TO_DEEP_COPY, \
505 UACPI_PARSE_OP_INVOKE_HANDLER, \
506 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 0, \
507 } \
508) \
509UACPI_BAD_OPCODE(0x09) \
510UACPI_INTEGER_LITERAL_OP(Byte, 0x0A, 1) \
511UACPI_INTEGER_LITERAL_OP(Word, 0x0B, 2) \
512UACPI_INTEGER_LITERAL_OP(DWord, 0x0C, 4) \
513UACPI_OP( \
514 StringPrefix, 0x0D, \
515 { \
516 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_STRING, \
517 UACPI_PARSE_OP_INVOKE_HANDLER, \
518 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
519 }, \
520 UACPI_OP_PROPERTY_TERM_ARG \
521) \
522UACPI_INTEGER_LITERAL_OP(QWord, 0x0E, 8) \
523UACPI_BAD_OPCODE(0x0F) \
524UACPI_OP( \
525 ScopeOp, 0x10, \
526 { \
527 UACPI_PARSE_OP_TRACKED_PKGLEN, \
528 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL_IF_LOAD, \
529 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 1, \
530 UACPI_PARSE_OP_INVOKE_HANDLER, \
531 } \
532) \
533UACPI_OP( \
534 BufferOp, 0x11, \
535 { \
536 UACPI_PARSE_OP_TRACKED_PKGLEN, \
537 UACPI_PARSE_OP_OPERAND, \
538 UACPI_PARSE_OP_RECORD_AML_PC, \
539 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER, \
540 UACPI_PARSE_OP_INVOKE_HANDLER, \
541 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
542 }, \
543 UACPI_OP_PROPERTY_TERM_ARG \
544) \
545UACPI_BUILD_PACKAGE_OP( \
546 Package, 0x12, 3, \
547 UACPI_PARSE_OP_LOAD_IMM, 1, \
548) \
549UACPI_BUILD_PACKAGE_OP( \
550 VarPackage, 0x13, 2, \
551 UACPI_PARSE_OP_OPERAND, \
552) \
553UACPI_OP( \
554 MethodOp, 0x14, \
555 { \
556 UACPI_PARSE_OP_TRACKED_PKGLEN, \
557 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
558 UACPI_PARSE_OP_LOAD_IMM, 1, \
559 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 1, \
560 UACPI_PARSE_OP_RECORD_AML_PC, \
561 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_METHOD, \
562 UACPI_PARSE_OP_INVOKE_HANDLER, \
563 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 1, \
564 } \
565) \
566UACPI_OP( \
567 ExternalOp, 0x15, \
568 { \
569 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL, \
570 UACPI_PARSE_OP_LOAD_IMM, 1, \
571 UACPI_PARSE_OP_LOAD_IMM, 1, \
572 } \
573) \
574UACPI_BAD_OPCODE(0x16) \
575UACPI_BAD_OPCODE(0x17) \
576UACPI_BAD_OPCODE(0x18) \
577UACPI_BAD_OPCODE(0x19) \
578UACPI_BAD_OPCODE(0x1A) \
579UACPI_BAD_OPCODE(0x1B) \
580UACPI_BAD_OPCODE(0x1C) \
581UACPI_BAD_OPCODE(0x1D) \
582UACPI_BAD_OPCODE(0x1E) \
583UACPI_BAD_OPCODE(0x1F) \
584UACPI_BAD_OPCODE(0x20) \
585UACPI_BAD_OPCODE(0x21) \
586UACPI_BAD_OPCODE(0x22) \
587UACPI_BAD_OPCODE(0x23) \
588UACPI_BAD_OPCODE(0x24) \
589UACPI_BAD_OPCODE(0x25) \
590UACPI_BAD_OPCODE(0x26) \
591UACPI_BAD_OPCODE(0x27) \
592UACPI_BAD_OPCODE(0x28) \
593UACPI_BAD_OPCODE(0x29) \
594UACPI_BAD_OPCODE(0x2A) \
595UACPI_BAD_OPCODE(0x2B) \
596UACPI_BAD_OPCODE(0x2C) \
597UACPI_BAD_OPCODE(0x2D) \
598UACPI_UNRESOLVED_NAME_STRING_OP(DualNamePrefix, 0x2E) \
599UACPI_UNRESOLVED_NAME_STRING_OP(MultiNamePrefix, 0x2F) \
600UACPI_INTERNAL_OP(0x30) \
601UACPI_INTERNAL_OP(0x31) \
602UACPI_INTERNAL_OP(0x32) \
603UACPI_INTERNAL_OP(0x33) \
604UACPI_INTERNAL_OP(0x34) \
605UACPI_INTERNAL_OP(0x35) \
606UACPI_INTERNAL_OP(0x36) \
607UACPI_INTERNAL_OP(0x37) \
608UACPI_INTERNAL_OP(0x38) \
609UACPI_INTERNAL_OP(0x39) \
610UACPI_BAD_OPCODE(0x3A) \
611UACPI_BAD_OPCODE(0x3B) \
612UACPI_BAD_OPCODE(0x3C) \
613UACPI_BAD_OPCODE(0x3D) \
614UACPI_BAD_OPCODE(0x3E) \
615UACPI_BAD_OPCODE(0x3F) \
616UACPI_BAD_OPCODE(0x40) \
617UACPI_UNRESOLVED_NAME_STRING_OP(A, 0x41) \
618UACPI_UNRESOLVED_NAME_STRING_OP(B, 0x42) \
619UACPI_UNRESOLVED_NAME_STRING_OP(C, 0x43) \
620UACPI_UNRESOLVED_NAME_STRING_OP(D, 0x44) \
621UACPI_UNRESOLVED_NAME_STRING_OP(E, 0x45) \
622UACPI_UNRESOLVED_NAME_STRING_OP(F, 0x46) \
623UACPI_UNRESOLVED_NAME_STRING_OP(G, 0x47) \
624UACPI_UNRESOLVED_NAME_STRING_OP(H, 0x48) \
625UACPI_UNRESOLVED_NAME_STRING_OP(I, 0x49) \
626UACPI_UNRESOLVED_NAME_STRING_OP(J, 0x4A) \
627UACPI_UNRESOLVED_NAME_STRING_OP(K, 0x4B) \
628UACPI_UNRESOLVED_NAME_STRING_OP(L, 0x4C) \
629UACPI_UNRESOLVED_NAME_STRING_OP(M, 0x4D) \
630UACPI_UNRESOLVED_NAME_STRING_OP(N, 0x4E) \
631UACPI_UNRESOLVED_NAME_STRING_OP(O, 0x4F) \
632UACPI_UNRESOLVED_NAME_STRING_OP(P, 0x50) \
633UACPI_UNRESOLVED_NAME_STRING_OP(Q, 0x51) \
634UACPI_UNRESOLVED_NAME_STRING_OP(R, 0x52) \
635UACPI_UNRESOLVED_NAME_STRING_OP(S, 0x53) \
636UACPI_UNRESOLVED_NAME_STRING_OP(T, 0x54) \
637UACPI_UNRESOLVED_NAME_STRING_OP(U, 0x55) \
638UACPI_UNRESOLVED_NAME_STRING_OP(V, 0x56) \
639UACPI_UNRESOLVED_NAME_STRING_OP(W, 0x57) \
640UACPI_UNRESOLVED_NAME_STRING_OP(X, 0x58) \
641UACPI_UNRESOLVED_NAME_STRING_OP(Y, 0x59) \
642UACPI_UNRESOLVED_NAME_STRING_OP(Z, 0x5A) \
643UACPI_INTERNAL_OP(0x5B) \
644UACPI_UNRESOLVED_NAME_STRING_OP(RootChar, 0x5C) \
645UACPI_BAD_OPCODE(0x5D) \
646UACPI_UNRESOLVED_NAME_STRING_OP(ParentPrefixChar, 0x5E) \
647UACPI_UNRESOLVED_NAME_STRING_OP(Underscore, 0x5F) \
648UACPI_LOCALX_OP(0) \
649UACPI_LOCALX_OP(1) \
650UACPI_LOCALX_OP(2) \
651UACPI_LOCALX_OP(3) \
652UACPI_LOCALX_OP(4) \
653UACPI_LOCALX_OP(5) \
654UACPI_LOCALX_OP(6) \
655UACPI_LOCALX_OP(7) \
656UACPI_ARGX_OP(0) \
657UACPI_ARGX_OP(1) \
658UACPI_ARGX_OP(2) \
659UACPI_ARGX_OP(3) \
660UACPI_ARGX_OP(4) \
661UACPI_ARGX_OP(5) \
662UACPI_ARGX_OP(6) \
663UACPI_BAD_OPCODE(0x6F) \
664UACPI_OP( \
665 StoreOp, 0x70, \
666 { \
667 UACPI_PARSE_OP_TERM_ARG, \
668 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV, \
669 UACPI_PARSE_OP_SUPERNAME, \
670 UACPI_PARSE_OP_INVOKE_HANDLER, \
671 }, \
672 UACPI_OP_PROPERTY_TERM_ARG \
673) \
674UACPI_OP( \
675 RefOfOp, 0x71, \
676 { \
677 UACPI_PARSE_OP_SUPERNAME, \
678 UACPI_PARSE_OP_OBJECT_ALLOC, \
679 UACPI_PARSE_OP_INVOKE_HANDLER, \
680 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
681 }, \
682 UACPI_OP_PROPERTY_TERM_ARG \
683) \
684UACPI_BUILD_BINARY_MATH_OP(Add, 0x72) \
685UACPI_OP( \
686 ConcatOp, 0x73, \
687 { \
688 UACPI_PARSE_OP_COMPUTATIONAL_DATA, \
689 UACPI_PARSE_OP_COMPUTATIONAL_DATA, \
690 UACPI_PARSE_OP_TARGET, \
691 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER, \
692 UACPI_PARSE_OP_INVOKE_HANDLER, \
693 UACPI_PARSE_OP_STORE_TO_TARGET, 2, \
694 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV, \
695 }, \
696 UACPI_OP_PROPERTY_TERM_ARG \
697) \
698UACPI_BUILD_BINARY_MATH_OP(Subtract, 0x74) \
699UACPI_BUILD_INC_DEC_OP(Increment, 0x75) \
700UACPI_BUILD_INC_DEC_OP(Decrement, 0x76) \
701UACPI_BUILD_BINARY_MATH_OP(Multiply, 0x77) \
702UACPI_OP( \
703 DivideOp, 0x78, \
704 { \
705 UACPI_PARSE_OP_OPERAND, \
706 UACPI_PARSE_OP_OPERAND, \
707 UACPI_PARSE_OP_TARGET, \
708 UACPI_PARSE_OP_TARGET, \
709 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
710 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
711 UACPI_PARSE_OP_INVOKE_HANDLER, \
712 UACPI_PARSE_OP_STORE_TO_TARGET, 3, \
713 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV, \
714 UACPI_PARSE_OP_STORE_TO_TARGET_INDIRECT, 2, 4, \
715 }, \
716 UACPI_OP_PROPERTY_TERM_ARG \
717) \
718UACPI_BUILD_BINARY_MATH_OP(ShiftLeft, 0x79) \
719UACPI_BUILD_BINARY_MATH_OP(ShiftRight, 0x7A) \
720UACPI_BUILD_BINARY_MATH_OP(And, 0x7B) \
721UACPI_BUILD_BINARY_MATH_OP(Nand, 0x7C) \
722UACPI_BUILD_BINARY_MATH_OP(Or, 0x7D) \
723UACPI_BUILD_BINARY_MATH_OP(Nor, 0x7E) \
724UACPI_BUILD_BINARY_MATH_OP(Xor, 0x7F) \
725UACPI_BUILD_UNARY_MATH_OP(Not, 0x80) \
726UACPI_BUILD_UNARY_MATH_OP(FindSetLeftBit, 0x81) \
727UACPI_BUILD_UNARY_MATH_OP(FindSetRightBit, 0x82) \
728UACPI_OP( \
729 DerefOfOp, 0x83, \
730 { \
731 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
732 UACPI_PARSE_OP_OBJECT_ALLOC, \
733 UACPI_PARSE_OP_INVOKE_HANDLER, \
734 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
735 }, \
736 UACPI_OP_PROPERTY_TERM_ARG \
737) \
738UACPI_OP( \
739 ConcatResOp, 0x84, \
740 { \
741 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
742 UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
743 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
744 UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
745 UACPI_PARSE_OP_TARGET, \
746 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER, \
747 UACPI_PARSE_OP_INVOKE_HANDLER, \
748 UACPI_PARSE_OP_STORE_TO_TARGET, 2, \
749 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
750 }, \
751 UACPI_OP_PROPERTY_TERM_ARG \
752) \
753UACPI_BUILD_BINARY_MATH_OP(Mod, 0x85) \
754UACPI_OP( \
755 NotifyOp, 0x86, \
756 { \
757 /* This is technically wrong according to spec but I was */ \
758 /* unable to find any examples of anything else after */ \
759 /* inspecting about 500 AML dumps. Spec says this is a */ \
760 /* SuperName that must evaluate to Device/ThermalZone or */ \
761 /* Processor, just ignore for now. */ \
762 UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL_IF_LOAD, \
763 UACPI_PARSE_OP_OPERAND, \
764 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
765 UACPI_PARSE_OP_INVOKE_HANDLER, \
766 } \
767) \
768UACPI_OP( \
769 SizeOfOp, 0x87, \
770 { \
771 UACPI_PARSE_OP_SUPERNAME, \
772 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
773 UACPI_PARSE_OP_INVOKE_HANDLER, \
774 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
775 }, \
776 UACPI_OP_PROPERTY_TERM_ARG \
777) \
778UACPI_OP( \
779 IndexOp, 0x88, \
780 { \
781 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
782 UACPI_PARSE_OP_OPERAND, \
783 UACPI_PARSE_OP_TARGET, \
784 UACPI_PARSE_OP_EMPTY_OBJECT_ALLOC, \
785 UACPI_PARSE_OP_INVOKE_HANDLER, \
786 UACPI_PARSE_OP_STORE_TO_TARGET, 2, \
787 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
788 }, \
789 UACPI_OP_PROPERTY_TERM_ARG | \
790 UACPI_OP_PROPERTY_SUPERNAME | \
791 UACPI_OP_PROPERTY_SIMPLE_NAME \
792) \
793UACPI_OP( \
794 MatchOp, 0x89, \
795 { \
796 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
797 UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_PACKAGE, \
798 UACPI_PARSE_OP_LOAD_IMM, 1, \
799 UACPI_PARSE_OP_OPERAND, \
800 UACPI_PARSE_OP_LOAD_IMM, 1, \
801 UACPI_PARSE_OP_OPERAND, \
802 UACPI_PARSE_OP_OPERAND, \
803 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
804 UACPI_PARSE_OP_INVOKE_HANDLER, \
805 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
806 }, \
807 UACPI_OP_PROPERTY_TERM_ARG \
808) \
809UACPI_BUILD_BUFFER_FIELD_OP(DWord, 0x8A) \
810UACPI_BUILD_BUFFER_FIELD_OP(Word, 0x8B) \
811UACPI_BUILD_BUFFER_FIELD_OP(Byte, 0x8C) \
812UACPI_BUILD_BUFFER_FIELD_OP(Bit, 0x8D) \
813UACPI_OP( \
814 ObjectTypeOp, 0x8E, \
815 { \
816 UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT, \
817 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
818 UACPI_PARSE_OP_INVOKE_HANDLER, \
819 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
820 }, \
821 UACPI_OP_PROPERTY_TERM_ARG \
822) \
823UACPI_BUILD_BUFFER_FIELD_OP(QWord, 0x8F) \
824UACPI_BUILD_BINARY_LOGIC_OP(Land, 0x90) \
825UACPI_BUILD_BINARY_LOGIC_OP(Lor, 0x91) \
826UACPI_OP( \
827 LnotOp, 0x92, \
828 { \
829 UACPI_PARSE_OP_OPERAND, \
830 UACPI_PARSE_OP_OBJECT_ALLOC, \
831 UACPI_PARSE_OP_INVOKE_HANDLER, \
832 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
833 }, \
834 UACPI_OP_PROPERTY_TERM_ARG \
835) \
836UACPI_BUILD_BINARY_LOGIC_OP(LEqual, 0x93) \
837UACPI_BUILD_BINARY_LOGIC_OP(LGreater, 0x94) \
838UACPI_BUILD_BINARY_LOGIC_OP(LLess, 0x95) \
839UACPI_BUILD_TO_OP(Buffer, 0x96, UACPI_OBJECT_BUFFER) \
840UACPI_BUILD_TO_OP(DecimalString, 0x97, UACPI_OBJECT_STRING) \
841UACPI_BUILD_TO_OP(HexString, 0x98, UACPI_OBJECT_STRING) \
842UACPI_BUILD_TO_OP(Integer, 0x99, UACPI_OBJECT_INTEGER) \
843UACPI_BAD_OPCODE(0x9A) \
844UACPI_BAD_OPCODE(0x9B) \
845UACPI_OP( \
846 ToStringOp, 0x9C, \
847 { \
848 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
849 UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
850 UACPI_PARSE_OP_OPERAND, \
851 UACPI_PARSE_OP_TARGET, \
852 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_STRING, \
853 UACPI_PARSE_OP_INVOKE_HANDLER, \
854 UACPI_PARSE_OP_STORE_TO_TARGET, 2, \
855 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
856 }, \
857 UACPI_OP_PROPERTY_TERM_ARG \
858) \
859UACPI_OP( \
860 CopyObjectOp, 0x9D, \
861 { \
862 UACPI_PARSE_OP_TERM_ARG, \
863 UACPI_PARSE_OP_OBJECT_COPY_TO_PREV, \
864 UACPI_PARSE_OP_SIMPLE_NAME, \
865 UACPI_PARSE_OP_INVOKE_HANDLER, \
866 }, \
867 UACPI_OP_PROPERTY_TERM_ARG \
868) \
869UACPI_OP( \
870 MidOp, 0x9E, \
871 { \
872 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
873 UACPI_PARSE_OP_OPERAND, \
874 UACPI_PARSE_OP_OPERAND, \
875 UACPI_PARSE_OP_TARGET, \
876 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER, \
877 UACPI_PARSE_OP_INVOKE_HANDLER, \
878 UACPI_PARSE_OP_STORE_TO_TARGET, 3, \
879 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
880 }, \
881 UACPI_OP_PROPERTY_TERM_ARG \
882) \
883UACPI_OP( \
884 ContinueOp, 0x9F, \
885 { \
886 UACPI_PARSE_OP_INVOKE_HANDLER, \
887 } \
888) \
889UACPI_OP( \
890 IfOp, 0xA0, \
891 { \
892 UACPI_PARSE_OP_PKGLEN, \
893 UACPI_PARSE_OP_OPERAND, \
894 UACPI_PARSE_OP_INVOKE_HANDLER, \
895 } \
896) \
897UACPI_OP( \
898 ElseOp, 0xA1, \
899 { \
900 UACPI_PARSE_OP_PKGLEN, \
901 UACPI_PARSE_OP_INVOKE_HANDLER, \
902 } \
903) \
904UACPI_OP( \
905 WhileOp, 0xA2, \
906 { \
907 UACPI_PARSE_OP_PKGLEN, \
908 UACPI_PARSE_OP_OPERAND, \
909 UACPI_PARSE_OP_INVOKE_HANDLER, \
910 } \
911) \
912UACPI_OP( \
913 NoopOp, 0xA3, \
914 { \
915 UACPI_PARSE_OP_END, \
916 } \
917) \
918UACPI_OP( \
919 ReturnOp, 0xA4, \
920 { \
921 UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
922 UACPI_PARSE_OP_INVOKE_HANDLER, \
923 } \
924) \
925UACPI_OP( \
926 BreakOp, 0xA5, \
927 { \
928 UACPI_PARSE_OP_INVOKE_HANDLER, \
929 } \
930) \
931UACPI_BAD_OPCODE(0xA6) \
932UACPI_BAD_OPCODE(0xA7) \
933UACPI_BAD_OPCODE(0xA8) \
934UACPI_BAD_OPCODE(0xA9) \
935UACPI_BAD_OPCODE(0xAA) \
936UACPI_BAD_OPCODE(0xAB) \
937UACPI_BAD_OPCODE(0xAC) \
938UACPI_BAD_OPCODE(0xAD) \
939UACPI_BAD_OPCODE(0xAE) \
940UACPI_BAD_OPCODE(0xAF) \
941UACPI_BAD_OPCODE(0xB0) \
942UACPI_BAD_OPCODE(0xB1) \
943UACPI_BAD_OPCODE(0xB2) \
944UACPI_BAD_OPCODE(0xB3) \
945UACPI_BAD_OPCODE(0xB4) \
946UACPI_BAD_OPCODE(0xB5) \
947UACPI_BAD_OPCODE(0xB6) \
948UACPI_BAD_OPCODE(0xB7) \
949UACPI_BAD_OPCODE(0xB8) \
950UACPI_BAD_OPCODE(0xB9) \
951UACPI_BAD_OPCODE(0xBA) \
952UACPI_BAD_OPCODE(0xBB) \
953UACPI_BAD_OPCODE(0xBC) \
954UACPI_BAD_OPCODE(0xBD) \
955UACPI_BAD_OPCODE(0xBE) \
956UACPI_BAD_OPCODE(0xBF) \
957UACPI_BAD_OPCODE(0xC0) \
958UACPI_BAD_OPCODE(0xC1) \
959UACPI_BAD_OPCODE(0xC2) \
960UACPI_BAD_OPCODE(0xC3) \
961UACPI_BAD_OPCODE(0xC4) \
962UACPI_BAD_OPCODE(0xC5) \
963UACPI_BAD_OPCODE(0xC6) \
964UACPI_BAD_OPCODE(0xC7) \
965UACPI_BAD_OPCODE(0xC8) \
966UACPI_BAD_OPCODE(0xC9) \
967UACPI_BAD_OPCODE(0xCA) \
968UACPI_BAD_OPCODE(0xCB) \
969UACPI_OP( \
970 BreakPointOp, 0xCC, \
971 { \
972 UACPI_PARSE_OP_INVOKE_HANDLER, \
973 } \
974) \
975UACPI_BAD_OPCODE(0xCD) \
976UACPI_BAD_OPCODE(0xCE) \
977UACPI_BAD_OPCODE(0xCF) \
978UACPI_BAD_OPCODE(0xD0) \
979UACPI_BAD_OPCODE(0xD1) \
980UACPI_BAD_OPCODE(0xD2) \
981UACPI_BAD_OPCODE(0xD3) \
982UACPI_BAD_OPCODE(0xD4) \
983UACPI_BAD_OPCODE(0xD5) \
984UACPI_BAD_OPCODE(0xD6) \
985UACPI_BAD_OPCODE(0xD7) \
986UACPI_BAD_OPCODE(0xD8) \
987UACPI_BAD_OPCODE(0xD9) \
988UACPI_BAD_OPCODE(0xDA) \
989UACPI_BAD_OPCODE(0xDB) \
990UACPI_BAD_OPCODE(0xDC) \
991UACPI_BAD_OPCODE(0xDD) \
992UACPI_BAD_OPCODE(0xDE) \
993UACPI_BAD_OPCODE(0xDF) \
994UACPI_BAD_OPCODE(0xE0) \
995UACPI_BAD_OPCODE(0xE1) \
996UACPI_BAD_OPCODE(0xE2) \
997UACPI_BAD_OPCODE(0xE3) \
998UACPI_BAD_OPCODE(0xE4) \
999UACPI_BAD_OPCODE(0xE5) \
1000UACPI_BAD_OPCODE(0xE6) \
1001UACPI_BAD_OPCODE(0xE7) \
1002UACPI_BAD_OPCODE(0xE8) \
1003UACPI_BAD_OPCODE(0xE9) \
1004UACPI_BAD_OPCODE(0xEA) \
1005UACPI_BAD_OPCODE(0xEB) \
1006UACPI_BAD_OPCODE(0xEC) \
1007UACPI_BAD_OPCODE(0xED) \
1008UACPI_BAD_OPCODE(0xEE) \
1009UACPI_BAD_OPCODE(0xEF) \
1010UACPI_BAD_OPCODE(0xF0) \
1011UACPI_BAD_OPCODE(0xF1) \
1012UACPI_BAD_OPCODE(0xF2) \
1013UACPI_BAD_OPCODE(0xF3) \
1014UACPI_OP( \
1015 InternalOpReadFieldAsBuffer, 0xF4, \
1016 { \
1017 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER, \
1018 UACPI_PARSE_OP_INVOKE_HANDLER, \
1019 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1020 }, \
1021 UACPI_OP_PROPERTY_TERM_ARG | \
1022 UACPI_OP_PROPERTY_RESERVED \
1023) \
1024UACPI_OP( \
1025 InternalOpReadFieldAsInteger, 0xF5, \
1026 { \
1027 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_INTEGER, \
1028 UACPI_PARSE_OP_INVOKE_HANDLER, \
1029 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1030 }, \
1031 UACPI_OP_PROPERTY_TERM_ARG | \
1032 UACPI_OP_PROPERTY_RESERVED \
1033) \
1034UACPI_OP( \
1035 InternalOpNamedObject, 0xF6, \
1036 { \
1037 UACPI_PARSE_OP_EMPTY_OBJECT_ALLOC, \
1038 UACPI_PARSE_OP_INVOKE_HANDLER, \
1039 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1040 }, \
1041 UACPI_OP_PROPERTY_SIMPLE_NAME | \
1042 UACPI_OP_PROPERTY_SUPERNAME | \
1043 UACPI_OP_PROPERTY_TERM_ARG | \
1044 UACPI_OP_PROPERTY_RESERVED \
1045) \
1046UACPI_METHOD_CALL_OPCODE(0) \
1047UACPI_METHOD_CALL_OPCODE(1) \
1048UACPI_METHOD_CALL_OPCODE(2) \
1049UACPI_METHOD_CALL_OPCODE(3) \
1050UACPI_METHOD_CALL_OPCODE(4) \
1051UACPI_METHOD_CALL_OPCODE(5) \
1052UACPI_METHOD_CALL_OPCODE(6) \
1053UACPI_METHOD_CALL_OPCODE(7) \
1054UACPI_OP( \
1055 OnesOp, 0xFF, \
1056 { \
1057 UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT, \
1058 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
1059 UACPI_PARSE_OP_TRUNCATE_NUMBER, \
1060 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1061 }, \
1062 UACPI_OP_PROPERTY_TERM_ARG \
1063)
1064
1065extern uacpi_u8 uacpi_field_op_decode_ops[];
1066extern uacpi_u8 uacpi_index_field_op_decode_ops[];
1067extern uacpi_u8 uacpi_bank_field_op_decode_ops[];
1068extern uacpi_u8 uacpi_load_op_decode_ops[];
1069extern uacpi_u8 uacpi_load_table_op_decode_ops[];
1070
1071#define UACPI_BUILD_NAMED_SCOPE_OBJECT_OP(name, code, type, ...) \
1072UACPI_OP( \
1073 name##Op, UACPI_EXT_OP(code), \
1074 { \
1075 UACPI_PARSE_OP_TRACKED_PKGLEN, \
1076 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
1077 __VA_ARGS__ \
1078 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 1, \
1079 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, type, \
1080 UACPI_PARSE_OP_INVOKE_HANDLER, \
1081 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 1, \
1082 } \
1083)
1084
1085#define UACPI_BUILD_TO_FROM_BCD(type, code) \
1086UACPI_OP( \
1087 type##BCDOp, UACPI_EXT_OP(code), \
1088 { \
1089 UACPI_PARSE_OP_OPERAND, \
1090 UACPI_PARSE_OP_TARGET, \
1091 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1092 UACPI_OBJECT_INTEGER, \
1093 UACPI_PARSE_OP_INVOKE_HANDLER, \
1094 UACPI_PARSE_OP_STORE_TO_TARGET, 1, \
1095 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1096 }, \
1097 UACPI_OP_PROPERTY_TERM_ARG \
1098)
1099
1100#define UACPI_ENUMERATE_EXT_OPCODES \
1101UACPI_OP( \
1102 ReservedExtOp, UACPI_EXT_OP(0x00), \
1103 { \
1104 UACPI_PARSE_OP_BAD_OPCODE, \
1105 } \
1106) \
1107UACPI_OP( \
1108 MutexOp, UACPI_EXT_OP(0x01), \
1109 { \
1110 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
1111 UACPI_PARSE_OP_LOAD_IMM, 1, \
1112 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
1113 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1114 UACPI_OBJECT_MUTEX, \
1115 UACPI_PARSE_OP_INVOKE_HANDLER, \
1116 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 0, \
1117 } \
1118) \
1119UACPI_OP( \
1120 EventOp, UACPI_EXT_OP(0x02), \
1121 { \
1122 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
1123 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
1124 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1125 UACPI_OBJECT_EVENT, \
1126 UACPI_PARSE_OP_INVOKE_HANDLER, \
1127 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 0, \
1128 } \
1129) \
1130UACPI_OP( \
1131 CondRefOfOp, UACPI_EXT_OP(0x12), \
1132 { \
1133 UACPI_PARSE_OP_SUPERNAME_OR_UNRESOLVED, \
1134 UACPI_PARSE_OP_TARGET, \
1135 UACPI_PARSE_OP_IF_NULL, 0, 3, \
1136 UACPI_PARSE_OP_LOAD_FALSE_OBJECT, \
1137 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1138 UACPI_PARSE_OP_END, \
1139 UACPI_PARSE_OP_OBJECT_ALLOC, \
1140 UACPI_PARSE_OP_INVOKE_HANDLER, \
1141 UACPI_PARSE_OP_STORE_TO_TARGET, 1, \
1142 UACPI_PARSE_OP_LOAD_TRUE_OBJECT, \
1143 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1144 }, \
1145 UACPI_OP_PROPERTY_TERM_ARG \
1146) \
1147UACPI_DO_BUILD_BUFFER_FIELD_OP( \
1148 Create, UACPI_EXT_OP(0x13), 3, \
1149 UACPI_PARSE_OP_OPERAND, \
1150) \
1151UACPI_OUT_OF_LINE_OP( \
1152 LoadTableOp, UACPI_EXT_OP(0x1F), \
1153 uacpi_load_table_op_decode_ops, \
1154 UACPI_OP_PROPERTY_TERM_ARG | \
1155 UACPI_OP_PROPERTY_OUT_OF_LINE \
1156) \
1157UACPI_OUT_OF_LINE_OP( \
1158 LoadOp, UACPI_EXT_OP(0x20), \
1159 uacpi_load_op_decode_ops, \
1160 UACPI_OP_PROPERTY_TERM_ARG | \
1161 UACPI_OP_PROPERTY_OUT_OF_LINE \
1162) \
1163UACPI_OP( \
1164 StallOp, UACPI_EXT_OP(0x21), \
1165 { \
1166 UACPI_PARSE_OP_OPERAND, \
1167 UACPI_PARSE_OP_INVOKE_HANDLER, \
1168 } \
1169) \
1170UACPI_OP( \
1171 SleepOp, UACPI_EXT_OP(0x22), \
1172 { \
1173 UACPI_PARSE_OP_OPERAND, \
1174 UACPI_PARSE_OP_INVOKE_HANDLER, \
1175 } \
1176) \
1177UACPI_OP( \
1178 AcquireOp, UACPI_EXT_OP(0x23), \
1179 { \
1180 UACPI_PARSE_OP_SUPERNAME, \
1181 UACPI_PARSE_OP_LOAD_IMM, 2, \
1182 UACPI_PARSE_OP_LOAD_TRUE_OBJECT, \
1183 UACPI_PARSE_OP_INVOKE_HANDLER, \
1184 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1185 }, \
1186 UACPI_OP_PROPERTY_TERM_ARG \
1187) \
1188UACPI_OP( \
1189 SignalOp, UACPI_EXT_OP(0x24), \
1190 { \
1191 UACPI_PARSE_OP_SUPERNAME, \
1192 UACPI_PARSE_OP_INVOKE_HANDLER, \
1193 } \
1194) \
1195UACPI_OP( \
1196 WaitOp, UACPI_EXT_OP(0x25), \
1197 { \
1198 UACPI_PARSE_OP_SUPERNAME, \
1199 UACPI_PARSE_OP_OPERAND, \
1200 UACPI_PARSE_OP_LOAD_TRUE_OBJECT, \
1201 UACPI_PARSE_OP_INVOKE_HANDLER, \
1202 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1203 }, \
1204 UACPI_OP_PROPERTY_TERM_ARG \
1205) \
1206UACPI_OP( \
1207 ResetOp, UACPI_EXT_OP(0x26), \
1208 { \
1209 UACPI_PARSE_OP_SUPERNAME, \
1210 UACPI_PARSE_OP_INVOKE_HANDLER, \
1211 } \
1212) \
1213UACPI_OP( \
1214 ReleaseOp, UACPI_EXT_OP(0x27), \
1215 { \
1216 UACPI_PARSE_OP_SUPERNAME, \
1217 UACPI_PARSE_OP_INVOKE_HANDLER, \
1218 } \
1219) \
1220UACPI_BUILD_TO_FROM_BCD(From, 0x28) \
1221UACPI_BUILD_TO_FROM_BCD(To, 0x29) \
1222UACPI_OP( \
1223 RevisionOp, UACPI_EXT_OP(0x30), \
1224 { \
1225 UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT, \
1226 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1227 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1228 }, \
1229 UACPI_OP_PROPERTY_TERM_ARG \
1230) \
1231UACPI_OP( \
1232 DebugOp, UACPI_EXT_OP(0x31), \
1233 { \
1234 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1235 UACPI_OBJECT_DEBUG, \
1236 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1237 }, \
1238 UACPI_OP_PROPERTY_TERM_ARG | \
1239 UACPI_OP_PROPERTY_SUPERNAME | \
1240 UACPI_OP_PROPERTY_TARGET \
1241) \
1242UACPI_OP( \
1243 FatalOp, UACPI_EXT_OP(0x32), \
1244 { \
1245 UACPI_PARSE_OP_LOAD_IMM, 1, \
1246 UACPI_PARSE_OP_LOAD_IMM, 4, \
1247 UACPI_PARSE_OP_OPERAND, \
1248 UACPI_PARSE_OP_INVOKE_HANDLER, \
1249 } \
1250) \
1251UACPI_OP( \
1252 TimerOp, UACPI_EXT_OP(0x33), \
1253 { \
1254 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1255 UACPI_OBJECT_INTEGER, \
1256 UACPI_PARSE_OP_INVOKE_HANDLER, \
1257 UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV, \
1258 }, \
1259 UACPI_OP_PROPERTY_TERM_ARG \
1260) \
1261UACPI_OP( \
1262 OpRegionOp, UACPI_EXT_OP(0x80), \
1263 { \
1264 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
1265 UACPI_PARSE_OP_LOAD_IMM, 1, \
1266 UACPI_PARSE_OP_OPERAND, \
1267 UACPI_PARSE_OP_OPERAND, \
1268 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
1269 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1270 UACPI_OBJECT_OPERATION_REGION, \
1271 UACPI_PARSE_OP_INVOKE_HANDLER, \
1272 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 0, \
1273 } \
1274) \
1275UACPI_OUT_OF_LINE_OP( \
1276 FieldOp, UACPI_EXT_OP(0x81), \
1277 uacpi_field_op_decode_ops, \
1278 UACPI_OP_PROPERTY_OUT_OF_LINE \
1279) \
1280UACPI_BUILD_NAMED_SCOPE_OBJECT_OP( \
1281 Device, 0x82, UACPI_OBJECT_DEVICE \
1282) \
1283UACPI_BUILD_NAMED_SCOPE_OBJECT_OP( \
1284 Processor, 0x83, UACPI_OBJECT_PROCESSOR, \
1285 UACPI_PARSE_OP_LOAD_IMM, 1, \
1286 UACPI_PARSE_OP_LOAD_IMM, 4, \
1287 UACPI_PARSE_OP_LOAD_IMM, 1, \
1288) \
1289UACPI_BUILD_NAMED_SCOPE_OBJECT_OP( \
1290 PowerRes, 0x84, UACPI_OBJECT_POWER_RESOURCE, \
1291 UACPI_PARSE_OP_LOAD_IMM, 1, \
1292 UACPI_PARSE_OP_LOAD_IMM, 2, \
1293) \
1294UACPI_BUILD_NAMED_SCOPE_OBJECT_OP( \
1295 ThermalZone, 0x85, UACPI_OBJECT_THERMAL_ZONE \
1296) \
1297UACPI_OUT_OF_LINE_OP( \
1298 IndexFieldOp, UACPI_EXT_OP(0x86), \
1299 uacpi_index_field_op_decode_ops, \
1300 UACPI_OP_PROPERTY_OUT_OF_LINE \
1301) \
1302UACPI_OUT_OF_LINE_OP( \
1303 BankFieldOp, UACPI_EXT_OP(0x87), \
1304 uacpi_bank_field_op_decode_ops, \
1305 UACPI_OP_PROPERTY_OUT_OF_LINE \
1306) \
1307UACPI_OP( \
1308 DataRegionOp, UACPI_EXT_OP(0x88), \
1309 { \
1310 UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
1311 UACPI_PARSE_OP_STRING, \
1312 UACPI_PARSE_OP_STRING, \
1313 UACPI_PARSE_OP_STRING, \
1314 UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, 0, \
1315 UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, \
1316 UACPI_OBJECT_OPERATION_REGION, \
1317 UACPI_PARSE_OP_INVOKE_HANDLER, \
1318 UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, 0, \
1319 } \
1320)
1321
1322enum uacpi_aml_op {
1323#define UACPI_OP(name, code, ...) UACPI_AML_OP_##name = code,
1324#define UACPI_OUT_OF_LINE_OP(name, code, ...) UACPI_AML_OP_##name = code,
1325 UACPI_ENUMERATE_OPCODES
1326 UACPI_ENUMERATE_EXT_OPCODES
1327#undef UACPI_OP
1328#undef UACPI_OUT_OF_LINE_OP
1329};
1330