Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:03

0001 /******************************************************************************
0002  *
0003  * Module Name: nsconvert - Object conversions for objects returned by
0004  *                          predefined methods
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights. You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code. No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision. In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change. Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee. Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution. In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government. In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************
0116  *
0117  * Alternatively, you may choose to be licensed under the terms of the
0118  * following license:
0119  *
0120  * Redistribution and use in source and binary forms, with or without
0121  * modification, are permitted provided that the following conditions
0122  * are met:
0123  * 1. Redistributions of source code must retain the above copyright
0124  *    notice, this list of conditions, and the following disclaimer,
0125  *    without modification.
0126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0127  *    substantially similar to the "NO WARRANTY" disclaimer below
0128  *    ("Disclaimer") and any redistribution must be conditioned upon
0129  *    including a substantially similar Disclaimer requirement for further
0130  *    binary redistribution.
0131  * 3. Neither the names of the above-listed copyright holders nor the names
0132  *    of any contributors may be used to endorse or promote products derived
0133  *    from this software without specific prior written permission.
0134  *
0135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0146  *
0147  * Alternatively, you may choose to be licensed under the terms of the
0148  * GNU General Public License ("GPL") version 2 as published by the Free
0149  * Software Foundation.
0150  *
0151  *****************************************************************************/
0152 
0153 #include "acpi.h"
0154 #include "accommon.h"
0155 #include "acnamesp.h"
0156 #include "acinterp.h"
0157 #include "acpredef.h"
0158 #include "amlresrc.h"
0159 
0160 #define _COMPONENT          ACPI_NAMESPACE
0161         ACPI_MODULE_NAME    ("nsconvert")
0162 
0163 
0164 /*******************************************************************************
0165  *
0166  * FUNCTION:    AcpiNsConvertToInteger
0167  *
0168  * PARAMETERS:  OriginalObject      - Object to be converted
0169  *              ReturnObject        - Where the new converted object is returned
0170  *
0171  * RETURN:      Status. AE_OK if conversion was successful.
0172  *
0173  * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
0174  *
0175  ******************************************************************************/
0176 
0177 ACPI_STATUS
0178 AcpiNsConvertToInteger (
0179     ACPI_OPERAND_OBJECT     *OriginalObject,
0180     ACPI_OPERAND_OBJECT     **ReturnObject)
0181 {
0182     ACPI_OPERAND_OBJECT     *NewObject;
0183     ACPI_STATUS             Status;
0184     UINT64                  Value = 0;
0185     UINT32                  i;
0186 
0187 
0188     switch (OriginalObject->Common.Type)
0189     {
0190     case ACPI_TYPE_STRING:
0191 
0192         /* String-to-Integer conversion */
0193 
0194         Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, &Value);
0195         if (ACPI_FAILURE (Status))
0196         {
0197             return (Status);
0198         }
0199         break;
0200 
0201     case ACPI_TYPE_BUFFER:
0202 
0203         /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
0204 
0205         if (OriginalObject->Buffer.Length > 8)
0206         {
0207             return (AE_AML_OPERAND_TYPE);
0208         }
0209 
0210         /* Extract each buffer byte to create the integer */
0211 
0212         for (i = 0; i < OriginalObject->Buffer.Length; i++)
0213         {
0214             Value |= ((UINT64)
0215                 OriginalObject->Buffer.Pointer[i] << (i * 8));
0216         }
0217         break;
0218 
0219     default:
0220 
0221         return (AE_AML_OPERAND_TYPE);
0222     }
0223 
0224     NewObject = AcpiUtCreateIntegerObject (Value);
0225     if (!NewObject)
0226     {
0227         return (AE_NO_MEMORY);
0228     }
0229 
0230     *ReturnObject = NewObject;
0231     return (AE_OK);
0232 }
0233 
0234 
0235 /*******************************************************************************
0236  *
0237  * FUNCTION:    AcpiNsConvertToString
0238  *
0239  * PARAMETERS:  OriginalObject      - Object to be converted
0240  *              ReturnObject        - Where the new converted object is returned
0241  *
0242  * RETURN:      Status. AE_OK if conversion was successful.
0243  *
0244  * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
0245  *
0246  ******************************************************************************/
0247 
0248 ACPI_STATUS
0249 AcpiNsConvertToString (
0250     ACPI_OPERAND_OBJECT     *OriginalObject,
0251     ACPI_OPERAND_OBJECT     **ReturnObject)
0252 {
0253     ACPI_OPERAND_OBJECT     *NewObject;
0254     ACPI_SIZE               Length;
0255     ACPI_STATUS             Status;
0256 
0257 
0258     switch (OriginalObject->Common.Type)
0259     {
0260     case ACPI_TYPE_INTEGER:
0261         /*
0262          * Integer-to-String conversion. Commonly, convert
0263          * an integer of value 0 to a NULL string. The last element of
0264          * _BIF and _BIX packages occasionally need this fix.
0265          */
0266         if (OriginalObject->Integer.Value == 0)
0267         {
0268             /* Allocate a new NULL string object */
0269 
0270             NewObject = AcpiUtCreateStringObject (0);
0271             if (!NewObject)
0272             {
0273                 return (AE_NO_MEMORY);
0274             }
0275         }
0276         else
0277         {
0278             Status = AcpiExConvertToString (OriginalObject,
0279                 &NewObject, ACPI_IMPLICIT_CONVERT_HEX);
0280             if (ACPI_FAILURE (Status))
0281             {
0282                 return (Status);
0283             }
0284         }
0285         break;
0286 
0287     case ACPI_TYPE_BUFFER:
0288         /*
0289          * Buffer-to-String conversion. Use a ToString
0290          * conversion, no transform performed on the buffer data. The best
0291          * example of this is the _BIF method, where the string data from
0292          * the battery is often (incorrectly) returned as buffer object(s).
0293          */
0294         Length = 0;
0295         while ((Length < OriginalObject->Buffer.Length) &&
0296                 (OriginalObject->Buffer.Pointer[Length]))
0297         {
0298             Length++;
0299         }
0300 
0301         /* Allocate a new string object */
0302 
0303         NewObject = AcpiUtCreateStringObject (Length);
0304         if (!NewObject)
0305         {
0306             return (AE_NO_MEMORY);
0307         }
0308 
0309         /*
0310          * Copy the raw buffer data with no transform. String is already NULL
0311          * terminated at Length+1.
0312          */
0313         memcpy (NewObject->String.Pointer,
0314             OriginalObject->Buffer.Pointer, Length);
0315         break;
0316 
0317     default:
0318 
0319         return (AE_AML_OPERAND_TYPE);
0320     }
0321 
0322     *ReturnObject = NewObject;
0323     return (AE_OK);
0324 }
0325 
0326 
0327 /*******************************************************************************
0328  *
0329  * FUNCTION:    AcpiNsConvertToBuffer
0330  *
0331  * PARAMETERS:  OriginalObject      - Object to be converted
0332  *              ReturnObject        - Where the new converted object is returned
0333  *
0334  * RETURN:      Status. AE_OK if conversion was successful.
0335  *
0336  * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
0337  *
0338  ******************************************************************************/
0339 
0340 ACPI_STATUS
0341 AcpiNsConvertToBuffer (
0342     ACPI_OPERAND_OBJECT     *OriginalObject,
0343     ACPI_OPERAND_OBJECT     **ReturnObject)
0344 {
0345     ACPI_OPERAND_OBJECT     *NewObject;
0346     ACPI_STATUS             Status;
0347     ACPI_OPERAND_OBJECT     **Elements;
0348     UINT32                  *DwordBuffer;
0349     UINT32                  Count;
0350     UINT32                  i;
0351 
0352 
0353     switch (OriginalObject->Common.Type)
0354     {
0355     case ACPI_TYPE_INTEGER:
0356         /*
0357          * Integer-to-Buffer conversion.
0358          * Convert the Integer to a packed-byte buffer. _MAT and other
0359          * objects need this sometimes, if a read has been performed on a
0360          * Field object that is less than or equal to the global integer
0361          * size (32 or 64 bits).
0362          */
0363         Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
0364         if (ACPI_FAILURE (Status))
0365         {
0366             return (Status);
0367         }
0368         break;
0369 
0370     case ACPI_TYPE_STRING:
0371 
0372         /* String-to-Buffer conversion. Simple data copy */
0373 
0374         NewObject = AcpiUtCreateBufferObject
0375             (OriginalObject->String.Length);
0376         if (!NewObject)
0377         {
0378             return (AE_NO_MEMORY);
0379         }
0380 
0381         memcpy (NewObject->Buffer.Pointer,
0382             OriginalObject->String.Pointer, OriginalObject->String.Length);
0383         break;
0384 
0385     case ACPI_TYPE_PACKAGE:
0386         /*
0387          * This case is often seen for predefined names that must return a
0388          * Buffer object with multiple DWORD integers within. For example,
0389          * _FDE and _GTM. The Package can be converted to a Buffer.
0390          */
0391 
0392         /* All elements of the Package must be integers */
0393 
0394         Elements = OriginalObject->Package.Elements;
0395         Count = OriginalObject->Package.Count;
0396 
0397         for (i = 0; i < Count; i++)
0398         {
0399             if ((!*Elements) ||
0400                 ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
0401             {
0402                 return (AE_AML_OPERAND_TYPE);
0403             }
0404             Elements++;
0405         }
0406 
0407         /* Create the new buffer object to replace the Package */
0408 
0409         NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
0410         if (!NewObject)
0411         {
0412             return (AE_NO_MEMORY);
0413         }
0414 
0415         /* Copy the package elements (integers) to the buffer as DWORDs */
0416 
0417         Elements = OriginalObject->Package.Elements;
0418         DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
0419 
0420         for (i = 0; i < Count; i++)
0421         {
0422             *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
0423             DwordBuffer++;
0424             Elements++;
0425         }
0426         break;
0427 
0428     default:
0429 
0430         return (AE_AML_OPERAND_TYPE);
0431     }
0432 
0433     *ReturnObject = NewObject;
0434     return (AE_OK);
0435 }
0436 
0437 
0438 /*******************************************************************************
0439  *
0440  * FUNCTION:    AcpiNsConvertToUnicode
0441  *
0442  * PARAMETERS:  Scope               - Namespace node for the method/object
0443  *              OriginalObject      - ASCII String Object to be converted
0444  *              ReturnObject        - Where the new converted object is returned
0445  *
0446  * RETURN:      Status. AE_OK if conversion was successful.
0447  *
0448  * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer.
0449  *
0450  ******************************************************************************/
0451 
0452 ACPI_STATUS
0453 AcpiNsConvertToUnicode (
0454     ACPI_NAMESPACE_NODE     *Scope,
0455     ACPI_OPERAND_OBJECT     *OriginalObject,
0456     ACPI_OPERAND_OBJECT     **ReturnObject)
0457 {
0458     ACPI_OPERAND_OBJECT     *NewObject;
0459     char                    *AsciiString;
0460     UINT16                  *UnicodeBuffer;
0461     UINT32                  UnicodeLength;
0462     UINT32                  i;
0463 
0464 
0465     if (!OriginalObject)
0466     {
0467         return (AE_OK);
0468     }
0469 
0470     /* If a Buffer was returned, it must be at least two bytes long */
0471 
0472     if (OriginalObject->Common.Type == ACPI_TYPE_BUFFER)
0473     {
0474         if (OriginalObject->Buffer.Length < 2)
0475         {
0476             return (AE_AML_OPERAND_VALUE);
0477         }
0478 
0479         *ReturnObject = NULL;
0480         return (AE_OK);
0481     }
0482 
0483     /*
0484      * The original object is an ASCII string. Convert this string to
0485      * a unicode buffer.
0486      */
0487     AsciiString = OriginalObject->String.Pointer;
0488     UnicodeLength = (OriginalObject->String.Length * 2) + 2;
0489 
0490     /* Create a new buffer object for the Unicode data */
0491 
0492     NewObject = AcpiUtCreateBufferObject (UnicodeLength);
0493     if (!NewObject)
0494     {
0495         return (AE_NO_MEMORY);
0496     }
0497 
0498     UnicodeBuffer = ACPI_CAST_PTR (UINT16, NewObject->Buffer.Pointer);
0499 
0500     /* Convert ASCII to Unicode */
0501 
0502     for (i = 0; i < OriginalObject->String.Length; i++)
0503     {
0504         UnicodeBuffer[i] = (UINT16) AsciiString[i];
0505     }
0506 
0507     *ReturnObject = NewObject;
0508     return (AE_OK);
0509 }
0510 
0511 
0512 /*******************************************************************************
0513  *
0514  * FUNCTION:    AcpiNsConvertToResource
0515  *
0516  * PARAMETERS:  Scope               - Namespace node for the method/object
0517  *              OriginalObject      - Object to be converted
0518  *              ReturnObject        - Where the new converted object is returned
0519  *
0520  * RETURN:      Status. AE_OK if conversion was successful
0521  *
0522  * DESCRIPTION: Attempt to convert a Integer object to a ResourceTemplate
0523  *              Buffer.
0524  *
0525  ******************************************************************************/
0526 
0527 ACPI_STATUS
0528 AcpiNsConvertToResource (
0529     ACPI_NAMESPACE_NODE     *Scope,
0530     ACPI_OPERAND_OBJECT     *OriginalObject,
0531     ACPI_OPERAND_OBJECT     **ReturnObject)
0532 {
0533     ACPI_OPERAND_OBJECT     *NewObject;
0534     UINT8                   *Buffer;
0535 
0536 
0537     /*
0538      * We can fix the following cases for an expected resource template:
0539      * 1. No return value (interpreter slack mode is disabled)
0540      * 2. A "Return (Zero)" statement
0541      * 3. A "Return empty buffer" statement
0542      *
0543      * We will return a buffer containing a single EndTag
0544      * resource descriptor.
0545      */
0546     if (OriginalObject)
0547     {
0548         switch (OriginalObject->Common.Type)
0549         {
0550         case ACPI_TYPE_INTEGER:
0551 
0552             /* We can only repair an Integer==0 */
0553 
0554             if (OriginalObject->Integer.Value)
0555             {
0556                 return (AE_AML_OPERAND_TYPE);
0557             }
0558             break;
0559 
0560         case ACPI_TYPE_BUFFER:
0561 
0562             if (OriginalObject->Buffer.Length)
0563             {
0564                 /* Additional checks can be added in the future */
0565 
0566                 *ReturnObject = NULL;
0567                 return (AE_OK);
0568             }
0569             break;
0570 
0571         case ACPI_TYPE_STRING:
0572         default:
0573 
0574             return (AE_AML_OPERAND_TYPE);
0575         }
0576     }
0577 
0578     /* Create the new buffer object for the resource descriptor */
0579 
0580     NewObject = AcpiUtCreateBufferObject (2);
0581     if (!NewObject)
0582     {
0583         return (AE_NO_MEMORY);
0584     }
0585 
0586     Buffer = ACPI_CAST_PTR (UINT8, NewObject->Buffer.Pointer);
0587 
0588     /* Initialize the Buffer with a single EndTag descriptor */
0589 
0590     Buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE);
0591     Buffer[1] = 0x00;
0592 
0593     *ReturnObject = NewObject;
0594     return (AE_OK);
0595 }
0596 
0597 
0598 /*******************************************************************************
0599  *
0600  * FUNCTION:    AcpiNsConvertToReference
0601  *
0602  * PARAMETERS:  Scope               - Namespace node for the method/object
0603  *              OriginalObject      - Object to be converted
0604  *              ReturnObject        - Where the new converted object is returned
0605  *
0606  * RETURN:      Status. AE_OK if conversion was successful
0607  *
0608  * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference.
0609  *              Buffer.
0610  *
0611  ******************************************************************************/
0612 
0613 ACPI_STATUS
0614 AcpiNsConvertToReference (
0615     ACPI_NAMESPACE_NODE     *Scope,
0616     ACPI_OPERAND_OBJECT     *OriginalObject,
0617     ACPI_OPERAND_OBJECT     **ReturnObject)
0618 {
0619     ACPI_OPERAND_OBJECT     *NewObject = NULL;
0620     ACPI_STATUS             Status;
0621     ACPI_NAMESPACE_NODE     *Node;
0622     ACPI_GENERIC_STATE      ScopeInfo;
0623     char                    *Name;
0624 
0625 
0626     ACPI_FUNCTION_NAME (NsConvertToReference);
0627 
0628 
0629     /* Convert path into internal presentation */
0630 
0631     Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name);
0632     if (ACPI_FAILURE (Status))
0633     {
0634         return_ACPI_STATUS (Status);
0635     }
0636 
0637     /* Find the namespace node */
0638 
0639     ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope);
0640     Status = AcpiNsLookup (&ScopeInfo, Name,
0641         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
0642         ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
0643     if (ACPI_FAILURE (Status))
0644     {
0645         /* Check if we are resolving a named reference within a package */
0646 
0647         ACPI_ERROR_NAMESPACE (&ScopeInfo,
0648             OriginalObject->String.Pointer, Status);
0649         goto ErrorExit;
0650     }
0651 
0652     /* Create and init a new internal ACPI object */
0653 
0654     NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
0655     if (!NewObject)
0656     {
0657         Status = AE_NO_MEMORY;
0658         goto ErrorExit;
0659     }
0660     NewObject->Reference.Node = Node;
0661     NewObject->Reference.Object = Node->Object;
0662     NewObject->Reference.Class = ACPI_REFCLASS_NAME;
0663 
0664     /*
0665      * Increase reference of the object if needed (the object is likely a
0666      * null for device nodes).
0667      */
0668     AcpiUtAddReference (Node->Object);
0669 
0670 ErrorExit:
0671     ACPI_FREE (Name);
0672     *ReturnObject = NewObject;
0673     return (Status);
0674 }