Home | History | Annotate | Line # | Download | only in common
dmtbdump.c revision 1.1.1.20
      1       1.1    jruoho /******************************************************************************
      2       1.1    jruoho  *
      3       1.1    jruoho  * Module Name: dmtbdump - Dump ACPI data tables that contain no AML code
      4       1.1    jruoho  *
      5       1.1    jruoho  *****************************************************************************/
      6       1.1    jruoho 
      7   1.1.1.2    jruoho /*
      8  1.1.1.19  christos  * Copyright (C) 2000 - 2022, Intel Corp.
      9       1.1    jruoho  * All rights reserved.
     10       1.1    jruoho  *
     11   1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12   1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13   1.1.1.2    jruoho  * are met:
     14   1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15   1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16   1.1.1.2    jruoho  *    without modification.
     17   1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18   1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19   1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20   1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21   1.1.1.2    jruoho  *    binary redistribution.
     22   1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23   1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24   1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25   1.1.1.2    jruoho  *
     26   1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27   1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28   1.1.1.2    jruoho  * Software Foundation.
     29   1.1.1.2    jruoho  *
     30   1.1.1.2    jruoho  * NO WARRANTY
     31   1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32   1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.17  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34   1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35   1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36   1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37   1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38   1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39   1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40   1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41   1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42   1.1.1.2    jruoho  */
     43       1.1    jruoho 
     44       1.1    jruoho #include "acpi.h"
     45       1.1    jruoho #include "accommon.h"
     46       1.1    jruoho #include "acdisasm.h"
     47       1.1    jruoho #include "actables.h"
     48       1.1    jruoho 
     49       1.1    jruoho /* This module used for application-level code only */
     50       1.1    jruoho 
     51       1.1    jruoho #define _COMPONENT          ACPI_CA_DISASSEMBLER
     52       1.1    jruoho         ACPI_MODULE_NAME    ("dmtbdump")
     53       1.1    jruoho 
     54       1.1    jruoho 
     55  1.1.1.11  christos /* Local prototypes */
     56   1.1.1.4  christos 
     57  1.1.1.11  christos static void
     58  1.1.1.11  christos AcpiDmValidateFadtLength (
     59  1.1.1.11  christos     UINT32                  Revision,
     60  1.1.1.11  christos     UINT32                  Length);
     61   1.1.1.2    jruoho 
     62   1.1.1.4  christos 
     63   1.1.1.4  christos /*******************************************************************************
     64   1.1.1.4  christos  *
     65   1.1.1.4  christos  * FUNCTION:    AcpiDmDumpBuffer
     66   1.1.1.4  christos  *
     67   1.1.1.4  christos  * PARAMETERS:  Table               - ACPI Table or subtable
     68   1.1.1.4  christos  *              BufferOffset        - Offset of buffer from Table above
     69   1.1.1.4  christos  *              Length              - Length of the buffer
     70   1.1.1.4  christos  *              AbsoluteOffset      - Offset of buffer in the main ACPI table
     71   1.1.1.4  christos  *              Header              - Name of the buffer field (printed on the
     72   1.1.1.4  christos  *                                    first line only.)
     73   1.1.1.4  christos  *
     74   1.1.1.4  christos  * RETURN:      None
     75   1.1.1.4  christos  *
     76   1.1.1.4  christos  * DESCRIPTION: Format the contents of an arbitrary length data buffer (in the
     77   1.1.1.4  christos  *              disassembler output format.)
     78   1.1.1.4  christos  *
     79   1.1.1.4  christos  ******************************************************************************/
     80   1.1.1.4  christos 
     81   1.1.1.6  christos void
     82   1.1.1.4  christos AcpiDmDumpBuffer (
     83   1.1.1.4  christos     void                    *Table,
     84   1.1.1.4  christos     UINT32                  BufferOffset,
     85   1.1.1.4  christos     UINT32                  Length,
     86   1.1.1.4  christos     UINT32                  AbsoluteOffset,
     87   1.1.1.7  christos     char                    *Header)
     88   1.1.1.4  christos {
     89   1.1.1.4  christos     UINT8                   *Buffer;
     90  1.1.1.18  christos     UINT8                   BufChar;
     91   1.1.1.4  christos     UINT32                  i;
     92  1.1.1.18  christos     UINT32                  j;
     93   1.1.1.4  christos 
     94   1.1.1.4  christos 
     95   1.1.1.4  christos     if (!Length)
     96   1.1.1.4  christos     {
     97   1.1.1.4  christos         return;
     98   1.1.1.4  christos     }
     99   1.1.1.4  christos 
    100   1.1.1.4  christos     Buffer = ACPI_CAST_PTR (UINT8, Table) + BufferOffset;
    101   1.1.1.4  christos     i = 0;
    102   1.1.1.4  christos 
    103   1.1.1.4  christos     while (i < Length)
    104   1.1.1.4  christos     {
    105  1.1.1.18  christos         if ((Length > 16) && (i != 0))
    106   1.1.1.4  christos         {
    107  1.1.1.18  christos         if ((Length - i) < 16)
    108  1.1.1.18  christos             AcpiOsPrintf ("\n/* %3.3Xh %4.4u %3u */                            ", AbsoluteOffset, AbsoluteOffset, Length - i);
    109  1.1.1.18  christos         else
    110  1.1.1.18  christos             AcpiOsPrintf ("\n/* %3.3Xh %4.4u  16 */                            ", AbsoluteOffset, AbsoluteOffset);
    111  1.1.1.18  christos         }
    112  1.1.1.18  christos         AbsoluteOffset += 16;
    113  1.1.1.18  christos 
    114  1.1.1.18  christos         /* Emit the raw data bytes*/
    115   1.1.1.6  christos 
    116  1.1.1.18  christos         for (j = 0; j < 16; j++)
    117  1.1.1.18  christos         {
    118  1.1.1.18  christos             if (i + j >= Length)
    119   1.1.1.6  christos             {
    120  1.1.1.18  christos                 /* Dump fill spaces */
    121  1.1.1.18  christos 
    122  1.1.1.18  christos                 AcpiOsPrintf ("%*s", (48 - (3 * (Length -i))), " ");
    123  1.1.1.18  christos                 break;
    124   1.1.1.6  christos             }
    125  1.1.1.18  christos             AcpiOsPrintf ("%.02X ", Buffer[(ACPI_SIZE) i + j]);
    126  1.1.1.18  christos         }
    127  1.1.1.18  christos 
    128  1.1.1.18  christos         /* Emit the ASCII equivalent to the raw data bytes */
    129  1.1.1.18  christos 
    130  1.1.1.18  christos         for (j = 0; j < 16; j++)
    131  1.1.1.18  christos         {
    132  1.1.1.18  christos             if (i + j >= Length)
    133  1.1.1.18  christos             {
    134  1.1.1.18  christos                 AcpiOsPrintf (" */\\\n");
    135  1.1.1.18  christos                 return;
    136  1.1.1.18  christos             }
    137  1.1.1.18  christos 
    138  1.1.1.18  christos             /*
    139  1.1.1.18  christos              * Add comment characters so rest of line is ignored when
    140  1.1.1.18  christos              * compiled
    141  1.1.1.18  christos              */
    142  1.1.1.18  christos             if (j == 0)
    143  1.1.1.18  christos             {
    144  1.1.1.18  christos                 AcpiOsPrintf ("/* ");
    145  1.1.1.18  christos             }
    146  1.1.1.18  christos 
    147  1.1.1.18  christos             BufChar = Buffer[(ACPI_SIZE) i + j];
    148  1.1.1.18  christos             if (isprint (BufChar))
    149  1.1.1.18  christos             {
    150  1.1.1.18  christos                 AcpiOsPrintf ("%c", BufChar);
    151  1.1.1.18  christos             }
    152  1.1.1.18  christos             else
    153  1.1.1.18  christos             {
    154  1.1.1.18  christos                 AcpiOsPrintf (".");
    155  1.1.1.18  christos             }
    156  1.1.1.18  christos         }
    157  1.1.1.18  christos 
    158  1.1.1.18  christos         /* Done with that line. */
    159  1.1.1.18  christos         /* Close the comment and insert a backslash - line continuation character */
    160  1.1.1.18  christos 
    161  1.1.1.18  christos         if (Length > 16)
    162  1.1.1.18  christos         {
    163  1.1.1.18  christos             AcpiOsPrintf (" */\\");
    164  1.1.1.18  christos         }
    165  1.1.1.18  christos         else
    166  1.1.1.18  christos         {
    167  1.1.1.18  christos             AcpiOsPrintf (" */\\");
    168   1.1.1.4  christos         }
    169   1.1.1.4  christos 
    170  1.1.1.18  christos         i += 16; /* Point to next line */
    171   1.1.1.4  christos     }
    172   1.1.1.4  christos 
    173   1.1.1.4  christos     AcpiOsPrintf ("\n");
    174   1.1.1.4  christos }
    175   1.1.1.4  christos 
    176   1.1.1.2    jruoho 
    177       1.1    jruoho /*******************************************************************************
    178       1.1    jruoho  *
    179   1.1.1.7  christos  * FUNCTION:    AcpiDmDumpUnicode
    180   1.1.1.7  christos  *
    181   1.1.1.7  christos  * PARAMETERS:  Table               - ACPI Table or subtable
    182   1.1.1.7  christos  *              BufferOffset        - Offset of buffer from Table above
    183   1.1.1.7  christos  *              ByteLength          - Length of the buffer
    184   1.1.1.7  christos  *
    185   1.1.1.7  christos  * RETURN:      None
    186   1.1.1.7  christos  *
    187   1.1.1.7  christos  * DESCRIPTION: Validate and dump the contents of a buffer that contains
    188   1.1.1.7  christos  *              unicode data. The output is a standard ASCII string. If it
    189   1.1.1.7  christos  *              appears that the data is not unicode, the buffer is dumped
    190   1.1.1.7  christos  *              as hex characters.
    191   1.1.1.7  christos  *
    192   1.1.1.7  christos  ******************************************************************************/
    193   1.1.1.7  christos 
    194   1.1.1.7  christos void
    195   1.1.1.7  christos AcpiDmDumpUnicode (
    196   1.1.1.7  christos     void                    *Table,
    197   1.1.1.7  christos     UINT32                  BufferOffset,
    198   1.1.1.7  christos     UINT32                  ByteLength)
    199   1.1.1.7  christos {
    200   1.1.1.7  christos     UINT8                   *Buffer;
    201   1.1.1.7  christos     UINT32                  Length;
    202   1.1.1.7  christos     UINT32                  i;
    203   1.1.1.7  christos 
    204   1.1.1.7  christos 
    205   1.1.1.7  christos     Buffer = ((UINT8 *) Table) + BufferOffset;
    206   1.1.1.7  christos     Length = ByteLength - 2; /* Last two bytes are the null terminator */
    207   1.1.1.7  christos 
    208   1.1.1.7  christos     /* Ensure all low bytes are entirely printable ASCII */
    209   1.1.1.7  christos 
    210   1.1.1.7  christos     for (i = 0; i < Length; i += 2)
    211   1.1.1.7  christos     {
    212   1.1.1.7  christos         if (!isprint (Buffer[i]))
    213   1.1.1.7  christos         {
    214   1.1.1.7  christos             goto DumpRawBuffer;
    215   1.1.1.7  christos         }
    216   1.1.1.7  christos     }
    217   1.1.1.7  christos 
    218   1.1.1.7  christos     /* Ensure all high bytes are zero */
    219   1.1.1.7  christos 
    220   1.1.1.7  christos     for (i = 1; i < Length; i += 2)
    221   1.1.1.7  christos     {
    222   1.1.1.7  christos         if (Buffer[i])
    223   1.1.1.7  christos         {
    224   1.1.1.7  christos             goto DumpRawBuffer;
    225   1.1.1.7  christos         }
    226   1.1.1.7  christos     }
    227   1.1.1.7  christos 
    228   1.1.1.7  christos     /* Dump the buffer as a normal string */
    229   1.1.1.7  christos 
    230   1.1.1.7  christos     AcpiOsPrintf ("\"");
    231   1.1.1.7  christos     for (i = 0; i < Length; i += 2)
    232   1.1.1.7  christos     {
    233   1.1.1.7  christos         AcpiOsPrintf ("%c", Buffer[i]);
    234   1.1.1.7  christos     }
    235   1.1.1.8  christos 
    236   1.1.1.7  christos     AcpiOsPrintf ("\"\n");
    237   1.1.1.7  christos     return;
    238   1.1.1.7  christos 
    239   1.1.1.7  christos DumpRawBuffer:
    240   1.1.1.7  christos     AcpiDmDumpBuffer (Table, BufferOffset, ByteLength,
    241   1.1.1.7  christos         BufferOffset, NULL);
    242   1.1.1.7  christos     AcpiOsPrintf ("\n");
    243   1.1.1.7  christos }
    244   1.1.1.7  christos 
    245   1.1.1.7  christos 
    246   1.1.1.7  christos /*******************************************************************************
    247   1.1.1.7  christos  *
    248       1.1    jruoho  * FUNCTION:    AcpiDmDumpRsdp
    249       1.1    jruoho  *
    250       1.1    jruoho  * PARAMETERS:  Table               - A RSDP
    251       1.1    jruoho  *
    252   1.1.1.2    jruoho  * RETURN:      Length of the table (there is not always a length field,
    253   1.1.1.2    jruoho  *              use revision or length if available (ACPI 2.0+))
    254       1.1    jruoho  *
    255       1.1    jruoho  * DESCRIPTION: Format the contents of a RSDP
    256       1.1    jruoho  *
    257       1.1    jruoho  ******************************************************************************/
    258       1.1    jruoho 
    259       1.1    jruoho UINT32
    260       1.1    jruoho AcpiDmDumpRsdp (
    261       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    262       1.1    jruoho {
    263   1.1.1.2    jruoho     ACPI_TABLE_RSDP         *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
    264   1.1.1.2    jruoho     UINT32                  Length = sizeof (ACPI_RSDP_COMMON);
    265   1.1.1.2    jruoho     UINT8                   Checksum;
    266   1.1.1.7  christos     ACPI_STATUS             Status;
    267       1.1    jruoho 
    268       1.1    jruoho 
    269       1.1    jruoho     /* Dump the common ACPI 1.0 portion */
    270       1.1    jruoho 
    271   1.1.1.7  christos     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1);
    272   1.1.1.7  christos     if (ACPI_FAILURE (Status))
    273   1.1.1.7  christos     {
    274   1.1.1.7  christos         return (Length);
    275   1.1.1.7  christos     }
    276       1.1    jruoho 
    277   1.1.1.2    jruoho     /* Validate the first checksum */
    278       1.1    jruoho 
    279  1.1.1.20  christos     Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
    280   1.1.1.8  christos         Rsdp->Checksum);
    281   1.1.1.2    jruoho     if (Checksum != Rsdp->Checksum)
    282       1.1    jruoho     {
    283   1.1.1.2    jruoho         AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n",
    284   1.1.1.2    jruoho             Checksum);
    285   1.1.1.2    jruoho     }
    286   1.1.1.2    jruoho 
    287   1.1.1.2    jruoho     /* The RSDP for ACPI 2.0+ contains more data and has a Length field */
    288   1.1.1.2    jruoho 
    289   1.1.1.2    jruoho     if (Rsdp->Revision > 0)
    290   1.1.1.2    jruoho     {
    291   1.1.1.2    jruoho         Length = Rsdp->Length;
    292   1.1.1.7  christos         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2);
    293   1.1.1.7  christos         if (ACPI_FAILURE (Status))
    294   1.1.1.7  christos         {
    295   1.1.1.7  christos             return (Length);
    296   1.1.1.7  christos         }
    297   1.1.1.2    jruoho 
    298   1.1.1.2    jruoho         /* Validate the extended checksum over entire RSDP */
    299   1.1.1.2    jruoho 
    300  1.1.1.20  christos         Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
    301   1.1.1.8  christos             Rsdp->ExtendedChecksum);
    302   1.1.1.2    jruoho         if (Checksum != Rsdp->ExtendedChecksum)
    303   1.1.1.2    jruoho         {
    304   1.1.1.2    jruoho             AcpiOsPrintf (
    305   1.1.1.2    jruoho                 "/* Incorrect Extended Checksum above, should be 0x%2.2X */\n",
    306   1.1.1.2    jruoho                 Checksum);
    307   1.1.1.2    jruoho         }
    308       1.1    jruoho     }
    309       1.1    jruoho 
    310       1.1    jruoho     return (Length);
    311       1.1    jruoho }
    312       1.1    jruoho 
    313       1.1    jruoho 
    314       1.1    jruoho /*******************************************************************************
    315       1.1    jruoho  *
    316       1.1    jruoho  * FUNCTION:    AcpiDmDumpRsdt
    317       1.1    jruoho  *
    318       1.1    jruoho  * PARAMETERS:  Table               - A RSDT
    319       1.1    jruoho  *
    320       1.1    jruoho  * RETURN:      None
    321       1.1    jruoho  *
    322       1.1    jruoho  * DESCRIPTION: Format the contents of a RSDT
    323       1.1    jruoho  *
    324       1.1    jruoho  ******************************************************************************/
    325       1.1    jruoho 
    326       1.1    jruoho void
    327       1.1    jruoho AcpiDmDumpRsdt (
    328       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    329       1.1    jruoho {
    330       1.1    jruoho     UINT32                  *Array;
    331       1.1    jruoho     UINT32                  Entries;
    332       1.1    jruoho     UINT32                  Offset;
    333       1.1    jruoho     UINT32                  i;
    334       1.1    jruoho 
    335       1.1    jruoho 
    336       1.1    jruoho     /* Point to start of table pointer array */
    337       1.1    jruoho 
    338       1.1    jruoho     Array = ACPI_CAST_PTR (ACPI_TABLE_RSDT, Table)->TableOffsetEntry;
    339       1.1    jruoho     Offset = sizeof (ACPI_TABLE_HEADER);
    340       1.1    jruoho 
    341       1.1    jruoho     /* RSDT uses 32-bit pointers */
    342       1.1    jruoho 
    343       1.1    jruoho     Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT32);
    344       1.1    jruoho 
    345       1.1    jruoho     for (i = 0; i < Entries; i++)
    346       1.1    jruoho     {
    347       1.1    jruoho         AcpiDmLineHeader2 (Offset, sizeof (UINT32), "ACPI Table Address", i);
    348       1.1    jruoho         AcpiOsPrintf ("%8.8X\n", Array[i]);
    349       1.1    jruoho         Offset += sizeof (UINT32);
    350       1.1    jruoho     }
    351       1.1    jruoho }
    352       1.1    jruoho 
    353       1.1    jruoho 
    354       1.1    jruoho /*******************************************************************************
    355       1.1    jruoho  *
    356       1.1    jruoho  * FUNCTION:    AcpiDmDumpXsdt
    357       1.1    jruoho  *
    358       1.1    jruoho  * PARAMETERS:  Table               - A XSDT
    359       1.1    jruoho  *
    360       1.1    jruoho  * RETURN:      None
    361       1.1    jruoho  *
    362       1.1    jruoho  * DESCRIPTION: Format the contents of a XSDT
    363       1.1    jruoho  *
    364       1.1    jruoho  ******************************************************************************/
    365       1.1    jruoho 
    366       1.1    jruoho void
    367       1.1    jruoho AcpiDmDumpXsdt (
    368       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    369       1.1    jruoho {
    370       1.1    jruoho     UINT64                  *Array;
    371       1.1    jruoho     UINT32                  Entries;
    372       1.1    jruoho     UINT32                  Offset;
    373       1.1    jruoho     UINT32                  i;
    374       1.1    jruoho 
    375       1.1    jruoho 
    376       1.1    jruoho     /* Point to start of table pointer array */
    377       1.1    jruoho 
    378       1.1    jruoho     Array = ACPI_CAST_PTR (ACPI_TABLE_XSDT, Table)->TableOffsetEntry;
    379       1.1    jruoho     Offset = sizeof (ACPI_TABLE_HEADER);
    380       1.1    jruoho 
    381       1.1    jruoho     /* XSDT uses 64-bit pointers */
    382       1.1    jruoho 
    383       1.1    jruoho     Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT64);
    384       1.1    jruoho 
    385       1.1    jruoho     for (i = 0; i < Entries; i++)
    386       1.1    jruoho     {
    387       1.1    jruoho         AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
    388       1.1    jruoho         AcpiOsPrintf ("%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Array[i]));
    389       1.1    jruoho         Offset += sizeof (UINT64);
    390       1.1    jruoho     }
    391       1.1    jruoho }
    392       1.1    jruoho 
    393       1.1    jruoho 
    394       1.1    jruoho /*******************************************************************************
    395       1.1    jruoho  *
    396       1.1    jruoho  * FUNCTION:    AcpiDmDumpFadt
    397       1.1    jruoho  *
    398       1.1    jruoho  * PARAMETERS:  Table               - A FADT
    399       1.1    jruoho  *
    400       1.1    jruoho  * RETURN:      None
    401       1.1    jruoho  *
    402       1.1    jruoho  * DESCRIPTION: Format the contents of a FADT
    403       1.1    jruoho  *
    404   1.1.1.2    jruoho  * NOTE:        We cannot depend on the FADT version to indicate the actual
    405   1.1.1.2    jruoho  *              contents of the FADT because of BIOS bugs. The table length
    406   1.1.1.2    jruoho  *              is the only reliable indicator.
    407   1.1.1.2    jruoho  *
    408       1.1    jruoho  ******************************************************************************/
    409       1.1    jruoho 
    410       1.1    jruoho void
    411       1.1    jruoho AcpiDmDumpFadt (
    412       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    413       1.1    jruoho {
    414   1.1.1.7  christos     ACPI_STATUS             Status;
    415       1.1    jruoho 
    416       1.1    jruoho 
    417  1.1.1.11  christos     /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
    418  1.1.1.10  christos 
    419  1.1.1.11  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    420  1.1.1.11  christos         AcpiDmTableInfoFadt1);
    421  1.1.1.11  christos     if (ACPI_FAILURE (Status))
    422   1.1.1.7  christos     {
    423   1.1.1.7  christos         return;
    424   1.1.1.7  christos     }
    425       1.1    jruoho 
    426  1.1.1.11  christos     /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
    427  1.1.1.11  christos 
    428  1.1.1.11  christos     if ((Table->Length > ACPI_FADT_V1_SIZE) &&
    429  1.1.1.11  christos         (Table->Length <= ACPI_FADT_V2_SIZE))
    430  1.1.1.10  christos     {
    431  1.1.1.11  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    432  1.1.1.11  christos             AcpiDmTableInfoFadt2);
    433  1.1.1.11  christos         if (ACPI_FAILURE (Status))
    434   1.1.1.7  christos         {
    435  1.1.1.11  christos             return;
    436   1.1.1.7  christos         }
    437       1.1    jruoho     }
    438       1.1    jruoho 
    439  1.1.1.11  christos     /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
    440  1.1.1.11  christos 
    441  1.1.1.11  christos     else if (Table->Length > ACPI_FADT_V2_SIZE)
    442       1.1    jruoho     {
    443  1.1.1.11  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    444  1.1.1.11  christos             AcpiDmTableInfoFadt3);
    445  1.1.1.11  christos         if (ACPI_FAILURE (Status))
    446   1.1.1.7  christos         {
    447  1.1.1.11  christos             return;
    448   1.1.1.7  christos         }
    449   1.1.1.4  christos 
    450  1.1.1.11  christos         /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
    451   1.1.1.4  christos 
    452  1.1.1.11  christos         if (Table->Length > ACPI_FADT_V3_SIZE)
    453   1.1.1.4  christos         {
    454  1.1.1.11  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    455  1.1.1.11  christos                 AcpiDmTableInfoFadt5);
    456  1.1.1.11  christos             if (ACPI_FAILURE (Status))
    457  1.1.1.11  christos             {
    458  1.1.1.11  christos                 return;
    459  1.1.1.11  christos             }
    460   1.1.1.7  christos         }
    461   1.1.1.7  christos 
    462  1.1.1.11  christos         /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
    463  1.1.1.11  christos 
    464  1.1.1.11  christos         if (Table->Length > ACPI_FADT_V3_SIZE)
    465   1.1.1.7  christos         {
    466  1.1.1.11  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    467  1.1.1.11  christos                 AcpiDmTableInfoFadt6);
    468  1.1.1.11  christos             if (ACPI_FAILURE (Status))
    469  1.1.1.11  christos             {
    470  1.1.1.11  christos                 return;
    471  1.1.1.11  christos             }
    472   1.1.1.4  christos         }
    473       1.1    jruoho     }
    474       1.1    jruoho 
    475  1.1.1.11  christos     /* Validate various fields in the FADT, including length */
    476       1.1    jruoho 
    477       1.1    jruoho     AcpiTbCreateLocalFadt (Table, Table->Length);
    478  1.1.1.11  christos 
    479  1.1.1.11  christos     /* Validate FADT length against the revision */
    480  1.1.1.11  christos 
    481  1.1.1.11  christos     AcpiDmValidateFadtLength (Table->Revision, Table->Length);
    482  1.1.1.11  christos }
    483  1.1.1.11  christos 
    484  1.1.1.11  christos 
    485  1.1.1.11  christos /*******************************************************************************
    486  1.1.1.11  christos  *
    487  1.1.1.11  christos  * FUNCTION:    AcpiDmValidateFadtLength
    488  1.1.1.11  christos  *
    489  1.1.1.11  christos  * PARAMETERS:  Revision            - FADT revision (Header->Revision)
    490  1.1.1.11  christos  *              Length              - FADT length (Header->Length
    491  1.1.1.11  christos  *
    492  1.1.1.11  christos  * RETURN:      None
    493  1.1.1.11  christos  *
    494  1.1.1.11  christos  * DESCRIPTION: Check the FADT revision against the expected table length for
    495  1.1.1.11  christos  *              that revision. Issue a warning if the length is not what was
    496  1.1.1.11  christos  *              expected. This seems to be such a common BIOS bug that the
    497  1.1.1.11  christos  *              FADT revision has been rendered virtually meaningless.
    498  1.1.1.11  christos  *
    499  1.1.1.11  christos  ******************************************************************************/
    500  1.1.1.11  christos 
    501  1.1.1.11  christos static void
    502  1.1.1.11  christos AcpiDmValidateFadtLength (
    503  1.1.1.11  christos     UINT32                  Revision,
    504  1.1.1.11  christos     UINT32                  Length)
    505  1.1.1.11  christos {
    506  1.1.1.11  christos     UINT32                  ExpectedLength;
    507  1.1.1.11  christos 
    508  1.1.1.11  christos 
    509  1.1.1.11  christos     switch (Revision)
    510  1.1.1.11  christos     {
    511  1.1.1.11  christos     case 0:
    512  1.1.1.11  christos 
    513  1.1.1.11  christos         AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
    514  1.1.1.11  christos         return;
    515  1.1.1.11  christos 
    516  1.1.1.11  christos     case 1:
    517  1.1.1.11  christos 
    518  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V1_SIZE;
    519  1.1.1.11  christos         break;
    520  1.1.1.11  christos 
    521  1.1.1.11  christos     case 2:
    522  1.1.1.11  christos 
    523  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V2_SIZE;
    524  1.1.1.11  christos         break;
    525  1.1.1.11  christos 
    526  1.1.1.11  christos     case 3:
    527  1.1.1.11  christos     case 4:
    528  1.1.1.11  christos 
    529  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V3_SIZE;
    530  1.1.1.11  christos         break;
    531  1.1.1.11  christos 
    532  1.1.1.11  christos     case 5:
    533  1.1.1.11  christos 
    534  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V5_SIZE;
    535  1.1.1.11  christos         break;
    536  1.1.1.11  christos 
    537  1.1.1.11  christos     default:
    538  1.1.1.11  christos 
    539  1.1.1.11  christos         return;
    540  1.1.1.11  christos     }
    541  1.1.1.11  christos 
    542  1.1.1.11  christos     if (Length == ExpectedLength)
    543  1.1.1.11  christos     {
    544  1.1.1.11  christos         return;
    545  1.1.1.11  christos     }
    546  1.1.1.11  christos 
    547  1.1.1.11  christos     AcpiOsPrintf (
    548  1.1.1.11  christos         "\n// ACPI Warning: FADT revision %X does not match length: "
    549  1.1.1.11  christos         "found %X expected %X\n",
    550  1.1.1.11  christos         Revision, Length, ExpectedLength);
    551       1.1    jruoho }
    552