1 /******************************************************************************
2  *
3  * Module Name: excreate - Named object creation
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
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.
20  *
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
27  *
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;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
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.
53  *
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.
65  *
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.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
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.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
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 
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government. In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************
116  *
117  * Alternatively, you may choose to be licensed under the terms of the
118  * following license:
119  *
120  * Redistribution and use in source and binary forms, with or without
121  * modification, are permitted provided that the following conditions
122  * are met:
123  * 1. Redistributions of source code must retain the above copyright
124  *    notice, this list of conditions, and the following disclaimer,
125  *    without modification.
126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127  *    substantially similar to the "NO WARRANTY" disclaimer below
128  *    ("Disclaimer") and any redistribution must be conditioned upon
129  *    including a substantially similar Disclaimer requirement for further
130  *    binary redistribution.
131  * 3. Neither the names of the above-listed copyright holders nor the names
132  *    of any contributors may be used to endorse or promote products derived
133  *    from this software without specific prior written permission.
134  *
135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146  *
147  * Alternatively, you may choose to be licensed under the terms of the
148  * GNU General Public License ("GPL") version 2 as published by the Free
149  * Software Foundation.
150  *
151  *****************************************************************************/
152 
153 #include "acpi.h"
154 #include "accommon.h"
155 #include "acinterp.h"
156 #include "amlcode.h"
157 #include "acnamesp.h"
158 
159 
160 #define _COMPONENT          ACPI_EXECUTER
161         ACPI_MODULE_NAME    ("excreate")
162 
163 
164 #ifndef ACPI_NO_METHOD_EXECUTION
165 /*******************************************************************************
166  *
167  * FUNCTION:    AcpiExCreateAlias
168  *
169  * PARAMETERS:  WalkState            - Current state, contains operands
170  *
171  * RETURN:      Status
172  *
173  * DESCRIPTION: Create a new named alias
174  *
175  ******************************************************************************/
176 
177 ACPI_STATUS
178 AcpiExCreateAlias (
179     ACPI_WALK_STATE         *WalkState)
180 {
181     ACPI_NAMESPACE_NODE     *TargetNode;
182     ACPI_NAMESPACE_NODE     *AliasNode;
183     ACPI_STATUS             Status = AE_OK;
184 
185 
186     ACPI_FUNCTION_TRACE (ExCreateAlias);
187 
188 
189     /* Get the source/alias operands (both namespace nodes) */
190 
191     AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
192     TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
193 
194     if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
195         (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
196     {
197         /*
198          * Dereference an existing alias so that we don't create a chain
199          * of aliases. With this code, we guarantee that an alias is
200          * always exactly one level of indirection away from the
201          * actual aliased name.
202          */
203         TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
204     }
205 
206     /*
207      * For objects that can never change (i.e., the NS node will
208      * permanently point to the same object), we can simply attach
209      * the object to the new NS node. For other objects (such as
210      * Integers, buffers, etc.), we have to point the Alias node
211      * to the original Node.
212      */
213     switch (TargetNode->Type)
214     {
215 
216     /* For these types, the sub-object can change dynamically via a Store */
217 
218     case ACPI_TYPE_INTEGER:
219     case ACPI_TYPE_STRING:
220     case ACPI_TYPE_BUFFER:
221     case ACPI_TYPE_PACKAGE:
222     case ACPI_TYPE_BUFFER_FIELD:
223     /*
224      * These types open a new scope, so we need the NS node in order to access
225      * any children.
226      */
227     case ACPI_TYPE_DEVICE:
228     case ACPI_TYPE_POWER:
229     case ACPI_TYPE_PROCESSOR:
230     case ACPI_TYPE_THERMAL:
231     case ACPI_TYPE_LOCAL_SCOPE:
232         /*
233          * The new alias has the type ALIAS and points to the original
234          * NS node, not the object itself.
235          */
236         AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
237         AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
238         break;
239 
240     case ACPI_TYPE_METHOD:
241         /*
242          * Control method aliases need to be differentiated
243          */
244         AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
245         AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
246         break;
247 
248     default:
249 
250         /* Attach the original source object to the new Alias Node */
251 
252         /*
253          * The new alias assumes the type of the target, and it points
254          * to the same object. The reference count of the object has an
255          * additional reference to prevent deletion out from under either the
256          * target node or the alias Node
257          */
258         Status = AcpiNsAttachObject (AliasNode,
259             AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
260         break;
261     }
262 
263     /* Since both operands are Nodes, we don't need to delete them */
264 
265     return_ACPI_STATUS (Status);
266 }
267 
268 
269 /*******************************************************************************
270  *
271  * FUNCTION:    AcpiExCreateEvent
272  *
273  * PARAMETERS:  WalkState           - Current state
274  *
275  * RETURN:      Status
276  *
277  * DESCRIPTION: Create a new event object
278  *
279  ******************************************************************************/
280 
281 ACPI_STATUS
282 AcpiExCreateEvent (
283     ACPI_WALK_STATE         *WalkState)
284 {
285     ACPI_STATUS             Status;
286     ACPI_OPERAND_OBJECT     *ObjDesc;
287 
288 
289     ACPI_FUNCTION_TRACE (ExCreateEvent);
290 
291 
292     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
293     if (!ObjDesc)
294     {
295         Status = AE_NO_MEMORY;
296         goto Cleanup;
297     }
298 
299     /*
300      * Create the actual OS semaphore, with zero initial units -- meaning
301      * that the event is created in an unsignalled state
302      */
303     Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
304         &ObjDesc->Event.OsSemaphore);
305     if (ACPI_FAILURE (Status))
306     {
307         goto Cleanup;
308     }
309 
310     /* Attach object to the Node */
311 
312     Status = AcpiNsAttachObject (
313         (ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
314         ObjDesc, ACPI_TYPE_EVENT);
315 
316 Cleanup:
317     /*
318      * Remove local reference to the object (on error, will cause deletion
319      * of both object and semaphore if present.)
320      */
321     AcpiUtRemoveReference (ObjDesc);
322     return_ACPI_STATUS (Status);
323 }
324 
325 
326 /*******************************************************************************
327  *
328  * FUNCTION:    AcpiExCreateMutex
329  *
330  * PARAMETERS:  WalkState           - Current state
331  *
332  * RETURN:      Status
333  *
334  * DESCRIPTION: Create a new mutex object
335  *
336  *              Mutex (Name[0], SyncLevel[1])
337  *
338  ******************************************************************************/
339 
340 ACPI_STATUS
341 AcpiExCreateMutex (
342     ACPI_WALK_STATE         *WalkState)
343 {
344     ACPI_STATUS             Status = AE_OK;
345     ACPI_OPERAND_OBJECT     *ObjDesc;
346 
347 
348     ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
349 
350 
351     /* Create the new mutex object */
352 
353     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
354     if (!ObjDesc)
355     {
356         Status = AE_NO_MEMORY;
357         goto Cleanup;
358     }
359 
360     /* Create the actual OS Mutex */
361 
362     Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
363     if (ACPI_FAILURE (Status))
364     {
365         goto Cleanup;
366     }
367 
368     /* Init object and attach to NS node */
369 
370     ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
371     ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
372 
373     Status = AcpiNsAttachObject (
374         ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
375 
376 
377 Cleanup:
378     /*
379      * Remove local reference to the object (on error, will cause deletion
380      * of both object and semaphore if present.)
381      */
382     AcpiUtRemoveReference (ObjDesc);
383     return_ACPI_STATUS (Status);
384 }
385 
386 
387 /*******************************************************************************
388  *
389  * FUNCTION:    AcpiExCreateRegion
390  *
391  * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
392  *              AmlLength           - Max length of the declaration AML
393  *              SpaceId             - Address space ID for the region
394  *              WalkState           - Current state
395  *
396  * RETURN:      Status
397  *
398  * DESCRIPTION: Create a new operation region object
399  *
400  ******************************************************************************/
401 
402 ACPI_STATUS
403 AcpiExCreateRegion (
404     UINT8                   *AmlStart,
405     UINT32                  AmlLength,
406     UINT8                   SpaceId,
407     ACPI_WALK_STATE         *WalkState)
408 {
409     ACPI_STATUS             Status;
410     ACPI_OPERAND_OBJECT     *ObjDesc;
411     ACPI_NAMESPACE_NODE     *Node;
412     ACPI_OPERAND_OBJECT     *RegionObj2;
413 
414 
415     ACPI_FUNCTION_TRACE (ExCreateRegion);
416 
417 
418     /* Get the Namespace Node */
419 
420     Node = WalkState->Op->Common.Node;
421 
422     /*
423      * If the region object is already attached to this node,
424      * just return
425      */
426     if (AcpiNsGetAttachedObject (Node))
427     {
428         return_ACPI_STATUS (AE_OK);
429     }
430 
431     /*
432      * Space ID must be one of the predefined IDs, or in the user-defined
433      * range
434      */
435     if (!AcpiIsValidSpaceId (SpaceId))
436     {
437         /*
438          * Print an error message, but continue. We don't want to abort
439          * a table load for this exception. Instead, if the region is
440          * actually used at runtime, abort the executing method.
441          */
442         ACPI_ERROR ((AE_INFO,
443             "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
444     }
445 
446     ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
447         AcpiUtGetRegionName (SpaceId), SpaceId));
448 
449     /* Create the region descriptor */
450 
451     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
452     if (!ObjDesc)
453     {
454         Status = AE_NO_MEMORY;
455         goto Cleanup;
456     }
457 
458     /*
459      * Remember location in AML stream of address & length
460      * operands since they need to be evaluated at run time.
461      */
462     RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
463     RegionObj2->Extra.AmlStart = AmlStart;
464     RegionObj2->Extra.AmlLength = AmlLength;
465     RegionObj2->Extra.Method_REG = NULL;
466     if (WalkState->ScopeInfo)
467     {
468         RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
469     }
470     else
471     {
472         RegionObj2->Extra.ScopeNode = Node;
473     }
474 
475     /* Init the region from the operands */
476 
477     ObjDesc->Region.SpaceId = SpaceId;
478     ObjDesc->Region.Address = 0;
479     ObjDesc->Region.Length = 0;
480     ObjDesc->Region.Node = Node;
481     ObjDesc->Region.Handler = NULL;
482     ObjDesc->Common.Flags &=
483         ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
484           AOPOBJ_OBJECT_INITIALIZED);
485 
486     /* Install the new region object in the parent Node */
487 
488     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
489 
490 
491 Cleanup:
492 
493     /* Remove local reference to the object */
494 
495     AcpiUtRemoveReference (ObjDesc);
496     return_ACPI_STATUS (Status);
497 }
498 
499 
500 /*******************************************************************************
501  *
502  * FUNCTION:    AcpiExCreateProcessor
503  *
504  * PARAMETERS:  WalkState           - Current state
505  *
506  * RETURN:      Status
507  *
508  * DESCRIPTION: Create a new processor object and populate the fields
509  *
510  *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
511  *
512  ******************************************************************************/
513 
514 ACPI_STATUS
515 AcpiExCreateProcessor (
516     ACPI_WALK_STATE         *WalkState)
517 {
518     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
519     ACPI_OPERAND_OBJECT     *ObjDesc;
520     ACPI_STATUS             Status;
521 
522 
523     ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
524 
525 
526     /* Create the processor object */
527 
528     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
529     if (!ObjDesc)
530     {
531         return_ACPI_STATUS (AE_NO_MEMORY);
532     }
533 
534     /* Initialize the processor object from the operands */
535 
536     ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
537     ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
538     ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
539 
540     /* Install the processor object in the parent Node */
541 
542     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
543         ObjDesc, ACPI_TYPE_PROCESSOR);
544 
545     /* Remove local reference to the object */
546 
547     AcpiUtRemoveReference (ObjDesc);
548     return_ACPI_STATUS (Status);
549 }
550 
551 
552 /*******************************************************************************
553  *
554  * FUNCTION:    AcpiExCreatePowerResource
555  *
556  * PARAMETERS:  WalkState           - Current state
557  *
558  * RETURN:      Status
559  *
560  * DESCRIPTION: Create a new PowerResource object and populate the fields
561  *
562  *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
563  *
564  ******************************************************************************/
565 
566 ACPI_STATUS
567 AcpiExCreatePowerResource (
568     ACPI_WALK_STATE         *WalkState)
569 {
570     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
571     ACPI_STATUS             Status;
572     ACPI_OPERAND_OBJECT     *ObjDesc;
573 
574 
575     ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
576 
577 
578     /* Create the power resource object */
579 
580     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
581     if (!ObjDesc)
582     {
583         return_ACPI_STATUS (AE_NO_MEMORY);
584     }
585 
586     /* Initialize the power object from the operands */
587 
588     ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
589     ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
590 
591     /* Install the  power resource object in the parent Node */
592 
593     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
594         ObjDesc, ACPI_TYPE_POWER);
595 
596     /* Remove local reference to the object */
597 
598     AcpiUtRemoveReference (ObjDesc);
599     return_ACPI_STATUS (Status);
600 }
601 #endif
602 
603 
604 /*******************************************************************************
605  *
606  * FUNCTION:    AcpiExCreateMethod
607  *
608  * PARAMETERS:  AmlStart        - First byte of the method's AML
609  *              AmlLength       - AML byte count for this method
610  *              WalkState       - Current state
611  *
612  * RETURN:      Status
613  *
614  * DESCRIPTION: Create a new method object
615  *
616  ******************************************************************************/
617 
618 ACPI_STATUS
619 AcpiExCreateMethod (
620     UINT8                   *AmlStart,
621     UINT32                  AmlLength,
622     ACPI_WALK_STATE         *WalkState)
623 {
624     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
625     ACPI_OPERAND_OBJECT     *ObjDesc;
626     ACPI_STATUS             Status;
627     UINT8                   MethodFlags;
628 
629 
630     ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
631 
632 
633     /* Create a new method object */
634 
635     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
636     if (!ObjDesc)
637     {
638        Status = AE_NO_MEMORY;
639        goto Exit;
640     }
641 
642     /* Save the method's AML pointer and length  */
643 
644     ObjDesc->Method.AmlStart = AmlStart;
645     ObjDesc->Method.AmlLength = AmlLength;
646     ObjDesc->Method.Node = Operand[0];
647 
648     /*
649      * Disassemble the method flags. Split off the ArgCount, Serialized
650      * flag, and SyncLevel for efficiency.
651      */
652     MethodFlags = (UINT8) Operand[1]->Integer.Value;
653     ObjDesc->Method.ParamCount = (UINT8)
654         (MethodFlags & AML_METHOD_ARG_COUNT);
655 
656     /*
657      * Get the SyncLevel. If method is serialized, a mutex will be
658      * created for this method when it is parsed.
659      */
660     if (MethodFlags & AML_METHOD_SERIALIZED)
661     {
662         ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
663 
664         /*
665          * ACPI 1.0: SyncLevel = 0
666          * ACPI 2.0: SyncLevel = SyncLevel in method declaration
667          */
668         ObjDesc->Method.SyncLevel = (UINT8)
669             ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
670     }
671 
672     /* Attach the new object to the method Node */
673 
674     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
675         ObjDesc, ACPI_TYPE_METHOD);
676 
677     /* Remove local reference to the object */
678 
679     AcpiUtRemoveReference (ObjDesc);
680 
681 Exit:
682     /* Remove a reference to the operand */
683 
684     AcpiUtRemoveReference (Operand[1]);
685     return_ACPI_STATUS (Status);
686 }
687