Home | History | Annotate | Line # | Download | only in acpihelp
ahdecode.c revision 1.1.1.10
      1       1.1    jruoho /******************************************************************************
      2       1.1    jruoho  *
      3   1.1.1.8  christos  * Module Name: ahdecode - Miscellaneous decoding for acpihelp utility
      4       1.1    jruoho  *
      5       1.1    jruoho  *****************************************************************************/
      6       1.1    jruoho 
      7       1.1    jruoho /*
      8   1.1.1.9  christos  * Copyright (C) 2000 - 2018, Intel Corp.
      9       1.1    jruoho  * All rights reserved.
     10       1.1    jruoho  *
     11       1.1    jruoho  * Redistribution and use in source and binary forms, with or without
     12       1.1    jruoho  * modification, are permitted provided that the following conditions
     13       1.1    jruoho  * are met:
     14       1.1    jruoho  * 1. Redistributions of source code must retain the above copyright
     15       1.1    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16       1.1    jruoho  *    without modification.
     17       1.1    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1    jruoho  *    including a substantially similar Disclaimer requirement for further
     21       1.1    jruoho  *    binary redistribution.
     22       1.1    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1    jruoho  *    of any contributors may be used to endorse or promote products derived
     24       1.1    jruoho  *    from this software without specific prior written permission.
     25       1.1    jruoho  *
     26       1.1    jruoho  * Alternatively, this software may be distributed under the terms of the
     27       1.1    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1    jruoho  * Software Foundation.
     29       1.1    jruoho  *
     30       1.1    jruoho  * NO WARRANTY
     31       1.1    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33       1.1    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34       1.1    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1    jruoho  */
     43       1.1    jruoho 
     44       1.1    jruoho #define ACPI_CREATE_PREDEFINED_TABLE
     45   1.1.1.2  christos #define ACPI_CREATE_RESOURCE_TABLE
     46   1.1.1.2  christos 
     47   1.1.1.2  christos #include "acpihelp.h"
     48       1.1    jruoho #include "acpredef.h"
     49       1.1    jruoho 
     50   1.1.1.2  christos 
     51       1.1    jruoho /* Local prototypes */
     52       1.1    jruoho 
     53       1.1    jruoho static BOOLEAN
     54       1.1    jruoho AhDisplayPredefinedName (
     55       1.1    jruoho     char                    *Name,
     56       1.1    jruoho     UINT32                  Length);
     57       1.1    jruoho 
     58       1.1    jruoho static void
     59       1.1    jruoho AhDisplayPredefinedInfo (
     60       1.1    jruoho     char                    *Name);
     61       1.1    jruoho 
     62       1.1    jruoho static void
     63  1.1.1.10  christos AhDoSpecialNames (
     64  1.1.1.10  christos     char                    *Name);
     65  1.1.1.10  christos 
     66  1.1.1.10  christos static void
     67   1.1.1.2  christos AhDisplayResourceName (
     68   1.1.1.2  christos     const ACPI_PREDEFINED_INFO  *ThisName);
     69       1.1    jruoho 
     70   1.1.1.2  christos 
     71   1.1.1.8  christos /*******************************************************************************
     72   1.1.1.8  christos  *
     73   1.1.1.8  christos  * FUNCTION:    AhPrintOneField
     74   1.1.1.8  christos  *
     75   1.1.1.8  christos  * PARAMETERS:  Indent              - Indent length for new line(s)
     76   1.1.1.8  christos  *              CurrentPosition     - Position on current line
     77   1.1.1.8  christos  *              MaxPosition         - Max allowed line length
     78   1.1.1.8  christos  *              Field               - Data to output
     79   1.1.1.8  christos  *
     80   1.1.1.8  christos  * RETURN:      Line position after field is written
     81   1.1.1.8  christos  *
     82   1.1.1.8  christos  * DESCRIPTION: Split long lines appropriately for ease of reading.
     83   1.1.1.8  christos  *
     84   1.1.1.8  christos  ******************************************************************************/
     85       1.1    jruoho 
     86   1.1.1.8  christos void
     87       1.1    jruoho AhPrintOneField (
     88       1.1    jruoho     UINT32                  Indent,
     89       1.1    jruoho     UINT32                  CurrentPosition,
     90       1.1    jruoho     UINT32                  MaxPosition,
     91   1.1.1.8  christos     const char              *Field)
     92   1.1.1.8  christos {
     93   1.1.1.8  christos     UINT32                  Position;
     94   1.1.1.8  christos     UINT32                  TokenLength;
     95   1.1.1.8  christos     const char              *This;
     96   1.1.1.8  christos     const char              *Next;
     97   1.1.1.8  christos     const char              *Last;
     98   1.1.1.8  christos 
     99   1.1.1.8  christos 
    100   1.1.1.8  christos     This = Field;
    101   1.1.1.8  christos     Position = CurrentPosition;
    102   1.1.1.8  christos 
    103   1.1.1.8  christos     if (Position == 0)
    104   1.1.1.8  christos     {
    105   1.1.1.8  christos         printf ("%*s", (int) Indent, " ");
    106   1.1.1.8  christos         Position = Indent;
    107   1.1.1.8  christos     }
    108   1.1.1.8  christos 
    109   1.1.1.8  christos     Last = This + strlen (This);
    110   1.1.1.8  christos     while ((Next = strpbrk (This, " ")))
    111   1.1.1.8  christos     {
    112   1.1.1.8  christos         TokenLength = Next - This;
    113   1.1.1.8  christos         Position += TokenLength;
    114   1.1.1.8  christos 
    115   1.1.1.8  christos         /* Split long lines */
    116   1.1.1.8  christos 
    117   1.1.1.8  christos         if (Position > MaxPosition)
    118   1.1.1.8  christos         {
    119   1.1.1.8  christos             printf ("\n%*s", (int) Indent, " ");
    120   1.1.1.8  christos             Position = TokenLength;
    121   1.1.1.8  christos         }
    122   1.1.1.8  christos 
    123   1.1.1.8  christos         printf ("%.*s ", (int) TokenLength, This);
    124   1.1.1.8  christos         This = Next + 1;
    125   1.1.1.8  christos     }
    126   1.1.1.8  christos 
    127   1.1.1.8  christos     /* Handle last token on the input line */
    128   1.1.1.8  christos 
    129   1.1.1.8  christos     TokenLength = Last - This;
    130   1.1.1.8  christos     if (TokenLength > 0)
    131   1.1.1.8  christos     {
    132   1.1.1.8  christos         Position += TokenLength;
    133   1.1.1.8  christos         if (Position > MaxPosition)
    134   1.1.1.8  christos         {
    135   1.1.1.8  christos             printf ("\n%*s", (int) Indent, " ");
    136   1.1.1.8  christos         }
    137   1.1.1.8  christos 
    138   1.1.1.8  christos         printf ("%s", This);
    139   1.1.1.8  christos     }
    140   1.1.1.8  christos }
    141       1.1    jruoho 
    142       1.1    jruoho 
    143       1.1    jruoho /*******************************************************************************
    144       1.1    jruoho  *
    145   1.1.1.5  christos  * FUNCTION:    AhDisplayDirectives
    146   1.1.1.5  christos  *
    147   1.1.1.5  christos  * PARAMETERS:  None
    148   1.1.1.5  christos  *
    149   1.1.1.5  christos  * RETURN:      None
    150   1.1.1.5  christos  *
    151   1.1.1.5  christos  * DESCRIPTION: Display all iASL preprocessor directives.
    152   1.1.1.5  christos  *
    153   1.1.1.5  christos  ******************************************************************************/
    154   1.1.1.5  christos 
    155   1.1.1.5  christos void
    156   1.1.1.5  christos AhDisplayDirectives (
    157   1.1.1.5  christos     void)
    158   1.1.1.5  christos {
    159   1.1.1.5  christos     const AH_DIRECTIVE_INFO *Info;
    160   1.1.1.5  christos 
    161   1.1.1.5  christos 
    162   1.1.1.5  christos     printf ("iASL Preprocessor Directives\n\n");
    163   1.1.1.5  christos 
    164   1.1.1.8  christos     for (Info = Gbl_PreprocessorDirectives; Info->Name; Info++)
    165   1.1.1.5  christos     {
    166   1.1.1.5  christos         printf ("  %-36s : %s\n", Info->Name, Info->Description);
    167   1.1.1.5  christos     }
    168   1.1.1.5  christos }
    169   1.1.1.5  christos 
    170   1.1.1.5  christos 
    171   1.1.1.5  christos /*******************************************************************************
    172   1.1.1.5  christos  *
    173       1.1    jruoho  * FUNCTION:    AhFindPredefinedNames (entry point for predefined name search)
    174       1.1    jruoho  *
    175       1.1    jruoho  * PARAMETERS:  NamePrefix          - Name or prefix to find. Must start with
    176       1.1    jruoho  *                                    an underscore. NULL means "find all"
    177       1.1    jruoho  *
    178       1.1    jruoho  * RETURN:      None
    179       1.1    jruoho  *
    180       1.1    jruoho  * DESCRIPTION: Find and display all ACPI predefined names that match the
    181       1.1    jruoho  *              input name or prefix. Includes the required number of arguments
    182       1.1    jruoho  *              and the expected return type, if any.
    183       1.1    jruoho  *
    184       1.1    jruoho  ******************************************************************************/
    185       1.1    jruoho 
    186       1.1    jruoho void
    187       1.1    jruoho AhFindPredefinedNames (
    188       1.1    jruoho     char                    *NamePrefix)
    189       1.1    jruoho {
    190       1.1    jruoho     UINT32                  Length;
    191       1.1    jruoho     BOOLEAN                 Found;
    192  1.1.1.10  christos     char                    Name[ACPI_NAME_SIZE + 1];
    193       1.1    jruoho 
    194       1.1    jruoho 
    195  1.1.1.10  christos     if (!NamePrefix || (*NamePrefix == '*'))
    196       1.1    jruoho     {
    197   1.1.1.5  christos         Found = AhDisplayPredefinedName (NULL, 0);
    198       1.1    jruoho         return;
    199       1.1    jruoho     }
    200       1.1    jruoho 
    201  1.1.1.10  christos     Length = strlen (NamePrefix);
    202  1.1.1.10  christos     if (Length > ACPI_NAME_SIZE)
    203  1.1.1.10  christos     {
    204  1.1.1.10  christos         printf ("%.8s: Predefined name must be 4 characters maximum\n",
    205  1.1.1.10  christos             NamePrefix);
    206  1.1.1.10  christos         return;
    207  1.1.1.10  christos     }
    208  1.1.1.10  christos 
    209       1.1    jruoho     /* Contruct a local name or name prefix */
    210       1.1    jruoho 
    211   1.1.1.5  christos     AcpiUtStrupr (NamePrefix);
    212       1.1    jruoho     if (*NamePrefix == '_')
    213       1.1    jruoho     {
    214       1.1    jruoho         NamePrefix++;
    215       1.1    jruoho     }
    216       1.1    jruoho 
    217       1.1    jruoho     Name[0] = '_';
    218  1.1.1.10  christos     AcpiUtSafeStrncpy (&Name[1], NamePrefix, 4);
    219       1.1    jruoho 
    220  1.1.1.10  christos     /* Check for special names such as _Exx, _ACx, etc. */
    221  1.1.1.10  christos 
    222  1.1.1.10  christos     AhDoSpecialNames (Name);
    223  1.1.1.10  christos 
    224  1.1.1.10  christos     /* Lookup and display the name(s) */
    225       1.1    jruoho 
    226       1.1    jruoho     Found = AhDisplayPredefinedName (Name, Length);
    227       1.1    jruoho     if (!Found)
    228       1.1    jruoho     {
    229       1.1    jruoho         printf ("%s, no matching predefined names\n", Name);
    230       1.1    jruoho     }
    231       1.1    jruoho }
    232       1.1    jruoho 
    233       1.1    jruoho 
    234       1.1    jruoho /*******************************************************************************
    235       1.1    jruoho  *
    236  1.1.1.10  christos  * FUNCTION:    AhDoSpecialNames
    237  1.1.1.10  christos  *
    238  1.1.1.10  christos  * PARAMETERS:  Name          - Name or prefix to find
    239  1.1.1.10  christos  *
    240  1.1.1.10  christos  * RETURN:      None
    241  1.1.1.10  christos  *
    242  1.1.1.10  christos  * DESCRIPTION: Detect and handle the "special" names such as _Exx, _ACx, etc.
    243  1.1.1.10  christos  *
    244  1.1.1.10  christos  * Current support:
    245  1.1.1.10  christos  *  _EJx
    246  1.1.1.10  christos  *  _Exx
    247  1.1.1.10  christos  *  _Lxx
    248  1.1.1.10  christos  *  _Qxx
    249  1.1.1.10  christos  *  _Wxx
    250  1.1.1.10  christos  *  _ACx
    251  1.1.1.10  christos  *  _ALx
    252  1.1.1.10  christos  *  _T_x
    253  1.1.1.10  christos  *
    254  1.1.1.10  christos  ******************************************************************************/
    255  1.1.1.10  christos 
    256  1.1.1.10  christos static void
    257  1.1.1.10  christos AhDoSpecialNames (
    258  1.1.1.10  christos     char                    *Name)
    259  1.1.1.10  christos {
    260  1.1.1.10  christos 
    261  1.1.1.10  christos     /*
    262  1.1.1.10  christos      * Check for the special names that have one or more numeric
    263  1.1.1.10  christos      * suffixes. For example, _Lxx can have 256 different flavors,
    264  1.1.1.10  christos      * from _L00 to _LFF.
    265  1.1.1.10  christos      */
    266  1.1.1.10  christos     switch (Name[1])
    267  1.1.1.10  christos     {
    268  1.1.1.10  christos     case 'E':
    269  1.1.1.10  christos         if (Name[2] == 'J')
    270  1.1.1.10  christos         {
    271  1.1.1.10  christos             if (isdigit (Name[3]) || (Name[3] == 'X'))
    272  1.1.1.10  christos             {
    273  1.1.1.10  christos                 /* _EJx */
    274  1.1.1.10  christos 
    275  1.1.1.10  christos                 Name[3] = 'x';
    276  1.1.1.10  christos                 break;
    277  1.1.1.10  christos             }
    278  1.1.1.10  christos         }
    279  1.1.1.10  christos 
    280  1.1.1.10  christos         /* Fallthrough */
    281  1.1.1.10  christos 
    282  1.1.1.10  christos     case 'L':
    283  1.1.1.10  christos     case 'Q':
    284  1.1.1.10  christos     case 'W':
    285  1.1.1.10  christos         if ((isxdigit (Name[2]) && isxdigit (Name[3]))
    286  1.1.1.10  christos                 ||
    287  1.1.1.10  christos             ((Name[2] == 'X') && (Name[3] == 'X')))
    288  1.1.1.10  christos         {
    289  1.1.1.10  christos             /* _Exx, _Lxx, _Qxx, or _Wxx */
    290  1.1.1.10  christos 
    291  1.1.1.10  christos             Name[2] = 'x';
    292  1.1.1.10  christos             Name[3] = 'x';
    293  1.1.1.10  christos         }
    294  1.1.1.10  christos         break;
    295  1.1.1.10  christos 
    296  1.1.1.10  christos     case 'A':
    297  1.1.1.10  christos         if ((Name[2] == 'C') || (Name[2] == 'L'))
    298  1.1.1.10  christos         {
    299  1.1.1.10  christos             if (isdigit (Name[3]) || (Name[3] == 'X'))
    300  1.1.1.10  christos             {
    301  1.1.1.10  christos                 /* _ACx or _ALx */
    302  1.1.1.10  christos 
    303  1.1.1.10  christos                 Name[3] = 'x';
    304  1.1.1.10  christos             }
    305  1.1.1.10  christos         }
    306  1.1.1.10  christos         break;
    307  1.1.1.10  christos 
    308  1.1.1.10  christos     case 'T':
    309  1.1.1.10  christos         if (Name[2] == '_')
    310  1.1.1.10  christos         {
    311  1.1.1.10  christos             /* _T_x (Reserved for iASL compiler */
    312  1.1.1.10  christos 
    313  1.1.1.10  christos             Name[3] = 'x';
    314  1.1.1.10  christos         }
    315  1.1.1.10  christos         break;
    316  1.1.1.10  christos 
    317  1.1.1.10  christos     default:
    318  1.1.1.10  christos         break;
    319  1.1.1.10  christos     }
    320  1.1.1.10  christos }
    321  1.1.1.10  christos 
    322  1.1.1.10  christos 
    323  1.1.1.10  christos /*******************************************************************************
    324  1.1.1.10  christos  *
    325       1.1    jruoho  * FUNCTION:    AhDisplayPredefinedName
    326       1.1    jruoho  *
    327       1.1    jruoho  * PARAMETERS:  Name                - Name or name prefix
    328       1.1    jruoho  *
    329       1.1    jruoho  * RETURN:      TRUE if any names matched, FALSE otherwise
    330       1.1    jruoho  *
    331       1.1    jruoho  * DESCRIPTION: Display information about ACPI predefined names that match
    332       1.1    jruoho  *              the input name or name prefix.
    333       1.1    jruoho  *
    334       1.1    jruoho  ******************************************************************************/
    335       1.1    jruoho 
    336       1.1    jruoho static BOOLEAN
    337       1.1    jruoho AhDisplayPredefinedName (
    338       1.1    jruoho     char                    *Name,
    339       1.1    jruoho     UINT32                  Length)
    340       1.1    jruoho {
    341       1.1    jruoho     const AH_PREDEFINED_NAME    *Info;
    342       1.1    jruoho     BOOLEAN                     Found = FALSE;
    343       1.1    jruoho     BOOLEAN                     Matched;
    344   1.1.1.5  christos     UINT32                      i = 0;
    345       1.1    jruoho 
    346       1.1    jruoho 
    347       1.1    jruoho     /* Find/display all names that match the input name prefix */
    348       1.1    jruoho 
    349       1.1    jruoho     for (Info = AslPredefinedInfo; Info->Name; Info++)
    350       1.1    jruoho     {
    351       1.1    jruoho         if (!Name)
    352       1.1    jruoho         {
    353       1.1    jruoho             Found = TRUE;
    354       1.1    jruoho             printf ("%s: <%s>\n", Info->Name, Info->Description);
    355       1.1    jruoho             printf ("%*s%s\n", 6, " ", Info->Action);
    356       1.1    jruoho 
    357       1.1    jruoho             AhDisplayPredefinedInfo (Info->Name);
    358   1.1.1.5  christos             i++;
    359       1.1    jruoho             continue;
    360       1.1    jruoho         }
    361       1.1    jruoho 
    362       1.1    jruoho         Matched = TRUE;
    363       1.1    jruoho         for (i = 0; i < Length; i++)
    364       1.1    jruoho         {
    365       1.1    jruoho             if (Info->Name[i] != Name[i])
    366       1.1    jruoho             {
    367       1.1    jruoho                 Matched = FALSE;
    368       1.1    jruoho                 break;
    369       1.1    jruoho             }
    370       1.1    jruoho         }
    371       1.1    jruoho 
    372       1.1    jruoho         if (Matched)
    373       1.1    jruoho         {
    374       1.1    jruoho             Found = TRUE;
    375       1.1    jruoho             printf ("%s: <%s>\n", Info->Name, Info->Description);
    376       1.1    jruoho             printf ("%*s%s\n", 6, " ", Info->Action);
    377       1.1    jruoho 
    378       1.1    jruoho             AhDisplayPredefinedInfo (Info->Name);
    379       1.1    jruoho         }
    380       1.1    jruoho     }
    381       1.1    jruoho 
    382   1.1.1.5  christos     if (!Name)
    383   1.1.1.5  christos     {
    384   1.1.1.5  christos         printf ("\nFound %d Predefined ACPI Names\n", i);
    385   1.1.1.5  christos     }
    386       1.1    jruoho     return (Found);
    387       1.1    jruoho }
    388       1.1    jruoho 
    389       1.1    jruoho 
    390       1.1    jruoho /*******************************************************************************
    391       1.1    jruoho  *
    392       1.1    jruoho  * FUNCTION:    AhDisplayPredefinedInfo
    393       1.1    jruoho  *
    394       1.1    jruoho  * PARAMETERS:  Name                - Exact 4-character ACPI name.
    395       1.1    jruoho  *
    396       1.1    jruoho  * RETURN:      None
    397       1.1    jruoho  *
    398       1.1    jruoho  * DESCRIPTION: Find the name in the main ACPICA predefined info table and
    399       1.1    jruoho  *              display the # of arguments and the return value type.
    400       1.1    jruoho  *
    401       1.1    jruoho  *              Note: Resource Descriptor field names do not appear in this
    402       1.1    jruoho  *              table -- thus, nothing will be displayed for them.
    403       1.1    jruoho  *
    404       1.1    jruoho  ******************************************************************************/
    405       1.1    jruoho 
    406       1.1    jruoho static void
    407       1.1    jruoho AhDisplayPredefinedInfo (
    408   1.1.1.2  christos     char                        *Name)
    409       1.1    jruoho {
    410       1.1    jruoho     const ACPI_PREDEFINED_INFO  *ThisName;
    411       1.1    jruoho 
    412       1.1    jruoho 
    413   1.1.1.2  christos     /* NOTE: we check both tables always because there are some dupes */
    414       1.1    jruoho 
    415  1.1.1.10  christos     /* Check against the predefined methods first */
    416       1.1    jruoho 
    417   1.1.1.2  christos     ThisName = AcpiUtMatchPredefinedMethod (Name);
    418   1.1.1.2  christos     if (ThisName)
    419   1.1.1.2  christos     {
    420   1.1.1.2  christos         AcpiUtDisplayPredefinedMethod (Gbl_Buffer, ThisName, TRUE);
    421   1.1.1.2  christos     }
    422       1.1    jruoho 
    423   1.1.1.2  christos     /* Check against the predefined resource descriptor names */
    424       1.1    jruoho 
    425   1.1.1.2  christos     ThisName = AcpiUtMatchResourceName (Name);
    426   1.1.1.2  christos     if (ThisName)
    427   1.1.1.2  christos     {
    428   1.1.1.2  christos         AhDisplayResourceName (ThisName);
    429       1.1    jruoho     }
    430       1.1    jruoho }
    431       1.1    jruoho 
    432       1.1    jruoho 
    433       1.1    jruoho /*******************************************************************************
    434       1.1    jruoho  *
    435   1.1.1.2  christos  * FUNCTION:    AhDisplayResourceName
    436       1.1    jruoho  *
    437   1.1.1.2  christos  * PARAMETERS:  ThisName            - Entry in the predefined method/name table
    438       1.1    jruoho  *
    439   1.1.1.2  christos  * RETURN:      None
    440       1.1    jruoho  *
    441   1.1.1.2  christos  * DESCRIPTION: Display information about a resource descriptor name.
    442       1.1    jruoho  *
    443       1.1    jruoho  ******************************************************************************/
    444       1.1    jruoho 
    445       1.1    jruoho static void
    446   1.1.1.2  christos AhDisplayResourceName (
    447   1.1.1.2  christos     const ACPI_PREDEFINED_INFO  *ThisName)
    448       1.1    jruoho {
    449   1.1.1.2  christos     UINT32                      NumTypes;
    450       1.1    jruoho 
    451       1.1    jruoho 
    452   1.1.1.2  christos     NumTypes = AcpiUtGetResourceBitWidth (Gbl_Buffer,
    453   1.1.1.2  christos         ThisName->Info.ArgumentList);
    454       1.1    jruoho 
    455   1.1.1.2  christos     printf ("      %4.4s resource descriptor field is %s bits wide%s\n",
    456   1.1.1.2  christos         ThisName->Info.Name,
    457   1.1.1.2  christos         Gbl_Buffer,
    458   1.1.1.2  christos         (NumTypes > 1) ? " (depending on descriptor type)" : "");
    459       1.1    jruoho }
    460       1.1    jruoho 
    461       1.1    jruoho 
    462       1.1    jruoho /*******************************************************************************
    463       1.1    jruoho  *
    464   1.1.1.2  christos  * FUNCTION:    AhDisplayDeviceIds
    465   1.1.1.2  christos  *
    466   1.1.1.3  christos  * PARAMETERS:  Name                - Device Hardware ID string.
    467   1.1.1.3  christos  *                                    NULL means "find all"
    468   1.1.1.2  christos  *
    469   1.1.1.2  christos  * RETURN:      None
    470   1.1.1.2  christos  *
    471   1.1.1.3  christos  * DESCRIPTION: Display PNP* and ACPI* device IDs.
    472   1.1.1.2  christos  *
    473   1.1.1.2  christos  ******************************************************************************/
    474   1.1.1.2  christos 
    475   1.1.1.2  christos void
    476   1.1.1.2  christos AhDisplayDeviceIds (
    477   1.1.1.3  christos     char                    *Name)
    478   1.1.1.3  christos {
    479   1.1.1.3  christos     const AH_DEVICE_ID      *Info;
    480   1.1.1.3  christos     UINT32                  Length;
    481   1.1.1.3  christos     BOOLEAN                 Matched;
    482   1.1.1.3  christos     UINT32                  i;
    483   1.1.1.3  christos     BOOLEAN                 Found = FALSE;
    484   1.1.1.3  christos 
    485   1.1.1.3  christos 
    486   1.1.1.3  christos     /* Null input name indicates "display all" */
    487   1.1.1.3  christos 
    488   1.1.1.7  christos     if (!Name || (Name[0] == '*'))
    489   1.1.1.3  christos     {
    490   1.1.1.3  christos         printf ("ACPI and PNP Device/Hardware IDs:\n\n");
    491   1.1.1.3  christos         for (Info = AslDeviceIds; Info->Name; Info++)
    492   1.1.1.3  christos         {
    493   1.1.1.3  christos             printf ("%8s   %s\n", Info->Name, Info->Description);
    494   1.1.1.3  christos         }
    495   1.1.1.3  christos 
    496   1.1.1.3  christos         return;
    497   1.1.1.3  christos     }
    498   1.1.1.3  christos 
    499   1.1.1.3  christos     Length = strlen (Name);
    500   1.1.1.3  christos     if (Length > 8)
    501   1.1.1.3  christos     {
    502   1.1.1.3  christos         printf ("%.8s: Hardware ID must be 8 characters maximum\n", Name);
    503   1.1.1.3  christos         return;
    504   1.1.1.3  christos     }
    505   1.1.1.3  christos 
    506   1.1.1.3  christos     /* Find/display all names that match the input name prefix */
    507   1.1.1.3  christos 
    508   1.1.1.5  christos     AcpiUtStrupr (Name);
    509   1.1.1.3  christos     for (Info = AslDeviceIds; Info->Name; Info++)
    510   1.1.1.3  christos     {
    511   1.1.1.3  christos         Matched = TRUE;
    512   1.1.1.3  christos         for (i = 0; i < Length; i++)
    513   1.1.1.3  christos         {
    514   1.1.1.3  christos             if (Info->Name[i] != Name[i])
    515   1.1.1.3  christos             {
    516   1.1.1.3  christos                 Matched = FALSE;
    517   1.1.1.3  christos                 break;
    518   1.1.1.3  christos             }
    519   1.1.1.3  christos         }
    520   1.1.1.3  christos 
    521   1.1.1.3  christos         if (Matched)
    522   1.1.1.3  christos         {
    523   1.1.1.3  christos             Found = TRUE;
    524   1.1.1.3  christos             printf ("%8s   %s\n", Info->Name, Info->Description);
    525   1.1.1.3  christos         }
    526   1.1.1.3  christos     }
    527   1.1.1.3  christos 
    528   1.1.1.3  christos     if (!Found)
    529   1.1.1.3  christos     {
    530   1.1.1.3  christos         printf ("%s, Hardware ID not found\n", Name);
    531   1.1.1.3  christos     }
    532   1.1.1.3  christos }
    533   1.1.1.3  christos 
    534   1.1.1.3  christos 
    535   1.1.1.3  christos /*******************************************************************************
    536   1.1.1.3  christos  *
    537   1.1.1.3  christos  * FUNCTION:    AhDisplayUuids
    538   1.1.1.3  christos  *
    539   1.1.1.3  christos  * PARAMETERS:  None
    540   1.1.1.3  christos  *
    541   1.1.1.3  christos  * RETURN:      None
    542   1.1.1.3  christos  *
    543   1.1.1.3  christos  * DESCRIPTION: Display all known UUIDs.
    544   1.1.1.3  christos  *
    545   1.1.1.3  christos  ******************************************************************************/
    546   1.1.1.3  christos 
    547   1.1.1.3  christos void
    548   1.1.1.3  christos AhDisplayUuids (
    549   1.1.1.2  christos     void)
    550   1.1.1.2  christos {
    551   1.1.1.3  christos     const AH_UUID           *Info;
    552   1.1.1.3  christos 
    553   1.1.1.2  christos 
    554   1.1.1.5  christos     printf ("ACPI-related UUIDs/GUIDs:\n");
    555   1.1.1.5  christos 
    556   1.1.1.5  christos     /* Display entire table of known ACPI-related UUIDs/GUIDs */
    557   1.1.1.2  christos 
    558   1.1.1.8  christos     for (Info = Gbl_AcpiUuids; Info->Description; Info++)
    559   1.1.1.2  christos     {
    560   1.1.1.5  christos         if (!Info->String) /* Null UUID string means group description */
    561   1.1.1.5  christos         {
    562   1.1.1.5  christos             printf ("\n%36s\n", Info->Description);
    563   1.1.1.5  christos         }
    564   1.1.1.5  christos         else
    565   1.1.1.5  christos         {
    566   1.1.1.5  christos             printf ("%32s : %s\n", Info->Description, Info->String);
    567   1.1.1.5  christos         }
    568   1.1.1.5  christos     }
    569   1.1.1.5  christos 
    570   1.1.1.5  christos     /* Help info on how UUIDs/GUIDs strings are encoded */
    571   1.1.1.5  christos 
    572   1.1.1.5  christos     printf ("\n\nByte encoding of UUID/GUID strings"
    573   1.1.1.5  christos         " into ACPI Buffer objects (use ToUUID from ASL):\n\n");
    574   1.1.1.5  christos 
    575   1.1.1.5  christos     printf ("%32s : %s\n", "Input UUID/GUID String format",
    576   1.1.1.5  christos         "aabbccdd-eeff-gghh-iijj-kkllmmnnoopp");
    577   1.1.1.5  christos 
    578   1.1.1.5  christos     printf ("%32s : %s\n", "Expected output ACPI buffer",
    579   1.1.1.5  christos         "dd,cc,bb,aa, ff,ee, hh,gg, ii,jj, kk,ll,mm,nn,oo,pp");
    580   1.1.1.5  christos }
    581   1.1.1.5  christos 
    582   1.1.1.5  christos 
    583   1.1.1.5  christos /*******************************************************************************
    584   1.1.1.5  christos  *
    585   1.1.1.5  christos  * FUNCTION:    AhDisplayTables
    586   1.1.1.5  christos  *
    587   1.1.1.5  christos  * PARAMETERS:  None
    588   1.1.1.5  christos  *
    589   1.1.1.5  christos  * RETURN:      None
    590   1.1.1.5  christos  *
    591   1.1.1.5  christos  * DESCRIPTION: Display all known ACPI tables
    592   1.1.1.5  christos  *
    593   1.1.1.5  christos  ******************************************************************************/
    594   1.1.1.5  christos 
    595   1.1.1.5  christos void
    596   1.1.1.5  christos AhDisplayTables (
    597   1.1.1.5  christos     void)
    598   1.1.1.5  christos {
    599   1.1.1.5  christos     const AH_TABLE          *Info;
    600   1.1.1.5  christos     UINT32                  i = 0;
    601   1.1.1.5  christos 
    602   1.1.1.5  christos 
    603   1.1.1.5  christos     printf ("Known ACPI tables:\n");
    604   1.1.1.5  christos 
    605  1.1.1.10  christos     for (Info = AcpiGbl_SupportedTables; Info->Signature; Info++)
    606   1.1.1.5  christos     {
    607   1.1.1.5  christos         printf ("%8s : %s\n", Info->Signature, Info->Description);
    608   1.1.1.5  christos         i++;
    609   1.1.1.2  christos     }
    610   1.1.1.5  christos 
    611   1.1.1.5  christos     printf ("\nTotal %u ACPI tables\n\n", i);
    612   1.1.1.2  christos }
    613   1.1.1.2  christos 
    614   1.1.1.2  christos 
    615   1.1.1.2  christos /*******************************************************************************
    616   1.1.1.2  christos  *
    617   1.1.1.2  christos  * FUNCTION:    AhDecodeException
    618   1.1.1.2  christos  *
    619   1.1.1.2  christos  * PARAMETERS:  HexString           - ACPI status string from command line, in
    620   1.1.1.2  christos  *                                    hex. If null, display all exceptions.
    621   1.1.1.2  christos  *
    622   1.1.1.2  christos  * RETURN:      None
    623   1.1.1.2  christos  *
    624   1.1.1.2  christos  * DESCRIPTION: Decode and display an ACPI_STATUS exception code.
    625   1.1.1.2  christos  *
    626   1.1.1.2  christos  ******************************************************************************/
    627   1.1.1.2  christos 
    628   1.1.1.2  christos void
    629   1.1.1.2  christos AhDecodeException (
    630   1.1.1.2  christos     char                    *HexString)
    631   1.1.1.2  christos {
    632   1.1.1.2  christos     const ACPI_EXCEPTION_INFO   *ExceptionInfo;
    633   1.1.1.2  christos     UINT32                      Status;
    634   1.1.1.2  christos     UINT32                      i;
    635   1.1.1.2  christos 
    636   1.1.1.2  christos 
    637   1.1.1.2  christos     /*
    638   1.1.1.2  christos      * A null input string means to decode and display all known
    639   1.1.1.2  christos      * exception codes.
    640   1.1.1.2  christos      */
    641   1.1.1.2  christos     if (!HexString)
    642   1.1.1.2  christos     {
    643   1.1.1.2  christos         printf ("All defined ACPICA exception codes:\n\n");
    644   1.1.1.6  christos         AH_DISPLAY_EXCEPTION (0,
    645   1.1.1.6  christos             "AE_OK                        (No error occurred)");
    646   1.1.1.2  christos 
    647   1.1.1.2  christos         /* Display codes in each block of exception types */
    648   1.1.1.2  christos 
    649   1.1.1.2  christos         for (i = 1; (i & AE_CODE_MASK) <= AE_CODE_MAX; i += 0x1000)
    650   1.1.1.2  christos         {
    651   1.1.1.2  christos             Status = i;
    652   1.1.1.2  christos             do
    653   1.1.1.2  christos             {
    654   1.1.1.2  christos                 ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status);
    655   1.1.1.2  christos                 if (ExceptionInfo)
    656   1.1.1.2  christos                 {
    657   1.1.1.2  christos                     AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo);
    658   1.1.1.2  christos                 }
    659   1.1.1.6  christos 
    660   1.1.1.2  christos                 Status++;
    661   1.1.1.2  christos 
    662   1.1.1.2  christos             } while (ExceptionInfo);
    663   1.1.1.2  christos         }
    664   1.1.1.2  christos         return;
    665   1.1.1.2  christos     }
    666   1.1.1.2  christos 
    667   1.1.1.2  christos     /* Decode a single user-supplied exception code */
    668   1.1.1.2  christos 
    669   1.1.1.5  christos     Status = strtoul (HexString, NULL, 16);
    670   1.1.1.2  christos     if (!Status)
    671   1.1.1.2  christos     {
    672   1.1.1.2  christos         printf ("%s: Invalid hexadecimal exception code value\n", HexString);
    673   1.1.1.2  christos         return;
    674   1.1.1.2  christos     }
    675   1.1.1.2  christos 
    676   1.1.1.2  christos     if (Status > ACPI_UINT16_MAX)
    677   1.1.1.2  christos     {
    678   1.1.1.2  christos         AH_DISPLAY_EXCEPTION (Status, "Invalid exception code (more than 16 bits)");
    679   1.1.1.2  christos         return;
    680   1.1.1.2  christos     }
    681   1.1.1.2  christos 
    682   1.1.1.2  christos     ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status);
    683   1.1.1.2  christos     if (!ExceptionInfo)
    684   1.1.1.2  christos     {
    685   1.1.1.2  christos         AH_DISPLAY_EXCEPTION (Status, "Unknown exception code");
    686   1.1.1.2  christos         return;
    687   1.1.1.2  christos     }
    688   1.1.1.2  christos 
    689   1.1.1.2  christos     AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo);
    690   1.1.1.2  christos }
    691