1 /******************************************************************************
3 * Module Name: aslnamesp - Namespace output file generation
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include "aslcompiler.h"
46 #include "aslcompiler.y.h"
50 #define _COMPONENT ACPI_COMPILER
51 ACPI_MODULE_NAME ("aslnamesp")
53 /* Local prototypes */
56 NsDoOneNamespaceObject (
57 ACPI_HANDLE ObjHandle
,
64 ACPI_HANDLE ObjHandle
,
70 /*******************************************************************************
72 * FUNCTION: NsSetupNamespaceListing
74 * PARAMETERS: Handle - local file handle
78 * DESCRIPTION: Set the namespace output file to the input handle
80 ******************************************************************************/
83 NsSetupNamespaceListing (
87 Gbl_NsOutputFlag
= TRUE
;
88 Gbl_Files
[ASL_FILE_NAMESPACE_OUTPUT
].Handle
= Handle
;
92 /*******************************************************************************
94 * FUNCTION: NsDisplayNamespace
100 * DESCRIPTION: Walk the namespace an display information about each node
101 * in the tree. Information is written to the optional
102 * namespace output file.
104 ******************************************************************************/
113 if (!Gbl_NsOutputFlag
)
118 Gbl_NumNamespaceObjects
= 0;
122 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "Contents of ACPI Namespace\n\n");
123 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "Count Depth Name - Type\n\n");
125 /* Walk entire namespace from the root */
127 Status
= AcpiNsWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
128 ACPI_UINT32_MAX
, FALSE
, NsDoOneNamespaceObject
, NULL
,
131 /* Print the full pathname for each namespace node */
133 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "\nNamespace pathnames\n\n");
135 Status
= AcpiNsWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
136 ACPI_UINT32_MAX
, FALSE
, NsDoOnePathname
, NULL
,
143 /*******************************************************************************
145 * FUNCTION: NsDoOneNamespaceObject
147 * PARAMETERS: ACPI_WALK_CALLBACK
151 * DESCRIPTION: Dump a namespace object to the namespace output file.
152 * Called during the walk of the namespace to dump all objects.
154 ******************************************************************************/
157 NsDoOneNamespaceObject (
158 ACPI_HANDLE ObjHandle
,
163 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
164 ACPI_OPERAND_OBJECT
*ObjDesc
;
165 ACPI_PARSE_OBJECT
*Op
;
168 Gbl_NumNamespaceObjects
++;
170 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "%5u [%u] %*s %4.4s - %s",
171 Gbl_NumNamespaceObjects
, Level
, (Level
* 3), " ",
173 AcpiUtGetTypeName (Node
->Type
));
176 ObjDesc
= ACPI_CAST_PTR (ACPI_OPERAND_OBJECT
, Node
->Object
);
180 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "\n");
186 (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc
) == ACPI_DESC_TYPE_OPERAND
))
190 case ACPI_TYPE_INTEGER
:
192 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
193 " [Initial Value 0x%8.8X%8.8X]",
194 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
197 case ACPI_TYPE_STRING
:
199 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
200 " [Initial Value \"%s\"]",
201 ObjDesc
->String
.Pointer
);
206 /* Nothing to do for other types */
216 case ACPI_TYPE_INTEGER
:
218 if (Op
->Asl
.ParseOpcode
== PARSEOP_NAME
)
222 if ((Op
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
) ||
223 (Op
->Asl
.ParseOpcode
== PARSEOP_NAMESTRING
))
227 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
228 " [Initial Value 0x%8.8X%8.8X]",
229 ACPI_FORMAT_UINT64 (Op
->Asl
.Value
.Integer
));
232 case ACPI_TYPE_STRING
:
234 if (Op
->Asl
.ParseOpcode
== PARSEOP_NAME
)
238 if ((Op
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
) ||
239 (Op
->Asl
.ParseOpcode
== PARSEOP_NAMESTRING
))
243 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
244 " [Initial Value \"%s\"]",
245 Op
->Asl
.Value
.String
);
248 case ACPI_TYPE_LOCAL_REGION_FIELD
:
250 if ((Op
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
) ||
251 (Op
->Asl
.ParseOpcode
== PARSEOP_NAMESTRING
))
255 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
256 " [Offset 0x%04X Length 0x%04X bits]",
257 Op
->Asl
.Parent
->Asl
.ExtraValue
, (UINT32
) Op
->Asl
.Value
.Integer
);
260 case ACPI_TYPE_BUFFER_FIELD
:
262 switch (Op
->Asl
.ParseOpcode
)
264 case PARSEOP_CREATEBYTEFIELD
:
266 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [BYTE ( 8 bit)]");
269 case PARSEOP_CREATEDWORDFIELD
:
271 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [DWORD (32 bit)]");
274 case PARSEOP_CREATEQWORDFIELD
:
276 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [QWORD (64 bit)]");
279 case PARSEOP_CREATEWORDFIELD
:
281 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [WORD (16 bit)]");
284 case PARSEOP_CREATEBITFIELD
:
286 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [BIT ( 1 bit)]");
289 case PARSEOP_CREATEFIELD
:
291 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, " [Arbitrary Bit Field]");
301 case ACPI_TYPE_PACKAGE
:
303 if (Op
->Asl
.ParseOpcode
== PARSEOP_NAME
)
307 if ((Op
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
) ||
308 (Op
->Asl
.ParseOpcode
== PARSEOP_NAMESTRING
))
314 if ((Op
->Asl
.ParseOpcode
== PARSEOP_BYTECONST
) ||
315 (Op
->Asl
.ParseOpcode
== PARSEOP_RAW_DATA
))
317 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
318 " [Initial Length 0x%.2X elements]",
319 Op
->Asl
.Value
.Integer
);
323 case ACPI_TYPE_BUFFER
:
325 if (Op
->Asl
.ParseOpcode
== PARSEOP_NAME
)
329 if ((Op
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
) ||
330 (Op
->Asl
.ParseOpcode
== PARSEOP_NAMESTRING
))
336 if (Op
&& (Op
->Asl
.ParseOpcode
== PARSEOP_INTEGER
))
338 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
339 " [Initial Length 0x%.2X bytes]",
340 Op
->Asl
.Value
.Integer
);
344 case ACPI_TYPE_METHOD
:
346 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
347 " [Code Length 0x%.4X bytes]",
348 Op
->Asl
.AmlSubtreeLength
);
351 case ACPI_TYPE_LOCAL_RESOURCE
:
353 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
354 " [Desc Offset 0x%.4X Bytes]", Node
->Value
);
357 case ACPI_TYPE_LOCAL_RESOURCE_FIELD
:
359 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
360 " [Field Offset 0x%.4X Bits 0x%.4X Bytes] ",
361 Node
->Value
, Node
->Value
/ 8);
363 if (Node
->Flags
& ANOBJ_IS_REFERENCED
)
365 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
370 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
,
371 "Name not referenced");
377 /* Nothing to do for other types */
383 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "\n");
388 /*******************************************************************************
390 * FUNCTION: NsDoOnePathname
392 * PARAMETERS: ACPI_WALK_CALLBACK
396 * DESCRIPTION: Print the full pathname for a namespace node.
398 ******************************************************************************/
402 ACPI_HANDLE ObjHandle
,
407 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
409 ACPI_BUFFER TargetPath
;
412 TargetPath
.Length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
413 Status
= AcpiNsHandleToPathname (Node
, &TargetPath
);
414 if (ACPI_FAILURE (Status
))
419 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT
, "%s\n", TargetPath
.Pointer
);
420 ACPI_FREE (TargetPath
.Pointer
);