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