MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / acpi / dispatcher / dswload.c
blob9c0d99e09a593222101f1bd662e8b769f7a2fb48
1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2004, R. Byron Moore
9 * All rights reserved.
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.
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.
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.
45 #include <acpi/acpi.h>
46 #include <acpi/acparser.h>
47 #include <acpi/amlcode.h>
48 #include <acpi/acdispat.h>
49 #include <acpi/acinterp.h>
50 #include <acpi/acnamesp.h>
51 #include <acpi/acevents.h>
53 #ifdef _ACPI_ASL_COMPILER
54 #include <acpi/acdisasm.h>
55 #endif
57 #define _COMPONENT ACPI_DISPATCHER
58 ACPI_MODULE_NAME ("dswload")
61 /*******************************************************************************
63 * FUNCTION: acpi_ds_init_callbacks
65 * PARAMETERS: walk_state - Current state of the parse tree walk
66 * pass_number - 1, 2, or 3
68 * RETURN: Status
70 * DESCRIPTION: Init walk state callbacks
72 ******************************************************************************/
74 acpi_status
75 acpi_ds_init_callbacks (
76 struct acpi_walk_state *walk_state,
77 u32 pass_number)
80 switch (pass_number) {
81 case 1:
82 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
83 walk_state->descending_callback = acpi_ds_load1_begin_op;
84 walk_state->ascending_callback = acpi_ds_load1_end_op;
85 break;
87 case 2:
88 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
89 walk_state->descending_callback = acpi_ds_load2_begin_op;
90 walk_state->ascending_callback = acpi_ds_load2_end_op;
91 break;
93 case 3:
94 #ifndef ACPI_NO_METHOD_EXECUTION
95 walk_state->parse_flags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE;
96 walk_state->descending_callback = acpi_ds_exec_begin_op;
97 walk_state->ascending_callback = acpi_ds_exec_end_op;
98 #endif
99 break;
101 default:
102 return (AE_BAD_PARAMETER);
105 return (AE_OK);
109 /*******************************************************************************
111 * FUNCTION: acpi_ds_load1_begin_op
113 * PARAMETERS: walk_state - Current state of the parse tree walk
114 * Op - Op that has been just been reached in the
115 * walk; Arguments have not been evaluated yet.
117 * RETURN: Status
119 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
121 ******************************************************************************/
123 acpi_status
124 acpi_ds_load1_begin_op (
125 struct acpi_walk_state *walk_state,
126 union acpi_parse_object **out_op)
128 union acpi_parse_object *op;
129 struct acpi_namespace_node *node;
130 acpi_status status;
131 acpi_object_type object_type;
132 char *path;
133 u32 flags;
136 ACPI_FUNCTION_NAME ("ds_load1_begin_op");
139 op = walk_state->op;
140 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
142 /* We are only interested in opcodes that have an associated name */
144 if (op) {
145 if (!(walk_state->op_info->flags & AML_NAMED)) {
146 #if 0
147 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
148 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
149 acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", walk_state->op_info->name);
150 *out_op = op;
151 return (AE_CTRL_SKIP);
153 #endif
154 *out_op = op;
155 return (AE_OK);
158 /* Check if this object has already been installed in the namespace */
160 if (op->common.node) {
161 *out_op = op;
162 return (AE_OK);
166 path = acpi_ps_get_next_namestring (&walk_state->parser_state);
168 /* Map the raw opcode into an internal object type */
170 object_type = walk_state->op_info->object_type;
172 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
173 "State=%p Op=%p [%s]\n", walk_state, op, acpi_ut_get_type_name (object_type)));
175 switch (walk_state->opcode) {
176 case AML_SCOPE_OP:
179 * The target name of the Scope() operator must exist at this point so
180 * that we can actually open the scope to enter new names underneath it.
181 * Allow search-to-root for single namesegs.
183 status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
184 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
185 if (ACPI_FAILURE (status)) {
186 #ifdef _ACPI_ASL_COMPILER
187 if (status == AE_NOT_FOUND) {
188 acpi_dm_add_to_external_list (path);
189 status = AE_OK;
191 else {
192 ACPI_REPORT_NSERROR (path, status);
194 #else
195 ACPI_REPORT_NSERROR (path, status);
196 #endif
197 return (status);
201 * Check to make sure that the target is
202 * one of the opcodes that actually opens a scope
204 switch (node->type) {
205 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
206 case ACPI_TYPE_DEVICE:
207 case ACPI_TYPE_POWER:
208 case ACPI_TYPE_PROCESSOR:
209 case ACPI_TYPE_THERMAL:
211 /* These are acceptable types */
212 break;
214 case ACPI_TYPE_INTEGER:
215 case ACPI_TYPE_STRING:
216 case ACPI_TYPE_BUFFER:
219 * These types we will allow, but we will change the type. This
220 * enables some existing code of the form:
222 * Name (DEB, 0)
223 * Scope (DEB) { ... }
225 * Note: silently change the type here. On the second pass, we will report a warning
228 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
229 path, acpi_ut_get_type_name (node->type)));
231 node->type = ACPI_TYPE_ANY;
232 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
233 break;
235 default:
237 /* All other types are an error */
239 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
240 acpi_ut_get_type_name (node->type), path));
242 return (AE_AML_OPERAND_TYPE);
244 break;
247 default:
250 * For all other named opcodes, we will enter the name into the namespace.
252 * Setup the search flags.
253 * Since we are entering a name into the namespace, we do not want to
254 * enable the search-to-root upsearch.
256 * There are only two conditions where it is acceptable that the name
257 * already exists:
258 * 1) the Scope() operator can reopen a scoping object that was
259 * previously defined (Scope, Method, Device, etc.)
260 * 2) Whenever we are parsing a deferred opcode (op_region, Buffer,
261 * buffer_field, or Package), the name of the object is already
262 * in the namespace.
264 if (walk_state->deferred_node) {
265 /* This name is already in the namespace, get the node */
267 node = walk_state->deferred_node;
268 status = AE_OK;
269 break;
272 flags = ACPI_NS_NO_UPSEARCH;
273 if ((walk_state->opcode != AML_SCOPE_OP) &&
274 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
275 flags |= ACPI_NS_ERROR_IF_FOUND;
276 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
277 acpi_ut_get_type_name (object_type)));
279 else {
280 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n",
281 acpi_ut_get_type_name (object_type)));
285 * Enter the named type into the internal namespace. We enter the name
286 * as we go downward in the parse tree. Any necessary subobjects that involve
287 * arguments to the opcode must be created as we go back up the parse tree later.
289 status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
290 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node));
291 if (ACPI_FAILURE (status)) {
292 ACPI_REPORT_NSERROR (path, status);
293 return (status);
295 break;
299 /* Common exit */
301 if (!op) {
302 /* Create a new op */
304 op = acpi_ps_alloc_op (walk_state->opcode);
305 if (!op) {
306 return (AE_NO_MEMORY);
310 /* Initialize */
312 op->named.name = node->name.integer;
314 #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
315 op->named.path = (u8 *) path;
316 #endif
320 * Put the Node in the "op" object that the parser uses, so we
321 * can get it again quickly when this scope is closed
323 op->common.node = node;
324 acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op);
326 *out_op = op;
327 return (status);
331 /*******************************************************************************
333 * FUNCTION: acpi_ds_load1_end_op
335 * PARAMETERS: walk_state - Current state of the parse tree walk
336 * Op - Op that has been just been completed in the
337 * walk; Arguments have now been evaluated.
339 * RETURN: Status
341 * DESCRIPTION: Ascending callback used during the loading of the namespace,
342 * both control methods and everything else.
344 ******************************************************************************/
346 acpi_status
347 acpi_ds_load1_end_op (
348 struct acpi_walk_state *walk_state)
350 union acpi_parse_object *op;
351 acpi_object_type object_type;
352 acpi_status status = AE_OK;
355 ACPI_FUNCTION_NAME ("ds_load1_end_op");
358 op = walk_state->op;
359 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
361 /* We are only interested in opcodes that have an associated name */
363 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
364 return (AE_OK);
367 /* Get the object type to determine if we should pop the scope */
369 object_type = walk_state->op_info->object_type;
371 #ifndef ACPI_NO_METHOD_EXECUTION
372 if (walk_state->op_info->flags & AML_FIELD) {
373 if (walk_state->opcode == AML_FIELD_OP ||
374 walk_state->opcode == AML_BANK_FIELD_OP ||
375 walk_state->opcode == AML_INDEX_FIELD_OP) {
376 status = acpi_ds_init_field_objects (op, walk_state);
378 return (status);
382 if (op->common.aml_opcode == AML_REGION_OP) {
383 status = acpi_ex_create_region (op->named.data, op->named.length,
384 (acpi_adr_space_type) ((op->common.value.arg)->common.value.integer), walk_state);
385 if (ACPI_FAILURE (status)) {
386 return (status);
389 #endif
391 if (op->common.aml_opcode == AML_NAME_OP) {
392 /* For Name opcode, get the object type from the argument */
394 if (op->common.value.arg) {
395 object_type = (acpi_ps_get_opcode_info ((op->common.value.arg)->common.aml_opcode))->object_type;
396 op->common.node->type = (u8) object_type;
400 if (op->common.aml_opcode == AML_METHOD_OP) {
402 * method_op pkg_length name_string method_flags term_list
404 * Note: We must create the method node/object pair as soon as we
405 * see the method declaration. This allows later pass1 parsing
406 * of invocations of the method (need to know the number of
407 * arguments.)
409 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
410 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
411 walk_state, op, op->named.node));
413 if (!acpi_ns_get_attached_object (op->named.node)) {
414 walk_state->operands[0] = (void *) op->named.node;
415 walk_state->num_operands = 1;
417 status = acpi_ds_create_operands (walk_state, op->common.value.arg);
418 if (ACPI_SUCCESS (status)) {
419 status = acpi_ex_create_method (op->named.data,
420 op->named.length, walk_state);
422 walk_state->operands[0] = NULL;
423 walk_state->num_operands = 0;
425 if (ACPI_FAILURE (status)) {
426 return (status);
431 /* Pop the scope stack */
433 if (acpi_ns_opens_scope (object_type)) {
434 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
435 acpi_ut_get_type_name (object_type), op));
437 status = acpi_ds_scope_stack_pop (walk_state);
440 return (status);
444 /*******************************************************************************
446 * FUNCTION: acpi_ds_load2_begin_op
448 * PARAMETERS: walk_state - Current state of the parse tree walk
449 * Op - Op that has been just been reached in the
450 * walk; Arguments have not been evaluated yet.
452 * RETURN: Status
454 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
456 ******************************************************************************/
458 acpi_status
459 acpi_ds_load2_begin_op (
460 struct acpi_walk_state *walk_state,
461 union acpi_parse_object **out_op)
463 union acpi_parse_object *op;
464 struct acpi_namespace_node *node;
465 acpi_status status;
466 acpi_object_type object_type;
467 char *buffer_ptr;
470 ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
473 op = walk_state->op;
474 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
476 if (op) {
477 /* We only care about Namespace opcodes here */
479 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
480 (!(walk_state->op_info->flags & AML_NAMED))) {
481 return_ACPI_STATUS (AE_OK);
485 * Get the name we are going to enter or lookup in the namespace
487 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
488 /* For Namepath op, get the path string */
490 buffer_ptr = op->common.value.string;
491 if (!buffer_ptr) {
492 /* No name, just exit */
494 return_ACPI_STATUS (AE_OK);
497 else {
498 /* Get name from the op */
500 buffer_ptr = (char *) &op->named.name;
503 else {
504 /* Get the namestring from the raw AML */
506 buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state);
509 /* Map the opcode into an internal object type */
511 object_type = walk_state->op_info->object_type;
513 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
514 "State=%p Op=%p Type=%X\n", walk_state, op, object_type));
517 switch (walk_state->opcode) {
518 case AML_FIELD_OP:
519 case AML_BANK_FIELD_OP:
520 case AML_INDEX_FIELD_OP:
522 node = NULL;
523 status = AE_OK;
524 break;
526 case AML_INT_NAMEPATH_OP:
529 * The name_path is an object reference to an existing object. Don't enter the
530 * name into the namespace, but look it up for use later
532 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
533 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
534 break;
536 case AML_SCOPE_OP:
539 * The Path is an object reference to an existing object. Don't enter the
540 * name into the namespace, but look it up for use later
542 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
543 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
544 if (ACPI_FAILURE (status)) {
545 #ifdef _ACPI_ASL_COMPILER
546 if (status == AE_NOT_FOUND) {
547 status = AE_OK;
549 else {
550 ACPI_REPORT_NSERROR (buffer_ptr, status);
552 #else
553 ACPI_REPORT_NSERROR (buffer_ptr, status);
554 #endif
555 return_ACPI_STATUS (status);
558 * We must check to make sure that the target is
559 * one of the opcodes that actually opens a scope
561 switch (node->type) {
562 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
563 case ACPI_TYPE_DEVICE:
564 case ACPI_TYPE_POWER:
565 case ACPI_TYPE_PROCESSOR:
566 case ACPI_TYPE_THERMAL:
568 /* These are acceptable types */
569 break;
571 case ACPI_TYPE_INTEGER:
572 case ACPI_TYPE_STRING:
573 case ACPI_TYPE_BUFFER:
576 * These types we will allow, but we will change the type. This
577 * enables some existing code of the form:
579 * Name (DEB, 0)
580 * Scope (DEB) { ... }
583 ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
584 buffer_ptr, acpi_ut_get_type_name (node->type)));
586 node->type = ACPI_TYPE_ANY;
587 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
588 break;
590 default:
592 /* All other types are an error */
594 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n",
595 acpi_ut_get_type_name (node->type), buffer_ptr));
597 return (AE_AML_OPERAND_TYPE);
599 break;
601 default:
603 /* All other opcodes */
605 if (op && op->common.node) {
606 /* This op/node was previously entered into the namespace */
608 node = op->common.node;
610 if (acpi_ns_opens_scope (object_type)) {
611 status = acpi_ds_scope_stack_push (node, object_type, walk_state);
612 if (ACPI_FAILURE (status)) {
613 return_ACPI_STATUS (status);
617 return_ACPI_STATUS (AE_OK);
621 * Enter the named type into the internal namespace. We enter the name
622 * as we go downward in the parse tree. Any necessary subobjects that involve
623 * arguments to the opcode must be created as we go back up the parse tree later.
625 * Note: Name may already exist if we are executing a deferred opcode.
627 if (walk_state->deferred_node) {
628 /* This name is already in the namespace, get the node */
630 node = walk_state->deferred_node;
631 status = AE_OK;
632 break;
635 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
636 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
637 break;
640 if (ACPI_FAILURE (status)) {
641 ACPI_REPORT_NSERROR (buffer_ptr, status);
642 return_ACPI_STATUS (status);
646 if (!op) {
647 /* Create a new op */
649 op = acpi_ps_alloc_op (walk_state->opcode);
650 if (!op) {
651 return_ACPI_STATUS (AE_NO_MEMORY);
654 /* Initialize the new op */
656 if (node) {
657 op->named.name = node->name.integer;
659 if (out_op) {
660 *out_op = op;
665 * Put the Node in the "op" object that the parser uses, so we
666 * can get it again quickly when this scope is closed
668 op->common.node = node;
670 return_ACPI_STATUS (status);
674 /*******************************************************************************
676 * FUNCTION: acpi_ds_load2_end_op
678 * PARAMETERS: walk_state - Current state of the parse tree walk
679 * Op - Op that has been just been completed in the
680 * walk; Arguments have now been evaluated.
682 * RETURN: Status
684 * DESCRIPTION: Ascending callback used during the loading of the namespace,
685 * both control methods and everything else.
687 ******************************************************************************/
689 acpi_status
690 acpi_ds_load2_end_op (
691 struct acpi_walk_state *walk_state)
693 union acpi_parse_object *op;
694 acpi_status status = AE_OK;
695 acpi_object_type object_type;
696 struct acpi_namespace_node *node;
697 union acpi_parse_object *arg;
698 struct acpi_namespace_node *new_node;
699 #ifndef ACPI_NO_METHOD_EXECUTION
700 u32 i;
701 #endif
704 ACPI_FUNCTION_TRACE ("ds_load2_end_op");
706 op = walk_state->op;
707 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
708 walk_state->op_info->name, op, walk_state));
710 /* Only interested in opcodes that have namespace objects */
712 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
713 return_ACPI_STATUS (AE_OK);
716 if (op->common.aml_opcode == AML_SCOPE_OP) {
717 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
718 "Ending scope Op=%p State=%p\n", op, walk_state));
722 object_type = walk_state->op_info->object_type;
725 * Get the Node/name from the earlier lookup
726 * (It was saved in the *op structure)
728 node = op->common.node;
731 * Put the Node on the object stack (Contains the ACPI Name of
732 * this object)
734 walk_state->operands[0] = (void *) node;
735 walk_state->num_operands = 1;
737 /* Pop the scope stack */
739 if (acpi_ns_opens_scope (object_type) && (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
740 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
741 acpi_ut_get_type_name (object_type), op));
743 status = acpi_ds_scope_stack_pop (walk_state);
744 if (ACPI_FAILURE (status)) {
745 goto cleanup;
750 * Named operations are as follows:
752 * AML_ALIAS
753 * AML_BANKFIELD
754 * AML_CREATEBITFIELD
755 * AML_CREATEBYTEFIELD
756 * AML_CREATEDWORDFIELD
757 * AML_CREATEFIELD
758 * AML_CREATEQWORDFIELD
759 * AML_CREATEWORDFIELD
760 * AML_DATA_REGION
761 * AML_DEVICE
762 * AML_EVENT
763 * AML_FIELD
764 * AML_INDEXFIELD
765 * AML_METHOD
766 * AML_METHODCALL
767 * AML_MUTEX
768 * AML_NAME
769 * AML_NAMEDFIELD
770 * AML_OPREGION
771 * AML_POWERRES
772 * AML_PROCESSOR
773 * AML_SCOPE
774 * AML_THERMALZONE
777 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
778 "Create-Load [%s] State=%p Op=%p named_obj=%p\n",
779 acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node));
781 /* Decode the opcode */
783 arg = op->common.value.arg;
785 switch (walk_state->op_info->type) {
786 #ifndef ACPI_NO_METHOD_EXECUTION
788 case AML_TYPE_CREATE_FIELD:
791 * Create the field object, but the field buffer and index must
792 * be evaluated later during the execution phase
794 status = acpi_ds_create_buffer_field (op, walk_state);
795 break;
798 case AML_TYPE_NAMED_FIELD:
800 switch (op->common.aml_opcode) {
801 case AML_INDEX_FIELD_OP:
803 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node,
804 walk_state);
805 break;
807 case AML_BANK_FIELD_OP:
809 status = acpi_ds_create_bank_field (op, arg->common.node, walk_state);
810 break;
812 case AML_FIELD_OP:
814 status = acpi_ds_create_field (op, arg->common.node, walk_state);
815 break;
817 default:
818 /* All NAMED_FIELD opcodes must be handled above */
819 break;
821 break;
824 case AML_TYPE_NAMED_SIMPLE:
826 status = acpi_ds_create_operands (walk_state, arg);
827 if (ACPI_FAILURE (status)) {
828 goto cleanup;
831 switch (op->common.aml_opcode) {
832 case AML_PROCESSOR_OP:
834 status = acpi_ex_create_processor (walk_state);
835 break;
837 case AML_POWER_RES_OP:
839 status = acpi_ex_create_power_resource (walk_state);
840 break;
842 case AML_MUTEX_OP:
844 status = acpi_ex_create_mutex (walk_state);
845 break;
847 case AML_EVENT_OP:
849 status = acpi_ex_create_event (walk_state);
850 break;
852 case AML_DATA_REGION_OP:
854 status = acpi_ex_create_table_region (walk_state);
855 break;
857 case AML_ALIAS_OP:
859 status = acpi_ex_create_alias (walk_state);
860 break;
862 default:
863 /* Unknown opcode */
865 status = AE_OK;
866 goto cleanup;
869 /* Delete operands */
871 for (i = 1; i < walk_state->num_operands; i++) {
872 acpi_ut_remove_reference (walk_state->operands[i]);
873 walk_state->operands[i] = NULL;
876 break;
877 #endif /* ACPI_NO_METHOD_EXECUTION */
879 case AML_TYPE_NAMED_COMPLEX:
881 switch (op->common.aml_opcode) {
882 #ifndef ACPI_NO_METHOD_EXECUTION
883 case AML_REGION_OP:
885 * The op_region is not fully parsed at this time. Only valid argument is the space_id.
886 * (We must save the address of the AML of the address and length operands)
889 * If we have a valid region, initialize it
890 * Namespace is NOT locked at this point.
892 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), FALSE);
893 if (ACPI_FAILURE (status)) {
895 * If AE_NOT_EXIST is returned, it is not fatal
896 * because many regions get created before a handler
897 * is installed for said region.
899 if (AE_NOT_EXIST == status) {
900 status = AE_OK;
903 break;
906 case AML_NAME_OP:
908 status = acpi_ds_create_node (walk_state, node, op);
909 break;
910 #endif /* ACPI_NO_METHOD_EXECUTION */
913 default:
914 /* All NAMED_COMPLEX opcodes must be handled above */
915 /* Note: Method objects were already created in Pass 1 */
916 break;
918 break;
921 case AML_CLASS_INTERNAL:
923 /* case AML_INT_NAMEPATH_OP: */
924 break;
927 case AML_CLASS_METHOD_CALL:
929 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
930 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
931 walk_state, op, node));
934 * Lookup the method name and save the Node
936 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
937 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
938 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
939 walk_state, &(new_node));
940 if (ACPI_SUCCESS (status)) {
942 * Make sure that what we found is indeed a method
943 * We didn't search for a method on purpose, to see if the name would resolve
945 if (new_node->type != ACPI_TYPE_METHOD) {
946 status = AE_AML_OPERAND_TYPE;
949 /* We could put the returned object (Node) on the object stack for later, but
950 * for now, we will put it in the "op" object that the parser uses, so we
951 * can get it again at the end of this scope
953 op->common.node = new_node;
955 else {
956 ACPI_REPORT_NSERROR (arg->common.value.string, status);
958 break;
961 default:
962 break;
965 cleanup:
967 /* Remove the Node pushed at the very beginning */
969 walk_state->operands[0] = NULL;
970 walk_state->num_operands = 0;
971 return_ACPI_STATUS (status);