Sync ACPICA with Intel's version 20160831.
[dragonfly.git] / sys / contrib / dev / acpica / source / components / parser / psargs.c
bloba4745c3adc1dfe11ff9affb6bd85178f4f97e63b
1 /******************************************************************************
3 * Module Name: psargs - Parse AML opcode arguments
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acparser.h"
47 #include "amlcode.h"
48 #include "acnamesp.h"
49 #include "acdispat.h"
51 #define _COMPONENT ACPI_PARSER
52 ACPI_MODULE_NAME ("psargs")
54 /* Local prototypes */
56 static UINT32
57 AcpiPsGetNextPackageLength (
58 ACPI_PARSE_STATE *ParserState);
60 static ACPI_PARSE_OBJECT *
61 AcpiPsGetNextField (
62 ACPI_PARSE_STATE *ParserState);
65 /*******************************************************************************
67 * FUNCTION: AcpiPsGetNextPackageLength
69 * PARAMETERS: ParserState - Current parser state object
71 * RETURN: Decoded package length. On completion, the AML pointer points
72 * past the length byte or bytes.
74 * DESCRIPTION: Decode and return a package length field.
75 * Note: Largest package length is 28 bits, from ACPI specification
77 ******************************************************************************/
79 static UINT32
80 AcpiPsGetNextPackageLength (
81 ACPI_PARSE_STATE *ParserState)
83 UINT8 *Aml = ParserState->Aml;
84 UINT32 PackageLength = 0;
85 UINT32 ByteCount;
86 UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
89 ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
93 * Byte 0 bits [6:7] contain the number of additional bytes
94 * used to encode the package length, either 0,1,2, or 3
96 ByteCount = (Aml[0] >> 6);
97 ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
99 /* Get bytes 3, 2, 1 as needed */
101 while (ByteCount)
104 * Final bit positions for the package length bytes:
105 * Byte3->[20:27]
106 * Byte2->[12:19]
107 * Byte1->[04:11]
108 * Byte0->[00:03]
110 PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
112 ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
113 ByteCount--;
116 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
118 PackageLength |= (Aml[0] & ByteZeroMask);
119 return_UINT32 (PackageLength);
123 /*******************************************************************************
125 * FUNCTION: AcpiPsGetNextPackageEnd
127 * PARAMETERS: ParserState - Current parser state object
129 * RETURN: Pointer to end-of-package +1
131 * DESCRIPTION: Get next package length and return a pointer past the end of
132 * the package. Consumes the package length field
134 ******************************************************************************/
136 UINT8 *
137 AcpiPsGetNextPackageEnd (
138 ACPI_PARSE_STATE *ParserState)
140 UINT8 *Start = ParserState->Aml;
141 UINT32 PackageLength;
144 ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
147 /* Function below updates ParserState->Aml */
149 PackageLength = AcpiPsGetNextPackageLength (ParserState);
151 return_PTR (Start + PackageLength); /* end of package */
155 /*******************************************************************************
157 * FUNCTION: AcpiPsGetNextNamestring
159 * PARAMETERS: ParserState - Current parser state object
161 * RETURN: Pointer to the start of the name string (pointer points into
162 * the AML.
164 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
165 * prefix characters. Set parser state to point past the string.
166 * (Name is consumed from the AML.)
168 ******************************************************************************/
170 char *
171 AcpiPsGetNextNamestring (
172 ACPI_PARSE_STATE *ParserState)
174 UINT8 *Start = ParserState->Aml;
175 UINT8 *End = ParserState->Aml;
178 ACPI_FUNCTION_TRACE (PsGetNextNamestring);
181 /* Point past any namestring prefix characters (backslash or carat) */
183 while (ACPI_IS_ROOT_PREFIX (*End) ||
184 ACPI_IS_PARENT_PREFIX (*End))
186 End++;
189 /* Decode the path prefix character */
191 switch (*End)
193 case 0:
195 /* NullName */
197 if (End == Start)
199 Start = NULL;
201 End++;
202 break;
204 case AML_DUAL_NAME_PREFIX:
206 /* Two name segments */
208 End += 1 + (2 * ACPI_NAME_SIZE);
209 break;
211 case AML_MULTI_NAME_PREFIX_OP:
213 /* Multiple name segments, 4 chars each, count in next byte */
215 End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
216 break;
218 default:
220 /* Single name segment */
222 End += ACPI_NAME_SIZE;
223 break;
226 ParserState->Aml = End;
227 return_PTR ((char *) Start);
231 /*******************************************************************************
233 * FUNCTION: AcpiPsGetNextNamepath
235 * PARAMETERS: ParserState - Current parser state object
236 * Arg - Where the namepath will be stored
237 * ArgCount - If the namepath points to a control method
238 * the method's argument is returned here.
239 * PossibleMethodCall - Whether the namepath can possibly be the
240 * start of a method call
242 * RETURN: Status
244 * DESCRIPTION: Get next name (if method call, return # of required args).
245 * Names are looked up in the internal namespace to determine
246 * if the name represents a control method. If a method
247 * is found, the number of arguments to the method is returned.
248 * This information is critical for parsing to continue correctly.
250 ******************************************************************************/
252 ACPI_STATUS
253 AcpiPsGetNextNamepath (
254 ACPI_WALK_STATE *WalkState,
255 ACPI_PARSE_STATE *ParserState,
256 ACPI_PARSE_OBJECT *Arg,
257 BOOLEAN PossibleMethodCall)
259 ACPI_STATUS Status;
260 char *Path;
261 ACPI_PARSE_OBJECT *NameOp;
262 ACPI_OPERAND_OBJECT *MethodDesc;
263 ACPI_NAMESPACE_NODE *Node;
264 UINT8 *Start = ParserState->Aml;
267 ACPI_FUNCTION_TRACE (PsGetNextNamepath);
270 Path = AcpiPsGetNextNamestring (ParserState);
271 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
273 /* Null path case is allowed, just exit */
275 if (!Path)
277 Arg->Common.Value.Name = Path;
278 return_ACPI_STATUS (AE_OK);
282 * Lookup the name in the internal namespace, starting with the current
283 * scope. We don't want to add anything new to the namespace here,
284 * however, so we use MODE_EXECUTE.
285 * Allow searching of the parent tree, but don't open a new scope -
286 * we just want to lookup the object (must be mode EXECUTE to perform
287 * the upsearch)
289 Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
290 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
291 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
294 * If this name is a control method invocation, we must
295 * setup the method call
297 if (ACPI_SUCCESS (Status) &&
298 PossibleMethodCall &&
299 (Node->Type == ACPI_TYPE_METHOD))
301 if (WalkState->Opcode == AML_UNLOAD_OP)
304 * AcpiPsGetNextNamestring has increased the AML pointer,
305 * so we need to restore the saved AML pointer for method call.
307 WalkState->ParserState.Aml = Start;
308 WalkState->ArgCount = 1;
309 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
310 return_ACPI_STATUS (AE_OK);
313 /* This name is actually a control method invocation */
315 MethodDesc = AcpiNsGetAttachedObject (Node);
316 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
317 "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
319 NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start);
320 if (!NameOp)
322 return_ACPI_STATUS (AE_NO_MEMORY);
325 /* Change Arg into a METHOD CALL and attach name to it */
327 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
328 NameOp->Common.Value.Name = Path;
330 /* Point METHODCALL/NAME to the METHOD Node */
332 NameOp->Common.Node = Node;
333 AcpiPsAppendArg (Arg, NameOp);
335 if (!MethodDesc)
337 ACPI_ERROR ((AE_INFO,
338 "Control Method %p has no attached object",
339 Node));
340 return_ACPI_STATUS (AE_AML_INTERNAL);
343 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
344 "Control Method - %p Args %X\n",
345 Node, MethodDesc->Method.ParamCount));
347 /* Get the number of arguments to expect */
349 WalkState->ArgCount = MethodDesc->Method.ParamCount;
350 return_ACPI_STATUS (AE_OK);
354 * Special handling if the name was not found during the lookup -
355 * some NotFound cases are allowed
357 if (Status == AE_NOT_FOUND)
359 /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
361 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
362 ACPI_PARSE_EXECUTE)
364 Status = AE_OK;
367 /* 2) NotFound during a CondRefOf(x) is ok by definition */
369 else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
371 Status = AE_OK;
375 * 3) NotFound while building a Package is ok at this point, we
376 * may flag as an error later if slack mode is not enabled.
377 * (Some ASL code depends on allowing this behavior)
379 else if ((Arg->Common.Parent) &&
380 ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
381 (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
383 Status = AE_OK;
387 /* Final exception check (may have been changed from code above) */
389 if (ACPI_FAILURE (Status))
391 ACPI_ERROR_NAMESPACE (Path, Status);
393 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
394 ACPI_PARSE_EXECUTE)
396 /* Report a control method execution error */
398 Status = AcpiDsMethodError (Status, WalkState);
402 /* Save the namepath */
404 Arg->Common.Value.Name = Path;
405 return_ACPI_STATUS (Status);
409 /*******************************************************************************
411 * FUNCTION: AcpiPsGetNextSimpleArg
413 * PARAMETERS: ParserState - Current parser state object
414 * ArgType - The argument type (AML_*_ARG)
415 * Arg - Where the argument is returned
417 * RETURN: None
419 * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
421 ******************************************************************************/
423 void
424 AcpiPsGetNextSimpleArg (
425 ACPI_PARSE_STATE *ParserState,
426 UINT32 ArgType,
427 ACPI_PARSE_OBJECT *Arg)
429 UINT32 Length;
430 UINT16 Opcode;
431 UINT8 *Aml = ParserState->Aml;
434 ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
437 switch (ArgType)
439 case ARGP_BYTEDATA:
441 /* Get 1 byte from the AML stream */
443 Opcode = AML_BYTE_OP;
444 Arg->Common.Value.Integer = (UINT64) *Aml;
445 Length = 1;
446 break;
448 case ARGP_WORDDATA:
450 /* Get 2 bytes from the AML stream */
452 Opcode = AML_WORD_OP;
453 ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
454 Length = 2;
455 break;
457 case ARGP_DWORDDATA:
459 /* Get 4 bytes from the AML stream */
461 Opcode = AML_DWORD_OP;
462 ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
463 Length = 4;
464 break;
466 case ARGP_QWORDDATA:
468 /* Get 8 bytes from the AML stream */
470 Opcode = AML_QWORD_OP;
471 ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
472 Length = 8;
473 break;
475 case ARGP_CHARLIST:
477 /* Get a pointer to the string, point past the string */
479 Opcode = AML_STRING_OP;
480 Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
482 /* Find the null terminator */
484 Length = 0;
485 while (Aml[Length])
487 Length++;
489 Length++;
490 break;
492 case ARGP_NAME:
493 case ARGP_NAMESTRING:
495 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
496 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
497 return_VOID;
499 default:
501 ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
502 return_VOID;
505 AcpiPsInitOp (Arg, Opcode);
506 ParserState->Aml += Length;
507 return_VOID;
511 /*******************************************************************************
513 * FUNCTION: AcpiPsGetNextField
515 * PARAMETERS: ParserState - Current parser state object
517 * RETURN: A newly allocated FIELD op
519 * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
521 ******************************************************************************/
523 static ACPI_PARSE_OBJECT *
524 AcpiPsGetNextField (
525 ACPI_PARSE_STATE *ParserState)
527 UINT8 *Aml;
528 ACPI_PARSE_OBJECT *Field;
529 ACPI_PARSE_OBJECT *Arg = NULL;
530 UINT16 Opcode;
531 UINT32 Name;
532 UINT8 AccessType;
533 UINT8 AccessAttribute;
534 UINT8 AccessLength;
535 UINT32 PkgLength;
536 UINT8 *PkgEnd;
537 UINT32 BufferLength;
540 ACPI_FUNCTION_TRACE (PsGetNextField);
543 Aml = ParserState->Aml;
545 /* Determine field type */
547 switch (ACPI_GET8 (ParserState->Aml))
549 case AML_FIELD_OFFSET_OP:
551 Opcode = AML_INT_RESERVEDFIELD_OP;
552 ParserState->Aml++;
553 break;
555 case AML_FIELD_ACCESS_OP:
557 Opcode = AML_INT_ACCESSFIELD_OP;
558 ParserState->Aml++;
559 break;
561 case AML_FIELD_CONNECTION_OP:
563 Opcode = AML_INT_CONNECTION_OP;
564 ParserState->Aml++;
565 break;
567 case AML_FIELD_EXT_ACCESS_OP:
569 Opcode = AML_INT_EXTACCESSFIELD_OP;
570 ParserState->Aml++;
571 break;
573 default:
575 Opcode = AML_INT_NAMEDFIELD_OP;
576 break;
579 /* Allocate a new field op */
581 Field = AcpiPsAllocOp (Opcode, Aml);
582 if (!Field)
584 return_PTR (NULL);
587 /* Decode the field type */
589 switch (Opcode)
591 case AML_INT_NAMEDFIELD_OP:
593 /* Get the 4-character name */
595 ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
596 AcpiPsSetName (Field, Name);
597 ParserState->Aml += ACPI_NAME_SIZE;
599 /* Get the length which is encoded as a package length */
601 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
602 break;
605 case AML_INT_RESERVEDFIELD_OP:
607 /* Get the length which is encoded as a package length */
609 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
610 break;
613 case AML_INT_ACCESSFIELD_OP:
614 case AML_INT_EXTACCESSFIELD_OP:
617 * Get AccessType and AccessAttrib and merge into the field Op
618 * AccessType is first operand, AccessAttribute is second. stuff
619 * these bytes into the node integer value for convenience.
622 /* Get the two bytes (Type/Attribute) */
624 AccessType = ACPI_GET8 (ParserState->Aml);
625 ParserState->Aml++;
626 AccessAttribute = ACPI_GET8 (ParserState->Aml);
627 ParserState->Aml++;
629 Field->Common.Value.Integer = (UINT8) AccessType;
630 Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
632 /* This opcode has a third byte, AccessLength */
634 if (Opcode == AML_INT_EXTACCESSFIELD_OP)
636 AccessLength = ACPI_GET8 (ParserState->Aml);
637 ParserState->Aml++;
639 Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
641 break;
644 case AML_INT_CONNECTION_OP:
647 * Argument for Connection operator can be either a Buffer
648 * (resource descriptor), or a NameString.
650 Aml = ParserState->Aml;
651 if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
653 ParserState->Aml++;
655 PkgEnd = ParserState->Aml;
656 PkgLength = AcpiPsGetNextPackageLength (ParserState);
657 PkgEnd += PkgLength;
659 if (ParserState->Aml < PkgEnd)
661 /* Non-empty list */
663 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP, Aml);
664 if (!Arg)
666 AcpiPsFreeOp (Field);
667 return_PTR (NULL);
670 /* Get the actual buffer length argument */
672 Opcode = ACPI_GET8 (ParserState->Aml);
673 ParserState->Aml++;
675 switch (Opcode)
677 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
679 BufferLength = ACPI_GET8 (ParserState->Aml);
680 ParserState->Aml += 1;
681 break;
683 case AML_WORD_OP: /* AML_WORDDATA_ARG */
685 BufferLength = ACPI_GET16 (ParserState->Aml);
686 ParserState->Aml += 2;
687 break;
689 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
691 BufferLength = ACPI_GET32 (ParserState->Aml);
692 ParserState->Aml += 4;
693 break;
695 default:
697 BufferLength = 0;
698 break;
701 /* Fill in bytelist data */
703 Arg->Named.Value.Size = BufferLength;
704 Arg->Named.Data = ParserState->Aml;
707 /* Skip to End of byte data */
709 ParserState->Aml = PkgEnd;
711 else
713 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Aml);
714 if (!Arg)
716 AcpiPsFreeOp (Field);
717 return_PTR (NULL);
720 /* Get the Namestring argument */
722 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
725 /* Link the buffer/namestring to parent (CONNECTION_OP) */
727 AcpiPsAppendArg (Field, Arg);
728 break;
731 default:
733 /* Opcode was set in previous switch */
734 break;
737 return_PTR (Field);
741 /*******************************************************************************
743 * FUNCTION: AcpiPsGetNextArg
745 * PARAMETERS: WalkState - Current state
746 * ParserState - Current parser state object
747 * ArgType - The argument type (AML_*_ARG)
748 * ReturnArg - Where the next arg is returned
750 * RETURN: Status, and an op object containing the next argument.
752 * DESCRIPTION: Get next argument (including complex list arguments that require
753 * pushing the parser stack)
755 ******************************************************************************/
757 ACPI_STATUS
758 AcpiPsGetNextArg (
759 ACPI_WALK_STATE *WalkState,
760 ACPI_PARSE_STATE *ParserState,
761 UINT32 ArgType,
762 ACPI_PARSE_OBJECT **ReturnArg)
764 ACPI_PARSE_OBJECT *Arg = NULL;
765 ACPI_PARSE_OBJECT *Prev = NULL;
766 ACPI_PARSE_OBJECT *Field;
767 UINT32 Subop;
768 ACPI_STATUS Status = AE_OK;
771 ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
774 switch (ArgType)
776 case ARGP_BYTEDATA:
777 case ARGP_WORDDATA:
778 case ARGP_DWORDDATA:
779 case ARGP_CHARLIST:
780 case ARGP_NAME:
781 case ARGP_NAMESTRING:
783 /* Constants, strings, and namestrings are all the same size */
785 Arg = AcpiPsAllocOp (AML_BYTE_OP, ParserState->Aml);
786 if (!Arg)
788 return_ACPI_STATUS (AE_NO_MEMORY);
791 AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
792 break;
794 case ARGP_PKGLENGTH:
796 /* Package length, nothing returned */
798 ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
799 break;
801 case ARGP_FIELDLIST:
803 if (ParserState->Aml < ParserState->PkgEnd)
805 /* Non-empty list */
807 while (ParserState->Aml < ParserState->PkgEnd)
809 Field = AcpiPsGetNextField (ParserState);
810 if (!Field)
812 return_ACPI_STATUS (AE_NO_MEMORY);
815 if (Prev)
817 Prev->Common.Next = Field;
819 else
821 Arg = Field;
823 Prev = Field;
826 /* Skip to End of byte data */
828 ParserState->Aml = ParserState->PkgEnd;
830 break;
832 case ARGP_BYTELIST:
834 if (ParserState->Aml < ParserState->PkgEnd)
836 /* Non-empty list */
838 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP,
839 ParserState->Aml);
840 if (!Arg)
842 return_ACPI_STATUS (AE_NO_MEMORY);
845 /* Fill in bytelist data */
847 Arg->Common.Value.Size = (UINT32)
848 ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
849 Arg->Named.Data = ParserState->Aml;
851 /* Skip to End of byte data */
853 ParserState->Aml = ParserState->PkgEnd;
855 break;
857 case ARGP_TARGET:
858 case ARGP_SUPERNAME:
859 case ARGP_SIMPLENAME:
860 case ARGP_NAME_OR_REF:
862 Subop = AcpiPsPeekOpcode (ParserState);
863 if (Subop == 0 ||
864 AcpiPsIsLeadingChar (Subop) ||
865 ACPI_IS_ROOT_PREFIX (Subop) ||
866 ACPI_IS_PARENT_PREFIX (Subop))
868 /* NullName or NameString */
870 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
871 if (!Arg)
873 return_ACPI_STATUS (AE_NO_MEMORY);
876 /* To support SuperName arg of Unload */
878 if (WalkState->Opcode == AML_UNLOAD_OP)
880 Status = AcpiPsGetNextNamepath (WalkState, ParserState,
881 Arg, ACPI_POSSIBLE_METHOD_CALL);
884 * If the SuperName argument is a method call, we have
885 * already restored the AML pointer, just free this Arg
887 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
889 AcpiPsFreeOp (Arg);
890 Arg = NULL;
893 else
895 Status = AcpiPsGetNextNamepath (WalkState, ParserState,
896 Arg, ACPI_NOT_METHOD_CALL);
899 else
901 /* Single complex argument, nothing returned */
903 WalkState->ArgCount = 1;
905 break;
907 case ARGP_DATAOBJ:
908 case ARGP_TERMARG:
910 /* Single complex argument, nothing returned */
912 WalkState->ArgCount = 1;
913 break;
915 case ARGP_DATAOBJLIST:
916 case ARGP_TERMLIST:
917 case ARGP_OBJLIST:
919 if (ParserState->Aml < ParserState->PkgEnd)
921 /* Non-empty list of variable arguments, nothing returned */
923 WalkState->ArgCount = ACPI_VAR_ARGS;
925 break;
927 default:
929 ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
930 Status = AE_AML_OPERAND_TYPE;
931 break;
934 *ReturnArg = Arg;
935 return_ACPI_STATUS (Status);