vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / bus_managers / acpi / acpica / components / dispatcher / dswload2.c
blob46870830f44bc5765bded91dda4f7bba0fad76ed
1 /******************************************************************************
3 * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acparser.h"
155 #include "amlcode.h"
156 #include "acdispat.h"
157 #include "acinterp.h"
158 #include "acnamesp.h"
159 #include "acevents.h"
161 #define _COMPONENT ACPI_DISPATCHER
162 ACPI_MODULE_NAME ("dswload2")
165 /*******************************************************************************
167 * FUNCTION: AcpiDsLoad2BeginOp
169 * PARAMETERS: WalkState - Current state of the parse tree walk
170 * OutOp - Wher to return op if a new one is created
172 * RETURN: Status
174 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
176 ******************************************************************************/
178 ACPI_STATUS
179 AcpiDsLoad2BeginOp (
180 ACPI_WALK_STATE *WalkState,
181 ACPI_PARSE_OBJECT **OutOp)
183 ACPI_PARSE_OBJECT *Op;
184 ACPI_NAMESPACE_NODE *Node;
185 ACPI_STATUS Status;
186 ACPI_OBJECT_TYPE ObjectType;
187 char *BufferPtr;
188 UINT32 Flags;
191 ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
194 Op = WalkState->Op;
195 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
197 if (Op)
199 if ((WalkState->ControlState) &&
200 (WalkState->ControlState->Common.State ==
201 ACPI_CONTROL_CONDITIONAL_EXECUTING))
203 /* We are executing a while loop outside of a method */
205 Status = AcpiDsExecBeginOp (WalkState, OutOp);
206 return_ACPI_STATUS (Status);
209 /* We only care about Namespace opcodes here */
211 if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
212 (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
213 (!(WalkState->OpInfo->Flags & AML_NAMED)))
215 return_ACPI_STATUS (AE_OK);
218 /* Get the name we are going to enter or lookup in the namespace */
220 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
222 /* For Namepath op, get the path string */
224 BufferPtr = Op->Common.Value.String;
225 if (!BufferPtr)
227 /* No name, just exit */
229 return_ACPI_STATUS (AE_OK);
232 else
234 /* Get name from the op */
236 BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
239 else
241 /* Get the namestring from the raw AML */
243 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
246 /* Map the opcode into an internal object type */
248 ObjectType = WalkState->OpInfo->ObjectType;
250 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
251 "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
253 switch (WalkState->Opcode)
255 case AML_FIELD_OP:
256 case AML_BANK_FIELD_OP:
257 case AML_INDEX_FIELD_OP:
259 Node = NULL;
260 Status = AE_OK;
261 break;
263 case AML_INT_NAMEPATH_OP:
265 * The NamePath is an object reference to an existing object.
266 * Don't enter the name into the namespace, but look it up
267 * for use later.
269 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
270 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
271 WalkState, &(Node));
272 break;
274 case AML_SCOPE_OP:
276 /* Special case for Scope(\) -> refers to the Root node */
278 if (Op && (Op->Named.Node == AcpiGbl_RootNode))
280 Node = Op->Named.Node;
282 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
283 if (ACPI_FAILURE (Status))
285 return_ACPI_STATUS (Status);
288 else
291 * The Path is an object reference to an existing object.
292 * Don't enter the name into the namespace, but look it up
293 * for use later.
295 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
296 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
297 WalkState, &(Node));
298 if (ACPI_FAILURE (Status))
300 #ifdef ACPI_ASL_COMPILER
301 if (Status == AE_NOT_FOUND)
303 Status = AE_OK;
305 else
307 ACPI_ERROR_NAMESPACE (BufferPtr, Status);
309 #else
310 ACPI_ERROR_NAMESPACE (BufferPtr, Status);
311 #endif
312 return_ACPI_STATUS (Status);
317 * We must check to make sure that the target is
318 * one of the opcodes that actually opens a scope
320 switch (Node->Type)
322 case ACPI_TYPE_ANY:
323 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
324 case ACPI_TYPE_DEVICE:
325 case ACPI_TYPE_POWER:
326 case ACPI_TYPE_PROCESSOR:
327 case ACPI_TYPE_THERMAL:
329 /* These are acceptable types */
330 break;
332 case ACPI_TYPE_INTEGER:
333 case ACPI_TYPE_STRING:
334 case ACPI_TYPE_BUFFER:
337 * These types we will allow, but we will change the type.
338 * This enables some existing code of the form:
340 * Name (DEB, 0)
341 * Scope (DEB) { ... }
343 ACPI_WARNING ((AE_INFO,
344 "Type override - [%4.4s] had invalid type (%s) "
345 "for Scope operator, changed to type ANY",
346 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
348 Node->Type = ACPI_TYPE_ANY;
349 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
350 break;
352 case ACPI_TYPE_METHOD:
355 * Allow scope change to root during execution of module-level
356 * code. Root is typed METHOD during this time.
358 if ((Node == AcpiGbl_RootNode) &&
359 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
361 break;
364 /*lint -fallthrough */
366 default:
368 /* All other types are an error */
370 ACPI_ERROR ((AE_INFO,
371 "Invalid type (%s) for target of "
372 "Scope operator [%4.4s] (Cannot override)",
373 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
375 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
377 break;
379 default:
381 /* All other opcodes */
383 if (Op && Op->Common.Node)
385 /* This op/node was previously entered into the namespace */
387 Node = Op->Common.Node;
389 if (AcpiNsOpensScope (ObjectType))
391 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
392 if (ACPI_FAILURE (Status))
394 return_ACPI_STATUS (Status);
398 return_ACPI_STATUS (AE_OK);
402 * Enter the named type into the internal namespace. We enter the name
403 * as we go downward in the parse tree. Any necessary subobjects that
404 * involve arguments to the opcode must be created as we go back up the
405 * parse tree later.
407 * Note: Name may already exist if we are executing a deferred opcode.
409 if (WalkState->DeferredNode)
411 /* This name is already in the namespace, get the node */
413 Node = WalkState->DeferredNode;
414 Status = AE_OK;
415 break;
418 Flags = ACPI_NS_NO_UPSEARCH;
419 if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
421 /* Execution mode, node cannot already exist, node is temporary */
423 Flags |= ACPI_NS_ERROR_IF_FOUND;
425 if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
427 Flags |= ACPI_NS_TEMPORARY;
431 /* Add new entry or lookup existing entry */
433 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
434 ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
436 if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
438 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
439 "***New Node [%4.4s] %p is temporary\n",
440 AcpiUtGetNodeName (Node), Node));
442 break;
445 if (ACPI_FAILURE (Status))
447 ACPI_ERROR_NAMESPACE (BufferPtr, Status);
448 return_ACPI_STATUS (Status);
451 if (!Op)
453 /* Create a new op */
455 Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
456 if (!Op)
458 return_ACPI_STATUS (AE_NO_MEMORY);
461 /* Initialize the new op */
463 if (Node)
465 Op->Named.Name = Node->Name.Integer;
467 *OutOp = Op;
471 * Put the Node in the "op" object that the parser uses, so we
472 * can get it again quickly when this scope is closed
474 Op->Common.Node = Node;
475 return_ACPI_STATUS (Status);
479 /*******************************************************************************
481 * FUNCTION: AcpiDsLoad2EndOp
483 * PARAMETERS: WalkState - Current state of the parse tree walk
485 * RETURN: Status
487 * DESCRIPTION: Ascending callback used during the loading of the namespace,
488 * both control methods and everything else.
490 ******************************************************************************/
492 ACPI_STATUS
493 AcpiDsLoad2EndOp (
494 ACPI_WALK_STATE *WalkState)
496 ACPI_PARSE_OBJECT *Op;
497 ACPI_STATUS Status = AE_OK;
498 ACPI_OBJECT_TYPE ObjectType;
499 ACPI_NAMESPACE_NODE *Node;
500 ACPI_PARSE_OBJECT *Arg;
501 ACPI_NAMESPACE_NODE *NewNode;
502 #ifndef ACPI_NO_METHOD_EXECUTION
503 UINT32 i;
504 UINT8 RegionSpace;
505 #endif
508 ACPI_FUNCTION_TRACE (DsLoad2EndOp);
510 Op = WalkState->Op;
511 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
512 WalkState->OpInfo->Name, Op, WalkState));
514 /* Check if opcode had an associated namespace object */
516 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
518 return_ACPI_STATUS (AE_OK);
521 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
523 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
524 "Ending scope Op=%p State=%p\n", Op, WalkState));
527 ObjectType = WalkState->OpInfo->ObjectType;
530 * Get the Node/name from the earlier lookup
531 * (It was saved in the *op structure)
533 Node = Op->Common.Node;
536 * Put the Node on the object stack (Contains the ACPI Name of
537 * this object)
539 WalkState->Operands[0] = (void *) Node;
540 WalkState->NumOperands = 1;
542 /* Pop the scope stack */
544 if (AcpiNsOpensScope (ObjectType) &&
545 (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
547 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
548 AcpiUtGetTypeName (ObjectType), Op));
550 Status = AcpiDsScopeStackPop (WalkState);
551 if (ACPI_FAILURE (Status))
553 goto Cleanup;
558 * Named operations are as follows:
560 * AML_ALIAS
561 * AML_BANKFIELD
562 * AML_CREATEBITFIELD
563 * AML_CREATEBYTEFIELD
564 * AML_CREATEDWORDFIELD
565 * AML_CREATEFIELD
566 * AML_CREATEQWORDFIELD
567 * AML_CREATEWORDFIELD
568 * AML_DATA_REGION
569 * AML_DEVICE
570 * AML_EVENT
571 * AML_FIELD
572 * AML_INDEXFIELD
573 * AML_METHOD
574 * AML_METHODCALL
575 * AML_MUTEX
576 * AML_NAME
577 * AML_NAMEDFIELD
578 * AML_OPREGION
579 * AML_POWERRES
580 * AML_PROCESSOR
581 * AML_SCOPE
582 * AML_THERMALZONE
585 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
586 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
587 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
589 /* Decode the opcode */
591 Arg = Op->Common.Value.Arg;
593 switch (WalkState->OpInfo->Type)
595 #ifndef ACPI_NO_METHOD_EXECUTION
597 case AML_TYPE_CREATE_FIELD:
599 * Create the field object, but the field buffer and index must
600 * be evaluated later during the execution phase
602 Status = AcpiDsCreateBufferField (Op, WalkState);
603 break;
605 case AML_TYPE_NAMED_FIELD:
607 * If we are executing a method, initialize the field
609 if (WalkState->MethodNode)
611 Status = AcpiDsInitFieldObjects (Op, WalkState);
614 switch (Op->Common.AmlOpcode)
616 case AML_INDEX_FIELD_OP:
618 Status = AcpiDsCreateIndexField (
619 Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);
620 break;
622 case AML_BANK_FIELD_OP:
624 Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
625 break;
627 case AML_FIELD_OP:
629 Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
630 break;
632 default:
634 /* All NAMED_FIELD opcodes must be handled above */
635 break;
637 break;
639 case AML_TYPE_NAMED_SIMPLE:
641 Status = AcpiDsCreateOperands (WalkState, Arg);
642 if (ACPI_FAILURE (Status))
644 goto Cleanup;
647 switch (Op->Common.AmlOpcode)
649 case AML_PROCESSOR_OP:
651 Status = AcpiExCreateProcessor (WalkState);
652 break;
654 case AML_POWER_RESOURCE_OP:
656 Status = AcpiExCreatePowerResource (WalkState);
657 break;
659 case AML_MUTEX_OP:
661 Status = AcpiExCreateMutex (WalkState);
662 break;
664 case AML_EVENT_OP:
666 Status = AcpiExCreateEvent (WalkState);
667 break;
669 case AML_ALIAS_OP:
671 Status = AcpiExCreateAlias (WalkState);
672 break;
674 default:
676 /* Unknown opcode */
678 Status = AE_OK;
679 goto Cleanup;
682 /* Delete operands */
684 for (i = 1; i < WalkState->NumOperands; i++)
686 AcpiUtRemoveReference (WalkState->Operands[i]);
687 WalkState->Operands[i] = NULL;
690 break;
691 #endif /* ACPI_NO_METHOD_EXECUTION */
693 case AML_TYPE_NAMED_COMPLEX:
695 switch (Op->Common.AmlOpcode)
697 #ifndef ACPI_NO_METHOD_EXECUTION
698 case AML_REGION_OP:
699 case AML_DATA_REGION_OP:
701 if (Op->Common.AmlOpcode == AML_REGION_OP)
703 RegionSpace = (ACPI_ADR_SPACE_TYPE)
704 ((Op->Common.Value.Arg)->Common.Value.Integer);
706 else
708 RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
712 * The OpRegion is not fully parsed at this time. The only valid
713 * argument is the SpaceId. (We must save the address of the
714 * AML of the address and length operands)
716 * If we have a valid region, initialize it. The namespace is
717 * unlocked at this point.
719 * Need to unlock interpreter if it is locked (if we are running
720 * a control method), in order to allow _REG methods to be run
721 * during AcpiEvInitializeRegion.
723 if (WalkState->MethodNode)
726 * Executing a method: initialize the region and unlock
727 * the interpreter
729 Status = AcpiExCreateRegion (Op->Named.Data,
730 Op->Named.Length, RegionSpace, WalkState);
731 if (ACPI_FAILURE (Status))
733 return_ACPI_STATUS (Status);
737 Status = AcpiEvInitializeRegion (
738 AcpiNsGetAttachedObject (Node));
739 break;
741 case AML_NAME_OP:
743 Status = AcpiDsCreateNode (WalkState, Node, Op);
744 break;
746 case AML_METHOD_OP:
748 * MethodOp PkgLength NameString MethodFlags TermList
750 * Note: We must create the method node/object pair as soon as we
751 * see the method declaration. This allows later pass1 parsing
752 * of invocations of the method (need to know the number of
753 * arguments.)
755 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
756 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
757 WalkState, Op, Op->Named.Node));
759 if (!AcpiNsGetAttachedObject (Op->Named.Node))
761 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
762 WalkState->NumOperands = 1;
764 Status = AcpiDsCreateOperands (
765 WalkState, Op->Common.Value.Arg);
766 if (ACPI_SUCCESS (Status))
768 Status = AcpiExCreateMethod (
769 Op->Named.Data, Op->Named.Length, WalkState);
772 WalkState->Operands[0] = NULL;
773 WalkState->NumOperands = 0;
775 if (ACPI_FAILURE (Status))
777 return_ACPI_STATUS (Status);
780 break;
782 #endif /* ACPI_NO_METHOD_EXECUTION */
784 default:
786 /* All NAMED_COMPLEX opcodes must be handled above */
787 break;
789 break;
791 case AML_CLASS_INTERNAL:
793 /* case AML_INT_NAMEPATH_OP: */
794 break;
796 case AML_CLASS_METHOD_CALL:
798 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
799 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
800 WalkState, Op, Node));
803 * Lookup the method name and save the Node
805 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
806 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
807 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
808 WalkState, &(NewNode));
809 if (ACPI_SUCCESS (Status))
812 * Make sure that what we found is indeed a method
813 * We didn't search for a method on purpose, to see if the name
814 * would resolve
816 if (NewNode->Type != ACPI_TYPE_METHOD)
818 Status = AE_AML_OPERAND_TYPE;
821 /* We could put the returned object (Node) on the object stack for
822 * later, but for now, we will put it in the "op" object that the
823 * parser uses, so we can get it again at the end of this scope
825 Op->Common.Node = NewNode;
827 else
829 ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
831 break;
834 default:
836 break;
839 Cleanup:
841 /* Remove the Node pushed at the very beginning */
843 WalkState->Operands[0] = NULL;
844 WalkState->NumOperands = 0;
845 return_ACPI_STATUS (Status);