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