aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/parser
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/acpi/parser
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/acpi/parser')
-rw-r--r--drivers/acpi/parser/Makefile8
-rw-r--r--drivers/acpi/parser/psargs.c746
-rw-r--r--drivers/acpi/parser/psopcode.c778
-rw-r--r--drivers/acpi/parser/psparse.c1266
-rw-r--r--drivers/acpi/parser/psscope.c290
-rw-r--r--drivers/acpi/parser/pstree.c327
-rw-r--r--drivers/acpi/parser/psutils.c309
-rw-r--r--drivers/acpi/parser/pswalk.c115
-rw-r--r--drivers/acpi/parser/psxface.c243
9 files changed, 4082 insertions, 0 deletions
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
new file mode 100644
index 000000000000..bbdd286c660d
--- /dev/null
+++ b/drivers/acpi/parser/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := psargs.o psparse.o pstree.o pswalk.o \
6 psopcode.o psscope.o psutils.o psxface.o
7
8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
new file mode 100644
index 000000000000..b5d98895f6a8
--- /dev/null
+++ b/drivers/acpi/parser/psargs.c
@@ -0,0 +1,746 @@
1/******************************************************************************
2 *
3 * Module Name: psargs - Parse AML opcode arguments
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h>
49
50#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psargs")
52
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ps_get_next_package_length
57 *
58 * PARAMETERS: parser_state - Current parser state object
59 *
60 * RETURN: Decoded package length. On completion, the AML pointer points
61 * past the length byte or bytes.
62 *
63 * DESCRIPTION: Decode and return a package length field
64 *
65 ******************************************************************************/
66
67u32
68acpi_ps_get_next_package_length (
69 struct acpi_parse_state *parser_state)
70{
71 u32 encoded_length;
72 u32 length = 0;
73
74
75 ACPI_FUNCTION_TRACE ("ps_get_next_package_length");
76
77
78 encoded_length = (u32) ACPI_GET8 (parser_state->aml);
79 parser_state->aml++;
80
81
82 switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ {
83 case 0: /* 1-byte encoding (bits 0-5) */
84
85 length = (encoded_length & 0x3F);
86 break;
87
88
89 case 1: /* 2-byte encoding (next byte + bits 0-3) */
90
91 length = ((ACPI_GET8 (parser_state->aml) << 04) |
92 (encoded_length & 0x0F));
93 parser_state->aml++;
94 break;
95
96
97 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
98
99 length = ((ACPI_GET8 (parser_state->aml + 1) << 12) |
100 (ACPI_GET8 (parser_state->aml) << 04) |
101 (encoded_length & 0x0F));
102 parser_state->aml += 2;
103 break;
104
105
106 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
107
108 length = ((ACPI_GET8 (parser_state->aml + 2) << 20) |
109 (ACPI_GET8 (parser_state->aml + 1) << 12) |
110 (ACPI_GET8 (parser_state->aml) << 04) |
111 (encoded_length & 0x0F));
112 parser_state->aml += 3;
113 break;
114
115 default:
116
117 /* Can't get here, only 2 bits / 4 cases */
118 break;
119 }
120
121 return_VALUE (length);
122}
123
124
125/*******************************************************************************
126 *
127 * FUNCTION: acpi_ps_get_next_package_end
128 *
129 * PARAMETERS: parser_state - Current parser state object
130 *
131 * RETURN: Pointer to end-of-package +1
132 *
133 * DESCRIPTION: Get next package length and return a pointer past the end of
134 * the package. Consumes the package length field
135 *
136 ******************************************************************************/
137
138u8 *
139acpi_ps_get_next_package_end (
140 struct acpi_parse_state *parser_state)
141{
142 u8 *start = parser_state->aml;
143 acpi_native_uint length;
144
145
146 ACPI_FUNCTION_TRACE ("ps_get_next_package_end");
147
148
149 /* Function below changes parser_state->Aml */
150
151 length = (acpi_native_uint) acpi_ps_get_next_package_length (parser_state);
152
153 return_PTR (start + length); /* end of package */
154}
155
156
157/*******************************************************************************
158 *
159 * FUNCTION: acpi_ps_get_next_namestring
160 *
161 * PARAMETERS: parser_state - Current parser state object
162 *
163 * RETURN: Pointer to the start of the name string (pointer points into
164 * the AML.
165 *
166 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
167 * prefix characters. Set parser state to point past the string.
168 * (Name is consumed from the AML.)
169 *
170 ******************************************************************************/
171
172char *
173acpi_ps_get_next_namestring (
174 struct acpi_parse_state *parser_state)
175{
176 u8 *start = parser_state->aml;
177 u8 *end = parser_state->aml;
178
179
180 ACPI_FUNCTION_TRACE ("ps_get_next_namestring");
181
182
183 /* Handle multiple prefix characters */
184
185 while (acpi_ps_is_prefix_char (ACPI_GET8 (end))) {
186 /* Include prefix '\\' or '^' */
187
188 end++;
189 }
190
191 /* Decode the path */
192
193 switch (ACPI_GET8 (end)) {
194 case 0:
195
196 /* null_name */
197
198 if (end == start) {
199 start = NULL;
200 }
201 end++;
202 break;
203
204 case AML_DUAL_NAME_PREFIX:
205
206 /* Two name segments */
207
208 end += 1 + (2 * ACPI_NAME_SIZE);
209 break;
210
211 case AML_MULTI_NAME_PREFIX_OP:
212
213 /* Multiple name segments, 4 chars each */
214
215 end += 2 + ((acpi_size) ACPI_GET8 (end + 1) * ACPI_NAME_SIZE);
216 break;
217
218 default:
219
220 /* Single name segment */
221
222 end += ACPI_NAME_SIZE;
223 break;
224 }
225
226 parser_state->aml = (u8*) end;
227 return_PTR ((char *) start);
228}
229
230
231/*******************************************************************************
232 *
233 * FUNCTION: acpi_ps_get_next_namepath
234 *
235 * PARAMETERS: parser_state - Current parser state object
236 * Arg - Where the namepath will be stored
237 * arg_count - If the namepath points to a control method
238 * the method's argument is returned here.
239 * method_call - Whether the namepath can possibly be the
240 * start of a method call
241 *
242 * RETURN: Status
243 *
244 * DESCRIPTION: Get next name (if method call, return # of required args).
245 * Names are looked up in the internal namespace to determine
246 * if the name represents a control method. If a method
247 * is found, the number of arguments to the method is returned.
248 * This information is critical for parsing to continue correctly.
249 *
250 ******************************************************************************/
251
252acpi_status
253acpi_ps_get_next_namepath (
254 struct acpi_walk_state *walk_state,
255 struct acpi_parse_state *parser_state,
256 union acpi_parse_object *arg,
257 u8 method_call)
258{
259 char *path;
260 union acpi_parse_object *name_op;
261 acpi_status status = AE_OK;
262 union acpi_operand_object *method_desc;
263 struct acpi_namespace_node *node;
264 union acpi_generic_state scope_info;
265
266
267 ACPI_FUNCTION_TRACE ("ps_get_next_namepath");
268
269
270 path = acpi_ps_get_next_namestring (parser_state);
271
272 /* Null path case is allowed */
273
274 if (path) {
275 /*
276 * Lookup the name in the internal namespace
277 */
278 scope_info.scope.node = NULL;
279 node = parser_state->start_node;
280 if (node) {
281 scope_info.scope.node = node;
282 }
283
284 /*
285 * Lookup object. We don't want to add anything new to the namespace
286 * here, however. So we use MODE_EXECUTE. Allow searching of the
287 * parent tree, but don't open a new scope -- we just want to lookup the
288 * object (MUST BE mode EXECUTE to perform upsearch)
289 */
290 status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
291 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
292 if (ACPI_SUCCESS (status) && method_call) {
293 if (node->type == ACPI_TYPE_METHOD) {
294 /*
295 * This name is actually a control method invocation
296 */
297 method_desc = acpi_ns_get_attached_object (node);
298 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
299 "Control Method - %p Desc %p Path=%p\n",
300 node, method_desc, path));
301
302 name_op = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
303 if (!name_op) {
304 return_ACPI_STATUS (AE_NO_MEMORY);
305 }
306
307 /* Change arg into a METHOD CALL and attach name to it */
308
309 acpi_ps_init_op (arg, AML_INT_METHODCALL_OP);
310 name_op->common.value.name = path;
311
312 /* Point METHODCALL/NAME to the METHOD Node */
313
314 name_op->common.node = node;
315 acpi_ps_append_arg (arg, name_op);
316
317 if (!method_desc) {
318 ACPI_REPORT_ERROR ((
319 "ps_get_next_namepath: Control Method %p has no attached object\n",
320 node));
321 return_ACPI_STATUS (AE_AML_INTERNAL);
322 }
323
324 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
325 "Control Method - %p Args %X\n",
326 node, method_desc->method.param_count));
327
328 /* Get the number of arguments to expect */
329
330 walk_state->arg_count = method_desc->method.param_count;
331 return_ACPI_STATUS (AE_OK);
332 }
333
334 /*
335 * Else this is normal named object reference.
336 * Just init the NAMEPATH object with the pathname.
337 * (See code below)
338 */
339 }
340
341 if (ACPI_FAILURE (status)) {
342 /*
343 * 1) Any error other than NOT_FOUND is always severe
344 * 2) NOT_FOUND is only important if we are executing a method.
345 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok.
346 */
347 if ((((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) &&
348 (status == AE_NOT_FOUND) &&
349 (walk_state->op->common.aml_opcode != AML_COND_REF_OF_OP)) ||
350
351 (status != AE_NOT_FOUND)) {
352 ACPI_REPORT_NSERROR (path, status);
353
354 acpi_os_printf ("search_node %p start_node %p return_node %p\n",
355 scope_info.scope.node, parser_state->start_node, node);
356
357
358 }
359 else {
360 /*
361 * We got a NOT_FOUND during table load or we encountered
362 * a cond_ref_of(x) where the target does not exist.
363 * -- either case is ok
364 */
365 status = AE_OK;
366 }
367 }
368 }
369
370 /*
371 * Regardless of success/failure above,
372 * Just initialize the Op with the pathname.
373 */
374 acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
375 arg->common.value.name = path;
376
377 return_ACPI_STATUS (status);
378}
379
380
381/*******************************************************************************
382 *
383 * FUNCTION: acpi_ps_get_next_simple_arg
384 *
385 * PARAMETERS: parser_state - Current parser state object
386 * arg_type - The argument type (AML_*_ARG)
387 * Arg - Where the argument is returned
388 *
389 * RETURN: None
390 *
391 * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
392 *
393 ******************************************************************************/
394
395void
396acpi_ps_get_next_simple_arg (
397 struct acpi_parse_state *parser_state,
398 u32 arg_type,
399 union acpi_parse_object *arg)
400{
401
402 ACPI_FUNCTION_TRACE_U32 ("ps_get_next_simple_arg", arg_type);
403
404
405 switch (arg_type) {
406 case ARGP_BYTEDATA:
407
408 acpi_ps_init_op (arg, AML_BYTE_OP);
409 arg->common.value.integer = (u32) ACPI_GET8 (parser_state->aml);
410 parser_state->aml++;
411 break;
412
413
414 case ARGP_WORDDATA:
415
416 acpi_ps_init_op (arg, AML_WORD_OP);
417
418 /* Get 2 bytes from the AML stream */
419
420 ACPI_MOVE_16_TO_32 (&arg->common.value.integer, parser_state->aml);
421 parser_state->aml += 2;
422 break;
423
424
425 case ARGP_DWORDDATA:
426
427 acpi_ps_init_op (arg, AML_DWORD_OP);
428
429 /* Get 4 bytes from the AML stream */
430
431 ACPI_MOVE_32_TO_32 (&arg->common.value.integer, parser_state->aml);
432 parser_state->aml += 4;
433 break;
434
435
436 case ARGP_QWORDDATA:
437
438 acpi_ps_init_op (arg, AML_QWORD_OP);
439
440 /* Get 8 bytes from the AML stream */
441
442 ACPI_MOVE_64_TO_64 (&arg->common.value.integer, parser_state->aml);
443 parser_state->aml += 8;
444 break;
445
446
447 case ARGP_CHARLIST:
448
449 acpi_ps_init_op (arg, AML_STRING_OP);
450 arg->common.value.string = (char *) parser_state->aml;
451
452 while (ACPI_GET8 (parser_state->aml) != '\0') {
453 parser_state->aml++;
454 }
455 parser_state->aml++;
456 break;
457
458
459 case ARGP_NAME:
460 case ARGP_NAMESTRING:
461
462 acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
463 arg->common.value.name = acpi_ps_get_next_namestring (parser_state);
464 break;
465
466
467 default:
468
469 ACPI_REPORT_ERROR (("Invalid arg_type %X\n", arg_type));
470 break;
471 }
472
473 return_VOID;
474}
475
476
477/*******************************************************************************
478 *
479 * FUNCTION: acpi_ps_get_next_field
480 *
481 * PARAMETERS: parser_state - Current parser state object
482 *
483 * RETURN: A newly allocated FIELD op
484 *
485 * DESCRIPTION: Get next field (named_field, reserved_field, or access_field)
486 *
487 ******************************************************************************/
488
489union acpi_parse_object *
490acpi_ps_get_next_field (
491 struct acpi_parse_state *parser_state)
492{
493 u32 aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
494 parser_state->aml_start);
495 union acpi_parse_object *field;
496 u16 opcode;
497 u32 name;
498
499
500 ACPI_FUNCTION_TRACE ("ps_get_next_field");
501
502
503 /* determine field type */
504
505 switch (ACPI_GET8 (parser_state->aml)) {
506 default:
507
508 opcode = AML_INT_NAMEDFIELD_OP;
509 break;
510
511 case 0x00:
512
513 opcode = AML_INT_RESERVEDFIELD_OP;
514 parser_state->aml++;
515 break;
516
517 case 0x01:
518
519 opcode = AML_INT_ACCESSFIELD_OP;
520 parser_state->aml++;
521 break;
522 }
523
524
525 /* Allocate a new field op */
526
527 field = acpi_ps_alloc_op (opcode);
528 if (!field) {
529 return_PTR (NULL);
530 }
531
532 field->common.aml_offset = aml_offset;
533
534 /* Decode the field type */
535
536 switch (opcode) {
537 case AML_INT_NAMEDFIELD_OP:
538
539 /* Get the 4-character name */
540
541 ACPI_MOVE_32_TO_32 (&name, parser_state->aml);
542 acpi_ps_set_name (field, name);
543 parser_state->aml += ACPI_NAME_SIZE;
544
545 /* Get the length which is encoded as a package length */
546
547 field->common.value.size = acpi_ps_get_next_package_length (parser_state);
548 break;
549
550
551 case AML_INT_RESERVEDFIELD_OP:
552
553 /* Get the length which is encoded as a package length */
554
555 field->common.value.size = acpi_ps_get_next_package_length (parser_state);
556 break;
557
558
559 case AML_INT_ACCESSFIELD_OP:
560
561 /*
562 * Get access_type and access_attrib and merge into the field Op
563 * access_type is first operand, access_attribute is second
564 */
565 field->common.value.integer = (ACPI_GET8 (parser_state->aml) << 8);
566 parser_state->aml++;
567 field->common.value.integer |= ACPI_GET8 (parser_state->aml);
568 parser_state->aml++;
569 break;
570
571 default:
572
573 /* Opcode was set in previous switch */
574 break;
575 }
576
577 return_PTR (field);
578}
579
580
581/*******************************************************************************
582 *
583 * FUNCTION: acpi_ps_get_next_arg
584 *
585 * PARAMETERS: parser_state - Current parser state object
586 * arg_type - The argument type (AML_*_ARG)
587 * arg_count - If the argument points to a control method
588 * the method's argument is returned here.
589 *
590 * RETURN: Status, and an op object containing the next argument.
591 *
592 * DESCRIPTION: Get next argument (including complex list arguments that require
593 * pushing the parser stack)
594 *
595 ******************************************************************************/
596
597acpi_status
598acpi_ps_get_next_arg (
599 struct acpi_walk_state *walk_state,
600 struct acpi_parse_state *parser_state,
601 u32 arg_type,
602 union acpi_parse_object **return_arg)
603{
604 union acpi_parse_object *arg = NULL;
605 union acpi_parse_object *prev = NULL;
606 union acpi_parse_object *field;
607 u32 subop;
608 acpi_status status = AE_OK;
609
610
611 ACPI_FUNCTION_TRACE_PTR ("ps_get_next_arg", parser_state);
612
613
614 switch (arg_type) {
615 case ARGP_BYTEDATA:
616 case ARGP_WORDDATA:
617 case ARGP_DWORDDATA:
618 case ARGP_CHARLIST:
619 case ARGP_NAME:
620 case ARGP_NAMESTRING:
621
622 /* constants, strings, and namestrings are all the same size */
623
624 arg = acpi_ps_alloc_op (AML_BYTE_OP);
625 if (!arg) {
626 return_ACPI_STATUS (AE_NO_MEMORY);
627 }
628 acpi_ps_get_next_simple_arg (parser_state, arg_type, arg);
629 break;
630
631
632 case ARGP_PKGLENGTH:
633
634 /* Package length, nothing returned */
635
636 parser_state->pkg_end = acpi_ps_get_next_package_end (parser_state);
637 break;
638
639
640 case ARGP_FIELDLIST:
641
642 if (parser_state->aml < parser_state->pkg_end) {
643 /* Non-empty list */
644
645 while (parser_state->aml < parser_state->pkg_end) {
646 field = acpi_ps_get_next_field (parser_state);
647 if (!field) {
648 return_ACPI_STATUS (AE_NO_MEMORY);
649 }
650
651 if (prev) {
652 prev->common.next = field;
653 }
654 else {
655 arg = field;
656 }
657
658 prev = field;
659 }
660
661 /* Skip to End of byte data */
662
663 parser_state->aml = parser_state->pkg_end;
664 }
665 break;
666
667
668 case ARGP_BYTELIST:
669
670 if (parser_state->aml < parser_state->pkg_end) {
671 /* Non-empty list */
672
673 arg = acpi_ps_alloc_op (AML_INT_BYTELIST_OP);
674 if (!arg) {
675 return_ACPI_STATUS (AE_NO_MEMORY);
676 }
677
678 /* Fill in bytelist data */
679
680 arg->common.value.size = (u32) ACPI_PTR_DIFF (parser_state->pkg_end,
681 parser_state->aml);
682 arg->named.data = parser_state->aml;
683
684 /* Skip to End of byte data */
685
686 parser_state->aml = parser_state->pkg_end;
687 }
688 break;
689
690
691 case ARGP_TARGET:
692 case ARGP_SUPERNAME:
693 case ARGP_SIMPLENAME:
694
695 subop = acpi_ps_peek_opcode (parser_state);
696 if (subop == 0 ||
697 acpi_ps_is_leading_char (subop) ||
698 acpi_ps_is_prefix_char (subop)) {
699 /* null_name or name_string */
700
701 arg = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
702 if (!arg) {
703 return_ACPI_STATUS (AE_NO_MEMORY);
704 }
705
706 status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0);
707 }
708 else {
709 /* single complex argument, nothing returned */
710
711 walk_state->arg_count = 1;
712 }
713 break;
714
715
716 case ARGP_DATAOBJ:
717 case ARGP_TERMARG:
718
719 /* single complex argument, nothing returned */
720
721 walk_state->arg_count = 1;
722 break;
723
724
725 case ARGP_DATAOBJLIST:
726 case ARGP_TERMLIST:
727 case ARGP_OBJLIST:
728
729 if (parser_state->aml < parser_state->pkg_end) {
730 /* non-empty list of variable arguments, nothing returned */
731
732 walk_state->arg_count = ACPI_VAR_ARGS;
733 }
734 break;
735
736
737 default:
738
739 ACPI_REPORT_ERROR (("Invalid arg_type: %X\n", arg_type));
740 status = AE_AML_OPERAND_TYPE;
741 break;
742 }
743
744 *return_arg = arg;
745 return_ACPI_STATUS (status);
746}
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
new file mode 100644
index 000000000000..03e33fedc11a
--- /dev/null
+++ b/drivers/acpi/parser/psopcode.c
@@ -0,0 +1,778 @@
1/******************************************************************************
2 *
3 * Module Name: psopcode - Parser/Interpreter opcode information table
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/amlcode.h>
48
49
50#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psopcode")
52
53
54#define _UNK 0x6B
55/*
56 * Reserved ASCII characters. Do not use any of these for
57 * internal opcodes, since they are used to differentiate
58 * name strings from AML opcodes
59 */
60#define _ASC 0x6C
61#define _NAM 0x6C
62#define _PFX 0x6D
63#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */
64
65#define MAX_EXTENDED_OPCODE 0x88
66#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
67#define MAX_INTERNAL_OPCODE
68#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
69
70
71/*******************************************************************************
72 *
73 * NAME: acpi_gbl_aml_op_info
74 *
75 * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
76 * The name is a simple ascii string, the operand specifier is an
77 * ascii string with one letter per operand. The letter specifies
78 * the operand type.
79 *
80 ******************************************************************************/
81
82
83/*
84 * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed
85 * into a 32-bit number and stored in the master opcode table at the end of this file.
86 */
87
88
89#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
90#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
91#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
92#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
93#define ARGP_ARG0 ARG_NONE
94#define ARGP_ARG1 ARG_NONE
95#define ARGP_ARG2 ARG_NONE
96#define ARGP_ARG3 ARG_NONE
97#define ARGP_ARG4 ARG_NONE
98#define ARGP_ARG5 ARG_NONE
99#define ARGP_ARG6 ARG_NONE
100#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
101#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
102#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
103#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
104#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
105#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
106#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
107#define ARGP_BREAK_OP ARG_NONE
108#define ARGP_BREAK_POINT_OP ARG_NONE
109#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
110#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
111#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
112#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
113#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
114#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
115#define ARGP_CONTINUE_OP ARG_NONE
116#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME)
117#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
118#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
119#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
120#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
121#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
122#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
123#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
124#define ARGP_DEBUG_OP ARG_NONE
125#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
126#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
127#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
128#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
129#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
130#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
131#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
132#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
133#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
134#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
135#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
136#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
137#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
138#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
139#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
140#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
141#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
142#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
143#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
144#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
145#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
146#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
147#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
148#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
149#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
150#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
151#define ARGP_LOCAL0 ARG_NONE
152#define ARGP_LOCAL1 ARG_NONE
153#define ARGP_LOCAL2 ARG_NONE
154#define ARGP_LOCAL3 ARG_NONE
155#define ARGP_LOCAL4 ARG_NONE
156#define ARGP_LOCAL5 ARG_NONE
157#define ARGP_LOCAL6 ARG_NONE
158#define ARGP_LOCAL7 ARG_NONE
159#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
160#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
161#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
162#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
163#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
164#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
165#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
166#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
167#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
168#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
169#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
170#define ARGP_NOOP_OP ARG_NONE
171#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
172#define ARGP_ONE_OP ARG_NONE
173#define ARGP_ONES_OP ARG_NONE
174#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
175#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
176#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
177#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
178#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
179#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
180#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
181#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
182#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
183#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
184#define ARGP_REVISION_OP ARG_NONE
185#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
186#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
187#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
188#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
189#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
190#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
191#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
192#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
193#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
194#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
195#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
196#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
197#define ARGP_TIMER_OP ARG_NONE
198#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
199#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
200#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
201#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
202#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
203#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
204#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
205#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
206#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
207#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
208#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
209#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
210#define ARGP_ZERO_OP ARG_NONE
211
212
213/*
214 * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed
215 * into a 32-bit number and stored in the master opcode table at the end of this file.
216 *
217 * (Used by prep_operands procedure and the ASL Compiler)
218 */
219
220
221#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
222#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
223#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
224#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
225#define ARGI_ARG0 ARG_NONE
226#define ARGI_ARG1 ARG_NONE
227#define ARGI_ARG2 ARG_NONE
228#define ARGI_ARG3 ARG_NONE
229#define ARGI_ARG4 ARG_NONE
230#define ARGI_ARG5 ARG_NONE
231#define ARGI_ARG6 ARG_NONE
232#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
233#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
234#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
235#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
236#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
237#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
238#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
239#define ARGI_BREAK_OP ARG_NONE
240#define ARGI_BREAK_POINT_OP ARG_NONE
241#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
242#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
243#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
244#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
245#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
246#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
247#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
248#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
249#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
250#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
251#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
252#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
253#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
254#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
255#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
256#define ARGI_DEBUG_OP ARG_NONE
257#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
258#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
259#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
260#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
261#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
262#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
263#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
264#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
265#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
266#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
267#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
268#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
269#define ARGI_IF_OP ARGI_INVALID_OPCODE
270#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
271#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
272#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
273#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
274#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
275#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
276#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
277#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
278#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
279#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
280#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
281#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF)
282#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
283#define ARGI_LOCAL0 ARG_NONE
284#define ARGI_LOCAL1 ARG_NONE
285#define ARGI_LOCAL2 ARG_NONE
286#define ARGI_LOCAL3 ARG_NONE
287#define ARGI_LOCAL4 ARG_NONE
288#define ARGI_LOCAL5 ARG_NONE
289#define ARGI_LOCAL6 ARG_NONE
290#define ARGI_LOCAL7 ARG_NONE
291#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
292#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
293#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
294#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
295#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
296#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
297#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
298#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
299#define ARGI_NAME_OP ARGI_INVALID_OPCODE
300#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
301#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
302#define ARGI_NOOP_OP ARG_NONE
303#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
304#define ARGI_ONE_OP ARG_NONE
305#define ARGI_ONES_OP ARG_NONE
306#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
307#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
308#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
309#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
310#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
311#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
312#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
313#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
314#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
315#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
316#define ARGI_REVISION_OP ARG_NONE
317#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
318#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
319#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
320#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
321#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
322#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
323#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
324#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
325#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
326#define ARGI_STRING_OP ARGI_INVALID_OPCODE
327#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
328#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
329#define ARGI_TIMER_OP ARG_NONE
330#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
331#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
332#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
333#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
334#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
335#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
336#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
337#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
338#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
339#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
340#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
341#define ARGI_WORD_OP ARGI_INVALID_OPCODE
342#define ARGI_ZERO_OP ARG_NONE
343
344
345/*
346 * Summary of opcode types/flags
347 */
348
349/******************************************************************************
350
351 Opcodes that have associated namespace objects (AML_NSOBJECT flag)
352
353 AML_SCOPE_OP
354 AML_DEVICE_OP
355 AML_THERMAL_ZONE_OP
356 AML_METHOD_OP
357 AML_POWER_RES_OP
358 AML_PROCESSOR_OP
359 AML_FIELD_OP
360 AML_INDEX_FIELD_OP
361 AML_BANK_FIELD_OP
362 AML_NAME_OP
363 AML_ALIAS_OP
364 AML_MUTEX_OP
365 AML_EVENT_OP
366 AML_REGION_OP
367 AML_CREATE_FIELD_OP
368 AML_CREATE_BIT_FIELD_OP
369 AML_CREATE_BYTE_FIELD_OP
370 AML_CREATE_WORD_FIELD_OP
371 AML_CREATE_DWORD_FIELD_OP
372 AML_CREATE_QWORD_FIELD_OP
373 AML_INT_NAMEDFIELD_OP
374 AML_INT_METHODCALL_OP
375 AML_INT_NAMEPATH_OP
376
377 Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
378
379 AML_SCOPE_OP
380 AML_DEVICE_OP
381 AML_THERMAL_ZONE_OP
382 AML_METHOD_OP
383 AML_POWER_RES_OP
384 AML_PROCESSOR_OP
385 AML_FIELD_OP
386 AML_INDEX_FIELD_OP
387 AML_BANK_FIELD_OP
388 AML_NAME_OP
389 AML_ALIAS_OP
390 AML_MUTEX_OP
391 AML_EVENT_OP
392 AML_REGION_OP
393 AML_INT_NAMEDFIELD_OP
394
395 Opcodes that have an associated namespace node (AML_NSNODE flag)
396
397 AML_SCOPE_OP
398 AML_DEVICE_OP
399 AML_THERMAL_ZONE_OP
400 AML_METHOD_OP
401 AML_POWER_RES_OP
402 AML_PROCESSOR_OP
403 AML_NAME_OP
404 AML_ALIAS_OP
405 AML_MUTEX_OP
406 AML_EVENT_OP
407 AML_REGION_OP
408 AML_CREATE_FIELD_OP
409 AML_CREATE_BIT_FIELD_OP
410 AML_CREATE_BYTE_FIELD_OP
411 AML_CREATE_WORD_FIELD_OP
412 AML_CREATE_DWORD_FIELD_OP
413 AML_CREATE_QWORD_FIELD_OP
414 AML_INT_NAMEDFIELD_OP
415 AML_INT_METHODCALL_OP
416 AML_INT_NAMEPATH_OP
417
418 Opcodes that define named ACPI objects (AML_NAMED flag)
419
420 AML_SCOPE_OP
421 AML_DEVICE_OP
422 AML_THERMAL_ZONE_OP
423 AML_METHOD_OP
424 AML_POWER_RES_OP
425 AML_PROCESSOR_OP
426 AML_NAME_OP
427 AML_ALIAS_OP
428 AML_MUTEX_OP
429 AML_EVENT_OP
430 AML_REGION_OP
431 AML_INT_NAMEDFIELD_OP
432
433 Opcodes that contain executable AML as part of the definition that
434 must be deferred until needed
435
436 AML_METHOD_OP
437 AML_VAR_PACKAGE_OP
438 AML_CREATE_FIELD_OP
439 AML_CREATE_BIT_FIELD_OP
440 AML_CREATE_BYTE_FIELD_OP
441 AML_CREATE_WORD_FIELD_OP
442 AML_CREATE_DWORD_FIELD_OP
443 AML_CREATE_QWORD_FIELD_OP
444 AML_REGION_OP
445 AML_BUFFER_OP
446
447 Field opcodes
448
449 AML_CREATE_FIELD_OP
450 AML_FIELD_OP
451 AML_INDEX_FIELD_OP
452 AML_BANK_FIELD_OP
453
454 Field "Create" opcodes
455
456 AML_CREATE_FIELD_OP
457 AML_CREATE_BIT_FIELD_OP
458 AML_CREATE_BYTE_FIELD_OP
459 AML_CREATE_WORD_FIELD_OP
460 AML_CREATE_DWORD_FIELD_OP
461 AML_CREATE_QWORD_FIELD_OP
462
463******************************************************************************/
464
465
466/*
467 * Master Opcode information table. A summary of everything we know about each opcode, all in one place.
468 */
469
470
471const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] =
472{
473/*! [Begin] no source code translation */
474/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */
475
476/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
477/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
478/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
479/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
480/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
481/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
482/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
483/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
484/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
485/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
486/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
487/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
488/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
489/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
490/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
491/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
492/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
493/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
494/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
495/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
496/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
497/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
498/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
499/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
500/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
501/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
502/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
503/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
504/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
505/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
506/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
507/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
508/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
509/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
510/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
511/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
512/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
513/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
514/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
515/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
516/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
517/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
518/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
519/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
520/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
521/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
522/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
523/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R),
524/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
525/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R),
526/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
527/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
528/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
529/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
530/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
531/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
532/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
533/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
534/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
535/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
536/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
537/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
538/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
539/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
540/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
541/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
542/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
543/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
544/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
545/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
546
547/* Prefixed opcodes (Two-byte opcodes with a prefix op) */
548
549/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
550/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
551/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
552/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
553/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R),
554/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
555/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
556/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
557/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
558/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
559/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
560/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
561/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
562/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
563/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
564/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
565/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
566/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R),
567/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
568/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
569/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
570/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
571/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
572/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
573/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
574/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
575
576/* Internal opcodes that map to invalid AML opcodes */
577
578/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
579/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
580/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
581/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ),
582/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
583/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0),
584/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
585/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
586/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
587/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
588/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL),
589/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS),
590/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS),
591/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS),
592
593/* ACPI 2.0 opcodes */
594
595/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
596/* 6F */ ACPI_OP ("Package /*Var*/", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER),
597/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
598/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
599/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
600/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
601/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
602/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
603/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
604/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
605/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
606/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
607/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
608/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R),
609/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
610/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
611
612/* ACPI 3.0 opcodes */
613
614/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R)
615
616/*! [End] no source code translation !*/
617};
618
619/*
620 * This table is directly indexed by the opcodes, and returns an
621 * index into the table above
622 */
623static const u8 acpi_gbl_short_op_index[256] =
624{
625/* 0 1 2 3 4 5 6 7 */
626/* 8 9 A B C D E F */
627/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
628/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
629/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
630/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
631/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
632/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
633/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
634/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
635/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
636/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
637/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
638/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
639/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
640/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
641/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
642/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
643/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
644/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
645/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
646/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
647/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
648/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
649/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
650/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
651/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
652/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
653/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
654/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
655/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
656/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
657/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
658/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
659};
660
661/*
662 * This table is indexed by the second opcode of the extended opcode
663 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
664 */
665static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
666{
667/* 0 1 2 3 4 5 6 7 */
668/* 8 9 A B C D E F */
669/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
670/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
671/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
672/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
673/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
674/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
675/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
676/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
677/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
678/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
679/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
680/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
681/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
682/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
683/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
684/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
685/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
686/* 0x88 */ 0x7C,
687};
688
689
690/*******************************************************************************
691 *
692 * FUNCTION: acpi_ps_get_opcode_info
693 *
694 * PARAMETERS: Opcode - The AML opcode
695 *
696 * RETURN: A pointer to the info about the opcode. NULL if the opcode was
697 * not found in the table.
698 *
699 * DESCRIPTION: Find AML opcode description based on the opcode.
700 * NOTE: This procedure must ALWAYS return a valid pointer!
701 *
702 ******************************************************************************/
703
704const struct acpi_opcode_info *
705acpi_ps_get_opcode_info (
706 u16 opcode)
707{
708 ACPI_FUNCTION_NAME ("ps_get_opcode_info");
709
710
711 /*
712 * Detect normal 8-bit opcode or extended 16-bit opcode
713 */
714 switch ((u8) (opcode >> 8)) {
715 case 0:
716
717 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
718
719 return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]);
720
721 case AML_EXTOP:
722
723 /* Extended (16-bit, prefix+opcode) opcode */
724
725 if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
726 return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
727 }
728
729 /* Else fall through to error case below */
730 /*lint -fallthrough */
731
732 default:
733
734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", opcode));
735 break;
736 }
737
738
739 /* Default is "unknown opcode" */
740
741 return (&acpi_gbl_aml_op_info [_UNK]);
742}
743
744
745/*******************************************************************************
746 *
747 * FUNCTION: acpi_ps_get_opcode_name
748 *
749 * PARAMETERS: Opcode - The AML opcode
750 *
751 * RETURN: A pointer to the name of the opcode (ASCII String)
752 * Note: Never returns NULL.
753 *
754 * DESCRIPTION: Translate an opcode into a human-readable string
755 *
756 ******************************************************************************/
757
758char *
759acpi_ps_get_opcode_name (
760 u16 opcode)
761{
762#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
763
764 const struct acpi_opcode_info *op;
765
766
767 op = acpi_ps_get_opcode_info (opcode);
768
769 /* Always guaranteed to return a valid pointer */
770
771 return (op->name);
772
773#else
774 return ("AE_NOT_CONFIGURED");
775
776#endif
777}
778
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
new file mode 100644
index 000000000000..e79edb53cb3b
--- /dev/null
+++ b/drivers/acpi/parser/psparse.c
@@ -0,0 +1,1266 @@
1/******************************************************************************
2 *
3 * Module Name: psparse - Parser top level AML parse routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45/*
46 * Parse the AML and build an operation tree as most interpreters,
47 * like Perl, do. Parsing is done by hand rather than with a YACC
48 * generated parser to tightly constrain stack and dynamic memory
49 * usage. At the same time, parsing is kept flexible and the code
50 * fairly compact by parsing based on a list of AML opcode
51 * templates in aml_op_info[]
52 */
53
54#include <acpi/acpi.h>
55#include <acpi/acparser.h>
56#include <acpi/acdispat.h>
57#include <acpi/amlcode.h>
58#include <acpi/acnamesp.h>
59#include <acpi/acinterp.h>
60
61#define _COMPONENT ACPI_PARSER
62 ACPI_MODULE_NAME ("psparse")
63
64
65static u32 acpi_gbl_depth = 0;
66
67
68/*******************************************************************************
69 *
70 * FUNCTION: acpi_ps_get_opcode_size
71 *
72 * PARAMETERS: Opcode - An AML opcode
73 *
74 * RETURN: Size of the opcode, in bytes (1 or 2)
75 *
76 * DESCRIPTION: Get the size of the current opcode.
77 *
78 ******************************************************************************/
79
80u32
81acpi_ps_get_opcode_size (
82 u32 opcode)
83{
84
85 /* Extended (2-byte) opcode if > 255 */
86
87 if (opcode > 0x00FF) {
88 return (2);
89 }
90
91 /* Otherwise, just a single byte opcode */
92
93 return (1);
94}
95
96
97/*******************************************************************************
98 *
99 * FUNCTION: acpi_ps_peek_opcode
100 *
101 * PARAMETERS: parser_state - A parser state object
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
106 *
107 ******************************************************************************/
108
109u16
110acpi_ps_peek_opcode (
111 struct acpi_parse_state *parser_state)
112{
113 u8 *aml;
114 u16 opcode;
115
116
117 aml = parser_state->aml;
118 opcode = (u16) ACPI_GET8 (aml);
119
120
121 if (opcode == AML_EXTOP) {
122 /* Extended opcode */
123
124 aml++;
125 opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml));
126 }
127
128 return (opcode);
129}
130
131
132/*******************************************************************************
133 *
134 * FUNCTION: acpi_ps_complete_this_op
135 *
136 * PARAMETERS: walk_state - Current State
137 * Op - Op to complete
138 *
139 * RETURN: None.
140 *
141 * DESCRIPTION: Perform any cleanup at the completion of an Op.
142 *
143 ******************************************************************************/
144
145void
146acpi_ps_complete_this_op (
147 struct acpi_walk_state *walk_state,
148 union acpi_parse_object *op)
149{
150 union acpi_parse_object *prev;
151 union acpi_parse_object *next;
152 const struct acpi_opcode_info *parent_info;
153 union acpi_parse_object *replacement_op = NULL;
154
155
156 ACPI_FUNCTION_TRACE_PTR ("ps_complete_this_op", op);
157
158
159 /* Check for null Op, can happen if AML code is corrupt */
160
161 if (!op) {
162 return_VOID;
163 }
164
165 /* Delete this op and the subtree below it if asked to */
166
167 if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
168 (walk_state->op_info->class == AML_CLASS_ARGUMENT)) {
169 return_VOID;
170 }
171
172 /* Make sure that we only delete this subtree */
173
174 if (op->common.parent) {
175 /*
176 * Check if we need to replace the operator and its subtree
177 * with a return value op (placeholder op)
178 */
179 parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
180
181 switch (parent_info->class) {
182 case AML_CLASS_CONTROL:
183 break;
184
185 case AML_CLASS_CREATE:
186
187 /*
188 * These opcodes contain term_arg operands. The current
189 * op must be replaced by a placeholder return op
190 */
191 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
192 if (!replacement_op) {
193 goto cleanup;
194 }
195 break;
196
197 case AML_CLASS_NAMED_OBJECT:
198
199 /*
200 * These opcodes contain term_arg operands. The current
201 * op must be replaced by a placeholder return op
202 */
203 if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
204 (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) ||
205 (op->common.parent->common.aml_opcode == AML_BUFFER_OP) ||
206 (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
207 (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
208 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
209 if (!replacement_op) {
210 goto cleanup;
211 }
212 }
213
214 if ((op->common.parent->common.aml_opcode == AML_NAME_OP) &&
215 (walk_state->descending_callback != acpi_ds_exec_begin_op)) {
216 if ((op->common.aml_opcode == AML_BUFFER_OP) ||
217 (op->common.aml_opcode == AML_PACKAGE_OP) ||
218 (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
219 replacement_op = acpi_ps_alloc_op (op->common.aml_opcode);
220 if (!replacement_op) {
221 goto cleanup;
222 }
223
224 replacement_op->named.data = op->named.data;
225 replacement_op->named.length = op->named.length;
226 }
227 }
228 break;
229
230 default:
231 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
232 if (!replacement_op) {
233 goto cleanup;
234 }
235 }
236
237 /* We must unlink this op from the parent tree */
238
239 prev = op->common.parent->common.value.arg;
240 if (prev == op) {
241 /* This op is the first in the list */
242
243 if (replacement_op) {
244 replacement_op->common.parent = op->common.parent;
245 replacement_op->common.value.arg = NULL;
246 replacement_op->common.node = op->common.node;
247 op->common.parent->common.value.arg = replacement_op;
248 replacement_op->common.next = op->common.next;
249 }
250 else {
251 op->common.parent->common.value.arg = op->common.next;
252 }
253 }
254
255 /* Search the parent list */
256
257 else while (prev) {
258 /* Traverse all siblings in the parent's argument list */
259
260 next = prev->common.next;
261 if (next == op) {
262 if (replacement_op) {
263 replacement_op->common.parent = op->common.parent;
264 replacement_op->common.value.arg = NULL;
265 replacement_op->common.node = op->common.node;
266 prev->common.next = replacement_op;
267 replacement_op->common.next = op->common.next;
268 next = NULL;
269 }
270 else {
271 prev->common.next = op->common.next;
272 next = NULL;
273 }
274 }
275
276 prev = next;
277 }
278 }
279
280
281cleanup:
282
283 /* Now we can actually delete the subtree rooted at op */
284
285 acpi_ps_delete_parse_tree (op);
286 return_VOID;
287}
288
289
290/*******************************************************************************
291 *
292 * FUNCTION: acpi_ps_next_parse_state
293 *
294 * PARAMETERS: parser_state - Current parser state object
295 *
296 * RETURN: Status
297 *
298 * DESCRIPTION: Update the parser state based upon the return exception from
299 * the parser callback.
300 *
301 ******************************************************************************/
302
303acpi_status
304acpi_ps_next_parse_state (
305 struct acpi_walk_state *walk_state,
306 union acpi_parse_object *op,
307 acpi_status callback_status)
308{
309 struct acpi_parse_state *parser_state = &walk_state->parser_state;
310 acpi_status status = AE_CTRL_PENDING;
311
312
313 ACPI_FUNCTION_TRACE_PTR ("ps_next_parse_state", op);
314
315
316 switch (callback_status) {
317 case AE_CTRL_TERMINATE:
318
319 /*
320 * A control method was terminated via a RETURN statement.
321 * The walk of this method is complete.
322 */
323 parser_state->aml = parser_state->aml_end;
324 status = AE_CTRL_TERMINATE;
325 break;
326
327
328 case AE_CTRL_BREAK:
329
330 parser_state->aml = walk_state->aml_last_while;
331 walk_state->control_state->common.value = FALSE;
332 status = AE_CTRL_BREAK;
333 break;
334
335 case AE_CTRL_CONTINUE:
336
337
338 parser_state->aml = walk_state->aml_last_while;
339 status = AE_CTRL_CONTINUE;
340 break;
341
342 case AE_CTRL_PENDING:
343
344 parser_state->aml = walk_state->aml_last_while;
345 break;
346
347#if 0
348 case AE_CTRL_SKIP:
349
350 parser_state->aml = parser_state->scope->parse_scope.pkg_end;
351 status = AE_OK;
352 break;
353#endif
354
355 case AE_CTRL_TRUE:
356
357 /*
358 * Predicate of an IF was true, and we are at the matching ELSE.
359 * Just close out this package
360 */
361 parser_state->aml = acpi_ps_get_next_package_end (parser_state);
362 break;
363
364
365 case AE_CTRL_FALSE:
366
367 /*
368 * Either an IF/WHILE Predicate was false or we encountered a BREAK
369 * opcode. In both cases, we do not execute the rest of the
370 * package; We simply close out the parent (finishing the walk of
371 * this branch of the tree) and continue execution at the parent
372 * level.
373 */
374 parser_state->aml = parser_state->scope->parse_scope.pkg_end;
375
376 /* In the case of a BREAK, just force a predicate (if any) to FALSE */
377
378 walk_state->control_state->common.value = FALSE;
379 status = AE_CTRL_END;
380 break;
381
382
383 case AE_CTRL_TRANSFER:
384
385 /*
386 * A method call (invocation) -- transfer control
387 */
388 status = AE_CTRL_TRANSFER;
389 walk_state->prev_op = op;
390 walk_state->method_call_op = op;
391 walk_state->method_call_node = (op->common.value.arg)->common.node;
392
393 /* Will return value (if any) be used by the caller? */
394
395 walk_state->return_used = acpi_ds_is_result_used (op, walk_state);
396 break;
397
398
399 default:
400 status = callback_status;
401 if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) {
402 status = AE_OK;
403 }
404 break;
405 }
406
407 return_ACPI_STATUS (status);
408}
409
410
411/*******************************************************************************
412 *
413 * FUNCTION: acpi_ps_parse_loop
414 *
415 * PARAMETERS: parser_state - Current parser state object
416 *
417 * RETURN: Status
418 *
419 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
420 * a tree of ops.
421 *
422 ******************************************************************************/
423
424acpi_status
425acpi_ps_parse_loop (
426 struct acpi_walk_state *walk_state)
427{
428 acpi_status status = AE_OK;
429 union acpi_parse_object *op = NULL; /* current op */
430 union acpi_parse_object *arg = NULL;
431 union acpi_parse_object *pre_op = NULL;
432 struct acpi_parse_state *parser_state;
433 u8 *aml_op_start = NULL;
434
435
436 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state);
437
438 if (walk_state->descending_callback == NULL) {
439 return_ACPI_STATUS (AE_BAD_PARAMETER);
440 }
441
442 parser_state = &walk_state->parser_state;
443 walk_state->arg_types = 0;
444
445#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
446 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
447 /* We are restarting a preempted control method */
448
449 if (acpi_ps_has_completed_scope (parser_state)) {
450 /*
451 * We must check if a predicate to an IF or WHILE statement
452 * was just completed
453 */
454 if ((parser_state->scope->parse_scope.op) &&
455 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) ||
456 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) &&
457 (walk_state->control_state) &&
458 (walk_state->control_state->common.state ==
459 ACPI_CONTROL_PREDICATE_EXECUTING)) {
460 /*
461 * A predicate was just completed, get the value of the
462 * predicate and branch based on that value
463 */
464 walk_state->op = NULL;
465 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
466 if (ACPI_FAILURE (status) &&
467 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
468 if (status == AE_AML_NO_RETURN_VALUE) {
469 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
470 "Invoked method did not return a value, %s\n",
471 acpi_format_exception (status)));
472
473 }
474 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "get_predicate Failed, %s\n",
475 acpi_format_exception (status)));
476 return_ACPI_STATUS (status);
477 }
478
479 status = acpi_ps_next_parse_state (walk_state, op, status);
480 }
481
482 acpi_ps_pop_scope (parser_state, &op,
483 &walk_state->arg_types, &walk_state->arg_count);
484 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
485 }
486 else if (walk_state->prev_op) {
487 /* We were in the middle of an op */
488
489 op = walk_state->prev_op;
490 walk_state->arg_types = walk_state->prev_arg_types;
491 }
492 }
493#endif
494
495 /*
496 * Iterative parsing loop, while there is more aml to process:
497 */
498 while ((parser_state->aml < parser_state->aml_end) || (op)) {
499 aml_op_start = parser_state->aml;
500 if (!op) {
501 /* Get the next opcode from the AML stream */
502
503 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
504 parser_state->aml_start);
505 walk_state->opcode = acpi_ps_peek_opcode (parser_state);
506
507 /*
508 * First cut to determine what we have found:
509 * 1) A valid AML opcode
510 * 2) A name string
511 * 3) An unknown/invalid opcode
512 */
513 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
514 switch (walk_state->op_info->class) {
515 case AML_CLASS_ASCII:
516 case AML_CLASS_PREFIX:
517 /*
518 * Starts with a valid prefix or ASCII char, this is a name
519 * string. Convert the bare name string to a namepath.
520 */
521 walk_state->opcode = AML_INT_NAMEPATH_OP;
522 walk_state->arg_types = ARGP_NAMESTRING;
523 break;
524
525 case AML_CLASS_UNKNOWN:
526
527 /* The opcode is unrecognized. Just skip unknown opcodes */
528
529 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
530 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
531 walk_state->opcode, parser_state->aml, walk_state->aml_offset));
532
533 ACPI_DUMP_BUFFER (parser_state->aml, 128);
534
535 /* Assume one-byte bad opcode */
536
537 parser_state->aml++;
538 continue;
539
540 default:
541
542 /* Found opcode info, this is a normal opcode */
543
544 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode);
545 walk_state->arg_types = walk_state->op_info->parse_args;
546 break;
547 }
548
549 /* Create Op structure and append to parent's argument list */
550
551 if (walk_state->op_info->flags & AML_NAMED) {
552 /* Allocate a new pre_op if necessary */
553
554 if (!pre_op) {
555 pre_op = acpi_ps_alloc_op (walk_state->opcode);
556 if (!pre_op) {
557 status = AE_NO_MEMORY;
558 goto close_this_op;
559 }
560 }
561
562 pre_op->common.value.arg = NULL;
563 pre_op->common.aml_opcode = walk_state->opcode;
564
565 /*
566 * Get and append arguments until we find the node that contains
567 * the name (the type ARGP_NAME).
568 */
569 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
570 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) {
571 status = acpi_ps_get_next_arg (walk_state, parser_state,
572 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
573 if (ACPI_FAILURE (status)) {
574 goto close_this_op;
575 }
576
577 acpi_ps_append_arg (pre_op, arg);
578 INCREMENT_ARG_LIST (walk_state->arg_types);
579 }
580
581 /* Make sure that we found a NAME and didn't run out of arguments */
582
583 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
584 status = AE_AML_NO_OPERAND;
585 goto close_this_op;
586 }
587
588 /* We know that this arg is a name, move to next arg */
589
590 INCREMENT_ARG_LIST (walk_state->arg_types);
591
592 /*
593 * Find the object. This will either insert the object into
594 * the namespace or simply look it up
595 */
596 walk_state->op = NULL;
597
598 status = walk_state->descending_callback (walk_state, &op);
599 if (ACPI_FAILURE (status)) {
600 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
601 acpi_format_exception (status)));
602 goto close_this_op;
603 }
604
605 if (op == NULL) {
606 continue;
607 }
608
609 status = acpi_ps_next_parse_state (walk_state, op, status);
610 if (status == AE_CTRL_PENDING) {
611 status = AE_OK;
612 goto close_this_op;
613 }
614
615 if (ACPI_FAILURE (status)) {
616 goto close_this_op;
617 }
618
619 acpi_ps_append_arg (op, pre_op->common.value.arg);
620 acpi_gbl_depth++;
621
622 if (op->common.aml_opcode == AML_REGION_OP) {
623 /*
624 * Defer final parsing of an operation_region body,
625 * because we don't have enough info in the first pass
626 * to parse it correctly (i.e., there may be method
627 * calls within the term_arg elements of the body.)
628 *
629 * However, we must continue parsing because
630 * the opregion is not a standalone package --
631 * we don't know where the end is at this point.
632 *
633 * (Length is unknown until parse of the body complete)
634 */
635 op->named.data = aml_op_start;
636 op->named.length = 0;
637 }
638 }
639 else {
640 /* Not a named opcode, just allocate Op and append to parent */
641
642 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
643 op = acpi_ps_alloc_op (walk_state->opcode);
644 if (!op) {
645 status = AE_NO_MEMORY;
646 goto close_this_op;
647 }
648
649 if (walk_state->op_info->flags & AML_CREATE) {
650 /*
651 * Backup to beginning of create_xXXfield declaration
652 * body_length is unknown until we parse the body
653 */
654 op->named.data = aml_op_start;
655 op->named.length = 0;
656 }
657
658 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op);
659
660 if ((walk_state->descending_callback != NULL)) {
661 /*
662 * Find the object. This will either insert the object into
663 * the namespace or simply look it up
664 */
665 walk_state->op = op;
666
667 status = walk_state->descending_callback (walk_state, &op);
668 status = acpi_ps_next_parse_state (walk_state, op, status);
669 if (status == AE_CTRL_PENDING) {
670 status = AE_OK;
671 goto close_this_op;
672 }
673
674 if (ACPI_FAILURE (status)) {
675 goto close_this_op;
676 }
677 }
678 }
679
680 op->common.aml_offset = walk_state->aml_offset;
681
682 if (walk_state->op_info) {
683 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
684 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
685 (u32) op->common.aml_opcode, walk_state->op_info->name,
686 op, parser_state->aml, op->common.aml_offset));
687 }
688 }
689
690
691 /* Start arg_count at zero because we don't know if there are any args yet */
692
693 walk_state->arg_count = 0;
694
695 if (walk_state->arg_types) /* Are there any arguments that must be processed? */ {
696 /* Get arguments */
697
698 switch (op->common.aml_opcode) {
699 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
700 case AML_WORD_OP: /* AML_WORDDATA_ARG */
701 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
702 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
703 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
704
705 /* Fill in constant or string argument directly */
706
707 acpi_ps_get_next_simple_arg (parser_state,
708 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
709 break;
710
711 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
712
713 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1);
714 if (ACPI_FAILURE (status)) {
715 goto close_this_op;
716 }
717
718 walk_state->arg_types = 0;
719 break;
720
721 default:
722
723 /* Op is not a constant or string, append each argument to the Op */
724
725 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
726 !walk_state->arg_count) {
727 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
728 parser_state->aml_start);
729 status = acpi_ps_get_next_arg (walk_state, parser_state,
730 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
731 if (ACPI_FAILURE (status)) {
732 goto close_this_op;
733 }
734
735 if (arg) {
736 arg->common.aml_offset = walk_state->aml_offset;
737 acpi_ps_append_arg (op, arg);
738 }
739 INCREMENT_ARG_LIST (walk_state->arg_types);
740 }
741
742 /* Special processing for certain opcodes */
743
744 switch (op->common.aml_opcode) {
745 case AML_METHOD_OP:
746
747 /*
748 * Skip parsing of control method
749 * because we don't have enough info in the first pass
750 * to parse it correctly.
751 *
752 * Save the length and address of the body
753 */
754 op->named.data = parser_state->aml;
755 op->named.length = (u32) (parser_state->pkg_end - parser_state->aml);
756
757 /* Skip body of method */
758
759 parser_state->aml = parser_state->pkg_end;
760 walk_state->arg_count = 0;
761 break;
762
763 case AML_BUFFER_OP:
764 case AML_PACKAGE_OP:
765 case AML_VAR_PACKAGE_OP:
766
767 if ((op->common.parent) &&
768 (op->common.parent->common.aml_opcode == AML_NAME_OP) &&
769 (walk_state->descending_callback != acpi_ds_exec_begin_op)) {
770 /*
771 * Skip parsing of Buffers and Packages
772 * because we don't have enough info in the first pass
773 * to parse them correctly.
774 */
775 op->named.data = aml_op_start;
776 op->named.length = (u32) (parser_state->pkg_end - aml_op_start);
777
778 /* Skip body */
779
780 parser_state->aml = parser_state->pkg_end;
781 walk_state->arg_count = 0;
782 }
783 break;
784
785 case AML_WHILE_OP:
786
787 if (walk_state->control_state) {
788 walk_state->control_state->control.package_end = parser_state->pkg_end;
789 }
790 break;
791
792 default:
793
794 /* No action for all other opcodes */
795 break;
796 }
797 break;
798 }
799 }
800
801 /* Check for arguments that need to be processed */
802
803 if (walk_state->arg_count) {
804 /* There are arguments (complex ones), push Op and prepare for argument */
805
806 status = acpi_ps_push_scope (parser_state, op,
807 walk_state->arg_types, walk_state->arg_count);
808 if (ACPI_FAILURE (status)) {
809 goto close_this_op;
810 }
811 op = NULL;
812 continue;
813 }
814
815 /* All arguments have been processed -- Op is complete, prepare for next */
816
817 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
818 if (walk_state->op_info->flags & AML_NAMED) {
819 if (acpi_gbl_depth) {
820 acpi_gbl_depth--;
821 }
822
823 if (op->common.aml_opcode == AML_REGION_OP) {
824 /*
825 * Skip parsing of control method or opregion body,
826 * because we don't have enough info in the first pass
827 * to parse them correctly.
828 *
829 * Completed parsing an op_region declaration, we now
830 * know the length.
831 */
832 op->named.length = (u32) (parser_state->aml - op->named.data);
833 }
834 }
835
836 if (walk_state->op_info->flags & AML_CREATE) {
837 /*
838 * Backup to beginning of create_xXXfield declaration (1 for
839 * Opcode)
840 *
841 * body_length is unknown until we parse the body
842 */
843 op->named.length = (u32) (parser_state->aml - op->named.data);
844 }
845
846 /* This op complete, notify the dispatcher */
847
848 if (walk_state->ascending_callback != NULL) {
849 walk_state->op = op;
850 walk_state->opcode = op->common.aml_opcode;
851
852 status = walk_state->ascending_callback (walk_state);
853 status = acpi_ps_next_parse_state (walk_state, op, status);
854 if (status == AE_CTRL_PENDING) {
855 status = AE_OK;
856 goto close_this_op;
857 }
858 }
859
860
861close_this_op:
862 /*
863 * Finished one argument of the containing scope
864 */
865 parser_state->scope->parse_scope.arg_count--;
866
867 /* Close this Op (will result in parse subtree deletion) */
868
869 acpi_ps_complete_this_op (walk_state, op);
870 op = NULL;
871 if (pre_op) {
872 acpi_ps_free_op (pre_op);
873 pre_op = NULL;
874 }
875
876 switch (status) {
877 case AE_OK:
878 break;
879
880
881 case AE_CTRL_TRANSFER:
882
883 /*
884 * We are about to transfer to a called method.
885 */
886 walk_state->prev_op = op;
887 walk_state->prev_arg_types = walk_state->arg_types;
888 return_ACPI_STATUS (status);
889
890
891 case AE_CTRL_END:
892
893 acpi_ps_pop_scope (parser_state, &op,
894 &walk_state->arg_types, &walk_state->arg_count);
895
896 if (op) {
897 walk_state->op = op;
898 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
899 walk_state->opcode = op->common.aml_opcode;
900
901 status = walk_state->ascending_callback (walk_state);
902 status = acpi_ps_next_parse_state (walk_state, op, status);
903
904 acpi_ps_complete_this_op (walk_state, op);
905 op = NULL;
906 }
907 status = AE_OK;
908 break;
909
910
911 case AE_CTRL_BREAK:
912 case AE_CTRL_CONTINUE:
913
914 /* Pop off scopes until we find the While */
915
916 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
917 acpi_ps_pop_scope (parser_state, &op,
918 &walk_state->arg_types, &walk_state->arg_count);
919 }
920
921 /* Close this iteration of the While loop */
922
923 walk_state->op = op;
924 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
925 walk_state->opcode = op->common.aml_opcode;
926
927 status = walk_state->ascending_callback (walk_state);
928 status = acpi_ps_next_parse_state (walk_state, op, status);
929
930 acpi_ps_complete_this_op (walk_state, op);
931 op = NULL;
932
933 status = AE_OK;
934 break;
935
936
937 case AE_CTRL_TERMINATE:
938
939 status = AE_OK;
940
941 /* Clean up */
942 do {
943 if (op) {
944 acpi_ps_complete_this_op (walk_state, op);
945 }
946 acpi_ps_pop_scope (parser_state, &op,
947 &walk_state->arg_types, &walk_state->arg_count);
948
949 } while (op);
950
951 return_ACPI_STATUS (status);
952
953
954 default: /* All other non-AE_OK status */
955
956 do {
957 if (op) {
958 acpi_ps_complete_this_op (walk_state, op);
959 }
960 acpi_ps_pop_scope (parser_state, &op,
961 &walk_state->arg_types, &walk_state->arg_count);
962
963 } while (op);
964
965
966 /*
967 * TBD: Cleanup parse ops on error
968 */
969#if 0
970 if (op == NULL) {
971 acpi_ps_pop_scope (parser_state, &op,
972 &walk_state->arg_types, &walk_state->arg_count);
973 }
974#endif
975 walk_state->prev_op = op;
976 walk_state->prev_arg_types = walk_state->arg_types;
977 return_ACPI_STATUS (status);
978 }
979
980 /* This scope complete? */
981
982 if (acpi_ps_has_completed_scope (parser_state)) {
983 acpi_ps_pop_scope (parser_state, &op,
984 &walk_state->arg_types, &walk_state->arg_count);
985 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
986 }
987 else {
988 op = NULL;
989 }
990
991 } /* while parser_state->Aml */
992
993
994 /*
995 * Complete the last Op (if not completed), and clear the scope stack.
996 * It is easily possible to end an AML "package" with an unbounded number
997 * of open scopes (such as when several ASL blocks are closed with
998 * sequential closing braces). We want to terminate each one cleanly.
999 */
1000 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op));
1001 do {
1002 if (op) {
1003 if (walk_state->ascending_callback != NULL) {
1004 walk_state->op = op;
1005 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
1006 walk_state->opcode = op->common.aml_opcode;
1007
1008 status = walk_state->ascending_callback (walk_state);
1009 status = acpi_ps_next_parse_state (walk_state, op, status);
1010 if (status == AE_CTRL_PENDING) {
1011 status = AE_OK;
1012 goto close_this_op;
1013 }
1014
1015 if (status == AE_CTRL_TERMINATE) {
1016 status = AE_OK;
1017
1018 /* Clean up */
1019 do {
1020 if (op) {
1021 acpi_ps_complete_this_op (walk_state, op);
1022 }
1023
1024 acpi_ps_pop_scope (parser_state, &op,
1025 &walk_state->arg_types, &walk_state->arg_count);
1026
1027 } while (op);
1028
1029 return_ACPI_STATUS (status);
1030 }
1031
1032 else if (ACPI_FAILURE (status)) {
1033 acpi_ps_complete_this_op (walk_state, op);
1034 return_ACPI_STATUS (status);
1035 }
1036 }
1037
1038 acpi_ps_complete_this_op (walk_state, op);
1039 }
1040
1041 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types,
1042 &walk_state->arg_count);
1043
1044 } while (op);
1045
1046 return_ACPI_STATUS (status);
1047}
1048
1049
1050/*******************************************************************************
1051 *
1052 * FUNCTION: acpi_ps_parse_aml
1053 *
1054 * PARAMETERS: start_scope - The starting point of the parse. Becomes the
1055 * root of the parsed op tree.
1056 * Aml - Pointer to the raw AML code to parse
1057 * aml_size - Length of the AML to parse
1058 *
1059 *
1060 * RETURN: Status
1061 *
1062 * DESCRIPTION: Parse raw AML and return a tree of ops
1063 *
1064 ******************************************************************************/
1065
1066acpi_status
1067acpi_ps_parse_aml (
1068 struct acpi_walk_state *walk_state)
1069{
1070 acpi_status status;
1071 acpi_status terminate_status;
1072 struct acpi_thread_state *thread;
1073 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list;
1074 struct acpi_walk_state *previous_walk_state;
1075
1076
1077 ACPI_FUNCTION_TRACE ("ps_parse_aml");
1078
1079 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with walk_state=%p Aml=%p size=%X\n",
1080 walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size));
1081
1082
1083 /* Create and initialize a new thread state */
1084
1085 thread = acpi_ut_create_thread_state ();
1086 if (!thread) {
1087 return_ACPI_STATUS (AE_NO_MEMORY);
1088 }
1089
1090 walk_state->thread = thread;
1091 acpi_ds_push_walk_state (walk_state, thread);
1092
1093 /*
1094 * This global allows the AML debugger to get a handle to the currently
1095 * executing control method.
1096 */
1097 acpi_gbl_current_walk_list = thread;
1098
1099 /*
1100 * Execute the walk loop as long as there is a valid Walk State. This
1101 * handles nested control method invocations without recursion.
1102 */
1103 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", walk_state));
1104
1105 status = AE_OK;
1106 while (walk_state) {
1107 if (ACPI_SUCCESS (status)) {
1108 /*
1109 * The parse_loop executes AML until the method terminates
1110 * or calls another method.
1111 */
1112 status = acpi_ps_parse_loop (walk_state);
1113 }
1114
1115 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1116 "Completed one call to walk loop, %s State=%p\n",
1117 acpi_format_exception (status), walk_state));
1118
1119 if (status == AE_CTRL_TRANSFER) {
1120 /*
1121 * A method call was detected.
1122 * Transfer control to the called control method
1123 */
1124 status = acpi_ds_call_control_method (thread, walk_state, NULL);
1125
1126 /*
1127 * If the transfer to the new method method call worked, a new walk
1128 * state was created -- get it
1129 */
1130 walk_state = acpi_ds_get_current_walk_state (thread);
1131 continue;
1132 }
1133 else if (status == AE_CTRL_TERMINATE) {
1134 status = AE_OK;
1135 }
1136 else if ((status != AE_OK) && (walk_state->method_desc)) {
1137 ACPI_REPORT_METHOD_ERROR ("Method execution failed",
1138 walk_state->method_node, NULL, status);
1139
1140 /* Check for possible multi-thread reentrancy problem */
1141
1142 if ((status == AE_ALREADY_EXISTS) &&
1143 (!walk_state->method_desc->method.semaphore)) {
1144 /*
1145 * This method is marked not_serialized, but it tried to create a named
1146 * object, causing the second thread entrance to fail. We will workaround
1147 * this by marking the method permanently as Serialized.
1148 */
1149 walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED;
1150 walk_state->method_desc->method.concurrency = 1;
1151 }
1152 }
1153
1154 if (walk_state->method_desc) {
1155 /* Decrement the thread count on the method parse tree */
1156
1157 if (walk_state->method_desc->method.thread_count) {
1158 walk_state->method_desc->method.thread_count--;
1159 }
1160 }
1161
1162 /* We are done with this walk, move on to the parent if any */
1163
1164 walk_state = acpi_ds_pop_walk_state (thread);
1165
1166 /* Reset the current scope to the beginning of scope stack */
1167
1168 acpi_ds_scope_stack_clear (walk_state);
1169
1170 /*
1171 * If we just returned from the execution of a control method,
1172 * there's lots of cleanup to do
1173 */
1174 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) {
1175 terminate_status = acpi_ds_terminate_control_method (walk_state);
1176 if (ACPI_FAILURE (terminate_status)) {
1177 ACPI_REPORT_ERROR ((
1178 "Could not terminate control method properly\n"));
1179
1180 /* Ignore error and continue */
1181 }
1182 }
1183
1184 /* Delete this walk state and all linked control states */
1185
1186 acpi_ps_cleanup_scope (&walk_state->parser_state);
1187
1188 previous_walk_state = walk_state;
1189
1190 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "return_value=%p, implicit_value=%p State=%p\n",
1191 walk_state->return_desc, walk_state->implicit_return_obj, walk_state));
1192
1193 /* Check if we have restarted a preempted walk */
1194
1195 walk_state = acpi_ds_get_current_walk_state (thread);
1196 if (walk_state) {
1197 if (ACPI_SUCCESS (status)) {
1198 /*
1199 * There is another walk state, restart it.
1200 * If the method return value is not used by the parent,
1201 * The object is deleted
1202 */
1203 if (!previous_walk_state->return_desc) {
1204 status = acpi_ds_restart_control_method (walk_state,
1205 previous_walk_state->implicit_return_obj);
1206 }
1207 else {
1208 /*
1209 * We have a valid return value, delete any implicit
1210 * return value.
1211 */
1212 acpi_ds_clear_implicit_return (previous_walk_state);
1213
1214 status = acpi_ds_restart_control_method (walk_state,
1215 previous_walk_state->return_desc);
1216 }
1217 if (ACPI_SUCCESS (status)) {
1218 walk_state->walk_type |= ACPI_WALK_METHOD_RESTART;
1219 }
1220 }
1221 else {
1222 /* On error, delete any return object */
1223
1224 acpi_ut_remove_reference (previous_walk_state->return_desc);
1225 }
1226 }
1227
1228 /*
1229 * Just completed a 1st-level method, save the final internal return
1230 * value (if any)
1231 */
1232 else if (previous_walk_state->caller_return_desc) {
1233 if (previous_walk_state->implicit_return_obj) {
1234 *(previous_walk_state->caller_return_desc) = previous_walk_state->implicit_return_obj;
1235 }
1236 else {
1237 /* NULL if no return value */
1238
1239 *(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc;
1240 }
1241 }
1242 else {
1243 if (previous_walk_state->return_desc) {
1244 /* Caller doesn't want it, must delete it */
1245
1246 acpi_ut_remove_reference (previous_walk_state->return_desc);
1247 }
1248 if (previous_walk_state->implicit_return_obj) {
1249 /* Caller doesn't want it, must delete it */
1250
1251 acpi_ut_remove_reference (previous_walk_state->implicit_return_obj);
1252 }
1253 }
1254
1255 acpi_ds_delete_walk_state (previous_walk_state);
1256 }
1257
1258 /* Normal exit */
1259
1260 acpi_ex_release_all_mutexes (thread);
1261 acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread));
1262 acpi_gbl_current_walk_list = prev_walk_list;
1263 return_ACPI_STATUS (status);
1264}
1265
1266
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
new file mode 100644
index 000000000000..dcbed49608b0
--- /dev/null
+++ b/drivers/acpi/parser/psscope.c
@@ -0,0 +1,290 @@
1/******************************************************************************
2 *
3 * Module Name: psscope - Parser scope stack management routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47
48#define _COMPONENT ACPI_PARSER
49 ACPI_MODULE_NAME ("psscope")
50
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_ps_get_parent_scope
55 *
56 * PARAMETERS: parser_state - Current parser state object
57 *
58 * RETURN: Pointer to an Op object
59 *
60 * DESCRIPTION: Get parent of current op being parsed
61 *
62 ******************************************************************************/
63
64union acpi_parse_object *
65acpi_ps_get_parent_scope (
66 struct acpi_parse_state *parser_state)
67{
68 return (parser_state->scope->parse_scope.op);
69}
70
71
72/*******************************************************************************
73 *
74 * FUNCTION: acpi_ps_has_completed_scope
75 *
76 * PARAMETERS: parser_state - Current parser state object
77 *
78 * RETURN: Boolean, TRUE = scope completed.
79 *
80 * DESCRIPTION: Is parsing of current argument complete? Determined by
81 * 1) AML pointer is at or beyond the end of the scope
82 * 2) The scope argument count has reached zero.
83 *
84 ******************************************************************************/
85
86u8
87acpi_ps_has_completed_scope (
88 struct acpi_parse_state *parser_state)
89{
90 return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end ||
91 !parser_state->scope->parse_scope.arg_count)));
92}
93
94
95/*******************************************************************************
96 *
97 * FUNCTION: acpi_ps_init_scope
98 *
99 * PARAMETERS: parser_state - Current parser state object
100 * Root - the Root Node of this new scope
101 *
102 * RETURN: Status
103 *
104 * DESCRIPTION: Allocate and init a new scope object
105 *
106 ******************************************************************************/
107
108acpi_status
109acpi_ps_init_scope (
110 struct acpi_parse_state *parser_state,
111 union acpi_parse_object *root_op)
112{
113 union acpi_generic_state *scope;
114
115
116 ACPI_FUNCTION_TRACE_PTR ("ps_init_scope", root_op);
117
118
119 scope = acpi_ut_create_generic_state ();
120 if (!scope) {
121 return_ACPI_STATUS (AE_NO_MEMORY);
122 }
123
124 scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE;
125 scope->parse_scope.op = root_op;
126 scope->parse_scope.arg_count = ACPI_VAR_ARGS;
127 scope->parse_scope.arg_end = parser_state->aml_end;
128 scope->parse_scope.pkg_end = parser_state->aml_end;
129
130 parser_state->scope = scope;
131 parser_state->start_op = root_op;
132
133 return_ACPI_STATUS (AE_OK);
134}
135
136
137/*******************************************************************************
138 *
139 * FUNCTION: acpi_ps_push_scope
140 *
141 * PARAMETERS: parser_state - Current parser state object
142 * Op - Current op to be pushed
143 * remaining_args - List of args remaining
144 * arg_count - Fixed or variable number of args
145 *
146 * RETURN: Status
147 *
148 * DESCRIPTION: Push current op to begin parsing its argument
149 *
150 ******************************************************************************/
151
152acpi_status
153acpi_ps_push_scope (
154 struct acpi_parse_state *parser_state,
155 union acpi_parse_object *op,
156 u32 remaining_args,
157 u32 arg_count)
158{
159 union acpi_generic_state *scope;
160
161
162 ACPI_FUNCTION_TRACE_PTR ("ps_push_scope", op);
163
164
165 scope = acpi_ut_create_generic_state ();
166 if (!scope) {
167 return_ACPI_STATUS (AE_NO_MEMORY);
168 }
169
170 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE;
171 scope->parse_scope.op = op;
172 scope->parse_scope.arg_list = remaining_args;
173 scope->parse_scope.arg_count = arg_count;
174 scope->parse_scope.pkg_end = parser_state->pkg_end;
175
176 /* Push onto scope stack */
177
178 acpi_ut_push_generic_state (&parser_state->scope, scope);
179
180 if (arg_count == ACPI_VAR_ARGS) {
181 /* multiple arguments */
182
183 scope->parse_scope.arg_end = parser_state->pkg_end;
184 }
185 else {
186 /* single argument */
187
188 scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR);
189 }
190
191 return_ACPI_STATUS (AE_OK);
192}
193
194
195/*******************************************************************************
196 *
197 * FUNCTION: acpi_ps_pop_scope
198 *
199 * PARAMETERS: parser_state - Current parser state object
200 * Op - Where the popped op is returned
201 * arg_list - Where the popped "next argument" is
202 * returned
203 * arg_count - Count of objects in arg_list
204 *
205 * RETURN: Status
206 *
207 * DESCRIPTION: Return to parsing a previous op
208 *
209 ******************************************************************************/
210
211void
212acpi_ps_pop_scope (
213 struct acpi_parse_state *parser_state,
214 union acpi_parse_object **op,
215 u32 *arg_list,
216 u32 *arg_count)
217{
218 union acpi_generic_state *scope = parser_state->scope;
219
220
221 ACPI_FUNCTION_TRACE ("ps_pop_scope");
222
223
224 /*
225 * Only pop the scope if there is in fact a next scope
226 */
227 if (scope->common.next) {
228 scope = acpi_ut_pop_generic_state (&parser_state->scope);
229
230 /* return to parsing previous op */
231
232 *op = scope->parse_scope.op;
233 *arg_list = scope->parse_scope.arg_list;
234 *arg_count = scope->parse_scope.arg_count;
235 parser_state->pkg_end = scope->parse_scope.pkg_end;
236
237 /* All done with this scope state structure */
238
239 acpi_ut_delete_generic_state (scope);
240 }
241 else {
242 /* empty parse stack, prepare to fetch next opcode */
243
244 *op = NULL;
245 *arg_list = 0;
246 *arg_count = 0;
247 }
248
249 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *op, *arg_count));
250 return_VOID;
251}
252
253
254/*******************************************************************************
255 *
256 * FUNCTION: acpi_ps_cleanup_scope
257 *
258 * PARAMETERS: parser_state - Current parser state object
259 *
260 * RETURN: Status
261 *
262 * DESCRIPTION: Destroy available list, remaining stack levels, and return
263 * root scope
264 *
265 ******************************************************************************/
266
267void
268acpi_ps_cleanup_scope (
269 struct acpi_parse_state *parser_state)
270{
271 union acpi_generic_state *scope;
272
273
274 ACPI_FUNCTION_TRACE_PTR ("ps_cleanup_scope", parser_state);
275
276
277 if (!parser_state) {
278 return_VOID;
279 }
280
281 /* Delete anything on the scope stack */
282
283 while (parser_state->scope) {
284 scope = acpi_ut_pop_generic_state (&parser_state->scope);
285 acpi_ut_delete_generic_state (scope);
286 }
287
288 return_VOID;
289}
290
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
new file mode 100644
index 000000000000..2140bd1ac10b
--- /dev/null
+++ b/drivers/acpi/parser/pstree.c
@@ -0,0 +1,327 @@
1/******************************************************************************
2 *
3 * Module Name: pstree - Parser op tree manipulation/traversal/search
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/amlcode.h>
48
49#define _COMPONENT ACPI_PARSER
50 ACPI_MODULE_NAME ("pstree")
51
52
53/*******************************************************************************
54 *
55 * FUNCTION: acpi_ps_get_arg
56 *
57 * PARAMETERS: Op - Get an argument for this op
58 * Argn - Nth argument to get
59 *
60 * RETURN: The argument (as an Op object). NULL if argument does not exist
61 *
62 * DESCRIPTION: Get the specified op's argument.
63 *
64 ******************************************************************************/
65
66union acpi_parse_object *
67acpi_ps_get_arg (
68 union acpi_parse_object *op,
69 u32 argn)
70{
71 union acpi_parse_object *arg = NULL;
72 const struct acpi_opcode_info *op_info;
73
74
75 ACPI_FUNCTION_ENTRY ();
76
77
78 /* Get the info structure for this opcode */
79
80 op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
81 if (op_info->class == AML_CLASS_UNKNOWN) {
82 /* Invalid opcode or ASCII character */
83
84 return (NULL);
85 }
86
87 /* Check if this opcode requires argument sub-objects */
88
89 if (!(op_info->flags & AML_HAS_ARGS)) {
90 /* Has no linked argument objects */
91
92 return (NULL);
93 }
94
95 /* Get the requested argument object */
96
97 arg = op->common.value.arg;
98 while (arg && argn) {
99 argn--;
100 arg = arg->common.next;
101 }
102
103 return (arg);
104}
105
106
107/*******************************************************************************
108 *
109 * FUNCTION: acpi_ps_append_arg
110 *
111 * PARAMETERS: Op - Append an argument to this Op.
112 * Arg - Argument Op to append
113 *
114 * RETURN: None.
115 *
116 * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
117 *
118 ******************************************************************************/
119
120void
121acpi_ps_append_arg (
122 union acpi_parse_object *op,
123 union acpi_parse_object *arg)
124{
125 union acpi_parse_object *prev_arg;
126 const struct acpi_opcode_info *op_info;
127
128
129 ACPI_FUNCTION_ENTRY ();
130
131
132 if (!op) {
133 return;
134 }
135
136 /* Get the info structure for this opcode */
137
138 op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
139 if (op_info->class == AML_CLASS_UNKNOWN) {
140 /* Invalid opcode */
141
142 ACPI_REPORT_ERROR (("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n",
143 op->common.aml_opcode));
144 return;
145 }
146
147 /* Check if this opcode requires argument sub-objects */
148
149 if (!(op_info->flags & AML_HAS_ARGS)) {
150 /* Has no linked argument objects */
151
152 return;
153 }
154
155
156 /* Append the argument to the linked argument list */
157
158 if (op->common.value.arg) {
159 /* Append to existing argument list */
160
161 prev_arg = op->common.value.arg;
162 while (prev_arg->common.next) {
163 prev_arg = prev_arg->common.next;
164 }
165 prev_arg->common.next = arg;
166 }
167
168 else {
169 /* No argument list, this will be the first argument */
170
171 op->common.value.arg = arg;
172 }
173
174
175 /* Set the parent in this arg and any args linked after it */
176
177 while (arg) {
178 arg->common.parent = op;
179 arg = arg->common.next;
180 }
181}
182
183
184#ifdef ACPI_FUTURE_USAGE
185
186/*******************************************************************************
187 *
188 * FUNCTION: acpi_ps_get_child
189 *
190 * PARAMETERS: Op - Get the child of this Op
191 *
192 * RETURN: Child Op, Null if none is found.
193 *
194 * DESCRIPTION: Get op's children or NULL if none
195 *
196 ******************************************************************************/
197union acpi_parse_object *
198acpi_ps_get_child (
199 union acpi_parse_object *op)
200{
201 union acpi_parse_object *child = NULL;
202
203
204 ACPI_FUNCTION_ENTRY ();
205
206
207 switch (op->common.aml_opcode) {
208 case AML_SCOPE_OP:
209 case AML_ELSE_OP:
210 case AML_DEVICE_OP:
211 case AML_THERMAL_ZONE_OP:
212 case AML_INT_METHODCALL_OP:
213
214 child = acpi_ps_get_arg (op, 0);
215 break;
216
217
218 case AML_BUFFER_OP:
219 case AML_PACKAGE_OP:
220 case AML_METHOD_OP:
221 case AML_IF_OP:
222 case AML_WHILE_OP:
223 case AML_FIELD_OP:
224
225 child = acpi_ps_get_arg (op, 1);
226 break;
227
228
229 case AML_POWER_RES_OP:
230 case AML_INDEX_FIELD_OP:
231
232 child = acpi_ps_get_arg (op, 2);
233 break;
234
235
236 case AML_PROCESSOR_OP:
237 case AML_BANK_FIELD_OP:
238
239 child = acpi_ps_get_arg (op, 3);
240 break;
241
242
243 default:
244 /* All others have no children */
245 break;
246 }
247
248 return (child);
249}
250
251
252/*******************************************************************************
253 *
254 * FUNCTION: acpi_ps_get_depth_next
255 *
256 * PARAMETERS: Origin - Root of subtree to search
257 * Op - Last (previous) Op that was found
258 *
259 * RETURN: Next Op found in the search.
260 *
261 * DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
262 * Return NULL when reaching "origin" or when walking up from root
263 *
264 ******************************************************************************/
265
266union acpi_parse_object *
267acpi_ps_get_depth_next (
268 union acpi_parse_object *origin,
269 union acpi_parse_object *op)
270{
271 union acpi_parse_object *next = NULL;
272 union acpi_parse_object *parent;
273 union acpi_parse_object *arg;
274
275
276 ACPI_FUNCTION_ENTRY ();
277
278
279 if (!op) {
280 return (NULL);
281 }
282
283 /* look for an argument or child */
284
285 next = acpi_ps_get_arg (op, 0);
286 if (next) {
287 return (next);
288 }
289
290 /* look for a sibling */
291
292 next = op->common.next;
293 if (next) {
294 return (next);
295 }
296
297 /* look for a sibling of parent */
298
299 parent = op->common.parent;
300
301 while (parent) {
302 arg = acpi_ps_get_arg (parent, 0);
303 while (arg && (arg != origin) && (arg != op)) {
304 arg = arg->common.next;
305 }
306
307 if (arg == origin) {
308 /* reached parent of origin, end search */
309
310 return (NULL);
311 }
312
313 if (parent->common.next) {
314 /* found sibling of parent */
315
316 return (parent->common.next);
317 }
318
319 op = parent;
320 parent = parent->common.parent;
321 }
322
323 return (next);
324}
325
326#endif /* ACPI_FUTURE_USAGE */
327
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
new file mode 100644
index 000000000000..b3597cb19f88
--- /dev/null
+++ b/drivers/acpi/parser/psutils.c
@@ -0,0 +1,309 @@
1/******************************************************************************
2 *
3 * Module Name: psutils - Parser miscellaneous utilities (Parser only)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h>
49
50#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psutils")
52
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ps_create_scope_op
57 *
58 * PARAMETERS: None
59 *
60 * RETURN: scope_op
61 *
62 * DESCRIPTION: Create a Scope and associated namepath op with the root name
63 *
64 ******************************************************************************/
65
66union acpi_parse_object *
67acpi_ps_create_scope_op (
68 void)
69{
70 union acpi_parse_object *scope_op;
71
72
73 scope_op = acpi_ps_alloc_op (AML_SCOPE_OP);
74 if (!scope_op) {
75 return (NULL);
76 }
77
78
79 scope_op->named.name = ACPI_ROOT_NAME;
80 return (scope_op);
81}
82
83
84/*******************************************************************************
85 *
86 * FUNCTION: acpi_ps_init_op
87 *
88 * PARAMETERS: Op - A newly allocated Op object
89 * Opcode - Opcode to store in the Op
90 *
91 * RETURN: Status
92 *
93 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
94 * opcode
95 *
96 ******************************************************************************/
97
98void
99acpi_ps_init_op (
100 union acpi_parse_object *op,
101 u16 opcode)
102{
103 ACPI_FUNCTION_ENTRY ();
104
105
106 op->common.data_type = ACPI_DESC_TYPE_PARSER;
107 op->common.aml_opcode = opcode;
108
109 ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name,
110 (acpi_ps_get_opcode_info (opcode))->name, sizeof (op->common.aml_op_name)));
111}
112
113
114/*******************************************************************************
115 *
116 * FUNCTION: acpi_ps_alloc_op
117 *
118 * PARAMETERS: Opcode - Opcode that will be stored in the new Op
119 *
120 * RETURN: Pointer to the new Op.
121 *
122 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
123 * opcode. A cache of opcodes is available for the pure
124 * GENERIC_OP, since this is by far the most commonly used.
125 *
126 ******************************************************************************/
127
128union acpi_parse_object*
129acpi_ps_alloc_op (
130 u16 opcode)
131{
132 union acpi_parse_object *op;
133 const struct acpi_opcode_info *op_info;
134 u8 flags = ACPI_PARSEOP_GENERIC;
135
136
137 ACPI_FUNCTION_ENTRY ();
138
139
140 op_info = acpi_ps_get_opcode_info (opcode);
141
142 /* Determine type of parse_op required */
143
144 if (op_info->flags & AML_DEFER) {
145 flags = ACPI_PARSEOP_DEFERRED;
146 }
147 else if (op_info->flags & AML_NAMED) {
148 flags = ACPI_PARSEOP_NAMED;
149 }
150 else if (opcode == AML_INT_BYTELIST_OP) {
151 flags = ACPI_PARSEOP_BYTELIST;
152 }
153
154 /* Allocate the minimum required size object */
155
156 if (flags == ACPI_PARSEOP_GENERIC) {
157 /* The generic op (default) is by far the most common (16 to 1) */
158
159 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE);
160 }
161 else {
162 /* Extended parseop */
163
164 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT);
165 }
166
167 /* Initialize the Op */
168
169 if (op) {
170 acpi_ps_init_op (op, opcode);
171 op->common.flags = flags;
172 }
173
174 return (op);
175}
176
177
178/*******************************************************************************
179 *
180 * FUNCTION: acpi_ps_free_op
181 *
182 * PARAMETERS: Op - Op to be freed
183 *
184 * RETURN: None.
185 *
186 * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
187 * or actually free it.
188 *
189 ******************************************************************************/
190
191void
192acpi_ps_free_op (
193 union acpi_parse_object *op)
194{
195 ACPI_FUNCTION_NAME ("ps_free_op");
196
197
198 if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
199 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", op));
200 }
201
202 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
203 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op);
204 }
205 else {
206 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op);
207 }
208}
209
210
211#ifdef ACPI_ENABLE_OBJECT_CACHE
212/*******************************************************************************
213 *
214 * FUNCTION: acpi_ps_delete_parse_cache
215 *
216 * PARAMETERS: None
217 *
218 * RETURN: None
219 *
220 * DESCRIPTION: Free all objects that are on the parse cache list.
221 *
222 ******************************************************************************/
223
224void
225acpi_ps_delete_parse_cache (
226 void)
227{
228 ACPI_FUNCTION_TRACE ("ps_delete_parse_cache");
229
230
231 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
232 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT);
233 return_VOID;
234}
235#endif
236
237
238/*******************************************************************************
239 *
240 * FUNCTION: Utility functions
241 *
242 * DESCRIPTION: Low level character and object functions
243 *
244 ******************************************************************************/
245
246
247/*
248 * Is "c" a namestring lead character?
249 */
250u8
251acpi_ps_is_leading_char (
252 u32 c)
253{
254 return ((u8) (c == '_' || (c >= 'A' && c <= 'Z')));
255}
256
257
258/*
259 * Is "c" a namestring prefix character?
260 */
261u8
262acpi_ps_is_prefix_char (
263 u32 c)
264{
265 return ((u8) (c == '\\' || c == '^'));
266}
267
268
269/*
270 * Get op's name (4-byte name segment) or 0 if unnamed
271 */
272#ifdef ACPI_FUTURE_USAGE
273u32
274acpi_ps_get_name (
275 union acpi_parse_object *op)
276{
277
278
279 /* The "generic" object has no name associated with it */
280
281 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
282 return (0);
283 }
284
285 /* Only the "Extended" parse objects have a name */
286
287 return (op->named.name);
288}
289#endif /* ACPI_FUTURE_USAGE */
290
291
292/*
293 * Set op's name
294 */
295void
296acpi_ps_set_name (
297 union acpi_parse_object *op,
298 u32 name)
299{
300
301 /* The "generic" object has no name associated with it */
302
303 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
304 return;
305 }
306
307 op->named.name = name;
308}
309
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
new file mode 100644
index 000000000000..110d2ce917b6
--- /dev/null
+++ b/drivers/acpi/parser/pswalk.c
@@ -0,0 +1,115 @@
1/******************************************************************************
2 *
3 * Module Name: pswalk - Parser routines to walk parsed op tree(s)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47
48#define _COMPONENT ACPI_PARSER
49 ACPI_MODULE_NAME ("pswalk")
50
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_ps_delete_parse_tree
55 *
56 * PARAMETERS: subtree_root - Root of tree (or subtree) to delete
57 *
58 * RETURN: None
59 *
60 * DESCRIPTION: Delete a portion of or an entire parse tree.
61 *
62 ******************************************************************************/
63
64void
65acpi_ps_delete_parse_tree (
66 union acpi_parse_object *subtree_root)
67{
68 union acpi_parse_object *op = subtree_root;
69 union acpi_parse_object *next = NULL;
70 union acpi_parse_object *parent = NULL;
71
72
73 ACPI_FUNCTION_TRACE_PTR ("ps_delete_parse_tree", subtree_root);
74
75
76 /* Visit all nodes in the subtree */
77
78 while (op) {
79 /* Check if we are not ascending */
80
81 if (op != parent) {
82 /* Look for an argument or child of the current op */
83
84 next = acpi_ps_get_arg (op, 0);
85 if (next) {
86 /* Still going downward in tree (Op is not completed yet) */
87
88 op = next;
89 continue;
90 }
91 }
92
93 /*
94 * No more children, this Op is complete.
95 */
96 next = op->common.next;
97 parent = op->common.parent;
98
99 acpi_ps_free_op (op);
100
101 /*
102 * If we are back to the starting point, the walk is complete.
103 */
104 if (op == subtree_root) {
105 return_VOID;
106 }
107 if (next) {
108 op = next;
109 }
110 else {
111 op = parent;
112 }
113 }
114 return_VOID;
115}
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
new file mode 100644
index 000000000000..b318ad24726d
--- /dev/null
+++ b/drivers/acpi/parser/psxface.c
@@ -0,0 +1,243 @@
1/******************************************************************************
2 *
3 * Module Name: psxface - Parser external interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/acdispat.h>
48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h>
50
51
52#define _COMPONENT ACPI_PARSER
53 ACPI_MODULE_NAME ("psxface")
54
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_psx_execute
59 *
60 * PARAMETERS: Info->Node - A method object containing both the AML
61 * address and length.
62 * **Params - List of parameters to pass to method,
63 * terminated by NULL. Params itself may be
64 * NULL if no parameters are being passed.
65 * **return_obj_desc - Return object from execution of the
66 * method.
67 *
68 * RETURN: Status
69 *
70 * DESCRIPTION: Execute a control method
71 *
72 ******************************************************************************/
73
74acpi_status
75acpi_psx_execute (
76 struct acpi_parameter_info *info)
77{
78 acpi_status status;
79 union acpi_operand_object *obj_desc;
80 u32 i;
81 union acpi_parse_object *op;
82 struct acpi_walk_state *walk_state;
83
84
85 ACPI_FUNCTION_TRACE ("psx_execute");
86
87
88 /* Validate the Node and get the attached object */
89
90 if (!info || !info->node) {
91 return_ACPI_STATUS (AE_NULL_ENTRY);
92 }
93
94 obj_desc = acpi_ns_get_attached_object (info->node);
95 if (!obj_desc) {
96 return_ACPI_STATUS (AE_NULL_OBJECT);
97 }
98
99 /* Init for new method, wait on concurrency semaphore */
100
101 status = acpi_ds_begin_method_execution (info->node, obj_desc, NULL);
102 if (ACPI_FAILURE (status)) {
103 return_ACPI_STATUS (status);
104 }
105
106 if ((info->parameter_type == ACPI_PARAM_ARGS) &&
107 (info->parameters)) {
108 /*
109 * The caller "owns" the parameters, so give each one an extra
110 * reference
111 */
112 for (i = 0; info->parameters[i]; i++) {
113 acpi_ut_add_reference (info->parameters[i]);
114 }
115 }
116
117 /*
118 * 1) Perform the first pass parse of the method to enter any
119 * named objects that it creates into the namespace
120 */
121 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
122 "**** Begin Method Parse **** Entry=%p obj=%p\n",
123 info->node, obj_desc));
124
125 /* Create and init a Root Node */
126
127 op = acpi_ps_create_scope_op ();
128 if (!op) {
129 status = AE_NO_MEMORY;
130 goto cleanup1;
131 }
132
133 /*
134 * Get a new owner_id for objects created by this method. Namespace
135 * objects (such as Operation Regions) can be created during the
136 * first pass parse.
137 */
138 obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
139
140 /* Create and initialize a new walk state */
141
142 walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
143 NULL, NULL, NULL);
144 if (!walk_state) {
145 status = AE_NO_MEMORY;
146 goto cleanup2;
147 }
148
149 status = acpi_ds_init_aml_walk (walk_state, op, info->node,
150 obj_desc->method.aml_start,
151 obj_desc->method.aml_length, NULL, 1);
152 if (ACPI_FAILURE (status)) {
153 goto cleanup3;
154 }
155
156 /* Parse the AML */
157
158 status = acpi_ps_parse_aml (walk_state);
159 acpi_ps_delete_parse_tree (op);
160 if (ACPI_FAILURE (status)) {
161 goto cleanup1; /* Walk state is already deleted */
162 }
163
164 /*
165 * 2) Execute the method. Performs second pass parse simultaneously
166 */
167 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
168 "**** Begin Method Execution **** Entry=%p obj=%p\n",
169 info->node, obj_desc));
170
171 /* Create and init a Root Node */
172
173 op = acpi_ps_create_scope_op ();
174 if (!op) {
175 status = AE_NO_MEMORY;
176 goto cleanup1;
177 }
178
179 /* Init new op with the method name and pointer back to the NS node */
180
181 acpi_ps_set_name (op, info->node->name.integer);
182 op->common.node = info->node;
183
184 /* Create and initialize a new walk state */
185
186 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
187 if (!walk_state) {
188 status = AE_NO_MEMORY;
189 goto cleanup2;
190 }
191
192 status = acpi_ds_init_aml_walk (walk_state, op, info->node,
193 obj_desc->method.aml_start,
194 obj_desc->method.aml_length, info, 3);
195 if (ACPI_FAILURE (status)) {
196 goto cleanup3;
197 }
198
199 /*
200 * The walk of the parse tree is where we actually execute the method
201 */
202 status = acpi_ps_parse_aml (walk_state);
203 goto cleanup2; /* Walk state already deleted */
204
205
206cleanup3:
207 acpi_ds_delete_walk_state (walk_state);
208
209cleanup2:
210 acpi_ps_delete_parse_tree (op);
211
212cleanup1:
213 if ((info->parameter_type == ACPI_PARAM_ARGS) &&
214 (info->parameters)) {
215 /* Take away the extra reference that we gave the parameters above */
216
217 for (i = 0; info->parameters[i]; i++) {
218 /* Ignore errors, just do them all */
219
220 (void) acpi_ut_update_object_reference (info->parameters[i], REF_DECREMENT);
221 }
222 }
223
224 if (ACPI_FAILURE (status)) {
225 return_ACPI_STATUS (status);
226 }
227
228 /*
229 * If the method has returned an object, signal this to the caller with
230 * a control exception code
231 */
232 if (info->return_object) {
233 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
234 info->return_object));
235 ACPI_DUMP_STACK_ENTRY (info->return_object);
236
237 status = AE_CTRL_RETURN_VALUE;
238 }
239
240 return_ACPI_STATUS (status);
241}
242
243