13446Smrj /******************************************************************************* 23446Smrj * 33446Smrj * Module Name: dmnames - AML disassembler, names, namestrings, pathnames 4*7851SDana.Myers@Sun.COM * $Revision: 1.19 $ 53446Smrj * 63446Smrj ******************************************************************************/ 73446Smrj 83446Smrj /****************************************************************************** 93446Smrj * 103446Smrj * 1. Copyright Notice 113446Smrj * 12*7851SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. 133446Smrj * All rights reserved. 143446Smrj * 153446Smrj * 2. License 163446Smrj * 173446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 183446Smrj * rights. You may have additional license terms from the party that provided 193446Smrj * you this software, covering your right to use that party's intellectual 203446Smrj * property rights. 213446Smrj * 223446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 233446Smrj * copy of the source code appearing in this file ("Covered Code") an 243446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 253446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 263446Smrj * make derivatives, distribute, use and display any portion of the Covered 273446Smrj * Code in any form, with the right to sublicense such rights; and 283446Smrj * 293446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 303446Smrj * license (with the right to sublicense), under only those claims of Intel 313446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 323446Smrj * offer to sell, and import the Covered Code and derivative works thereof 333446Smrj * solely to the minimum extent necessary to exercise the above copyright 343446Smrj * license, and in no event shall the patent license extend to any additions 353446Smrj * to or modifications of the Original Intel Code. No other license or right 363446Smrj * is granted directly or by implication, estoppel or otherwise; 373446Smrj * 383446Smrj * The above copyright and patent license is granted only if the following 393446Smrj * conditions are met: 403446Smrj * 413446Smrj * 3. Conditions 423446Smrj * 433446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 443446Smrj * Redistribution of source code of any substantial portion of the Covered 453446Smrj * Code or modification with rights to further distribute source must include 463446Smrj * the above Copyright Notice, the above License, this list of Conditions, 473446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 483446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 493446Smrj * contain a file documenting the changes Licensee made to create that Covered 503446Smrj * Code and the date of any change. Licensee must include in that file the 513446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 523446Smrj * must include a prominent statement that the modification is derived, 533446Smrj * directly or indirectly, from Original Intel Code. 543446Smrj * 553446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 563446Smrj * Redistribution of source code of any substantial portion of the Covered 573446Smrj * Code or modification without rights to further distribute source must 583446Smrj * include the following Disclaimer and Export Compliance provision in the 593446Smrj * documentation and/or other materials provided with distribution. In 603446Smrj * addition, Licensee may not authorize further sublicense of source of any 613446Smrj * portion of the Covered Code, and must include terms to the effect that the 623446Smrj * license from Licensee to its licensee is limited to the intellectual 633446Smrj * property embodied in the software Licensee provides to its licensee, and 643446Smrj * not to intellectual property embodied in modifications its licensee may 653446Smrj * make. 663446Smrj * 673446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 683446Smrj * substantial portion of the Covered Code or modification must reproduce the 693446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 703446Smrj * provision in the documentation and/or other materials provided with the 713446Smrj * distribution. 723446Smrj * 733446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 743446Smrj * Intel Code. 753446Smrj * 763446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 773446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 783446Smrj * other dealings in products derived from or relating to the Covered Code 793446Smrj * without prior written authorization from Intel. 803446Smrj * 813446Smrj * 4. Disclaimer and Export Compliance 823446Smrj * 833446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 843446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 853446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 863446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 873446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 883446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 893446Smrj * PARTICULAR PURPOSE. 903446Smrj * 913446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 923446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 933446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 943446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 953446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 963446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 973446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 983446Smrj * LIMITED REMEDY. 993446Smrj * 1003446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 1013446Smrj * software or system incorporating such software without first obtaining any 1023446Smrj * required license or other approval from the U. S. Department of Commerce or 1033446Smrj * any other agency or department of the United States Government. In the 1043446Smrj * event Licensee exports any such software from the United States or 1053446Smrj * re-exports any such software from a foreign destination, Licensee shall 1063446Smrj * ensure that the distribution and export/re-export of the software is in 1073446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 1083446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1093446Smrj * any of its subsidiaries will export/re-export any technical data, process, 1103446Smrj * software, or service, directly or indirectly, to any country for which the 1113446Smrj * United States government or any agency thereof requires an export license, 1123446Smrj * other governmental approval, or letter of assurance, without first obtaining 1133446Smrj * such license, approval or letter. 1143446Smrj * 1153446Smrj *****************************************************************************/ 1163446Smrj 1173446Smrj 1183446Smrj #include "acpi.h" 1193446Smrj #include "acparser.h" 1203446Smrj #include "amlcode.h" 1213446Smrj #include "acnamesp.h" 1223446Smrj #include "acdisasm.h" 1233446Smrj 1243446Smrj 1253446Smrj #ifdef ACPI_DISASSEMBLER 1263446Smrj 1273446Smrj #define _COMPONENT ACPI_CA_DEBUGGER 1283446Smrj ACPI_MODULE_NAME ("dmnames") 1293446Smrj 1303446Smrj /* Local prototypes */ 1313446Smrj 1323446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS 1333446Smrj void 1343446Smrj AcpiDmDisplayPath ( 1353446Smrj ACPI_PARSE_OBJECT *Op); 1363446Smrj #endif 1373446Smrj 1383446Smrj 1393446Smrj /******************************************************************************* 1403446Smrj * 1413446Smrj * FUNCTION: AcpiDmDumpName 1423446Smrj * 1433446Smrj * PARAMETERS: Name - 4 character ACPI name 1443446Smrj * 1453446Smrj * RETURN: Final length of name 1463446Smrj * 1473446Smrj * DESCRIPTION: Dump an ACPI name, minus any trailing underscores. 1483446Smrj * 1493446Smrj ******************************************************************************/ 1503446Smrj 1513446Smrj UINT32 1523446Smrj AcpiDmDumpName ( 153*7851SDana.Myers@Sun.COM UINT32 Name) 1543446Smrj { 1553446Smrj UINT32 i; 1563446Smrj UINT32 Length; 1573446Smrj char NewName[4]; 1583446Smrj 1593446Smrj 160*7851SDana.Myers@Sun.COM /* Copy name locally in case the original name is not writeable */ 161*7851SDana.Myers@Sun.COM 162*7851SDana.Myers@Sun.COM *(UINT32 *) NewName = Name; 163*7851SDana.Myers@Sun.COM 1643446Smrj /* Ensure that the name is printable, even if we have to fix it */ 1653446Smrj 166*7851SDana.Myers@Sun.COM AcpiUtRepairName (NewName); 1673446Smrj 1683446Smrj /* Remove all trailing underscores from the name */ 1693446Smrj 1703446Smrj Length = ACPI_NAME_SIZE; 1713446Smrj for (i = (ACPI_NAME_SIZE - 1); i != 0; i--) 1723446Smrj { 1733446Smrj if (NewName[i] == '_') 1743446Smrj { 1753446Smrj Length--; 1763446Smrj } 1773446Smrj else 1783446Smrj { 1793446Smrj break; 1803446Smrj } 1813446Smrj } 1823446Smrj 1833446Smrj /* Dump the name, up to the start of the trailing underscores */ 1843446Smrj 1853446Smrj for (i = 0; i < Length; i++) 1863446Smrj { 1873446Smrj AcpiOsPrintf ("%c", NewName[i]); 1883446Smrj } 1893446Smrj 1903446Smrj return (Length); 1913446Smrj } 1923446Smrj 1933446Smrj 1943446Smrj /******************************************************************************* 1953446Smrj * 1963446Smrj * FUNCTION: AcpiPsDisplayObjectPathname 1973446Smrj * 1983446Smrj * PARAMETERS: WalkState - Current walk state 1993446Smrj * Op - Object whose pathname is to be obtained 2003446Smrj * 2013446Smrj * RETURN: Status 2023446Smrj * 2033446Smrj * DESCRIPTION: Diplay the pathname associated with a named object. Two 2043446Smrj * versions. One searches the parse tree (for parser-only 2053446Smrj * applications suchas AcpiDump), and the other searches the 2063446Smrj * ACPI namespace (the parse tree is probably deleted) 2073446Smrj * 2083446Smrj ******************************************************************************/ 2093446Smrj 2103446Smrj ACPI_STATUS 2113446Smrj AcpiPsDisplayObjectPathname ( 2123446Smrj ACPI_WALK_STATE *WalkState, 2133446Smrj ACPI_PARSE_OBJECT *Op) 2143446Smrj { 2153446Smrj ACPI_STATUS Status; 2163446Smrj ACPI_NAMESPACE_NODE *Node; 2173446Smrj ACPI_BUFFER Buffer; 2183446Smrj UINT32 DebugLevel; 2193446Smrj 2203446Smrj 2213446Smrj /* Save current debug level so we don't get extraneous debug output */ 2223446Smrj 2233446Smrj DebugLevel = AcpiDbgLevel; 2243446Smrj AcpiDbgLevel = 0; 2253446Smrj 2263446Smrj /* Just get the Node out of the Op object */ 2273446Smrj 2283446Smrj Node = Op->Common.Node; 2293446Smrj if (!Node) 2303446Smrj { 2313446Smrj /* Node not defined in this scope, look it up */ 2323446Smrj 2333446Smrj Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, 2343446Smrj ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 2353446Smrj WalkState, &(Node)); 2363446Smrj 2373446Smrj if (ACPI_FAILURE (Status)) 2383446Smrj { 2393446Smrj /* 2403446Smrj * We can't get the pathname since the object 2413446Smrj * is not in the namespace. This can happen during single 2423446Smrj * stepping where a dynamic named object is *about* to be created. 2433446Smrj */ 2443446Smrj AcpiOsPrintf (" [Path not found]"); 2453446Smrj goto Exit; 2463446Smrj } 2473446Smrj 2483446Smrj /* Save it for next time. */ 2493446Smrj 2503446Smrj Op->Common.Node = Node; 2513446Smrj } 2523446Smrj 2533446Smrj /* Convert NamedDesc/handle to a full pathname */ 2543446Smrj 2553446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 2563446Smrj Status = AcpiNsHandleToPathname (Node, &Buffer); 2573446Smrj if (ACPI_FAILURE (Status)) 2583446Smrj { 2593446Smrj AcpiOsPrintf ("****Could not get pathname****)"); 2603446Smrj goto Exit; 2613446Smrj } 2623446Smrj 2633446Smrj AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer); 2643446Smrj ACPI_FREE (Buffer.Pointer); 2653446Smrj 2663446Smrj 2673446Smrj Exit: 2683446Smrj /* Restore the debug level */ 2693446Smrj 2703446Smrj AcpiDbgLevel = DebugLevel; 2713446Smrj return (Status); 2723446Smrj } 2733446Smrj 2743446Smrj 2753446Smrj /******************************************************************************* 2763446Smrj * 2773446Smrj * FUNCTION: AcpiDmNamestring 2783446Smrj * 2793446Smrj * PARAMETERS: Name - ACPI Name string to store 2803446Smrj * 2813446Smrj * RETURN: None 2823446Smrj * 2833446Smrj * DESCRIPTION: Decode and dump an ACPI namestring. Handles prefix characters 2843446Smrj * 2853446Smrj ******************************************************************************/ 2863446Smrj 2873446Smrj void 2883446Smrj AcpiDmNamestring ( 2893446Smrj char *Name) 2903446Smrj { 2913446Smrj UINT32 SegCount; 2923446Smrj 2933446Smrj 2943446Smrj if (!Name) 2953446Smrj { 2963446Smrj return; 2973446Smrj } 2983446Smrj 2993446Smrj /* Handle all Scope Prefix operators */ 3003446Smrj 3013446Smrj while (AcpiPsIsPrefixChar (ACPI_GET8 (Name))) 3023446Smrj { 3033446Smrj /* Append prefix character */ 3043446Smrj 3053446Smrj AcpiOsPrintf ("%1c", ACPI_GET8 (Name)); 3063446Smrj Name++; 3073446Smrj } 3083446Smrj 3093446Smrj switch (ACPI_GET8 (Name)) 3103446Smrj { 3113446Smrj case 0: 3123446Smrj SegCount = 0; 3133446Smrj break; 3143446Smrj 3153446Smrj case AML_DUAL_NAME_PREFIX: 3163446Smrj SegCount = 2; 3173446Smrj Name++; 3183446Smrj break; 3193446Smrj 3203446Smrj case AML_MULTI_NAME_PREFIX_OP: 3213446Smrj SegCount = (UINT32) ACPI_GET8 (Name + 1); 3223446Smrj Name += 2; 3233446Smrj break; 3243446Smrj 3253446Smrj default: 3263446Smrj SegCount = 1; 3273446Smrj break; 3283446Smrj } 3293446Smrj 3303446Smrj while (SegCount) 3313446Smrj { 3323446Smrj /* Append Name segment */ 3333446Smrj 334*7851SDana.Myers@Sun.COM AcpiDmDumpName (*ACPI_CAST_PTR (UINT32, Name)); 3353446Smrj 3363446Smrj SegCount--; 3373446Smrj if (SegCount) 3383446Smrj { 3393446Smrj /* Not last name, append dot separator */ 3403446Smrj 3413446Smrj AcpiOsPrintf ("."); 3423446Smrj } 3433446Smrj Name += ACPI_NAME_SIZE; 3443446Smrj } 3453446Smrj } 3463446Smrj 3473446Smrj 3483446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS 3493446Smrj /******************************************************************************* 3503446Smrj * 3513446Smrj * FUNCTION: AcpiDmDisplayPath 3523446Smrj * 3533446Smrj * PARAMETERS: Op - Named Op whose path is to be constructed 3543446Smrj * 3553446Smrj * RETURN: None 3563446Smrj * 3573446Smrj * DESCRIPTION: Walk backwards from current scope and display the name 3583446Smrj * of each previous level of scope up to the root scope 3593446Smrj * (like "pwd" does with file systems) 3603446Smrj * 3613446Smrj ******************************************************************************/ 3623446Smrj 3633446Smrj void 3643446Smrj AcpiDmDisplayPath ( 3653446Smrj ACPI_PARSE_OBJECT *Op) 3663446Smrj { 3673446Smrj ACPI_PARSE_OBJECT *Prev; 3683446Smrj ACPI_PARSE_OBJECT *Search; 3693446Smrj UINT32 Name; 3703446Smrj BOOLEAN DoDot = FALSE; 3713446Smrj ACPI_PARSE_OBJECT *NamePath; 3723446Smrj const ACPI_OPCODE_INFO *OpInfo; 3733446Smrj 3743446Smrj 3753446Smrj /* We are only interested in named objects */ 3763446Smrj 3773446Smrj OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 3783446Smrj if (!(OpInfo->Flags & AML_NSNODE)) 3793446Smrj { 3803446Smrj return; 3813446Smrj } 3823446Smrj 3833446Smrj if (OpInfo->Flags & AML_CREATE) 3843446Smrj { 3853446Smrj /* Field creation - check for a fully qualified namepath */ 3863446Smrj 3873446Smrj if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 3883446Smrj { 3893446Smrj NamePath = AcpiPsGetArg (Op, 3); 3903446Smrj } 3913446Smrj else 3923446Smrj { 3933446Smrj NamePath = AcpiPsGetArg (Op, 2); 3943446Smrj } 3953446Smrj 3963446Smrj if ((NamePath) && 3973446Smrj (NamePath->Common.Value.String) && 3983446Smrj (NamePath->Common.Value.String[0] == '\\')) 3993446Smrj { 4003446Smrj AcpiDmNamestring (NamePath->Common.Value.String); 4013446Smrj return; 4023446Smrj } 4033446Smrj } 4043446Smrj 4053446Smrj Prev = NULL; /* Start with Root Node */ 4063446Smrj 4073446Smrj while (Prev != Op) 4083446Smrj { 4093446Smrj /* Search upwards in the tree to find scope with "prev" as its parent */ 4103446Smrj 4113446Smrj Search = Op; 4123446Smrj for (; ;) 4133446Smrj { 4143446Smrj if (Search->Common.Parent == Prev) 4153446Smrj { 4163446Smrj break; 4173446Smrj } 4183446Smrj 4193446Smrj /* Go up one level */ 4203446Smrj 4213446Smrj Search = Search->Common.Parent; 4223446Smrj } 4233446Smrj 4243446Smrj if (Prev) 4253446Smrj { 4263446Smrj OpInfo = AcpiPsGetOpcodeInfo (Search->Common.AmlOpcode); 4273446Smrj if (!(OpInfo->Flags & AML_FIELD)) 4283446Smrj { 4293446Smrj /* Below root scope, append scope name */ 4303446Smrj 4313446Smrj if (DoDot) 4323446Smrj { 4333446Smrj /* Append dot */ 4343446Smrj 4353446Smrj AcpiOsPrintf ("."); 4363446Smrj } 4373446Smrj 4383446Smrj if (OpInfo->Flags & AML_CREATE) 4393446Smrj { 4403446Smrj if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 4413446Smrj { 4423446Smrj NamePath = AcpiPsGetArg (Op, 3); 4433446Smrj } 4443446Smrj else 4453446Smrj { 4463446Smrj NamePath = AcpiPsGetArg (Op, 2); 4473446Smrj } 4483446Smrj 4493446Smrj if ((NamePath) && 4503446Smrj (NamePath->Common.Value.String)) 4513446Smrj { 4523446Smrj AcpiDmDumpName (NamePath->Common.Value.String); 4533446Smrj } 4543446Smrj } 4553446Smrj else 4563446Smrj { 4573446Smrj Name = AcpiPsGetName (Search); 4583446Smrj AcpiDmDumpName ((char *) &Name); 4593446Smrj } 4603446Smrj 4613446Smrj DoDot = TRUE; 4623446Smrj } 4633446Smrj } 4643446Smrj Prev = Search; 4653446Smrj } 4663446Smrj } 4673446Smrj 4683446Smrj 4693446Smrj /******************************************************************************* 4703446Smrj * 4713446Smrj * FUNCTION: AcpiDmValidateName 4723446Smrj * 4733446Smrj * PARAMETERS: Name - 4 character ACPI name 4743446Smrj * 4753446Smrj * RETURN: None 4763446Smrj * 4773446Smrj * DESCRIPTION: Lookup the name 4783446Smrj * 4793446Smrj ******************************************************************************/ 4803446Smrj 4813446Smrj void 4823446Smrj AcpiDmValidateName ( 4833446Smrj char *Name, 4843446Smrj ACPI_PARSE_OBJECT *Op) 4853446Smrj { 4863446Smrj 4873446Smrj if ((!Name) || 4883446Smrj (!Op->Common.Parent)) 4893446Smrj { 4903446Smrj return; 4913446Smrj } 4923446Smrj 4933446Smrj if (!Op->Common.Node) 4943446Smrj { 4953446Smrj AcpiOsPrintf ( 4963446Smrj " /**** Name not found or not accessible from this scope ****/ "); 4973446Smrj } 4983446Smrj 4993446Smrj ACPI_PARSE_OBJECT *TargetOp; 5003446Smrj 5013446Smrj 5023446Smrj if ((!Name) || 5033446Smrj (!Op->Common.Parent)) 5043446Smrj { 5053446Smrj return; 5063446Smrj } 5073446Smrj 5083446Smrj TargetOp = AcpiPsFind (Op, Name, 0, 0); 5093446Smrj if (!TargetOp) 5103446Smrj { 5113446Smrj /* 5123446Smrj * Didn't find the name in the parse tree. This may be 5133446Smrj * a problem, or it may simply be one of the predefined names 5143446Smrj * (such as _OS_). Rather than worry about looking up all 5153446Smrj * the predefined names, just display the name as given 5163446Smrj */ 5173446Smrj AcpiOsPrintf ( 5183446Smrj " /**** Name not found or not accessible from this scope ****/ "); 5193446Smrj } 5203446Smrj } 5213446Smrj #endif 5223446Smrj 5233446Smrj #endif 5243446Smrj 5253446Smrj 526