1 /*******************************************************************************
3 * Module Name: dmnames - AML disassembler, names, namestrings, pathnames
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, 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.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/amlcode.h>
47 #include <contrib/dev/acpica/include/acnamesp.h>
48 #include <contrib/dev/acpica/include/acdisasm.h>
51 #ifdef ACPI_DISASSEMBLER
53 #define _COMPONENT ACPI_CA_DEBUGGER
54 ACPI_MODULE_NAME ("dmnames")
56 /* Local prototypes */
58 #ifdef ACPI_OBSOLETE_FUNCTIONS
61 ACPI_PARSE_OBJECT *Op);
65 /*******************************************************************************
67 * FUNCTION: AcpiDmDumpName
69 * PARAMETERS: Name - 4 character ACPI name
71 * RETURN: Final length of name
73 * DESCRIPTION: Dump an ACPI name, minus any trailing underscores.
75 ******************************************************************************/
86 /* Copy name locally in case the original name is not writeable */
88 *ACPI_CAST_PTR (UINT32, &NewName[0]) = Name;
90 /* Ensure that the name is printable, even if we have to fix it */
92 AcpiUtRepairName (NewName);
94 /* Remove all trailing underscores from the name */
96 Length = ACPI_NAME_SIZE;
97 for (i = (ACPI_NAME_SIZE - 1); i != 0; i--)
99 if (NewName[i] == '_')
109 /* Dump the name, up to the start of the trailing underscores */
111 for (i = 0; i < Length; i++)
113 AcpiOsPrintf ("%c", NewName[i]);
120 /*******************************************************************************
122 * FUNCTION: AcpiPsDisplayObjectPathname
124 * PARAMETERS: WalkState - Current walk state
125 * Op - Object whose pathname is to be obtained
129 * DESCRIPTION: Diplay the pathname associated with a named object. Two
130 * versions. One searches the parse tree (for parser-only
131 * applications suchas AcpiDump), and the other searches the
132 * ACPI namespace (the parse tree is probably deleted)
134 ******************************************************************************/
137 AcpiPsDisplayObjectPathname (
138 ACPI_WALK_STATE *WalkState,
139 ACPI_PARSE_OBJECT *Op)
142 ACPI_NAMESPACE_NODE *Node;
147 /* Save current debug level so we don't get extraneous debug output */
149 DebugLevel = AcpiDbgLevel;
152 /* Just get the Node out of the Op object */
154 Node = Op->Common.Node;
157 /* Node not defined in this scope, look it up */
159 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String,
160 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
163 if (ACPI_FAILURE (Status))
166 * We can't get the pathname since the object
167 * is not in the namespace. This can happen during single
168 * stepping where a dynamic named object is *about* to be created.
170 AcpiOsPrintf (" [Path not found]");
174 /* Save it for next time. */
176 Op->Common.Node = Node;
179 /* Convert NamedDesc/handle to a full pathname */
181 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
182 Status = AcpiNsHandleToPathname (Node, &Buffer);
183 if (ACPI_FAILURE (Status))
185 AcpiOsPrintf ("****Could not get pathname****)");
189 AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer);
190 ACPI_FREE (Buffer.Pointer);
194 /* Restore the debug level */
196 AcpiDbgLevel = DebugLevel;
201 /*******************************************************************************
203 * FUNCTION: AcpiDmNamestring
205 * PARAMETERS: Name - ACPI Name string to store
209 * DESCRIPTION: Decode and dump an ACPI namestring. Handles prefix characters
211 ******************************************************************************/
225 /* Handle all Scope Prefix operators */
227 while (ACPI_IS_ROOT_PREFIX (ACPI_GET8 (Name)) ||
228 ACPI_IS_PARENT_PREFIX (ACPI_GET8 (Name)))
230 /* Append prefix character */
232 AcpiOsPrintf ("%1c", ACPI_GET8 (Name));
236 switch (ACPI_GET8 (Name))
243 case AML_DUAL_NAME_PREFIX:
249 case AML_MULTI_NAME_PREFIX_OP:
251 SegCount = (UINT32) ACPI_GET8 (Name + 1);
263 /* Append Name segment */
265 AcpiDmDumpName (*ACPI_CAST_PTR (UINT32, Name));
270 /* Not last name, append dot separator */
274 Name += ACPI_NAME_SIZE;
279 #ifdef ACPI_OBSOLETE_FUNCTIONS
280 /*******************************************************************************
282 * FUNCTION: AcpiDmDisplayPath
284 * PARAMETERS: Op - Named Op whose path is to be constructed
288 * DESCRIPTION: Walk backwards from current scope and display the name
289 * of each previous level of scope up to the root scope
290 * (like "pwd" does with file systems)
292 ******************************************************************************/
296 ACPI_PARSE_OBJECT *Op)
298 ACPI_PARSE_OBJECT *Prev;
299 ACPI_PARSE_OBJECT *Search;
301 BOOLEAN DoDot = FALSE;
302 ACPI_PARSE_OBJECT *NamePath;
303 const ACPI_OPCODE_INFO *OpInfo;
306 /* We are only interested in named objects */
308 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
309 if (!(OpInfo->Flags & AML_NSNODE))
314 if (OpInfo->Flags & AML_CREATE)
316 /* Field creation - check for a fully qualified namepath */
318 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
320 NamePath = AcpiPsGetArg (Op, 3);
324 NamePath = AcpiPsGetArg (Op, 2);
328 (NamePath->Common.Value.String) &&
329 (ACPI_IS_ROOT_PREFIX (NamePath->Common.Value.String[0])))
331 AcpiDmNamestring (NamePath->Common.Value.String);
336 Prev = NULL; /* Start with Root Node */
340 /* Search upwards in the tree to find scope with "prev" as its parent */
345 if (Search->Common.Parent == Prev)
350 /* Go up one level */
352 Search = Search->Common.Parent;
357 OpInfo = AcpiPsGetOpcodeInfo (Search->Common.AmlOpcode);
358 if (!(OpInfo->Flags & AML_FIELD))
360 /* Below root scope, append scope name */
369 if (OpInfo->Flags & AML_CREATE)
371 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
373 NamePath = AcpiPsGetArg (Op, 3);
377 NamePath = AcpiPsGetArg (Op, 2);
381 (NamePath->Common.Value.String))
383 AcpiDmDumpName (NamePath->Common.Value.String);
388 Name = AcpiPsGetName (Search);
389 AcpiDmDumpName ((char *) &Name);
400 /*******************************************************************************
402 * FUNCTION: AcpiDmValidateName
404 * PARAMETERS: Name - 4 character ACPI name
408 * DESCRIPTION: Lookup the name
410 ******************************************************************************/
415 ACPI_PARSE_OBJECT *Op)
419 (!Op->Common.Parent))
424 if (!Op->Common.Node)
427 " /**** Name not found or not accessible from this scope ****/ ");
430 ACPI_PARSE_OBJECT *TargetOp;
434 (!Op->Common.Parent))
439 TargetOp = AcpiPsFind (Op, Name, 0, 0);
443 * Didn't find the name in the parse tree. This may be
444 * a problem, or it may simply be one of the predefined names
445 * (such as _OS_). Rather than worry about looking up all
446 * the predefined names, just display the name as given
449 " /**** Name not found or not accessible from this scope ****/ ");