17c478bd9Sstevel@tonic-gate /******************************************************************************
27c478bd9Sstevel@tonic-gate *
37c478bd9Sstevel@tonic-gate * Module Name: psargs - Parse AML opcode arguments
47c478bd9Sstevel@tonic-gate *
57c478bd9Sstevel@tonic-gate *****************************************************************************/
67c478bd9Sstevel@tonic-gate
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi *
9*35786f68SRobert Mustacchi * 1. Copyright Notice
10*35786f68SRobert Mustacchi *
11*35786f68SRobert Mustacchi * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
127c478bd9Sstevel@tonic-gate * All rights reserved.
137c478bd9Sstevel@tonic-gate *
14*35786f68SRobert Mustacchi * 2. License
15*35786f68SRobert Mustacchi *
16*35786f68SRobert Mustacchi * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi * property rights.
20*35786f68SRobert Mustacchi *
21*35786f68SRobert Mustacchi * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi *
28*35786f68SRobert Mustacchi * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi *
37*35786f68SRobert Mustacchi * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi * conditions are met:
39*35786f68SRobert Mustacchi *
40*35786f68SRobert Mustacchi * 3. Conditions
41*35786f68SRobert Mustacchi *
42*35786f68SRobert Mustacchi * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi *
54*35786f68SRobert Mustacchi * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi * make.
65*35786f68SRobert Mustacchi *
66*35786f68SRobert Mustacchi * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi * distribution.
71*35786f68SRobert Mustacchi *
72*35786f68SRobert Mustacchi * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi * Intel Code.
74*35786f68SRobert Mustacchi *
75*35786f68SRobert Mustacchi * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi *
80*35786f68SRobert Mustacchi * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi *
82*35786f68SRobert Mustacchi * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi *
90*35786f68SRobert Mustacchi * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi * LIMITED REMEDY.
98*35786f68SRobert Mustacchi *
99*35786f68SRobert Mustacchi * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi * such license, approval or letter.
113*35786f68SRobert Mustacchi *
114*35786f68SRobert Mustacchi *****************************************************************************
115*35786f68SRobert Mustacchi *
116*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi * following license:
118*35786f68SRobert Mustacchi *
11926f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
12026f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
12126f3cdf0SGordon Ross * are met:
12226f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
12326f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
12426f3cdf0SGordon Ross * without modification.
12526f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12626f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
12726f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
12826f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
12926f3cdf0SGordon Ross * binary redistribution.
13026f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
13126f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
13226f3cdf0SGordon Ross * from this software without specific prior written permission.
13326f3cdf0SGordon Ross *
13426f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13526f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
13726f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi *
146*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi * Software Foundation.
149*35786f68SRobert Mustacchi *
150*35786f68SRobert Mustacchi *****************************************************************************/
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate #include "acpi.h"
153aa2aa9a6SDana Myers #include "accommon.h"
1547c478bd9Sstevel@tonic-gate #include "acparser.h"
1557c478bd9Sstevel@tonic-gate #include "amlcode.h"
1567c478bd9Sstevel@tonic-gate #include "acnamesp.h"
15730082d0cSmyers #include "acdispat.h"
158*35786f68SRobert Mustacchi #include "acconvert.h"
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate #define _COMPONENT ACPI_PARSER
1617c478bd9Sstevel@tonic-gate ACPI_MODULE_NAME ("psargs")
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate /* Local prototypes */
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gate static UINT32
1667c478bd9Sstevel@tonic-gate AcpiPsGetNextPackageLength (
1677c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState);
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gate static ACPI_PARSE_OBJECT *
1707c478bd9Sstevel@tonic-gate AcpiPsGetNextField (
1717c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState);
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate /*******************************************************************************
1757c478bd9Sstevel@tonic-gate *
1767c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextPackageLength
1777c478bd9Sstevel@tonic-gate *
1787c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
1797c478bd9Sstevel@tonic-gate *
18030082d0cSmyers * RETURN: Decoded package length. On completion, the AML pointer points
1817c478bd9Sstevel@tonic-gate * past the length byte or bytes.
1827c478bd9Sstevel@tonic-gate *
18330082d0cSmyers * DESCRIPTION: Decode and return a package length field.
18430082d0cSmyers * Note: Largest package length is 28 bits, from ACPI specification
1857c478bd9Sstevel@tonic-gate *
1867c478bd9Sstevel@tonic-gate ******************************************************************************/
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate static UINT32
AcpiPsGetNextPackageLength(ACPI_PARSE_STATE * ParserState)1897c478bd9Sstevel@tonic-gate AcpiPsGetNextPackageLength (
1907c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState)
1917c478bd9Sstevel@tonic-gate {
19230082d0cSmyers UINT8 *Aml = ParserState->Aml;
19330082d0cSmyers UINT32 PackageLength = 0;
194db2bae30SDana Myers UINT32 ByteCount;
19530082d0cSmyers UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate
19827f7c583Smyers ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate
20130082d0cSmyers /*
20230082d0cSmyers * Byte 0 bits [6:7] contain the number of additional bytes
20330082d0cSmyers * used to encode the package length, either 0,1,2, or 3
20430082d0cSmyers */
20530082d0cSmyers ByteCount = (Aml[0] >> 6);
206db2bae30SDana Myers ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
2077c478bd9Sstevel@tonic-gate
20830082d0cSmyers /* Get bytes 3, 2, 1 as needed */
2097c478bd9Sstevel@tonic-gate
21030082d0cSmyers while (ByteCount)
21130082d0cSmyers {
21230082d0cSmyers /*
21330082d0cSmyers * Final bit positions for the package length bytes:
21430082d0cSmyers * Byte3->[20:27]
21530082d0cSmyers * Byte2->[12:19]
21630082d0cSmyers * Byte1->[04:11]
21730082d0cSmyers * Byte0->[00:03]
21830082d0cSmyers */
21930082d0cSmyers PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
2207c478bd9Sstevel@tonic-gate
22130082d0cSmyers ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
22230082d0cSmyers ByteCount--;
2237c478bd9Sstevel@tonic-gate }
2247c478bd9Sstevel@tonic-gate
22530082d0cSmyers /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
22630082d0cSmyers
22730082d0cSmyers PackageLength |= (Aml[0] & ByteZeroMask);
22830082d0cSmyers return_UINT32 (PackageLength);
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate /*******************************************************************************
2337c478bd9Sstevel@tonic-gate *
2347c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextPackageEnd
2357c478bd9Sstevel@tonic-gate *
2367c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
2377c478bd9Sstevel@tonic-gate *
2387c478bd9Sstevel@tonic-gate * RETURN: Pointer to end-of-package +1
2397c478bd9Sstevel@tonic-gate *
2407c478bd9Sstevel@tonic-gate * DESCRIPTION: Get next package length and return a pointer past the end of
2417b1019a6SJerry Jelinek * the package. Consumes the package length field
2427c478bd9Sstevel@tonic-gate *
2437c478bd9Sstevel@tonic-gate ******************************************************************************/
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gate UINT8 *
AcpiPsGetNextPackageEnd(ACPI_PARSE_STATE * ParserState)2467c478bd9Sstevel@tonic-gate AcpiPsGetNextPackageEnd (
2477c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState)
2487c478bd9Sstevel@tonic-gate {
2497c478bd9Sstevel@tonic-gate UINT8 *Start = ParserState->Aml;
25030082d0cSmyers UINT32 PackageLength;
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate
25327f7c583Smyers ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate
25630082d0cSmyers /* Function below updates ParserState->Aml */
2577c478bd9Sstevel@tonic-gate
25830082d0cSmyers PackageLength = AcpiPsGetNextPackageLength (ParserState);
2597c478bd9Sstevel@tonic-gate
26030082d0cSmyers return_PTR (Start + PackageLength); /* end of package */
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate /*******************************************************************************
2657c478bd9Sstevel@tonic-gate *
2667c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextNamestring
2677c478bd9Sstevel@tonic-gate *
2687c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
2697c478bd9Sstevel@tonic-gate *
2707c478bd9Sstevel@tonic-gate * RETURN: Pointer to the start of the name string (pointer points into
2717c478bd9Sstevel@tonic-gate * the AML.
2727c478bd9Sstevel@tonic-gate *
2737b1019a6SJerry Jelinek * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
2747b1019a6SJerry Jelinek * prefix characters. Set parser state to point past the string.
2757c478bd9Sstevel@tonic-gate * (Name is consumed from the AML.)
2767c478bd9Sstevel@tonic-gate *
2777c478bd9Sstevel@tonic-gate ******************************************************************************/
2787c478bd9Sstevel@tonic-gate
2797c478bd9Sstevel@tonic-gate char *
AcpiPsGetNextNamestring(ACPI_PARSE_STATE * ParserState)2807c478bd9Sstevel@tonic-gate AcpiPsGetNextNamestring (
2817c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState)
2827c478bd9Sstevel@tonic-gate {
2837c478bd9Sstevel@tonic-gate UINT8 *Start = ParserState->Aml;
2847c478bd9Sstevel@tonic-gate UINT8 *End = ParserState->Aml;
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate
28727f7c583Smyers ACPI_FUNCTION_TRACE (PsGetNextNamestring);
2887c478bd9Sstevel@tonic-gate
2897c478bd9Sstevel@tonic-gate
29030082d0cSmyers /* Point past any namestring prefix characters (backslash or carat) */
2917c478bd9Sstevel@tonic-gate
2927b1019a6SJerry Jelinek while (ACPI_IS_ROOT_PREFIX (*End) ||
2937b1019a6SJerry Jelinek ACPI_IS_PARENT_PREFIX (*End))
2947c478bd9Sstevel@tonic-gate {
2957c478bd9Sstevel@tonic-gate End++;
2967c478bd9Sstevel@tonic-gate }
2977c478bd9Sstevel@tonic-gate
29830082d0cSmyers /* Decode the path prefix character */
2997c478bd9Sstevel@tonic-gate
30030082d0cSmyers switch (*End)
3017c478bd9Sstevel@tonic-gate {
3027c478bd9Sstevel@tonic-gate case 0:
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gate /* NullName */
3057c478bd9Sstevel@tonic-gate
3067c478bd9Sstevel@tonic-gate if (End == Start)
3077c478bd9Sstevel@tonic-gate {
3087c478bd9Sstevel@tonic-gate Start = NULL;
3097c478bd9Sstevel@tonic-gate }
3107c478bd9Sstevel@tonic-gate End++;
3117c478bd9Sstevel@tonic-gate break;
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gate case AML_DUAL_NAME_PREFIX:
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate /* Two name segments */
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate End += 1 + (2 * ACPI_NAME_SIZE);
3187c478bd9Sstevel@tonic-gate break;
3197c478bd9Sstevel@tonic-gate
320*35786f68SRobert Mustacchi case AML_MULTI_NAME_PREFIX:
3217c478bd9Sstevel@tonic-gate
32230082d0cSmyers /* Multiple name segments, 4 chars each, count in next byte */
3237c478bd9Sstevel@tonic-gate
32430082d0cSmyers End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
3257c478bd9Sstevel@tonic-gate break;
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate default:
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate /* Single name segment */
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate End += ACPI_NAME_SIZE;
3327c478bd9Sstevel@tonic-gate break;
3337c478bd9Sstevel@tonic-gate }
3347c478bd9Sstevel@tonic-gate
33530082d0cSmyers ParserState->Aml = End;
3367c478bd9Sstevel@tonic-gate return_PTR ((char *) Start);
3377c478bd9Sstevel@tonic-gate }
3387c478bd9Sstevel@tonic-gate
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate /*******************************************************************************
3417c478bd9Sstevel@tonic-gate *
3427c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextNamepath
3437c478bd9Sstevel@tonic-gate *
3447c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
3457c478bd9Sstevel@tonic-gate * Arg - Where the namepath will be stored
3467c478bd9Sstevel@tonic-gate * ArgCount - If the namepath points to a control method
3477c478bd9Sstevel@tonic-gate * the method's argument is returned here.
34830082d0cSmyers * PossibleMethodCall - Whether the namepath can possibly be the
3497c478bd9Sstevel@tonic-gate * start of a method call
3507c478bd9Sstevel@tonic-gate *
3517c478bd9Sstevel@tonic-gate * RETURN: Status
3527c478bd9Sstevel@tonic-gate *
3537c478bd9Sstevel@tonic-gate * DESCRIPTION: Get next name (if method call, return # of required args).
3547c478bd9Sstevel@tonic-gate * Names are looked up in the internal namespace to determine
3557b1019a6SJerry Jelinek * if the name represents a control method. If a method
3567c478bd9Sstevel@tonic-gate * is found, the number of arguments to the method is returned.
3577c478bd9Sstevel@tonic-gate * This information is critical for parsing to continue correctly.
3587c478bd9Sstevel@tonic-gate *
3597c478bd9Sstevel@tonic-gate ******************************************************************************/
3607c478bd9Sstevel@tonic-gate
3617c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiPsGetNextNamepath(ACPI_WALK_STATE * WalkState,ACPI_PARSE_STATE * ParserState,ACPI_PARSE_OBJECT * Arg,BOOLEAN PossibleMethodCall)3627c478bd9Sstevel@tonic-gate AcpiPsGetNextNamepath (
3637c478bd9Sstevel@tonic-gate ACPI_WALK_STATE *WalkState,
3647c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState,
3657c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Arg,
36630082d0cSmyers BOOLEAN PossibleMethodCall)
3677c478bd9Sstevel@tonic-gate {
368db2bae30SDana Myers ACPI_STATUS Status;
3697c478bd9Sstevel@tonic-gate char *Path;
3707c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *NameOp;
3717c478bd9Sstevel@tonic-gate ACPI_OPERAND_OBJECT *MethodDesc;
3727c478bd9Sstevel@tonic-gate ACPI_NAMESPACE_NODE *Node;
373db2bae30SDana Myers UINT8 *Start = ParserState->Aml;
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate
37627f7c583Smyers ACPI_FUNCTION_TRACE (PsGetNextNamepath);
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate
3797c478bd9Sstevel@tonic-gate Path = AcpiPsGetNextNamestring (ParserState);
38030082d0cSmyers AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
3817c478bd9Sstevel@tonic-gate
38230082d0cSmyers /* Null path case is allowed, just exit */
3837c478bd9Sstevel@tonic-gate
38430082d0cSmyers if (!Path)
3857c478bd9Sstevel@tonic-gate {
38630082d0cSmyers Arg->Common.Value.Name = Path;
38730082d0cSmyers return_ACPI_STATUS (AE_OK);
38830082d0cSmyers }
38930082d0cSmyers
39030082d0cSmyers /*
391db2bae30SDana Myers * Lookup the name in the internal namespace, starting with the current
392db2bae30SDana Myers * scope. We don't want to add anything new to the namespace here,
393db2bae30SDana Myers * however, so we use MODE_EXECUTE.
39430082d0cSmyers * Allow searching of the parent tree, but don't open a new scope -
39530082d0cSmyers * we just want to lookup the object (must be mode EXECUTE to perform
39630082d0cSmyers * the upsearch)
39730082d0cSmyers */
398db2bae30SDana Myers Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
3997b1019a6SJerry Jelinek ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
4007b1019a6SJerry Jelinek ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
40130082d0cSmyers
40230082d0cSmyers /*
40330082d0cSmyers * If this name is a control method invocation, we must
40430082d0cSmyers * setup the method call
40530082d0cSmyers */
40630082d0cSmyers if (ACPI_SUCCESS (Status) &&
40730082d0cSmyers PossibleMethodCall &&
40830082d0cSmyers (Node->Type == ACPI_TYPE_METHOD))
40930082d0cSmyers {
410*35786f68SRobert Mustacchi if ((GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME) ||
411*35786f68SRobert Mustacchi (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_TARGET))
412db2bae30SDana Myers {
413db2bae30SDana Myers /*
414*35786f68SRobert Mustacchi * AcpiPsGetNextNamestring has increased the AML pointer past
415*35786f68SRobert Mustacchi * the method invocation namestring, so we need to restore the
416*35786f68SRobert Mustacchi * saved AML pointer back to the original method invocation
417*35786f68SRobert Mustacchi * namestring.
418db2bae30SDana Myers */
419db2bae30SDana Myers WalkState->ParserState.Aml = Start;
420db2bae30SDana Myers WalkState->ArgCount = 1;
421db2bae30SDana Myers AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
422db2bae30SDana Myers }
423db2bae30SDana Myers
42430082d0cSmyers /* This name is actually a control method invocation */
42530082d0cSmyers
42630082d0cSmyers MethodDesc = AcpiNsGetAttachedObject (Node);
42730082d0cSmyers ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
428*35786f68SRobert Mustacchi "Control Method invocation %4.4s - %p Desc %p Path=%p\n",
429*35786f68SRobert Mustacchi Node->Name.Ascii, Node, MethodDesc, Path));
43030082d0cSmyers
4317b1019a6SJerry Jelinek NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start);
43230082d0cSmyers if (!NameOp)
4337c478bd9Sstevel@tonic-gate {
43430082d0cSmyers return_ACPI_STATUS (AE_NO_MEMORY);
4357c478bd9Sstevel@tonic-gate }
4367c478bd9Sstevel@tonic-gate
43730082d0cSmyers /* Change Arg into a METHOD CALL and attach name to it */
4387c478bd9Sstevel@tonic-gate
43930082d0cSmyers AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
44030082d0cSmyers NameOp->Common.Value.Name = Path;
4417c478bd9Sstevel@tonic-gate
44230082d0cSmyers /* Point METHODCALL/NAME to the METHOD Node */
4437c478bd9Sstevel@tonic-gate
44430082d0cSmyers NameOp->Common.Node = Node;
44530082d0cSmyers AcpiPsAppendArg (Arg, NameOp);
4467c478bd9Sstevel@tonic-gate
44730082d0cSmyers if (!MethodDesc)
44830082d0cSmyers {
44930082d0cSmyers ACPI_ERROR ((AE_INFO,
45030082d0cSmyers "Control Method %p has no attached object",
45130082d0cSmyers Node));
45230082d0cSmyers return_ACPI_STATUS (AE_AML_INTERNAL);
45330082d0cSmyers }
4547c478bd9Sstevel@tonic-gate
45530082d0cSmyers ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
45630082d0cSmyers "Control Method - %p Args %X\n",
45730082d0cSmyers Node, MethodDesc->Method.ParamCount));
4587c478bd9Sstevel@tonic-gate
45930082d0cSmyers /* Get the number of arguments to expect */
4607c478bd9Sstevel@tonic-gate
46130082d0cSmyers WalkState->ArgCount = MethodDesc->Method.ParamCount;
46230082d0cSmyers return_ACPI_STATUS (AE_OK);
46330082d0cSmyers }
4647c478bd9Sstevel@tonic-gate
46530082d0cSmyers /*
46630082d0cSmyers * Special handling if the name was not found during the lookup -
46730082d0cSmyers * some NotFound cases are allowed
46830082d0cSmyers */
46930082d0cSmyers if (Status == AE_NOT_FOUND)
47030082d0cSmyers {
47130082d0cSmyers /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
4727c478bd9Sstevel@tonic-gate
47330082d0cSmyers if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
4747b1019a6SJerry Jelinek ACPI_PARSE_EXECUTE)
47530082d0cSmyers {
47630082d0cSmyers Status = AE_OK;
47730082d0cSmyers }
4787c478bd9Sstevel@tonic-gate
47930082d0cSmyers /* 2) NotFound during a CondRefOf(x) is ok by definition */
4807c478bd9Sstevel@tonic-gate
481*35786f68SRobert Mustacchi else if (WalkState->Op->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
48230082d0cSmyers {
48330082d0cSmyers Status = AE_OK;
4847c478bd9Sstevel@tonic-gate }
4857c478bd9Sstevel@tonic-gate
48630082d0cSmyers /*
48730082d0cSmyers * 3) NotFound while building a Package is ok at this point, we
48830082d0cSmyers * may flag as an error later if slack mode is not enabled.
48930082d0cSmyers * (Some ASL code depends on allowing this behavior)
49030082d0cSmyers */
49130082d0cSmyers else if ((Arg->Common.Parent) &&
49230082d0cSmyers ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
493*35786f68SRobert Mustacchi (Arg->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
4947c478bd9Sstevel@tonic-gate {
49530082d0cSmyers Status = AE_OK;
49630082d0cSmyers }
49730082d0cSmyers }
4987c478bd9Sstevel@tonic-gate
49930082d0cSmyers /* Final exception check (may have been changed from code above) */
5007c478bd9Sstevel@tonic-gate
50130082d0cSmyers if (ACPI_FAILURE (Status))
50230082d0cSmyers {
503*35786f68SRobert Mustacchi ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
5047c478bd9Sstevel@tonic-gate
50530082d0cSmyers if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
5067b1019a6SJerry Jelinek ACPI_PARSE_EXECUTE)
50730082d0cSmyers {
50830082d0cSmyers /* Report a control method execution error */
50930082d0cSmyers
51030082d0cSmyers Status = AcpiDsMethodError (Status, WalkState);
5117c478bd9Sstevel@tonic-gate }
5127c478bd9Sstevel@tonic-gate }
5137c478bd9Sstevel@tonic-gate
51430082d0cSmyers /* Save the namepath */
5157c478bd9Sstevel@tonic-gate
51630082d0cSmyers Arg->Common.Value.Name = Path;
5177c478bd9Sstevel@tonic-gate return_ACPI_STATUS (Status);
5187c478bd9Sstevel@tonic-gate }
5197c478bd9Sstevel@tonic-gate
5207c478bd9Sstevel@tonic-gate
5217c478bd9Sstevel@tonic-gate /*******************************************************************************
5227c478bd9Sstevel@tonic-gate *
5237c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextSimpleArg
5247c478bd9Sstevel@tonic-gate *
5257c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
5267c478bd9Sstevel@tonic-gate * ArgType - The argument type (AML_*_ARG)
5277c478bd9Sstevel@tonic-gate * Arg - Where the argument is returned
5287c478bd9Sstevel@tonic-gate *
5297c478bd9Sstevel@tonic-gate * RETURN: None
5307c478bd9Sstevel@tonic-gate *
5317c478bd9Sstevel@tonic-gate * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
5327c478bd9Sstevel@tonic-gate *
5337c478bd9Sstevel@tonic-gate ******************************************************************************/
5347c478bd9Sstevel@tonic-gate
5357c478bd9Sstevel@tonic-gate void
AcpiPsGetNextSimpleArg(ACPI_PARSE_STATE * ParserState,UINT32 ArgType,ACPI_PARSE_OBJECT * Arg)5367c478bd9Sstevel@tonic-gate AcpiPsGetNextSimpleArg (
5377c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState,
5387c478bd9Sstevel@tonic-gate UINT32 ArgType,
5397c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Arg)
5407c478bd9Sstevel@tonic-gate {
54130082d0cSmyers UINT32 Length;
54230082d0cSmyers UINT16 Opcode;
54330082d0cSmyers UINT8 *Aml = ParserState->Aml;
54430082d0cSmyers
5457c478bd9Sstevel@tonic-gate
54627f7c583Smyers ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
5477c478bd9Sstevel@tonic-gate
5487c478bd9Sstevel@tonic-gate
5497c478bd9Sstevel@tonic-gate switch (ArgType)
5507c478bd9Sstevel@tonic-gate {
5517c478bd9Sstevel@tonic-gate case ARGP_BYTEDATA:
5527c478bd9Sstevel@tonic-gate
55330082d0cSmyers /* Get 1 byte from the AML stream */
55430082d0cSmyers
55530082d0cSmyers Opcode = AML_BYTE_OP;
55626f3cdf0SGordon Ross Arg->Common.Value.Integer = (UINT64) *Aml;
55730082d0cSmyers Length = 1;
5587c478bd9Sstevel@tonic-gate break;
5597c478bd9Sstevel@tonic-gate
5607c478bd9Sstevel@tonic-gate case ARGP_WORDDATA:
5617c478bd9Sstevel@tonic-gate
5627c478bd9Sstevel@tonic-gate /* Get 2 bytes from the AML stream */
5637c478bd9Sstevel@tonic-gate
56430082d0cSmyers Opcode = AML_WORD_OP;
56530082d0cSmyers ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
56630082d0cSmyers Length = 2;
5677c478bd9Sstevel@tonic-gate break;
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate case ARGP_DWORDDATA:
5707c478bd9Sstevel@tonic-gate
5717c478bd9Sstevel@tonic-gate /* Get 4 bytes from the AML stream */
5727c478bd9Sstevel@tonic-gate
57330082d0cSmyers Opcode = AML_DWORD_OP;
57430082d0cSmyers ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
57530082d0cSmyers Length = 4;
5767c478bd9Sstevel@tonic-gate break;
5777c478bd9Sstevel@tonic-gate
5787c478bd9Sstevel@tonic-gate case ARGP_QWORDDATA:
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate /* Get 8 bytes from the AML stream */
5817c478bd9Sstevel@tonic-gate
58230082d0cSmyers Opcode = AML_QWORD_OP;
58330082d0cSmyers ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
58430082d0cSmyers Length = 8;
5857c478bd9Sstevel@tonic-gate break;
5867c478bd9Sstevel@tonic-gate
5877c478bd9Sstevel@tonic-gate case ARGP_CHARLIST:
5887c478bd9Sstevel@tonic-gate
58930082d0cSmyers /* Get a pointer to the string, point past the string */
5907c478bd9Sstevel@tonic-gate
59130082d0cSmyers Opcode = AML_STRING_OP;
59230082d0cSmyers Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
59330082d0cSmyers
59430082d0cSmyers /* Find the null terminator */
59530082d0cSmyers
59630082d0cSmyers Length = 0;
59730082d0cSmyers while (Aml[Length])
5987c478bd9Sstevel@tonic-gate {
59930082d0cSmyers Length++;
6007c478bd9Sstevel@tonic-gate }
60130082d0cSmyers Length++;
6027c478bd9Sstevel@tonic-gate break;
6037c478bd9Sstevel@tonic-gate
6047c478bd9Sstevel@tonic-gate case ARGP_NAME:
6057c478bd9Sstevel@tonic-gate case ARGP_NAMESTRING:
6067c478bd9Sstevel@tonic-gate
6077c478bd9Sstevel@tonic-gate AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
6087c478bd9Sstevel@tonic-gate Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
60930082d0cSmyers return_VOID;
6107c478bd9Sstevel@tonic-gate
6117c478bd9Sstevel@tonic-gate default:
6127c478bd9Sstevel@tonic-gate
61326f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
61430082d0cSmyers return_VOID;
6157c478bd9Sstevel@tonic-gate }
6167c478bd9Sstevel@tonic-gate
61730082d0cSmyers AcpiPsInitOp (Arg, Opcode);
61830082d0cSmyers ParserState->Aml += Length;
6197c478bd9Sstevel@tonic-gate return_VOID;
6207c478bd9Sstevel@tonic-gate }
6217c478bd9Sstevel@tonic-gate
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gate /*******************************************************************************
6247c478bd9Sstevel@tonic-gate *
6257c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextField
6267c478bd9Sstevel@tonic-gate *
6277c478bd9Sstevel@tonic-gate * PARAMETERS: ParserState - Current parser state object
6287c478bd9Sstevel@tonic-gate *
6297c478bd9Sstevel@tonic-gate * RETURN: A newly allocated FIELD op
6307c478bd9Sstevel@tonic-gate *
6317c478bd9Sstevel@tonic-gate * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
6327c478bd9Sstevel@tonic-gate *
6337c478bd9Sstevel@tonic-gate ******************************************************************************/
6347c478bd9Sstevel@tonic-gate
6357c478bd9Sstevel@tonic-gate static ACPI_PARSE_OBJECT *
AcpiPsGetNextField(ACPI_PARSE_STATE * ParserState)6367c478bd9Sstevel@tonic-gate AcpiPsGetNextField (
6377c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState)
6387c478bd9Sstevel@tonic-gate {
6397b1019a6SJerry Jelinek UINT8 *Aml;
6407c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Field;
6417b1019a6SJerry Jelinek ACPI_PARSE_OBJECT *Arg = NULL;
6427c478bd9Sstevel@tonic-gate UINT16 Opcode;
6437c478bd9Sstevel@tonic-gate UINT32 Name;
6447b1019a6SJerry Jelinek UINT8 AccessType;
6457b1019a6SJerry Jelinek UINT8 AccessAttribute;
6467b1019a6SJerry Jelinek UINT8 AccessLength;
6477b1019a6SJerry Jelinek UINT32 PkgLength;
6487b1019a6SJerry Jelinek UINT8 *PkgEnd;
6497b1019a6SJerry Jelinek UINT32 BufferLength;
6507c478bd9Sstevel@tonic-gate
6517c478bd9Sstevel@tonic-gate
65227f7c583Smyers ACPI_FUNCTION_TRACE (PsGetNextField);
6537c478bd9Sstevel@tonic-gate
6547c478bd9Sstevel@tonic-gate
655*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
6567b1019a6SJerry Jelinek Aml = ParserState->Aml;
6577b1019a6SJerry Jelinek
6587c478bd9Sstevel@tonic-gate /* Determine field type */
6597c478bd9Sstevel@tonic-gate
6607c478bd9Sstevel@tonic-gate switch (ACPI_GET8 (ParserState->Aml))
6617c478bd9Sstevel@tonic-gate {
6627b1019a6SJerry Jelinek case AML_FIELD_OFFSET_OP:
6637c478bd9Sstevel@tonic-gate
6647b1019a6SJerry Jelinek Opcode = AML_INT_RESERVEDFIELD_OP;
6657b1019a6SJerry Jelinek ParserState->Aml++;
6667c478bd9Sstevel@tonic-gate break;
6677c478bd9Sstevel@tonic-gate
6687b1019a6SJerry Jelinek case AML_FIELD_ACCESS_OP:
6697c478bd9Sstevel@tonic-gate
6707b1019a6SJerry Jelinek Opcode = AML_INT_ACCESSFIELD_OP;
6717c478bd9Sstevel@tonic-gate ParserState->Aml++;
6727c478bd9Sstevel@tonic-gate break;
6737c478bd9Sstevel@tonic-gate
6747b1019a6SJerry Jelinek case AML_FIELD_CONNECTION_OP:
6757c478bd9Sstevel@tonic-gate
6767b1019a6SJerry Jelinek Opcode = AML_INT_CONNECTION_OP;
6777c478bd9Sstevel@tonic-gate ParserState->Aml++;
6787c478bd9Sstevel@tonic-gate break;
6797b1019a6SJerry Jelinek
6807b1019a6SJerry Jelinek case AML_FIELD_EXT_ACCESS_OP:
6817b1019a6SJerry Jelinek
6827b1019a6SJerry Jelinek Opcode = AML_INT_EXTACCESSFIELD_OP;
6837b1019a6SJerry Jelinek ParserState->Aml++;
6847b1019a6SJerry Jelinek break;
6857b1019a6SJerry Jelinek
6867b1019a6SJerry Jelinek default:
6877b1019a6SJerry Jelinek
6887b1019a6SJerry Jelinek Opcode = AML_INT_NAMEDFIELD_OP;
6897b1019a6SJerry Jelinek break;
6907c478bd9Sstevel@tonic-gate }
6917c478bd9Sstevel@tonic-gate
6927c478bd9Sstevel@tonic-gate /* Allocate a new field op */
6937c478bd9Sstevel@tonic-gate
6947b1019a6SJerry Jelinek Field = AcpiPsAllocOp (Opcode, Aml);
6957c478bd9Sstevel@tonic-gate if (!Field)
6967c478bd9Sstevel@tonic-gate {
6977c478bd9Sstevel@tonic-gate return_PTR (NULL);
6987c478bd9Sstevel@tonic-gate }
6997c478bd9Sstevel@tonic-gate
7007c478bd9Sstevel@tonic-gate /* Decode the field type */
7017c478bd9Sstevel@tonic-gate
702*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
7037c478bd9Sstevel@tonic-gate switch (Opcode)
7047c478bd9Sstevel@tonic-gate {
7057c478bd9Sstevel@tonic-gate case AML_INT_NAMEDFIELD_OP:
7067c478bd9Sstevel@tonic-gate
7077c478bd9Sstevel@tonic-gate /* Get the 4-character name */
7087c478bd9Sstevel@tonic-gate
7097c478bd9Sstevel@tonic-gate ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
7107c478bd9Sstevel@tonic-gate AcpiPsSetName (Field, Name);
7117c478bd9Sstevel@tonic-gate ParserState->Aml += ACPI_NAME_SIZE;
7127c478bd9Sstevel@tonic-gate
713*35786f68SRobert Mustacchi
714*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
715*35786f68SRobert Mustacchi
716*35786f68SRobert Mustacchi #ifdef ACPI_ASL_COMPILER
717*35786f68SRobert Mustacchi /*
718*35786f68SRobert Mustacchi * Because the package length isn't represented as a parse tree object,
719*35786f68SRobert Mustacchi * take comments surrounding this and add to the previously created
720*35786f68SRobert Mustacchi * parse node.
721*35786f68SRobert Mustacchi */
722*35786f68SRobert Mustacchi if (Field->Common.InlineComment)
723*35786f68SRobert Mustacchi {
724*35786f68SRobert Mustacchi Field->Common.NameComment = Field->Common.InlineComment;
725*35786f68SRobert Mustacchi }
726*35786f68SRobert Mustacchi Field->Common.InlineComment = AcpiGbl_CurrentInlineComment;
727*35786f68SRobert Mustacchi AcpiGbl_CurrentInlineComment = NULL;
728*35786f68SRobert Mustacchi #endif
729*35786f68SRobert Mustacchi
7307c478bd9Sstevel@tonic-gate /* Get the length which is encoded as a package length */
7317c478bd9Sstevel@tonic-gate
7327c478bd9Sstevel@tonic-gate Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
7337c478bd9Sstevel@tonic-gate break;
7347c478bd9Sstevel@tonic-gate
7357c478bd9Sstevel@tonic-gate
7367c478bd9Sstevel@tonic-gate case AML_INT_RESERVEDFIELD_OP:
7377c478bd9Sstevel@tonic-gate
7387c478bd9Sstevel@tonic-gate /* Get the length which is encoded as a package length */
7397c478bd9Sstevel@tonic-gate
7407c478bd9Sstevel@tonic-gate Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
7417c478bd9Sstevel@tonic-gate break;
7427c478bd9Sstevel@tonic-gate
7437c478bd9Sstevel@tonic-gate
7447c478bd9Sstevel@tonic-gate case AML_INT_ACCESSFIELD_OP:
7457b1019a6SJerry Jelinek case AML_INT_EXTACCESSFIELD_OP:
7467c478bd9Sstevel@tonic-gate
7477c478bd9Sstevel@tonic-gate /*
7487c478bd9Sstevel@tonic-gate * Get AccessType and AccessAttrib and merge into the field Op
7497b1019a6SJerry Jelinek * AccessType is first operand, AccessAttribute is second. stuff
7507b1019a6SJerry Jelinek * these bytes into the node integer value for convenience.
7517c478bd9Sstevel@tonic-gate */
7527b1019a6SJerry Jelinek
7537b1019a6SJerry Jelinek /* Get the two bytes (Type/Attribute) */
7547b1019a6SJerry Jelinek
7557b1019a6SJerry Jelinek AccessType = ACPI_GET8 (ParserState->Aml);
7567c478bd9Sstevel@tonic-gate ParserState->Aml++;
7577b1019a6SJerry Jelinek AccessAttribute = ACPI_GET8 (ParserState->Aml);
7587c478bd9Sstevel@tonic-gate ParserState->Aml++;
7597b1019a6SJerry Jelinek
7607b1019a6SJerry Jelinek Field->Common.Value.Integer = (UINT8) AccessType;
7617b1019a6SJerry Jelinek Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
7627b1019a6SJerry Jelinek
7637b1019a6SJerry Jelinek /* This opcode has a third byte, AccessLength */
7647b1019a6SJerry Jelinek
7657b1019a6SJerry Jelinek if (Opcode == AML_INT_EXTACCESSFIELD_OP)
7667b1019a6SJerry Jelinek {
7677b1019a6SJerry Jelinek AccessLength = ACPI_GET8 (ParserState->Aml);
7687b1019a6SJerry Jelinek ParserState->Aml++;
7697b1019a6SJerry Jelinek
7707b1019a6SJerry Jelinek Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
7717b1019a6SJerry Jelinek }
7727c478bd9Sstevel@tonic-gate break;
7737c478bd9Sstevel@tonic-gate
7747b1019a6SJerry Jelinek
7757b1019a6SJerry Jelinek case AML_INT_CONNECTION_OP:
7767b1019a6SJerry Jelinek
7777b1019a6SJerry Jelinek /*
7787b1019a6SJerry Jelinek * Argument for Connection operator can be either a Buffer
7797b1019a6SJerry Jelinek * (resource descriptor), or a NameString.
7807b1019a6SJerry Jelinek */
7817b1019a6SJerry Jelinek Aml = ParserState->Aml;
7827b1019a6SJerry Jelinek if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
7837b1019a6SJerry Jelinek {
7847b1019a6SJerry Jelinek ParserState->Aml++;
7857b1019a6SJerry Jelinek
786*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
7877b1019a6SJerry Jelinek PkgEnd = ParserState->Aml;
7887b1019a6SJerry Jelinek PkgLength = AcpiPsGetNextPackageLength (ParserState);
7897b1019a6SJerry Jelinek PkgEnd += PkgLength;
7907b1019a6SJerry Jelinek
791*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
7927b1019a6SJerry Jelinek if (ParserState->Aml < PkgEnd)
7937b1019a6SJerry Jelinek {
7947b1019a6SJerry Jelinek /* Non-empty list */
7957b1019a6SJerry Jelinek
7967b1019a6SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP, Aml);
7977b1019a6SJerry Jelinek if (!Arg)
7987b1019a6SJerry Jelinek {
7997b1019a6SJerry Jelinek AcpiPsFreeOp (Field);
8007b1019a6SJerry Jelinek return_PTR (NULL);
8017b1019a6SJerry Jelinek }
8027b1019a6SJerry Jelinek
8037b1019a6SJerry Jelinek /* Get the actual buffer length argument */
8047b1019a6SJerry Jelinek
8057b1019a6SJerry Jelinek Opcode = ACPI_GET8 (ParserState->Aml);
8067b1019a6SJerry Jelinek ParserState->Aml++;
8077b1019a6SJerry Jelinek
808*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
8097b1019a6SJerry Jelinek switch (Opcode)
8107b1019a6SJerry Jelinek {
8117b1019a6SJerry Jelinek case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
8127b1019a6SJerry Jelinek
8137b1019a6SJerry Jelinek BufferLength = ACPI_GET8 (ParserState->Aml);
8147b1019a6SJerry Jelinek ParserState->Aml += 1;
8157b1019a6SJerry Jelinek break;
8167b1019a6SJerry Jelinek
8177b1019a6SJerry Jelinek case AML_WORD_OP: /* AML_WORDDATA_ARG */
8187b1019a6SJerry Jelinek
8197b1019a6SJerry Jelinek BufferLength = ACPI_GET16 (ParserState->Aml);
8207b1019a6SJerry Jelinek ParserState->Aml += 2;
8217b1019a6SJerry Jelinek break;
8227b1019a6SJerry Jelinek
8237b1019a6SJerry Jelinek case AML_DWORD_OP: /* AML_DWORDATA_ARG */
8247b1019a6SJerry Jelinek
8257b1019a6SJerry Jelinek BufferLength = ACPI_GET32 (ParserState->Aml);
8267b1019a6SJerry Jelinek ParserState->Aml += 4;
8277b1019a6SJerry Jelinek break;
8287b1019a6SJerry Jelinek
8297b1019a6SJerry Jelinek default:
8307b1019a6SJerry Jelinek
8317b1019a6SJerry Jelinek BufferLength = 0;
8327b1019a6SJerry Jelinek break;
8337b1019a6SJerry Jelinek }
8347b1019a6SJerry Jelinek
8357b1019a6SJerry Jelinek /* Fill in bytelist data */
8367b1019a6SJerry Jelinek
837*35786f68SRobert Mustacchi ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
8387b1019a6SJerry Jelinek Arg->Named.Value.Size = BufferLength;
8397b1019a6SJerry Jelinek Arg->Named.Data = ParserState->Aml;
8407b1019a6SJerry Jelinek }
8417b1019a6SJerry Jelinek
8427b1019a6SJerry Jelinek /* Skip to End of byte data */
8437b1019a6SJerry Jelinek
8447b1019a6SJerry Jelinek ParserState->Aml = PkgEnd;
8457b1019a6SJerry Jelinek }
8467b1019a6SJerry Jelinek else
8477b1019a6SJerry Jelinek {
8487b1019a6SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Aml);
8497b1019a6SJerry Jelinek if (!Arg)
8507b1019a6SJerry Jelinek {
8517b1019a6SJerry Jelinek AcpiPsFreeOp (Field);
8527b1019a6SJerry Jelinek return_PTR (NULL);
8537b1019a6SJerry Jelinek }
8547b1019a6SJerry Jelinek
8557b1019a6SJerry Jelinek /* Get the Namestring argument */
8567b1019a6SJerry Jelinek
8577b1019a6SJerry Jelinek Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
8587b1019a6SJerry Jelinek }
8597b1019a6SJerry Jelinek
8607b1019a6SJerry Jelinek /* Link the buffer/namestring to parent (CONNECTION_OP) */
8617b1019a6SJerry Jelinek
8627b1019a6SJerry Jelinek AcpiPsAppendArg (Field, Arg);
8637b1019a6SJerry Jelinek break;
8647b1019a6SJerry Jelinek
8657b1019a6SJerry Jelinek
8667c478bd9Sstevel@tonic-gate default:
8677c478bd9Sstevel@tonic-gate
8687c478bd9Sstevel@tonic-gate /* Opcode was set in previous switch */
8697c478bd9Sstevel@tonic-gate break;
8707c478bd9Sstevel@tonic-gate }
8717c478bd9Sstevel@tonic-gate
8727c478bd9Sstevel@tonic-gate return_PTR (Field);
8737c478bd9Sstevel@tonic-gate }
8747c478bd9Sstevel@tonic-gate
8757c478bd9Sstevel@tonic-gate
8767c478bd9Sstevel@tonic-gate /*******************************************************************************
8777c478bd9Sstevel@tonic-gate *
8787c478bd9Sstevel@tonic-gate * FUNCTION: AcpiPsGetNextArg
8797c478bd9Sstevel@tonic-gate *
8807c478bd9Sstevel@tonic-gate * PARAMETERS: WalkState - Current state
8817c478bd9Sstevel@tonic-gate * ParserState - Current parser state object
8827c478bd9Sstevel@tonic-gate * ArgType - The argument type (AML_*_ARG)
8837c478bd9Sstevel@tonic-gate * ReturnArg - Where the next arg is returned
8847c478bd9Sstevel@tonic-gate *
8857c478bd9Sstevel@tonic-gate * RETURN: Status, and an op object containing the next argument.
8867c478bd9Sstevel@tonic-gate *
8877c478bd9Sstevel@tonic-gate * DESCRIPTION: Get next argument (including complex list arguments that require
8887c478bd9Sstevel@tonic-gate * pushing the parser stack)
8897c478bd9Sstevel@tonic-gate *
8907c478bd9Sstevel@tonic-gate ******************************************************************************/
8917c478bd9Sstevel@tonic-gate
8927c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiPsGetNextArg(ACPI_WALK_STATE * WalkState,ACPI_PARSE_STATE * ParserState,UINT32 ArgType,ACPI_PARSE_OBJECT ** ReturnArg)8937c478bd9Sstevel@tonic-gate AcpiPsGetNextArg (
8947c478bd9Sstevel@tonic-gate ACPI_WALK_STATE *WalkState,
8957c478bd9Sstevel@tonic-gate ACPI_PARSE_STATE *ParserState,
8967c478bd9Sstevel@tonic-gate UINT32 ArgType,
8977c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT **ReturnArg)
8987c478bd9Sstevel@tonic-gate {
8997c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Arg = NULL;
9007c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Prev = NULL;
9017c478bd9Sstevel@tonic-gate ACPI_PARSE_OBJECT *Field;
9027c478bd9Sstevel@tonic-gate UINT32 Subop;
9037c478bd9Sstevel@tonic-gate ACPI_STATUS Status = AE_OK;
9047c478bd9Sstevel@tonic-gate
9057c478bd9Sstevel@tonic-gate
90627f7c583Smyers ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
9077c478bd9Sstevel@tonic-gate
9087c478bd9Sstevel@tonic-gate
909*35786f68SRobert Mustacchi ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
910*35786f68SRobert Mustacchi "Expected argument type ARGP: %s (%2.2X)\n",
911*35786f68SRobert Mustacchi AcpiUtGetArgumentTypeName (ArgType), ArgType));
912*35786f68SRobert Mustacchi
9137c478bd9Sstevel@tonic-gate switch (ArgType)
9147c478bd9Sstevel@tonic-gate {
9157c478bd9Sstevel@tonic-gate case ARGP_BYTEDATA:
9167c478bd9Sstevel@tonic-gate case ARGP_WORDDATA:
9177c478bd9Sstevel@tonic-gate case ARGP_DWORDDATA:
9187c478bd9Sstevel@tonic-gate case ARGP_CHARLIST:
9197c478bd9Sstevel@tonic-gate case ARGP_NAME:
9207c478bd9Sstevel@tonic-gate case ARGP_NAMESTRING:
9217c478bd9Sstevel@tonic-gate
9227c478bd9Sstevel@tonic-gate /* Constants, strings, and namestrings are all the same size */
9237c478bd9Sstevel@tonic-gate
9247b1019a6SJerry Jelinek Arg = AcpiPsAllocOp (AML_BYTE_OP, ParserState->Aml);
9257c478bd9Sstevel@tonic-gate if (!Arg)
9267c478bd9Sstevel@tonic-gate {
9277c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_NO_MEMORY);
9287c478bd9Sstevel@tonic-gate }
9297b1019a6SJerry Jelinek
9307c478bd9Sstevel@tonic-gate AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
9317c478bd9Sstevel@tonic-gate break;
9327c478bd9Sstevel@tonic-gate
9337c478bd9Sstevel@tonic-gate case ARGP_PKGLENGTH:
9347c478bd9Sstevel@tonic-gate
9357c478bd9Sstevel@tonic-gate /* Package length, nothing returned */
9367c478bd9Sstevel@tonic-gate
9377c478bd9Sstevel@tonic-gate ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
9387c478bd9Sstevel@tonic-gate break;
9397c478bd9Sstevel@tonic-gate
9407c478bd9Sstevel@tonic-gate case ARGP_FIELDLIST:
9417c478bd9Sstevel@tonic-gate
9427c478bd9Sstevel@tonic-gate if (ParserState->Aml < ParserState->PkgEnd)
9437c478bd9Sstevel@tonic-gate {
9447c478bd9Sstevel@tonic-gate /* Non-empty list */
9457c478bd9Sstevel@tonic-gate
9467c478bd9Sstevel@tonic-gate while (ParserState->Aml < ParserState->PkgEnd)
9477c478bd9Sstevel@tonic-gate {
9487c478bd9Sstevel@tonic-gate Field = AcpiPsGetNextField (ParserState);
9497c478bd9Sstevel@tonic-gate if (!Field)
9507c478bd9Sstevel@tonic-gate {
9517c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_NO_MEMORY);
9527c478bd9Sstevel@tonic-gate }
9537c478bd9Sstevel@tonic-gate
9547c478bd9Sstevel@tonic-gate if (Prev)
9557c478bd9Sstevel@tonic-gate {
9567c478bd9Sstevel@tonic-gate Prev->Common.Next = Field;
9577c478bd9Sstevel@tonic-gate }
9587c478bd9Sstevel@tonic-gate else
9597c478bd9Sstevel@tonic-gate {
9607c478bd9Sstevel@tonic-gate Arg = Field;
9617c478bd9Sstevel@tonic-gate }
9627c478bd9Sstevel@tonic-gate Prev = Field;
9637c478bd9Sstevel@tonic-gate }
9647c478bd9Sstevel@tonic-gate
9657c478bd9Sstevel@tonic-gate /* Skip to End of byte data */
9667c478bd9Sstevel@tonic-gate
9677c478bd9Sstevel@tonic-gate ParserState->Aml = ParserState->PkgEnd;
9687c478bd9Sstevel@tonic-gate }
9697c478bd9Sstevel@tonic-gate break;
9707c478bd9Sstevel@tonic-gate
9717c478bd9Sstevel@tonic-gate case ARGP_BYTELIST:
9727c478bd9Sstevel@tonic-gate
9737c478bd9Sstevel@tonic-gate if (ParserState->Aml < ParserState->PkgEnd)
9747c478bd9Sstevel@tonic-gate {
9757c478bd9Sstevel@tonic-gate /* Non-empty list */
9767c478bd9Sstevel@tonic-gate
9777b1019a6SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP,
9787b1019a6SJerry Jelinek ParserState->Aml);
9797c478bd9Sstevel@tonic-gate if (!Arg)
9807c478bd9Sstevel@tonic-gate {
9817c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_NO_MEMORY);
9827c478bd9Sstevel@tonic-gate }
9837c478bd9Sstevel@tonic-gate
9847c478bd9Sstevel@tonic-gate /* Fill in bytelist data */
9857c478bd9Sstevel@tonic-gate
9867c478bd9Sstevel@tonic-gate Arg->Common.Value.Size = (UINT32)
9877c478bd9Sstevel@tonic-gate ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
9887c478bd9Sstevel@tonic-gate Arg->Named.Data = ParserState->Aml;
9897c478bd9Sstevel@tonic-gate
9907c478bd9Sstevel@tonic-gate /* Skip to End of byte data */
9917c478bd9Sstevel@tonic-gate
9927c478bd9Sstevel@tonic-gate ParserState->Aml = ParserState->PkgEnd;
9937c478bd9Sstevel@tonic-gate }
9947c478bd9Sstevel@tonic-gate break;
9957c478bd9Sstevel@tonic-gate
9967c478bd9Sstevel@tonic-gate case ARGP_SIMPLENAME:
9977b1019a6SJerry Jelinek case ARGP_NAME_OR_REF:
9987c478bd9Sstevel@tonic-gate
999*35786f68SRobert Mustacchi ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1000*35786f68SRobert Mustacchi "**** SimpleName/NameOrRef: %s (%2.2X)\n",
1001*35786f68SRobert Mustacchi AcpiUtGetArgumentTypeName (ArgType), ArgType));
1002*35786f68SRobert Mustacchi
10037c478bd9Sstevel@tonic-gate Subop = AcpiPsPeekOpcode (ParserState);
10047c478bd9Sstevel@tonic-gate if (Subop == 0 ||
10057c478bd9Sstevel@tonic-gate AcpiPsIsLeadingChar (Subop) ||
10067b1019a6SJerry Jelinek ACPI_IS_ROOT_PREFIX (Subop) ||
10077b1019a6SJerry Jelinek ACPI_IS_PARENT_PREFIX (Subop))
10087c478bd9Sstevel@tonic-gate {
10097c478bd9Sstevel@tonic-gate /* NullName or NameString */
10107c478bd9Sstevel@tonic-gate
10117b1019a6SJerry Jelinek Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
10127c478bd9Sstevel@tonic-gate if (!Arg)
10137c478bd9Sstevel@tonic-gate {
10147c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_NO_MEMORY);
10157c478bd9Sstevel@tonic-gate }
10167c478bd9Sstevel@tonic-gate
1017*35786f68SRobert Mustacchi Status = AcpiPsGetNextNamepath (WalkState, ParserState,
1018*35786f68SRobert Mustacchi Arg, ACPI_NOT_METHOD_CALL);
1019*35786f68SRobert Mustacchi }
1020*35786f68SRobert Mustacchi else
1021*35786f68SRobert Mustacchi {
1022*35786f68SRobert Mustacchi /* Single complex argument, nothing returned */
1023*35786f68SRobert Mustacchi
1024*35786f68SRobert Mustacchi WalkState->ArgCount = 1;
1025*35786f68SRobert Mustacchi }
1026*35786f68SRobert Mustacchi break;
1027*35786f68SRobert Mustacchi
1028*35786f68SRobert Mustacchi case ARGP_TARGET:
1029*35786f68SRobert Mustacchi case ARGP_SUPERNAME:
1030*35786f68SRobert Mustacchi
1031*35786f68SRobert Mustacchi ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1032*35786f68SRobert Mustacchi "**** Target/Supername: %s (%2.2X)\n",
1033*35786f68SRobert Mustacchi AcpiUtGetArgumentTypeName (ArgType), ArgType));
1034db2bae30SDana Myers
1035*35786f68SRobert Mustacchi Subop = AcpiPsPeekOpcode (ParserState);
1036*35786f68SRobert Mustacchi if (Subop == 0 ||
1037*35786f68SRobert Mustacchi AcpiPsIsLeadingChar (Subop) ||
1038*35786f68SRobert Mustacchi ACPI_IS_ROOT_PREFIX (Subop) ||
1039*35786f68SRobert Mustacchi ACPI_IS_PARENT_PREFIX (Subop))
1040*35786f68SRobert Mustacchi {
1041*35786f68SRobert Mustacchi /* NULL target (zero). Convert to a NULL namepath */
1042*35786f68SRobert Mustacchi
1043*35786f68SRobert Mustacchi Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
1044*35786f68SRobert Mustacchi if (!Arg)
1045db2bae30SDana Myers {
1046*35786f68SRobert Mustacchi return_ACPI_STATUS (AE_NO_MEMORY);
1047db2bae30SDana Myers }
1048*35786f68SRobert Mustacchi
1049*35786f68SRobert Mustacchi Status = AcpiPsGetNextNamepath (WalkState, ParserState,
1050*35786f68SRobert Mustacchi Arg, ACPI_POSSIBLE_METHOD_CALL);
1051*35786f68SRobert Mustacchi
1052*35786f68SRobert Mustacchi if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
1053db2bae30SDana Myers {
1054*35786f68SRobert Mustacchi /* Free method call op and corresponding namestring sub-ob */
1055*35786f68SRobert Mustacchi
1056*35786f68SRobert Mustacchi AcpiPsFreeOp (Arg->Common.Value.Arg);
1057*35786f68SRobert Mustacchi AcpiPsFreeOp (Arg);
1058*35786f68SRobert Mustacchi Arg = NULL;
1059*35786f68SRobert Mustacchi WalkState->ArgCount = 1;
1060db2bae30SDana Myers }
10617c478bd9Sstevel@tonic-gate }
10627c478bd9Sstevel@tonic-gate else
10637c478bd9Sstevel@tonic-gate {
10647c478bd9Sstevel@tonic-gate /* Single complex argument, nothing returned */
10657c478bd9Sstevel@tonic-gate
10667c478bd9Sstevel@tonic-gate WalkState->ArgCount = 1;
10677c478bd9Sstevel@tonic-gate }
10687c478bd9Sstevel@tonic-gate break;
10697c478bd9Sstevel@tonic-gate
10707c478bd9Sstevel@tonic-gate case ARGP_DATAOBJ:
10717c478bd9Sstevel@tonic-gate case ARGP_TERMARG:
10727c478bd9Sstevel@tonic-gate
1073*35786f68SRobert Mustacchi ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1074*35786f68SRobert Mustacchi "**** TermArg/DataObj: %s (%2.2X)\n",
1075*35786f68SRobert Mustacchi AcpiUtGetArgumentTypeName (ArgType), ArgType));
1076*35786f68SRobert Mustacchi
10777c478bd9Sstevel@tonic-gate /* Single complex argument, nothing returned */
10787c478bd9Sstevel@tonic-gate
10797c478bd9Sstevel@tonic-gate WalkState->ArgCount = 1;
10807c478bd9Sstevel@tonic-gate break;
10817c478bd9Sstevel@tonic-gate
10827c478bd9Sstevel@tonic-gate case ARGP_DATAOBJLIST:
10837c478bd9Sstevel@tonic-gate case ARGP_TERMLIST:
10847c478bd9Sstevel@tonic-gate case ARGP_OBJLIST:
10857c478bd9Sstevel@tonic-gate
10867c478bd9Sstevel@tonic-gate if (ParserState->Aml < ParserState->PkgEnd)
10877c478bd9Sstevel@tonic-gate {
10887c478bd9Sstevel@tonic-gate /* Non-empty list of variable arguments, nothing returned */
10897c478bd9Sstevel@tonic-gate
10907c478bd9Sstevel@tonic-gate WalkState->ArgCount = ACPI_VAR_ARGS;
10917c478bd9Sstevel@tonic-gate }
10927c478bd9Sstevel@tonic-gate break;
10937c478bd9Sstevel@tonic-gate
10947c478bd9Sstevel@tonic-gate default:
10957c478bd9Sstevel@tonic-gate
109626f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
10977c478bd9Sstevel@tonic-gate Status = AE_AML_OPERAND_TYPE;
10987c478bd9Sstevel@tonic-gate break;
10997c478bd9Sstevel@tonic-gate }
11007c478bd9Sstevel@tonic-gate
11017c478bd9Sstevel@tonic-gate *ReturnArg = Arg;
11027c478bd9Sstevel@tonic-gate return_ACPI_STATUS (Status);
11037c478bd9Sstevel@tonic-gate }
1104