diff options
author | Len Brown <len.brown@intel.com> | 2009-01-09 00:13:17 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-01-09 03:30:47 -0500 |
commit | 95b482a8d31116f3f5c2a5089569393234d06385 (patch) | |
tree | f32aec8673a285a9d188948be97af3034ee06e93 /drivers/acpi/parser | |
parent | 6620e0c49f577454b772fb381543d60ae53eb885 (diff) |
ACPICA: create acpica/ directory
also, delete sleep/ and delete ACPI_CFLAGS from Makefile
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/parser')
-rw-r--r-- | drivers/acpi/parser/Makefile | 8 | ||||
-rw-r--r-- | drivers/acpi/parser/psargs.c | 752 | ||||
-rw-r--r-- | drivers/acpi/parser/psloop.c | 1088 | ||||
-rw-r--r-- | drivers/acpi/parser/psopcode.c | 810 | ||||
-rw-r--r-- | drivers/acpi/parser/psparse.c | 701 | ||||
-rw-r--r-- | drivers/acpi/parser/psscope.c | 265 | ||||
-rw-r--r-- | drivers/acpi/parser/pstree.c | 312 | ||||
-rw-r--r-- | drivers/acpi/parser/psutils.c | 244 | ||||
-rw-r--r-- | drivers/acpi/parser/pswalk.c | 110 | ||||
-rw-r--r-- | drivers/acpi/parser/psxface.c | 385 |
10 files changed, 0 insertions, 4675 deletions
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile deleted file mode 100644 index db24ee09cf11..000000000000 --- a/drivers/acpi/parser/Makefile +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for all Linux ACPI interpreter subdirectories | ||
3 | # | ||
4 | |||
5 | obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \ | ||
6 | psopcode.o psscope.o psutils.o psxface.o | ||
7 | |||
8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | ||
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c deleted file mode 100644 index 852f3a83b2e6..000000000000 --- a/drivers/acpi/parser/psargs.c +++ /dev/null | |||
@@ -1,752 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psargs - Parse AML opcode arguments | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | #include <acpi/amlcode.h> | ||
48 | #include <acpi/acnamesp.h> | ||
49 | #include <acpi/acdispat.h> | ||
50 | |||
51 | #define _COMPONENT ACPI_PARSER | ||
52 | ACPI_MODULE_NAME("psargs") | ||
53 | |||
54 | /* Local prototypes */ | ||
55 | static u32 | ||
56 | acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state); | ||
57 | |||
58 | static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state | ||
59 | *parser_state); | ||
60 | |||
61 | /******************************************************************************* | ||
62 | * | ||
63 | * FUNCTION: acpi_ps_get_next_package_length | ||
64 | * | ||
65 | * PARAMETERS: parser_state - Current parser state object | ||
66 | * | ||
67 | * RETURN: Decoded package length. On completion, the AML pointer points | ||
68 | * past the length byte or bytes. | ||
69 | * | ||
70 | * DESCRIPTION: Decode and return a package length field. | ||
71 | * Note: Largest package length is 28 bits, from ACPI specification | ||
72 | * | ||
73 | ******************************************************************************/ | ||
74 | |||
75 | static u32 | ||
76 | acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) | ||
77 | { | ||
78 | u8 *aml = parser_state->aml; | ||
79 | u32 package_length = 0; | ||
80 | u32 byte_count; | ||
81 | u8 byte_zero_mask = 0x3F; /* Default [0:5] */ | ||
82 | |||
83 | ACPI_FUNCTION_TRACE(ps_get_next_package_length); | ||
84 | |||
85 | /* | ||
86 | * Byte 0 bits [6:7] contain the number of additional bytes | ||
87 | * used to encode the package length, either 0,1,2, or 3 | ||
88 | */ | ||
89 | byte_count = (aml[0] >> 6); | ||
90 | parser_state->aml += ((acpi_size) byte_count + 1); | ||
91 | |||
92 | /* Get bytes 3, 2, 1 as needed */ | ||
93 | |||
94 | while (byte_count) { | ||
95 | /* | ||
96 | * Final bit positions for the package length bytes: | ||
97 | * Byte3->[20:27] | ||
98 | * Byte2->[12:19] | ||
99 | * Byte1->[04:11] | ||
100 | * Byte0->[00:03] | ||
101 | */ | ||
102 | package_length |= (aml[byte_count] << ((byte_count << 3) - 4)); | ||
103 | |||
104 | byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */ | ||
105 | byte_count--; | ||
106 | } | ||
107 | |||
108 | /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ | ||
109 | |||
110 | package_length |= (aml[0] & byte_zero_mask); | ||
111 | return_UINT32(package_length); | ||
112 | } | ||
113 | |||
114 | /******************************************************************************* | ||
115 | * | ||
116 | * FUNCTION: acpi_ps_get_next_package_end | ||
117 | * | ||
118 | * PARAMETERS: parser_state - Current parser state object | ||
119 | * | ||
120 | * RETURN: Pointer to end-of-package +1 | ||
121 | * | ||
122 | * DESCRIPTION: Get next package length and return a pointer past the end of | ||
123 | * the package. Consumes the package length field | ||
124 | * | ||
125 | ******************************************************************************/ | ||
126 | |||
127 | u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) | ||
128 | { | ||
129 | u8 *start = parser_state->aml; | ||
130 | u32 package_length; | ||
131 | |||
132 | ACPI_FUNCTION_TRACE(ps_get_next_package_end); | ||
133 | |||
134 | /* Function below updates parser_state->Aml */ | ||
135 | |||
136 | package_length = acpi_ps_get_next_package_length(parser_state); | ||
137 | |||
138 | return_PTR(start + package_length); /* end of package */ | ||
139 | } | ||
140 | |||
141 | /******************************************************************************* | ||
142 | * | ||
143 | * FUNCTION: acpi_ps_get_next_namestring | ||
144 | * | ||
145 | * PARAMETERS: parser_state - Current parser state object | ||
146 | * | ||
147 | * RETURN: Pointer to the start of the name string (pointer points into | ||
148 | * the AML. | ||
149 | * | ||
150 | * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name | ||
151 | * prefix characters. Set parser state to point past the string. | ||
152 | * (Name is consumed from the AML.) | ||
153 | * | ||
154 | ******************************************************************************/ | ||
155 | |||
156 | char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) | ||
157 | { | ||
158 | u8 *start = parser_state->aml; | ||
159 | u8 *end = parser_state->aml; | ||
160 | |||
161 | ACPI_FUNCTION_TRACE(ps_get_next_namestring); | ||
162 | |||
163 | /* Point past any namestring prefix characters (backslash or carat) */ | ||
164 | |||
165 | while (acpi_ps_is_prefix_char(*end)) { | ||
166 | end++; | ||
167 | } | ||
168 | |||
169 | /* Decode the path prefix character */ | ||
170 | |||
171 | switch (*end) { | ||
172 | case 0: | ||
173 | |||
174 | /* null_name */ | ||
175 | |||
176 | if (end == start) { | ||
177 | start = NULL; | ||
178 | } | ||
179 | end++; | ||
180 | break; | ||
181 | |||
182 | case AML_DUAL_NAME_PREFIX: | ||
183 | |||
184 | /* Two name segments */ | ||
185 | |||
186 | end += 1 + (2 * ACPI_NAME_SIZE); | ||
187 | break; | ||
188 | |||
189 | case AML_MULTI_NAME_PREFIX_OP: | ||
190 | |||
191 | /* Multiple name segments, 4 chars each, count in next byte */ | ||
192 | |||
193 | end += 2 + (*(end + 1) * ACPI_NAME_SIZE); | ||
194 | break; | ||
195 | |||
196 | default: | ||
197 | |||
198 | /* Single name segment */ | ||
199 | |||
200 | end += ACPI_NAME_SIZE; | ||
201 | break; | ||
202 | } | ||
203 | |||
204 | parser_state->aml = end; | ||
205 | return_PTR((char *)start); | ||
206 | } | ||
207 | |||
208 | /******************************************************************************* | ||
209 | * | ||
210 | * FUNCTION: acpi_ps_get_next_namepath | ||
211 | * | ||
212 | * PARAMETERS: parser_state - Current parser state object | ||
213 | * Arg - Where the namepath will be stored | ||
214 | * arg_count - If the namepath points to a control method | ||
215 | * the method's argument is returned here. | ||
216 | * possible_method_call - Whether the namepath can possibly be the | ||
217 | * start of a method call | ||
218 | * | ||
219 | * RETURN: Status | ||
220 | * | ||
221 | * DESCRIPTION: Get next name (if method call, return # of required args). | ||
222 | * Names are looked up in the internal namespace to determine | ||
223 | * if the name represents a control method. If a method | ||
224 | * is found, the number of arguments to the method is returned. | ||
225 | * This information is critical for parsing to continue correctly. | ||
226 | * | ||
227 | ******************************************************************************/ | ||
228 | |||
229 | acpi_status | ||
230 | acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, | ||
231 | struct acpi_parse_state *parser_state, | ||
232 | union acpi_parse_object *arg, u8 possible_method_call) | ||
233 | { | ||
234 | acpi_status status; | ||
235 | char *path; | ||
236 | union acpi_parse_object *name_op; | ||
237 | union acpi_operand_object *method_desc; | ||
238 | struct acpi_namespace_node *node; | ||
239 | u8 *start = parser_state->aml; | ||
240 | |||
241 | ACPI_FUNCTION_TRACE(ps_get_next_namepath); | ||
242 | |||
243 | path = acpi_ps_get_next_namestring(parser_state); | ||
244 | acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); | ||
245 | |||
246 | /* Null path case is allowed, just exit */ | ||
247 | |||
248 | if (!path) { | ||
249 | arg->common.value.name = path; | ||
250 | return_ACPI_STATUS(AE_OK); | ||
251 | } | ||
252 | |||
253 | /* | ||
254 | * Lookup the name in the internal namespace, starting with the current | ||
255 | * scope. We don't want to add anything new to the namespace here, | ||
256 | * however, so we use MODE_EXECUTE. | ||
257 | * Allow searching of the parent tree, but don't open a new scope - | ||
258 | * we just want to lookup the object (must be mode EXECUTE to perform | ||
259 | * the upsearch) | ||
260 | */ | ||
261 | status = acpi_ns_lookup(walk_state->scope_info, path, | ||
262 | ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, | ||
263 | ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, | ||
264 | NULL, &node); | ||
265 | |||
266 | /* | ||
267 | * If this name is a control method invocation, we must | ||
268 | * setup the method call | ||
269 | */ | ||
270 | if (ACPI_SUCCESS(status) && | ||
271 | possible_method_call && (node->type == ACPI_TYPE_METHOD)) { | ||
272 | if (walk_state->opcode == AML_UNLOAD_OP) { | ||
273 | /* | ||
274 | * acpi_ps_get_next_namestring has increased the AML pointer, | ||
275 | * so we need to restore the saved AML pointer for method call. | ||
276 | */ | ||
277 | walk_state->parser_state.aml = start; | ||
278 | walk_state->arg_count = 1; | ||
279 | acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); | ||
280 | return_ACPI_STATUS(AE_OK); | ||
281 | } | ||
282 | |||
283 | /* This name is actually a control method invocation */ | ||
284 | |||
285 | method_desc = acpi_ns_get_attached_object(node); | ||
286 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
287 | "Control Method - %p Desc %p Path=%p\n", node, | ||
288 | method_desc, path)); | ||
289 | |||
290 | name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); | ||
291 | if (!name_op) { | ||
292 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
293 | } | ||
294 | |||
295 | /* Change Arg into a METHOD CALL and attach name to it */ | ||
296 | |||
297 | acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); | ||
298 | name_op->common.value.name = path; | ||
299 | |||
300 | /* Point METHODCALL/NAME to the METHOD Node */ | ||
301 | |||
302 | name_op->common.node = node; | ||
303 | acpi_ps_append_arg(arg, name_op); | ||
304 | |||
305 | if (!method_desc) { | ||
306 | ACPI_ERROR((AE_INFO, | ||
307 | "Control Method %p has no attached object", | ||
308 | node)); | ||
309 | return_ACPI_STATUS(AE_AML_INTERNAL); | ||
310 | } | ||
311 | |||
312 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
313 | "Control Method - %p Args %X\n", | ||
314 | node, method_desc->method.param_count)); | ||
315 | |||
316 | /* Get the number of arguments to expect */ | ||
317 | |||
318 | walk_state->arg_count = method_desc->method.param_count; | ||
319 | return_ACPI_STATUS(AE_OK); | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Special handling if the name was not found during the lookup - | ||
324 | * some not_found cases are allowed | ||
325 | */ | ||
326 | if (status == AE_NOT_FOUND) { | ||
327 | |||
328 | /* 1) not_found is ok during load pass 1/2 (allow forward references) */ | ||
329 | |||
330 | if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) != | ||
331 | ACPI_PARSE_EXECUTE) { | ||
332 | status = AE_OK; | ||
333 | } | ||
334 | |||
335 | /* 2) not_found during a cond_ref_of(x) is ok by definition */ | ||
336 | |||
337 | else if (walk_state->op->common.aml_opcode == | ||
338 | AML_COND_REF_OF_OP) { | ||
339 | status = AE_OK; | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * 3) not_found while building a Package is ok at this point, we | ||
344 | * may flag as an error later if slack mode is not enabled. | ||
345 | * (Some ASL code depends on allowing this behavior) | ||
346 | */ | ||
347 | else if ((arg->common.parent) && | ||
348 | ((arg->common.parent->common.aml_opcode == | ||
349 | AML_PACKAGE_OP) | ||
350 | || (arg->common.parent->common.aml_opcode == | ||
351 | AML_VAR_PACKAGE_OP))) { | ||
352 | status = AE_OK; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | /* Final exception check (may have been changed from code above) */ | ||
357 | |||
358 | if (ACPI_FAILURE(status)) { | ||
359 | ACPI_ERROR_NAMESPACE(path, status); | ||
360 | |||
361 | if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == | ||
362 | ACPI_PARSE_EXECUTE) { | ||
363 | |||
364 | /* Report a control method execution error */ | ||
365 | |||
366 | status = acpi_ds_method_error(status, walk_state); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | /* Save the namepath */ | ||
371 | |||
372 | arg->common.value.name = path; | ||
373 | return_ACPI_STATUS(status); | ||
374 | } | ||
375 | |||
376 | /******************************************************************************* | ||
377 | * | ||
378 | * FUNCTION: acpi_ps_get_next_simple_arg | ||
379 | * | ||
380 | * PARAMETERS: parser_state - Current parser state object | ||
381 | * arg_type - The argument type (AML_*_ARG) | ||
382 | * Arg - Where the argument is returned | ||
383 | * | ||
384 | * RETURN: None | ||
385 | * | ||
386 | * DESCRIPTION: Get the next simple argument (constant, string, or namestring) | ||
387 | * | ||
388 | ******************************************************************************/ | ||
389 | |||
390 | void | ||
391 | acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, | ||
392 | u32 arg_type, union acpi_parse_object *arg) | ||
393 | { | ||
394 | u32 length; | ||
395 | u16 opcode; | ||
396 | u8 *aml = parser_state->aml; | ||
397 | |||
398 | ACPI_FUNCTION_TRACE_U32(ps_get_next_simple_arg, arg_type); | ||
399 | |||
400 | switch (arg_type) { | ||
401 | case ARGP_BYTEDATA: | ||
402 | |||
403 | /* Get 1 byte from the AML stream */ | ||
404 | |||
405 | opcode = AML_BYTE_OP; | ||
406 | arg->common.value.integer = (acpi_integer) * aml; | ||
407 | length = 1; | ||
408 | break; | ||
409 | |||
410 | case ARGP_WORDDATA: | ||
411 | |||
412 | /* Get 2 bytes from the AML stream */ | ||
413 | |||
414 | opcode = AML_WORD_OP; | ||
415 | ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml); | ||
416 | length = 2; | ||
417 | break; | ||
418 | |||
419 | case ARGP_DWORDDATA: | ||
420 | |||
421 | /* Get 4 bytes from the AML stream */ | ||
422 | |||
423 | opcode = AML_DWORD_OP; | ||
424 | ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml); | ||
425 | length = 4; | ||
426 | break; | ||
427 | |||
428 | case ARGP_QWORDDATA: | ||
429 | |||
430 | /* Get 8 bytes from the AML stream */ | ||
431 | |||
432 | opcode = AML_QWORD_OP; | ||
433 | ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml); | ||
434 | length = 8; | ||
435 | break; | ||
436 | |||
437 | case ARGP_CHARLIST: | ||
438 | |||
439 | /* Get a pointer to the string, point past the string */ | ||
440 | |||
441 | opcode = AML_STRING_OP; | ||
442 | arg->common.value.string = ACPI_CAST_PTR(char, aml); | ||
443 | |||
444 | /* Find the null terminator */ | ||
445 | |||
446 | length = 0; | ||
447 | while (aml[length]) { | ||
448 | length++; | ||
449 | } | ||
450 | length++; | ||
451 | break; | ||
452 | |||
453 | case ARGP_NAME: | ||
454 | case ARGP_NAMESTRING: | ||
455 | |||
456 | acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); | ||
457 | arg->common.value.name = | ||
458 | acpi_ps_get_next_namestring(parser_state); | ||
459 | return_VOID; | ||
460 | |||
461 | default: | ||
462 | |||
463 | ACPI_ERROR((AE_INFO, "Invalid ArgType %X", arg_type)); | ||
464 | return_VOID; | ||
465 | } | ||
466 | |||
467 | acpi_ps_init_op(arg, opcode); | ||
468 | parser_state->aml += length; | ||
469 | return_VOID; | ||
470 | } | ||
471 | |||
472 | /******************************************************************************* | ||
473 | * | ||
474 | * FUNCTION: acpi_ps_get_next_field | ||
475 | * | ||
476 | * PARAMETERS: parser_state - Current parser state object | ||
477 | * | ||
478 | * RETURN: A newly allocated FIELD op | ||
479 | * | ||
480 | * DESCRIPTION: Get next field (named_field, reserved_field, or access_field) | ||
481 | * | ||
482 | ******************************************************************************/ | ||
483 | |||
484 | static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state | ||
485 | *parser_state) | ||
486 | { | ||
487 | u32 aml_offset = (u32) | ||
488 | ACPI_PTR_DIFF(parser_state->aml, | ||
489 | parser_state->aml_start); | ||
490 | union acpi_parse_object *field; | ||
491 | u16 opcode; | ||
492 | u32 name; | ||
493 | |||
494 | ACPI_FUNCTION_TRACE(ps_get_next_field); | ||
495 | |||
496 | /* Determine field type */ | ||
497 | |||
498 | switch (ACPI_GET8(parser_state->aml)) { | ||
499 | default: | ||
500 | |||
501 | opcode = AML_INT_NAMEDFIELD_OP; | ||
502 | break; | ||
503 | |||
504 | case 0x00: | ||
505 | |||
506 | opcode = AML_INT_RESERVEDFIELD_OP; | ||
507 | parser_state->aml++; | ||
508 | break; | ||
509 | |||
510 | case 0x01: | ||
511 | |||
512 | opcode = AML_INT_ACCESSFIELD_OP; | ||
513 | parser_state->aml++; | ||
514 | break; | ||
515 | } | ||
516 | |||
517 | /* Allocate a new field op */ | ||
518 | |||
519 | field = acpi_ps_alloc_op(opcode); | ||
520 | if (!field) { | ||
521 | return_PTR(NULL); | ||
522 | } | ||
523 | |||
524 | field->common.aml_offset = aml_offset; | ||
525 | |||
526 | /* Decode the field type */ | ||
527 | |||
528 | switch (opcode) { | ||
529 | case AML_INT_NAMEDFIELD_OP: | ||
530 | |||
531 | /* Get the 4-character name */ | ||
532 | |||
533 | ACPI_MOVE_32_TO_32(&name, parser_state->aml); | ||
534 | acpi_ps_set_name(field, name); | ||
535 | parser_state->aml += ACPI_NAME_SIZE; | ||
536 | |||
537 | /* Get the length which is encoded as a package length */ | ||
538 | |||
539 | field->common.value.size = | ||
540 | acpi_ps_get_next_package_length(parser_state); | ||
541 | break; | ||
542 | |||
543 | case AML_INT_RESERVEDFIELD_OP: | ||
544 | |||
545 | /* Get the length which is encoded as a package length */ | ||
546 | |||
547 | field->common.value.size = | ||
548 | acpi_ps_get_next_package_length(parser_state); | ||
549 | break; | ||
550 | |||
551 | case AML_INT_ACCESSFIELD_OP: | ||
552 | |||
553 | /* | ||
554 | * Get access_type and access_attrib and merge into the field Op | ||
555 | * access_type is first operand, access_attribute is second | ||
556 | */ | ||
557 | field->common.value.integer = | ||
558 | (((u32) ACPI_GET8(parser_state->aml) << 8)); | ||
559 | parser_state->aml++; | ||
560 | field->common.value.integer |= ACPI_GET8(parser_state->aml); | ||
561 | parser_state->aml++; | ||
562 | break; | ||
563 | |||
564 | default: | ||
565 | |||
566 | /* Opcode was set in previous switch */ | ||
567 | break; | ||
568 | } | ||
569 | |||
570 | return_PTR(field); | ||
571 | } | ||
572 | |||
573 | /******************************************************************************* | ||
574 | * | ||
575 | * FUNCTION: acpi_ps_get_next_arg | ||
576 | * | ||
577 | * PARAMETERS: walk_state - Current state | ||
578 | * parser_state - Current parser state object | ||
579 | * arg_type - The argument type (AML_*_ARG) | ||
580 | * return_arg - Where the next arg is returned | ||
581 | * | ||
582 | * RETURN: Status, and an op object containing the next argument. | ||
583 | * | ||
584 | * DESCRIPTION: Get next argument (including complex list arguments that require | ||
585 | * pushing the parser stack) | ||
586 | * | ||
587 | ******************************************************************************/ | ||
588 | |||
589 | acpi_status | ||
590 | acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, | ||
591 | struct acpi_parse_state *parser_state, | ||
592 | u32 arg_type, union acpi_parse_object **return_arg) | ||
593 | { | ||
594 | union acpi_parse_object *arg = NULL; | ||
595 | union acpi_parse_object *prev = NULL; | ||
596 | union acpi_parse_object *field; | ||
597 | u32 subop; | ||
598 | acpi_status status = AE_OK; | ||
599 | |||
600 | ACPI_FUNCTION_TRACE_PTR(ps_get_next_arg, parser_state); | ||
601 | |||
602 | switch (arg_type) { | ||
603 | case ARGP_BYTEDATA: | ||
604 | case ARGP_WORDDATA: | ||
605 | case ARGP_DWORDDATA: | ||
606 | case ARGP_CHARLIST: | ||
607 | case ARGP_NAME: | ||
608 | case ARGP_NAMESTRING: | ||
609 | |||
610 | /* Constants, strings, and namestrings are all the same size */ | ||
611 | |||
612 | arg = acpi_ps_alloc_op(AML_BYTE_OP); | ||
613 | if (!arg) { | ||
614 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
615 | } | ||
616 | acpi_ps_get_next_simple_arg(parser_state, arg_type, arg); | ||
617 | break; | ||
618 | |||
619 | case ARGP_PKGLENGTH: | ||
620 | |||
621 | /* Package length, nothing returned */ | ||
622 | |||
623 | parser_state->pkg_end = | ||
624 | acpi_ps_get_next_package_end(parser_state); | ||
625 | break; | ||
626 | |||
627 | case ARGP_FIELDLIST: | ||
628 | |||
629 | if (parser_state->aml < parser_state->pkg_end) { | ||
630 | |||
631 | /* Non-empty list */ | ||
632 | |||
633 | while (parser_state->aml < parser_state->pkg_end) { | ||
634 | field = acpi_ps_get_next_field(parser_state); | ||
635 | if (!field) { | ||
636 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
637 | } | ||
638 | |||
639 | if (prev) { | ||
640 | prev->common.next = field; | ||
641 | } else { | ||
642 | arg = field; | ||
643 | } | ||
644 | prev = field; | ||
645 | } | ||
646 | |||
647 | /* Skip to End of byte data */ | ||
648 | |||
649 | parser_state->aml = parser_state->pkg_end; | ||
650 | } | ||
651 | break; | ||
652 | |||
653 | case ARGP_BYTELIST: | ||
654 | |||
655 | if (parser_state->aml < parser_state->pkg_end) { | ||
656 | |||
657 | /* Non-empty list */ | ||
658 | |||
659 | arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP); | ||
660 | if (!arg) { | ||
661 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
662 | } | ||
663 | |||
664 | /* Fill in bytelist data */ | ||
665 | |||
666 | arg->common.value.size = (u32) | ||
667 | ACPI_PTR_DIFF(parser_state->pkg_end, | ||
668 | parser_state->aml); | ||
669 | arg->named.data = parser_state->aml; | ||
670 | |||
671 | /* Skip to End of byte data */ | ||
672 | |||
673 | parser_state->aml = parser_state->pkg_end; | ||
674 | } | ||
675 | break; | ||
676 | |||
677 | case ARGP_TARGET: | ||
678 | case ARGP_SUPERNAME: | ||
679 | case ARGP_SIMPLENAME: | ||
680 | |||
681 | subop = acpi_ps_peek_opcode(parser_state); | ||
682 | if (subop == 0 || | ||
683 | acpi_ps_is_leading_char(subop) || | ||
684 | acpi_ps_is_prefix_char(subop)) { | ||
685 | |||
686 | /* null_name or name_string */ | ||
687 | |||
688 | arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); | ||
689 | if (!arg) { | ||
690 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
691 | } | ||
692 | |||
693 | /* To support super_name arg of Unload */ | ||
694 | |||
695 | if (walk_state->opcode == AML_UNLOAD_OP) { | ||
696 | status = | ||
697 | acpi_ps_get_next_namepath(walk_state, | ||
698 | parser_state, arg, | ||
699 | 1); | ||
700 | |||
701 | /* | ||
702 | * If the super_name arg of Unload is a method call, | ||
703 | * we have restored the AML pointer, just free this Arg | ||
704 | */ | ||
705 | if (arg->common.aml_opcode == | ||
706 | AML_INT_METHODCALL_OP) { | ||
707 | acpi_ps_free_op(arg); | ||
708 | arg = NULL; | ||
709 | } | ||
710 | } else { | ||
711 | status = | ||
712 | acpi_ps_get_next_namepath(walk_state, | ||
713 | parser_state, arg, | ||
714 | 0); | ||
715 | } | ||
716 | } else { | ||
717 | /* Single complex argument, nothing returned */ | ||
718 | |||
719 | walk_state->arg_count = 1; | ||
720 | } | ||
721 | break; | ||
722 | |||
723 | case ARGP_DATAOBJ: | ||
724 | case ARGP_TERMARG: | ||
725 | |||
726 | /* Single complex argument, nothing returned */ | ||
727 | |||
728 | walk_state->arg_count = 1; | ||
729 | break; | ||
730 | |||
731 | case ARGP_DATAOBJLIST: | ||
732 | case ARGP_TERMLIST: | ||
733 | case ARGP_OBJLIST: | ||
734 | |||
735 | if (parser_state->aml < parser_state->pkg_end) { | ||
736 | |||
737 | /* Non-empty list of variable arguments, nothing returned */ | ||
738 | |||
739 | walk_state->arg_count = ACPI_VAR_ARGS; | ||
740 | } | ||
741 | break; | ||
742 | |||
743 | default: | ||
744 | |||
745 | ACPI_ERROR((AE_INFO, "Invalid ArgType: %X", arg_type)); | ||
746 | status = AE_AML_OPERAND_TYPE; | ||
747 | break; | ||
748 | } | ||
749 | |||
750 | *return_arg = arg; | ||
751 | return_ACPI_STATUS(status); | ||
752 | } | ||
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c deleted file mode 100644 index fd6648f0d65f..000000000000 --- a/drivers/acpi/parser/psloop.c +++ /dev/null | |||
@@ -1,1088 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psloop - Main AML parse loop | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | * Parse the AML and build an operation tree as most interpreters, (such as | ||
46 | * Perl) do. Parsing is done by hand rather than with a YACC generated parser | ||
47 | * to tightly constrain stack and dynamic memory usage. Parsing is kept | ||
48 | * flexible and the code fairly compact by parsing based on a list of AML | ||
49 | * opcode templates in aml_op_info[]. | ||
50 | */ | ||
51 | |||
52 | #include <acpi/acpi.h> | ||
53 | #include <acpi/accommon.h> | ||
54 | #include <acpi/acparser.h> | ||
55 | #include <acpi/acdispat.h> | ||
56 | #include <acpi/amlcode.h> | ||
57 | |||
58 | #define _COMPONENT ACPI_PARSER | ||
59 | ACPI_MODULE_NAME("psloop") | ||
60 | |||
61 | static u32 acpi_gbl_depth = 0; | ||
62 | |||
63 | /* Local prototypes */ | ||
64 | |||
65 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state); | ||
66 | |||
67 | static acpi_status | ||
68 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
69 | u8 * aml_op_start, | ||
70 | union acpi_parse_object *unnamed_op, | ||
71 | union acpi_parse_object **op); | ||
72 | |||
73 | static acpi_status | ||
74 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
75 | u8 * aml_op_start, union acpi_parse_object **new_op); | ||
76 | |||
77 | static acpi_status | ||
78 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | ||
79 | u8 * aml_op_start, union acpi_parse_object *op); | ||
80 | |||
81 | static acpi_status | ||
82 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
83 | union acpi_parse_object **op, acpi_status status); | ||
84 | |||
85 | static acpi_status | ||
86 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
87 | union acpi_parse_object *op, acpi_status status); | ||
88 | |||
89 | /******************************************************************************* | ||
90 | * | ||
91 | * FUNCTION: acpi_ps_get_aml_opcode | ||
92 | * | ||
93 | * PARAMETERS: walk_state - Current state | ||
94 | * | ||
95 | * RETURN: Status | ||
96 | * | ||
97 | * DESCRIPTION: Extract the next AML opcode from the input stream. | ||
98 | * | ||
99 | ******************************************************************************/ | ||
100 | |||
101 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state) | ||
102 | { | ||
103 | |||
104 | ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state); | ||
105 | |||
106 | walk_state->aml_offset = | ||
107 | (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml, | ||
108 | walk_state->parser_state.aml_start); | ||
109 | walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state)); | ||
110 | |||
111 | /* | ||
112 | * First cut to determine what we have found: | ||
113 | * 1) A valid AML opcode | ||
114 | * 2) A name string | ||
115 | * 3) An unknown/invalid opcode | ||
116 | */ | ||
117 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
118 | |||
119 | switch (walk_state->op_info->class) { | ||
120 | case AML_CLASS_ASCII: | ||
121 | case AML_CLASS_PREFIX: | ||
122 | /* | ||
123 | * Starts with a valid prefix or ASCII char, this is a name | ||
124 | * string. Convert the bare name string to a namepath. | ||
125 | */ | ||
126 | walk_state->opcode = AML_INT_NAMEPATH_OP; | ||
127 | walk_state->arg_types = ARGP_NAMESTRING; | ||
128 | break; | ||
129 | |||
130 | case AML_CLASS_UNKNOWN: | ||
131 | |||
132 | /* The opcode is unrecognized. Just skip unknown opcodes */ | ||
133 | |||
134 | ACPI_ERROR((AE_INFO, | ||
135 | "Found unknown opcode %X at AML address %p offset %X, ignoring", | ||
136 | walk_state->opcode, walk_state->parser_state.aml, | ||
137 | walk_state->aml_offset)); | ||
138 | |||
139 | ACPI_DUMP_BUFFER(walk_state->parser_state.aml, 128); | ||
140 | |||
141 | /* Assume one-byte bad opcode */ | ||
142 | |||
143 | walk_state->parser_state.aml++; | ||
144 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
145 | |||
146 | default: | ||
147 | |||
148 | /* Found opcode info, this is a normal opcode */ | ||
149 | |||
150 | walk_state->parser_state.aml += | ||
151 | acpi_ps_get_opcode_size(walk_state->opcode); | ||
152 | walk_state->arg_types = walk_state->op_info->parse_args; | ||
153 | break; | ||
154 | } | ||
155 | |||
156 | return_ACPI_STATUS(AE_OK); | ||
157 | } | ||
158 | |||
159 | /******************************************************************************* | ||
160 | * | ||
161 | * FUNCTION: acpi_ps_build_named_op | ||
162 | * | ||
163 | * PARAMETERS: walk_state - Current state | ||
164 | * aml_op_start - Begin of named Op in AML | ||
165 | * unnamed_op - Early Op (not a named Op) | ||
166 | * Op - Returned Op | ||
167 | * | ||
168 | * RETURN: Status | ||
169 | * | ||
170 | * DESCRIPTION: Parse a named Op | ||
171 | * | ||
172 | ******************************************************************************/ | ||
173 | |||
174 | static acpi_status | ||
175 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
176 | u8 * aml_op_start, | ||
177 | union acpi_parse_object *unnamed_op, | ||
178 | union acpi_parse_object **op) | ||
179 | { | ||
180 | acpi_status status = AE_OK; | ||
181 | union acpi_parse_object *arg = NULL; | ||
182 | |||
183 | ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state); | ||
184 | |||
185 | unnamed_op->common.value.arg = NULL; | ||
186 | unnamed_op->common.arg_list_length = 0; | ||
187 | unnamed_op->common.aml_opcode = walk_state->opcode; | ||
188 | |||
189 | /* | ||
190 | * Get and append arguments until we find the node that contains | ||
191 | * the name (the type ARGP_NAME). | ||
192 | */ | ||
193 | while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) && | ||
194 | (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) { | ||
195 | status = | ||
196 | acpi_ps_get_next_arg(walk_state, | ||
197 | &(walk_state->parser_state), | ||
198 | GET_CURRENT_ARG_TYPE(walk_state-> | ||
199 | arg_types), &arg); | ||
200 | if (ACPI_FAILURE(status)) { | ||
201 | return_ACPI_STATUS(status); | ||
202 | } | ||
203 | |||
204 | acpi_ps_append_arg(unnamed_op, arg); | ||
205 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
206 | } | ||
207 | |||
208 | /* | ||
209 | * Make sure that we found a NAME and didn't run out of arguments | ||
210 | */ | ||
211 | if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) { | ||
212 | return_ACPI_STATUS(AE_AML_NO_OPERAND); | ||
213 | } | ||
214 | |||
215 | /* We know that this arg is a name, move to next arg */ | ||
216 | |||
217 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
218 | |||
219 | /* | ||
220 | * Find the object. This will either insert the object into | ||
221 | * the namespace or simply look it up | ||
222 | */ | ||
223 | walk_state->op = NULL; | ||
224 | |||
225 | status = walk_state->descending_callback(walk_state, op); | ||
226 | if (ACPI_FAILURE(status)) { | ||
227 | ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog")); | ||
228 | return_ACPI_STATUS(status); | ||
229 | } | ||
230 | |||
231 | if (!*op) { | ||
232 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
233 | } | ||
234 | |||
235 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
236 | if (ACPI_FAILURE(status)) { | ||
237 | if (status == AE_CTRL_PENDING) { | ||
238 | return_ACPI_STATUS(AE_CTRL_PARSE_PENDING); | ||
239 | } | ||
240 | return_ACPI_STATUS(status); | ||
241 | } | ||
242 | |||
243 | acpi_ps_append_arg(*op, unnamed_op->common.value.arg); | ||
244 | acpi_gbl_depth++; | ||
245 | |||
246 | if ((*op)->common.aml_opcode == AML_REGION_OP || | ||
247 | (*op)->common.aml_opcode == AML_DATA_REGION_OP) { | ||
248 | /* | ||
249 | * Defer final parsing of an operation_region body, because we don't | ||
250 | * have enough info in the first pass to parse it correctly (i.e., | ||
251 | * there may be method calls within the term_arg elements of the body.) | ||
252 | * | ||
253 | * However, we must continue parsing because the opregion is not a | ||
254 | * standalone package -- we don't know where the end is at this point. | ||
255 | * | ||
256 | * (Length is unknown until parse of the body complete) | ||
257 | */ | ||
258 | (*op)->named.data = aml_op_start; | ||
259 | (*op)->named.length = 0; | ||
260 | } | ||
261 | |||
262 | return_ACPI_STATUS(AE_OK); | ||
263 | } | ||
264 | |||
265 | /******************************************************************************* | ||
266 | * | ||
267 | * FUNCTION: acpi_ps_create_op | ||
268 | * | ||
269 | * PARAMETERS: walk_state - Current state | ||
270 | * aml_op_start - Op start in AML | ||
271 | * new_op - Returned Op | ||
272 | * | ||
273 | * RETURN: Status | ||
274 | * | ||
275 | * DESCRIPTION: Get Op from AML | ||
276 | * | ||
277 | ******************************************************************************/ | ||
278 | |||
279 | static acpi_status | ||
280 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
281 | u8 * aml_op_start, union acpi_parse_object **new_op) | ||
282 | { | ||
283 | acpi_status status = AE_OK; | ||
284 | union acpi_parse_object *op; | ||
285 | union acpi_parse_object *named_op = NULL; | ||
286 | union acpi_parse_object *parent_scope; | ||
287 | u8 argument_count; | ||
288 | const struct acpi_opcode_info *op_info; | ||
289 | |||
290 | ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state); | ||
291 | |||
292 | status = acpi_ps_get_aml_opcode(walk_state); | ||
293 | if (status == AE_CTRL_PARSE_CONTINUE) { | ||
294 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
295 | } | ||
296 | |||
297 | /* Create Op structure and append to parent's argument list */ | ||
298 | |||
299 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
300 | op = acpi_ps_alloc_op(walk_state->opcode); | ||
301 | if (!op) { | ||
302 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
303 | } | ||
304 | |||
305 | if (walk_state->op_info->flags & AML_NAMED) { | ||
306 | status = | ||
307 | acpi_ps_build_named_op(walk_state, aml_op_start, op, | ||
308 | &named_op); | ||
309 | acpi_ps_free_op(op); | ||
310 | if (ACPI_FAILURE(status)) { | ||
311 | return_ACPI_STATUS(status); | ||
312 | } | ||
313 | |||
314 | *new_op = named_op; | ||
315 | return_ACPI_STATUS(AE_OK); | ||
316 | } | ||
317 | |||
318 | /* Not a named opcode, just allocate Op and append to parent */ | ||
319 | |||
320 | if (walk_state->op_info->flags & AML_CREATE) { | ||
321 | /* | ||
322 | * Backup to beginning of create_xXXfield declaration | ||
323 | * body_length is unknown until we parse the body | ||
324 | */ | ||
325 | op->named.data = aml_op_start; | ||
326 | op->named.length = 0; | ||
327 | } | ||
328 | |||
329 | if (walk_state->opcode == AML_BANK_FIELD_OP) { | ||
330 | /* | ||
331 | * Backup to beginning of bank_field declaration | ||
332 | * body_length is unknown until we parse the body | ||
333 | */ | ||
334 | op->named.data = aml_op_start; | ||
335 | op->named.length = 0; | ||
336 | } | ||
337 | |||
338 | parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state)); | ||
339 | acpi_ps_append_arg(parent_scope, op); | ||
340 | |||
341 | if (parent_scope) { | ||
342 | op_info = | ||
343 | acpi_ps_get_opcode_info(parent_scope->common.aml_opcode); | ||
344 | if (op_info->flags & AML_HAS_TARGET) { | ||
345 | argument_count = | ||
346 | acpi_ps_get_argument_count(op_info->type); | ||
347 | if (parent_scope->common.arg_list_length > | ||
348 | argument_count) { | ||
349 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
350 | } | ||
351 | } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) { | ||
352 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | if (walk_state->descending_callback != NULL) { | ||
357 | /* | ||
358 | * Find the object. This will either insert the object into | ||
359 | * the namespace or simply look it up | ||
360 | */ | ||
361 | walk_state->op = *new_op = op; | ||
362 | |||
363 | status = walk_state->descending_callback(walk_state, &op); | ||
364 | status = acpi_ps_next_parse_state(walk_state, op, status); | ||
365 | if (status == AE_CTRL_PENDING) { | ||
366 | status = AE_CTRL_PARSE_PENDING; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | return_ACPI_STATUS(status); | ||
371 | } | ||
372 | |||
373 | /******************************************************************************* | ||
374 | * | ||
375 | * FUNCTION: acpi_ps_get_arguments | ||
376 | * | ||
377 | * PARAMETERS: walk_state - Current state | ||
378 | * aml_op_start - Op start in AML | ||
379 | * Op - Current Op | ||
380 | * | ||
381 | * RETURN: Status | ||
382 | * | ||
383 | * DESCRIPTION: Get arguments for passed Op. | ||
384 | * | ||
385 | ******************************************************************************/ | ||
386 | |||
387 | static acpi_status | ||
388 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | ||
389 | u8 * aml_op_start, union acpi_parse_object *op) | ||
390 | { | ||
391 | acpi_status status = AE_OK; | ||
392 | union acpi_parse_object *arg = NULL; | ||
393 | |||
394 | ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state); | ||
395 | |||
396 | switch (op->common.aml_opcode) { | ||
397 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ | ||
398 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ | ||
399 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ | ||
400 | case AML_QWORD_OP: /* AML_QWORDATA_ARG */ | ||
401 | case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ | ||
402 | |||
403 | /* Fill in constant or string argument directly */ | ||
404 | |||
405 | acpi_ps_get_next_simple_arg(&(walk_state->parser_state), | ||
406 | GET_CURRENT_ARG_TYPE(walk_state-> | ||
407 | arg_types), | ||
408 | op); | ||
409 | break; | ||
410 | |||
411 | case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ | ||
412 | |||
413 | status = | ||
414 | acpi_ps_get_next_namepath(walk_state, | ||
415 | &(walk_state->parser_state), op, | ||
416 | 1); | ||
417 | if (ACPI_FAILURE(status)) { | ||
418 | return_ACPI_STATUS(status); | ||
419 | } | ||
420 | |||
421 | walk_state->arg_types = 0; | ||
422 | break; | ||
423 | |||
424 | default: | ||
425 | /* | ||
426 | * Op is not a constant or string, append each argument to the Op | ||
427 | */ | ||
428 | while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) | ||
429 | && !walk_state->arg_count) { | ||
430 | walk_state->aml_offset = | ||
431 | (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml, | ||
432 | walk_state->parser_state. | ||
433 | aml_start); | ||
434 | |||
435 | status = | ||
436 | acpi_ps_get_next_arg(walk_state, | ||
437 | &(walk_state->parser_state), | ||
438 | GET_CURRENT_ARG_TYPE | ||
439 | (walk_state->arg_types), &arg); | ||
440 | if (ACPI_FAILURE(status)) { | ||
441 | return_ACPI_STATUS(status); | ||
442 | } | ||
443 | |||
444 | if (arg) { | ||
445 | arg->common.aml_offset = walk_state->aml_offset; | ||
446 | acpi_ps_append_arg(op, arg); | ||
447 | } | ||
448 | |||
449 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
450 | } | ||
451 | |||
452 | /* Special processing for certain opcodes */ | ||
453 | |||
454 | /* TBD (remove): Temporary mechanism to disable this code if needed */ | ||
455 | |||
456 | #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE | ||
457 | |||
458 | if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && | ||
459 | ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { | ||
460 | /* | ||
461 | * We want to skip If/Else/While constructs during Pass1 because we | ||
462 | * want to actually conditionally execute the code during Pass2. | ||
463 | * | ||
464 | * Except for disassembly, where we always want to walk the | ||
465 | * If/Else/While packages | ||
466 | */ | ||
467 | switch (op->common.aml_opcode) { | ||
468 | case AML_IF_OP: | ||
469 | case AML_ELSE_OP: | ||
470 | case AML_WHILE_OP: | ||
471 | |||
472 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
473 | "Pass1: Skipping an If/Else/While body\n")); | ||
474 | |||
475 | /* Skip body of if/else/while in pass 1 */ | ||
476 | |||
477 | walk_state->parser_state.aml = | ||
478 | walk_state->parser_state.pkg_end; | ||
479 | walk_state->arg_count = 0; | ||
480 | break; | ||
481 | |||
482 | default: | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | #endif | ||
487 | |||
488 | switch (op->common.aml_opcode) { | ||
489 | case AML_METHOD_OP: | ||
490 | /* | ||
491 | * Skip parsing of control method because we don't have enough | ||
492 | * info in the first pass to parse it correctly. | ||
493 | * | ||
494 | * Save the length and address of the body | ||
495 | */ | ||
496 | op->named.data = walk_state->parser_state.aml; | ||
497 | op->named.length = (u32) | ||
498 | (walk_state->parser_state.pkg_end - | ||
499 | walk_state->parser_state.aml); | ||
500 | |||
501 | /* Skip body of method */ | ||
502 | |||
503 | walk_state->parser_state.aml = | ||
504 | walk_state->parser_state.pkg_end; | ||
505 | walk_state->arg_count = 0; | ||
506 | break; | ||
507 | |||
508 | case AML_BUFFER_OP: | ||
509 | case AML_PACKAGE_OP: | ||
510 | case AML_VAR_PACKAGE_OP: | ||
511 | |||
512 | if ((op->common.parent) && | ||
513 | (op->common.parent->common.aml_opcode == | ||
514 | AML_NAME_OP) | ||
515 | && (walk_state->pass_number <= | ||
516 | ACPI_IMODE_LOAD_PASS2)) { | ||
517 | /* | ||
518 | * Skip parsing of Buffers and Packages because we don't have | ||
519 | * enough info in the first pass to parse them correctly. | ||
520 | */ | ||
521 | op->named.data = aml_op_start; | ||
522 | op->named.length = (u32) | ||
523 | (walk_state->parser_state.pkg_end - | ||
524 | aml_op_start); | ||
525 | |||
526 | /* Skip body */ | ||
527 | |||
528 | walk_state->parser_state.aml = | ||
529 | walk_state->parser_state.pkg_end; | ||
530 | walk_state->arg_count = 0; | ||
531 | } | ||
532 | break; | ||
533 | |||
534 | case AML_WHILE_OP: | ||
535 | |||
536 | if (walk_state->control_state) { | ||
537 | walk_state->control_state->control.package_end = | ||
538 | walk_state->parser_state.pkg_end; | ||
539 | } | ||
540 | break; | ||
541 | |||
542 | default: | ||
543 | |||
544 | /* No action for all other opcodes */ | ||
545 | break; | ||
546 | } | ||
547 | |||
548 | break; | ||
549 | } | ||
550 | |||
551 | return_ACPI_STATUS(AE_OK); | ||
552 | } | ||
553 | |||
554 | /******************************************************************************* | ||
555 | * | ||
556 | * FUNCTION: acpi_ps_complete_op | ||
557 | * | ||
558 | * PARAMETERS: walk_state - Current state | ||
559 | * Op - Returned Op | ||
560 | * Status - Parse status before complete Op | ||
561 | * | ||
562 | * RETURN: Status | ||
563 | * | ||
564 | * DESCRIPTION: Complete Op | ||
565 | * | ||
566 | ******************************************************************************/ | ||
567 | |||
568 | static acpi_status | ||
569 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
570 | union acpi_parse_object **op, acpi_status status) | ||
571 | { | ||
572 | acpi_status status2; | ||
573 | |||
574 | ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state); | ||
575 | |||
576 | /* | ||
577 | * Finished one argument of the containing scope | ||
578 | */ | ||
579 | walk_state->parser_state.scope->parse_scope.arg_count--; | ||
580 | |||
581 | /* Close this Op (will result in parse subtree deletion) */ | ||
582 | |||
583 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
584 | if (ACPI_FAILURE(status2)) { | ||
585 | return_ACPI_STATUS(status2); | ||
586 | } | ||
587 | |||
588 | *op = NULL; | ||
589 | |||
590 | switch (status) { | ||
591 | case AE_OK: | ||
592 | break; | ||
593 | |||
594 | case AE_CTRL_TRANSFER: | ||
595 | |||
596 | /* We are about to transfer to a called method */ | ||
597 | |||
598 | walk_state->prev_op = NULL; | ||
599 | walk_state->prev_arg_types = walk_state->arg_types; | ||
600 | return_ACPI_STATUS(status); | ||
601 | |||
602 | case AE_CTRL_END: | ||
603 | |||
604 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
605 | &walk_state->arg_types, | ||
606 | &walk_state->arg_count); | ||
607 | |||
608 | if (*op) { | ||
609 | walk_state->op = *op; | ||
610 | walk_state->op_info = | ||
611 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
612 | walk_state->opcode = (*op)->common.aml_opcode; | ||
613 | |||
614 | status = walk_state->ascending_callback(walk_state); | ||
615 | status = | ||
616 | acpi_ps_next_parse_state(walk_state, *op, status); | ||
617 | |||
618 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
619 | if (ACPI_FAILURE(status2)) { | ||
620 | return_ACPI_STATUS(status2); | ||
621 | } | ||
622 | } | ||
623 | |||
624 | status = AE_OK; | ||
625 | break; | ||
626 | |||
627 | case AE_CTRL_BREAK: | ||
628 | case AE_CTRL_CONTINUE: | ||
629 | |||
630 | /* Pop off scopes until we find the While */ | ||
631 | |||
632 | while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) { | ||
633 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
634 | &walk_state->arg_types, | ||
635 | &walk_state->arg_count); | ||
636 | } | ||
637 | |||
638 | /* Close this iteration of the While loop */ | ||
639 | |||
640 | walk_state->op = *op; | ||
641 | walk_state->op_info = | ||
642 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
643 | walk_state->opcode = (*op)->common.aml_opcode; | ||
644 | |||
645 | status = walk_state->ascending_callback(walk_state); | ||
646 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
647 | |||
648 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
649 | if (ACPI_FAILURE(status2)) { | ||
650 | return_ACPI_STATUS(status2); | ||
651 | } | ||
652 | |||
653 | status = AE_OK; | ||
654 | break; | ||
655 | |||
656 | case AE_CTRL_TERMINATE: | ||
657 | |||
658 | /* Clean up */ | ||
659 | do { | ||
660 | if (*op) { | ||
661 | status2 = | ||
662 | acpi_ps_complete_this_op(walk_state, *op); | ||
663 | if (ACPI_FAILURE(status2)) { | ||
664 | return_ACPI_STATUS(status2); | ||
665 | } | ||
666 | |||
667 | acpi_ut_delete_generic_state | ||
668 | (acpi_ut_pop_generic_state | ||
669 | (&walk_state->control_state)); | ||
670 | } | ||
671 | |||
672 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
673 | &walk_state->arg_types, | ||
674 | &walk_state->arg_count); | ||
675 | |||
676 | } while (*op); | ||
677 | |||
678 | return_ACPI_STATUS(AE_OK); | ||
679 | |||
680 | default: /* All other non-AE_OK status */ | ||
681 | |||
682 | do { | ||
683 | if (*op) { | ||
684 | status2 = | ||
685 | acpi_ps_complete_this_op(walk_state, *op); | ||
686 | if (ACPI_FAILURE(status2)) { | ||
687 | return_ACPI_STATUS(status2); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
692 | &walk_state->arg_types, | ||
693 | &walk_state->arg_count); | ||
694 | |||
695 | } while (*op); | ||
696 | |||
697 | #if 0 | ||
698 | /* | ||
699 | * TBD: Cleanup parse ops on error | ||
700 | */ | ||
701 | if (*op == NULL) { | ||
702 | acpi_ps_pop_scope(parser_state, op, | ||
703 | &walk_state->arg_types, | ||
704 | &walk_state->arg_count); | ||
705 | } | ||
706 | #endif | ||
707 | walk_state->prev_op = NULL; | ||
708 | walk_state->prev_arg_types = walk_state->arg_types; | ||
709 | return_ACPI_STATUS(status); | ||
710 | } | ||
711 | |||
712 | /* This scope complete? */ | ||
713 | |||
714 | if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) { | ||
715 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
716 | &walk_state->arg_types, | ||
717 | &walk_state->arg_count); | ||
718 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op)); | ||
719 | } else { | ||
720 | *op = NULL; | ||
721 | } | ||
722 | |||
723 | ACPI_PREEMPTION_POINT(); | ||
724 | |||
725 | return_ACPI_STATUS(AE_OK); | ||
726 | } | ||
727 | |||
728 | /******************************************************************************* | ||
729 | * | ||
730 | * FUNCTION: acpi_ps_complete_final_op | ||
731 | * | ||
732 | * PARAMETERS: walk_state - Current state | ||
733 | * Op - Current Op | ||
734 | * Status - Current parse status before complete last | ||
735 | * Op | ||
736 | * | ||
737 | * RETURN: Status | ||
738 | * | ||
739 | * DESCRIPTION: Complete last Op. | ||
740 | * | ||
741 | ******************************************************************************/ | ||
742 | |||
743 | static acpi_status | ||
744 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
745 | union acpi_parse_object *op, acpi_status status) | ||
746 | { | ||
747 | acpi_status status2; | ||
748 | |||
749 | ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state); | ||
750 | |||
751 | /* | ||
752 | * Complete the last Op (if not completed), and clear the scope stack. | ||
753 | * It is easily possible to end an AML "package" with an unbounded number | ||
754 | * of open scopes (such as when several ASL blocks are closed with | ||
755 | * sequential closing braces). We want to terminate each one cleanly. | ||
756 | */ | ||
757 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n", | ||
758 | op)); | ||
759 | do { | ||
760 | if (op) { | ||
761 | if (walk_state->ascending_callback != NULL) { | ||
762 | walk_state->op = op; | ||
763 | walk_state->op_info = | ||
764 | acpi_ps_get_opcode_info(op->common. | ||
765 | aml_opcode); | ||
766 | walk_state->opcode = op->common.aml_opcode; | ||
767 | |||
768 | status = | ||
769 | walk_state->ascending_callback(walk_state); | ||
770 | status = | ||
771 | acpi_ps_next_parse_state(walk_state, op, | ||
772 | status); | ||
773 | if (status == AE_CTRL_PENDING) { | ||
774 | status = | ||
775 | acpi_ps_complete_op(walk_state, &op, | ||
776 | AE_OK); | ||
777 | if (ACPI_FAILURE(status)) { | ||
778 | return_ACPI_STATUS(status); | ||
779 | } | ||
780 | } | ||
781 | |||
782 | if (status == AE_CTRL_TERMINATE) { | ||
783 | status = AE_OK; | ||
784 | |||
785 | /* Clean up */ | ||
786 | do { | ||
787 | if (op) { | ||
788 | status2 = | ||
789 | acpi_ps_complete_this_op | ||
790 | (walk_state, op); | ||
791 | if (ACPI_FAILURE | ||
792 | (status2)) { | ||
793 | return_ACPI_STATUS | ||
794 | (status2); | ||
795 | } | ||
796 | } | ||
797 | |||
798 | acpi_ps_pop_scope(& | ||
799 | (walk_state-> | ||
800 | parser_state), | ||
801 | &op, | ||
802 | &walk_state-> | ||
803 | arg_types, | ||
804 | &walk_state-> | ||
805 | arg_count); | ||
806 | |||
807 | } while (op); | ||
808 | |||
809 | return_ACPI_STATUS(status); | ||
810 | } | ||
811 | |||
812 | else if (ACPI_FAILURE(status)) { | ||
813 | |||
814 | /* First error is most important */ | ||
815 | |||
816 | (void) | ||
817 | acpi_ps_complete_this_op(walk_state, | ||
818 | op); | ||
819 | return_ACPI_STATUS(status); | ||
820 | } | ||
821 | } | ||
822 | |||
823 | status2 = acpi_ps_complete_this_op(walk_state, op); | ||
824 | if (ACPI_FAILURE(status2)) { | ||
825 | return_ACPI_STATUS(status2); | ||
826 | } | ||
827 | } | ||
828 | |||
829 | acpi_ps_pop_scope(&(walk_state->parser_state), &op, | ||
830 | &walk_state->arg_types, | ||
831 | &walk_state->arg_count); | ||
832 | |||
833 | } while (op); | ||
834 | |||
835 | return_ACPI_STATUS(status); | ||
836 | } | ||
837 | |||
838 | /******************************************************************************* | ||
839 | * | ||
840 | * FUNCTION: acpi_ps_parse_loop | ||
841 | * | ||
842 | * PARAMETERS: walk_state - Current state | ||
843 | * | ||
844 | * RETURN: Status | ||
845 | * | ||
846 | * DESCRIPTION: Parse AML (pointed to by the current parser state) and return | ||
847 | * a tree of ops. | ||
848 | * | ||
849 | ******************************************************************************/ | ||
850 | |||
851 | acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) | ||
852 | { | ||
853 | acpi_status status = AE_OK; | ||
854 | union acpi_parse_object *op = NULL; /* current op */ | ||
855 | struct acpi_parse_state *parser_state; | ||
856 | u8 *aml_op_start = NULL; | ||
857 | |||
858 | ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state); | ||
859 | |||
860 | if (walk_state->descending_callback == NULL) { | ||
861 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
862 | } | ||
863 | |||
864 | parser_state = &walk_state->parser_state; | ||
865 | walk_state->arg_types = 0; | ||
866 | |||
867 | #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) | ||
868 | |||
869 | if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { | ||
870 | |||
871 | /* We are restarting a preempted control method */ | ||
872 | |||
873 | if (acpi_ps_has_completed_scope(parser_state)) { | ||
874 | /* | ||
875 | * We must check if a predicate to an IF or WHILE statement | ||
876 | * was just completed | ||
877 | */ | ||
878 | if ((parser_state->scope->parse_scope.op) && | ||
879 | ((parser_state->scope->parse_scope.op->common. | ||
880 | aml_opcode == AML_IF_OP) | ||
881 | || (parser_state->scope->parse_scope.op->common. | ||
882 | aml_opcode == AML_WHILE_OP)) | ||
883 | && (walk_state->control_state) | ||
884 | && (walk_state->control_state->common.state == | ||
885 | ACPI_CONTROL_PREDICATE_EXECUTING)) { | ||
886 | /* | ||
887 | * A predicate was just completed, get the value of the | ||
888 | * predicate and branch based on that value | ||
889 | */ | ||
890 | walk_state->op = NULL; | ||
891 | status = | ||
892 | acpi_ds_get_predicate_value(walk_state, | ||
893 | ACPI_TO_POINTER | ||
894 | (TRUE)); | ||
895 | if (ACPI_FAILURE(status) | ||
896 | && ((status & AE_CODE_MASK) != | ||
897 | AE_CODE_CONTROL)) { | ||
898 | if (status == AE_AML_NO_RETURN_VALUE) { | ||
899 | ACPI_EXCEPTION((AE_INFO, status, | ||
900 | "Invoked method did not return a value")); | ||
901 | |||
902 | } | ||
903 | |||
904 | ACPI_EXCEPTION((AE_INFO, status, | ||
905 | "GetPredicate Failed")); | ||
906 | return_ACPI_STATUS(status); | ||
907 | } | ||
908 | |||
909 | status = | ||
910 | acpi_ps_next_parse_state(walk_state, op, | ||
911 | status); | ||
912 | } | ||
913 | |||
914 | acpi_ps_pop_scope(parser_state, &op, | ||
915 | &walk_state->arg_types, | ||
916 | &walk_state->arg_count); | ||
917 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
918 | "Popped scope, Op=%p\n", op)); | ||
919 | } else if (walk_state->prev_op) { | ||
920 | |||
921 | /* We were in the middle of an op */ | ||
922 | |||
923 | op = walk_state->prev_op; | ||
924 | walk_state->arg_types = walk_state->prev_arg_types; | ||
925 | } | ||
926 | } | ||
927 | #endif | ||
928 | |||
929 | /* Iterative parsing loop, while there is more AML to process: */ | ||
930 | |||
931 | while ((parser_state->aml < parser_state->aml_end) || (op)) { | ||
932 | aml_op_start = parser_state->aml; | ||
933 | if (!op) { | ||
934 | status = | ||
935 | acpi_ps_create_op(walk_state, aml_op_start, &op); | ||
936 | if (ACPI_FAILURE(status)) { | ||
937 | if (status == AE_CTRL_PARSE_CONTINUE) { | ||
938 | continue; | ||
939 | } | ||
940 | |||
941 | if (status == AE_CTRL_PARSE_PENDING) { | ||
942 | status = AE_OK; | ||
943 | } | ||
944 | |||
945 | status = | ||
946 | acpi_ps_complete_op(walk_state, &op, | ||
947 | status); | ||
948 | if (ACPI_FAILURE(status)) { | ||
949 | return_ACPI_STATUS(status); | ||
950 | } | ||
951 | |||
952 | continue; | ||
953 | } | ||
954 | |||
955 | op->common.aml_offset = walk_state->aml_offset; | ||
956 | |||
957 | if (walk_state->op_info) { | ||
958 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
959 | "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", | ||
960 | (u32) op->common.aml_opcode, | ||
961 | walk_state->op_info->name, op, | ||
962 | parser_state->aml, | ||
963 | op->common.aml_offset)); | ||
964 | } | ||
965 | } | ||
966 | |||
967 | /* | ||
968 | * Start arg_count at zero because we don't know if there are | ||
969 | * any args yet | ||
970 | */ | ||
971 | walk_state->arg_count = 0; | ||
972 | |||
973 | /* Are there any arguments that must be processed? */ | ||
974 | |||
975 | if (walk_state->arg_types) { | ||
976 | |||
977 | /* Get arguments */ | ||
978 | |||
979 | status = | ||
980 | acpi_ps_get_arguments(walk_state, aml_op_start, op); | ||
981 | if (ACPI_FAILURE(status)) { | ||
982 | status = | ||
983 | acpi_ps_complete_op(walk_state, &op, | ||
984 | status); | ||
985 | if (ACPI_FAILURE(status)) { | ||
986 | return_ACPI_STATUS(status); | ||
987 | } | ||
988 | |||
989 | continue; | ||
990 | } | ||
991 | } | ||
992 | |||
993 | /* Check for arguments that need to be processed */ | ||
994 | |||
995 | if (walk_state->arg_count) { | ||
996 | /* | ||
997 | * There are arguments (complex ones), push Op and | ||
998 | * prepare for argument | ||
999 | */ | ||
1000 | status = acpi_ps_push_scope(parser_state, op, | ||
1001 | walk_state->arg_types, | ||
1002 | walk_state->arg_count); | ||
1003 | if (ACPI_FAILURE(status)) { | ||
1004 | status = | ||
1005 | acpi_ps_complete_op(walk_state, &op, | ||
1006 | status); | ||
1007 | if (ACPI_FAILURE(status)) { | ||
1008 | return_ACPI_STATUS(status); | ||
1009 | } | ||
1010 | |||
1011 | continue; | ||
1012 | } | ||
1013 | |||
1014 | op = NULL; | ||
1015 | continue; | ||
1016 | } | ||
1017 | |||
1018 | /* | ||
1019 | * All arguments have been processed -- Op is complete, | ||
1020 | * prepare for next | ||
1021 | */ | ||
1022 | walk_state->op_info = | ||
1023 | acpi_ps_get_opcode_info(op->common.aml_opcode); | ||
1024 | if (walk_state->op_info->flags & AML_NAMED) { | ||
1025 | if (acpi_gbl_depth) { | ||
1026 | acpi_gbl_depth--; | ||
1027 | } | ||
1028 | |||
1029 | if (op->common.aml_opcode == AML_REGION_OP || | ||
1030 | op->common.aml_opcode == AML_DATA_REGION_OP) { | ||
1031 | /* | ||
1032 | * Skip parsing of control method or opregion body, | ||
1033 | * because we don't have enough info in the first pass | ||
1034 | * to parse them correctly. | ||
1035 | * | ||
1036 | * Completed parsing an op_region declaration, we now | ||
1037 | * know the length. | ||
1038 | */ | ||
1039 | op->named.length = | ||
1040 | (u32) (parser_state->aml - op->named.data); | ||
1041 | } | ||
1042 | } | ||
1043 | |||
1044 | if (walk_state->op_info->flags & AML_CREATE) { | ||
1045 | /* | ||
1046 | * Backup to beginning of create_xXXfield declaration (1 for | ||
1047 | * Opcode) | ||
1048 | * | ||
1049 | * body_length is unknown until we parse the body | ||
1050 | */ | ||
1051 | op->named.length = | ||
1052 | (u32) (parser_state->aml - op->named.data); | ||
1053 | } | ||
1054 | |||
1055 | if (op->common.aml_opcode == AML_BANK_FIELD_OP) { | ||
1056 | /* | ||
1057 | * Backup to beginning of bank_field declaration | ||
1058 | * | ||
1059 | * body_length is unknown until we parse the body | ||
1060 | */ | ||
1061 | op->named.length = | ||
1062 | (u32) (parser_state->aml - op->named.data); | ||
1063 | } | ||
1064 | |||
1065 | /* This op complete, notify the dispatcher */ | ||
1066 | |||
1067 | if (walk_state->ascending_callback != NULL) { | ||
1068 | walk_state->op = op; | ||
1069 | walk_state->opcode = op->common.aml_opcode; | ||
1070 | |||
1071 | status = walk_state->ascending_callback(walk_state); | ||
1072 | status = | ||
1073 | acpi_ps_next_parse_state(walk_state, op, status); | ||
1074 | if (status == AE_CTRL_PENDING) { | ||
1075 | status = AE_OK; | ||
1076 | } | ||
1077 | } | ||
1078 | |||
1079 | status = acpi_ps_complete_op(walk_state, &op, status); | ||
1080 | if (ACPI_FAILURE(status)) { | ||
1081 | return_ACPI_STATUS(status); | ||
1082 | } | ||
1083 | |||
1084 | } /* while parser_state->Aml */ | ||
1085 | |||
1086 | status = acpi_ps_complete_final_op(walk_state, op, status); | ||
1087 | return_ACPI_STATUS(status); | ||
1088 | } | ||
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c deleted file mode 100644 index 3693a121b347..000000000000 --- a/drivers/acpi/parser/psopcode.c +++ /dev/null | |||
@@ -1,810 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psopcode - Parser/Interpreter opcode information table | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | #include <acpi/acopcode.h> | ||
48 | #include <acpi/amlcode.h> | ||
49 | |||
50 | #define _COMPONENT ACPI_PARSER | ||
51 | ACPI_MODULE_NAME("psopcode") | ||
52 | |||
53 | static const u8 acpi_gbl_argument_count[] = | ||
54 | { 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 }; | ||
55 | |||
56 | /******************************************************************************* | ||
57 | * | ||
58 | * NAME: acpi_gbl_aml_op_info | ||
59 | * | ||
60 | * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands> | ||
61 | * The name is a simple ascii string, the operand specifier is an | ||
62 | * ascii string with one letter per operand. The letter specifies | ||
63 | * the operand type. | ||
64 | * | ||
65 | ******************************************************************************/ | ||
66 | |||
67 | /* | ||
68 | * Summary of opcode types/flags | ||
69 | * | ||
70 | |||
71 | Opcodes that have associated namespace objects (AML_NSOBJECT flag) | ||
72 | |||
73 | AML_SCOPE_OP | ||
74 | AML_DEVICE_OP | ||
75 | AML_THERMAL_ZONE_OP | ||
76 | AML_METHOD_OP | ||
77 | AML_POWER_RES_OP | ||
78 | AML_PROCESSOR_OP | ||
79 | AML_FIELD_OP | ||
80 | AML_INDEX_FIELD_OP | ||
81 | AML_BANK_FIELD_OP | ||
82 | AML_NAME_OP | ||
83 | AML_ALIAS_OP | ||
84 | AML_MUTEX_OP | ||
85 | AML_EVENT_OP | ||
86 | AML_REGION_OP | ||
87 | AML_CREATE_FIELD_OP | ||
88 | AML_CREATE_BIT_FIELD_OP | ||
89 | AML_CREATE_BYTE_FIELD_OP | ||
90 | AML_CREATE_WORD_FIELD_OP | ||
91 | AML_CREATE_DWORD_FIELD_OP | ||
92 | AML_CREATE_QWORD_FIELD_OP | ||
93 | AML_INT_NAMEDFIELD_OP | ||
94 | AML_INT_METHODCALL_OP | ||
95 | AML_INT_NAMEPATH_OP | ||
96 | |||
97 | Opcodes that are "namespace" opcodes (AML_NSOPCODE flag) | ||
98 | |||
99 | AML_SCOPE_OP | ||
100 | AML_DEVICE_OP | ||
101 | AML_THERMAL_ZONE_OP | ||
102 | AML_METHOD_OP | ||
103 | AML_POWER_RES_OP | ||
104 | AML_PROCESSOR_OP | ||
105 | AML_FIELD_OP | ||
106 | AML_INDEX_FIELD_OP | ||
107 | AML_BANK_FIELD_OP | ||
108 | AML_NAME_OP | ||
109 | AML_ALIAS_OP | ||
110 | AML_MUTEX_OP | ||
111 | AML_EVENT_OP | ||
112 | AML_REGION_OP | ||
113 | AML_INT_NAMEDFIELD_OP | ||
114 | |||
115 | Opcodes that have an associated namespace node (AML_NSNODE flag) | ||
116 | |||
117 | AML_SCOPE_OP | ||
118 | AML_DEVICE_OP | ||
119 | AML_THERMAL_ZONE_OP | ||
120 | AML_METHOD_OP | ||
121 | AML_POWER_RES_OP | ||
122 | AML_PROCESSOR_OP | ||
123 | AML_NAME_OP | ||
124 | AML_ALIAS_OP | ||
125 | AML_MUTEX_OP | ||
126 | AML_EVENT_OP | ||
127 | AML_REGION_OP | ||
128 | AML_CREATE_FIELD_OP | ||
129 | AML_CREATE_BIT_FIELD_OP | ||
130 | AML_CREATE_BYTE_FIELD_OP | ||
131 | AML_CREATE_WORD_FIELD_OP | ||
132 | AML_CREATE_DWORD_FIELD_OP | ||
133 | AML_CREATE_QWORD_FIELD_OP | ||
134 | AML_INT_NAMEDFIELD_OP | ||
135 | AML_INT_METHODCALL_OP | ||
136 | AML_INT_NAMEPATH_OP | ||
137 | |||
138 | Opcodes that define named ACPI objects (AML_NAMED flag) | ||
139 | |||
140 | AML_SCOPE_OP | ||
141 | AML_DEVICE_OP | ||
142 | AML_THERMAL_ZONE_OP | ||
143 | AML_METHOD_OP | ||
144 | AML_POWER_RES_OP | ||
145 | AML_PROCESSOR_OP | ||
146 | AML_NAME_OP | ||
147 | AML_ALIAS_OP | ||
148 | AML_MUTEX_OP | ||
149 | AML_EVENT_OP | ||
150 | AML_REGION_OP | ||
151 | AML_INT_NAMEDFIELD_OP | ||
152 | |||
153 | Opcodes that contain executable AML as part of the definition that | ||
154 | must be deferred until needed | ||
155 | |||
156 | AML_METHOD_OP | ||
157 | AML_VAR_PACKAGE_OP | ||
158 | AML_CREATE_FIELD_OP | ||
159 | AML_CREATE_BIT_FIELD_OP | ||
160 | AML_CREATE_BYTE_FIELD_OP | ||
161 | AML_CREATE_WORD_FIELD_OP | ||
162 | AML_CREATE_DWORD_FIELD_OP | ||
163 | AML_CREATE_QWORD_FIELD_OP | ||
164 | AML_REGION_OP | ||
165 | AML_BUFFER_OP | ||
166 | |||
167 | Field opcodes | ||
168 | |||
169 | AML_CREATE_FIELD_OP | ||
170 | AML_FIELD_OP | ||
171 | AML_INDEX_FIELD_OP | ||
172 | AML_BANK_FIELD_OP | ||
173 | |||
174 | Field "Create" opcodes | ||
175 | |||
176 | AML_CREATE_FIELD_OP | ||
177 | AML_CREATE_BIT_FIELD_OP | ||
178 | AML_CREATE_BYTE_FIELD_OP | ||
179 | AML_CREATE_WORD_FIELD_OP | ||
180 | AML_CREATE_DWORD_FIELD_OP | ||
181 | AML_CREATE_QWORD_FIELD_OP | ||
182 | |||
183 | ******************************************************************************/ | ||
184 | |||
185 | /* | ||
186 | * Master Opcode information table. A summary of everything we know about each | ||
187 | * opcode, all in one place. | ||
188 | */ | ||
189 | const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | ||
190 | /*! [Begin] no source code translation */ | ||
191 | /* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ | ||
192 | |||
193 | /* 00 */ ACPI_OP("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, | ||
194 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | ||
195 | /* 01 */ ACPI_OP("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, | ||
196 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | ||
197 | /* 02 */ ACPI_OP("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, | ||
198 | ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, | ||
199 | AML_TYPE_NAMED_SIMPLE, | ||
200 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
201 | AML_NSNODE | AML_NAMED), | ||
202 | /* 03 */ ACPI_OP("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, | ||
203 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, | ||
204 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
205 | AML_NSNODE | AML_NAMED), | ||
206 | /* 04 */ ACPI_OP("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, | ||
207 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | ||
208 | AML_TYPE_LITERAL, AML_CONSTANT), | ||
209 | /* 05 */ ACPI_OP("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, | ||
210 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | ||
211 | AML_TYPE_LITERAL, AML_CONSTANT), | ||
212 | /* 06 */ ACPI_OP("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, | ||
213 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | ||
214 | AML_TYPE_LITERAL, AML_CONSTANT), | ||
215 | /* 07 */ ACPI_OP("String", ARGP_STRING_OP, ARGI_STRING_OP, | ||
216 | ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, | ||
217 | AML_TYPE_LITERAL, AML_CONSTANT), | ||
218 | /* 08 */ ACPI_OP("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, | ||
219 | ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, | ||
220 | AML_TYPE_NAMED_NO_OBJ, | ||
221 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
222 | AML_NSNODE | AML_NAMED), | ||
223 | /* 09 */ ACPI_OP("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, | ||
224 | ACPI_TYPE_BUFFER, AML_CLASS_CREATE, | ||
225 | AML_TYPE_CREATE_OBJECT, | ||
226 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), | ||
227 | /* 0A */ ACPI_OP("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, | ||
228 | ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, | ||
229 | AML_TYPE_CREATE_OBJECT, | ||
230 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), | ||
231 | /* 0B */ ACPI_OP("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, | ||
232 | ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, | ||
233 | AML_TYPE_NAMED_COMPLEX, | ||
234 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
235 | AML_NSNODE | AML_NAMED | AML_DEFER), | ||
236 | /* 0C */ ACPI_OP("Local0", ARGP_LOCAL0, ARGI_LOCAL0, | ||
237 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
238 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
239 | /* 0D */ ACPI_OP("Local1", ARGP_LOCAL1, ARGI_LOCAL1, | ||
240 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
241 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
242 | /* 0E */ ACPI_OP("Local2", ARGP_LOCAL2, ARGI_LOCAL2, | ||
243 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
244 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
245 | /* 0F */ ACPI_OP("Local3", ARGP_LOCAL3, ARGI_LOCAL3, | ||
246 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
247 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
248 | /* 10 */ ACPI_OP("Local4", ARGP_LOCAL4, ARGI_LOCAL4, | ||
249 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
250 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
251 | /* 11 */ ACPI_OP("Local5", ARGP_LOCAL5, ARGI_LOCAL5, | ||
252 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
253 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
254 | /* 12 */ ACPI_OP("Local6", ARGP_LOCAL6, ARGI_LOCAL6, | ||
255 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
256 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
257 | /* 13 */ ACPI_OP("Local7", ARGP_LOCAL7, ARGI_LOCAL7, | ||
258 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
259 | AML_TYPE_LOCAL_VARIABLE, 0), | ||
260 | /* 14 */ ACPI_OP("Arg0", ARGP_ARG0, ARGI_ARG0, | ||
261 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
262 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
263 | /* 15 */ ACPI_OP("Arg1", ARGP_ARG1, ARGI_ARG1, | ||
264 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
265 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
266 | /* 16 */ ACPI_OP("Arg2", ARGP_ARG2, ARGI_ARG2, | ||
267 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
268 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
269 | /* 17 */ ACPI_OP("Arg3", ARGP_ARG3, ARGI_ARG3, | ||
270 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
271 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
272 | /* 18 */ ACPI_OP("Arg4", ARGP_ARG4, ARGI_ARG4, | ||
273 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
274 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
275 | /* 19 */ ACPI_OP("Arg5", ARGP_ARG5, ARGI_ARG5, | ||
276 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
277 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
278 | /* 1A */ ACPI_OP("Arg6", ARGP_ARG6, ARGI_ARG6, | ||
279 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
280 | AML_TYPE_METHOD_ARGUMENT, 0), | ||
281 | /* 1B */ ACPI_OP("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, | ||
282 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
283 | AML_FLAGS_EXEC_1A_1T_1R), | ||
284 | /* 1C */ ACPI_OP("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, | ||
285 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, | ||
286 | AML_FLAGS_EXEC_1A_0T_1R), | ||
287 | /* 1D */ ACPI_OP("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, | ||
288 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
289 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
290 | /* 1E */ ACPI_OP("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, | ||
291 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
292 | AML_TYPE_EXEC_2A_1T_1R, | ||
293 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | ||
294 | /* 1F */ ACPI_OP("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, | ||
295 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
296 | AML_TYPE_EXEC_2A_1T_1R, | ||
297 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
298 | /* 20 */ ACPI_OP("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, | ||
299 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
300 | AML_TYPE_EXEC_1A_0T_1R, | ||
301 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | ||
302 | /* 21 */ ACPI_OP("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, | ||
303 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
304 | AML_TYPE_EXEC_1A_0T_1R, | ||
305 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | ||
306 | /* 22 */ ACPI_OP("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, | ||
307 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
308 | AML_TYPE_EXEC_2A_1T_1R, | ||
309 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
310 | /* 23 */ ACPI_OP("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, | ||
311 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
312 | AML_TYPE_EXEC_2A_2T_1R, | ||
313 | AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), | ||
314 | /* 24 */ ACPI_OP("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, | ||
315 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
316 | AML_TYPE_EXEC_2A_1T_1R, | ||
317 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
318 | /* 25 */ ACPI_OP("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, | ||
319 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
320 | AML_TYPE_EXEC_2A_1T_1R, | ||
321 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
322 | /* 26 */ ACPI_OP("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, | ||
323 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
324 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
325 | /* 27 */ ACPI_OP("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, | ||
326 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
327 | AML_TYPE_EXEC_2A_1T_1R, | ||
328 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
329 | /* 28 */ ACPI_OP("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, | ||
330 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
331 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
332 | /* 29 */ ACPI_OP("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, | ||
333 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
334 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
335 | /* 2A */ ACPI_OP("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, | ||
336 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
337 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | ||
338 | /* 2B */ ACPI_OP("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, | ||
339 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
340 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
341 | /* 2C */ ACPI_OP("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, | ||
342 | ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, | ||
343 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
344 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
345 | /* 2D */ ACPI_OP("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, | ||
346 | ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, | ||
347 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
348 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
349 | /* 2E */ ACPI_OP("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, | ||
350 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
351 | AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), | ||
352 | /* 2F */ ACPI_OP("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, | ||
353 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
354 | AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), | ||
355 | /* 30 */ ACPI_OP("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, | ||
356 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
357 | AML_TYPE_EXEC_1A_0T_1R, | ||
358 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), | ||
359 | /* 31 */ ACPI_OP("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, | ||
360 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
361 | AML_FLAGS_EXEC_2A_1T_1R), | ||
362 | /* 32 */ ACPI_OP("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, | ||
363 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, | ||
364 | AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), | ||
365 | /* 33 */ ACPI_OP("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP, | ||
366 | ARGI_CREATE_DWORD_FIELD_OP, | ||
367 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | ||
368 | AML_TYPE_CREATE_FIELD, | ||
369 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
370 | AML_DEFER | AML_CREATE), | ||
371 | /* 34 */ ACPI_OP("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, | ||
372 | ARGI_CREATE_WORD_FIELD_OP, | ||
373 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | ||
374 | AML_TYPE_CREATE_FIELD, | ||
375 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
376 | AML_DEFER | AML_CREATE), | ||
377 | /* 35 */ ACPI_OP("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, | ||
378 | ARGI_CREATE_BYTE_FIELD_OP, | ||
379 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | ||
380 | AML_TYPE_CREATE_FIELD, | ||
381 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
382 | AML_DEFER | AML_CREATE), | ||
383 | /* 36 */ ACPI_OP("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, | ||
384 | ARGI_CREATE_BIT_FIELD_OP, | ||
385 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | ||
386 | AML_TYPE_CREATE_FIELD, | ||
387 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
388 | AML_DEFER | AML_CREATE), | ||
389 | /* 37 */ ACPI_OP("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, | ||
390 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
391 | AML_TYPE_EXEC_1A_0T_1R, | ||
392 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), | ||
393 | /* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, | ||
394 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | ||
395 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), | ||
396 | /* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, | ||
397 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | ||
398 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), | ||
399 | /* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, | ||
400 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, | ||
401 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | ||
402 | /* 3B */ ACPI_OP("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, | ||
403 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
404 | AML_TYPE_EXEC_2A_0T_1R, | ||
405 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | ||
406 | /* 3C */ ACPI_OP("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, | ||
407 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
408 | AML_TYPE_EXEC_2A_0T_1R, | ||
409 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | ||
410 | /* 3D */ ACPI_OP("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, | ||
411 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | ||
412 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | ||
413 | /* 3E */ ACPI_OP("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, | ||
414 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | ||
415 | /* 3F */ ACPI_OP("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, | ||
416 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | ||
417 | /* 40 */ ACPI_OP("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, | ||
418 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | ||
419 | /* 41 */ ACPI_OP("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, | ||
420 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | ||
421 | /* 42 */ ACPI_OP("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, | ||
422 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, | ||
423 | AML_TYPE_CONTROL, AML_HAS_ARGS), | ||
424 | /* 43 */ ACPI_OP("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, | ||
425 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | ||
426 | /* 44 */ ACPI_OP("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, | ||
427 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | ||
428 | /* 45 */ ACPI_OP("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, | ||
429 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | ||
430 | |||
431 | /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ | ||
432 | |||
433 | /* 46 */ ACPI_OP("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, | ||
434 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, | ||
435 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
436 | AML_NSNODE | AML_NAMED), | ||
437 | /* 47 */ ACPI_OP("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, | ||
438 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, | ||
439 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), | ||
440 | /* 48 */ ACPI_OP("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, | ||
441 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
442 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), | ||
443 | /* 49 */ ACPI_OP("CreateField", ARGP_CREATE_FIELD_OP, | ||
444 | ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, | ||
445 | AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, | ||
446 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
447 | AML_DEFER | AML_FIELD | AML_CREATE), | ||
448 | /* 4A */ ACPI_OP("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, | ||
449 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, | ||
450 | AML_FLAGS_EXEC_1A_1T_0R), | ||
451 | /* 4B */ ACPI_OP("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, | ||
452 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | ||
453 | AML_FLAGS_EXEC_1A_0T_0R), | ||
454 | /* 4C */ ACPI_OP("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, | ||
455 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | ||
456 | AML_FLAGS_EXEC_1A_0T_0R), | ||
457 | /* 4D */ ACPI_OP("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, | ||
458 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
459 | AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), | ||
460 | /* 4E */ ACPI_OP("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, | ||
461 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
462 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | ||
463 | /* 4F */ ACPI_OP("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, | ||
464 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | ||
465 | AML_FLAGS_EXEC_2A_0T_1R), | ||
466 | /* 50 */ ACPI_OP("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, | ||
467 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | ||
468 | AML_FLAGS_EXEC_1A_0T_0R), | ||
469 | /* 51 */ ACPI_OP("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, | ||
470 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
471 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | ||
472 | /* 52 */ ACPI_OP("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, | ||
473 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
474 | AML_TYPE_EXEC_1A_1T_1R, | ||
475 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
476 | /* 53 */ ACPI_OP("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, | ||
477 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
478 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
479 | /* 54 */ ACPI_OP("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, | ||
480 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
481 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | ||
482 | /* 55 */ ACPI_OP("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, | ||
483 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | ||
484 | AML_TYPE_CONSTANT, 0), | ||
485 | /* 56 */ ACPI_OP("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, | ||
486 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
487 | AML_TYPE_CONSTANT, 0), | ||
488 | /* 57 */ ACPI_OP("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, | ||
489 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, | ||
490 | AML_FLAGS_EXEC_3A_0T_0R), | ||
491 | /* 58 */ ACPI_OP("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, | ||
492 | ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, | ||
493 | AML_TYPE_NAMED_COMPLEX, | ||
494 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
495 | AML_NSNODE | AML_NAMED | AML_DEFER), | ||
496 | /* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, | ||
497 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, | ||
498 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), | ||
499 | /* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, | ||
500 | ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, | ||
501 | AML_TYPE_NAMED_NO_OBJ, | ||
502 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
503 | AML_NSNODE | AML_NAMED), | ||
504 | /* 5B */ ACPI_OP("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, | ||
505 | ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, | ||
506 | AML_TYPE_NAMED_SIMPLE, | ||
507 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
508 | AML_NSNODE | AML_NAMED), | ||
509 | /* 5C */ ACPI_OP("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, | ||
510 | ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, | ||
511 | AML_TYPE_NAMED_SIMPLE, | ||
512 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
513 | AML_NSNODE | AML_NAMED), | ||
514 | /* 5D */ ACPI_OP("ThermalZone", ARGP_THERMAL_ZONE_OP, | ||
515 | ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, | ||
516 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, | ||
517 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
518 | AML_NSNODE | AML_NAMED), | ||
519 | /* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, | ||
520 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | ||
521 | AML_TYPE_NAMED_FIELD, | ||
522 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), | ||
523 | /* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, | ||
524 | ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, | ||
525 | AML_TYPE_NAMED_FIELD, | ||
526 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | | ||
527 | AML_DEFER), | ||
528 | |||
529 | /* Internal opcodes that map to invalid AML opcodes */ | ||
530 | |||
531 | /* 60 */ ACPI_OP("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, | ||
532 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | ||
533 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), | ||
534 | /* 61 */ ACPI_OP("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, | ||
535 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | ||
536 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), | ||
537 | /* 62 */ ACPI_OP("LGreaterEqual", ARGP_LGREATEREQUAL_OP, | ||
538 | ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, | ||
539 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, | ||
540 | AML_HAS_ARGS | AML_CONSTANT), | ||
541 | /* 63 */ ACPI_OP("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, | ||
542 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | ||
543 | AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE), | ||
544 | /* 64 */ ACPI_OP("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, | ||
545 | ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, | ||
546 | AML_TYPE_METHOD_CALL, | ||
547 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), | ||
548 | /* 65 */ ACPI_OP("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, | ||
549 | ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, | ||
550 | AML_TYPE_LITERAL, 0), | ||
551 | /* 66 */ ACPI_OP("-ReservedField-", ARGP_RESERVEDFIELD_OP, | ||
552 | ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, | ||
553 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | ||
554 | /* 67 */ ACPI_OP("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, | ||
555 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | ||
556 | AML_TYPE_BOGUS, | ||
557 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), | ||
558 | /* 68 */ ACPI_OP("-AccessField-", ARGP_ACCESSFIELD_OP, | ||
559 | ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, | ||
560 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | ||
561 | /* 69 */ ACPI_OP("-StaticString", ARGP_STATICSTRING_OP, | ||
562 | ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, | ||
563 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | ||
564 | /* 6A */ ACPI_OP("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | ||
565 | AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, | ||
566 | AML_HAS_ARGS | AML_HAS_RETVAL), | ||
567 | /* 6B */ ACPI_OP("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, | ||
568 | AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), | ||
569 | /* 6C */ ACPI_OP("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | ||
570 | AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), | ||
571 | /* 6D */ ACPI_OP("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | ||
572 | AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), | ||
573 | |||
574 | /* ACPI 2.0 opcodes */ | ||
575 | |||
576 | /* 6E */ ACPI_OP("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, | ||
577 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | ||
578 | AML_TYPE_LITERAL, AML_CONSTANT), | ||
579 | /* 6F */ ACPI_OP("Package", /* Var */ ARGP_VAR_PACKAGE_OP, | ||
580 | ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, | ||
581 | AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, | ||
582 | AML_HAS_ARGS | AML_DEFER), | ||
583 | /* 70 */ ACPI_OP("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, | ||
584 | ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, | ||
585 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
586 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | ||
587 | /* 71 */ ACPI_OP("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, | ||
588 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | ||
589 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | ||
590 | /* 72 */ ACPI_OP("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP, | ||
591 | ARGI_CREATE_QWORD_FIELD_OP, | ||
592 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | ||
593 | AML_TYPE_CREATE_FIELD, | ||
594 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | ||
595 | AML_DEFER | AML_CREATE), | ||
596 | /* 73 */ ACPI_OP("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, | ||
597 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
598 | AML_TYPE_EXEC_1A_1T_1R, | ||
599 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
600 | /* 74 */ ACPI_OP("ToDecimalString", ARGP_TO_DEC_STR_OP, | ||
601 | ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, | ||
602 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | ||
603 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
604 | /* 75 */ ACPI_OP("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, | ||
605 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
606 | AML_TYPE_EXEC_1A_1T_1R, | ||
607 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
608 | /* 76 */ ACPI_OP("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, | ||
609 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
610 | AML_TYPE_EXEC_1A_1T_1R, | ||
611 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | ||
612 | /* 77 */ ACPI_OP("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, | ||
613 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
614 | AML_TYPE_EXEC_2A_1T_1R, | ||
615 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | ||
616 | /* 78 */ ACPI_OP("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, | ||
617 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
618 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), | ||
619 | /* 79 */ ACPI_OP("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, | ||
620 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, | ||
621 | AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), | ||
622 | /* 7A */ ACPI_OP("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, | ||
623 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | ||
624 | /* 7B */ ACPI_OP("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, | ||
625 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | ||
626 | AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), | ||
627 | /* 7C */ ACPI_OP("DataTableRegion", ARGP_DATA_REGION_OP, | ||
628 | ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, | ||
629 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, | ||
630 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | ||
631 | AML_NSNODE | AML_NAMED | AML_DEFER), | ||
632 | /* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, | ||
633 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | ||
634 | AML_TYPE_NAMED_NO_OBJ, | ||
635 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), | ||
636 | |||
637 | /* ACPI 3.0 opcodes */ | ||
638 | |||
639 | /* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, | ||
640 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, | ||
641 | AML_FLAGS_EXEC_0A_0T_1R) | ||
642 | |||
643 | /*! [End] no source code translation !*/ | ||
644 | }; | ||
645 | |||
646 | /* | ||
647 | * This table is directly indexed by the opcodes, and returns an | ||
648 | * index into the table above | ||
649 | */ | ||
650 | static const u8 acpi_gbl_short_op_index[256] = { | ||
651 | /* 0 1 2 3 4 5 6 7 */ | ||
652 | /* 8 9 A B C D E F */ | ||
653 | /* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, | ||
654 | /* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, | ||
655 | /* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, | ||
656 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
657 | /* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
658 | /* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, | ||
659 | /* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, | ||
660 | /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
661 | /* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
662 | /* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
663 | /* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
664 | /* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, | ||
665 | /* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, | ||
666 | /* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, | ||
667 | /* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, | ||
668 | /* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, | ||
669 | /* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, | ||
670 | /* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, | ||
671 | /* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, | ||
672 | /* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, | ||
673 | /* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, | ||
674 | /* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
675 | /* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
676 | /* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
677 | /* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
678 | /* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, | ||
679 | /* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
680 | /* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
681 | /* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
682 | /* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
683 | /* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
684 | /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, | ||
685 | }; | ||
686 | |||
687 | /* | ||
688 | * This table is indexed by the second opcode of the extended opcode | ||
689 | * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) | ||
690 | */ | ||
691 | static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { | ||
692 | /* 0 1 2 3 4 5 6 7 */ | ||
693 | /* 8 9 A B C D E F */ | ||
694 | /* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
695 | /* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
696 | /* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, | ||
697 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, | ||
698 | /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, | ||
699 | /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
700 | /* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, | ||
701 | /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
702 | /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
703 | /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
704 | /* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
705 | /* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
706 | /* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
707 | /* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
708 | /* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
709 | /* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
710 | /* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, | ||
711 | /* 0x88 */ 0x7C, | ||
712 | }; | ||
713 | |||
714 | /******************************************************************************* | ||
715 | * | ||
716 | * FUNCTION: acpi_ps_get_opcode_info | ||
717 | * | ||
718 | * PARAMETERS: Opcode - The AML opcode | ||
719 | * | ||
720 | * RETURN: A pointer to the info about the opcode. | ||
721 | * | ||
722 | * DESCRIPTION: Find AML opcode description based on the opcode. | ||
723 | * NOTE: This procedure must ALWAYS return a valid pointer! | ||
724 | * | ||
725 | ******************************************************************************/ | ||
726 | |||
727 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) | ||
728 | { | ||
729 | ACPI_FUNCTION_NAME(ps_get_opcode_info); | ||
730 | |||
731 | /* | ||
732 | * Detect normal 8-bit opcode or extended 16-bit opcode | ||
733 | */ | ||
734 | if (!(opcode & 0xFF00)) { | ||
735 | |||
736 | /* Simple (8-bit) opcode: 0-255, can't index beyond table */ | ||
737 | |||
738 | return (&acpi_gbl_aml_op_info | ||
739 | [acpi_gbl_short_op_index[(u8) opcode]]); | ||
740 | } | ||
741 | |||
742 | if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && | ||
743 | (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { | ||
744 | |||
745 | /* Valid extended (16-bit) opcode */ | ||
746 | |||
747 | return (&acpi_gbl_aml_op_info | ||
748 | [acpi_gbl_long_op_index[(u8) opcode]]); | ||
749 | } | ||
750 | |||
751 | /* Unknown AML opcode */ | ||
752 | |||
753 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
754 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
755 | |||
756 | return (&acpi_gbl_aml_op_info[_UNK]); | ||
757 | } | ||
758 | |||
759 | /******************************************************************************* | ||
760 | * | ||
761 | * FUNCTION: acpi_ps_get_opcode_name | ||
762 | * | ||
763 | * PARAMETERS: Opcode - The AML opcode | ||
764 | * | ||
765 | * RETURN: A pointer to the name of the opcode (ASCII String) | ||
766 | * Note: Never returns NULL. | ||
767 | * | ||
768 | * DESCRIPTION: Translate an opcode into a human-readable string | ||
769 | * | ||
770 | ******************************************************************************/ | ||
771 | |||
772 | char *acpi_ps_get_opcode_name(u16 opcode) | ||
773 | { | ||
774 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) | ||
775 | |||
776 | const struct acpi_opcode_info *op; | ||
777 | |||
778 | op = acpi_ps_get_opcode_info(opcode); | ||
779 | |||
780 | /* Always guaranteed to return a valid pointer */ | ||
781 | |||
782 | return (op->name); | ||
783 | |||
784 | #else | ||
785 | return ("OpcodeName unavailable"); | ||
786 | |||
787 | #endif | ||
788 | } | ||
789 | |||
790 | /******************************************************************************* | ||
791 | * | ||
792 | * FUNCTION: acpi_ps_get_argument_count | ||
793 | * | ||
794 | * PARAMETERS: op_type - Type associated with the AML opcode | ||
795 | * | ||
796 | * RETURN: Argument count | ||
797 | * | ||
798 | * DESCRIPTION: Obtain the number of expected arguments for an AML opcode | ||
799 | * | ||
800 | ******************************************************************************/ | ||
801 | |||
802 | u8 acpi_ps_get_argument_count(u32 op_type) | ||
803 | { | ||
804 | |||
805 | if (op_type <= AML_TYPE_EXEC_6A_0T_1R) { | ||
806 | return (acpi_gbl_argument_count[op_type]); | ||
807 | } | ||
808 | |||
809 | return (0); | ||
810 | } | ||
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c deleted file mode 100644 index 9da48fdb811a..000000000000 --- a/drivers/acpi/parser/psparse.c +++ /dev/null | |||
@@ -1,701 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psparse - Parser top level AML parse routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | * Parse the AML and build an operation tree as most interpreters, | ||
46 | * like Perl, do. Parsing is done by hand rather than with a YACC | ||
47 | * generated parser to tightly constrain stack and dynamic memory | ||
48 | * usage. At the same time, parsing is kept flexible and the code | ||
49 | * fairly compact by parsing based on a list of AML opcode | ||
50 | * templates in aml_op_info[] | ||
51 | */ | ||
52 | |||
53 | #include <acpi/acpi.h> | ||
54 | #include <acpi/accommon.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 | /******************************************************************************* | ||
65 | * | ||
66 | * FUNCTION: acpi_ps_get_opcode_size | ||
67 | * | ||
68 | * PARAMETERS: Opcode - An AML opcode | ||
69 | * | ||
70 | * RETURN: Size of the opcode, in bytes (1 or 2) | ||
71 | * | ||
72 | * DESCRIPTION: Get the size of the current opcode. | ||
73 | * | ||
74 | ******************************************************************************/ | ||
75 | u32 acpi_ps_get_opcode_size(u32 opcode) | ||
76 | { | ||
77 | |||
78 | /* Extended (2-byte) opcode if > 255 */ | ||
79 | |||
80 | if (opcode > 0x00FF) { | ||
81 | return (2); | ||
82 | } | ||
83 | |||
84 | /* Otherwise, just a single byte opcode */ | ||
85 | |||
86 | return (1); | ||
87 | } | ||
88 | |||
89 | /******************************************************************************* | ||
90 | * | ||
91 | * FUNCTION: acpi_ps_peek_opcode | ||
92 | * | ||
93 | * PARAMETERS: parser_state - A parser state object | ||
94 | * | ||
95 | * RETURN: Next AML opcode | ||
96 | * | ||
97 | * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) | ||
98 | * | ||
99 | ******************************************************************************/ | ||
100 | |||
101 | u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state) | ||
102 | { | ||
103 | u8 *aml; | ||
104 | u16 opcode; | ||
105 | |||
106 | aml = parser_state->aml; | ||
107 | opcode = (u16) ACPI_GET8(aml); | ||
108 | |||
109 | if (opcode == AML_EXTENDED_OP_PREFIX) { | ||
110 | |||
111 | /* Extended opcode, get the second opcode byte */ | ||
112 | |||
113 | aml++; | ||
114 | opcode = (u16) ((opcode << 8) | ACPI_GET8(aml)); | ||
115 | } | ||
116 | |||
117 | return (opcode); | ||
118 | } | ||
119 | |||
120 | /******************************************************************************* | ||
121 | * | ||
122 | * FUNCTION: acpi_ps_complete_this_op | ||
123 | * | ||
124 | * PARAMETERS: walk_state - Current State | ||
125 | * Op - Op to complete | ||
126 | * | ||
127 | * RETURN: Status | ||
128 | * | ||
129 | * DESCRIPTION: Perform any cleanup at the completion of an Op. | ||
130 | * | ||
131 | ******************************************************************************/ | ||
132 | |||
133 | acpi_status | ||
134 | acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | ||
135 | union acpi_parse_object * op) | ||
136 | { | ||
137 | union acpi_parse_object *prev; | ||
138 | union acpi_parse_object *next; | ||
139 | const struct acpi_opcode_info *parent_info; | ||
140 | union acpi_parse_object *replacement_op = NULL; | ||
141 | acpi_status status = AE_OK; | ||
142 | |||
143 | ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op); | ||
144 | |||
145 | /* Check for null Op, can happen if AML code is corrupt */ | ||
146 | |||
147 | if (!op) { | ||
148 | return_ACPI_STATUS(AE_OK); /* OK for now */ | ||
149 | } | ||
150 | |||
151 | /* Delete this op and the subtree below it if asked to */ | ||
152 | |||
153 | if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != | ||
154 | ACPI_PARSE_DELETE_TREE) | ||
155 | || (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { | ||
156 | return_ACPI_STATUS(AE_OK); | ||
157 | } | ||
158 | |||
159 | /* Make sure that we only delete this subtree */ | ||
160 | |||
161 | if (op->common.parent) { | ||
162 | prev = op->common.parent->common.value.arg; | ||
163 | if (!prev) { | ||
164 | |||
165 | /* Nothing more to do */ | ||
166 | |||
167 | goto cleanup; | ||
168 | } | ||
169 | |||
170 | /* | ||
171 | * Check if we need to replace the operator and its subtree | ||
172 | * with a return value op (placeholder op) | ||
173 | */ | ||
174 | parent_info = | ||
175 | acpi_ps_get_opcode_info(op->common.parent->common. | ||
176 | aml_opcode); | ||
177 | |||
178 | switch (parent_info->class) { | ||
179 | case AML_CLASS_CONTROL: | ||
180 | break; | ||
181 | |||
182 | case AML_CLASS_CREATE: | ||
183 | |||
184 | /* | ||
185 | * These opcodes contain term_arg operands. The current | ||
186 | * op must be replaced by a placeholder return op | ||
187 | */ | ||
188 | replacement_op = | ||
189 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | ||
190 | if (!replacement_op) { | ||
191 | status = AE_NO_MEMORY; | ||
192 | } | ||
193 | break; | ||
194 | |||
195 | case AML_CLASS_NAMED_OBJECT: | ||
196 | |||
197 | /* | ||
198 | * These opcodes contain term_arg operands. The current | ||
199 | * op must be replaced by a placeholder return op | ||
200 | */ | ||
201 | if ((op->common.parent->common.aml_opcode == | ||
202 | AML_REGION_OP) | ||
203 | || (op->common.parent->common.aml_opcode == | ||
204 | AML_DATA_REGION_OP) | ||
205 | || (op->common.parent->common.aml_opcode == | ||
206 | AML_BUFFER_OP) | ||
207 | || (op->common.parent->common.aml_opcode == | ||
208 | AML_PACKAGE_OP) | ||
209 | || (op->common.parent->common.aml_opcode == | ||
210 | AML_BANK_FIELD_OP) | ||
211 | || (op->common.parent->common.aml_opcode == | ||
212 | AML_VAR_PACKAGE_OP)) { | ||
213 | replacement_op = | ||
214 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | ||
215 | if (!replacement_op) { | ||
216 | status = AE_NO_MEMORY; | ||
217 | } | ||
218 | } else | ||
219 | if ((op->common.parent->common.aml_opcode == | ||
220 | AML_NAME_OP) | ||
221 | && (walk_state->pass_number <= | ||
222 | ACPI_IMODE_LOAD_PASS2)) { | ||
223 | if ((op->common.aml_opcode == AML_BUFFER_OP) | ||
224 | || (op->common.aml_opcode == AML_PACKAGE_OP) | ||
225 | || (op->common.aml_opcode == | ||
226 | AML_VAR_PACKAGE_OP)) { | ||
227 | replacement_op = | ||
228 | acpi_ps_alloc_op(op->common. | ||
229 | aml_opcode); | ||
230 | if (!replacement_op) { | ||
231 | status = AE_NO_MEMORY; | ||
232 | } else { | ||
233 | replacement_op->named.data = | ||
234 | op->named.data; | ||
235 | replacement_op->named.length = | ||
236 | op->named.length; | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | break; | ||
241 | |||
242 | default: | ||
243 | |||
244 | replacement_op = | ||
245 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | ||
246 | if (!replacement_op) { | ||
247 | status = AE_NO_MEMORY; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | /* We must unlink this op from the parent tree */ | ||
252 | |||
253 | if (prev == op) { | ||
254 | |||
255 | /* This op is the first in the list */ | ||
256 | |||
257 | if (replacement_op) { | ||
258 | replacement_op->common.parent = | ||
259 | op->common.parent; | ||
260 | replacement_op->common.value.arg = NULL; | ||
261 | replacement_op->common.node = op->common.node; | ||
262 | op->common.parent->common.value.arg = | ||
263 | replacement_op; | ||
264 | replacement_op->common.next = op->common.next; | ||
265 | } else { | ||
266 | op->common.parent->common.value.arg = | ||
267 | op->common.next; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | /* Search the parent list */ | ||
272 | |||
273 | else | ||
274 | while (prev) { | ||
275 | |||
276 | /* Traverse all siblings in the parent's argument list */ | ||
277 | |||
278 | next = prev->common.next; | ||
279 | if (next == op) { | ||
280 | if (replacement_op) { | ||
281 | replacement_op->common.parent = | ||
282 | op->common.parent; | ||
283 | replacement_op->common.value. | ||
284 | arg = NULL; | ||
285 | replacement_op->common.node = | ||
286 | op->common.node; | ||
287 | prev->common.next = | ||
288 | replacement_op; | ||
289 | replacement_op->common.next = | ||
290 | op->common.next; | ||
291 | next = NULL; | ||
292 | } else { | ||
293 | prev->common.next = | ||
294 | op->common.next; | ||
295 | next = NULL; | ||
296 | } | ||
297 | } | ||
298 | prev = next; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | cleanup: | ||
303 | |||
304 | /* Now we can actually delete the subtree rooted at Op */ | ||
305 | |||
306 | acpi_ps_delete_parse_tree(op); | ||
307 | return_ACPI_STATUS(status); | ||
308 | } | ||
309 | |||
310 | /******************************************************************************* | ||
311 | * | ||
312 | * FUNCTION: acpi_ps_next_parse_state | ||
313 | * | ||
314 | * PARAMETERS: walk_state - Current state | ||
315 | * Op - Current parse op | ||
316 | * callback_status - Status from previous operation | ||
317 | * | ||
318 | * RETURN: Status | ||
319 | * | ||
320 | * DESCRIPTION: Update the parser state based upon the return exception from | ||
321 | * the parser callback. | ||
322 | * | ||
323 | ******************************************************************************/ | ||
324 | |||
325 | acpi_status | ||
326 | acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, | ||
327 | union acpi_parse_object *op, | ||
328 | acpi_status callback_status) | ||
329 | { | ||
330 | struct acpi_parse_state *parser_state = &walk_state->parser_state; | ||
331 | acpi_status status = AE_CTRL_PENDING; | ||
332 | |||
333 | ACPI_FUNCTION_TRACE_PTR(ps_next_parse_state, op); | ||
334 | |||
335 | switch (callback_status) { | ||
336 | case AE_CTRL_TERMINATE: | ||
337 | /* | ||
338 | * A control method was terminated via a RETURN statement. | ||
339 | * The walk of this method is complete. | ||
340 | */ | ||
341 | parser_state->aml = parser_state->aml_end; | ||
342 | status = AE_CTRL_TERMINATE; | ||
343 | break; | ||
344 | |||
345 | case AE_CTRL_BREAK: | ||
346 | |||
347 | parser_state->aml = walk_state->aml_last_while; | ||
348 | walk_state->control_state->common.value = FALSE; | ||
349 | status = AE_CTRL_BREAK; | ||
350 | break; | ||
351 | |||
352 | case AE_CTRL_CONTINUE: | ||
353 | |||
354 | parser_state->aml = walk_state->aml_last_while; | ||
355 | status = AE_CTRL_CONTINUE; | ||
356 | break; | ||
357 | |||
358 | case AE_CTRL_PENDING: | ||
359 | |||
360 | parser_state->aml = walk_state->aml_last_while; | ||
361 | break; | ||
362 | |||
363 | #if 0 | ||
364 | case AE_CTRL_SKIP: | ||
365 | |||
366 | parser_state->aml = parser_state->scope->parse_scope.pkg_end; | ||
367 | status = AE_OK; | ||
368 | break; | ||
369 | #endif | ||
370 | |||
371 | case AE_CTRL_TRUE: | ||
372 | /* | ||
373 | * Predicate of an IF was true, and we are at the matching ELSE. | ||
374 | * Just close out this package | ||
375 | */ | ||
376 | parser_state->aml = acpi_ps_get_next_package_end(parser_state); | ||
377 | status = AE_CTRL_PENDING; | ||
378 | break; | ||
379 | |||
380 | case AE_CTRL_FALSE: | ||
381 | /* | ||
382 | * Either an IF/WHILE Predicate was false or we encountered a BREAK | ||
383 | * opcode. In both cases, we do not execute the rest of the | ||
384 | * package; We simply close out the parent (finishing the walk of | ||
385 | * this branch of the tree) and continue execution at the parent | ||
386 | * level. | ||
387 | */ | ||
388 | parser_state->aml = parser_state->scope->parse_scope.pkg_end; | ||
389 | |||
390 | /* In the case of a BREAK, just force a predicate (if any) to FALSE */ | ||
391 | |||
392 | walk_state->control_state->common.value = FALSE; | ||
393 | status = AE_CTRL_END; | ||
394 | break; | ||
395 | |||
396 | case AE_CTRL_TRANSFER: | ||
397 | |||
398 | /* A method call (invocation) -- transfer control */ | ||
399 | |||
400 | status = AE_CTRL_TRANSFER; | ||
401 | walk_state->prev_op = op; | ||
402 | walk_state->method_call_op = op; | ||
403 | walk_state->method_call_node = | ||
404 | (op->common.value.arg)->common.node; | ||
405 | |||
406 | /* Will return value (if any) be used by the caller? */ | ||
407 | |||
408 | walk_state->return_used = | ||
409 | acpi_ds_is_result_used(op, walk_state); | ||
410 | break; | ||
411 | |||
412 | default: | ||
413 | |||
414 | status = callback_status; | ||
415 | if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) { | ||
416 | status = AE_OK; | ||
417 | } | ||
418 | break; | ||
419 | } | ||
420 | |||
421 | return_ACPI_STATUS(status); | ||
422 | } | ||
423 | |||
424 | /******************************************************************************* | ||
425 | * | ||
426 | * FUNCTION: acpi_ps_parse_aml | ||
427 | * | ||
428 | * PARAMETERS: walk_state - Current state | ||
429 | * | ||
430 | * | ||
431 | * RETURN: Status | ||
432 | * | ||
433 | * DESCRIPTION: Parse raw AML and return a tree of ops | ||
434 | * | ||
435 | ******************************************************************************/ | ||
436 | |||
437 | acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) | ||
438 | { | ||
439 | acpi_status status; | ||
440 | struct acpi_thread_state *thread; | ||
441 | struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; | ||
442 | struct acpi_walk_state *previous_walk_state; | ||
443 | |||
444 | ACPI_FUNCTION_TRACE(ps_parse_aml); | ||
445 | |||
446 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
447 | "Entered with WalkState=%p Aml=%p size=%X\n", | ||
448 | walk_state, walk_state->parser_state.aml, | ||
449 | walk_state->parser_state.aml_size)); | ||
450 | |||
451 | if (!walk_state->parser_state.aml) { | ||
452 | return_ACPI_STATUS(AE_NULL_OBJECT); | ||
453 | } | ||
454 | |||
455 | /* Create and initialize a new thread state */ | ||
456 | |||
457 | thread = acpi_ut_create_thread_state(); | ||
458 | if (!thread) { | ||
459 | if (walk_state->method_desc) { | ||
460 | |||
461 | /* Executing a control method - additional cleanup */ | ||
462 | |||
463 | acpi_ds_terminate_control_method( | ||
464 | walk_state->method_desc, walk_state); | ||
465 | } | ||
466 | |||
467 | acpi_ds_delete_walk_state(walk_state); | ||
468 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
469 | } | ||
470 | |||
471 | walk_state->thread = thread; | ||
472 | |||
473 | /* | ||
474 | * If executing a method, the starting sync_level is this method's | ||
475 | * sync_level | ||
476 | */ | ||
477 | if (walk_state->method_desc) { | ||
478 | walk_state->thread->current_sync_level = | ||
479 | walk_state->method_desc->method.sync_level; | ||
480 | } | ||
481 | |||
482 | acpi_ds_push_walk_state(walk_state, thread); | ||
483 | |||
484 | /* | ||
485 | * This global allows the AML debugger to get a handle to the currently | ||
486 | * executing control method. | ||
487 | */ | ||
488 | acpi_gbl_current_walk_list = thread; | ||
489 | |||
490 | /* | ||
491 | * Execute the walk loop as long as there is a valid Walk State. This | ||
492 | * handles nested control method invocations without recursion. | ||
493 | */ | ||
494 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state)); | ||
495 | |||
496 | status = AE_OK; | ||
497 | while (walk_state) { | ||
498 | if (ACPI_SUCCESS(status)) { | ||
499 | /* | ||
500 | * The parse_loop executes AML until the method terminates | ||
501 | * or calls another method. | ||
502 | */ | ||
503 | status = acpi_ps_parse_loop(walk_state); | ||
504 | } | ||
505 | |||
506 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
507 | "Completed one call to walk loop, %s State=%p\n", | ||
508 | acpi_format_exception(status), walk_state)); | ||
509 | |||
510 | if (status == AE_CTRL_TRANSFER) { | ||
511 | /* | ||
512 | * A method call was detected. | ||
513 | * Transfer control to the called control method | ||
514 | */ | ||
515 | status = | ||
516 | acpi_ds_call_control_method(thread, walk_state, | ||
517 | NULL); | ||
518 | if (ACPI_FAILURE(status)) { | ||
519 | status = | ||
520 | acpi_ds_method_error(status, walk_state); | ||
521 | } | ||
522 | |||
523 | /* | ||
524 | * If the transfer to the new method method call worked, a new walk | ||
525 | * state was created -- get it | ||
526 | */ | ||
527 | walk_state = acpi_ds_get_current_walk_state(thread); | ||
528 | continue; | ||
529 | } else if (status == AE_CTRL_TERMINATE) { | ||
530 | status = AE_OK; | ||
531 | } else if ((status != AE_OK) && (walk_state->method_desc)) { | ||
532 | |||
533 | /* Either the method parse or actual execution failed */ | ||
534 | |||
535 | ACPI_ERROR_METHOD("Method parse/execution failed", | ||
536 | walk_state->method_node, NULL, | ||
537 | status); | ||
538 | |||
539 | /* Check for possible multi-thread reentrancy problem */ | ||
540 | |||
541 | if ((status == AE_ALREADY_EXISTS) && | ||
542 | (!walk_state->method_desc->method.mutex)) { | ||
543 | ACPI_INFO((AE_INFO, | ||
544 | "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", | ||
545 | walk_state->method_node->name. | ||
546 | ascii)); | ||
547 | |||
548 | /* | ||
549 | * Method tried to create an object twice. The probable cause is | ||
550 | * that the method cannot handle reentrancy. | ||
551 | * | ||
552 | * The method is marked not_serialized, but it tried to create | ||
553 | * a named object, causing the second thread entrance to fail. | ||
554 | * Workaround this problem by marking the method permanently | ||
555 | * as Serialized. | ||
556 | */ | ||
557 | walk_state->method_desc->method.method_flags |= | ||
558 | AML_METHOD_SERIALIZED; | ||
559 | walk_state->method_desc->method.sync_level = 0; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | /* We are done with this walk, move on to the parent if any */ | ||
564 | |||
565 | walk_state = acpi_ds_pop_walk_state(thread); | ||
566 | |||
567 | /* Reset the current scope to the beginning of scope stack */ | ||
568 | |||
569 | acpi_ds_scope_stack_clear(walk_state); | ||
570 | |||
571 | /* | ||
572 | * If we just returned from the execution of a control method or if we | ||
573 | * encountered an error during the method parse phase, there's lots of | ||
574 | * cleanup to do | ||
575 | */ | ||
576 | if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == | ||
577 | ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) { | ||
578 | acpi_ds_terminate_control_method(walk_state-> | ||
579 | method_desc, | ||
580 | walk_state); | ||
581 | } | ||
582 | |||
583 | /* Delete this walk state and all linked control states */ | ||
584 | |||
585 | acpi_ps_cleanup_scope(&walk_state->parser_state); | ||
586 | previous_walk_state = walk_state; | ||
587 | |||
588 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
589 | "ReturnValue=%p, ImplicitValue=%p State=%p\n", | ||
590 | walk_state->return_desc, | ||
591 | walk_state->implicit_return_obj, walk_state)); | ||
592 | |||
593 | /* Check if we have restarted a preempted walk */ | ||
594 | |||
595 | walk_state = acpi_ds_get_current_walk_state(thread); | ||
596 | if (walk_state) { | ||
597 | if (ACPI_SUCCESS(status)) { | ||
598 | /* | ||
599 | * There is another walk state, restart it. | ||
600 | * If the method return value is not used by the parent, | ||
601 | * The object is deleted | ||
602 | */ | ||
603 | if (!previous_walk_state->return_desc) { | ||
604 | /* | ||
605 | * In slack mode execution, if there is no return value | ||
606 | * we should implicitly return zero (0) as a default value. | ||
607 | */ | ||
608 | if (acpi_gbl_enable_interpreter_slack && | ||
609 | !previous_walk_state-> | ||
610 | implicit_return_obj) { | ||
611 | previous_walk_state-> | ||
612 | implicit_return_obj = | ||
613 | acpi_ut_create_internal_object | ||
614 | (ACPI_TYPE_INTEGER); | ||
615 | if (!previous_walk_state-> | ||
616 | implicit_return_obj) { | ||
617 | return_ACPI_STATUS | ||
618 | (AE_NO_MEMORY); | ||
619 | } | ||
620 | |||
621 | previous_walk_state-> | ||
622 | implicit_return_obj-> | ||
623 | integer.value = 0; | ||
624 | } | ||
625 | |||
626 | /* Restart the calling control method */ | ||
627 | |||
628 | status = | ||
629 | acpi_ds_restart_control_method | ||
630 | (walk_state, | ||
631 | previous_walk_state-> | ||
632 | implicit_return_obj); | ||
633 | } else { | ||
634 | /* | ||
635 | * We have a valid return value, delete any implicit | ||
636 | * return value. | ||
637 | */ | ||
638 | acpi_ds_clear_implicit_return | ||
639 | (previous_walk_state); | ||
640 | |||
641 | status = | ||
642 | acpi_ds_restart_control_method | ||
643 | (walk_state, | ||
644 | previous_walk_state->return_desc); | ||
645 | } | ||
646 | if (ACPI_SUCCESS(status)) { | ||
647 | walk_state->walk_type |= | ||
648 | ACPI_WALK_METHOD_RESTART; | ||
649 | } | ||
650 | } else { | ||
651 | /* On error, delete any return object or implicit return */ | ||
652 | |||
653 | acpi_ut_remove_reference(previous_walk_state-> | ||
654 | return_desc); | ||
655 | acpi_ds_clear_implicit_return | ||
656 | (previous_walk_state); | ||
657 | } | ||
658 | } | ||
659 | |||
660 | /* | ||
661 | * Just completed a 1st-level method, save the final internal return | ||
662 | * value (if any) | ||
663 | */ | ||
664 | else if (previous_walk_state->caller_return_desc) { | ||
665 | if (previous_walk_state->implicit_return_obj) { | ||
666 | *(previous_walk_state->caller_return_desc) = | ||
667 | previous_walk_state->implicit_return_obj; | ||
668 | } else { | ||
669 | /* NULL if no return value */ | ||
670 | |||
671 | *(previous_walk_state->caller_return_desc) = | ||
672 | previous_walk_state->return_desc; | ||
673 | } | ||
674 | } else { | ||
675 | if (previous_walk_state->return_desc) { | ||
676 | |||
677 | /* Caller doesn't want it, must delete it */ | ||
678 | |||
679 | acpi_ut_remove_reference(previous_walk_state-> | ||
680 | return_desc); | ||
681 | } | ||
682 | if (previous_walk_state->implicit_return_obj) { | ||
683 | |||
684 | /* Caller doesn't want it, must delete it */ | ||
685 | |||
686 | acpi_ut_remove_reference(previous_walk_state-> | ||
687 | implicit_return_obj); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | acpi_ds_delete_walk_state(previous_walk_state); | ||
692 | } | ||
693 | |||
694 | /* Normal exit */ | ||
695 | |||
696 | acpi_ex_release_all_mutexes(thread); | ||
697 | acpi_ut_delete_generic_state(ACPI_CAST_PTR | ||
698 | (union acpi_generic_state, thread)); | ||
699 | acpi_gbl_current_walk_list = prev_walk_list; | ||
700 | return_ACPI_STATUS(status); | ||
701 | } | ||
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c deleted file mode 100644 index 22929ca1ffe4..000000000000 --- a/drivers/acpi/parser/psscope.c +++ /dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psscope - Parser scope stack management routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_PARSER | ||
49 | ACPI_MODULE_NAME("psscope") | ||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_ps_get_parent_scope | ||
54 | * | ||
55 | * PARAMETERS: parser_state - Current parser state object | ||
56 | * | ||
57 | * RETURN: Pointer to an Op object | ||
58 | * | ||
59 | * DESCRIPTION: Get parent of current op being parsed | ||
60 | * | ||
61 | ******************************************************************************/ | ||
62 | union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state | ||
63 | *parser_state) | ||
64 | { | ||
65 | |||
66 | return (parser_state->scope->parse_scope.op); | ||
67 | } | ||
68 | |||
69 | /******************************************************************************* | ||
70 | * | ||
71 | * FUNCTION: acpi_ps_has_completed_scope | ||
72 | * | ||
73 | * PARAMETERS: parser_state - Current parser state object | ||
74 | * | ||
75 | * RETURN: Boolean, TRUE = scope completed. | ||
76 | * | ||
77 | * DESCRIPTION: Is parsing of current argument complete? Determined by | ||
78 | * 1) AML pointer is at or beyond the end of the scope | ||
79 | * 2) The scope argument count has reached zero. | ||
80 | * | ||
81 | ******************************************************************************/ | ||
82 | |||
83 | u8 acpi_ps_has_completed_scope(struct acpi_parse_state * parser_state) | ||
84 | { | ||
85 | |||
86 | return ((u8) | ||
87 | ((parser_state->aml >= parser_state->scope->parse_scope.arg_end | ||
88 | || !parser_state->scope->parse_scope.arg_count))); | ||
89 | } | ||
90 | |||
91 | /******************************************************************************* | ||
92 | * | ||
93 | * FUNCTION: acpi_ps_init_scope | ||
94 | * | ||
95 | * PARAMETERS: parser_state - Current parser state object | ||
96 | * Root - the Root Node of this new scope | ||
97 | * | ||
98 | * RETURN: Status | ||
99 | * | ||
100 | * DESCRIPTION: Allocate and init a new scope object | ||
101 | * | ||
102 | ******************************************************************************/ | ||
103 | |||
104 | acpi_status | ||
105 | acpi_ps_init_scope(struct acpi_parse_state * parser_state, | ||
106 | union acpi_parse_object * root_op) | ||
107 | { | ||
108 | union acpi_generic_state *scope; | ||
109 | |||
110 | ACPI_FUNCTION_TRACE_PTR(ps_init_scope, root_op); | ||
111 | |||
112 | scope = acpi_ut_create_generic_state(); | ||
113 | if (!scope) { | ||
114 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
115 | } | ||
116 | |||
117 | scope->common.descriptor_type = ACPI_DESC_TYPE_STATE_RPSCOPE; | ||
118 | scope->parse_scope.op = root_op; | ||
119 | scope->parse_scope.arg_count = ACPI_VAR_ARGS; | ||
120 | scope->parse_scope.arg_end = parser_state->aml_end; | ||
121 | scope->parse_scope.pkg_end = parser_state->aml_end; | ||
122 | |||
123 | parser_state->scope = scope; | ||
124 | parser_state->start_op = root_op; | ||
125 | |||
126 | return_ACPI_STATUS(AE_OK); | ||
127 | } | ||
128 | |||
129 | /******************************************************************************* | ||
130 | * | ||
131 | * FUNCTION: acpi_ps_push_scope | ||
132 | * | ||
133 | * PARAMETERS: parser_state - Current parser state object | ||
134 | * Op - Current op to be pushed | ||
135 | * remaining_args - List of args remaining | ||
136 | * arg_count - Fixed or variable number of args | ||
137 | * | ||
138 | * RETURN: Status | ||
139 | * | ||
140 | * DESCRIPTION: Push current op to begin parsing its argument | ||
141 | * | ||
142 | ******************************************************************************/ | ||
143 | |||
144 | acpi_status | ||
145 | acpi_ps_push_scope(struct acpi_parse_state *parser_state, | ||
146 | union acpi_parse_object *op, | ||
147 | u32 remaining_args, u32 arg_count) | ||
148 | { | ||
149 | union acpi_generic_state *scope; | ||
150 | |||
151 | ACPI_FUNCTION_TRACE_PTR(ps_push_scope, op); | ||
152 | |||
153 | scope = acpi_ut_create_generic_state(); | ||
154 | if (!scope) { | ||
155 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
156 | } | ||
157 | |||
158 | scope->common.descriptor_type = ACPI_DESC_TYPE_STATE_PSCOPE; | ||
159 | scope->parse_scope.op = op; | ||
160 | scope->parse_scope.arg_list = remaining_args; | ||
161 | scope->parse_scope.arg_count = arg_count; | ||
162 | scope->parse_scope.pkg_end = parser_state->pkg_end; | ||
163 | |||
164 | /* Push onto scope stack */ | ||
165 | |||
166 | acpi_ut_push_generic_state(&parser_state->scope, scope); | ||
167 | |||
168 | if (arg_count == ACPI_VAR_ARGS) { | ||
169 | |||
170 | /* Multiple arguments */ | ||
171 | |||
172 | scope->parse_scope.arg_end = parser_state->pkg_end; | ||
173 | } else { | ||
174 | /* Single argument */ | ||
175 | |||
176 | scope->parse_scope.arg_end = ACPI_TO_POINTER(ACPI_MAX_PTR); | ||
177 | } | ||
178 | |||
179 | return_ACPI_STATUS(AE_OK); | ||
180 | } | ||
181 | |||
182 | /******************************************************************************* | ||
183 | * | ||
184 | * FUNCTION: acpi_ps_pop_scope | ||
185 | * | ||
186 | * PARAMETERS: parser_state - Current parser state object | ||
187 | * Op - Where the popped op is returned | ||
188 | * arg_list - Where the popped "next argument" is | ||
189 | * returned | ||
190 | * arg_count - Count of objects in arg_list | ||
191 | * | ||
192 | * RETURN: Status | ||
193 | * | ||
194 | * DESCRIPTION: Return to parsing a previous op | ||
195 | * | ||
196 | ******************************************************************************/ | ||
197 | |||
198 | void | ||
199 | acpi_ps_pop_scope(struct acpi_parse_state *parser_state, | ||
200 | union acpi_parse_object **op, u32 * arg_list, u32 * arg_count) | ||
201 | { | ||
202 | union acpi_generic_state *scope = parser_state->scope; | ||
203 | |||
204 | ACPI_FUNCTION_TRACE(ps_pop_scope); | ||
205 | |||
206 | /* Only pop the scope if there is in fact a next scope */ | ||
207 | |||
208 | if (scope->common.next) { | ||
209 | scope = acpi_ut_pop_generic_state(&parser_state->scope); | ||
210 | |||
211 | /* Return to parsing previous op */ | ||
212 | |||
213 | *op = scope->parse_scope.op; | ||
214 | *arg_list = scope->parse_scope.arg_list; | ||
215 | *arg_count = scope->parse_scope.arg_count; | ||
216 | parser_state->pkg_end = scope->parse_scope.pkg_end; | ||
217 | |||
218 | /* All done with this scope state structure */ | ||
219 | |||
220 | acpi_ut_delete_generic_state(scope); | ||
221 | } else { | ||
222 | /* Empty parse stack, prepare to fetch next opcode */ | ||
223 | |||
224 | *op = NULL; | ||
225 | *arg_list = 0; | ||
226 | *arg_count = 0; | ||
227 | } | ||
228 | |||
229 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
230 | "Popped Op %p Args %X\n", *op, *arg_count)); | ||
231 | return_VOID; | ||
232 | } | ||
233 | |||
234 | /******************************************************************************* | ||
235 | * | ||
236 | * FUNCTION: acpi_ps_cleanup_scope | ||
237 | * | ||
238 | * PARAMETERS: parser_state - Current parser state object | ||
239 | * | ||
240 | * RETURN: None | ||
241 | * | ||
242 | * DESCRIPTION: Destroy available list, remaining stack levels, and return | ||
243 | * root scope | ||
244 | * | ||
245 | ******************************************************************************/ | ||
246 | |||
247 | void acpi_ps_cleanup_scope(struct acpi_parse_state *parser_state) | ||
248 | { | ||
249 | union acpi_generic_state *scope; | ||
250 | |||
251 | ACPI_FUNCTION_TRACE_PTR(ps_cleanup_scope, parser_state); | ||
252 | |||
253 | if (!parser_state) { | ||
254 | return_VOID; | ||
255 | } | ||
256 | |||
257 | /* Delete anything on the scope stack */ | ||
258 | |||
259 | while (parser_state->scope) { | ||
260 | scope = acpi_ut_pop_generic_state(&parser_state->scope); | ||
261 | acpi_ut_delete_generic_state(scope); | ||
262 | } | ||
263 | |||
264 | return_VOID; | ||
265 | } | ||
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c deleted file mode 100644 index 8e73fbf00971..000000000000 --- a/drivers/acpi/parser/pstree.c +++ /dev/null | |||
@@ -1,312 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: pstree - Parser op tree manipulation/traversal/search | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | #include <acpi/amlcode.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_PARSER | ||
50 | ACPI_MODULE_NAME("pstree") | ||
51 | |||
52 | /* Local prototypes */ | ||
53 | #ifdef ACPI_OBSOLETE_FUNCTIONS | ||
54 | union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op); | ||
55 | #endif | ||
56 | |||
57 | /******************************************************************************* | ||
58 | * | ||
59 | * FUNCTION: acpi_ps_get_arg | ||
60 | * | ||
61 | * PARAMETERS: Op - Get an argument for this op | ||
62 | * Argn - Nth argument to get | ||
63 | * | ||
64 | * RETURN: The argument (as an Op object). NULL if argument does not exist | ||
65 | * | ||
66 | * DESCRIPTION: Get the specified op's argument. | ||
67 | * | ||
68 | ******************************************************************************/ | ||
69 | |||
70 | union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn) | ||
71 | { | ||
72 | union acpi_parse_object *arg = NULL; | ||
73 | const struct acpi_opcode_info *op_info; | ||
74 | |||
75 | ACPI_FUNCTION_ENTRY(); | ||
76 | |||
77 | /* Get the info structure for this opcode */ | ||
78 | |||
79 | op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); | ||
80 | if (op_info->class == AML_CLASS_UNKNOWN) { | ||
81 | |||
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 | |||
91 | /* Has no linked argument objects */ | ||
92 | |||
93 | return (NULL); | ||
94 | } | ||
95 | |||
96 | /* Get the requested argument object */ | ||
97 | |||
98 | arg = op->common.value.arg; | ||
99 | while (arg && argn) { | ||
100 | argn--; | ||
101 | arg = arg->common.next; | ||
102 | } | ||
103 | |||
104 | return (arg); | ||
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 | |||
120 | void | ||
121 | acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) | ||
122 | { | ||
123 | union acpi_parse_object *prev_arg; | ||
124 | const struct acpi_opcode_info *op_info; | ||
125 | |||
126 | ACPI_FUNCTION_ENTRY(); | ||
127 | |||
128 | if (!op) { | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | /* Get the info structure for this opcode */ | ||
133 | |||
134 | op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); | ||
135 | if (op_info->class == AML_CLASS_UNKNOWN) { | ||
136 | |||
137 | /* Invalid opcode */ | ||
138 | |||
139 | ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X", | ||
140 | op->common.aml_opcode)); | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | /* Check if this opcode requires argument sub-objects */ | ||
145 | |||
146 | if (!(op_info->flags & AML_HAS_ARGS)) { | ||
147 | |||
148 | /* Has no linked argument objects */ | ||
149 | |||
150 | return; | ||
151 | } | ||
152 | |||
153 | /* Append the argument to the linked argument list */ | ||
154 | |||
155 | if (op->common.value.arg) { | ||
156 | |||
157 | /* Append to existing argument list */ | ||
158 | |||
159 | prev_arg = op->common.value.arg; | ||
160 | while (prev_arg->common.next) { | ||
161 | prev_arg = prev_arg->common.next; | ||
162 | } | ||
163 | prev_arg->common.next = arg; | ||
164 | } else { | ||
165 | /* No argument list, this will be the first argument */ | ||
166 | |||
167 | op->common.value.arg = arg; | ||
168 | } | ||
169 | |||
170 | /* Set the parent in this arg and any args linked after it */ | ||
171 | |||
172 | while (arg) { | ||
173 | arg->common.parent = op; | ||
174 | arg = arg->common.next; | ||
175 | |||
176 | op->common.arg_list_length++; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | #ifdef ACPI_FUTURE_USAGE | ||
181 | /******************************************************************************* | ||
182 | * | ||
183 | * FUNCTION: acpi_ps_get_depth_next | ||
184 | * | ||
185 | * PARAMETERS: Origin - Root of subtree to search | ||
186 | * Op - Last (previous) Op that was found | ||
187 | * | ||
188 | * RETURN: Next Op found in the search. | ||
189 | * | ||
190 | * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) | ||
191 | * Return NULL when reaching "origin" or when walking up from root | ||
192 | * | ||
193 | ******************************************************************************/ | ||
194 | |||
195 | union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin, | ||
196 | union acpi_parse_object *op) | ||
197 | { | ||
198 | union acpi_parse_object *next = NULL; | ||
199 | union acpi_parse_object *parent; | ||
200 | union acpi_parse_object *arg; | ||
201 | |||
202 | ACPI_FUNCTION_ENTRY(); | ||
203 | |||
204 | if (!op) { | ||
205 | return (NULL); | ||
206 | } | ||
207 | |||
208 | /* Look for an argument or child */ | ||
209 | |||
210 | next = acpi_ps_get_arg(op, 0); | ||
211 | if (next) { | ||
212 | return (next); | ||
213 | } | ||
214 | |||
215 | /* Look for a sibling */ | ||
216 | |||
217 | next = op->common.next; | ||
218 | if (next) { | ||
219 | return (next); | ||
220 | } | ||
221 | |||
222 | /* Look for a sibling of parent */ | ||
223 | |||
224 | parent = op->common.parent; | ||
225 | |||
226 | while (parent) { | ||
227 | arg = acpi_ps_get_arg(parent, 0); | ||
228 | while (arg && (arg != origin) && (arg != op)) { | ||
229 | arg = arg->common.next; | ||
230 | } | ||
231 | |||
232 | if (arg == origin) { | ||
233 | |||
234 | /* Reached parent of origin, end search */ | ||
235 | |||
236 | return (NULL); | ||
237 | } | ||
238 | |||
239 | if (parent->common.next) { | ||
240 | |||
241 | /* Found sibling of parent */ | ||
242 | |||
243 | return (parent->common.next); | ||
244 | } | ||
245 | |||
246 | op = parent; | ||
247 | parent = parent->common.parent; | ||
248 | } | ||
249 | |||
250 | return (next); | ||
251 | } | ||
252 | |||
253 | #ifdef ACPI_OBSOLETE_FUNCTIONS | ||
254 | /******************************************************************************* | ||
255 | * | ||
256 | * FUNCTION: acpi_ps_get_child | ||
257 | * | ||
258 | * PARAMETERS: Op - Get the child of this Op | ||
259 | * | ||
260 | * RETURN: Child Op, Null if none is found. | ||
261 | * | ||
262 | * DESCRIPTION: Get op's children or NULL if none | ||
263 | * | ||
264 | ******************************************************************************/ | ||
265 | |||
266 | union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op) | ||
267 | { | ||
268 | union acpi_parse_object *child = NULL; | ||
269 | |||
270 | ACPI_FUNCTION_ENTRY(); | ||
271 | |||
272 | switch (op->common.aml_opcode) { | ||
273 | case AML_SCOPE_OP: | ||
274 | case AML_ELSE_OP: | ||
275 | case AML_DEVICE_OP: | ||
276 | case AML_THERMAL_ZONE_OP: | ||
277 | case AML_INT_METHODCALL_OP: | ||
278 | |||
279 | child = acpi_ps_get_arg(op, 0); | ||
280 | break; | ||
281 | |||
282 | case AML_BUFFER_OP: | ||
283 | case AML_PACKAGE_OP: | ||
284 | case AML_METHOD_OP: | ||
285 | case AML_IF_OP: | ||
286 | case AML_WHILE_OP: | ||
287 | case AML_FIELD_OP: | ||
288 | |||
289 | child = acpi_ps_get_arg(op, 1); | ||
290 | break; | ||
291 | |||
292 | case AML_POWER_RES_OP: | ||
293 | case AML_INDEX_FIELD_OP: | ||
294 | |||
295 | child = acpi_ps_get_arg(op, 2); | ||
296 | break; | ||
297 | |||
298 | case AML_PROCESSOR_OP: | ||
299 | case AML_BANK_FIELD_OP: | ||
300 | |||
301 | child = acpi_ps_get_arg(op, 3); | ||
302 | break; | ||
303 | |||
304 | default: | ||
305 | /* All others have no children */ | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | return (child); | ||
310 | } | ||
311 | #endif | ||
312 | #endif /* ACPI_FUTURE_USAGE */ | ||
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c deleted file mode 100644 index eec7d624db8e..000000000000 --- a/drivers/acpi/parser/psutils.c +++ /dev/null | |||
@@ -1,244 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psutils - Parser miscellaneous utilities (Parser only) | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | #include <acpi/amlcode.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_PARSER | ||
50 | ACPI_MODULE_NAME("psutils") | ||
51 | |||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: acpi_ps_create_scope_op | ||
55 | * | ||
56 | * PARAMETERS: None | ||
57 | * | ||
58 | * RETURN: A new Scope object, null on failure | ||
59 | * | ||
60 | * DESCRIPTION: Create a Scope and associated namepath op with the root name | ||
61 | * | ||
62 | ******************************************************************************/ | ||
63 | union acpi_parse_object *acpi_ps_create_scope_op(void) | ||
64 | { | ||
65 | union acpi_parse_object *scope_op; | ||
66 | |||
67 | scope_op = acpi_ps_alloc_op(AML_SCOPE_OP); | ||
68 | if (!scope_op) { | ||
69 | return (NULL); | ||
70 | } | ||
71 | |||
72 | scope_op->named.name = ACPI_ROOT_NAME; | ||
73 | return (scope_op); | ||
74 | } | ||
75 | |||
76 | /******************************************************************************* | ||
77 | * | ||
78 | * FUNCTION: acpi_ps_init_op | ||
79 | * | ||
80 | * PARAMETERS: Op - A newly allocated Op object | ||
81 | * Opcode - Opcode to store in the Op | ||
82 | * | ||
83 | * RETURN: None | ||
84 | * | ||
85 | * DESCRIPTION: Initialize a parse (Op) object | ||
86 | * | ||
87 | ******************************************************************************/ | ||
88 | |||
89 | void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode) | ||
90 | { | ||
91 | ACPI_FUNCTION_ENTRY(); | ||
92 | |||
93 | op->common.descriptor_type = ACPI_DESC_TYPE_PARSER; | ||
94 | op->common.aml_opcode = opcode; | ||
95 | |||
96 | ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name, | ||
97 | (acpi_ps_get_opcode_info | ||
98 | (opcode))->name, | ||
99 | sizeof(op->common.aml_op_name))); | ||
100 | } | ||
101 | |||
102 | /******************************************************************************* | ||
103 | * | ||
104 | * FUNCTION: acpi_ps_alloc_op | ||
105 | * | ||
106 | * PARAMETERS: Opcode - Opcode that will be stored in the new Op | ||
107 | * | ||
108 | * RETURN: Pointer to the new Op, null on failure | ||
109 | * | ||
110 | * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on | ||
111 | * opcode. A cache of opcodes is available for the pure | ||
112 | * GENERIC_OP, since this is by far the most commonly used. | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | union acpi_parse_object *acpi_ps_alloc_op(u16 opcode) | ||
117 | { | ||
118 | union acpi_parse_object *op; | ||
119 | const struct acpi_opcode_info *op_info; | ||
120 | u8 flags = ACPI_PARSEOP_GENERIC; | ||
121 | |||
122 | ACPI_FUNCTION_ENTRY(); | ||
123 | |||
124 | op_info = acpi_ps_get_opcode_info(opcode); | ||
125 | |||
126 | /* Determine type of parse_op required */ | ||
127 | |||
128 | if (op_info->flags & AML_DEFER) { | ||
129 | flags = ACPI_PARSEOP_DEFERRED; | ||
130 | } else if (op_info->flags & AML_NAMED) { | ||
131 | flags = ACPI_PARSEOP_NAMED; | ||
132 | } else if (opcode == AML_INT_BYTELIST_OP) { | ||
133 | flags = ACPI_PARSEOP_BYTELIST; | ||
134 | } | ||
135 | |||
136 | /* Allocate the minimum required size object */ | ||
137 | |||
138 | if (flags == ACPI_PARSEOP_GENERIC) { | ||
139 | |||
140 | /* The generic op (default) is by far the most common (16 to 1) */ | ||
141 | |||
142 | op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); | ||
143 | } else { | ||
144 | /* Extended parseop */ | ||
145 | |||
146 | op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); | ||
147 | } | ||
148 | |||
149 | /* Initialize the Op */ | ||
150 | |||
151 | if (op) { | ||
152 | acpi_ps_init_op(op, opcode); | ||
153 | op->common.flags = flags; | ||
154 | } | ||
155 | |||
156 | return (op); | ||
157 | } | ||
158 | |||
159 | /******************************************************************************* | ||
160 | * | ||
161 | * FUNCTION: acpi_ps_free_op | ||
162 | * | ||
163 | * PARAMETERS: Op - Op to be freed | ||
164 | * | ||
165 | * RETURN: None. | ||
166 | * | ||
167 | * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list | ||
168 | * or actually free it. | ||
169 | * | ||
170 | ******************************************************************************/ | ||
171 | |||
172 | void acpi_ps_free_op(union acpi_parse_object *op) | ||
173 | { | ||
174 | ACPI_FUNCTION_NAME(ps_free_op); | ||
175 | |||
176 | if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { | ||
177 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", | ||
178 | op)); | ||
179 | } | ||
180 | |||
181 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { | ||
182 | (void)acpi_os_release_object(acpi_gbl_ps_node_cache, op); | ||
183 | } else { | ||
184 | (void)acpi_os_release_object(acpi_gbl_ps_node_ext_cache, op); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | /******************************************************************************* | ||
189 | * | ||
190 | * FUNCTION: Utility functions | ||
191 | * | ||
192 | * DESCRIPTION: Low level character and object functions | ||
193 | * | ||
194 | ******************************************************************************/ | ||
195 | |||
196 | /* | ||
197 | * Is "c" a namestring lead character? | ||
198 | */ | ||
199 | u8 acpi_ps_is_leading_char(u32 c) | ||
200 | { | ||
201 | return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * Is "c" a namestring prefix character? | ||
206 | */ | ||
207 | u8 acpi_ps_is_prefix_char(u32 c) | ||
208 | { | ||
209 | return ((u8) (c == '\\' || c == '^')); | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * Get op's name (4-byte name segment) or 0 if unnamed | ||
214 | */ | ||
215 | #ifdef ACPI_FUTURE_USAGE | ||
216 | u32 acpi_ps_get_name(union acpi_parse_object * op) | ||
217 | { | ||
218 | |||
219 | /* The "generic" object has no name associated with it */ | ||
220 | |||
221 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { | ||
222 | return (0); | ||
223 | } | ||
224 | |||
225 | /* Only the "Extended" parse objects have a name */ | ||
226 | |||
227 | return (op->named.name); | ||
228 | } | ||
229 | #endif /* ACPI_FUTURE_USAGE */ | ||
230 | |||
231 | /* | ||
232 | * Set op's name | ||
233 | */ | ||
234 | void acpi_ps_set_name(union acpi_parse_object *op, u32 name) | ||
235 | { | ||
236 | |||
237 | /* The "generic" object has no name associated with it */ | ||
238 | |||
239 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | op->named.name = name; | ||
244 | } | ||
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c deleted file mode 100644 index dacc4228ba1a..000000000000 --- a/drivers/acpi/parser/pswalk.c +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: pswalk - Parser routines to walk parsed op tree(s) | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_PARSER | ||
49 | ACPI_MODULE_NAME("pswalk") | ||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_ps_delete_parse_tree | ||
54 | * | ||
55 | * PARAMETERS: subtree_root - Root of tree (or subtree) to delete | ||
56 | * | ||
57 | * RETURN: None | ||
58 | * | ||
59 | * DESCRIPTION: Delete a portion of or an entire parse tree. | ||
60 | * | ||
61 | ******************************************************************************/ | ||
62 | void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root) | ||
63 | { | ||
64 | union acpi_parse_object *op = subtree_root; | ||
65 | union acpi_parse_object *next = NULL; | ||
66 | union acpi_parse_object *parent = NULL; | ||
67 | |||
68 | ACPI_FUNCTION_TRACE_PTR(ps_delete_parse_tree, subtree_root); | ||
69 | |||
70 | /* Visit all nodes in the subtree */ | ||
71 | |||
72 | while (op) { | ||
73 | |||
74 | /* Check if we are not ascending */ | ||
75 | |||
76 | if (op != parent) { | ||
77 | |||
78 | /* Look for an argument or child of the current op */ | ||
79 | |||
80 | next = acpi_ps_get_arg(op, 0); | ||
81 | if (next) { | ||
82 | |||
83 | /* Still going downward in tree (Op is not completed yet) */ | ||
84 | |||
85 | op = next; | ||
86 | continue; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /* No more children, this Op is complete. */ | ||
91 | |||
92 | next = op->common.next; | ||
93 | parent = op->common.parent; | ||
94 | |||
95 | acpi_ps_free_op(op); | ||
96 | |||
97 | /* If we are back to the starting point, the walk is complete. */ | ||
98 | |||
99 | if (op == subtree_root) { | ||
100 | return_VOID; | ||
101 | } | ||
102 | if (next) { | ||
103 | op = next; | ||
104 | } else { | ||
105 | op = parent; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | return_VOID; | ||
110 | } | ||
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c deleted file mode 100644 index 98c31a893706..000000000000 --- a/drivers/acpi/parser/psxface.c +++ /dev/null | |||
@@ -1,385 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psxface - Parser external interfaces | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
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 | #include <acpi/acpi.h> | ||
45 | #include <acpi/accommon.h> | ||
46 | #include <acpi/acparser.h> | ||
47 | #include <acpi/acdispat.h> | ||
48 | #include <acpi/acinterp.h> | ||
49 | #include <acpi/amlcode.h> | ||
50 | |||
51 | #define _COMPONENT ACPI_PARSER | ||
52 | ACPI_MODULE_NAME("psxface") | ||
53 | |||
54 | /* Local Prototypes */ | ||
55 | static void acpi_ps_start_trace(struct acpi_evaluate_info *info); | ||
56 | |||
57 | static void acpi_ps_stop_trace(struct acpi_evaluate_info *info); | ||
58 | |||
59 | static void | ||
60 | acpi_ps_update_parameter_list(struct acpi_evaluate_info *info, u16 action); | ||
61 | |||
62 | /******************************************************************************* | ||
63 | * | ||
64 | * FUNCTION: acpi_debug_trace | ||
65 | * | ||
66 | * PARAMETERS: method_name - Valid ACPI name string | ||
67 | * debug_level - Optional level mask. 0 to use default | ||
68 | * debug_layer - Optional layer mask. 0 to use default | ||
69 | * Flags - bit 1: one shot(1) or persistent(0) | ||
70 | * | ||
71 | * RETURN: Status | ||
72 | * | ||
73 | * DESCRIPTION: External interface to enable debug tracing during control | ||
74 | * method execution | ||
75 | * | ||
76 | ******************************************************************************/ | ||
77 | |||
78 | acpi_status | ||
79 | acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags) | ||
80 | { | ||
81 | acpi_status status; | ||
82 | |||
83 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
84 | if (ACPI_FAILURE(status)) { | ||
85 | return (status); | ||
86 | } | ||
87 | |||
88 | /* TBDs: Validate name, allow full path or just nameseg */ | ||
89 | |||
90 | acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name); | ||
91 | acpi_gbl_trace_flags = flags; | ||
92 | |||
93 | if (debug_level) { | ||
94 | acpi_gbl_trace_dbg_level = debug_level; | ||
95 | } | ||
96 | if (debug_layer) { | ||
97 | acpi_gbl_trace_dbg_layer = debug_layer; | ||
98 | } | ||
99 | |||
100 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
101 | return (AE_OK); | ||
102 | } | ||
103 | |||
104 | /******************************************************************************* | ||
105 | * | ||
106 | * FUNCTION: acpi_ps_start_trace | ||
107 | * | ||
108 | * PARAMETERS: Info - Method info struct | ||
109 | * | ||
110 | * RETURN: None | ||
111 | * | ||
112 | * DESCRIPTION: Start control method execution trace | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | static void acpi_ps_start_trace(struct acpi_evaluate_info *info) | ||
117 | { | ||
118 | acpi_status status; | ||
119 | |||
120 | ACPI_FUNCTION_ENTRY(); | ||
121 | |||
122 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
123 | if (ACPI_FAILURE(status)) { | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | if ((!acpi_gbl_trace_method_name) || | ||
128 | (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { | ||
129 | goto exit; | ||
130 | } | ||
131 | |||
132 | acpi_gbl_original_dbg_level = acpi_dbg_level; | ||
133 | acpi_gbl_original_dbg_layer = acpi_dbg_layer; | ||
134 | |||
135 | acpi_dbg_level = 0x00FFFFFF; | ||
136 | acpi_dbg_layer = ACPI_UINT32_MAX; | ||
137 | |||
138 | if (acpi_gbl_trace_dbg_level) { | ||
139 | acpi_dbg_level = acpi_gbl_trace_dbg_level; | ||
140 | } | ||
141 | if (acpi_gbl_trace_dbg_layer) { | ||
142 | acpi_dbg_layer = acpi_gbl_trace_dbg_layer; | ||
143 | } | ||
144 | |||
145 | exit: | ||
146 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
147 | } | ||
148 | |||
149 | /******************************************************************************* | ||
150 | * | ||
151 | * FUNCTION: acpi_ps_stop_trace | ||
152 | * | ||
153 | * PARAMETERS: Info - Method info struct | ||
154 | * | ||
155 | * RETURN: None | ||
156 | * | ||
157 | * DESCRIPTION: Stop control method execution trace | ||
158 | * | ||
159 | ******************************************************************************/ | ||
160 | |||
161 | static void acpi_ps_stop_trace(struct acpi_evaluate_info *info) | ||
162 | { | ||
163 | acpi_status status; | ||
164 | |||
165 | ACPI_FUNCTION_ENTRY(); | ||
166 | |||
167 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
168 | if (ACPI_FAILURE(status)) { | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | if ((!acpi_gbl_trace_method_name) || | ||
173 | (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { | ||
174 | goto exit; | ||
175 | } | ||
176 | |||
177 | /* Disable further tracing if type is one-shot */ | ||
178 | |||
179 | if (acpi_gbl_trace_flags & 1) { | ||
180 | acpi_gbl_trace_method_name = 0; | ||
181 | acpi_gbl_trace_dbg_level = 0; | ||
182 | acpi_gbl_trace_dbg_layer = 0; | ||
183 | } | ||
184 | |||
185 | acpi_dbg_level = acpi_gbl_original_dbg_level; | ||
186 | acpi_dbg_layer = acpi_gbl_original_dbg_layer; | ||
187 | |||
188 | exit: | ||
189 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
190 | } | ||
191 | |||
192 | /******************************************************************************* | ||
193 | * | ||
194 | * FUNCTION: acpi_ps_execute_method | ||
195 | * | ||
196 | * PARAMETERS: Info - Method info block, contains: | ||
197 | * Node - Method Node to execute | ||
198 | * obj_desc - Method object | ||
199 | * Parameters - List of parameters to pass to the method, | ||
200 | * terminated by NULL. Params itself may be | ||
201 | * NULL if no parameters are being passed. | ||
202 | * return_object - Where to put method's return value (if | ||
203 | * any). If NULL, no value is returned. | ||
204 | * parameter_type - Type of Parameter list | ||
205 | * return_object - Where to put method's return value (if | ||
206 | * any). If NULL, no value is returned. | ||
207 | * pass_number - Parse or execute pass | ||
208 | * | ||
209 | * RETURN: Status | ||
210 | * | ||
211 | * DESCRIPTION: Execute a control method | ||
212 | * | ||
213 | ******************************************************************************/ | ||
214 | |||
215 | acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) | ||
216 | { | ||
217 | acpi_status status; | ||
218 | union acpi_parse_object *op; | ||
219 | struct acpi_walk_state *walk_state; | ||
220 | |||
221 | ACPI_FUNCTION_TRACE(ps_execute_method); | ||
222 | |||
223 | /* Validate the Info and method Node */ | ||
224 | |||
225 | if (!info || !info->resolved_node) { | ||
226 | return_ACPI_STATUS(AE_NULL_ENTRY); | ||
227 | } | ||
228 | |||
229 | /* Init for new method, wait on concurrency semaphore */ | ||
230 | |||
231 | status = | ||
232 | acpi_ds_begin_method_execution(info->resolved_node, info->obj_desc, | ||
233 | NULL); | ||
234 | if (ACPI_FAILURE(status)) { | ||
235 | return_ACPI_STATUS(status); | ||
236 | } | ||
237 | |||
238 | /* | ||
239 | * The caller "owns" the parameters, so give each one an extra reference | ||
240 | */ | ||
241 | acpi_ps_update_parameter_list(info, REF_INCREMENT); | ||
242 | |||
243 | /* Begin tracing if requested */ | ||
244 | |||
245 | acpi_ps_start_trace(info); | ||
246 | |||
247 | /* | ||
248 | * Execute the method. Performs parse simultaneously | ||
249 | */ | ||
250 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | ||
251 | "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", | ||
252 | info->resolved_node->name.ascii, info->resolved_node, | ||
253 | info->obj_desc)); | ||
254 | |||
255 | /* Create and init a Root Node */ | ||
256 | |||
257 | op = acpi_ps_create_scope_op(); | ||
258 | if (!op) { | ||
259 | status = AE_NO_MEMORY; | ||
260 | goto cleanup; | ||
261 | } | ||
262 | |||
263 | /* Create and initialize a new walk state */ | ||
264 | |||
265 | info->pass_number = ACPI_IMODE_EXECUTE; | ||
266 | walk_state = | ||
267 | acpi_ds_create_walk_state(info->obj_desc->method.owner_id, NULL, | ||
268 | NULL, NULL); | ||
269 | if (!walk_state) { | ||
270 | status = AE_NO_MEMORY; | ||
271 | goto cleanup; | ||
272 | } | ||
273 | |||
274 | status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node, | ||
275 | info->obj_desc->method.aml_start, | ||
276 | info->obj_desc->method.aml_length, info, | ||
277 | info->pass_number); | ||
278 | if (ACPI_FAILURE(status)) { | ||
279 | acpi_ds_delete_walk_state(walk_state); | ||
280 | goto cleanup; | ||
281 | } | ||
282 | |||
283 | /* Invoke an internal method if necessary */ | ||
284 | |||
285 | if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { | ||
286 | status = info->obj_desc->method.implementation(walk_state); | ||
287 | info->return_object = walk_state->return_desc; | ||
288 | |||
289 | /* Cleanup states */ | ||
290 | |||
291 | acpi_ds_scope_stack_clear(walk_state); | ||
292 | acpi_ps_cleanup_scope(&walk_state->parser_state); | ||
293 | acpi_ds_terminate_control_method(walk_state->method_desc, | ||
294 | walk_state); | ||
295 | acpi_ds_delete_walk_state(walk_state); | ||
296 | goto cleanup; | ||
297 | } | ||
298 | |||
299 | /* | ||
300 | * Start method evaluation with an implicit return of zero. | ||
301 | * This is done for Windows compatibility. | ||
302 | */ | ||
303 | if (acpi_gbl_enable_interpreter_slack) { | ||
304 | walk_state->implicit_return_obj = | ||
305 | acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); | ||
306 | if (!walk_state->implicit_return_obj) { | ||
307 | status = AE_NO_MEMORY; | ||
308 | acpi_ds_delete_walk_state(walk_state); | ||
309 | goto cleanup; | ||
310 | } | ||
311 | |||
312 | walk_state->implicit_return_obj->integer.value = 0; | ||
313 | } | ||
314 | |||
315 | /* Parse the AML */ | ||
316 | |||
317 | status = acpi_ps_parse_aml(walk_state); | ||
318 | |||
319 | /* walk_state was deleted by parse_aml */ | ||
320 | |||
321 | cleanup: | ||
322 | acpi_ps_delete_parse_tree(op); | ||
323 | |||
324 | /* End optional tracing */ | ||
325 | |||
326 | acpi_ps_stop_trace(info); | ||
327 | |||
328 | /* Take away the extra reference that we gave the parameters above */ | ||
329 | |||
330 | acpi_ps_update_parameter_list(info, REF_DECREMENT); | ||
331 | |||
332 | /* Exit now if error above */ | ||
333 | |||
334 | if (ACPI_FAILURE(status)) { | ||
335 | return_ACPI_STATUS(status); | ||
336 | } | ||
337 | |||
338 | /* | ||
339 | * If the method has returned an object, signal this to the caller with | ||
340 | * a control exception code | ||
341 | */ | ||
342 | if (info->return_object) { | ||
343 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", | ||
344 | info->return_object)); | ||
345 | ACPI_DUMP_STACK_ENTRY(info->return_object); | ||
346 | |||
347 | status = AE_CTRL_RETURN_VALUE; | ||
348 | } | ||
349 | |||
350 | return_ACPI_STATUS(status); | ||
351 | } | ||
352 | |||
353 | /******************************************************************************* | ||
354 | * | ||
355 | * FUNCTION: acpi_ps_update_parameter_list | ||
356 | * | ||
357 | * PARAMETERS: Info - See struct acpi_evaluate_info | ||
358 | * (Used: parameter_type and Parameters) | ||
359 | * Action - Add or Remove reference | ||
360 | * | ||
361 | * RETURN: Status | ||
362 | * | ||
363 | * DESCRIPTION: Update reference count on all method parameter objects | ||
364 | * | ||
365 | ******************************************************************************/ | ||
366 | |||
367 | static void | ||
368 | acpi_ps_update_parameter_list(struct acpi_evaluate_info *info, u16 action) | ||
369 | { | ||
370 | u32 i; | ||
371 | |||
372 | if (info->parameters) { | ||
373 | |||
374 | /* Update reference count for each parameter */ | ||
375 | |||
376 | for (i = 0; info->parameters[i]; i++) { | ||
377 | |||
378 | /* Ignore errors, just do them all */ | ||
379 | |||
380 | (void)acpi_ut_update_object_reference(info-> | ||
381 | parameters[i], | ||
382 | action); | ||
383 | } | ||
384 | } | ||
385 | } | ||