Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:03

0001 /******************************************************************************
0002  *
0003  * Module Name: nsdump - table dumping routines for debug
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025 
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code. No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision. In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change. Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee. Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution. In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government. In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************
0116  *
0117  * Alternatively, you may choose to be licensed under the terms of the
0118  * following license:
0119  *
0120  * Redistribution and use in source and binary forms, with or without
0121  * modification, are permitted provided that the following conditions
0122  * are met:
0123  * 1. Redistributions of source code must retain the above copyright
0124  *    notice, this list of conditions, and the following disclaimer,
0125  *    without modification.
0126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0127  *    substantially similar to the "NO WARRANTY" disclaimer below
0128  *    ("Disclaimer") and any redistribution must be conditioned upon
0129  *    including a substantially similar Disclaimer requirement for further
0130  *    binary redistribution.
0131  * 3. Neither the names of the above-listed copyright holders nor the names
0132  *    of any contributors may be used to endorse or promote products derived
0133  *    from this software without specific prior written permission.
0134  *
0135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0146  *
0147  * Alternatively, you may choose to be licensed under the terms of the
0148  * GNU General Public License ("GPL") version 2 as published by the Free
0149  * Software Foundation.
0150  *
0151  *****************************************************************************/
0152 
0153 #include "acpi.h"
0154 #include "accommon.h"
0155 #include "acnamesp.h"
0156 #include "acoutput.h"
0157 
0158 
0159 #define _COMPONENT          ACPI_NAMESPACE
0160         ACPI_MODULE_NAME    ("nsdump")
0161 
0162 /* Local prototypes */
0163 
0164 #ifdef ACPI_OBSOLETE_FUNCTIONS
0165 void
0166 AcpiNsDumpRootDevices (
0167     void);
0168 
0169 static ACPI_STATUS
0170 AcpiNsDumpOneDevice (
0171     ACPI_HANDLE             ObjHandle,
0172     UINT32                  Level,
0173     void                    *Context,
0174     void                    **ReturnValue);
0175 #endif
0176 
0177 
0178 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
0179 
0180 static ACPI_STATUS
0181 AcpiNsDumpOneObjectPath (
0182     ACPI_HANDLE             ObjHandle,
0183     UINT32                  Level,
0184     void                    *Context,
0185     void                    **ReturnValue);
0186 
0187 static ACPI_STATUS
0188 AcpiNsGetMaxDepth (
0189     ACPI_HANDLE             ObjHandle,
0190     UINT32                  Level,
0191     void                    *Context,
0192     void                    **ReturnValue);
0193 
0194 
0195 /*******************************************************************************
0196  *
0197  * FUNCTION:    AcpiNsPrintPathname
0198  *
0199  * PARAMETERS:  NumSegments         - Number of ACPI name segments
0200  *              Pathname            - The compressed (internal) path
0201  *
0202  * RETURN:      None
0203  *
0204  * DESCRIPTION: Print an object's full namespace pathname
0205  *
0206  ******************************************************************************/
0207 
0208 void
0209 AcpiNsPrintPathname (
0210     UINT32                  NumSegments,
0211     const char              *Pathname)
0212 {
0213     UINT32                  i;
0214 
0215 
0216     ACPI_FUNCTION_NAME (NsPrintPathname);
0217 
0218 
0219     /* Check if debug output enabled */
0220 
0221     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
0222     {
0223         return;
0224     }
0225 
0226     /* Print the entire name */
0227 
0228     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
0229 
0230     while (NumSegments)
0231     {
0232         for (i = 0; i < 4; i++)
0233         {
0234             isprint ((int) Pathname[i]) ?
0235                 AcpiOsPrintf ("%c", Pathname[i]) :
0236                 AcpiOsPrintf ("?");
0237         }
0238 
0239         Pathname += ACPI_NAMESEG_SIZE;
0240         NumSegments--;
0241         if (NumSegments)
0242         {
0243             AcpiOsPrintf (".");
0244         }
0245     }
0246 
0247     AcpiOsPrintf ("]\n");
0248 }
0249 
0250 
0251 #ifdef ACPI_OBSOLETE_FUNCTIONS
0252 /* Not used at this time, perhaps later */
0253 
0254 /*******************************************************************************
0255  *
0256  * FUNCTION:    AcpiNsDumpPathname
0257  *
0258  * PARAMETERS:  Handle              - Object
0259  *              Msg                 - Prefix message
0260  *              Level               - Desired debug level
0261  *              Component           - Caller's component ID
0262  *
0263  * RETURN:      None
0264  *
0265  * DESCRIPTION: Print an object's full namespace pathname
0266  *              Manages allocation/freeing of a pathname buffer
0267  *
0268  ******************************************************************************/
0269 
0270 void
0271 AcpiNsDumpPathname (
0272     ACPI_HANDLE             Handle,
0273     const char              *Msg,
0274     UINT32                  Level,
0275     UINT32                  Component)
0276 {
0277 
0278     ACPI_FUNCTION_TRACE (NsDumpPathname);
0279 
0280 
0281     /* Do this only if the requested debug level and component are enabled */
0282 
0283     if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
0284     {
0285         return_VOID;
0286     }
0287 
0288     /* Convert handle to a full pathname and print it (with supplied message) */
0289 
0290     AcpiNsPrintNodePathname (Handle, Msg);
0291     AcpiOsPrintf ("\n");
0292     return_VOID;
0293 }
0294 #endif
0295 
0296 
0297 /*******************************************************************************
0298  *
0299  * FUNCTION:    AcpiNsDumpOneObject
0300  *
0301  * PARAMETERS:  ObjHandle           - Node to be dumped
0302  *              Level               - Nesting level of the handle
0303  *              Context             - Passed into WalkNamespace
0304  *              ReturnValue         - Not used
0305  *
0306  * RETURN:      Status
0307  *
0308  * DESCRIPTION: Dump a single Node
0309  *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
0310  *
0311  ******************************************************************************/
0312 
0313 ACPI_STATUS
0314 AcpiNsDumpOneObject (
0315     ACPI_HANDLE             ObjHandle,
0316     UINT32                  Level,
0317     void                    *Context,
0318     void                    **ReturnValue)
0319 {
0320     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
0321     ACPI_NAMESPACE_NODE     *ThisNode;
0322     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
0323     ACPI_OBJECT_TYPE        ObjType;
0324     ACPI_OBJECT_TYPE        Type;
0325     UINT32                  BytesToDump;
0326     UINT32                  DbgLevel;
0327     UINT32                  i;
0328 
0329 
0330     ACPI_FUNCTION_NAME (NsDumpOneObject);
0331 
0332 
0333     /* Is output enabled? */
0334 
0335     if (!(AcpiDbgLevel & Info->DebugLevel))
0336     {
0337         return (AE_OK);
0338     }
0339 
0340     if (!ObjHandle)
0341     {
0342         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
0343         return (AE_OK);
0344     }
0345 
0346     ThisNode = AcpiNsValidateHandle (ObjHandle);
0347     if (!ThisNode)
0348     {
0349         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
0350             ObjHandle));
0351         return (AE_OK);
0352     }
0353 
0354     Type = ThisNode->Type;
0355     Info->Count++;
0356 
0357     /* Check if the owner matches */
0358 
0359     if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
0360         (Info->OwnerId != ThisNode->OwnerId))
0361     {
0362         return (AE_OK);
0363     }
0364 
0365     if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
0366     {
0367         /* Indent the object according to the level */
0368 
0369         AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
0370 
0371         /* Check the node type and name */
0372 
0373         if (Type > ACPI_TYPE_LOCAL_MAX)
0374         {
0375             ACPI_WARNING ((AE_INFO,
0376                 "Invalid ACPI Object Type 0x%08X", Type));
0377         }
0378 
0379         AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
0380     }
0381 
0382     /* Now we can print out the pertinent information */
0383 
0384     AcpiOsPrintf (" %-12s %p %3.3X ",
0385         AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
0386 
0387     DbgLevel = AcpiDbgLevel;
0388     AcpiDbgLevel = 0;
0389     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
0390     AcpiDbgLevel = DbgLevel;
0391 
0392     /* Temp nodes are those nodes created by a control method */
0393 
0394     if (ThisNode->Flags & ANOBJ_TEMPORARY)
0395     {
0396         AcpiOsPrintf ("(T) ");
0397     }
0398 
0399     switch (Info->DisplayType & ACPI_DISPLAY_MASK)
0400     {
0401     case ACPI_DISPLAY_SUMMARY:
0402 
0403         if (!ObjDesc)
0404         {
0405             /* No attached object. Some types should always have an object */
0406 
0407             switch (Type)
0408             {
0409             case ACPI_TYPE_INTEGER:
0410             case ACPI_TYPE_PACKAGE:
0411             case ACPI_TYPE_BUFFER:
0412             case ACPI_TYPE_STRING:
0413             case ACPI_TYPE_METHOD:
0414 
0415                 AcpiOsPrintf ("<No attached object>");
0416                 break;
0417 
0418             default:
0419 
0420                 break;
0421             }
0422 
0423             AcpiOsPrintf ("\n");
0424             return (AE_OK);
0425         }
0426 
0427         switch (Type)
0428         {
0429         case ACPI_TYPE_PROCESSOR:
0430 
0431             AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",
0432                 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
0433                 ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));
0434             break;
0435 
0436         case ACPI_TYPE_DEVICE:
0437 
0438             AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
0439             break;
0440 
0441         case ACPI_TYPE_METHOD:
0442 
0443             AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
0444                 (UINT32) ObjDesc->Method.ParamCount,
0445                 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
0446             break;
0447 
0448         case ACPI_TYPE_INTEGER:
0449 
0450             AcpiOsPrintf ("= %8.8X%8.8X\n",
0451                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
0452             break;
0453 
0454         case ACPI_TYPE_PACKAGE:
0455 
0456             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
0457             {
0458                 AcpiOsPrintf ("Elements %.2X\n",
0459                     ObjDesc->Package.Count);
0460             }
0461             else
0462             {
0463                 AcpiOsPrintf ("[Length not yet evaluated]\n");
0464             }
0465             break;
0466 
0467         case ACPI_TYPE_BUFFER:
0468 
0469             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
0470             {
0471                 AcpiOsPrintf ("Len %.2X",
0472                     ObjDesc->Buffer.Length);
0473 
0474                 /* Dump some of the buffer */
0475 
0476                 if (ObjDesc->Buffer.Length > 0)
0477                 {
0478                     AcpiOsPrintf (" =");
0479                     for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
0480                     {
0481                         AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
0482                     }
0483                 }
0484                 AcpiOsPrintf ("\n");
0485             }
0486             else
0487             {
0488                 AcpiOsPrintf ("[Length not yet evaluated]\n");
0489             }
0490             break;
0491 
0492         case ACPI_TYPE_STRING:
0493 
0494             AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
0495             AcpiUtPrintString (ObjDesc->String.Pointer, 80);
0496             AcpiOsPrintf ("\n");
0497             break;
0498 
0499         case ACPI_TYPE_REGION:
0500 
0501             AcpiOsPrintf ("[%s]",
0502                 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
0503             if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
0504             {
0505                 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
0506                     ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
0507                     ObjDesc->Region.Length);
0508             }
0509             else
0510             {
0511                 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
0512             }
0513             break;
0514 
0515         case ACPI_TYPE_LOCAL_REFERENCE:
0516 
0517             AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
0518             break;
0519 
0520         case ACPI_TYPE_BUFFER_FIELD:
0521 
0522             if (ObjDesc->BufferField.BufferObj &&
0523                 ObjDesc->BufferField.BufferObj->Buffer.Node)
0524             {
0525                 AcpiOsPrintf ("Buf [%4.4s]",
0526                     AcpiUtGetNodeName (
0527                         ObjDesc->BufferField.BufferObj->Buffer.Node));
0528             }
0529             break;
0530 
0531         case ACPI_TYPE_LOCAL_REGION_FIELD:
0532 
0533             AcpiOsPrintf ("Rgn [%4.4s]",
0534                 AcpiUtGetNodeName (
0535                     ObjDesc->CommonField.RegionObj->Region.Node));
0536             break;
0537 
0538         case ACPI_TYPE_LOCAL_BANK_FIELD:
0539 
0540             AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
0541                 AcpiUtGetNodeName (
0542                     ObjDesc->CommonField.RegionObj->Region.Node),
0543                 AcpiUtGetNodeName (
0544                     ObjDesc->BankField.BankObj->CommonField.Node));
0545             break;
0546 
0547         case ACPI_TYPE_LOCAL_INDEX_FIELD:
0548 
0549             AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
0550                 AcpiUtGetNodeName (
0551                     ObjDesc->IndexField.IndexObj->CommonField.Node),
0552                 AcpiUtGetNodeName (
0553                     ObjDesc->IndexField.DataObj->CommonField.Node));
0554             break;
0555 
0556         case ACPI_TYPE_LOCAL_ALIAS:
0557         case ACPI_TYPE_LOCAL_METHOD_ALIAS:
0558 
0559             AcpiOsPrintf ("Target %4.4s (%p)\n",
0560                 AcpiUtGetNodeName (ObjDesc), ObjDesc);
0561             break;
0562 
0563         default:
0564 
0565             AcpiOsPrintf ("Object %p\n", ObjDesc);
0566             break;
0567         }
0568 
0569         /* Common field handling */
0570 
0571         switch (Type)
0572         {
0573         case ACPI_TYPE_BUFFER_FIELD:
0574         case ACPI_TYPE_LOCAL_REGION_FIELD:
0575         case ACPI_TYPE_LOCAL_BANK_FIELD:
0576         case ACPI_TYPE_LOCAL_INDEX_FIELD:
0577 
0578             AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2X\n",
0579                 (ObjDesc->CommonField.BaseByteOffset * 8)
0580                     + ObjDesc->CommonField.StartFieldBitOffset,
0581                 ObjDesc->CommonField.BitLength,
0582                 ObjDesc->CommonField.AccessByteWidth);
0583             break;
0584 
0585         default:
0586 
0587             break;
0588         }
0589         break;
0590 
0591     case ACPI_DISPLAY_OBJECTS:
0592 
0593         AcpiOsPrintf ("O:%p", ObjDesc);
0594         if (!ObjDesc)
0595         {
0596             /* No attached object, we are done */
0597 
0598             AcpiOsPrintf ("\n");
0599             return (AE_OK);
0600         }
0601 
0602         AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
0603 
0604         switch (Type)
0605         {
0606         case ACPI_TYPE_METHOD:
0607 
0608             /* Name is a Method and its AML offset/length are set */
0609 
0610             AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
0611                 ObjDesc->Method.AmlLength);
0612             break;
0613 
0614         case ACPI_TYPE_INTEGER:
0615 
0616             AcpiOsPrintf (" I:%8.8X8.8%X\n",
0617                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
0618             break;
0619 
0620         case ACPI_TYPE_STRING:
0621 
0622             AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
0623                 ObjDesc->String.Length);
0624             break;
0625 
0626         case ACPI_TYPE_BUFFER:
0627 
0628             AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
0629                 ObjDesc->Buffer.Length);
0630             break;
0631 
0632         default:
0633 
0634             AcpiOsPrintf ("\n");
0635             break;
0636         }
0637         break;
0638 
0639     default:
0640         AcpiOsPrintf ("\n");
0641         break;
0642     }
0643 
0644     /* If debug turned off, done */
0645 
0646     if (!(AcpiDbgLevel & ACPI_LV_VALUES))
0647     {
0648         return (AE_OK);
0649     }
0650 
0651     /* If there is an attached object, display it */
0652 
0653     DbgLevel = AcpiDbgLevel;
0654     AcpiDbgLevel = 0;
0655     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
0656     AcpiDbgLevel = DbgLevel;
0657 
0658     /* Dump attached objects */
0659 
0660     while (ObjDesc)
0661     {
0662         ObjType = ACPI_TYPE_INVALID;
0663         AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
0664 
0665         /* Decode the type of attached object and dump the contents */
0666 
0667         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
0668         {
0669         case ACPI_DESC_TYPE_NAMED:
0670 
0671             AcpiOsPrintf ("(Ptr to Node)\n");
0672             BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
0673             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
0674             break;
0675 
0676         case ACPI_DESC_TYPE_OPERAND:
0677 
0678             ObjType = ObjDesc->Common.Type;
0679 
0680             if (ObjType > ACPI_TYPE_LOCAL_MAX)
0681             {
0682                 AcpiOsPrintf (
0683                     "(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
0684                     ObjType);
0685 
0686                 BytesToDump = 32;
0687             }
0688             else
0689             {
0690                 AcpiOsPrintf (
0691                     "(Pointer to ACPI Object type %.2X [%s])\n",
0692                     ObjType, AcpiUtGetTypeName (ObjType));
0693 
0694                 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
0695             }
0696 
0697             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
0698             break;
0699 
0700         default:
0701 
0702             break;
0703         }
0704 
0705         /* If value is NOT an internal object, we are done */
0706 
0707         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
0708         {
0709             goto Cleanup;
0710         }
0711 
0712         /* Valid object, get the pointer to next level, if any */
0713 
0714         switch (ObjType)
0715         {
0716         case ACPI_TYPE_BUFFER:
0717         case ACPI_TYPE_STRING:
0718             /*
0719              * NOTE: takes advantage of common fields between string/buffer
0720              */
0721             BytesToDump = ObjDesc->String.Length;
0722             ObjDesc = (void *) ObjDesc->String.Pointer;
0723 
0724             AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n",
0725                 ObjDesc, BytesToDump);
0726             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
0727             goto Cleanup;
0728 
0729         case ACPI_TYPE_BUFFER_FIELD:
0730 
0731             ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
0732             break;
0733 
0734         case ACPI_TYPE_PACKAGE:
0735 
0736             ObjDesc = (void *) ObjDesc->Package.Elements;
0737             break;
0738 
0739         case ACPI_TYPE_METHOD:
0740 
0741             ObjDesc = (void *) ObjDesc->Method.AmlStart;
0742             break;
0743 
0744         case ACPI_TYPE_LOCAL_REGION_FIELD:
0745 
0746             ObjDesc = (void *) ObjDesc->Field.RegionObj;
0747             break;
0748 
0749         case ACPI_TYPE_LOCAL_BANK_FIELD:
0750 
0751             ObjDesc = (void *) ObjDesc->BankField.RegionObj;
0752             break;
0753 
0754         case ACPI_TYPE_LOCAL_INDEX_FIELD:
0755 
0756             ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
0757             break;
0758 
0759         default:
0760 
0761             goto Cleanup;
0762         }
0763     }
0764 
0765 Cleanup:
0766     AcpiOsPrintf ("\n");
0767     return (AE_OK);
0768 }
0769 
0770 
0771 /*******************************************************************************
0772  *
0773  * FUNCTION:    AcpiNsDumpObjects
0774  *
0775  * PARAMETERS:  Type                - Object type to be dumped
0776  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
0777  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
0778  *                                    for an effectively unlimited depth.
0779  *              OwnerId             - Dump only objects owned by this ID. Use
0780  *                                    ACPI_UINT32_MAX to match all owners.
0781  *              StartHandle         - Where in namespace to start/end search
0782  *
0783  * RETURN:      None
0784  *
0785  * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
0786  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
0787  *
0788  ******************************************************************************/
0789 
0790 void
0791 AcpiNsDumpObjects (
0792     ACPI_OBJECT_TYPE        Type,
0793     UINT8                   DisplayType,
0794     UINT32                  MaxDepth,
0795     ACPI_OWNER_ID           OwnerId,
0796     ACPI_HANDLE             StartHandle)
0797 {
0798     ACPI_WALK_INFO          Info;
0799     ACPI_STATUS             Status;
0800 
0801 
0802     ACPI_FUNCTION_ENTRY ();
0803 
0804 
0805     /*
0806      * Just lock the entire namespace for the duration of the dump.
0807      * We don't want any changes to the namespace during this time,
0808      * especially the temporary nodes since we are going to display
0809      * them also.
0810      */
0811     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
0812     if (ACPI_FAILURE (Status))
0813     {
0814         AcpiOsPrintf ("Could not acquire namespace mutex\n");
0815         return;
0816     }
0817 
0818     Info.Count = 0;
0819     Info.DebugLevel = ACPI_LV_TABLES;
0820     Info.OwnerId = OwnerId;
0821     Info.DisplayType = DisplayType;
0822 
0823     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
0824         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
0825         AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
0826 
0827     AcpiOsPrintf ("\nNamespace node count: %u\n\n", Info.Count);
0828     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
0829 }
0830 
0831 
0832 /*******************************************************************************
0833  *
0834  * FUNCTION:    AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
0835  *
0836  * PARAMETERS:  ObjHandle           - Node to be dumped
0837  *              Level               - Nesting level of the handle
0838  *              Context             - Passed into WalkNamespace
0839  *              ReturnValue         - Not used
0840  *
0841  * RETURN:      Status
0842  *
0843  * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
0844  *              computes the maximum nesting depth in the namespace tree, in
0845  *              order to simplify formatting in AcpiNsDumpOneObjectPath.
0846  *              These procedures are UserFunctions called by AcpiNsWalkNamespace.
0847  *
0848  ******************************************************************************/
0849 
0850 static ACPI_STATUS
0851 AcpiNsDumpOneObjectPath (
0852     ACPI_HANDLE             ObjHandle,
0853     UINT32                  Level,
0854     void                    *Context,
0855     void                    **ReturnValue)
0856 {
0857     UINT32                  MaxLevel = *((UINT32 *) Context);
0858     char                    *Pathname;
0859     ACPI_NAMESPACE_NODE     *Node;
0860     int                     PathIndent;
0861 
0862 
0863     if (!ObjHandle)
0864     {
0865         return (AE_OK);
0866     }
0867 
0868     Node = AcpiNsValidateHandle (ObjHandle);
0869     if (!Node)
0870     {
0871         /* Ignore bad node during namespace walk */
0872 
0873         return (AE_OK);
0874     }
0875 
0876     Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
0877 
0878     PathIndent = 1;
0879     if (Level <= MaxLevel)
0880     {
0881         PathIndent = MaxLevel - Level + 1;
0882     }
0883 
0884     AcpiOsPrintf ("%2d%*s%-12s%*s",
0885         Level, Level, " ", AcpiUtGetTypeName (Node->Type),
0886         PathIndent, " ");
0887 
0888     AcpiOsPrintf ("%s\n", &Pathname[1]);
0889     ACPI_FREE (Pathname);
0890     return (AE_OK);
0891 }
0892 
0893 
0894 static ACPI_STATUS
0895 AcpiNsGetMaxDepth (
0896     ACPI_HANDLE             ObjHandle,
0897     UINT32                  Level,
0898     void                    *Context,
0899     void                    **ReturnValue)
0900 {
0901     UINT32                  *MaxLevel = (UINT32 *) Context;
0902 
0903 
0904     if (Level > *MaxLevel)
0905     {
0906         *MaxLevel = Level;
0907     }
0908     return (AE_OK);
0909 }
0910 
0911 
0912 /*******************************************************************************
0913  *
0914  * FUNCTION:    AcpiNsDumpObjectPaths
0915  *
0916  * PARAMETERS:  Type                - Object type to be dumped
0917  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
0918  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
0919  *                                    for an effectively unlimited depth.
0920  *              OwnerId             - Dump only objects owned by this ID. Use
0921  *                                    ACPI_UINT32_MAX to match all owners.
0922  *              StartHandle         - Where in namespace to start/end search
0923  *
0924  * RETURN:      None
0925  *
0926  * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
0927  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
0928  *
0929  ******************************************************************************/
0930 
0931 void
0932 AcpiNsDumpObjectPaths (
0933     ACPI_OBJECT_TYPE        Type,
0934     UINT8                   DisplayType,
0935     UINT32                  MaxDepth,
0936     ACPI_OWNER_ID           OwnerId,
0937     ACPI_HANDLE             StartHandle)
0938 {
0939     ACPI_STATUS             Status;
0940     UINT32                  MaxLevel = 0;
0941 
0942 
0943     ACPI_FUNCTION_ENTRY ();
0944 
0945 
0946     /*
0947      * Just lock the entire namespace for the duration of the dump.
0948      * We don't want any changes to the namespace during this time,
0949      * especially the temporary nodes since we are going to display
0950      * them also.
0951      */
0952     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
0953     if (ACPI_FAILURE (Status))
0954     {
0955         AcpiOsPrintf ("Could not acquire namespace mutex\n");
0956         return;
0957     }
0958 
0959     /* Get the max depth of the namespace tree, for formatting later */
0960 
0961     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
0962         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
0963         AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
0964 
0965     /* Now dump the entire namespace */
0966 
0967     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
0968         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
0969         AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
0970 
0971     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
0972 }
0973 
0974 
0975 /*******************************************************************************
0976  *
0977  * FUNCTION:    AcpiNsDumpEntry
0978  *
0979  * PARAMETERS:  Handle              - Node to be dumped
0980  *              DebugLevel          - Output level
0981  *
0982  * RETURN:      None
0983  *
0984  * DESCRIPTION: Dump a single Node
0985  *
0986  ******************************************************************************/
0987 
0988 void
0989 AcpiNsDumpEntry (
0990     ACPI_HANDLE             Handle,
0991     UINT32                  DebugLevel)
0992 {
0993     ACPI_WALK_INFO          Info;
0994 
0995 
0996     ACPI_FUNCTION_ENTRY ();
0997 
0998 
0999     Info.DebugLevel = DebugLevel;
1000     Info.OwnerId = ACPI_OWNER_ID_MAX;
1001     Info.DisplayType = ACPI_DISPLAY_SUMMARY;
1002 
1003     (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
1004 }
1005 
1006 
1007 #ifdef ACPI_ASL_COMPILER
1008 /*******************************************************************************
1009  *
1010  * FUNCTION:    AcpiNsDumpTables
1011  *
1012  * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
1013  *                                    NS_ALL to dump the entire namespace
1014  *              MaxDepth            - Maximum depth of dump. Use INT_MAX
1015  *                                    for an effectively unlimited depth.
1016  *
1017  * RETURN:      None
1018  *
1019  * DESCRIPTION: Dump the name space, or a portion of it.
1020  *
1021  ******************************************************************************/
1022 
1023 void
1024 AcpiNsDumpTables (
1025     ACPI_HANDLE             SearchBase,
1026     UINT32                  MaxDepth)
1027 {
1028     ACPI_HANDLE             SearchHandle = SearchBase;
1029 
1030 
1031     ACPI_FUNCTION_TRACE (NsDumpTables);
1032 
1033 
1034     if (!AcpiGbl_RootNode)
1035     {
1036         /*
1037          * If the name space has not been initialized,
1038          * there is nothing to dump.
1039          */
1040         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
1041             "namespace not initialized!\n"));
1042         return_VOID;
1043     }
1044 
1045     if (ACPI_NS_ALL == SearchBase)
1046     {
1047         /* Entire namespace */
1048 
1049         SearchHandle = AcpiGbl_RootNode;
1050         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
1051     }
1052 
1053     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
1054         ACPI_OWNER_ID_MAX, SearchHandle);
1055     return_VOID;
1056 }
1057 #endif
1058 #endif