17c478bd9Sstevel@tonic-gate /*******************************************************************************
27c478bd9Sstevel@tonic-gate  *
37c478bd9Sstevel@tonic-gate  * Module Name: nsnames - Name manipulation and search
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 "amlcode.h"
1557c478bd9Sstevel@tonic-gate #include "acnamesp.h"
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #define _COMPONENT          ACPI_NAMESPACE
1597c478bd9Sstevel@tonic-gate         ACPI_MODULE_NAME    ("nsnames")
1607c478bd9Sstevel@tonic-gate 
161*35786f68SRobert Mustacchi /* Local Prototypes */
162*35786f68SRobert Mustacchi 
163*35786f68SRobert Mustacchi static void
164*35786f68SRobert Mustacchi AcpiNsNormalizePathname (
165*35786f68SRobert Mustacchi     char                    *OriginalPath);
166*35786f68SRobert Mustacchi 
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*******************************************************************************
1697c478bd9Sstevel@tonic-gate  *
1707c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiNsGetExternalPathname
1717c478bd9Sstevel@tonic-gate  *
1727c478bd9Sstevel@tonic-gate  * PARAMETERS:  Node            - Namespace node whose pathname is needed
1737c478bd9Sstevel@tonic-gate  *
1747c478bd9Sstevel@tonic-gate  * RETURN:      Pointer to storage containing the fully qualified name of
1757c478bd9Sstevel@tonic-gate  *              the node, In external format (name segments separated by path
1767c478bd9Sstevel@tonic-gate  *              separators.)
1777c478bd9Sstevel@tonic-gate  *
178aa2aa9a6SDana Myers  * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
179aa2aa9a6SDana Myers  *              for error and debug statements.
1807c478bd9Sstevel@tonic-gate  *
1817c478bd9Sstevel@tonic-gate  ******************************************************************************/
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate char *
AcpiNsGetExternalPathname(ACPI_NAMESPACE_NODE * Node)1847c478bd9Sstevel@tonic-gate AcpiNsGetExternalPathname (
1857c478bd9Sstevel@tonic-gate     ACPI_NAMESPACE_NODE     *Node)
1867c478bd9Sstevel@tonic-gate {
1877c478bd9Sstevel@tonic-gate     char                    *NameBuffer;
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 
19027f7c583Smyers     ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 
1937b1019a6SJerry Jelinek     NameBuffer = AcpiNsGetNormalizedPathname (Node, FALSE);
1947c478bd9Sstevel@tonic-gate     return_PTR (NameBuffer);
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*******************************************************************************
1997c478bd9Sstevel@tonic-gate  *
2007c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiNsGetPathnameLength
2017c478bd9Sstevel@tonic-gate  *
2027c478bd9Sstevel@tonic-gate  * PARAMETERS:  Node        - Namespace node
2037c478bd9Sstevel@tonic-gate  *
2047c478bd9Sstevel@tonic-gate  * RETURN:      Length of path, including prefix
2057c478bd9Sstevel@tonic-gate  *
2067c478bd9Sstevel@tonic-gate  * DESCRIPTION: Get the length of the pathname string for this node
2077c478bd9Sstevel@tonic-gate  *
2087c478bd9Sstevel@tonic-gate  ******************************************************************************/
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate ACPI_SIZE
AcpiNsGetPathnameLength(ACPI_NAMESPACE_NODE * Node)2117c478bd9Sstevel@tonic-gate AcpiNsGetPathnameLength (
2127c478bd9Sstevel@tonic-gate     ACPI_NAMESPACE_NODE     *Node)
2137c478bd9Sstevel@tonic-gate {
2147c478bd9Sstevel@tonic-gate     ACPI_SIZE               Size;
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 
217*35786f68SRobert Mustacchi     /* Validate the Node */
2187c478bd9Sstevel@tonic-gate 
219*35786f68SRobert Mustacchi     if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
220*35786f68SRobert Mustacchi     {
221*35786f68SRobert Mustacchi         ACPI_ERROR ((AE_INFO,
222*35786f68SRobert Mustacchi             "Invalid/cached reference target node: %p, descriptor type %d",
223*35786f68SRobert Mustacchi             Node, ACPI_GET_DESCRIPTOR_TYPE (Node)));
224*35786f68SRobert Mustacchi         return (0);
225*35786f68SRobert Mustacchi     }
2267c478bd9Sstevel@tonic-gate 
2277b1019a6SJerry Jelinek     Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, FALSE);
2287b1019a6SJerry Jelinek     return (Size);
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 
232*35786f68SRobert Mustacchi /*******************************************************************************
233*35786f68SRobert Mustacchi  *
234*35786f68SRobert Mustacchi  * FUNCTION:    AcpiNsHandleToName
235*35786f68SRobert Mustacchi  *
236*35786f68SRobert Mustacchi  * PARAMETERS:  TargetHandle            - Handle of named object whose name is
237*35786f68SRobert Mustacchi  *                                        to be found
238*35786f68SRobert Mustacchi  *              Buffer                  - Where the name is returned
239*35786f68SRobert Mustacchi  *
240*35786f68SRobert Mustacchi  * RETURN:      Status, Buffer is filled with name if status is AE_OK
241*35786f68SRobert Mustacchi  *
242*35786f68SRobert Mustacchi  * DESCRIPTION: Build and return a full namespace name
243*35786f68SRobert Mustacchi  *
244*35786f68SRobert Mustacchi  ******************************************************************************/
245*35786f68SRobert Mustacchi 
246*35786f68SRobert Mustacchi ACPI_STATUS
AcpiNsHandleToName(ACPI_HANDLE TargetHandle,ACPI_BUFFER * Buffer)247*35786f68SRobert Mustacchi AcpiNsHandleToName (
248*35786f68SRobert Mustacchi     ACPI_HANDLE             TargetHandle,
249*35786f68SRobert Mustacchi     ACPI_BUFFER             *Buffer)
250*35786f68SRobert Mustacchi {
251*35786f68SRobert Mustacchi     ACPI_STATUS             Status;
252*35786f68SRobert Mustacchi     ACPI_NAMESPACE_NODE     *Node;
253*35786f68SRobert Mustacchi     const char              *NodeName;
254*35786f68SRobert Mustacchi 
255*35786f68SRobert Mustacchi 
256*35786f68SRobert Mustacchi     ACPI_FUNCTION_TRACE_PTR (NsHandleToName, TargetHandle);
257*35786f68SRobert Mustacchi 
258*35786f68SRobert Mustacchi 
259*35786f68SRobert Mustacchi     Node = AcpiNsValidateHandle (TargetHandle);
260*35786f68SRobert Mustacchi     if (!Node)
261*35786f68SRobert Mustacchi     {
262*35786f68SRobert Mustacchi         return_ACPI_STATUS (AE_BAD_PARAMETER);
263*35786f68SRobert Mustacchi     }
264*35786f68SRobert Mustacchi 
265*35786f68SRobert Mustacchi     /* Validate/Allocate/Clear caller buffer */
266*35786f68SRobert Mustacchi 
267*35786f68SRobert Mustacchi     Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH);
268*35786f68SRobert Mustacchi     if (ACPI_FAILURE (Status))
269*35786f68SRobert Mustacchi     {
270*35786f68SRobert Mustacchi         return_ACPI_STATUS (Status);
271*35786f68SRobert Mustacchi     }
272*35786f68SRobert Mustacchi 
273*35786f68SRobert Mustacchi     /* Just copy the ACPI name from the Node and zero terminate it */
274*35786f68SRobert Mustacchi 
275*35786f68SRobert Mustacchi     NodeName = AcpiUtGetNodeName (Node);
276*35786f68SRobert Mustacchi     ACPI_MOVE_NAME (Buffer->Pointer, NodeName);
277*35786f68SRobert Mustacchi     ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
278*35786f68SRobert Mustacchi 
279*35786f68SRobert Mustacchi     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%4.4s\n", (char *) Buffer->Pointer));
280*35786f68SRobert Mustacchi     return_ACPI_STATUS (AE_OK);
281*35786f68SRobert Mustacchi }
282*35786f68SRobert Mustacchi 
283*35786f68SRobert Mustacchi 
2847c478bd9Sstevel@tonic-gate /*******************************************************************************
2857c478bd9Sstevel@tonic-gate  *
2867c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiNsHandleToPathname
2877c478bd9Sstevel@tonic-gate  *
2887c478bd9Sstevel@tonic-gate  * PARAMETERS:  TargetHandle            - Handle of named object whose name is
2897c478bd9Sstevel@tonic-gate  *                                        to be found
2907c478bd9Sstevel@tonic-gate  *              Buffer                  - Where the pathname is returned
2917b1019a6SJerry Jelinek  *              NoTrailing              - Remove trailing '_' for each name
2927b1019a6SJerry Jelinek  *                                        segment
2937c478bd9Sstevel@tonic-gate  *
2947c478bd9Sstevel@tonic-gate  * RETURN:      Status, Buffer is filled with pathname if status is AE_OK
2957c478bd9Sstevel@tonic-gate  *
2967c478bd9Sstevel@tonic-gate  * DESCRIPTION: Build and return a full namespace pathname
2977c478bd9Sstevel@tonic-gate  *
2987c478bd9Sstevel@tonic-gate  ******************************************************************************/
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiNsHandleToPathname(ACPI_HANDLE TargetHandle,ACPI_BUFFER * Buffer,BOOLEAN NoTrailing)3017c478bd9Sstevel@tonic-gate AcpiNsHandleToPathname (
3027c478bd9Sstevel@tonic-gate     ACPI_HANDLE             TargetHandle,
3037b1019a6SJerry Jelinek     ACPI_BUFFER             *Buffer,
3047b1019a6SJerry Jelinek     BOOLEAN                 NoTrailing)
3057c478bd9Sstevel@tonic-gate {
3067c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status;
3077c478bd9Sstevel@tonic-gate     ACPI_NAMESPACE_NODE     *Node;
3087c478bd9Sstevel@tonic-gate     ACPI_SIZE               RequiredSize;
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 
31127f7c583Smyers     ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle);
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 
31426f3cdf0SGordon Ross     Node = AcpiNsValidateHandle (TargetHandle);
3157c478bd9Sstevel@tonic-gate     if (!Node)
3167c478bd9Sstevel@tonic-gate     {
3177c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (AE_BAD_PARAMETER);
3187c478bd9Sstevel@tonic-gate     }
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate     /* Determine size required for the caller buffer */
3217c478bd9Sstevel@tonic-gate 
3227b1019a6SJerry Jelinek     RequiredSize = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing);
323db2bae30SDana Myers     if (!RequiredSize)
324db2bae30SDana Myers     {
325db2bae30SDana Myers         return_ACPI_STATUS (AE_BAD_PARAMETER);
326db2bae30SDana Myers     }
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate     /* Validate/Allocate/Clear caller buffer */
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate     Status = AcpiUtInitializeBuffer (Buffer, RequiredSize);
3317c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
3327c478bd9Sstevel@tonic-gate     {
3337c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
3347c478bd9Sstevel@tonic-gate     }
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate     /* Build the path in the caller buffer */
3377c478bd9Sstevel@tonic-gate 
3387b1019a6SJerry Jelinek     (void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer,
3397b1019a6SJerry Jelinek         RequiredSize, NoTrailing);
3407c478bd9Sstevel@tonic-gate 
341186507a7Smyers     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n",
3427c478bd9Sstevel@tonic-gate         (char *) Buffer->Pointer, (UINT32) RequiredSize));
3437c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (AE_OK);
3447c478bd9Sstevel@tonic-gate }
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 
3477b1019a6SJerry Jelinek /*******************************************************************************
3487b1019a6SJerry Jelinek  *
3497b1019a6SJerry Jelinek  * FUNCTION:    AcpiNsBuildNormalizedPath
3507b1019a6SJerry Jelinek  *
3517b1019a6SJerry Jelinek  * PARAMETERS:  Node        - Namespace node
3527b1019a6SJerry Jelinek  *              FullPath    - Where the path name is returned
3537b1019a6SJerry Jelinek  *              PathSize    - Size of returned path name buffer
3547b1019a6SJerry Jelinek  *              NoTrailing  - Remove trailing '_' from each name segment
3557b1019a6SJerry Jelinek  *
3567b1019a6SJerry Jelinek  * RETURN:      Return 1 if the AML path is empty, otherwise returning (length
3577b1019a6SJerry Jelinek  *              of pathname + 1) which means the 'FullPath' contains a trailing
3587b1019a6SJerry Jelinek  *              null.
3597b1019a6SJerry Jelinek  *
3607b1019a6SJerry Jelinek  * DESCRIPTION: Build and return a full namespace pathname.
3617b1019a6SJerry Jelinek  *              Note that if the size of 'FullPath' isn't large enough to
3627b1019a6SJerry Jelinek  *              contain the namespace node's path name, the actual required
3637b1019a6SJerry Jelinek  *              buffer length is returned, and it should be greater than
3647b1019a6SJerry Jelinek  *              'PathSize'. So callers are able to check the returning value
3657b1019a6SJerry Jelinek  *              to determine the buffer size of 'FullPath'.
3667b1019a6SJerry Jelinek  *
3677b1019a6SJerry Jelinek  ******************************************************************************/
3687b1019a6SJerry Jelinek 
3697b1019a6SJerry Jelinek UINT32
AcpiNsBuildNormalizedPath(ACPI_NAMESPACE_NODE * Node,char * FullPath,UINT32 PathSize,BOOLEAN NoTrailing)3707b1019a6SJerry Jelinek AcpiNsBuildNormalizedPath (
3717b1019a6SJerry Jelinek     ACPI_NAMESPACE_NODE     *Node,
3727b1019a6SJerry Jelinek     char                    *FullPath,
3737b1019a6SJerry Jelinek     UINT32                  PathSize,
3747b1019a6SJerry Jelinek     BOOLEAN                 NoTrailing)
3757b1019a6SJerry Jelinek {
3767b1019a6SJerry Jelinek     UINT32                  Length = 0, i;
3777b1019a6SJerry Jelinek     char                    Name[ACPI_NAME_SIZE];
3787b1019a6SJerry Jelinek     BOOLEAN                 DoNoTrailing;
3797b1019a6SJerry Jelinek     char                    c, *Left, *Right;
3807b1019a6SJerry Jelinek     ACPI_NAMESPACE_NODE     *NextNode;
3817b1019a6SJerry Jelinek 
3827b1019a6SJerry Jelinek 
3837b1019a6SJerry Jelinek     ACPI_FUNCTION_TRACE_PTR (NsBuildNormalizedPath, Node);
3847b1019a6SJerry Jelinek 
3857b1019a6SJerry Jelinek 
3867b1019a6SJerry Jelinek #define ACPI_PATH_PUT8(Path, Size, Byte, Length)    \
3877b1019a6SJerry Jelinek     do {                                            \
3887b1019a6SJerry Jelinek         if ((Length) < (Size))                      \
3897b1019a6SJerry Jelinek         {                                           \
3907b1019a6SJerry Jelinek             (Path)[(Length)] = (Byte);              \
3917b1019a6SJerry Jelinek         }                                           \
3927b1019a6SJerry Jelinek         (Length)++;                                 \
3937b1019a6SJerry Jelinek     } while (0)
3947b1019a6SJerry Jelinek 
3957b1019a6SJerry Jelinek     /*
3967b1019a6SJerry Jelinek      * Make sure the PathSize is correct, so that we don't need to
3977b1019a6SJerry Jelinek      * validate both FullPath and PathSize.
3987b1019a6SJerry Jelinek      */
3997b1019a6SJerry Jelinek     if (!FullPath)
4007b1019a6SJerry Jelinek     {
4017b1019a6SJerry Jelinek         PathSize = 0;
4027b1019a6SJerry Jelinek     }
4037b1019a6SJerry Jelinek 
4047b1019a6SJerry Jelinek     if (!Node)
4057b1019a6SJerry Jelinek     {
4067b1019a6SJerry Jelinek         goto BuildTrailingNull;
4077b1019a6SJerry Jelinek     }
4087b1019a6SJerry Jelinek 
4097b1019a6SJerry Jelinek     NextNode = Node;
4107b1019a6SJerry Jelinek     while (NextNode && NextNode != AcpiGbl_RootNode)
4117b1019a6SJerry Jelinek     {
4127b1019a6SJerry Jelinek         if (NextNode != Node)
4137b1019a6SJerry Jelinek         {
4147b1019a6SJerry Jelinek             ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
4157b1019a6SJerry Jelinek         }
4167b1019a6SJerry Jelinek 
4177b1019a6SJerry Jelinek         ACPI_MOVE_32_TO_32 (Name, &NextNode->Name);
4187b1019a6SJerry Jelinek         DoNoTrailing = NoTrailing;
4197b1019a6SJerry Jelinek         for (i = 0; i < 4; i++)
4207b1019a6SJerry Jelinek         {
4217b1019a6SJerry Jelinek             c = Name[4-i-1];
4227b1019a6SJerry Jelinek             if (DoNoTrailing && c != '_')
4237b1019a6SJerry Jelinek             {
4247b1019a6SJerry Jelinek                 DoNoTrailing = FALSE;
4257b1019a6SJerry Jelinek             }
4267b1019a6SJerry Jelinek             if (!DoNoTrailing)
4277b1019a6SJerry Jelinek             {
4287b1019a6SJerry Jelinek                 ACPI_PATH_PUT8(FullPath, PathSize, c, Length);
4297b1019a6SJerry Jelinek             }
4307b1019a6SJerry Jelinek         }
4317b1019a6SJerry Jelinek 
4327b1019a6SJerry Jelinek         NextNode = NextNode->Parent;
4337b1019a6SJerry Jelinek     }
4347b1019a6SJerry Jelinek 
4357b1019a6SJerry Jelinek     ACPI_PATH_PUT8(FullPath, PathSize, AML_ROOT_PREFIX, Length);
4367b1019a6SJerry Jelinek 
4377b1019a6SJerry Jelinek     /* Reverse the path string */
4387b1019a6SJerry Jelinek 
4397b1019a6SJerry Jelinek     if (Length <= PathSize)
4407b1019a6SJerry Jelinek     {
4417b1019a6SJerry Jelinek         Left = FullPath;
4427b1019a6SJerry Jelinek         Right = FullPath+Length - 1;
4437b1019a6SJerry Jelinek 
4447b1019a6SJerry Jelinek         while (Left < Right)
4457b1019a6SJerry Jelinek         {
4467b1019a6SJerry Jelinek             c = *Left;
4477b1019a6SJerry Jelinek             *Left++ = *Right;
4487b1019a6SJerry Jelinek             *Right-- = c;
4497b1019a6SJerry Jelinek         }
4507b1019a6SJerry Jelinek     }
4517b1019a6SJerry Jelinek 
4527b1019a6SJerry Jelinek     /* Append the trailing null */
4537b1019a6SJerry Jelinek 
4547b1019a6SJerry Jelinek BuildTrailingNull:
4557b1019a6SJerry Jelinek     ACPI_PATH_PUT8 (FullPath, PathSize, '\0', Length);
4567b1019a6SJerry Jelinek 
4577b1019a6SJerry Jelinek #undef ACPI_PATH_PUT8
4587b1019a6SJerry Jelinek 
4597b1019a6SJerry Jelinek     return_UINT32 (Length);
4607b1019a6SJerry Jelinek }
4617b1019a6SJerry Jelinek 
4627b1019a6SJerry Jelinek 
4637b1019a6SJerry Jelinek /*******************************************************************************
4647b1019a6SJerry Jelinek  *
4657b1019a6SJerry Jelinek  * FUNCTION:    AcpiNsGetNormalizedPathname
4667b1019a6SJerry Jelinek  *
4677b1019a6SJerry Jelinek  * PARAMETERS:  Node            - Namespace node whose pathname is needed
4687b1019a6SJerry Jelinek  *              NoTrailing      - Remove trailing '_' from each name segment
4697b1019a6SJerry Jelinek  *
4707b1019a6SJerry Jelinek  * RETURN:      Pointer to storage containing the fully qualified name of
4717b1019a6SJerry Jelinek  *              the node, In external format (name segments separated by path
4727b1019a6SJerry Jelinek  *              separators.)
4737b1019a6SJerry Jelinek  *
4747b1019a6SJerry Jelinek  * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
4757b1019a6SJerry Jelinek  *              for error and debug statements. All trailing '_' will be
4767b1019a6SJerry Jelinek  *              removed from the full pathname if 'NoTrailing' is specified..
4777b1019a6SJerry Jelinek  *
4787b1019a6SJerry Jelinek  ******************************************************************************/
4797b1019a6SJerry Jelinek 
4807b1019a6SJerry Jelinek char *
AcpiNsGetNormalizedPathname(ACPI_NAMESPACE_NODE * Node,BOOLEAN NoTrailing)4817b1019a6SJerry Jelinek AcpiNsGetNormalizedPathname (
4827b1019a6SJerry Jelinek     ACPI_NAMESPACE_NODE     *Node,
4837b1019a6SJerry Jelinek     BOOLEAN                 NoTrailing)
4847b1019a6SJerry Jelinek {
4857b1019a6SJerry Jelinek     char                    *NameBuffer;
4867b1019a6SJerry Jelinek     ACPI_SIZE               Size;
4877b1019a6SJerry Jelinek 
4887b1019a6SJerry Jelinek 
4897b1019a6SJerry Jelinek     ACPI_FUNCTION_TRACE_PTR (NsGetNormalizedPathname, Node);
4907b1019a6SJerry Jelinek 
4917b1019a6SJerry Jelinek 
4927b1019a6SJerry Jelinek     /* Calculate required buffer size based on depth below root */
4937b1019a6SJerry Jelinek 
4947b1019a6SJerry Jelinek     Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing);
4957b1019a6SJerry Jelinek     if (!Size)
4967b1019a6SJerry Jelinek     {
4977b1019a6SJerry Jelinek         return_PTR (NULL);
4987b1019a6SJerry Jelinek     }
4997b1019a6SJerry Jelinek 
5007b1019a6SJerry Jelinek     /* Allocate a buffer to be returned to caller */
5017b1019a6SJerry Jelinek 
5027b1019a6SJerry Jelinek     NameBuffer = ACPI_ALLOCATE_ZEROED (Size);
5037b1019a6SJerry Jelinek     if (!NameBuffer)
5047b1019a6SJerry Jelinek     {
5057b1019a6SJerry Jelinek         ACPI_ERROR ((AE_INFO,
5067b1019a6SJerry Jelinek             "Could not allocate %u bytes", (UINT32) Size));
5077b1019a6SJerry Jelinek         return_PTR (NULL);
5087b1019a6SJerry Jelinek     }
5097b1019a6SJerry Jelinek 
5107b1019a6SJerry Jelinek     /* Build the path in the allocated buffer */
5117b1019a6SJerry Jelinek 
5127b1019a6SJerry Jelinek     (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing);
5137b1019a6SJerry Jelinek 
514*35786f68SRobert Mustacchi     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%s: Path \"%s\"\n",
515*35786f68SRobert Mustacchi         ACPI_GET_FUNCTION_NAME, NameBuffer));
516*35786f68SRobert Mustacchi 
5177b1019a6SJerry Jelinek     return_PTR (NameBuffer);
5187b1019a6SJerry Jelinek }
519*35786f68SRobert Mustacchi 
520*35786f68SRobert Mustacchi 
521*35786f68SRobert Mustacchi /*******************************************************************************
522*35786f68SRobert Mustacchi  *
523*35786f68SRobert Mustacchi  * FUNCTION:    AcpiNsBuildPrefixedPathname
524*35786f68SRobert Mustacchi  *
525*35786f68SRobert Mustacchi  * PARAMETERS:  PrefixScope         - Scope/Path that prefixes the internal path
526*35786f68SRobert Mustacchi  *              InternalPath        - Name or path of the namespace node
527*35786f68SRobert Mustacchi  *
528*35786f68SRobert Mustacchi  * RETURN:      None
529*35786f68SRobert Mustacchi  *
530*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a fully qualified pathname from a concatenation of:
531*35786f68SRobert Mustacchi  *              1) Path associated with the PrefixScope namespace node
532*35786f68SRobert Mustacchi  *              2) External path representation of the Internal path
533*35786f68SRobert Mustacchi  *
534*35786f68SRobert Mustacchi  ******************************************************************************/
535*35786f68SRobert Mustacchi 
536*35786f68SRobert Mustacchi char *
AcpiNsBuildPrefixedPathname(ACPI_GENERIC_STATE * PrefixScope,const char * InternalPath)537*35786f68SRobert Mustacchi AcpiNsBuildPrefixedPathname (
538*35786f68SRobert Mustacchi     ACPI_GENERIC_STATE      *PrefixScope,
539*35786f68SRobert Mustacchi     const char              *InternalPath)
540*35786f68SRobert Mustacchi {
541*35786f68SRobert Mustacchi     ACPI_STATUS             Status;
542*35786f68SRobert Mustacchi     char                    *FullPath = NULL;
543*35786f68SRobert Mustacchi     char                    *ExternalPath = NULL;
544*35786f68SRobert Mustacchi     char                    *PrefixPath = NULL;
545*35786f68SRobert Mustacchi     UINT32                  PrefixPathLength = 0;
546*35786f68SRobert Mustacchi 
547*35786f68SRobert Mustacchi 
548*35786f68SRobert Mustacchi     /* If there is a prefix, get the pathname to it */
549*35786f68SRobert Mustacchi 
550*35786f68SRobert Mustacchi     if (PrefixScope && PrefixScope->Scope.Node)
551*35786f68SRobert Mustacchi     {
552*35786f68SRobert Mustacchi         PrefixPath = AcpiNsGetNormalizedPathname (PrefixScope->Scope.Node, TRUE);
553*35786f68SRobert Mustacchi         if (PrefixPath)
554*35786f68SRobert Mustacchi         {
555*35786f68SRobert Mustacchi             PrefixPathLength = strlen (PrefixPath);
556*35786f68SRobert Mustacchi         }
557*35786f68SRobert Mustacchi     }
558*35786f68SRobert Mustacchi 
559*35786f68SRobert Mustacchi     Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath,
560*35786f68SRobert Mustacchi         NULL, &ExternalPath);
561*35786f68SRobert Mustacchi     if (ACPI_FAILURE (Status))
562*35786f68SRobert Mustacchi     {
563*35786f68SRobert Mustacchi         goto Cleanup;
564*35786f68SRobert Mustacchi     }
565*35786f68SRobert Mustacchi 
566*35786f68SRobert Mustacchi     /* Merge the prefix path and the path. 2 is for one dot and trailing null */
567*35786f68SRobert Mustacchi 
568*35786f68SRobert Mustacchi     FullPath = ACPI_ALLOCATE_ZEROED (
569*35786f68SRobert Mustacchi         PrefixPathLength + strlen (ExternalPath) + 2);
570*35786f68SRobert Mustacchi     if (!FullPath)
571*35786f68SRobert Mustacchi     {
572*35786f68SRobert Mustacchi         goto Cleanup;
573*35786f68SRobert Mustacchi     }
574*35786f68SRobert Mustacchi 
575*35786f68SRobert Mustacchi     /* Don't merge if the External path is already fully qualified */
576*35786f68SRobert Mustacchi 
577*35786f68SRobert Mustacchi     if (PrefixPath &&
578*35786f68SRobert Mustacchi         (*ExternalPath != '\\') &&
579*35786f68SRobert Mustacchi         (*ExternalPath != '^'))
580*35786f68SRobert Mustacchi     {
581*35786f68SRobert Mustacchi         strcat (FullPath, PrefixPath);
582*35786f68SRobert Mustacchi         if (PrefixPath[1])
583*35786f68SRobert Mustacchi         {
584*35786f68SRobert Mustacchi             strcat (FullPath, ".");
585*35786f68SRobert Mustacchi         }
586*35786f68SRobert Mustacchi     }
587*35786f68SRobert Mustacchi 
588*35786f68SRobert Mustacchi     AcpiNsNormalizePathname (ExternalPath);
589*35786f68SRobert Mustacchi     strcat (FullPath, ExternalPath);
590*35786f68SRobert Mustacchi 
591*35786f68SRobert Mustacchi Cleanup:
592*35786f68SRobert Mustacchi     if (PrefixPath)
593*35786f68SRobert Mustacchi     {
594*35786f68SRobert Mustacchi         ACPI_FREE (PrefixPath);
595*35786f68SRobert Mustacchi     }
596*35786f68SRobert Mustacchi     if (ExternalPath)
597*35786f68SRobert Mustacchi     {
598*35786f68SRobert Mustacchi         ACPI_FREE (ExternalPath);
599*35786f68SRobert Mustacchi     }
600*35786f68SRobert Mustacchi 
601*35786f68SRobert Mustacchi     return (FullPath);
602*35786f68SRobert Mustacchi }
603*35786f68SRobert Mustacchi 
604*35786f68SRobert Mustacchi 
605*35786f68SRobert Mustacchi /*******************************************************************************
606*35786f68SRobert Mustacchi  *
607*35786f68SRobert Mustacchi  * FUNCTION:    AcpiNsNormalizePathname
608*35786f68SRobert Mustacchi  *
609*35786f68SRobert Mustacchi  * PARAMETERS:  OriginalPath        - Path to be normalized, in External format
610*35786f68SRobert Mustacchi  *
611*35786f68SRobert Mustacchi  * RETURN:      The original path is processed in-place
612*35786f68SRobert Mustacchi  *
613*35786f68SRobert Mustacchi  * DESCRIPTION: Remove trailing underscores from each element of a path.
614*35786f68SRobert Mustacchi  *
615*35786f68SRobert Mustacchi  *              For example:  \A___.B___.C___ becomes \A.B.C
616*35786f68SRobert Mustacchi  *
617*35786f68SRobert Mustacchi  ******************************************************************************/
618*35786f68SRobert Mustacchi 
619*35786f68SRobert Mustacchi static void
AcpiNsNormalizePathname(char * OriginalPath)620*35786f68SRobert Mustacchi AcpiNsNormalizePathname (
621*35786f68SRobert Mustacchi     char                    *OriginalPath)
622*35786f68SRobert Mustacchi {
623*35786f68SRobert Mustacchi     char                    *InputPath = OriginalPath;
624*35786f68SRobert Mustacchi     char                    *NewPathBuffer;
625*35786f68SRobert Mustacchi     char                    *NewPath;
626*35786f68SRobert Mustacchi     UINT32                  i;
627*35786f68SRobert Mustacchi 
628*35786f68SRobert Mustacchi 
629*35786f68SRobert Mustacchi     /* Allocate a temp buffer in which to construct the new path */
630*35786f68SRobert Mustacchi 
631*35786f68SRobert Mustacchi     NewPathBuffer = ACPI_ALLOCATE_ZEROED (strlen (InputPath) + 1);
632*35786f68SRobert Mustacchi     NewPath = NewPathBuffer;
633*35786f68SRobert Mustacchi     if (!NewPathBuffer)
634*35786f68SRobert Mustacchi     {
635*35786f68SRobert Mustacchi         return;
636*35786f68SRobert Mustacchi     }
637*35786f68SRobert Mustacchi 
638*35786f68SRobert Mustacchi     /* Special characters may appear at the beginning of the path */
639*35786f68SRobert Mustacchi 
640*35786f68SRobert Mustacchi     if (*InputPath == '\\')
641*35786f68SRobert Mustacchi     {
642*35786f68SRobert Mustacchi         *NewPath = *InputPath;
643*35786f68SRobert Mustacchi         NewPath++;
644*35786f68SRobert Mustacchi         InputPath++;
645*35786f68SRobert Mustacchi     }
646*35786f68SRobert Mustacchi 
647*35786f68SRobert Mustacchi     while (*InputPath == '^')
648*35786f68SRobert Mustacchi     {
649*35786f68SRobert Mustacchi         *NewPath = *InputPath;
650*35786f68SRobert Mustacchi         NewPath++;
651*35786f68SRobert Mustacchi         InputPath++;
652*35786f68SRobert Mustacchi     }
653*35786f68SRobert Mustacchi 
654*35786f68SRobert Mustacchi     /* Remainder of the path */
655*35786f68SRobert Mustacchi 
656*35786f68SRobert Mustacchi     while (*InputPath)
657*35786f68SRobert Mustacchi     {
658*35786f68SRobert Mustacchi         /* Do one nameseg at a time */
659*35786f68SRobert Mustacchi 
660*35786f68SRobert Mustacchi         for (i = 0; (i < ACPI_NAME_SIZE) && *InputPath; i++)
661*35786f68SRobert Mustacchi         {
662*35786f68SRobert Mustacchi             if ((i == 0) || (*InputPath != '_')) /* First char is allowed to be underscore */
663*35786f68SRobert Mustacchi             {
664*35786f68SRobert Mustacchi                 *NewPath = *InputPath;
665*35786f68SRobert Mustacchi                 NewPath++;
666*35786f68SRobert Mustacchi             }
667*35786f68SRobert Mustacchi 
668*35786f68SRobert Mustacchi             InputPath++;
669*35786f68SRobert Mustacchi         }
670*35786f68SRobert Mustacchi 
671*35786f68SRobert Mustacchi         /* Dot means that there are more namesegs to come */
672*35786f68SRobert Mustacchi 
673*35786f68SRobert Mustacchi         if (*InputPath == '.')
674*35786f68SRobert Mustacchi         {
675*35786f68SRobert Mustacchi             *NewPath = *InputPath;
676*35786f68SRobert Mustacchi             NewPath++;
677*35786f68SRobert Mustacchi             InputPath++;
678*35786f68SRobert Mustacchi         }
679*35786f68SRobert Mustacchi     }
680*35786f68SRobert Mustacchi 
681*35786f68SRobert Mustacchi     *NewPath = 0;
682*35786f68SRobert Mustacchi     strcpy (OriginalPath, NewPathBuffer);
683*35786f68SRobert Mustacchi     ACPI_FREE (NewPathBuffer);
684*35786f68SRobert Mustacchi }
685