Home | History | Annotate | Line # | Download | only in compiler
aslmapoutput.c revision 1.1.1.1
      1  1.1  christos /******************************************************************************
      2  1.1  christos  *
      3  1.1  christos  * Module Name: aslmapoutput - Output/emit the resource descriptor/device maps
      4  1.1  christos  *
      5  1.1  christos  *****************************************************************************/
      6  1.1  christos 
      7  1.1  christos /*
      8  1.1  christos  * Copyright (C) 2000 - 2014, Intel Corp.
      9  1.1  christos  * All rights reserved.
     10  1.1  christos  *
     11  1.1  christos  * Redistribution and use in source and binary forms, with or without
     12  1.1  christos  * modification, are permitted provided that the following conditions
     13  1.1  christos  * are met:
     14  1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15  1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16  1.1  christos  *    without modification.
     17  1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21  1.1  christos  *    binary redistribution.
     22  1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24  1.1  christos  *    from this software without specific prior written permission.
     25  1.1  christos  *
     26  1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27  1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1  christos  * Software Foundation.
     29  1.1  christos  *
     30  1.1  christos  * NO WARRANTY
     31  1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1  christos  */
     43  1.1  christos 
     44  1.1  christos #include "acpi.h"
     45  1.1  christos #include "accommon.h"
     46  1.1  christos #include "acapps.h"
     47  1.1  christos #include "aslcompiler.h"
     48  1.1  christos #include "aslcompiler.y.h"
     49  1.1  christos #include "acinterp.h"
     50  1.1  christos #include "acparser.h"
     51  1.1  christos #include "acnamesp.h"
     52  1.1  christos #include "amlcode.h"
     53  1.1  christos 
     54  1.1  christos /* This module used for application-level code only */
     55  1.1  christos 
     56  1.1  christos #define _COMPONENT          ACPI_COMPILER
     57  1.1  christos         ACPI_MODULE_NAME    ("aslmapoutput")
     58  1.1  christos 
     59  1.1  christos /* Local prototypes */
     60  1.1  christos 
     61  1.1  christos static void
     62  1.1  christos MpEmitGpioInfo (
     63  1.1  christos     void);
     64  1.1  christos 
     65  1.1  christos static void
     66  1.1  christos MpEmitSerialInfo (
     67  1.1  christos     void);
     68  1.1  christos 
     69  1.1  christos static void
     70  1.1  christos MpEmitDeviceTree (
     71  1.1  christos     void);
     72  1.1  christos 
     73  1.1  christos static ACPI_STATUS
     74  1.1  christos MpEmitOneDevice (
     75  1.1  christos     ACPI_HANDLE             ObjHandle,
     76  1.1  christos     UINT32                  NestingLevel,
     77  1.1  christos     void                    *Context,
     78  1.1  christos     void                    **ReturnValue);
     79  1.1  christos 
     80  1.1  christos static void
     81  1.1  christos MpXrefDevices (
     82  1.1  christos     ACPI_GPIO_INFO          *Info);
     83  1.1  christos 
     84  1.1  christos static ACPI_STATUS
     85  1.1  christos MpNamespaceXrefBegin (
     86  1.1  christos     ACPI_PARSE_OBJECT       *Op,
     87  1.1  christos     UINT32                  Level,
     88  1.1  christos     void                    *Context);
     89  1.1  christos 
     90  1.1  christos 
     91  1.1  christos /* Strings used to decode flag bits */
     92  1.1  christos 
     93  1.1  christos const char                  *DirectionDecode[] =
     94  1.1  christos {
     95  1.1  christos     "Both I/O   ",
     96  1.1  christos     "InputOnly  ",
     97  1.1  christos     "OutputOnly ",
     98  1.1  christos     "Preserve   "
     99  1.1  christos };
    100  1.1  christos 
    101  1.1  christos const char                  *PolarityDecode[] =
    102  1.1  christos {
    103  1.1  christos     "ActiveHigh",
    104  1.1  christos     "ActiveLow ",
    105  1.1  christos     "ActiveBoth",
    106  1.1  christos     "Reserved  "
    107  1.1  christos };
    108  1.1  christos 
    109  1.1  christos 
    110  1.1  christos /*******************************************************************************
    111  1.1  christos  *
    112  1.1  christos  * FUNCTION:    MpEmitMappingInfo
    113  1.1  christos  *
    114  1.1  christos  * PARAMETERS:  None
    115  1.1  christos  *
    116  1.1  christos  * RETURN:      None
    117  1.1  christos  *
    118  1.1  christos  * DESCRIPTION: External interface.
    119  1.1  christos  *              Create and open the mapfile and emit all of the collected
    120  1.1  christos  *              hardware mapping information. Includes: GPIO information,
    121  1.1  christos  *              Serial information, and a dump of the entire ACPI device tree.
    122  1.1  christos  *
    123  1.1  christos  ******************************************************************************/
    124  1.1  christos 
    125  1.1  christos void
    126  1.1  christos MpEmitMappingInfo (
    127  1.1  christos     void)
    128  1.1  christos {
    129  1.1  christos     char                    *NewFilename;
    130  1.1  christos 
    131  1.1  christos 
    132  1.1  christos     /* Mapfile option enabled? */
    133  1.1  christos 
    134  1.1  christos     if (!Gbl_MapfileFlag)
    135  1.1  christos     {
    136  1.1  christos         return;
    137  1.1  christos     }
    138  1.1  christos 
    139  1.1  christos     /* Create/Open a map file */
    140  1.1  christos 
    141  1.1  christos     NewFilename = FlGenerateFilename (Gbl_OutputFilenamePrefix,
    142  1.1  christos         FILE_SUFFIX_MAP);
    143  1.1  christos     if (!NewFilename)
    144  1.1  christos     {
    145  1.1  christos         AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    146  1.1  christos             0, 0, 0, 0, NULL, NULL);
    147  1.1  christos     }
    148  1.1  christos 
    149  1.1  christos     /* Open the hex file, text mode (closed at compiler exit) */
    150  1.1  christos 
    151  1.1  christos     FlOpenFile (ASL_FILE_MAP_OUTPUT, NewFilename, "w+t");
    152  1.1  christos     AslCompilerSignon (ASL_FILE_MAP_OUTPUT);
    153  1.1  christos     AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT);
    154  1.1  christos 
    155  1.1  christos     if (!Gbl_GpioList)
    156  1.1  christos     {
    157  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT,
    158  1.1  christos             "\nNo GPIO devices found\n");
    159  1.1  christos     }
    160  1.1  christos 
    161  1.1  christos     if (!Gbl_SerialList)
    162  1.1  christos     {
    163  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT,
    164  1.1  christos             "\nNo Serial devices found (I2C/SPI/UART)\n");
    165  1.1  christos     }
    166  1.1  christos 
    167  1.1  christos     if (!Gbl_GpioList && !Gbl_SerialList)
    168  1.1  christos     {
    169  1.1  christos         return;
    170  1.1  christos     }
    171  1.1  christos 
    172  1.1  christos     /* Headers */
    173  1.1  christos 
    174  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "\nResource Descriptor Connectivity Map\n");
    175  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT,   "------------------------------------\n");
    176  1.1  christos 
    177  1.1  christos     /* Emit GPIO and Serial descriptors, then entire ACPI device tree */
    178  1.1  christos 
    179  1.1  christos     MpEmitGpioInfo ();
    180  1.1  christos     MpEmitSerialInfo ();
    181  1.1  christos     MpEmitDeviceTree ();
    182  1.1  christos 
    183  1.1  christos     /* Clear the lists - no need to free memory here */
    184  1.1  christos 
    185  1.1  christos     Gbl_SerialList = NULL;
    186  1.1  christos     Gbl_GpioList = NULL;
    187  1.1  christos }
    188  1.1  christos 
    189  1.1  christos 
    190  1.1  christos /*******************************************************************************
    191  1.1  christos  *
    192  1.1  christos  * FUNCTION:    MpEmitGpioInfo
    193  1.1  christos  *
    194  1.1  christos  * PARAMETERS:  None
    195  1.1  christos  *
    196  1.1  christos  * RETURN:      None
    197  1.1  christos  *
    198  1.1  christos  * DESCRIPTION: Emit the info about all GPIO devices found during the
    199  1.1  christos  *              compile or disassembly.
    200  1.1  christos  *
    201  1.1  christos  ******************************************************************************/
    202  1.1  christos 
    203  1.1  christos static void
    204  1.1  christos MpEmitGpioInfo (
    205  1.1  christos     void)
    206  1.1  christos {
    207  1.1  christos     ACPI_GPIO_INFO          *Info;
    208  1.1  christos     char                    *Type;
    209  1.1  christos     char                    *PrevDeviceName = NULL;
    210  1.1  christos     const char              *Direction;
    211  1.1  christos     const char              *Polarity;
    212  1.1  christos     char                    *ParentPathname;
    213  1.1  christos     const char              *Description;
    214  1.1  christos     char                    *HidString;
    215  1.1  christos     const AH_DEVICE_ID      *HidInfo;
    216  1.1  christos 
    217  1.1  christos 
    218  1.1  christos     /* Walk the GPIO descriptor list */
    219  1.1  christos 
    220  1.1  christos     Info = Gbl_GpioList;
    221  1.1  christos     while (Info)
    222  1.1  christos     {
    223  1.1  christos         HidString = MpGetHidViaNamestring (Info->DeviceName);
    224  1.1  christos 
    225  1.1  christos         /* Print header info for the controller itself */
    226  1.1  christos 
    227  1.1  christos         if (!PrevDeviceName ||
    228  1.1  christos             ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
    229  1.1  christos         {
    230  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT,
    231  1.1  christos                 "\n\nGPIO Controller:  %-8s  %-28s",
    232  1.1  christos                 HidString, Info->DeviceName);
    233  1.1  christos 
    234  1.1  christos             HidInfo = AcpiAhMatchHardwareId (HidString);
    235  1.1  christos             if (HidInfo)
    236  1.1  christos             {
    237  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s",
    238  1.1  christos                     HidInfo->Description);
    239  1.1  christos             }
    240  1.1  christos 
    241  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT,
    242  1.1  christos                 "\n\nPin   Type     Direction    Polarity"
    243  1.1  christos                 "    Dest _HID  Destination\n");
    244  1.1  christos         }
    245  1.1  christos 
    246  1.1  christos         PrevDeviceName = Info->DeviceName;
    247  1.1  christos 
    248  1.1  christos         /* Setup various strings based upon the type (GpioInt or GpioIo) */
    249  1.1  christos 
    250  1.1  christos         switch (Info->Type)
    251  1.1  christos         {
    252  1.1  christos         case AML_RESOURCE_GPIO_TYPE_INT:
    253  1.1  christos 
    254  1.1  christos             Type = "GpioInt";
    255  1.1  christos             Direction = "-Interrupt-";
    256  1.1  christos             Polarity = PolarityDecode[Info->Polarity];
    257  1.1  christos             break;
    258  1.1  christos 
    259  1.1  christos         case AML_RESOURCE_GPIO_TYPE_IO:
    260  1.1  christos 
    261  1.1  christos             Type = "GpioIo ";
    262  1.1  christos             Direction = DirectionDecode[Info->Direction];
    263  1.1  christos             Polarity = "          ";
    264  1.1  christos             break;
    265  1.1  christos 
    266  1.1  christos         default:
    267  1.1  christos             continue;
    268  1.1  christos         }
    269  1.1  christos 
    270  1.1  christos         /* Emit the GPIO info */
    271  1.1  christos 
    272  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "%4.4X  %s  %s  %s  ",
    273  1.1  christos             Info->PinNumber, Type, Direction, Polarity);
    274  1.1  christos 
    275  1.1  christos         ParentPathname = NULL;
    276  1.1  christos         HidString = MpGetConnectionInfo (Info->Op, Info->PinIndex,
    277  1.1  christos             &Info->TargetNode, &ParentPathname);
    278  1.1  christos         if (HidString)
    279  1.1  christos         {
    280  1.1  christos             /*
    281  1.1  christos              * This is a Connection() field
    282  1.1  christos              * Attempt to find all references to the field.
    283  1.1  christos              */
    284  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s   %-28s",
    285  1.1  christos                 HidString, ParentPathname);
    286  1.1  christos 
    287  1.1  christos             MpXrefDevices (Info);
    288  1.1  christos         }
    289  1.1  christos         else
    290  1.1  christos         {
    291  1.1  christos             /*
    292  1.1  christos              * For Devices, attempt to get the _HID description string.
    293  1.1  christos              * Failing that (many _HIDs are not recognized), attempt to
    294  1.1  christos              * get the _DDN description string.
    295  1.1  christos              */
    296  1.1  christos             HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
    297  1.1  christos                 &ParentPathname);
    298  1.1  christos 
    299  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s   %-28s",
    300  1.1  christos                 HidString, ParentPathname);
    301  1.1  christos 
    302  1.1  christos             /* Get the _HID description or _DDN string */
    303  1.1  christos 
    304  1.1  christos             HidInfo = AcpiAhMatchHardwareId (HidString);
    305  1.1  christos             if (HidInfo)
    306  1.1  christos             {
    307  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s",
    308  1.1  christos                     HidInfo->Description);
    309  1.1  christos             }
    310  1.1  christos             else if ((Description = MpGetDdnValue (ParentPathname)))
    311  1.1  christos             {
    312  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s (_DDN)",
    313  1.1  christos                     Description);
    314  1.1  christos             }
    315  1.1  christos         }
    316  1.1  christos 
    317  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
    318  1.1  christos         ACPI_FREE (ParentPathname);
    319  1.1  christos         Info = Info->Next;
    320  1.1  christos     }
    321  1.1  christos }
    322  1.1  christos 
    323  1.1  christos 
    324  1.1  christos /*******************************************************************************
    325  1.1  christos  *
    326  1.1  christos  * FUNCTION:    MpEmitSerialInfo
    327  1.1  christos  *
    328  1.1  christos  * PARAMETERS:  None
    329  1.1  christos  *
    330  1.1  christos  * RETURN:      None
    331  1.1  christos  *
    332  1.1  christos  * DESCRIPTION: Emit the info about all Serial devices found during the
    333  1.1  christos  *              compile or disassembly.
    334  1.1  christos  *
    335  1.1  christos  ******************************************************************************/
    336  1.1  christos 
    337  1.1  christos static void
    338  1.1  christos MpEmitSerialInfo (
    339  1.1  christos     void)
    340  1.1  christos {
    341  1.1  christos     ACPI_SERIAL_INFO        *Info;
    342  1.1  christos     char                    *Type;
    343  1.1  christos     char                    *ParentPathname;
    344  1.1  christos     char                    *PrevDeviceName = NULL;
    345  1.1  christos     char                    *HidString;
    346  1.1  christos     const AH_DEVICE_ID      *HidInfo;
    347  1.1  christos     const char              *Description;
    348  1.1  christos     AML_RESOURCE            *Resource;
    349  1.1  christos 
    350  1.1  christos 
    351  1.1  christos     /* Walk the constructed serial descriptor list */
    352  1.1  christos 
    353  1.1  christos     Info = Gbl_SerialList;
    354  1.1  christos     while (Info)
    355  1.1  christos     {
    356  1.1  christos         Resource = Info->Resource;
    357  1.1  christos         switch (Resource->CommonSerialBus.Type)
    358  1.1  christos         {
    359  1.1  christos         case AML_RESOURCE_I2C_SERIALBUSTYPE:
    360  1.1  christos             Type = "I2C ";
    361  1.1  christos             break;
    362  1.1  christos 
    363  1.1  christos         case AML_RESOURCE_SPI_SERIALBUSTYPE:
    364  1.1  christos             Type = "SPI ";
    365  1.1  christos             break;
    366  1.1  christos 
    367  1.1  christos         case AML_RESOURCE_UART_SERIALBUSTYPE:
    368  1.1  christos             Type = "UART";
    369  1.1  christos             break;
    370  1.1  christos 
    371  1.1  christos         default:
    372  1.1  christos             Type = "UNKN";
    373  1.1  christos             break;
    374  1.1  christos         }
    375  1.1  christos 
    376  1.1  christos         HidString = MpGetHidViaNamestring (Info->DeviceName);
    377  1.1  christos 
    378  1.1  christos         /* Print header info for the controller itself */
    379  1.1  christos 
    380  1.1  christos         if (!PrevDeviceName ||
    381  1.1  christos             ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
    382  1.1  christos         {
    383  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller:  ",
    384  1.1  christos                 Type);
    385  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-8s  %-28s",
    386  1.1  christos                 HidString, Info->DeviceName);
    387  1.1  christos 
    388  1.1  christos             HidInfo = AcpiAhMatchHardwareId (HidString);
    389  1.1  christos             if (HidInfo)
    390  1.1  christos             {
    391  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s",
    392  1.1  christos                     HidInfo->Description);
    393  1.1  christos             }
    394  1.1  christos 
    395  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n");
    396  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT,
    397  1.1  christos                 "Type  Address   Speed      Dest _HID  Destination\n");
    398  1.1  christos         }
    399  1.1  christos 
    400  1.1  christos         PrevDeviceName = Info->DeviceName;
    401  1.1  christos 
    402  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "%s   %4.4X    %8.8X    ",
    403  1.1  christos             Type, Info->Address, Info->Speed);
    404  1.1  christos 
    405  1.1  christos         ParentPathname = NULL;
    406  1.1  christos         HidString = MpGetConnectionInfo (Info->Op, 0, &Info->TargetNode,
    407  1.1  christos             &ParentPathname);
    408  1.1  christos         if (HidString)
    409  1.1  christos         {
    410  1.1  christos             /*
    411  1.1  christos              * This is a Connection() field
    412  1.1  christos              * Attempt to find all references to the field.
    413  1.1  christos              */
    414  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s   %-28s",
    415  1.1  christos                 HidString, ParentPathname);
    416  1.1  christos         }
    417  1.1  christos         else
    418  1.1  christos         {
    419  1.1  christos             /* Normal resource template */
    420  1.1  christos 
    421  1.1  christos             HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
    422  1.1  christos                 &ParentPathname);
    423  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s   %-28s",
    424  1.1  christos                 HidString, ParentPathname);
    425  1.1  christos 
    426  1.1  christos             /* Get the _HID description or _DDN string */
    427  1.1  christos 
    428  1.1  christos             HidInfo = AcpiAhMatchHardwareId (HidString);
    429  1.1  christos             if (HidInfo)
    430  1.1  christos             {
    431  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s",
    432  1.1  christos                     HidInfo->Description);
    433  1.1  christos             }
    434  1.1  christos             else if ((Description = MpGetDdnValue (ParentPathname)))
    435  1.1  christos             {
    436  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // %s (_DDN)",
    437  1.1  christos                     Description);
    438  1.1  christos             }
    439  1.1  christos         }
    440  1.1  christos 
    441  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
    442  1.1  christos         ACPI_FREE (ParentPathname);
    443  1.1  christos         Info = Info->Next;
    444  1.1  christos     }
    445  1.1  christos }
    446  1.1  christos 
    447  1.1  christos 
    448  1.1  christos /*******************************************************************************
    449  1.1  christos  *
    450  1.1  christos  * FUNCTION:    MpEmitDeviceTree
    451  1.1  christos  *
    452  1.1  christos  * PARAMETERS:  None
    453  1.1  christos  *
    454  1.1  christos  * RETURN:      None
    455  1.1  christos  *
    456  1.1  christos  * DESCRIPTION: Emit information about all devices within the ACPI namespace.
    457  1.1  christos  *
    458  1.1  christos  ******************************************************************************/
    459  1.1  christos 
    460  1.1  christos static void
    461  1.1  christos MpEmitDeviceTree (
    462  1.1  christos     void)
    463  1.1  christos {
    464  1.1  christos 
    465  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nACPI Device Tree\n");
    466  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT,     "----------------\n\n");
    467  1.1  christos 
    468  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "Device Pathname                   "
    469  1.1  christos         "_HID      Description\n\n");
    470  1.1  christos 
    471  1.1  christos     /* Walk the namespace from the root */
    472  1.1  christos 
    473  1.1  christos     (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
    474  1.1  christos             ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL);
    475  1.1  christos }
    476  1.1  christos 
    477  1.1  christos 
    478  1.1  christos /*******************************************************************************
    479  1.1  christos  *
    480  1.1  christos  * FUNCTION:    MpEmitOneDevice
    481  1.1  christos  *
    482  1.1  christos  * PARAMETERS:  ACPI_NAMESPACE_WALK callback
    483  1.1  christos  *
    484  1.1  christos  * RETURN:      Status
    485  1.1  christos  *
    486  1.1  christos  * DESCRIPTION: Emit information about one ACPI device in the namespace. Used
    487  1.1  christos  *              during dump of all device objects within the namespace.
    488  1.1  christos  *
    489  1.1  christos  ******************************************************************************/
    490  1.1  christos 
    491  1.1  christos static ACPI_STATUS
    492  1.1  christos MpEmitOneDevice (
    493  1.1  christos     ACPI_HANDLE             ObjHandle,
    494  1.1  christos     UINT32                  NestingLevel,
    495  1.1  christos     void                    *Context,
    496  1.1  christos     void                    **ReturnValue)
    497  1.1  christos {
    498  1.1  christos     char                    *DevicePathname;
    499  1.1  christos     char                    *DdnString;
    500  1.1  christos     char                    *HidString;
    501  1.1  christos     const AH_DEVICE_ID      *HidInfo;
    502  1.1  christos 
    503  1.1  christos 
    504  1.1  christos     /* Device pathname */
    505  1.1  christos 
    506  1.1  christos     DevicePathname = AcpiNsGetExternalPathname (
    507  1.1  christos         ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
    508  1.1  christos 
    509  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-32s", DevicePathname);
    510  1.1  christos 
    511  1.1  christos     /* _HID or _DDN */
    512  1.1  christos 
    513  1.1  christos     HidString = MpGetHidValue (
    514  1.1  christos         ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
    515  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s", HidString);
    516  1.1  christos 
    517  1.1  christos     HidInfo = AcpiAhMatchHardwareId (HidString);
    518  1.1  christos     if (HidInfo)
    519  1.1  christos     {
    520  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "    // %s",
    521  1.1  christos             HidInfo->Description);
    522  1.1  christos     }
    523  1.1  christos     else if ((DdnString = MpGetDdnValue (DevicePathname)))
    524  1.1  christos     {
    525  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "    // %s (_DDN)", DdnString);
    526  1.1  christos     }
    527  1.1  christos 
    528  1.1  christos     FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
    529  1.1  christos     ACPI_FREE (DevicePathname);
    530  1.1  christos     return (AE_OK);
    531  1.1  christos }
    532  1.1  christos 
    533  1.1  christos 
    534  1.1  christos /*******************************************************************************
    535  1.1  christos  *
    536  1.1  christos  * FUNCTION:    MpXrefDevices
    537  1.1  christos  *
    538  1.1  christos  * PARAMETERS:  Info                    - A GPIO Info block
    539  1.1  christos  *
    540  1.1  christos  * RETURN:      None
    541  1.1  christos  *
    542  1.1  christos  * DESCRIPTION: Cross-reference the parse tree and find all references to the
    543  1.1  christos  *              specified GPIO device.
    544  1.1  christos  *
    545  1.1  christos  ******************************************************************************/
    546  1.1  christos 
    547  1.1  christos static void
    548  1.1  christos MpXrefDevices (
    549  1.1  christos     ACPI_GPIO_INFO          *Info)
    550  1.1  christos {
    551  1.1  christos 
    552  1.1  christos     /* Walk the entire parse tree */
    553  1.1  christos 
    554  1.1  christos     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
    555  1.1  christos         MpNamespaceXrefBegin, NULL, Info);
    556  1.1  christos 
    557  1.1  christos     if (!Info->References)
    558  1.1  christos     {
    559  1.1  christos         FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // **** No references in table");
    560  1.1  christos     }
    561  1.1  christos }
    562  1.1  christos 
    563  1.1  christos 
    564  1.1  christos /*******************************************************************************
    565  1.1  christos  *
    566  1.1  christos  * FUNCTION:    MpNamespaceXrefBegin
    567  1.1  christos  *
    568  1.1  christos  * PARAMETERS:  WALK_PARSE_TREE callback
    569  1.1  christos  *
    570  1.1  christos  * RETURN:      Status
    571  1.1  christos  *
    572  1.1  christos  * DESCRIPTION: Walk parse tree callback used to cross-reference GPIO pins.
    573  1.1  christos  *
    574  1.1  christos  ******************************************************************************/
    575  1.1  christos 
    576  1.1  christos static ACPI_STATUS
    577  1.1  christos MpNamespaceXrefBegin (
    578  1.1  christos     ACPI_PARSE_OBJECT       *Op,
    579  1.1  christos     UINT32                  Level,
    580  1.1  christos     void                    *Context)
    581  1.1  christos {
    582  1.1  christos     ACPI_GPIO_INFO          *Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Context);
    583  1.1  christos     const ACPI_OPCODE_INFO  *OpInfo;
    584  1.1  christos     char                    *DevicePathname;
    585  1.1  christos     ACPI_PARSE_OBJECT       *ParentOp;
    586  1.1  christos     char                    *HidString;
    587  1.1  christos 
    588  1.1  christos 
    589  1.1  christos     ACPI_FUNCTION_TRACE_PTR (MpNamespaceXrefBegin, Op);
    590  1.1  christos 
    591  1.1  christos     /*
    592  1.1  christos      * If this node is the actual declaration of a name
    593  1.1  christos      * [such as the XXXX name in "Method (XXXX)"],
    594  1.1  christos      * we are not interested in it here. We only care about names that
    595  1.1  christos      * are references to other objects within the namespace and the
    596  1.1  christos      * parent objects of name declarations
    597  1.1  christos      */
    598  1.1  christos     if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
    599  1.1  christos     {
    600  1.1  christos         return (AE_OK);
    601  1.1  christos     }
    602  1.1  christos 
    603  1.1  christos     /* We are only interested in opcodes that have an associated name */
    604  1.1  christos 
    605  1.1  christos     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
    606  1.1  christos 
    607  1.1  christos     if ((OpInfo->Flags & AML_NAMED) ||
    608  1.1  christos         (OpInfo->Flags & AML_CREATE))
    609  1.1  christos     {
    610  1.1  christos         return (AE_OK);
    611  1.1  christos     }
    612  1.1  christos 
    613  1.1  christos     if ((Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
    614  1.1  christos         (Op->Asl.ParseOpcode != PARSEOP_NAMESEG)    &&
    615  1.1  christos         (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
    616  1.1  christos     {
    617  1.1  christos         return (AE_OK);
    618  1.1  christos     }
    619  1.1  christos 
    620  1.1  christos     if (!Op->Asl.Node)
    621  1.1  christos     {
    622  1.1  christos         return (AE_OK);
    623  1.1  christos     }
    624  1.1  christos 
    625  1.1  christos     ParentOp = Op->Asl.Parent;
    626  1.1  christos     if (ParentOp->Asl.ParseOpcode == PARSEOP_FIELD)
    627  1.1  christos     {
    628  1.1  christos         return (AE_OK);
    629  1.1  christos     }
    630  1.1  christos 
    631  1.1  christos     if (Op->Asl.Node == Info->TargetNode)
    632  1.1  christos     {
    633  1.1  christos         DevicePathname = AcpiNsGetExternalPathname (
    634  1.1  christos             Info->TargetNode);
    635  1.1  christos 
    636  1.1  christos         while (ParentOp && (!ParentOp->Asl.Node))
    637  1.1  christos         {
    638  1.1  christos             ParentOp = ParentOp->Asl.Parent;
    639  1.1  christos         }
    640  1.1  christos 
    641  1.1  christos         if (ParentOp)
    642  1.1  christos         {
    643  1.1  christos             DevicePathname = AcpiNsGetExternalPathname (
    644  1.1  christos                 ParentOp->Asl.Node);
    645  1.1  christos 
    646  1.1  christos             if (!Info->References)
    647  1.1  christos             {
    648  1.1  christos                 FlPrintFile (ASL_FILE_MAP_OUTPUT, "  // References:");
    649  1.1  christos             }
    650  1.1  christos 
    651  1.1  christos             HidString = MpGetHidViaNamestring (DevicePathname);
    652  1.1  christos 
    653  1.1  christos             FlPrintFile (ASL_FILE_MAP_OUTPUT, " %s [%s]",
    654  1.1  christos                 DevicePathname, HidString);
    655  1.1  christos 
    656  1.1  christos             Info->References++;
    657  1.1  christos         }
    658  1.1  christos     }
    659  1.1  christos 
    660  1.1  christos     return (AE_OK);
    661  1.1  christos }
    662