Path: blob/main/sys/contrib/dev/acpica/components/namespace/nsdump.c
48524 views
/******************************************************************************1*2* Module Name: nsdump - table dumping routines for debug3*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,2425* make derivatives, distribute, use and display any portion of the Covered26* Code in any form, with the right to sublicense such rights; and27*28* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent29* license (with the right to sublicense), under only those claims of Intel30* patents that are infringed by the Original Intel Code, to make, use, sell,31* offer to sell, and import the Covered Code and derivative works thereof32* solely to the minimum extent necessary to exercise the above copyright33* license, and in no event shall the patent license extend to any additions34* to or modifications of the Original Intel Code. No other license or right35* is granted directly or by implication, estoppel or otherwise;36*37* The above copyright and patent license is granted only if the following38* conditions are met:39*40* 3. Conditions41*42* 3.1. Redistribution of Source with Rights to Further Distribute Source.43* Redistribution of source code of any substantial portion of the Covered44* Code or modification with rights to further distribute source must include45* the above Copyright Notice, the above License, this list of Conditions,46* and the following Disclaimer and Export Compliance provision. In addition,47* Licensee must cause all Covered Code to which Licensee contributes to48* contain a file documenting the changes Licensee made to create that Covered49* Code and the date of any change. Licensee must include in that file the50* documentation of any changes made by any predecessor Licensee. Licensee51* must include a prominent statement that the modification is derived,52* directly or indirectly, from Original Intel Code.53*54* 3.2. Redistribution of Source with no Rights to Further Distribute Source.55* Redistribution of source code of any substantial portion of the Covered56* Code or modification without rights to further distribute source must57* include the following Disclaimer and Export Compliance provision in the58* documentation and/or other materials provided with distribution. In59* addition, Licensee may not authorize further sublicense of source of any60* portion of the Covered Code, and must include terms to the effect that the61* license from Licensee to its licensee is limited to the intellectual62* property embodied in the software Licensee provides to its licensee, and63* not to intellectual property embodied in modifications its licensee may64* make.65*66* 3.3. Redistribution of Executable. Redistribution in executable form of any67* substantial portion of the Covered Code or modification must reproduce the68* above Copyright Notice, and the following Disclaimer and Export Compliance69* provision in the documentation and/or other materials provided with the70* distribution.71*72* 3.4. Intel retains all right, title, and interest in and to the Original73* Intel Code.74*75* 3.5. Neither the name Intel nor any other trademark owned or controlled by76* Intel shall be used in advertising or otherwise to promote the sale, use or77* other dealings in products derived from or relating to the Covered Code78* without prior written authorization from Intel.79*80* 4. Disclaimer and Export Compliance81*82* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED83* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE84* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,85* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY86* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY87* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A88* PARTICULAR PURPOSE.89*90* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES91* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR92* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,93* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY94* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL95* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS96* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY97* LIMITED REMEDY.98*99* 4.3. Licensee shall not export, either directly or indirectly, any of this100* software or system incorporating such software without first obtaining any101* required license or other approval from the U. S. Department of Commerce or102* any other agency or department of the United States Government. In the103* event Licensee exports any such software from the United States or104* re-exports any such software from a foreign destination, Licensee shall105* ensure that the distribution and export/re-export of the software is in106* compliance with all laws, regulations, orders, or other restrictions of the107* U.S. Export Administration Regulations. Licensee agrees that neither it nor108* any of its subsidiaries will export/re-export any technical data, process,109* software, or service, directly or indirectly, to any country for which the110* United States government or any agency thereof requires an export license,111* other governmental approval, or letter of assurance, without first obtaining112* such license, approval or letter.113*114*****************************************************************************115*116* Alternatively, you may choose to be licensed under the terms of the117* following license:118*119* Redistribution and use in source and binary forms, with or without120* modification, are permitted provided that the following conditions121* are met:122* 1. Redistributions of source code must retain the above copyright123* notice, this list of conditions, and the following disclaimer,124* without modification.125* 2. Redistributions in binary form must reproduce at minimum a disclaimer126* substantially similar to the "NO WARRANTY" disclaimer below127* ("Disclaimer") and any redistribution must be conditioned upon128* including a substantially similar Disclaimer requirement for further129* binary redistribution.130* 3. Neither the names of the above-listed copyright holders nor the names131* of any contributors may be used to endorse or promote products derived132* from this software without specific prior written permission.133*134* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS135* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT136* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR137* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT138* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,139* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT140* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,141* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY142* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT143* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE144* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.145*146* Alternatively, you may choose to be licensed under the terms of the147* GNU General Public License ("GPL") version 2 as published by the Free148* Software Foundation.149*150*****************************************************************************/151152#include <contrib/dev/acpica/include/acpi.h>153#include <contrib/dev/acpica/include/accommon.h>154#include <contrib/dev/acpica/include/acnamesp.h>155#include <contrib/dev/acpica/include/acoutput.h>156157158#define _COMPONENT ACPI_NAMESPACE159ACPI_MODULE_NAME ("nsdump")160161/* Local prototypes */162163#ifdef ACPI_OBSOLETE_FUNCTIONS164void165AcpiNsDumpRootDevices (166void);167168static ACPI_STATUS169AcpiNsDumpOneDevice (170ACPI_HANDLE ObjHandle,171UINT32 Level,172void *Context,173void **ReturnValue);174#endif175176177#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)178179static ACPI_STATUS180AcpiNsDumpOneObjectPath (181ACPI_HANDLE ObjHandle,182UINT32 Level,183void *Context,184void **ReturnValue);185186static ACPI_STATUS187AcpiNsGetMaxDepth (188ACPI_HANDLE ObjHandle,189UINT32 Level,190void *Context,191void **ReturnValue);192193194/*******************************************************************************195*196* FUNCTION: AcpiNsPrintPathname197*198* PARAMETERS: NumSegments - Number of ACPI name segments199* Pathname - The compressed (internal) path200*201* RETURN: None202*203* DESCRIPTION: Print an object's full namespace pathname204*205******************************************************************************/206207void208AcpiNsPrintPathname (209UINT32 NumSegments,210const char *Pathname)211{212UINT32 i;213214215ACPI_FUNCTION_NAME (NsPrintPathname);216217218/* Check if debug output enabled */219220if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))221{222return;223}224225/* Print the entire name */226227ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));228229while (NumSegments)230{231for (i = 0; i < 4; i++)232{233isprint ((int) Pathname[i]) ?234AcpiOsPrintf ("%c", Pathname[i]) :235AcpiOsPrintf ("?");236}237238Pathname += ACPI_NAMESEG_SIZE;239NumSegments--;240if (NumSegments)241{242AcpiOsPrintf (".");243}244}245246AcpiOsPrintf ("]\n");247}248249250#ifdef ACPI_OBSOLETE_FUNCTIONS251/* Not used at this time, perhaps later */252253/*******************************************************************************254*255* FUNCTION: AcpiNsDumpPathname256*257* PARAMETERS: Handle - Object258* Msg - Prefix message259* Level - Desired debug level260* Component - Caller's component ID261*262* RETURN: None263*264* DESCRIPTION: Print an object's full namespace pathname265* Manages allocation/freeing of a pathname buffer266*267******************************************************************************/268269void270AcpiNsDumpPathname (271ACPI_HANDLE Handle,272const char *Msg,273UINT32 Level,274UINT32 Component)275{276277ACPI_FUNCTION_TRACE (NsDumpPathname);278279280/* Do this only if the requested debug level and component are enabled */281282if (!ACPI_IS_DEBUG_ENABLED (Level, Component))283{284return_VOID;285}286287/* Convert handle to a full pathname and print it (with supplied message) */288289AcpiNsPrintNodePathname (Handle, Msg);290AcpiOsPrintf ("\n");291return_VOID;292}293#endif294295296/*******************************************************************************297*298* FUNCTION: AcpiNsDumpOneObject299*300* PARAMETERS: ObjHandle - Node to be dumped301* Level - Nesting level of the handle302* Context - Passed into WalkNamespace303* ReturnValue - Not used304*305* RETURN: Status306*307* DESCRIPTION: Dump a single Node308* This procedure is a UserFunction called by AcpiNsWalkNamespace.309*310******************************************************************************/311312ACPI_STATUS313AcpiNsDumpOneObject (314ACPI_HANDLE ObjHandle,315UINT32 Level,316void *Context,317void **ReturnValue)318{319ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;320ACPI_NAMESPACE_NODE *ThisNode;321ACPI_OPERAND_OBJECT *ObjDesc = NULL;322ACPI_OBJECT_TYPE ObjType;323ACPI_OBJECT_TYPE Type;324UINT32 BytesToDump;325UINT32 DbgLevel;326UINT32 i;327328329ACPI_FUNCTION_NAME (NsDumpOneObject);330331332/* Is output enabled? */333334if (!(AcpiDbgLevel & Info->DebugLevel))335{336return (AE_OK);337}338339if (!ObjHandle)340{341ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));342return (AE_OK);343}344345ThisNode = AcpiNsValidateHandle (ObjHandle);346if (!ThisNode)347{348ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",349ObjHandle));350return (AE_OK);351}352353Type = ThisNode->Type;354Info->Count++;355356/* Check if the owner matches */357358if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&359(Info->OwnerId != ThisNode->OwnerId))360{361return (AE_OK);362}363364if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))365{366/* Indent the object according to the level */367368AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");369370/* Check the node type and name */371372if (Type > ACPI_TYPE_LOCAL_MAX)373{374ACPI_WARNING ((AE_INFO,375"Invalid ACPI Object Type 0x%08X", Type));376}377378AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));379}380381/* Now we can print out the pertinent information */382383AcpiOsPrintf (" %-12s %p %3.3X ",384AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);385386DbgLevel = AcpiDbgLevel;387AcpiDbgLevel = 0;388ObjDesc = AcpiNsGetAttachedObject (ThisNode);389AcpiDbgLevel = DbgLevel;390391/* Temp nodes are those nodes created by a control method */392393if (ThisNode->Flags & ANOBJ_TEMPORARY)394{395AcpiOsPrintf ("(T) ");396}397398switch (Info->DisplayType & ACPI_DISPLAY_MASK)399{400case ACPI_DISPLAY_SUMMARY:401402if (!ObjDesc)403{404/* No attached object. Some types should always have an object */405406switch (Type)407{408case ACPI_TYPE_INTEGER:409case ACPI_TYPE_PACKAGE:410case ACPI_TYPE_BUFFER:411case ACPI_TYPE_STRING:412case ACPI_TYPE_METHOD:413414AcpiOsPrintf ("<No attached object>");415break;416417default:418419break;420}421422AcpiOsPrintf ("\n");423return (AE_OK);424}425426switch (Type)427{428case ACPI_TYPE_PROCESSOR:429430AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",431ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,432ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));433break;434435case ACPI_TYPE_DEVICE:436437AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);438break;439440case ACPI_TYPE_METHOD:441442AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",443(UINT32) ObjDesc->Method.ParamCount,444ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);445break;446447case ACPI_TYPE_INTEGER:448449AcpiOsPrintf ("= %8.8X%8.8X\n",450ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));451break;452453case ACPI_TYPE_PACKAGE:454455if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)456{457AcpiOsPrintf ("Elements %.2X\n",458ObjDesc->Package.Count);459}460else461{462AcpiOsPrintf ("[Length not yet evaluated]\n");463}464break;465466case ACPI_TYPE_BUFFER:467468if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)469{470AcpiOsPrintf ("Len %.2X",471ObjDesc->Buffer.Length);472473/* Dump some of the buffer */474475if (ObjDesc->Buffer.Length > 0)476{477AcpiOsPrintf (" =");478for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)479{480AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);481}482}483AcpiOsPrintf ("\n");484}485else486{487AcpiOsPrintf ("[Length not yet evaluated]\n");488}489break;490491case ACPI_TYPE_STRING:492493AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);494AcpiUtPrintString (ObjDesc->String.Pointer, 80);495AcpiOsPrintf ("\n");496break;497498case ACPI_TYPE_REGION:499500AcpiOsPrintf ("[%s]",501AcpiUtGetRegionName (ObjDesc->Region.SpaceId));502if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)503{504AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",505ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),506ObjDesc->Region.Length);507}508else509{510AcpiOsPrintf (" [Address/Length not yet evaluated]\n");511}512break;513514case ACPI_TYPE_LOCAL_REFERENCE:515516AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));517break;518519case ACPI_TYPE_BUFFER_FIELD:520521if (ObjDesc->BufferField.BufferObj &&522ObjDesc->BufferField.BufferObj->Buffer.Node)523{524AcpiOsPrintf ("Buf [%4.4s]",525AcpiUtGetNodeName (526ObjDesc->BufferField.BufferObj->Buffer.Node));527}528break;529530case ACPI_TYPE_LOCAL_REGION_FIELD:531532AcpiOsPrintf ("Rgn [%4.4s]",533AcpiUtGetNodeName (534ObjDesc->CommonField.RegionObj->Region.Node));535break;536537case ACPI_TYPE_LOCAL_BANK_FIELD:538539AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",540AcpiUtGetNodeName (541ObjDesc->CommonField.RegionObj->Region.Node),542AcpiUtGetNodeName (543ObjDesc->BankField.BankObj->CommonField.Node));544break;545546case ACPI_TYPE_LOCAL_INDEX_FIELD:547548AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",549AcpiUtGetNodeName (550ObjDesc->IndexField.IndexObj->CommonField.Node),551AcpiUtGetNodeName (552ObjDesc->IndexField.DataObj->CommonField.Node));553break;554555case ACPI_TYPE_LOCAL_ALIAS:556case ACPI_TYPE_LOCAL_METHOD_ALIAS:557558AcpiOsPrintf ("Target %4.4s (%p)\n",559AcpiUtGetNodeName (ObjDesc), ObjDesc);560break;561562default:563564AcpiOsPrintf ("Object %p\n", ObjDesc);565break;566}567568/* Common field handling */569570switch (Type)571{572case ACPI_TYPE_BUFFER_FIELD:573case ACPI_TYPE_LOCAL_REGION_FIELD:574case ACPI_TYPE_LOCAL_BANK_FIELD:575case ACPI_TYPE_LOCAL_INDEX_FIELD:576577AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2X\n",578(ObjDesc->CommonField.BaseByteOffset * 8)579+ ObjDesc->CommonField.StartFieldBitOffset,580ObjDesc->CommonField.BitLength,581ObjDesc->CommonField.AccessByteWidth);582break;583584default:585586break;587}588break;589590case ACPI_DISPLAY_OBJECTS:591592AcpiOsPrintf ("O:%p", ObjDesc);593if (!ObjDesc)594{595/* No attached object, we are done */596597AcpiOsPrintf ("\n");598return (AE_OK);599}600601AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);602603switch (Type)604{605case ACPI_TYPE_METHOD:606607/* Name is a Method and its AML offset/length are set */608609AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,610ObjDesc->Method.AmlLength);611break;612613case ACPI_TYPE_INTEGER:614615AcpiOsPrintf (" I:%8.8X8.8%X\n",616ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));617break;618619case ACPI_TYPE_STRING:620621AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,622ObjDesc->String.Length);623break;624625case ACPI_TYPE_BUFFER:626627AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,628ObjDesc->Buffer.Length);629break;630631default:632633AcpiOsPrintf ("\n");634break;635}636break;637638default:639AcpiOsPrintf ("\n");640break;641}642643/* If debug turned off, done */644645if (!(AcpiDbgLevel & ACPI_LV_VALUES))646{647return (AE_OK);648}649650/* If there is an attached object, display it */651652DbgLevel = AcpiDbgLevel;653AcpiDbgLevel = 0;654ObjDesc = AcpiNsGetAttachedObject (ThisNode);655AcpiDbgLevel = DbgLevel;656657/* Dump attached objects */658659while (ObjDesc)660{661ObjType = ACPI_TYPE_INVALID;662AcpiOsPrintf ("Attached Object %p: ", ObjDesc);663664/* Decode the type of attached object and dump the contents */665666switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))667{668case ACPI_DESC_TYPE_NAMED:669670AcpiOsPrintf ("(Ptr to Node)\n");671BytesToDump = sizeof (ACPI_NAMESPACE_NODE);672ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);673break;674675case ACPI_DESC_TYPE_OPERAND:676677ObjType = ObjDesc->Common.Type;678679if (ObjType > ACPI_TYPE_LOCAL_MAX)680{681AcpiOsPrintf (682"(Pointer to ACPI Object type %.2X [UNKNOWN])\n",683ObjType);684685BytesToDump = 32;686}687else688{689AcpiOsPrintf (690"(Pointer to ACPI Object type %.2X [%s])\n",691ObjType, AcpiUtGetTypeName (ObjType));692693BytesToDump = sizeof (ACPI_OPERAND_OBJECT);694}695696ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);697break;698699default:700701break;702}703704/* If value is NOT an internal object, we are done */705706if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)707{708goto Cleanup;709}710711/* Valid object, get the pointer to next level, if any */712713switch (ObjType)714{715case ACPI_TYPE_BUFFER:716case ACPI_TYPE_STRING:717/*718* NOTE: takes advantage of common fields between string/buffer719*/720BytesToDump = ObjDesc->String.Length;721ObjDesc = (void *) ObjDesc->String.Pointer;722723AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n",724ObjDesc, BytesToDump);725ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);726goto Cleanup;727728case ACPI_TYPE_BUFFER_FIELD:729730ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;731break;732733case ACPI_TYPE_PACKAGE:734735ObjDesc = (void *) ObjDesc->Package.Elements;736break;737738case ACPI_TYPE_METHOD:739740ObjDesc = (void *) ObjDesc->Method.AmlStart;741break;742743case ACPI_TYPE_LOCAL_REGION_FIELD:744745ObjDesc = (void *) ObjDesc->Field.RegionObj;746break;747748case ACPI_TYPE_LOCAL_BANK_FIELD:749750ObjDesc = (void *) ObjDesc->BankField.RegionObj;751break;752753case ACPI_TYPE_LOCAL_INDEX_FIELD:754755ObjDesc = (void *) ObjDesc->IndexField.IndexObj;756break;757758default:759760goto Cleanup;761}762}763764Cleanup:765AcpiOsPrintf ("\n");766return (AE_OK);767}768769770/*******************************************************************************771*772* FUNCTION: AcpiNsDumpObjects773*774* PARAMETERS: Type - Object type to be dumped775* DisplayType - 0 or ACPI_DISPLAY_SUMMARY776* MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX777* for an effectively unlimited depth.778* OwnerId - Dump only objects owned by this ID. Use779* ACPI_UINT32_MAX to match all owners.780* StartHandle - Where in namespace to start/end search781*782* RETURN: None783*784* DESCRIPTION: Dump typed objects within the loaded namespace. Uses785* AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.786*787******************************************************************************/788789void790AcpiNsDumpObjects (791ACPI_OBJECT_TYPE Type,792UINT8 DisplayType,793UINT32 MaxDepth,794ACPI_OWNER_ID OwnerId,795ACPI_HANDLE StartHandle)796{797ACPI_WALK_INFO Info;798ACPI_STATUS Status;799800801ACPI_FUNCTION_ENTRY ();802803804/*805* Just lock the entire namespace for the duration of the dump.806* We don't want any changes to the namespace during this time,807* especially the temporary nodes since we are going to display808* them also.809*/810Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);811if (ACPI_FAILURE (Status))812{813AcpiOsPrintf ("Could not acquire namespace mutex\n");814return;815}816817Info.Count = 0;818Info.DebugLevel = ACPI_LV_TABLES;819Info.OwnerId = OwnerId;820Info.DisplayType = DisplayType;821822(void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,823ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,824AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);825826AcpiOsPrintf ("\nNamespace node count: %u\n\n", Info.Count);827(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);828}829830831/*******************************************************************************832*833* FUNCTION: AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth834*835* PARAMETERS: ObjHandle - Node to be dumped836* Level - Nesting level of the handle837* Context - Passed into WalkNamespace838* ReturnValue - Not used839*840* RETURN: Status841*842* DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth843* computes the maximum nesting depth in the namespace tree, in844* order to simplify formatting in AcpiNsDumpOneObjectPath.845* These procedures are UserFunctions called by AcpiNsWalkNamespace.846*847******************************************************************************/848849static ACPI_STATUS850AcpiNsDumpOneObjectPath (851ACPI_HANDLE ObjHandle,852UINT32 Level,853void *Context,854void **ReturnValue)855{856UINT32 MaxLevel = *((UINT32 *) Context);857char *Pathname;858ACPI_NAMESPACE_NODE *Node;859int PathIndent;860861862if (!ObjHandle)863{864return (AE_OK);865}866867Node = AcpiNsValidateHandle (ObjHandle);868if (!Node)869{870/* Ignore bad node during namespace walk */871872return (AE_OK);873}874875Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);876877PathIndent = 1;878if (Level <= MaxLevel)879{880PathIndent = MaxLevel - Level + 1;881}882883AcpiOsPrintf ("%2d%*s%-12s%*s",884Level, Level, " ", AcpiUtGetTypeName (Node->Type),885PathIndent, " ");886887AcpiOsPrintf ("%s\n", &Pathname[1]);888ACPI_FREE (Pathname);889return (AE_OK);890}891892893static ACPI_STATUS894AcpiNsGetMaxDepth (895ACPI_HANDLE ObjHandle,896UINT32 Level,897void *Context,898void **ReturnValue)899{900UINT32 *MaxLevel = (UINT32 *) Context;901902903if (Level > *MaxLevel)904{905*MaxLevel = Level;906}907return (AE_OK);908}909910911/*******************************************************************************912*913* FUNCTION: AcpiNsDumpObjectPaths914*915* PARAMETERS: Type - Object type to be dumped916* DisplayType - 0 or ACPI_DISPLAY_SUMMARY917* MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX918* for an effectively unlimited depth.919* OwnerId - Dump only objects owned by this ID. Use920* ACPI_UINT32_MAX to match all owners.921* StartHandle - Where in namespace to start/end search922*923* RETURN: None924*925* DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses926* AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.927*928******************************************************************************/929930void931AcpiNsDumpObjectPaths (932ACPI_OBJECT_TYPE Type,933UINT8 DisplayType,934UINT32 MaxDepth,935ACPI_OWNER_ID OwnerId,936ACPI_HANDLE StartHandle)937{938ACPI_STATUS Status;939UINT32 MaxLevel = 0;940941942ACPI_FUNCTION_ENTRY ();943944945/*946* Just lock the entire namespace for the duration of the dump.947* We don't want any changes to the namespace during this time,948* especially the temporary nodes since we are going to display949* them also.950*/951Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);952if (ACPI_FAILURE (Status))953{954AcpiOsPrintf ("Could not acquire namespace mutex\n");955return;956}957958/* Get the max depth of the namespace tree, for formatting later */959960(void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,961ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,962AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);963964/* Now dump the entire namespace */965966(void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,967ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,968AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);969970(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);971}972973974/*******************************************************************************975*976* FUNCTION: AcpiNsDumpEntry977*978* PARAMETERS: Handle - Node to be dumped979* DebugLevel - Output level980*981* RETURN: None982*983* DESCRIPTION: Dump a single Node984*985******************************************************************************/986987void988AcpiNsDumpEntry (989ACPI_HANDLE Handle,990UINT32 DebugLevel)991{992ACPI_WALK_INFO Info;993994995ACPI_FUNCTION_ENTRY ();996997998Info.DebugLevel = DebugLevel;999Info.OwnerId = ACPI_OWNER_ID_MAX;1000Info.DisplayType = ACPI_DISPLAY_SUMMARY;10011002(void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);1003}100410051006#ifdef ACPI_ASL_COMPILER1007/*******************************************************************************1008*1009* FUNCTION: AcpiNsDumpTables1010*1011* PARAMETERS: SearchBase - Root of subtree to be dumped, or1012* NS_ALL to dump the entire namespace1013* MaxDepth - Maximum depth of dump. Use INT_MAX1014* for an effectively unlimited depth.1015*1016* RETURN: None1017*1018* DESCRIPTION: Dump the name space, or a portion of it.1019*1020******************************************************************************/10211022void1023AcpiNsDumpTables (1024ACPI_HANDLE SearchBase,1025UINT32 MaxDepth)1026{1027ACPI_HANDLE SearchHandle = SearchBase;102810291030ACPI_FUNCTION_TRACE (NsDumpTables);103110321033if (!AcpiGbl_RootNode)1034{1035/*1036* If the name space has not been initialized,1037* there is nothing to dump.1038*/1039ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,1040"namespace not initialized!\n"));1041return_VOID;1042}10431044if (ACPI_NS_ALL == SearchBase)1045{1046/* Entire namespace */10471048SearchHandle = AcpiGbl_RootNode;1049ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));1050}10511052AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,1053ACPI_OWNER_ID_MAX, SearchHandle);1054return_VOID;1055}1056#endif1057#endif105810591060