Merge from vendor branch LESS:
[dragonfly.git] / sys / contrib / dev / acpica / psargs.c
1 /******************************************************************************
2  *
3  * Module Name: psargs - Parse AML opcode arguments
4  *              $Revision: 69 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/psargs.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $                                                               */
117
118 #define __PSARGS_C__
119
120 #include "acpi.h"
121 #include "acparser.h"
122 #include "amlcode.h"
123 #include "acnamesp.h"
124
125 #define _COMPONENT          ACPI_PARSER
126         ACPI_MODULE_NAME    ("psargs")
127
128
129 /*******************************************************************************
130  *
131  * FUNCTION:    AcpiPsGetNextPackageLength
132  *
133  * PARAMETERS:  ParserState         - Current parser state object
134  *
135  * RETURN:      Decoded package length.  On completion, the AML pointer points
136  *              past the length byte or bytes.
137  *
138  * DESCRIPTION: Decode and return a package length field
139  *
140  ******************************************************************************/
141
142 UINT32
143 AcpiPsGetNextPackageLength (
144     ACPI_PARSE_STATE        *ParserState)
145 {
146     UINT32                  EncodedLength;
147     UINT32                  Length = 0;
148
149
150     ACPI_FUNCTION_TRACE ("PsGetNextPackageLength");
151
152
153     EncodedLength = (UINT32) ACPI_GET8 (ParserState->Aml);
154     ParserState->Aml++;
155
156
157     switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */
158     {
159     case 0: /* 1-byte encoding (bits 0-5) */
160
161         Length = (EncodedLength & 0x3F);
162         break;
163
164
165     case 1: /* 2-byte encoding (next byte + bits 0-3) */
166
167         Length = ((ACPI_GET8 (ParserState->Aml) << 04) |
168                  (EncodedLength & 0x0F));
169         ParserState->Aml++;
170         break;
171
172
173     case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
174
175         Length = ((ACPI_GET8 (ParserState->Aml + 1) << 12) |
176                   (ACPI_GET8 (ParserState->Aml)     << 04) |
177                   (EncodedLength & 0x0F));
178         ParserState->Aml += 2;
179         break;
180
181
182     case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
183
184         Length = ((ACPI_GET8 (ParserState->Aml + 2) << 20) |
185                   (ACPI_GET8 (ParserState->Aml + 1) << 12) |
186                   (ACPI_GET8 (ParserState->Aml)     << 04) |
187                   (EncodedLength & 0x0F));
188         ParserState->Aml += 3;
189         break;
190
191     default:
192
193         /* Can't get here, only 2 bits / 4 cases */
194         break;
195     }
196
197     return_VALUE (Length);
198 }
199
200
201 /*******************************************************************************
202  *
203  * FUNCTION:    AcpiPsGetNextPackageEnd
204  *
205  * PARAMETERS:  ParserState         - Current parser state object
206  *
207  * RETURN:      Pointer to end-of-package +1
208  *
209  * DESCRIPTION: Get next package length and return a pointer past the end of
210  *              the package.  Consumes the package length field
211  *
212  ******************************************************************************/
213
214 UINT8 *
215 AcpiPsGetNextPackageEnd (
216     ACPI_PARSE_STATE        *ParserState)
217 {
218     UINT8                   *Start = ParserState->Aml;
219     ACPI_NATIVE_UINT        Length;
220
221
222     ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd");
223
224
225     /* Function below changes ParserState->Aml */
226
227     Length = (ACPI_NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState);
228
229     return_PTR (Start + Length); /* end of package */
230 }
231
232
233 /*******************************************************************************
234  *
235  * FUNCTION:    AcpiPsGetNextNamestring
236  *
237  * PARAMETERS:  ParserState         - Current parser state object
238  *
239  * RETURN:      Pointer to the start of the name string (pointer points into
240  *              the AML.
241  *
242  * DESCRIPTION: Get next raw namestring within the AML stream.  Handles all name
243  *              prefix characters.  Set parser state to point past the string.
244  *              (Name is consumed from the AML.)
245  *
246  ******************************************************************************/
247
248 char *
249 AcpiPsGetNextNamestring (
250     ACPI_PARSE_STATE        *ParserState)
251 {
252     UINT8                   *Start = ParserState->Aml;
253     UINT8                   *End = ParserState->Aml;
254
255
256     ACPI_FUNCTION_TRACE ("PsGetNextNamestring");
257
258
259     /* Handle multiple prefix characters */
260
261     while (AcpiPsIsPrefixChar (ACPI_GET8 (End)))
262     {
263         /* Include prefix '\\' or '^' */
264
265         End++;
266     }
267
268     /* Decode the path */
269
270     switch (ACPI_GET8 (End))
271     {
272     case 0:
273
274         /* NullName */
275
276         if (End == Start)
277         {
278             Start = NULL;
279         }
280         End++;
281         break;
282
283     case AML_DUAL_NAME_PREFIX:
284
285         /* Two name segments */
286
287         End += 1 + (2 * ACPI_NAME_SIZE);
288         break;
289
290     case AML_MULTI_NAME_PREFIX_OP:
291
292         /* Multiple name segments, 4 chars each */
293
294         End += 2 + ((ACPI_SIZE) ACPI_GET8 (End + 1) * ACPI_NAME_SIZE);
295         break;
296
297     default:
298
299         /* Single name segment */
300
301         End += ACPI_NAME_SIZE;
302         break;
303     }
304
305     ParserState->Aml = (UINT8*) End;
306     return_PTR ((char *) Start);
307 }
308
309
310 /*******************************************************************************
311  *
312  * FUNCTION:    AcpiPsGetNextNamepath
313  *
314  * PARAMETERS:  ParserState         - Current parser state object
315  *              Arg                 - Where the namepath will be stored
316  *              ArgCount            - If the namepath points to a control method
317  *                                    the method's argument is returned here.
318  *              MethodCall          - Whether the namepath can possibly be the
319  *                                    start of a method call
320  *
321  * RETURN:      Status
322  *
323  * DESCRIPTION: Get next name (if method call, return # of required args).
324  *              Names are looked up in the internal namespace to determine
325  *              if the name represents a control method.  If a method
326  *              is found, the number of arguments to the method is returned.
327  *              This information is critical for parsing to continue correctly.
328  *
329  ******************************************************************************/
330
331 ACPI_STATUS
332 AcpiPsGetNextNamepath (
333     ACPI_WALK_STATE         *WalkState,
334     ACPI_PARSE_STATE        *ParserState,
335     ACPI_PARSE_OBJECT       *Arg,
336     BOOLEAN                 MethodCall)
337 {
338     char                    *Path;
339     ACPI_PARSE_OBJECT       *NameOp;
340     ACPI_STATUS             Status = AE_OK;
341     ACPI_OPERAND_OBJECT     *MethodDesc;
342     ACPI_NAMESPACE_NODE     *Node;
343     ACPI_GENERIC_STATE      ScopeInfo;
344
345
346     ACPI_FUNCTION_TRACE ("PsGetNextNamepath");
347
348
349     Path = AcpiPsGetNextNamestring (ParserState);
350
351     /* Null path case is allowed */
352
353     if (Path)
354     {
355         /*
356          * Lookup the name in the internal namespace
357          */
358         ScopeInfo.Scope.Node = NULL;
359         Node = ParserState->StartNode;
360         if (Node)
361         {
362             ScopeInfo.Scope.Node = Node;
363         }
364
365         /*
366          * Lookup object.  We don't want to add anything new to the namespace
367          * here, however.  So we use MODE_EXECUTE.  Allow searching of the
368          * parent tree, but don't open a new scope -- we just want to lookup the
369          * object  (MUST BE mode EXECUTE to perform upsearch)
370          */
371         Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
372                     ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
373         if (ACPI_SUCCESS (Status) && MethodCall)
374         {
375             if (Node->Type == ACPI_TYPE_METHOD)
376             {
377                 /*
378                  * This name is actually a control method invocation
379                  */
380                 MethodDesc = AcpiNsGetAttachedObject (Node);
381                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
382                     "Control Method - %p Desc %p Path=%p\n",
383                     Node, MethodDesc, Path));
384
385                 NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
386                 if (!NameOp)
387                 {
388                     return_ACPI_STATUS (AE_NO_MEMORY);
389                 }
390
391                 /* Change arg into a METHOD CALL and attach name to it */
392
393                 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
394                 NameOp->Common.Value.Name = Path;
395
396                 /* Point METHODCALL/NAME to the METHOD Node */
397
398                 NameOp->Common.Node = Node;
399                 AcpiPsAppendArg (Arg, NameOp);
400
401                 if (!MethodDesc)
402                 {
403                     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
404                         "Control Method - %p has no attached object\n",
405                         Node));
406                     return_ACPI_STATUS (AE_AML_INTERNAL);
407                 }
408
409                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
410                     "Control Method - %p Args %X\n",
411                     Node, MethodDesc->Method.ParamCount));
412
413                 /* Get the number of arguments to expect */
414
415                 WalkState->ArgCount = MethodDesc->Method.ParamCount;
416                 return_ACPI_STATUS (AE_OK);
417             }
418
419             /*
420              * Else this is normal named object reference.
421              * Just init the NAMEPATH object with the pathname.
422              * (See code below)
423              */
424         }
425
426         if (ACPI_FAILURE (Status))
427         {
428             /*
429              * 1) Any error other than NOT_FOUND is always severe
430              * 2) NOT_FOUND is only important if we are executing a method.
431              * 3) If executing a CondRefOf opcode, NOT_FOUND is ok.
432              */
433             if ((((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) &&
434                 (Status == AE_NOT_FOUND)                                                &&
435                 (WalkState->Op->Common.AmlOpcode != AML_COND_REF_OF_OP)) ||
436
437                 (Status != AE_NOT_FOUND))
438             {
439                 ACPI_REPORT_NSERROR (Path, Status);
440             }
441             else
442             {
443                 /*
444                  * We got a NOT_FOUND during table load or we encountered
445                  * a CondRefOf(x) where the target does not exist.
446                  * -- either case is ok
447                  */
448                 Status = AE_OK;
449             }
450         }
451     }
452
453     /*
454      * Regardless of success/failure above,
455      * Just initialize the Op with the pathname.
456      */
457     AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
458     Arg->Common.Value.Name = Path;
459
460     return_ACPI_STATUS (Status);
461 }
462
463
464 /*******************************************************************************
465  *
466  * FUNCTION:    AcpiPsGetNextSimpleArg
467  *
468  * PARAMETERS:  ParserState         - Current parser state object
469  *              ArgType             - The argument type (AML_*_ARG)
470  *              Arg                 - Where the argument is returned
471  *
472  * RETURN:      None
473  *
474  * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
475  *
476  ******************************************************************************/
477
478 void
479 AcpiPsGetNextSimpleArg (
480     ACPI_PARSE_STATE        *ParserState,
481     UINT32                  ArgType,
482     ACPI_PARSE_OBJECT       *Arg)
483 {
484
485     ACPI_FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType);
486
487
488     switch (ArgType)
489     {
490     case ARGP_BYTEDATA:
491
492         AcpiPsInitOp (Arg, AML_BYTE_OP);
493         Arg->Common.Value.Integer = (UINT32) ACPI_GET8 (ParserState->Aml);
494         ParserState->Aml++;
495         break;
496
497
498     case ARGP_WORDDATA:
499
500         AcpiPsInitOp (Arg, AML_WORD_OP);
501
502         /* Get 2 bytes from the AML stream */
503
504         ACPI_MOVE_UNALIGNED16_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml);
505         ParserState->Aml += 2;
506         break;
507
508
509     case ARGP_DWORDDATA:
510
511         AcpiPsInitOp (Arg, AML_DWORD_OP);
512
513         /* Get 4 bytes from the AML stream */
514
515         ACPI_MOVE_UNALIGNED32_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml);
516         ParserState->Aml += 4;
517         break;
518
519
520     case ARGP_QWORDDATA:
521
522         AcpiPsInitOp (Arg, AML_QWORD_OP);
523
524         /* Get 8 bytes from the AML stream */
525
526         ACPI_MOVE_UNALIGNED64_TO_64 (&Arg->Common.Value.Integer, ParserState->Aml);
527         ParserState->Aml += 8;
528         break;
529
530
531     case ARGP_CHARLIST:
532
533         AcpiPsInitOp (Arg, AML_STRING_OP);
534         Arg->Common.Value.String = (char *) ParserState->Aml;
535
536         while (ACPI_GET8 (ParserState->Aml) != '\0')
537         {
538             ParserState->Aml++;
539         }
540         ParserState->Aml++;
541         break;
542
543
544     case ARGP_NAME:
545     case ARGP_NAMESTRING:
546
547         AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
548         Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
549         break;
550
551
552     default:
553
554         ACPI_REPORT_ERROR (("Invalid ArgType %X\n", ArgType));
555         break;
556     }
557
558     return_VOID;
559 }
560
561
562 /*******************************************************************************
563  *
564  * FUNCTION:    AcpiPsGetNextField
565  *
566  * PARAMETERS:  ParserState         - Current parser state object
567  *
568  * RETURN:      A newly allocated FIELD op
569  *
570  * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
571  *
572  ******************************************************************************/
573
574 ACPI_PARSE_OBJECT *
575 AcpiPsGetNextField (
576     ACPI_PARSE_STATE        *ParserState)
577 {
578     UINT32                  AmlOffset = ACPI_PTR_DIFF (ParserState->Aml,
579                                                        ParserState->AmlStart);
580     ACPI_PARSE_OBJECT       *Field;
581     UINT16                  Opcode;
582     UINT32                  Name;
583
584
585     ACPI_FUNCTION_TRACE ("PsGetNextField");
586
587
588     /* determine field type */
589
590     switch (ACPI_GET8 (ParserState->Aml))
591     {
592     default:
593
594         Opcode = AML_INT_NAMEDFIELD_OP;
595         break;
596
597     case 0x00:
598
599         Opcode = AML_INT_RESERVEDFIELD_OP;
600         ParserState->Aml++;
601         break;
602
603     case 0x01:
604
605         Opcode = AML_INT_ACCESSFIELD_OP;
606         ParserState->Aml++;
607         break;
608     }
609
610
611     /* Allocate a new field op */
612
613     Field = AcpiPsAllocOp (Opcode);
614     if (!Field)
615     {
616         return_PTR (NULL);
617     }
618
619     Field->Common.AmlOffset = AmlOffset;
620
621     /* Decode the field type */
622
623     switch (Opcode)
624     {
625     case AML_INT_NAMEDFIELD_OP:
626
627         /* Get the 4-character name */
628
629         ACPI_MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml);
630         AcpiPsSetName (Field, Name);
631         ParserState->Aml += ACPI_NAME_SIZE;
632
633         /* Get the length which is encoded as a package length */
634
635         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
636         break;
637
638
639     case AML_INT_RESERVEDFIELD_OP:
640
641         /* Get the length which is encoded as a package length */
642
643         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
644         break;
645
646
647     case AML_INT_ACCESSFIELD_OP:
648
649         /*
650          * Get AccessType and AccessAttrib and merge into the field Op
651          * AccessType is first operand, AccessAttribute is second
652          */
653         Field->Common.Value.Integer32 = (ACPI_GET8 (ParserState->Aml) << 8);
654         ParserState->Aml++;
655         Field->Common.Value.Integer32 |= ACPI_GET8 (ParserState->Aml);
656         ParserState->Aml++;
657         break;
658
659     default:
660
661         /* Opcode was set in previous switch */
662         break;
663     }
664
665     return_PTR (Field);
666 }
667
668
669 /*******************************************************************************
670  *
671  * FUNCTION:    AcpiPsGetNextArg
672  *
673  * PARAMETERS:  ParserState         - Current parser state object
674  *              ArgType             - The argument type (AML_*_ARG)
675  *              ArgCount            - If the argument points to a control method
676  *                                    the method's argument is returned here.
677  *
678  * RETURN:      Status, and an op object containing the next argument.
679  *
680  * DESCRIPTION: Get next argument (including complex list arguments that require
681  *              pushing the parser stack)
682  *
683  ******************************************************************************/
684
685 ACPI_STATUS
686 AcpiPsGetNextArg (
687     ACPI_WALK_STATE         *WalkState,
688     ACPI_PARSE_STATE        *ParserState,
689     UINT32                  ArgType,
690     ACPI_PARSE_OBJECT       **ReturnArg)
691 {
692     ACPI_PARSE_OBJECT       *Arg = NULL;
693     ACPI_PARSE_OBJECT       *Prev = NULL;
694     ACPI_PARSE_OBJECT       *Field;
695     UINT32                  Subop;
696     ACPI_STATUS             Status = AE_OK;
697
698
699     ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState);
700
701
702     switch (ArgType)
703     {
704     case ARGP_BYTEDATA:
705     case ARGP_WORDDATA:
706     case ARGP_DWORDDATA:
707     case ARGP_CHARLIST:
708     case ARGP_NAME:
709     case ARGP_NAMESTRING:
710
711         /* constants, strings, and namestrings are all the same size */
712
713         Arg = AcpiPsAllocOp (AML_BYTE_OP);
714         if (!Arg)
715         {
716             return_ACPI_STATUS (AE_NO_MEMORY);
717         }
718         AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
719         break;
720
721
722     case ARGP_PKGLENGTH:
723
724         /* Package length, nothing returned */
725
726         ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
727         break;
728
729
730     case ARGP_FIELDLIST:
731
732         if (ParserState->Aml < ParserState->PkgEnd)
733         {
734             /* Non-empty list */
735
736             while (ParserState->Aml < ParserState->PkgEnd)
737             {
738                 Field = AcpiPsGetNextField (ParserState);
739                 if (!Field)
740                 {
741                     return_ACPI_STATUS (AE_NO_MEMORY);
742                 }
743
744                 if (Prev)
745                 {
746                     Prev->Common.Next = Field;
747                 }
748                 else
749                 {
750                     Arg = Field;
751                 }
752
753                 Prev = Field;
754             }
755
756             /* Skip to End of byte data */
757
758             ParserState->Aml = ParserState->PkgEnd;
759         }
760         break;
761
762
763     case ARGP_BYTELIST:
764
765         if (ParserState->Aml < ParserState->PkgEnd)
766         {
767             /* Non-empty list */
768
769             Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
770             if (!Arg)
771             {
772                 return_ACPI_STATUS (AE_NO_MEMORY);
773             }
774
775             /* Fill in bytelist data */
776
777             Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd,
778                                                     ParserState->Aml);
779             Arg->Named.Data = ParserState->Aml;
780
781             /* Skip to End of byte data */
782
783             ParserState->Aml = ParserState->PkgEnd;
784         }
785         break;
786
787
788     case ARGP_TARGET:
789     case ARGP_SUPERNAME:
790     case ARGP_SIMPLENAME:
791
792         Subop = AcpiPsPeekOpcode (ParserState);
793         if (Subop == 0                  ||
794             AcpiPsIsLeadingChar (Subop) ||
795             AcpiPsIsPrefixChar (Subop))
796         {
797             /* NullName or NameString */
798
799             Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
800             if (!Arg)
801             {
802                 return_ACPI_STATUS (AE_NO_MEMORY);
803             }
804
805             Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
806         }
807         else
808         {
809             /* single complex argument, nothing returned */
810
811             WalkState->ArgCount = 1;
812         }
813         break;
814
815
816     case ARGP_DATAOBJ:
817     case ARGP_TERMARG:
818
819         /* single complex argument, nothing returned */
820
821         WalkState->ArgCount = 1;
822         break;
823
824
825     case ARGP_DATAOBJLIST:
826     case ARGP_TERMLIST:
827     case ARGP_OBJLIST:
828
829         if (ParserState->Aml < ParserState->PkgEnd)
830         {
831             /* non-empty list of variable arguments, nothing returned */
832
833             WalkState->ArgCount = ACPI_VAR_ARGS;
834         }
835         break;
836
837
838     default:
839
840         ACPI_REPORT_ERROR (("Invalid ArgType: %X\n", ArgType));
841         Status = AE_AML_OPERAND_TYPE;
842         break;
843     }
844
845     *ReturnArg = Arg;
846     return_ACPI_STATUS (Status);
847 }