Deleted Added
sdiff udiff text old ( 80062 ) new ( 82367 )
full compact
1/******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 * $Revision: 71 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
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#define __DSOBJECT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
123#include "acinterp.h"
124#include "acnamesp.h"
125
126#define _COMPONENT ACPI_DISPATCHER
127 MODULE_NAME ("dsobject")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION: AcpiDsInitOneObject
133 *
134 * PARAMETERS: ObjHandle - Node
135 * Level - Current nesting level
136 * Context - Points to a init info struct
137 * ReturnValue - Not used
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
142 * within the namespace.
143 *
144 * Currently, the only objects that require initialization are:
145 * 1) Methods
146 * 2) Op Regions
147 *
148 ******************************************************************************/
149
150ACPI_STATUS
151AcpiDsInitOneObject (
152 ACPI_HANDLE ObjHandle,
153 UINT32 Level,
154 void *Context,
155 void **ReturnValue)
156{
157 ACPI_OBJECT_TYPE8 Type;
158 ACPI_STATUS Status;
159 ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
160 UINT8 TableRevision;
161
162
163 PROC_NAME ("DsInitOneObject");
164
165
166 Info->ObjectCount++;
167 TableRevision = Info->TableDesc->Pointer->Revision;
168
169 /*
170 * We are only interested in objects owned by the table that
171 * was just loaded
172 */
173
174 if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId !=
175 Info->TableDesc->TableId)
176 {
177 return (AE_OK);
178 }
179
180
181 /* And even then, we are only interested in a few object types */
182
183 Type = AcpiNsGetType (ObjHandle);
184
185 switch (Type)
186 {
187
188 case ACPI_TYPE_REGION:
189
190 AcpiDsInitializeRegion (ObjHandle);
191
192 Info->OpRegionCount++;
193 break;
194
195
196 case ACPI_TYPE_METHOD:
197
198 Info->MethodCount++;
199
200 if (!(AcpiDbgLevel & ACPI_LV_INIT))
201 {
202 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
203 }
204
205 /*
206 * Set the execution data width (32 or 64) based upon the
207 * revision number of the parent ACPI table.
208 */
209
210 if (TableRevision == 1)
211 {
212 ((ACPI_NAMESPACE_NODE *)ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32;
213 }
214
215 /*
216 * Always parse methods to detect errors, we may delete
217 * the parse tree below
218 */
219
220 Status = AcpiDsParseMethod (ObjHandle);
221
222 /* TBD: [Errors] what do we do with an error? */
223
224 if (ACPI_FAILURE (Status))
225 {
226 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] parse failed! %s\n",
227 ObjHandle, &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name,
228 AcpiFormatException (Status)));
229 break;
230 }
231
232 /*
233 * Delete the parse tree. We simple re-parse the method
234 * for every execution since there isn't much overhead
235 */
236 AcpiNsDeleteNamespaceSubtree (ObjHandle);
237 break;
238
239 default:
240 break;
241 }
242
243 /*
244 * We ignore errors from above, and always return OK, since
245 * we don't want to abort the walk on a single error.
246 */
247 return (AE_OK);
248}
249
250
251/*******************************************************************************
252 *
253 * FUNCTION: AcpiDsInitializeObjects
254 *
255 * PARAMETERS: None
256 *
257 * RETURN: Status
258 *
259 * DESCRIPTION: Walk the entire namespace and perform any necessary
260 * initialization on the objects found therein
261 *
262 ******************************************************************************/
263
264ACPI_STATUS
265AcpiDsInitializeObjects (
266 ACPI_TABLE_DESC *TableDesc,
267 ACPI_NAMESPACE_NODE *StartNode)
268{
269 ACPI_STATUS Status;
270 ACPI_INIT_WALK_INFO Info;
271
272
273 FUNCTION_TRACE ("DsInitializeObjects");
274
275
276 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
277 "**** Starting initialization of namespace objects ****\n"));
278 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:"));
279
280
281 Info.MethodCount = 0;
282 Info.OpRegionCount = 0;
283 Info.ObjectCount = 0;
284 Info.TableDesc = TableDesc;
285
286
287 /* Walk entire namespace from the supplied root */
288
289 Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX,
290 AcpiDsInitOneObject, &Info, NULL);
291 if (ACPI_FAILURE (Status))
292 {
293 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed! %x\n", Status));
294 }
295
296 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
297 "\n%d Control Methods found and parsed (%d nodes total)\n",
298 Info.MethodCount, Info.ObjectCount));
299 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
300 "%d Control Methods found\n", Info.MethodCount));
301 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
302 "%d Op Regions found\n", Info.OpRegionCount));
303
304 return_ACPI_STATUS (AE_OK);
305}
306
307
308/*****************************************************************************
309 *
310 * FUNCTION: AcpiDsInitObjectFromOp
311 *
312 * PARAMETERS: Op - Parser op used to init the internal object
313 * Opcode - AML opcode associated with the object
314 * ObjDesc - Namespace object to be initialized
315 *
316 * RETURN: Status
317 *
318 * DESCRIPTION: Initialize a namespace object from a parser Op and its
319 * associated arguments. The namespace object is a more compact
320 * representation of the Op and its arguments.
321 *
322 ****************************************************************************/
323
324ACPI_STATUS
325AcpiDsInitObjectFromOp (
326 ACPI_WALK_STATE *WalkState,
327 ACPI_PARSE_OBJECT *Op,
328 UINT16 Opcode,
329 ACPI_OPERAND_OBJECT **RetObjDesc)
330{
331 ACPI_STATUS Status;
332 ACPI_PARSE_OBJECT *Arg;
333 ACPI_PARSE2_OBJECT *ByteList;
334 ACPI_OPERAND_OBJECT *ArgDesc;
335 ACPI_OPCODE_INFO *OpInfo;
336 ACPI_OPERAND_OBJECT *ObjDesc;
337
338
339 PROC_NAME ("DsInitObjectFromOp");
340
341
342 ObjDesc = *RetObjDesc;
343 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
344 if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
345 {
346 /* Unknown opcode */
347
348 return (AE_TYPE);
349 }
350
351
352 /* Get and prepare the first argument */
353
354 switch (ObjDesc->Common.Type)
355 {
356 case ACPI_TYPE_BUFFER:
357
358 /* First arg is a number */
359
360 AcpiDsCreateOperand (WalkState, Op->Value.Arg, 0);
361 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
362 AcpiDsObjStackPop (1, WalkState);
363
364 /* Resolve the object (could be an arg or local) */
365
366 Status = AcpiExResolveToValue (&ArgDesc, WalkState);
367 if (ACPI_FAILURE (Status))
368 {
369 AcpiUtRemoveReference (ArgDesc);
370 return (Status);
371 }
372
373 /* We are expecting a number */
374
375 if (ArgDesc->Common.Type != ACPI_TYPE_INTEGER)
376 {
377 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
378 "Expecting number, got obj: %p type %X\n",
379 ArgDesc, ArgDesc->Common.Type));
380 AcpiUtRemoveReference (ArgDesc);
381 return (AE_TYPE);
382 }
383
384 /* Get the value, delete the internal object */
385
386 ObjDesc->Buffer.Length = (UINT32) ArgDesc->Integer.Value;
387 AcpiUtRemoveReference (ArgDesc);
388
389 /* Allocate the buffer */
390
391 if (ObjDesc->Buffer.Length == 0)
392 {
393 ObjDesc->Buffer.Pointer = NULL;
394 REPORT_WARNING (("Buffer created with zero length in AML\n"));
395 break;
396 }
397
398 else
399 {
400 ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE (
401 ObjDesc->Buffer.Length);
402
403 if (!ObjDesc->Buffer.Pointer)
404 {
405 return (AE_NO_MEMORY);
406 }
407 }
408
409 /*
410 * Second arg is the buffer data (optional) ByteList can be either
411 * individual bytes or a string initializer.
412 */
413
414 Arg = Op->Value.Arg; /* skip first arg */
415
416 ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next;
417 if (ByteList)
418 {
419 if (ByteList->Opcode != AML_INT_BYTELIST_OP)
420 {
421 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got: %x\n",
422 ByteList));
423 return (AE_TYPE);
424 }
425
426 MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Data,
427 ObjDesc->Buffer.Length);
428 }
429
430 break;
431
432
433 case ACPI_TYPE_PACKAGE:
434
435 /*
436 * When called, an internal package object has already been built and
437 * is pointed to by ObjDesc. AcpiDsBuildInternalObject builds another
438 * internal package object, so remove reference to the original so
439 * that it is deleted. Error checking is done within the remove
440 * reference function.
441 */
442 AcpiUtRemoveReference (ObjDesc);
443 Status = AcpiDsBuildInternalObject (WalkState, Op, RetObjDesc);
444 break;
445
446 case ACPI_TYPE_INTEGER:
447 ObjDesc->Integer.Value = Op->Value.Integer;
448 break;
449
450
451 case ACPI_TYPE_STRING:
452 ObjDesc->String.Pointer = Op->Value.String;
453 ObjDesc->String.Length = STRLEN (Op->Value.String);
454 break;
455
456
457 case ACPI_TYPE_METHOD:
458 break;
459
460
461 case INTERNAL_TYPE_REFERENCE:
462
463 switch (ACPI_GET_OP_CLASS (OpInfo))
464 {
465 case OPTYPE_LOCAL_VARIABLE:
466
467 /* Split the opcode into a base opcode + offset */
468
469 ObjDesc->Reference.Opcode = AML_LOCAL_OP;
470 ObjDesc->Reference.Offset = Opcode - AML_LOCAL_OP;
471 break;
472
473
474 case OPTYPE_METHOD_ARGUMENT:
475
476 /* Split the opcode into a base opcode + offset */
477
478 ObjDesc->Reference.Opcode = AML_ARG_OP;
479 ObjDesc->Reference.Offset = Opcode - AML_ARG_OP;
480 break;
481
482
483#ifdef INTEGER_CONST__
484 case OPTYPE_CONSTANT:
485
486 /* TBD: Why is the DEBUG object a CONSTANT? */
487
488 if (Op->Opcode == AML_DEBUG_OP)
489 {
490 break;
491 }
492
493 /* Reference object no longer needed */
494
495 AcpiUtRemoveReference (ObjDesc);
496
497 /* Create/Init a new Integer object */
498
499 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
500 if (!ObjDesc)
501 {
502 return_ACPI_STATUS (AE_NO_MEMORY);
503 }
504
505 /*
506 * Decode constants here. Turn them into real integer objects
507 * that are initialized to the value of the constant.
508 */
509 switch (Op->Opcode)
510 {
511 case AML_ONE_OP:
512 ObjDesc->Integer.Value = 1;
513 break;
514
515 case AML_ONES_OP:
516 ObjDesc->Integer.Value = ACPI_INTEGER_MAX;
517 break;
518
519 case AML_REVISION_OP:
520 ObjDesc->Integer.Value = ACPI_CA_VERSION;
521 break;
522
523 case AML_ZERO_OP:
524 ObjDesc->Integer.Flags |= AOPOBJ_ZERO_CONST;
525 ObjDesc->Integer.Value = 0;
526 break;
527
528 default:
529 ObjDesc->Integer.Value = 0;
530 break;
531 }
532
533 *RetObjDesc = ObjDesc;
534 break;
535#endif
536
537 default: /* Constants, Literals, etc.. */
538
539 if (Op->Opcode == AML_INT_NAMEPATH_OP)
540 {
541 /* Node was saved in Op */
542
543 ObjDesc->Reference.Node = Op->Node;
544 }
545
546 ObjDesc->Reference.Opcode = Opcode;
547 break;
548 }
549
550 break;
551
552
553 default:
554
555 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %x\n",
556 ObjDesc->Common.Type));
557
558 break;
559 }
560
561 return (AE_OK);
562}
563
564
565/*****************************************************************************
566 *
567 * FUNCTION: AcpiDsBuildInternalSimpleObj
568 *
569 * PARAMETERS: Op - Parser object to be translated
570 * ObjDescPtr - Where the ACPI internal object is returned
571 *
572 * RETURN: Status
573 *
574 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
575 * Simple objects are any objects other than a package object!
576 *
577 ****************************************************************************/
578
579static ACPI_STATUS
580AcpiDsBuildInternalSimpleObj (
581 ACPI_WALK_STATE *WalkState,
582 ACPI_PARSE_OBJECT *Op,
583 ACPI_OPERAND_OBJECT **ObjDescPtr)
584{
585 ACPI_OPERAND_OBJECT *ObjDesc;
586 ACPI_OBJECT_TYPE8 Type;
587 ACPI_STATUS Status;
588 UINT32 Length;
589 char *Name;
590
591
592 FUNCTION_TRACE ("DsBuildInternalSimpleObj");
593
594
595 if (Op->Opcode == AML_INT_NAMEPATH_OP)
596 {
597 /*
598 * This is an object reference. If The name was
599 * previously looked up in the NS, it is stored in this op.
600 * Otherwise, go ahead and look it up now
601 */
602 if (!Op->Node)
603 {
604 Status = AcpiNsLookup (WalkState->ScopeInfo,
605 Op->Value.String, ACPI_TYPE_ANY,
606 IMODE_EXECUTE,
607 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
608 NULL,
609 (ACPI_NAMESPACE_NODE **)&(Op->Node));
610
611 if (ACPI_FAILURE (Status))
612 {
613 if (Status == AE_NOT_FOUND)
614 {
615 Name = NULL;
616 AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, &Length, &Name);
617
618 if (Name)
619 {
620 REPORT_WARNING (("Reference %s at AML %X not found\n",
621 Name, Op->AmlOffset));
622 ACPI_MEM_FREE (Name);
623 }
624
625 else
626 {
627 REPORT_WARNING (("Reference %s at AML %X not found\n",
628 Op->Value.String, Op->AmlOffset));
629 }
630
631 *ObjDescPtr = NULL;
632 }
633
634 else
635 {
636 return_ACPI_STATUS (Status);
637 }
638 }
639 }
640
641 /*
642 * The reference will be a Reference
643 * TBD: [Restructure] unless we really need a separate
644 * type of INTERNAL_TYPE_REFERENCE change
645 * AcpiDsMapOpcodeToDataType to handle this case
646 */
647 Type = INTERNAL_TYPE_REFERENCE;
648 }
649 else
650 {
651 Type = AcpiDsMapOpcodeToDataType (Op->Opcode, NULL);
652 }
653
654
655 /* Create and init the internal ACPI object */
656
657 ObjDesc = AcpiUtCreateInternalObject (Type);
658 if (!ObjDesc)
659 {
660 return_ACPI_STATUS (AE_NO_MEMORY);
661 }
662
663 Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Opcode, &ObjDesc);
664 if (ACPI_FAILURE (Status))
665 {
666 AcpiUtRemoveReference (ObjDesc);
667 return_ACPI_STATUS (Status);
668 }
669
670 *ObjDescPtr = ObjDesc;
671
672 return_ACPI_STATUS (AE_OK);
673}
674
675
676/*****************************************************************************
677 *
678 * FUNCTION: AcpiDsBuildInternalPackageObj
679 *
680 * PARAMETERS: Op - Parser object to be translated
681 * ObjDescPtr - Where the ACPI internal object is returned
682 *
683 * RETURN: Status
684 *
685 * DESCRIPTION: Translate a parser Op package object to the equivalent
686 * namespace object
687 *
688 ****************************************************************************/
689
690ACPI_STATUS
691AcpiDsBuildInternalPackageObj (
692 ACPI_WALK_STATE *WalkState,
693 ACPI_PARSE_OBJECT *Op,
694 ACPI_OPERAND_OBJECT **ObjDescPtr)
695{
696 ACPI_PARSE_OBJECT *Arg;
697 ACPI_OPERAND_OBJECT *ObjDesc;
698 ACPI_STATUS Status = AE_OK;
699
700
701 FUNCTION_TRACE ("DsBuildInternalPackageObj");
702
703
704 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
705 *ObjDescPtr = ObjDesc;
706 if (!ObjDesc)
707 {
708 return_ACPI_STATUS (AE_NO_MEMORY);
709 }
710
711 if (Op->Opcode == AML_VAR_PACKAGE_OP)
712 {
713 /*
714 * Variable length package parameters are evaluated JIT
715 */
716 return_ACPI_STATUS (AE_OK);
717 }
718
719 /* The first argument must be the package length */
720
721 Arg = Op->Value.Arg;
722 ObjDesc->Package.Count = Arg->Value.Integer32;
723
724 /*
725 * Allocate the array of pointers (ptrs to the
726 * individual objects) Add an extra pointer slot so
727 * that the list is always null terminated.
728 */
729 ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE (
730 (ObjDesc->Package.Count + 1) * sizeof (void *));
731
732 if (!ObjDesc->Package.Elements)
733 {
734 AcpiUtDeleteObjectDesc (ObjDesc);
735 return_ACPI_STATUS (AE_NO_MEMORY);
736 }
737
738 ObjDesc->Package.NextElement = ObjDesc->Package.Elements;
739
740 /*
741 * Now init the elements of the package
742 */
743 Arg = Arg->Next;
744 while (Arg)
745 {
746 if (Arg->Opcode == AML_PACKAGE_OP)
747 {
748 Status = AcpiDsBuildInternalPackageObj (WalkState, Arg,
749 ObjDesc->Package.NextElement);
750 }
751
752 else
753 {
754 Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg,
755 ObjDesc->Package.NextElement);
756 }
757
758 ObjDesc->Package.NextElement++;
759 Arg = Arg->Next;
760 }
761
762 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
763 return_ACPI_STATUS (Status);
764}
765
766
767/*****************************************************************************
768 *
769 * FUNCTION: AcpiDsBuildInternalObject
770 *
771 * PARAMETERS: Op - Parser object to be translated
772 * ObjDescPtr - Where the ACPI internal object is returned
773 *
774 * RETURN: Status
775 *
776 * DESCRIPTION: Translate a parser Op object to the equivalent namespace
777 * object
778 *
779 ****************************************************************************/
780
781ACPI_STATUS
782AcpiDsBuildInternalObject (
783 ACPI_WALK_STATE *WalkState,
784 ACPI_PARSE_OBJECT *Op,
785 ACPI_OPERAND_OBJECT **ObjDescPtr)
786{
787 ACPI_STATUS Status;
788
789
790 switch (Op->Opcode)
791 {
792 case AML_PACKAGE_OP:
793 case AML_VAR_PACKAGE_OP:
794
795 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, ObjDescPtr);
796 break;
797
798
799 default:
800
801 Status = AcpiDsBuildInternalSimpleObj (WalkState, Op, ObjDescPtr);
802 break;
803 }
804
805 return (Status);
806}
807
808
809/*****************************************************************************
810 *
811 * FUNCTION: AcpiDsCreateNode
812 *
813 * PARAMETERS: Op - Parser object to be translated
814 * ObjDescPtr - Where the ACPI internal object is returned
815 *
816 * RETURN: Status
817 *
818 * DESCRIPTION:
819 *
820 ****************************************************************************/
821
822ACPI_STATUS
823AcpiDsCreateNode (
824 ACPI_WALK_STATE *WalkState,
825 ACPI_NAMESPACE_NODE *Node,
826 ACPI_PARSE_OBJECT *Op)
827{
828 ACPI_STATUS Status;
829 ACPI_OPERAND_OBJECT *ObjDesc;
830
831
832 FUNCTION_TRACE_PTR ("DsCreateNode", Op);
833
834
835 if (!Op->Value.Arg)
836 {
837 /* No arguments, there is nothing to do */
838
839 return_ACPI_STATUS (AE_OK);
840 }
841
842
843 /* Build an internal object for the argument(s) */
844
845 Status = AcpiDsBuildInternalObject (WalkState, Op->Value.Arg, &ObjDesc);
846 if (ACPI_FAILURE (Status))
847 {
848 return_ACPI_STATUS (Status);
849 }
850
851
852 /* Re-type the object according to it's argument */
853
854 Node->Type = ObjDesc->Common.Type;
855
856 /* Init obj */
857
858 Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) Node->Type);
859 if (ACPI_FAILURE (Status))
860 {
861 goto Cleanup;
862 }
863
864 return_ACPI_STATUS (Status);
865
866
867Cleanup:
868
869 AcpiUtRemoveReference (ObjDesc);
870
871 return_ACPI_STATUS (Status);
872}
873
874