Path: blob/main/sys/contrib/dev/acpica/components/debugger/dbnames.c
48406 views
/*******************************************************************************1*2* Module Name: dbnames - Debugger commands for the acpi namespace3*4******************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acnamesp.h>154#include <contrib/dev/acpica/include/acdebug.h>155#include <contrib/dev/acpica/include/acpredef.h>156#include <contrib/dev/acpica/include/acinterp.h>157158159#define _COMPONENT ACPI_CA_DEBUGGER160ACPI_MODULE_NAME ("dbnames")161162163/* Local prototypes */164165static ACPI_STATUS166AcpiDbWalkAndMatchName (167ACPI_HANDLE ObjHandle,168UINT32 NestingLevel,169void *Context,170void **ReturnValue);171172static ACPI_STATUS173AcpiDbWalkForPredefinedNames (174ACPI_HANDLE ObjHandle,175UINT32 NestingLevel,176void *Context,177void **ReturnValue);178179static ACPI_STATUS180AcpiDbWalkForSpecificObjects (181ACPI_HANDLE ObjHandle,182UINT32 NestingLevel,183void *Context,184void **ReturnValue);185186static ACPI_STATUS187AcpiDbWalkForObjectCounts (188ACPI_HANDLE ObjHandle,189UINT32 NestingLevel,190void *Context,191void **ReturnValue);192193static ACPI_STATUS194AcpiDbIntegrityWalk (195ACPI_HANDLE ObjHandle,196UINT32 NestingLevel,197void *Context,198void **ReturnValue);199200static ACPI_STATUS201AcpiDbWalkForReferences (202ACPI_HANDLE ObjHandle,203UINT32 NestingLevel,204void *Context,205void **ReturnValue);206207static ACPI_STATUS208AcpiDbBusWalk (209ACPI_HANDLE ObjHandle,210UINT32 NestingLevel,211void *Context,212void **ReturnValue);213214/*215* Arguments for the Objects command216* These object types map directly to the ACPI_TYPES217*/218static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =219{220{"ANY"},221{"INTEGERS"},222{"STRINGS"},223{"BUFFERS"},224{"PACKAGES"},225{"FIELDS"},226{"DEVICES"},227{"EVENTS"},228{"METHODS"},229{"MUTEXES"},230{"REGIONS"},231{"POWERRESOURCES"},232{"PROCESSORS"},233{"THERMALZONES"},234{"BUFFERFIELDS"},235{"DDBHANDLES"},236{"DEBUG"},237{"REGIONFIELDS"},238{"BANKFIELDS"},239{"INDEXFIELDS"},240{"REFERENCES"},241{"ALIASES"},242{"METHODALIASES"},243{"NOTIFY"},244{"ADDRESSHANDLER"},245{"RESOURCE"},246{"RESOURCEFIELD"},247{"SCOPES"},248{NULL} /* Must be null terminated */249};250251252/*******************************************************************************253*254* FUNCTION: AcpiDbSetScope255*256* PARAMETERS: Name - New scope path257*258* RETURN: Status259*260* DESCRIPTION: Set the "current scope" as maintained by this utility.261* The scope is used as a prefix to ACPI paths.262*263******************************************************************************/264265void266AcpiDbSetScope (267char *Name)268{269ACPI_STATUS Status;270ACPI_NAMESPACE_NODE *Node;271272273if (!Name || Name[0] == 0)274{275AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);276return;277}278279AcpiDbPrepNamestring (Name);280281if (ACPI_IS_ROOT_PREFIX (Name[0]))282{283/* Validate new scope from the root */284285Status = AcpiNsGetNode (AcpiGbl_RootNode, Name,286ACPI_NS_NO_UPSEARCH, &Node);287if (ACPI_FAILURE (Status))288{289goto ErrorExit;290}291292AcpiGbl_DbScopeBuf[0] = 0;293}294else295{296/* Validate new scope relative to old scope */297298Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name,299ACPI_NS_NO_UPSEARCH, &Node);300if (ACPI_FAILURE (Status))301{302goto ErrorExit;303}304}305306/* Build the final pathname */307308if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),309Name))310{311Status = AE_BUFFER_OVERFLOW;312goto ErrorExit;313}314315if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),316"\\"))317{318Status = AE_BUFFER_OVERFLOW;319goto ErrorExit;320}321322AcpiGbl_DbScopeNode = Node;323AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);324return;325326ErrorExit:327328AcpiOsPrintf ("Could not attach scope: %s, %s\n",329Name, AcpiFormatException (Status));330}331332333/*******************************************************************************334*335* FUNCTION: AcpiDbDumpNamespace336*337* PARAMETERS: StartArg - Node to begin namespace dump338* DepthArg - Maximum tree depth to be dumped339*340* RETURN: None341*342* DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed343* with type and other information.344*345******************************************************************************/346347void348AcpiDbDumpNamespace (349char *StartArg,350char *DepthArg)351{352ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;353UINT32 MaxDepth = ACPI_UINT32_MAX;354355356/* No argument given, just start at the root and dump entire namespace */357358if (StartArg)359{360SubtreeEntry = AcpiDbConvertToNode (StartArg);361if (!SubtreeEntry)362{363return;364}365366/* Now we can check for the depth argument */367368if (DepthArg)369{370MaxDepth = strtoul (DepthArg, NULL, 0);371}372}373374AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);375376if (((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Parent)377{378AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",379((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);380}381else382{383AcpiOsPrintf ("ACPI Namespace (from %s):\n",384ACPI_NAMESPACE_ROOT);385}386387/* Display the subtree */388389AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);390AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,391ACPI_OWNER_ID_MAX, SubtreeEntry);392AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);393}394395396/*******************************************************************************397*398* FUNCTION: AcpiDbDumpNamespacePaths399*400* PARAMETERS: None401*402* RETURN: None403*404* DESCRIPTION: Dump entire namespace with full object pathnames and object405* type information. Alternative to "namespace" command.406*407******************************************************************************/408409void410AcpiDbDumpNamespacePaths (411void)412{413414AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);415AcpiOsPrintf ("ACPI Namespace (from root):\n");416417/* Display the entire namespace */418419AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);420AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,421ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);422423AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);424}425426427/*******************************************************************************428*429* FUNCTION: AcpiDbDumpNamespaceByOwner430*431* PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed432* DepthArg - Maximum tree depth to be dumped433*434* RETURN: None435*436* DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.437*438******************************************************************************/439440void441AcpiDbDumpNamespaceByOwner (442char *OwnerArg,443char *DepthArg)444{445ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;446UINT32 MaxDepth = ACPI_UINT32_MAX;447ACPI_OWNER_ID OwnerId;448449450OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0);451452/* Now we can check for the depth argument */453454if (DepthArg)455{456MaxDepth = strtoul (DepthArg, NULL, 0);457}458459AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);460AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);461462/* Display the subtree */463464AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);465AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,466OwnerId, SubtreeEntry);467AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);468}469470471/*******************************************************************************472*473* FUNCTION: AcpiDbWalkAndMatchName474*475* PARAMETERS: Callback from WalkNamespace476*477* RETURN: Status478*479* DESCRIPTION: Find a particular name/names within the namespace. Wildcards480* are supported -- '?' matches any character.481*482******************************************************************************/483484static ACPI_STATUS485AcpiDbWalkAndMatchName (486ACPI_HANDLE ObjHandle,487UINT32 NestingLevel,488void *Context,489void **ReturnValue)490{491ACPI_STATUS Status;492char *RequestedName = (char *) Context;493UINT32 i;494ACPI_BUFFER Buffer;495ACPI_WALK_INFO Info;496497498/* Check for a name match */499500for (i = 0; i < 4; i++)501{502/* Wildcard support */503504if ((RequestedName[i] != '?') &&505(RequestedName[i] != ((ACPI_NAMESPACE_NODE *)506ObjHandle)->Name.Ascii[i]))507{508/* No match, just exit */509510return (AE_OK);511}512}513514/* Get the full pathname to this object */515516Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;517Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);518if (ACPI_FAILURE (Status))519{520AcpiOsPrintf ("Could Not get pathname for object %p\n",521ObjHandle);522}523else524{525Info.Count = 0;526Info.OwnerId = ACPI_OWNER_ID_MAX;527Info.DebugLevel = ACPI_UINT32_MAX;528Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;529530AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);531(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);532ACPI_FREE (Buffer.Pointer);533}534535return (AE_OK);536}537538539/*******************************************************************************540*541* FUNCTION: AcpiDbFindNameInNamespace542*543* PARAMETERS: NameArg - The 4-character ACPI name to find.544* wildcards are supported.545*546* RETURN: None547*548* DESCRIPTION: Search the namespace for a given name (with wildcards)549*550******************************************************************************/551552ACPI_STATUS553AcpiDbFindNameInNamespace (554char *NameArg)555{556char AcpiName[5] = "____";557char *AcpiNamePtr = AcpiName;558559560if (strlen (NameArg) > ACPI_NAMESEG_SIZE)561{562AcpiOsPrintf ("Name must be no longer than 4 characters\n");563return (AE_OK);564}565566/* Pad out name with underscores as necessary to create a 4-char name */567568AcpiUtStrupr (NameArg);569while (*NameArg)570{571*AcpiNamePtr = *NameArg;572AcpiNamePtr++;573NameArg++;574}575576/* Walk the namespace from the root */577578(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,579ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);580581AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);582return (AE_OK);583}584585586/*******************************************************************************587*588* FUNCTION: AcpiDbWalkForPredefinedNames589*590* PARAMETERS: Callback from WalkNamespace591*592* RETURN: Status593*594* DESCRIPTION: Detect and display predefined ACPI names (names that start with595* an underscore)596*597******************************************************************************/598599static ACPI_STATUS600AcpiDbWalkForPredefinedNames (601ACPI_HANDLE ObjHandle,602UINT32 NestingLevel,603void *Context,604void **ReturnValue)605{606ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;607UINT32 *Count = (UINT32 *) Context;608const ACPI_PREDEFINED_INFO *Predefined;609const ACPI_PREDEFINED_INFO *Package = NULL;610char *Pathname;611char StringBuffer[48];612613614Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);615if (!Predefined)616{617return (AE_OK);618}619620Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);621if (!Pathname)622{623return (AE_OK);624}625626/* If method returns a package, the info is in the next table entry */627628if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)629{630Package = Predefined + 1;631}632633AcpiUtGetExpectedReturnTypes (StringBuffer,634Predefined->Info.ExpectedBtypes);635636AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname,637METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList),638StringBuffer);639640if (Package)641{642AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",643Package->RetInfo.Type, Package->RetInfo.ObjectType1,644Package->RetInfo.Count1);645}646647AcpiOsPrintf("\n");648649/* Check that the declared argument count matches the ACPI spec */650651AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);652653ACPI_FREE (Pathname);654(*Count)++;655return (AE_OK);656}657658659/*******************************************************************************660*661* FUNCTION: AcpiDbCheckPredefinedNames662*663* PARAMETERS: None664*665* RETURN: None666*667* DESCRIPTION: Validate all predefined names in the namespace668*669******************************************************************************/670671void672AcpiDbCheckPredefinedNames (673void)674{675UINT32 Count = 0;676677678/* Search all nodes in namespace */679680(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,681ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames,682NULL, (void *) &Count, NULL);683684AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);685}686687688/*******************************************************************************689*690* FUNCTION: AcpiDbWalkForObjectCounts691*692* PARAMETERS: Callback from WalkNamespace693*694* RETURN: Status695*696* DESCRIPTION: Display short info about objects in the namespace697*698******************************************************************************/699700static ACPI_STATUS701AcpiDbWalkForObjectCounts (702ACPI_HANDLE ObjHandle,703UINT32 NestingLevel,704void *Context,705void **ReturnValue)706{707ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context;708ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;709710711if (Node->Type > ACPI_TYPE_NS_NODE_MAX)712{713AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n",714Node->Name.Ascii, Node->Type);715}716else717{718Info->Types[Node->Type]++;719}720721return (AE_OK);722}723724725/*******************************************************************************726*727* FUNCTION: AcpiDbWalkForFields728*729* PARAMETERS: Callback from WalkNamespace730*731* RETURN: Status732*733* DESCRIPTION: Display short info about objects in the namespace734*735******************************************************************************/736737static ACPI_STATUS738AcpiDbWalkForFields (739ACPI_HANDLE ObjHandle,740UINT32 NestingLevel,741void *Context,742void **ReturnValue)743{744ACPI_OBJECT *RetValue;745ACPI_REGION_WALK_INFO *Info = (ACPI_REGION_WALK_INFO *) Context;746ACPI_BUFFER Buffer;747ACPI_STATUS Status;748ACPI_NAMESPACE_NODE *Node = AcpiNsValidateHandle (ObjHandle);749750751if (!Node)752{753return (AE_OK);754}755if (Node->Object->Field.RegionObj->Region.SpaceId != Info->AddressSpaceId)756{757return (AE_OK);758}759760Info->Count++;761762/* Get and display the full pathname to this object */763764Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;765Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);766if (ACPI_FAILURE (Status))767{768AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);769return (AE_OK);770}771772AcpiOsPrintf ("%s ", (char *) Buffer.Pointer);773ACPI_FREE (Buffer.Pointer);774775Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;776Status = AcpiEvaluateObject (ObjHandle, NULL, NULL, &Buffer);777if (ACPI_FAILURE (Status))778{779AcpiOsPrintf ("Could Not evaluate object %p\n", ObjHandle);780return (AE_OK);781}782783/*784* Since this is a field unit, surround the output in braces785*/786AcpiOsPrintf ("{");787788RetValue = (ACPI_OBJECT *) Buffer.Pointer;789switch (RetValue->Type)790{791case ACPI_TYPE_INTEGER:792793AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (RetValue->Integer.Value));794break;795796case ACPI_TYPE_BUFFER:797798AcpiUtDumpBuffer (RetValue->Buffer.Pointer,799RetValue->Buffer.Length, DB_DISPLAY_DATA_ONLY | DB_BYTE_DISPLAY, 0);800break;801802default:803804break;805}806807AcpiOsPrintf ("}\n");808809ACPI_FREE (Buffer.Pointer);810return (AE_OK);811}812813814/*******************************************************************************815*816* FUNCTION: AcpiDbWalkForSpecificObjects817*818* PARAMETERS: Callback from WalkNamespace819*820* RETURN: Status821*822* DESCRIPTION: Display short info about objects in the namespace823*824******************************************************************************/825826static ACPI_STATUS827AcpiDbWalkForSpecificObjects (828ACPI_HANDLE ObjHandle,829UINT32 NestingLevel,830void *Context,831void **ReturnValue)832{833ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;834ACPI_BUFFER Buffer;835ACPI_STATUS Status;836837838Info->Count++;839840/* Get and display the full pathname to this object */841842Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;843Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);844if (ACPI_FAILURE (Status))845{846AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);847return (AE_OK);848}849850AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);851ACPI_FREE (Buffer.Pointer);852853/* Dump short info about the object */854855(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);856return (AE_OK);857}858859860/*******************************************************************************861*862* FUNCTION: AcpiDbDisplayObjects863*864* PARAMETERS: ObjTypeArg - Type of object to display865* DisplayCountArg - Max depth to display866*867* RETURN: None868*869* DESCRIPTION: Display objects in the namespace of the requested type870*871******************************************************************************/872873ACPI_STATUS874AcpiDbDisplayObjects (875char *ObjTypeArg,876char *DisplayCountArg)877{878ACPI_WALK_INFO Info;879ACPI_OBJECT_TYPE Type;880ACPI_OBJECT_INFO *ObjectInfo;881UINT32 i;882UINT32 TotalObjects = 0;883884885/* No argument means display summary/count of all object types */886887if (!ObjTypeArg)888{889ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO));890891if (!ObjectInfo)892return (AE_NO_MEMORY);893894/* Walk the namespace from the root */895896(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,897ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL,898(void *) ObjectInfo, NULL);899900AcpiOsPrintf ("\nSummary of namespace objects:\n\n");901902for (i = 0; i < ACPI_TOTAL_TYPES; i++)903{904AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i],905AcpiUtGetTypeName (i));906907TotalObjects += ObjectInfo->Types[i];908}909910AcpiOsPrintf ("\n%8u Total namespace objects\n\n",911TotalObjects);912913ACPI_FREE (ObjectInfo);914return (AE_OK);915}916917/* Get the object type */918919Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);920if (Type == ACPI_TYPE_NOT_FOUND)921{922AcpiOsPrintf ("Invalid or unsupported argument\n");923return (AE_OK);924}925926AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);927AcpiOsPrintf (928"Objects of type [%s] defined in the current ACPI Namespace:\n",929AcpiUtGetTypeName (Type));930931AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);932933Info.Count = 0;934Info.OwnerId = ACPI_OWNER_ID_MAX;935Info.DebugLevel = ACPI_UINT32_MAX;936Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;937938/* Walk the namespace from the root */939940(void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,941AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);942943AcpiOsPrintf (944"\nFound %u objects of type [%s] in the current ACPI Namespace\n",945Info.Count, AcpiUtGetTypeName (Type));946947AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);948return (AE_OK);949}950951952/*******************************************************************************953*954* FUNCTION: AcpiDbDisplayFields955*956* PARAMETERS: ObjTypeArg - Type of object to display957* DisplayCountArg - Max depth to display958*959* RETURN: None960*961* DESCRIPTION: Display objects in the namespace of the requested type962*963******************************************************************************/964965ACPI_STATUS966AcpiDbDisplayFields (967UINT32 AddressSpaceId)968{969ACPI_REGION_WALK_INFO Info;970971972Info.Count = 0;973Info.OwnerId = ACPI_OWNER_ID_MAX;974Info.DebugLevel = ACPI_UINT32_MAX;975Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;976Info.AddressSpaceId = AddressSpaceId;977978/* Walk the namespace from the root */979980(void) AcpiWalkNamespace (ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_ROOT_OBJECT,981ACPI_UINT32_MAX, AcpiDbWalkForFields, NULL,982(void *) &Info, NULL);983984return (AE_OK);985}986987988/*******************************************************************************989*990* FUNCTION: AcpiDbIntegrityWalk991*992* PARAMETERS: Callback from WalkNamespace993*994* RETURN: Status995*996* DESCRIPTION: Examine one NS node for valid values.997*998******************************************************************************/9991000static ACPI_STATUS1001AcpiDbIntegrityWalk (1002ACPI_HANDLE ObjHandle,1003UINT32 NestingLevel,1004void *Context,1005void **ReturnValue)1006{1007ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;1008ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;1009ACPI_OPERAND_OBJECT *Object;1010BOOLEAN Alias = TRUE;101110121013Info->Nodes++;10141015/* Verify the NS node, and dereference aliases */10161017while (Alias)1018{1019if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)1020{1021AcpiOsPrintf (1022"Invalid Descriptor Type for Node %p [%s] - "1023"is %2.2X should be %2.2X\n",1024Node, AcpiUtGetDescriptorName (Node),1025ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED);1026return (AE_OK);1027}10281029if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||1030(Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))1031{1032Node = (ACPI_NAMESPACE_NODE *) Node->Object;1033}1034else1035{1036Alias = FALSE;1037}1038}10391040if (Node->Type > ACPI_TYPE_LOCAL_MAX)1041{1042AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",1043Node, Node->Type);1044return (AE_OK);1045}10461047if (!AcpiUtValidNameseg (Node->Name.Ascii))1048{1049AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);1050return (AE_OK);1051}10521053Object = AcpiNsGetAttachedObject (Node);1054if (Object)1055{1056Info->Objects++;1057if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)1058{1059AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",1060Object, AcpiUtGetDescriptorName (Object));1061}1062}10631064return (AE_OK);1065}106610671068/*******************************************************************************1069*1070* FUNCTION: AcpiDbCheckIntegrity1071*1072* PARAMETERS: None1073*1074* RETURN: None1075*1076* DESCRIPTION: Check entire namespace for data structure integrity1077*1078******************************************************************************/10791080void1081AcpiDbCheckIntegrity (1082void)1083{1084ACPI_INTEGRITY_INFO Info = {0,0};10851086/* Search all nodes in namespace */10871088(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,1089ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);10901091AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",1092Info.Nodes, Info.Objects);1093}109410951096/*******************************************************************************1097*1098* FUNCTION: AcpiDbWalkForReferences1099*1100* PARAMETERS: Callback from WalkNamespace1101*1102* RETURN: Status1103*1104* DESCRIPTION: Check if this namespace object refers to the target object1105* that is passed in as the context value.1106*1107* Note: Currently doesn't check subobjects within the Node's object1108*1109******************************************************************************/11101111static ACPI_STATUS1112AcpiDbWalkForReferences (1113ACPI_HANDLE ObjHandle,1114UINT32 NestingLevel,1115void *Context,1116void **ReturnValue)1117{1118ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;1119ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;112011211122/* Check for match against the namespace node itself */11231124if (Node == (void *) ObjDesc)1125{1126AcpiOsPrintf ("Object is a Node [%4.4s]\n",1127AcpiUtGetNodeName (Node));1128}11291130/* Check for match against the object attached to the node */11311132if (AcpiNsGetAttachedObject (Node) == ObjDesc)1133{1134AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",1135Node, AcpiUtGetNodeName (Node));1136}11371138return (AE_OK);1139}114011411142/*******************************************************************************1143*1144* FUNCTION: AcpiDbFindReferences1145*1146* PARAMETERS: ObjectArg - String with hex value of the object1147*1148* RETURN: None1149*1150* DESCRIPTION: Search namespace for all references to the input object1151*1152******************************************************************************/11531154void1155AcpiDbFindReferences (1156char *ObjectArg)1157{1158ACPI_OPERAND_OBJECT *ObjDesc;1159ACPI_SIZE Address;116011611162/* Convert string to object pointer */11631164Address = strtoul (ObjectArg, NULL, 16);1165ObjDesc = ACPI_TO_POINTER (Address);11661167/* Search all nodes in namespace */11681169(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,1170ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL,1171(void *) ObjDesc, NULL);1172}117311741175/*******************************************************************************1176*1177* FUNCTION: AcpiDbBusWalk1178*1179* PARAMETERS: Callback from WalkNamespace1180*1181* RETURN: Status1182*1183* DESCRIPTION: Display info about device objects that have a corresponding1184* _PRT method.1185*1186******************************************************************************/11871188static ACPI_STATUS1189AcpiDbBusWalk (1190ACPI_HANDLE ObjHandle,1191UINT32 NestingLevel,1192void *Context,1193void **ReturnValue)1194{1195ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;1196ACPI_STATUS Status;1197ACPI_BUFFER Buffer;1198ACPI_NAMESPACE_NODE *TempNode;1199ACPI_DEVICE_INFO *Info;1200UINT32 i;120112021203if ((Node->Type != ACPI_TYPE_DEVICE) &&1204(Node->Type != ACPI_TYPE_PROCESSOR))1205{1206return (AE_OK);1207}12081209/* Exit if there is no _PRT under this device */12101211Status = AcpiGetHandle (Node, METHOD_NAME__PRT,1212ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));1213if (ACPI_FAILURE (Status))1214{1215return (AE_OK);1216}12171218/* Get the full path to this device object */12191220Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;1221Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);1222if (ACPI_FAILURE (Status))1223{1224AcpiOsPrintf ("Could Not get pathname for object %p\n",1225ObjHandle);1226return (AE_OK);1227}12281229Status = AcpiGetObjectInfo (ObjHandle, &Info);1230if (ACPI_FAILURE (Status))1231{1232return (AE_OK);1233}12341235/* Display the full path */12361237AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);1238ACPI_FREE (Buffer.Pointer);12391240if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)1241{1242AcpiOsPrintf (" - Is PCI Root Bridge");1243}1244AcpiOsPrintf ("\n");12451246/* _PRT info */12471248AcpiOsPrintf ("_PRT: %p\n", TempNode);12491250/* Dump _ADR, _HID, _UID, _CID */12511252if (Info->Valid & ACPI_VALID_ADR)1253{1254AcpiOsPrintf ("_ADR: %8.8X%8.8X\n",1255ACPI_FORMAT_UINT64 (Info->Address));1256}1257else1258{1259AcpiOsPrintf ("_ADR: <Not Present>\n");1260}12611262if (Info->Valid & ACPI_VALID_HID)1263{1264AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);1265}1266else1267{1268AcpiOsPrintf ("_HID: <Not Present>\n");1269}12701271if (Info->Valid & ACPI_VALID_UID)1272{1273AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);1274}1275else1276{1277AcpiOsPrintf ("_UID: <Not Present>\n");1278}12791280if (Info->Valid & ACPI_VALID_CID)1281{1282for (i = 0; i < Info->CompatibleIdList.Count; i++)1283{1284AcpiOsPrintf ("_CID: %s\n",1285Info->CompatibleIdList.Ids[i].String);1286}1287}1288else1289{1290AcpiOsPrintf ("_CID: <Not Present>\n");1291}12921293ACPI_FREE (Info);1294return (AE_OK);1295}129612971298/*******************************************************************************1299*1300* FUNCTION: AcpiDbGetBusInfo1301*1302* PARAMETERS: None1303*1304* RETURN: None1305*1306* DESCRIPTION: Display info about system buses.1307*1308******************************************************************************/13091310void1311AcpiDbGetBusInfo (1312void)1313{1314/* Search all nodes in namespace */13151316(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,1317ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL);1318}131913201321