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