1db2bae30SDana Myers /******************************************************************************
2db2bae30SDana Myers *
3db2bae30SDana Myers * Module Name: psargs - Parse AML opcode arguments
4db2bae30SDana Myers *
5db2bae30SDana Myers *****************************************************************************/
6db2bae30SDana Myers
726f3cdf0SGordon Ross /*
8*385cc6b4SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp.
9db2bae30SDana Myers * All rights reserved.
10db2bae30SDana Myers *
1126f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross * are met:
1426f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross * without modification.
1726f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross * binary redistribution.
2226f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross * from this software without specific prior written permission.
25db2bae30SDana Myers *
2626f3cdf0SGordon Ross * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross * Software Foundation.
29db2bae30SDana Myers *
3026f3cdf0SGordon Ross * NO WARRANTY
3126f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross */
43db2bae30SDana Myers
44db2bae30SDana Myers #include "acpi.h"
45aa2aa9a6SDana Myers #include "accommon.h"
46db2bae30SDana Myers #include "acparser.h"
47db2bae30SDana Myers #include "amlcode.h"
48db2bae30SDana Myers #include "acnamesp.h"
49db2bae30SDana Myers #include "acdispat.h"
50db2bae30SDana Myers
51db2bae30SDana Myers #define _COMPONENT ACPI_PARSER
52db2bae30SDana Myers ACPI_MODULE_NAME ("psargs")
53db2bae30SDana Myers
54db2bae30SDana Myers /* Local prototypes */
55db2bae30SDana Myers
56db2bae30SDana Myers static UINT32
57db2bae30SDana Myers AcpiPsGetNextPackageLength (
58db2bae30SDana Myers ACPI_PARSE_STATE *ParserState);
59db2bae30SDana Myers
60db2bae30SDana Myers static ACPI_PARSE_OBJECT *
61db2bae30SDana Myers AcpiPsGetNextField (
62db2bae30SDana Myers ACPI_PARSE_STATE *ParserState);
63db2bae30SDana Myers
64db2bae30SDana Myers
65db2bae30SDana Myers /*******************************************************************************
66db2bae30SDana Myers *
67db2bae30SDana Myers * FUNCTION: AcpiPsGetNextPackageLength
68db2bae30SDana Myers *
69db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
70db2bae30SDana Myers *
71db2bae30SDana Myers * RETURN: Decoded package length. On completion, the AML pointer points
72db2bae30SDana Myers * past the length byte or bytes.
73db2bae30SDana Myers *
74db2bae30SDana Myers * DESCRIPTION: Decode and return a package length field.
75db2bae30SDana Myers * Note: Largest package length is 28 bits, from ACPI specification
76db2bae30SDana Myers *
77db2bae30SDana Myers ******************************************************************************/
78db2bae30SDana Myers
79db2bae30SDana Myers static UINT32
AcpiPsGetNextPackageLength(ACPI_PARSE_STATE * ParserState)80db2bae30SDana Myers AcpiPsGetNextPackageLength (
81db2bae30SDana Myers ACPI_PARSE_STATE *ParserState)
82db2bae30SDana Myers {
83db2bae30SDana Myers UINT8 *Aml = ParserState->Aml;
84db2bae30SDana Myers UINT32 PackageLength = 0;
85db2bae30SDana Myers UINT32 ByteCount;
86db2bae30SDana Myers UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
87db2bae30SDana Myers
88db2bae30SDana Myers
89db2bae30SDana Myers ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
90db2bae30SDana Myers
91db2bae30SDana Myers
92db2bae30SDana Myers /*
93db2bae30SDana Myers * Byte 0 bits [6:7] contain the number of additional bytes
94db2bae30SDana Myers * used to encode the package length, either 0,1,2, or 3
95db2bae30SDana Myers */
96db2bae30SDana Myers ByteCount = (Aml[0] >> 6);
97db2bae30SDana Myers ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
98db2bae30SDana Myers
99db2bae30SDana Myers /* Get bytes 3, 2, 1 as needed */
100db2bae30SDana Myers
101db2bae30SDana Myers while (ByteCount)
102db2bae30SDana Myers {
103db2bae30SDana Myers /*
104db2bae30SDana Myers * Final bit positions for the package length bytes:
105db2bae30SDana Myers * Byte3->[20:27]
106db2bae30SDana Myers * Byte2->[12:19]
107db2bae30SDana Myers * Byte1->[04:11]
108db2bae30SDana Myers * Byte0->[00:03]
109db2bae30SDana Myers */
110db2bae30SDana Myers PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
111db2bae30SDana Myers
112db2bae30SDana Myers ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
113db2bae30SDana Myers ByteCount--;
114db2bae30SDana Myers }
115db2bae30SDana Myers
116db2bae30SDana Myers /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
117db2bae30SDana Myers
118db2bae30SDana Myers PackageLength |= (Aml[0] & ByteZeroMask);
119db2bae30SDana Myers return_UINT32 (PackageLength);
120db2bae30SDana Myers }
121db2bae30SDana Myers
122db2bae30SDana Myers
123db2bae30SDana Myers /*******************************************************************************
124db2bae30SDana Myers *
125db2bae30SDana Myers * FUNCTION: AcpiPsGetNextPackageEnd
126db2bae30SDana Myers *
127db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
128db2bae30SDana Myers *
129db2bae30SDana Myers * RETURN: Pointer to end-of-package +1
130db2bae30SDana Myers *
131db2bae30SDana Myers * DESCRIPTION: Get next package length and return a pointer past the end of
132db2bae30SDana Myers * the package. Consumes the package length field
133db2bae30SDana Myers *
134db2bae30SDana Myers ******************************************************************************/
135db2bae30SDana Myers
136db2bae30SDana Myers UINT8 *
AcpiPsGetNextPackageEnd(ACPI_PARSE_STATE * ParserState)137db2bae30SDana Myers AcpiPsGetNextPackageEnd (
138db2bae30SDana Myers ACPI_PARSE_STATE *ParserState)
139db2bae30SDana Myers {
140db2bae30SDana Myers UINT8 *Start = ParserState->Aml;
141db2bae30SDana Myers UINT32 PackageLength;
142db2bae30SDana Myers
143db2bae30SDana Myers
144db2bae30SDana Myers ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
145db2bae30SDana Myers
146db2bae30SDana Myers
147db2bae30SDana Myers /* Function below updates ParserState->Aml */
148db2bae30SDana Myers
149db2bae30SDana Myers PackageLength = AcpiPsGetNextPackageLength (ParserState);
150db2bae30SDana Myers
151db2bae30SDana Myers return_PTR (Start + PackageLength); /* end of package */
152db2bae30SDana Myers }
153db2bae30SDana Myers
154db2bae30SDana Myers
155db2bae30SDana Myers /*******************************************************************************
156db2bae30SDana Myers *
157db2bae30SDana Myers * FUNCTION: AcpiPsGetNextNamestring
158db2bae30SDana Myers *
159db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
160db2bae30SDana Myers *
161db2bae30SDana Myers * RETURN: Pointer to the start of the name string (pointer points into
162db2bae30SDana Myers * the AML.
163db2bae30SDana Myers *
164db2bae30SDana Myers * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
165db2bae30SDana Myers * prefix characters. Set parser state to point past the string.
166db2bae30SDana Myers * (Name is consumed from the AML.)
167db2bae30SDana Myers *
168db2bae30SDana Myers ******************************************************************************/
169db2bae30SDana Myers
170db2bae30SDana Myers char *
AcpiPsGetNextNamestring(ACPI_PARSE_STATE * ParserState)171db2bae30SDana Myers AcpiPsGetNextNamestring (
172db2bae30SDana Myers ACPI_PARSE_STATE *ParserState)
173db2bae30SDana Myers {
174db2bae30SDana Myers UINT8 *Start = ParserState->Aml;
175db2bae30SDana Myers UINT8 *End = ParserState->Aml;
176db2bae30SDana Myers
177db2bae30SDana Myers
178db2bae30SDana Myers ACPI_FUNCTION_TRACE (PsGetNextNamestring);
179db2bae30SDana Myers
180db2bae30SDana Myers
181db2bae30SDana Myers /* Point past any namestring prefix characters (backslash or carat) */
182db2bae30SDana Myers
183*385cc6b4SJerry Jelinek while (ACPI_IS_ROOT_PREFIX (*End) ||
184*385cc6b4SJerry Jelinek ACPI_IS_PARENT_PREFIX (*End))
185db2bae30SDana Myers {
186db2bae30SDana Myers End++;
187db2bae30SDana Myers }
188db2bae30SDana Myers
189db2bae30SDana Myers /* Decode the path prefix character */
190db2bae30SDana Myers
191db2bae30SDana Myers switch (*End)
192db2bae30SDana Myers {
193db2bae30SDana Myers case 0:
194db2bae30SDana Myers
195db2bae30SDana Myers /* NullName */
196db2bae30SDana Myers
197db2bae30SDana Myers if (End == Start)
198db2bae30SDana Myers {
199db2bae30SDana Myers Start = NULL;
200db2bae30SDana Myers }
201db2bae30SDana Myers End++;
202db2bae30SDana Myers break;
203db2bae30SDana Myers
204db2bae30SDana Myers case AML_DUAL_NAME_PREFIX:
205db2bae30SDana Myers
206db2bae30SDana Myers /* Two name segments */
207db2bae30SDana Myers
208db2bae30SDana Myers End += 1 + (2 * ACPI_NAME_SIZE);
209db2bae30SDana Myers break;
210db2bae30SDana Myers
211db2bae30SDana Myers case AML_MULTI_NAME_PREFIX_OP:
212db2bae30SDana Myers
213db2bae30SDana Myers /* Multiple name segments, 4 chars each, count in next byte */
214db2bae30SDana Myers
215db2bae30SDana Myers End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
216db2bae30SDana Myers break;
217db2bae30SDana Myers
218db2bae30SDana Myers default:
219db2bae30SDana Myers
220db2bae30SDana Myers /* Single name segment */
221db2bae30SDana Myers
222db2bae30SDana Myers End += ACPI_NAME_SIZE;
223db2bae30SDana Myers break;
224db2bae30SDana Myers }
225db2bae30SDana Myers
226db2bae30SDana Myers ParserState->Aml = End;
227db2bae30SDana Myers return_PTR ((char *) Start);
228db2bae30SDana Myers }
229db2bae30SDana Myers
230db2bae30SDana Myers
231db2bae30SDana Myers /*******************************************************************************
232db2bae30SDana Myers *
233db2bae30SDana Myers * FUNCTION: AcpiPsGetNextNamepath
234db2bae30SDana Myers *
235db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
236db2bae30SDana Myers * Arg - Where the namepath will be stored
237db2bae30SDana Myers * ArgCount - If the namepath points to a control method
238db2bae30SDana Myers * the method's argument is returned here.
239db2bae30SDana Myers * PossibleMethodCall - Whether the namepath can possibly be the
240db2bae30SDana Myers * start of a method call
241db2bae30SDana Myers *
242db2bae30SDana Myers * RETURN: Status
243db2bae30SDana Myers *
244db2bae30SDana Myers * DESCRIPTION: Get next name (if method call, return # of required args).
245db2bae30SDana Myers * Names are looked up in the internal namespace to determine
246db2bae30SDana Myers * if the name represents a control method. If a method
247db2bae30SDana Myers * is found, the number of arguments to the method is returned.
248db2bae30SDana Myers * This information is critical for parsing to continue correctly.
249db2bae30SDana Myers *
250db2bae30SDana Myers ******************************************************************************/
251db2bae30SDana Myers
252db2bae30SDana Myers ACPI_STATUS
AcpiPsGetNextNamepath(ACPI_WALK_STATE * WalkState,ACPI_PARSE_STATE * ParserState,ACPI_PARSE_OBJECT * Arg,BOOLEAN PossibleMethodCall)253db2bae30SDana Myers AcpiPsGetNextNamepath (
254db2bae30SDana Myers ACPI_WALK_STATE *WalkState,
255db2bae30SDana Myers ACPI_PARSE_STATE *ParserState,
256db2bae30SDana Myers ACPI_PARSE_OBJECT *Arg,
257db2bae30SDana Myers BOOLEAN PossibleMethodCall)
258db2bae30SDana Myers {
259db2bae30SDana Myers ACPI_STATUS Status;
260db2bae30SDana Myers char *Path;
261db2bae30SDana Myers ACPI_PARSE_OBJECT *NameOp;
262db2bae30SDana Myers ACPI_OPERAND_OBJECT *MethodDesc;
263db2bae30SDana Myers ACPI_NAMESPACE_NODE *Node;
264db2bae30SDana Myers UINT8 *Start = ParserState->Aml;
265db2bae30SDana Myers
266db2bae30SDana Myers
267db2bae30SDana Myers ACPI_FUNCTION_TRACE (PsGetNextNamepath);
268db2bae30SDana Myers
269db2bae30SDana Myers
270db2bae30SDana Myers Path = AcpiPsGetNextNamestring (ParserState);
271db2bae30SDana Myers AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
272db2bae30SDana Myers
273db2bae30SDana Myers /* Null path case is allowed, just exit */
274db2bae30SDana Myers
275db2bae30SDana Myers if (!Path)
276db2bae30SDana Myers {
277db2bae30SDana Myers Arg->Common.Value.Name = Path;
278db2bae30SDana Myers return_ACPI_STATUS (AE_OK);
279db2bae30SDana Myers }
280db2bae30SDana Myers
281db2bae30SDana Myers /*
282db2bae30SDana Myers * Lookup the name in the internal namespace, starting with the current
283db2bae30SDana Myers * scope. We don't want to add anything new to the namespace here,
284db2bae30SDana Myers * however, so we use MODE_EXECUTE.
285db2bae30SDana Myers * Allow searching of the parent tree, but don't open a new scope -
286db2bae30SDana Myers * we just want to lookup the object (must be mode EXECUTE to perform
287db2bae30SDana Myers * the upsearch)
288db2bae30SDana Myers */
289db2bae30SDana Myers Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
290db2bae30SDana Myers ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
291db2bae30SDana Myers ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
292db2bae30SDana Myers
293db2bae30SDana Myers /*
294db2bae30SDana Myers * If this name is a control method invocation, we must
295db2bae30SDana Myers * setup the method call
296db2bae30SDana Myers */
297db2bae30SDana Myers if (ACPI_SUCCESS (Status) &&
298db2bae30SDana Myers PossibleMethodCall &&
299db2bae30SDana Myers (Node->Type == ACPI_TYPE_METHOD))
300db2bae30SDana Myers {
301db2bae30SDana Myers if (WalkState->Opcode == AML_UNLOAD_OP)
302db2bae30SDana Myers {
303db2bae30SDana Myers /*
304db2bae30SDana Myers * AcpiPsGetNextNamestring has increased the AML pointer,
305db2bae30SDana Myers * so we need to restore the saved AML pointer for method call.
306db2bae30SDana Myers */
307db2bae30SDana Myers WalkState->ParserState.Aml = Start;
308db2bae30SDana Myers WalkState->ArgCount = 1;
309db2bae30SDana Myers AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
310db2bae30SDana Myers return_ACPI_STATUS (AE_OK);
311db2bae30SDana Myers }
312db2bae30SDana Myers
313db2bae30SDana Myers /* This name is actually a control method invocation */
314db2bae30SDana Myers
315db2bae30SDana Myers MethodDesc = AcpiNsGetAttachedObject (Node);
316db2bae30SDana Myers ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
317db2bae30SDana Myers "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
318db2bae30SDana Myers
319*385cc6b4SJerry Jelinek NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start);
320db2bae30SDana Myers if (!NameOp)
321db2bae30SDana Myers {
322db2bae30SDana Myers return_ACPI_STATUS (AE_NO_MEMORY);
323db2bae30SDana Myers }
324db2bae30SDana Myers
325db2bae30SDana Myers /* Change Arg into a METHOD CALL and attach name to it */
326db2bae30SDana Myers
327db2bae30SDana Myers AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
328db2bae30SDana Myers NameOp->Common.Value.Name = Path;
329db2bae30SDana Myers
330db2bae30SDana Myers /* Point METHODCALL/NAME to the METHOD Node */
331db2bae30SDana Myers
332db2bae30SDana Myers NameOp->Common.Node = Node;
333db2bae30SDana Myers AcpiPsAppendArg (Arg, NameOp);
334db2bae30SDana Myers
335db2bae30SDana Myers if (!MethodDesc)
336db2bae30SDana Myers {
337db2bae30SDana Myers ACPI_ERROR ((AE_INFO,
338db2bae30SDana Myers "Control Method %p has no attached object",
339db2bae30SDana Myers Node));
340db2bae30SDana Myers return_ACPI_STATUS (AE_AML_INTERNAL);
341db2bae30SDana Myers }
342db2bae30SDana Myers
343db2bae30SDana Myers ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
344db2bae30SDana Myers "Control Method - %p Args %X\n",
345db2bae30SDana Myers Node, MethodDesc->Method.ParamCount));
346db2bae30SDana Myers
347db2bae30SDana Myers /* Get the number of arguments to expect */
348db2bae30SDana Myers
349db2bae30SDana Myers WalkState->ArgCount = MethodDesc->Method.ParamCount;
350db2bae30SDana Myers return_ACPI_STATUS (AE_OK);
351db2bae30SDana Myers }
352db2bae30SDana Myers
353db2bae30SDana Myers /*
354db2bae30SDana Myers * Special handling if the name was not found during the lookup -
355db2bae30SDana Myers * some NotFound cases are allowed
356db2bae30SDana Myers */
357db2bae30SDana Myers if (Status == AE_NOT_FOUND)
358db2bae30SDana Myers {
359db2bae30SDana Myers /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
360db2bae30SDana Myers
361db2bae30SDana Myers if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
362db2bae30SDana Myers ACPI_PARSE_EXECUTE)
363db2bae30SDana Myers {
364db2bae30SDana Myers Status = AE_OK;
365db2bae30SDana Myers }
366db2bae30SDana Myers
367db2bae30SDana Myers /* 2) NotFound during a CondRefOf(x) is ok by definition */
368db2bae30SDana Myers
369db2bae30SDana Myers else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
370db2bae30SDana Myers {
371db2bae30SDana Myers Status = AE_OK;
372db2bae30SDana Myers }
373db2bae30SDana Myers
374db2bae30SDana Myers /*
375db2bae30SDana Myers * 3) NotFound while building a Package is ok at this point, we
376db2bae30SDana Myers * may flag as an error later if slack mode is not enabled.
377db2bae30SDana Myers * (Some ASL code depends on allowing this behavior)
378db2bae30SDana Myers */
379db2bae30SDana Myers else if ((Arg->Common.Parent) &&
380db2bae30SDana Myers ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
381db2bae30SDana Myers (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
382db2bae30SDana Myers {
383db2bae30SDana Myers Status = AE_OK;
384db2bae30SDana Myers }
385db2bae30SDana Myers }
386db2bae30SDana Myers
387db2bae30SDana Myers /* Final exception check (may have been changed from code above) */
388db2bae30SDana Myers
389db2bae30SDana Myers if (ACPI_FAILURE (Status))
390db2bae30SDana Myers {
391db2bae30SDana Myers ACPI_ERROR_NAMESPACE (Path, Status);
392db2bae30SDana Myers
393db2bae30SDana Myers if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
394db2bae30SDana Myers ACPI_PARSE_EXECUTE)
395db2bae30SDana Myers {
396db2bae30SDana Myers /* Report a control method execution error */
397db2bae30SDana Myers
398db2bae30SDana Myers Status = AcpiDsMethodError (Status, WalkState);
399db2bae30SDana Myers }
400db2bae30SDana Myers }
401db2bae30SDana Myers
402db2bae30SDana Myers /* Save the namepath */
403db2bae30SDana Myers
404db2bae30SDana Myers Arg->Common.Value.Name = Path;
405db2bae30SDana Myers return_ACPI_STATUS (Status);
406db2bae30SDana Myers }
407db2bae30SDana Myers
408db2bae30SDana Myers
409db2bae30SDana Myers /*******************************************************************************
410db2bae30SDana Myers *
411db2bae30SDana Myers * FUNCTION: AcpiPsGetNextSimpleArg
412db2bae30SDana Myers *
413db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
414db2bae30SDana Myers * ArgType - The argument type (AML_*_ARG)
415db2bae30SDana Myers * Arg - Where the argument is returned
416db2bae30SDana Myers *
417db2bae30SDana Myers * RETURN: None
418db2bae30SDana Myers *
419db2bae30SDana Myers * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
420db2bae30SDana Myers *
421db2bae30SDana Myers ******************************************************************************/
422db2bae30SDana Myers
423db2bae30SDana Myers void
AcpiPsGetNextSimpleArg(ACPI_PARSE_STATE * ParserState,UINT32 ArgType,ACPI_PARSE_OBJECT * Arg)424db2bae30SDana Myers AcpiPsGetNextSimpleArg (
425db2bae30SDana Myers ACPI_PARSE_STATE *ParserState,
426db2bae30SDana Myers UINT32 ArgType,
427db2bae30SDana Myers ACPI_PARSE_OBJECT *Arg)
428db2bae30SDana Myers {
429db2bae30SDana Myers UINT32 Length;
430db2bae30SDana Myers UINT16 Opcode;
431db2bae30SDana Myers UINT8 *Aml = ParserState->Aml;
432db2bae30SDana Myers
433db2bae30SDana Myers
434db2bae30SDana Myers ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
435db2bae30SDana Myers
436db2bae30SDana Myers
437db2bae30SDana Myers switch (ArgType)
438db2bae30SDana Myers {
439db2bae30SDana Myers case ARGP_BYTEDATA:
440db2bae30SDana Myers
441db2bae30SDana Myers /* Get 1 byte from the AML stream */
442db2bae30SDana Myers
443db2bae30SDana Myers Opcode = AML_BYTE_OP;
44426f3cdf0SGordon Ross Arg->Common.Value.Integer = (UINT64) *Aml;
445db2bae30SDana Myers Length = 1;
446db2bae30SDana Myers break;
447db2bae30SDana Myers
448db2bae30SDana Myers case ARGP_WORDDATA:
449db2bae30SDana Myers
450db2bae30SDana Myers /* Get 2 bytes from the AML stream */
451db2bae30SDana Myers
452db2bae30SDana Myers Opcode = AML_WORD_OP;
453db2bae30SDana Myers ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
454db2bae30SDana Myers Length = 2;
455db2bae30SDana Myers break;
456db2bae30SDana Myers
457db2bae30SDana Myers case ARGP_DWORDDATA:
458db2bae30SDana Myers
459db2bae30SDana Myers /* Get 4 bytes from the AML stream */
460db2bae30SDana Myers
461db2bae30SDana Myers Opcode = AML_DWORD_OP;
462db2bae30SDana Myers ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
463db2bae30SDana Myers Length = 4;
464db2bae30SDana Myers break;
465db2bae30SDana Myers
466db2bae30SDana Myers case ARGP_QWORDDATA:
467db2bae30SDana Myers
468db2bae30SDana Myers /* Get 8 bytes from the AML stream */
469db2bae30SDana Myers
470db2bae30SDana Myers Opcode = AML_QWORD_OP;
471db2bae30SDana Myers ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
472db2bae30SDana Myers Length = 8;
473db2bae30SDana Myers break;
474db2bae30SDana Myers
475db2bae30SDana Myers case ARGP_CHARLIST:
476db2bae30SDana Myers
477db2bae30SDana Myers /* Get a pointer to the string, point past the string */
478db2bae30SDana Myers
479db2bae30SDana Myers Opcode = AML_STRING_OP;
480db2bae30SDana Myers Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
481db2bae30SDana Myers
482db2bae30SDana Myers /* Find the null terminator */
483db2bae30SDana Myers
484db2bae30SDana Myers Length = 0;
485db2bae30SDana Myers while (Aml[Length])
486db2bae30SDana Myers {
487db2bae30SDana Myers Length++;
488db2bae30SDana Myers }
489db2bae30SDana Myers Length++;
490db2bae30SDana Myers break;
491db2bae30SDana Myers
492db2bae30SDana Myers case ARGP_NAME:
493db2bae30SDana Myers case ARGP_NAMESTRING:
494db2bae30SDana Myers
495db2bae30SDana Myers AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
496db2bae30SDana Myers Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
497db2bae30SDana Myers return_VOID;
498db2bae30SDana Myers
499db2bae30SDana Myers default:
500db2bae30SDana Myers
50126f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
502db2bae30SDana Myers return_VOID;
503db2bae30SDana Myers }
504db2bae30SDana Myers
505db2bae30SDana Myers AcpiPsInitOp (Arg, Opcode);
506db2bae30SDana Myers ParserState->Aml += Length;
507db2bae30SDana Myers return_VOID;
508db2bae30SDana Myers }
509db2bae30SDana Myers
510db2bae30SDana Myers
511db2bae30SDana Myers /*******************************************************************************
512db2bae30SDana Myers *
513db2bae30SDana Myers * FUNCTION: AcpiPsGetNextField
514db2bae30SDana Myers *
515db2bae30SDana Myers * PARAMETERS: ParserState - Current parser state object
516db2bae30SDana Myers *
517db2bae30SDana Myers * RETURN: A newly allocated FIELD op
518db2bae30SDana Myers *
519db2bae30SDana Myers * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
520db2bae30SDana Myers *
521db2bae30SDana Myers ******************************************************************************/
522db2bae30SDana Myers
523db2bae30SDana Myers static ACPI_PARSE_OBJECT *
AcpiPsGetNextField(ACPI_PARSE_STATE * ParserState)524db2bae30SDana Myers AcpiPsGetNextField (
525db2bae30SDana Myers ACPI_PARSE_STATE *ParserState)
526db2bae30SDana Myers {
527*385cc6b4SJerry Jelinek UINT8 *Aml;
528db2bae30SDana Myers ACPI_PARSE_OBJECT *Field;
529*385cc6b4SJerry Jelinek ACPI_PARSE_OBJECT *Arg = NULL;
530db2bae30SDana Myers UINT16 Opcode;
531db2bae30SDana Myers UINT32 Name;
532*385cc6b4SJerry Jelinek UINT8 AccessType;
533*385cc6b4SJerry Jelinek UINT8 AccessAttribute;
534*385cc6b4SJerry Jelinek UINT8 AccessLength;
535*385cc6b4SJerry Jelinek UINT32 PkgLength;
536*385cc6b4SJerry Jelinek UINT8 *PkgEnd;
537*385cc6b4SJerry Jelinek UINT32 BufferLength;
538db2bae30SDana Myers
539db2bae30SDana Myers
540db2bae30SDana Myers ACPI_FUNCTION_TRACE (PsGetNextField);
541db2bae30SDana Myers
542db2bae30SDana Myers
543*385cc6b4SJerry Jelinek Aml = ParserState->Aml;
544*385cc6b4SJerry Jelinek
545db2bae30SDana Myers /* Determine field type */
546db2bae30SDana Myers
547db2bae30SDana Myers switch (ACPI_GET8 (ParserState->Aml))
548db2bae30SDana Myers {
549*385cc6b4SJerry Jelinek case AML_FIELD_OFFSET_OP:
550db2bae30SDana Myers
551db2bae30SDana Myers Opcode = AML_INT_RESERVEDFIELD_OP;
552db2bae30SDana Myers ParserState->Aml++;
553db2bae30SDana Myers break;
554db2bae30SDana Myers
555*385cc6b4SJerry Jelinek case AML_FIELD_ACCESS_OP:
556db2bae30SDana Myers
557db2bae30SDana Myers Opcode = AML_INT_ACCESSFIELD_OP;
558db2bae30SDana Myers ParserState->Aml++;
559db2bae30SDana Myers break;
560*385cc6b4SJerry Jelinek
561*385cc6b4SJerry Jelinek case AML_FIELD_CONNECTION_OP:
562*385cc6b4SJerry Jelinek
563*385cc6b4SJerry Jelinek Opcode = AML_INT_CONNECTION_OP;
564*385cc6b4SJerry Jelinek ParserState->Aml++;
565*385cc6b4SJerry Jelinek break;
566*385cc6b4SJerry Jelinek
567*385cc6b4SJerry Jelinek case AML_FIELD_EXT_ACCESS_OP:
568*385cc6b4SJerry Jelinek
569*385cc6b4SJerry Jelinek Opcode = AML_INT_EXTACCESSFIELD_OP;
570*385cc6b4SJerry Jelinek ParserState->Aml++;
571*385cc6b4SJerry Jelinek break;
572*385cc6b4SJerry Jelinek
573*385cc6b4SJerry Jelinek default:
574*385cc6b4SJerry Jelinek
575*385cc6b4SJerry Jelinek Opcode = AML_INT_NAMEDFIELD_OP;
576*385cc6b4SJerry Jelinek break;
577db2bae30SDana Myers }
578db2bae30SDana Myers
579db2bae30SDana Myers /* Allocate a new field op */
580db2bae30SDana Myers
581*385cc6b4SJerry Jelinek Field = AcpiPsAllocOp (Opcode, Aml);
582db2bae30SDana Myers if (!Field)
583db2bae30SDana Myers {
584db2bae30SDana Myers return_PTR (NULL);
585db2bae30SDana Myers }
586db2bae30SDana Myers
587db2bae30SDana Myers /* Decode the field type */
588db2bae30SDana Myers
589db2bae30SDana Myers switch (Opcode)
590db2bae30SDana Myers {
591db2bae30SDana Myers case AML_INT_NAMEDFIELD_OP:
592db2bae30SDana Myers
593db2bae30SDana Myers /* Get the 4-character name */
594db2bae30SDana Myers
595db2bae30SDana Myers ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
596db2bae30SDana Myers AcpiPsSetName (Field, Name);
597db2bae30SDana Myers ParserState->Aml += ACPI_NAME_SIZE;
598db2bae30SDana Myers
599db2bae30SDana Myers /* Get the length which is encoded as a package length */
600db2bae30SDana Myers
601db2bae30SDana Myers Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
602db2bae30SDana Myers break;
603db2bae30SDana Myers
604db2bae30SDana Myers
605db2bae30SDana Myers case AML_INT_RESERVEDFIELD_OP:
606db2bae30SDana Myers
607db2bae30SDana Myers /* Get the length which is encoded as a package length */
608db2bae30SDana Myers
609db2bae30SDana Myers Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
610db2bae30SDana Myers break;
611db2bae30SDana Myers
612db2bae30SDana Myers
613db2bae30SDana Myers case AML_INT_ACCESSFIELD_OP:
614*385cc6b4SJerry Jelinek case AML_INT_EXTACCESSFIELD_OP:
615db2bae30SDana Myers
616db2bae30SDana Myers /*
617db2bae30SDana Myers * Get AccessType and AccessAttrib and merge into the field Op
618*385cc6b4SJerry Jelinek * AccessType is first operand, AccessAttribute is second. stuff
619*385cc6b4SJerry Jelinek * these bytes into the node integer value for convenience.
620db2bae30SDana Myers */
621*385cc6b4SJerry Jelinek
622*385cc6b4SJerry Jelinek /* Get the two bytes (Type/Attribute) */
623*385cc6b4SJerry Jelinek
624*385cc6b4SJerry Jelinek AccessType = ACPI_GET8 (ParserState->Aml);
625db2bae30SDana Myers ParserState->Aml++;
626*385cc6b4SJerry Jelinek AccessAttribute = ACPI_GET8 (ParserState->Aml);
627db2bae30SDana Myers ParserState->Aml++;
628*385cc6b4SJerry Jelinek
629*385cc6b4SJerry Jelinek Field->Common.Value.Integer = (UINT8) AccessType;
630*385cc6b4SJerry Jelinek Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
631*385cc6b4SJerry Jelinek
632*385cc6b4SJerry Jelinek /* This opcode has a third byte, AccessLength */
633*385cc6b4SJerry Jelinek
634*385cc6b4SJerry Jelinek if (Opcode == AML_INT_EXTACCESSFIELD_OP)
635*385cc6b4SJerry Jelinek {
636*385cc6b4SJerry Jelinek AccessLength = ACPI_GET8 (ParserState->Aml);
637*385cc6b4SJerry Jelinek ParserState->Aml++;
638*385cc6b4SJerry Jelinek
639*385cc6b4SJerry Jelinek Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
640*385cc6b4SJerry Jelinek }
641db2bae30SDana Myers break;
642db2bae30SDana Myers
643*385cc6b4SJerry Jelinek
644*385cc6b4SJerry Jelinek case AML_INT_CONNECTION_OP:
645*385cc6b4SJerry Jelinek
646*385cc6b4SJerry Jelinek /*
647*385cc6b4SJerry Jelinek * Argument for Connection operator can be either a Buffer
648*385cc6b4SJerry Jelinek * (resource descriptor), or a NameString.
649*385cc6b4SJerry Jelinek */
650*385cc6b4SJerry Jelinek Aml = ParserState->Aml;
651*385cc6b4SJerry Jelinek if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
652*385cc6b4SJerry Jelinek {
653*385cc6b4SJerry Jelinek ParserState->Aml++;
654*385cc6b4SJerry Jelinek
655*385cc6b4SJerry Jelinek PkgEnd = ParserState->Aml;
656*385cc6b4SJerry Jelinek PkgLength = AcpiPsGetNextPackageLength (ParserState);
657*385cc6b4SJerry Jelinek PkgEnd += PkgLength;
658*385cc6b4SJerry Jelinek
659*385cc6b4SJerry Jelinek if (ParserState->Aml < PkgEnd)
660*385cc6b4SJerry Jelinek {
661*385cc6b4SJerry Jelinek /* Non-empty list */
662*385cc6b4SJerry Jelinek
663*385cc6b4SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP, Aml);
664*385cc6b4SJerry Jelinek if (!Arg)
665*385cc6b4SJerry Jelinek {
666*385cc6b4SJerry Jelinek AcpiPsFreeOp (Field);
667*385cc6b4SJerry Jelinek return_PTR (NULL);
668*385cc6b4SJerry Jelinek }
669*385cc6b4SJerry Jelinek
670*385cc6b4SJerry Jelinek /* Get the actual buffer length argument */
671*385cc6b4SJerry Jelinek
672*385cc6b4SJerry Jelinek Opcode = ACPI_GET8 (ParserState->Aml);
673*385cc6b4SJerry Jelinek ParserState->Aml++;
674*385cc6b4SJerry Jelinek
675*385cc6b4SJerry Jelinek switch (Opcode)
676*385cc6b4SJerry Jelinek {
677*385cc6b4SJerry Jelinek case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
678*385cc6b4SJerry Jelinek
679*385cc6b4SJerry Jelinek BufferLength = ACPI_GET8 (ParserState->Aml);
680*385cc6b4SJerry Jelinek ParserState->Aml += 1;
681*385cc6b4SJerry Jelinek break;
682*385cc6b4SJerry Jelinek
683*385cc6b4SJerry Jelinek case AML_WORD_OP: /* AML_WORDDATA_ARG */
684*385cc6b4SJerry Jelinek
685*385cc6b4SJerry Jelinek BufferLength = ACPI_GET16 (ParserState->Aml);
686*385cc6b4SJerry Jelinek ParserState->Aml += 2;
687*385cc6b4SJerry Jelinek break;
688*385cc6b4SJerry Jelinek
689*385cc6b4SJerry Jelinek case AML_DWORD_OP: /* AML_DWORDATA_ARG */
690*385cc6b4SJerry Jelinek
691*385cc6b4SJerry Jelinek BufferLength = ACPI_GET32 (ParserState->Aml);
692*385cc6b4SJerry Jelinek ParserState->Aml += 4;
693*385cc6b4SJerry Jelinek break;
694*385cc6b4SJerry Jelinek
695*385cc6b4SJerry Jelinek default:
696*385cc6b4SJerry Jelinek
697*385cc6b4SJerry Jelinek BufferLength = 0;
698*385cc6b4SJerry Jelinek break;
699*385cc6b4SJerry Jelinek }
700*385cc6b4SJerry Jelinek
701*385cc6b4SJerry Jelinek /* Fill in bytelist data */
702*385cc6b4SJerry Jelinek
703*385cc6b4SJerry Jelinek Arg->Named.Value.Size = BufferLength;
704*385cc6b4SJerry Jelinek Arg->Named.Data = ParserState->Aml;
705*385cc6b4SJerry Jelinek }
706*385cc6b4SJerry Jelinek
707*385cc6b4SJerry Jelinek /* Skip to End of byte data */
708*385cc6b4SJerry Jelinek
709*385cc6b4SJerry Jelinek ParserState->Aml = PkgEnd;
710*385cc6b4SJerry Jelinek }
711*385cc6b4SJerry Jelinek else
712*385cc6b4SJerry Jelinek {
713*385cc6b4SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Aml);
714*385cc6b4SJerry Jelinek if (!Arg)
715*385cc6b4SJerry Jelinek {
716*385cc6b4SJerry Jelinek AcpiPsFreeOp (Field);
717*385cc6b4SJerry Jelinek return_PTR (NULL);
718*385cc6b4SJerry Jelinek }
719*385cc6b4SJerry Jelinek
720*385cc6b4SJerry Jelinek /* Get the Namestring argument */
721*385cc6b4SJerry Jelinek
722*385cc6b4SJerry Jelinek Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
723*385cc6b4SJerry Jelinek }
724*385cc6b4SJerry Jelinek
725*385cc6b4SJerry Jelinek /* Link the buffer/namestring to parent (CONNECTION_OP) */
726*385cc6b4SJerry Jelinek
727*385cc6b4SJerry Jelinek AcpiPsAppendArg (Field, Arg);
728*385cc6b4SJerry Jelinek break;
729*385cc6b4SJerry Jelinek
730*385cc6b4SJerry Jelinek
731db2bae30SDana Myers default:
732db2bae30SDana Myers
733db2bae30SDana Myers /* Opcode was set in previous switch */
734db2bae30SDana Myers break;
735db2bae30SDana Myers }
736db2bae30SDana Myers
737db2bae30SDana Myers return_PTR (Field);
738db2bae30SDana Myers }
739db2bae30SDana Myers
740db2bae30SDana Myers
741db2bae30SDana Myers /*******************************************************************************
742db2bae30SDana Myers *
743db2bae30SDana Myers * FUNCTION: AcpiPsGetNextArg
744db2bae30SDana Myers *
745db2bae30SDana Myers * PARAMETERS: WalkState - Current state
746db2bae30SDana Myers * ParserState - Current parser state object
747db2bae30SDana Myers * ArgType - The argument type (AML_*_ARG)
748db2bae30SDana Myers * ReturnArg - Where the next arg is returned
749db2bae30SDana Myers *
750db2bae30SDana Myers * RETURN: Status, and an op object containing the next argument.
751db2bae30SDana Myers *
752db2bae30SDana Myers * DESCRIPTION: Get next argument (including complex list arguments that require
753db2bae30SDana Myers * pushing the parser stack)
754db2bae30SDana Myers *
755db2bae30SDana Myers ******************************************************************************/
756db2bae30SDana Myers
757db2bae30SDana Myers ACPI_STATUS
AcpiPsGetNextArg(ACPI_WALK_STATE * WalkState,ACPI_PARSE_STATE * ParserState,UINT32 ArgType,ACPI_PARSE_OBJECT ** ReturnArg)758db2bae30SDana Myers AcpiPsGetNextArg (
759db2bae30SDana Myers ACPI_WALK_STATE *WalkState,
760db2bae30SDana Myers ACPI_PARSE_STATE *ParserState,
761db2bae30SDana Myers UINT32 ArgType,
762db2bae30SDana Myers ACPI_PARSE_OBJECT **ReturnArg)
763db2bae30SDana Myers {
764db2bae30SDana Myers ACPI_PARSE_OBJECT *Arg = NULL;
765db2bae30SDana Myers ACPI_PARSE_OBJECT *Prev = NULL;
766db2bae30SDana Myers ACPI_PARSE_OBJECT *Field;
767db2bae30SDana Myers UINT32 Subop;
768db2bae30SDana Myers ACPI_STATUS Status = AE_OK;
769db2bae30SDana Myers
770db2bae30SDana Myers
771db2bae30SDana Myers ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
772db2bae30SDana Myers
773db2bae30SDana Myers
774db2bae30SDana Myers switch (ArgType)
775db2bae30SDana Myers {
776db2bae30SDana Myers case ARGP_BYTEDATA:
777db2bae30SDana Myers case ARGP_WORDDATA:
778db2bae30SDana Myers case ARGP_DWORDDATA:
779db2bae30SDana Myers case ARGP_CHARLIST:
780db2bae30SDana Myers case ARGP_NAME:
781db2bae30SDana Myers case ARGP_NAMESTRING:
782db2bae30SDana Myers
783db2bae30SDana Myers /* Constants, strings, and namestrings are all the same size */
784db2bae30SDana Myers
785*385cc6b4SJerry Jelinek Arg = AcpiPsAllocOp (AML_BYTE_OP, ParserState->Aml);
786db2bae30SDana Myers if (!Arg)
787db2bae30SDana Myers {
788db2bae30SDana Myers return_ACPI_STATUS (AE_NO_MEMORY);
789db2bae30SDana Myers }
790*385cc6b4SJerry Jelinek
791db2bae30SDana Myers AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
792db2bae30SDana Myers break;
793db2bae30SDana Myers
794db2bae30SDana Myers case ARGP_PKGLENGTH:
795db2bae30SDana Myers
796db2bae30SDana Myers /* Package length, nothing returned */
797db2bae30SDana Myers
798db2bae30SDana Myers ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
799db2bae30SDana Myers break;
800db2bae30SDana Myers
801db2bae30SDana Myers case ARGP_FIELDLIST:
802db2bae30SDana Myers
803db2bae30SDana Myers if (ParserState->Aml < ParserState->PkgEnd)
804db2bae30SDana Myers {
805db2bae30SDana Myers /* Non-empty list */
806db2bae30SDana Myers
807db2bae30SDana Myers while (ParserState->Aml < ParserState->PkgEnd)
808db2bae30SDana Myers {
809db2bae30SDana Myers Field = AcpiPsGetNextField (ParserState);
810db2bae30SDana Myers if (!Field)
811db2bae30SDana Myers {
812db2bae30SDana Myers return_ACPI_STATUS (AE_NO_MEMORY);
813db2bae30SDana Myers }
814db2bae30SDana Myers
815db2bae30SDana Myers if (Prev)
816db2bae30SDana Myers {
817db2bae30SDana Myers Prev->Common.Next = Field;
818db2bae30SDana Myers }
819db2bae30SDana Myers else
820db2bae30SDana Myers {
821db2bae30SDana Myers Arg = Field;
822db2bae30SDana Myers }
823db2bae30SDana Myers Prev = Field;
824db2bae30SDana Myers }
825db2bae30SDana Myers
826db2bae30SDana Myers /* Skip to End of byte data */
827db2bae30SDana Myers
828db2bae30SDana Myers ParserState->Aml = ParserState->PkgEnd;
829db2bae30SDana Myers }
830db2bae30SDana Myers break;
831db2bae30SDana Myers
832db2bae30SDana Myers case ARGP_BYTELIST:
833db2bae30SDana Myers
834db2bae30SDana Myers if (ParserState->Aml < ParserState->PkgEnd)
835db2bae30SDana Myers {
836db2bae30SDana Myers /* Non-empty list */
837db2bae30SDana Myers
838*385cc6b4SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP,
839*385cc6b4SJerry Jelinek ParserState->Aml);
840db2bae30SDana Myers if (!Arg)
841db2bae30SDana Myers {
842db2bae30SDana Myers return_ACPI_STATUS (AE_NO_MEMORY);
843db2bae30SDana Myers }
844db2bae30SDana Myers
845db2bae30SDana Myers /* Fill in bytelist data */
846db2bae30SDana Myers
847db2bae30SDana Myers Arg->Common.Value.Size = (UINT32)
848db2bae30SDana Myers ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
849db2bae30SDana Myers Arg->Named.Data = ParserState->Aml;
850db2bae30SDana Myers
851db2bae30SDana Myers /* Skip to End of byte data */
852db2bae30SDana Myers
853db2bae30SDana Myers ParserState->Aml = ParserState->PkgEnd;
854db2bae30SDana Myers }
855db2bae30SDana Myers break;
856db2bae30SDana Myers
857db2bae30SDana Myers case ARGP_TARGET:
858db2bae30SDana Myers case ARGP_SUPERNAME:
859db2bae30SDana Myers case ARGP_SIMPLENAME:
860*385cc6b4SJerry Jelinek case ARGP_NAME_OR_REF:
861db2bae30SDana Myers
862db2bae30SDana Myers Subop = AcpiPsPeekOpcode (ParserState);
863db2bae30SDana Myers if (Subop == 0 ||
864db2bae30SDana Myers AcpiPsIsLeadingChar (Subop) ||
865*385cc6b4SJerry Jelinek ACPI_IS_ROOT_PREFIX (Subop) ||
866*385cc6b4SJerry Jelinek ACPI_IS_PARENT_PREFIX (Subop))
867db2bae30SDana Myers {
868db2bae30SDana Myers /* NullName or NameString */
869db2bae30SDana Myers
870*385cc6b4SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
871db2bae30SDana Myers if (!Arg)
872db2bae30SDana Myers {
873db2bae30SDana Myers return_ACPI_STATUS (AE_NO_MEMORY);
874db2bae30SDana Myers }
875db2bae30SDana Myers
876db2bae30SDana Myers /* To support SuperName arg of Unload */
877db2bae30SDana Myers
878db2bae30SDana Myers if (WalkState->Opcode == AML_UNLOAD_OP)
879db2bae30SDana Myers {
880*385cc6b4SJerry Jelinek Status = AcpiPsGetNextNamepath (WalkState, ParserState,
881*385cc6b4SJerry Jelinek Arg, ACPI_POSSIBLE_METHOD_CALL);
882db2bae30SDana Myers
883db2bae30SDana Myers /*
884*385cc6b4SJerry Jelinek * If the SuperName argument is a method call, we have
885*385cc6b4SJerry Jelinek * already restored the AML pointer, just free this Arg
886db2bae30SDana Myers */
887db2bae30SDana Myers if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
888db2bae30SDana Myers {
889db2bae30SDana Myers AcpiPsFreeOp (Arg);
890db2bae30SDana Myers Arg = NULL;
891db2bae30SDana Myers }
892db2bae30SDana Myers }
893db2bae30SDana Myers else
894db2bae30SDana Myers {
895*385cc6b4SJerry Jelinek Status = AcpiPsGetNextNamepath (WalkState, ParserState,
896*385cc6b4SJerry Jelinek Arg, ACPI_NOT_METHOD_CALL);
897db2bae30SDana Myers }
898db2bae30SDana Myers }
899db2bae30SDana Myers else
900db2bae30SDana Myers {
901db2bae30SDana Myers /* Single complex argument, nothing returned */
902db2bae30SDana Myers
903db2bae30SDana Myers WalkState->ArgCount = 1;
904db2bae30SDana Myers }
905db2bae30SDana Myers break;
906db2bae30SDana Myers
907db2bae30SDana Myers case ARGP_DATAOBJ:
908db2bae30SDana Myers case ARGP_TERMARG:
909db2bae30SDana Myers
910db2bae30SDana Myers /* Single complex argument, nothing returned */
911db2bae30SDana Myers
912db2bae30SDana Myers WalkState->ArgCount = 1;
913db2bae30SDana Myers break;
914db2bae30SDana Myers
915db2bae30SDana Myers case ARGP_DATAOBJLIST:
916db2bae30SDana Myers case ARGP_TERMLIST:
917db2bae30SDana Myers case ARGP_OBJLIST:
918db2bae30SDana Myers
919db2bae30SDana Myers if (ParserState->Aml < ParserState->PkgEnd)
920db2bae30SDana Myers {
921db2bae30SDana Myers /* Non-empty list of variable arguments, nothing returned */
922db2bae30SDana Myers
923db2bae30SDana Myers WalkState->ArgCount = ACPI_VAR_ARGS;
924db2bae30SDana Myers }
925db2bae30SDana Myers break;
926db2bae30SDana Myers
927db2bae30SDana Myers default:
928db2bae30SDana Myers
92926f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
930db2bae30SDana Myers Status = AE_AML_OPERAND_TYPE;
931db2bae30SDana Myers break;
932db2bae30SDana Myers }
933db2bae30SDana Myers
934db2bae30SDana Myers *ReturnArg = Arg;
935db2bae30SDana Myers return_ACPI_STATUS (Status);
936db2bae30SDana Myers }
937