Home | History | Annotate | Line # | Download | only in common
dmtbdump.c revision 1.1.1.22
      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.21  christos  * Copyright (C) 2000 - 2023, 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.22  christos         AcpiOsPrintf (" */\\");
    162   1.1.1.4  christos 
    163  1.1.1.18  christos         i += 16; /* Point to next line */
    164   1.1.1.4  christos     }
    165   1.1.1.4  christos 
    166   1.1.1.4  christos     AcpiOsPrintf ("\n");
    167   1.1.1.4  christos }
    168   1.1.1.4  christos 
    169   1.1.1.2    jruoho 
    170       1.1    jruoho /*******************************************************************************
    171       1.1    jruoho  *
    172   1.1.1.7  christos  * FUNCTION:    AcpiDmDumpUnicode
    173   1.1.1.7  christos  *
    174   1.1.1.7  christos  * PARAMETERS:  Table               - ACPI Table or subtable
    175   1.1.1.7  christos  *              BufferOffset        - Offset of buffer from Table above
    176   1.1.1.7  christos  *              ByteLength          - Length of the buffer
    177   1.1.1.7  christos  *
    178   1.1.1.7  christos  * RETURN:      None
    179   1.1.1.7  christos  *
    180   1.1.1.7  christos  * DESCRIPTION: Validate and dump the contents of a buffer that contains
    181   1.1.1.7  christos  *              unicode data. The output is a standard ASCII string. If it
    182   1.1.1.7  christos  *              appears that the data is not unicode, the buffer is dumped
    183   1.1.1.7  christos  *              as hex characters.
    184   1.1.1.7  christos  *
    185   1.1.1.7  christos  ******************************************************************************/
    186   1.1.1.7  christos 
    187   1.1.1.7  christos void
    188   1.1.1.7  christos AcpiDmDumpUnicode (
    189   1.1.1.7  christos     void                    *Table,
    190   1.1.1.7  christos     UINT32                  BufferOffset,
    191   1.1.1.7  christos     UINT32                  ByteLength)
    192   1.1.1.7  christos {
    193   1.1.1.7  christos     UINT8                   *Buffer;
    194   1.1.1.7  christos     UINT32                  Length;
    195   1.1.1.7  christos     UINT32                  i;
    196   1.1.1.7  christos 
    197   1.1.1.7  christos 
    198   1.1.1.7  christos     Buffer = ((UINT8 *) Table) + BufferOffset;
    199   1.1.1.7  christos     Length = ByteLength - 2; /* Last two bytes are the null terminator */
    200   1.1.1.7  christos 
    201   1.1.1.7  christos     /* Ensure all low bytes are entirely printable ASCII */
    202   1.1.1.7  christos 
    203   1.1.1.7  christos     for (i = 0; i < Length; i += 2)
    204   1.1.1.7  christos     {
    205   1.1.1.7  christos         if (!isprint (Buffer[i]))
    206   1.1.1.7  christos         {
    207   1.1.1.7  christos             goto DumpRawBuffer;
    208   1.1.1.7  christos         }
    209   1.1.1.7  christos     }
    210   1.1.1.7  christos 
    211   1.1.1.7  christos     /* Ensure all high bytes are zero */
    212   1.1.1.7  christos 
    213   1.1.1.7  christos     for (i = 1; i < Length; i += 2)
    214   1.1.1.7  christos     {
    215   1.1.1.7  christos         if (Buffer[i])
    216   1.1.1.7  christos         {
    217   1.1.1.7  christos             goto DumpRawBuffer;
    218   1.1.1.7  christos         }
    219   1.1.1.7  christos     }
    220   1.1.1.7  christos 
    221   1.1.1.7  christos     /* Dump the buffer as a normal string */
    222   1.1.1.7  christos 
    223   1.1.1.7  christos     AcpiOsPrintf ("\"");
    224   1.1.1.7  christos     for (i = 0; i < Length; i += 2)
    225   1.1.1.7  christos     {
    226   1.1.1.7  christos         AcpiOsPrintf ("%c", Buffer[i]);
    227   1.1.1.7  christos     }
    228   1.1.1.8  christos 
    229   1.1.1.7  christos     AcpiOsPrintf ("\"\n");
    230   1.1.1.7  christos     return;
    231   1.1.1.7  christos 
    232   1.1.1.7  christos DumpRawBuffer:
    233   1.1.1.7  christos     AcpiDmDumpBuffer (Table, BufferOffset, ByteLength,
    234   1.1.1.7  christos         BufferOffset, NULL);
    235   1.1.1.7  christos     AcpiOsPrintf ("\n");
    236   1.1.1.7  christos }
    237   1.1.1.7  christos 
    238   1.1.1.7  christos 
    239   1.1.1.7  christos /*******************************************************************************
    240   1.1.1.7  christos  *
    241       1.1    jruoho  * FUNCTION:    AcpiDmDumpRsdp
    242       1.1    jruoho  *
    243       1.1    jruoho  * PARAMETERS:  Table               - A RSDP
    244       1.1    jruoho  *
    245   1.1.1.2    jruoho  * RETURN:      Length of the table (there is not always a length field,
    246   1.1.1.2    jruoho  *              use revision or length if available (ACPI 2.0+))
    247       1.1    jruoho  *
    248       1.1    jruoho  * DESCRIPTION: Format the contents of a RSDP
    249       1.1    jruoho  *
    250       1.1    jruoho  ******************************************************************************/
    251       1.1    jruoho 
    252       1.1    jruoho UINT32
    253       1.1    jruoho AcpiDmDumpRsdp (
    254       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    255       1.1    jruoho {
    256   1.1.1.2    jruoho     ACPI_TABLE_RSDP         *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
    257   1.1.1.2    jruoho     UINT32                  Length = sizeof (ACPI_RSDP_COMMON);
    258   1.1.1.2    jruoho     UINT8                   Checksum;
    259   1.1.1.7  christos     ACPI_STATUS             Status;
    260       1.1    jruoho 
    261       1.1    jruoho 
    262       1.1    jruoho     /* Dump the common ACPI 1.0 portion */
    263       1.1    jruoho 
    264   1.1.1.7  christos     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1);
    265   1.1.1.7  christos     if (ACPI_FAILURE (Status))
    266   1.1.1.7  christos     {
    267   1.1.1.7  christos         return (Length);
    268   1.1.1.7  christos     }
    269       1.1    jruoho 
    270   1.1.1.2    jruoho     /* Validate the first checksum */
    271       1.1    jruoho 
    272  1.1.1.20  christos     Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
    273   1.1.1.8  christos         Rsdp->Checksum);
    274   1.1.1.2    jruoho     if (Checksum != Rsdp->Checksum)
    275       1.1    jruoho     {
    276   1.1.1.2    jruoho         AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n",
    277   1.1.1.2    jruoho             Checksum);
    278   1.1.1.2    jruoho     }
    279   1.1.1.2    jruoho 
    280   1.1.1.2    jruoho     /* The RSDP for ACPI 2.0+ contains more data and has a Length field */
    281   1.1.1.2    jruoho 
    282   1.1.1.2    jruoho     if (Rsdp->Revision > 0)
    283   1.1.1.2    jruoho     {
    284   1.1.1.2    jruoho         Length = Rsdp->Length;
    285   1.1.1.7  christos         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2);
    286   1.1.1.7  christos         if (ACPI_FAILURE (Status))
    287   1.1.1.7  christos         {
    288   1.1.1.7  christos             return (Length);
    289   1.1.1.7  christos         }
    290   1.1.1.2    jruoho 
    291   1.1.1.2    jruoho         /* Validate the extended checksum over entire RSDP */
    292   1.1.1.2    jruoho 
    293  1.1.1.20  christos         Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
    294   1.1.1.8  christos             Rsdp->ExtendedChecksum);
    295   1.1.1.2    jruoho         if (Checksum != Rsdp->ExtendedChecksum)
    296   1.1.1.2    jruoho         {
    297   1.1.1.2    jruoho             AcpiOsPrintf (
    298   1.1.1.2    jruoho                 "/* Incorrect Extended Checksum above, should be 0x%2.2X */\n",
    299   1.1.1.2    jruoho                 Checksum);
    300   1.1.1.2    jruoho         }
    301       1.1    jruoho     }
    302       1.1    jruoho 
    303       1.1    jruoho     return (Length);
    304       1.1    jruoho }
    305       1.1    jruoho 
    306       1.1    jruoho 
    307       1.1    jruoho /*******************************************************************************
    308       1.1    jruoho  *
    309       1.1    jruoho  * FUNCTION:    AcpiDmDumpRsdt
    310       1.1    jruoho  *
    311       1.1    jruoho  * PARAMETERS:  Table               - A RSDT
    312       1.1    jruoho  *
    313       1.1    jruoho  * RETURN:      None
    314       1.1    jruoho  *
    315       1.1    jruoho  * DESCRIPTION: Format the contents of a RSDT
    316       1.1    jruoho  *
    317       1.1    jruoho  ******************************************************************************/
    318       1.1    jruoho 
    319       1.1    jruoho void
    320       1.1    jruoho AcpiDmDumpRsdt (
    321       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    322       1.1    jruoho {
    323       1.1    jruoho     UINT32                  *Array;
    324       1.1    jruoho     UINT32                  Entries;
    325       1.1    jruoho     UINT32                  Offset;
    326       1.1    jruoho     UINT32                  i;
    327       1.1    jruoho 
    328       1.1    jruoho 
    329       1.1    jruoho     /* Point to start of table pointer array */
    330       1.1    jruoho 
    331       1.1    jruoho     Array = ACPI_CAST_PTR (ACPI_TABLE_RSDT, Table)->TableOffsetEntry;
    332       1.1    jruoho     Offset = sizeof (ACPI_TABLE_HEADER);
    333       1.1    jruoho 
    334       1.1    jruoho     /* RSDT uses 32-bit pointers */
    335       1.1    jruoho 
    336       1.1    jruoho     Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT32);
    337       1.1    jruoho 
    338       1.1    jruoho     for (i = 0; i < Entries; i++)
    339       1.1    jruoho     {
    340       1.1    jruoho         AcpiDmLineHeader2 (Offset, sizeof (UINT32), "ACPI Table Address", i);
    341       1.1    jruoho         AcpiOsPrintf ("%8.8X\n", Array[i]);
    342       1.1    jruoho         Offset += sizeof (UINT32);
    343       1.1    jruoho     }
    344       1.1    jruoho }
    345       1.1    jruoho 
    346       1.1    jruoho 
    347       1.1    jruoho /*******************************************************************************
    348       1.1    jruoho  *
    349       1.1    jruoho  * FUNCTION:    AcpiDmDumpXsdt
    350       1.1    jruoho  *
    351       1.1    jruoho  * PARAMETERS:  Table               - A XSDT
    352       1.1    jruoho  *
    353       1.1    jruoho  * RETURN:      None
    354       1.1    jruoho  *
    355       1.1    jruoho  * DESCRIPTION: Format the contents of a XSDT
    356       1.1    jruoho  *
    357       1.1    jruoho  ******************************************************************************/
    358       1.1    jruoho 
    359       1.1    jruoho void
    360       1.1    jruoho AcpiDmDumpXsdt (
    361       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    362       1.1    jruoho {
    363       1.1    jruoho     UINT64                  *Array;
    364       1.1    jruoho     UINT32                  Entries;
    365       1.1    jruoho     UINT32                  Offset;
    366       1.1    jruoho     UINT32                  i;
    367       1.1    jruoho 
    368       1.1    jruoho 
    369       1.1    jruoho     /* Point to start of table pointer array */
    370       1.1    jruoho 
    371       1.1    jruoho     Array = ACPI_CAST_PTR (ACPI_TABLE_XSDT, Table)->TableOffsetEntry;
    372       1.1    jruoho     Offset = sizeof (ACPI_TABLE_HEADER);
    373       1.1    jruoho 
    374       1.1    jruoho     /* XSDT uses 64-bit pointers */
    375       1.1    jruoho 
    376       1.1    jruoho     Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT64);
    377       1.1    jruoho 
    378       1.1    jruoho     for (i = 0; i < Entries; i++)
    379       1.1    jruoho     {
    380       1.1    jruoho         AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
    381       1.1    jruoho         AcpiOsPrintf ("%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Array[i]));
    382       1.1    jruoho         Offset += sizeof (UINT64);
    383       1.1    jruoho     }
    384       1.1    jruoho }
    385       1.1    jruoho 
    386       1.1    jruoho 
    387       1.1    jruoho /*******************************************************************************
    388       1.1    jruoho  *
    389       1.1    jruoho  * FUNCTION:    AcpiDmDumpFadt
    390       1.1    jruoho  *
    391       1.1    jruoho  * PARAMETERS:  Table               - A FADT
    392       1.1    jruoho  *
    393       1.1    jruoho  * RETURN:      None
    394       1.1    jruoho  *
    395       1.1    jruoho  * DESCRIPTION: Format the contents of a FADT
    396       1.1    jruoho  *
    397   1.1.1.2    jruoho  * NOTE:        We cannot depend on the FADT version to indicate the actual
    398   1.1.1.2    jruoho  *              contents of the FADT because of BIOS bugs. The table length
    399   1.1.1.2    jruoho  *              is the only reliable indicator.
    400   1.1.1.2    jruoho  *
    401       1.1    jruoho  ******************************************************************************/
    402       1.1    jruoho 
    403       1.1    jruoho void
    404       1.1    jruoho AcpiDmDumpFadt (
    405       1.1    jruoho     ACPI_TABLE_HEADER       *Table)
    406       1.1    jruoho {
    407   1.1.1.7  christos     ACPI_STATUS             Status;
    408       1.1    jruoho 
    409       1.1    jruoho 
    410  1.1.1.11  christos     /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
    411  1.1.1.10  christos 
    412  1.1.1.11  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    413  1.1.1.11  christos         AcpiDmTableInfoFadt1);
    414  1.1.1.11  christos     if (ACPI_FAILURE (Status))
    415   1.1.1.7  christos     {
    416   1.1.1.7  christos         return;
    417   1.1.1.7  christos     }
    418       1.1    jruoho 
    419  1.1.1.11  christos     /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
    420  1.1.1.11  christos 
    421  1.1.1.11  christos     if ((Table->Length > ACPI_FADT_V1_SIZE) &&
    422  1.1.1.11  christos         (Table->Length <= ACPI_FADT_V2_SIZE))
    423  1.1.1.10  christos     {
    424  1.1.1.11  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    425  1.1.1.11  christos             AcpiDmTableInfoFadt2);
    426  1.1.1.11  christos         if (ACPI_FAILURE (Status))
    427   1.1.1.7  christos         {
    428  1.1.1.11  christos             return;
    429   1.1.1.7  christos         }
    430       1.1    jruoho     }
    431       1.1    jruoho 
    432  1.1.1.11  christos     /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
    433  1.1.1.11  christos 
    434  1.1.1.11  christos     else if (Table->Length > ACPI_FADT_V2_SIZE)
    435       1.1    jruoho     {
    436  1.1.1.11  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    437  1.1.1.11  christos             AcpiDmTableInfoFadt3);
    438  1.1.1.11  christos         if (ACPI_FAILURE (Status))
    439   1.1.1.7  christos         {
    440  1.1.1.11  christos             return;
    441   1.1.1.7  christos         }
    442   1.1.1.4  christos 
    443  1.1.1.11  christos         /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
    444   1.1.1.4  christos 
    445  1.1.1.11  christos         if (Table->Length > ACPI_FADT_V3_SIZE)
    446   1.1.1.4  christos         {
    447  1.1.1.11  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    448  1.1.1.11  christos                 AcpiDmTableInfoFadt5);
    449  1.1.1.11  christos             if (ACPI_FAILURE (Status))
    450  1.1.1.11  christos             {
    451  1.1.1.11  christos                 return;
    452  1.1.1.11  christos             }
    453   1.1.1.7  christos         }
    454   1.1.1.7  christos 
    455  1.1.1.11  christos         /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
    456  1.1.1.11  christos 
    457  1.1.1.22  christos         if (Table->Length > ACPI_FADT_V5_SIZE)
    458   1.1.1.7  christos         {
    459  1.1.1.11  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    460  1.1.1.11  christos                 AcpiDmTableInfoFadt6);
    461  1.1.1.11  christos             if (ACPI_FAILURE (Status))
    462  1.1.1.11  christos             {
    463  1.1.1.11  christos                 return;
    464  1.1.1.11  christos             }
    465   1.1.1.4  christos         }
    466       1.1    jruoho     }
    467       1.1    jruoho 
    468  1.1.1.11  christos     /* Validate various fields in the FADT, including length */
    469       1.1    jruoho 
    470       1.1    jruoho     AcpiTbCreateLocalFadt (Table, Table->Length);
    471  1.1.1.11  christos 
    472  1.1.1.11  christos     /* Validate FADT length against the revision */
    473  1.1.1.11  christos 
    474  1.1.1.11  christos     AcpiDmValidateFadtLength (Table->Revision, Table->Length);
    475  1.1.1.11  christos }
    476  1.1.1.11  christos 
    477  1.1.1.11  christos 
    478  1.1.1.11  christos /*******************************************************************************
    479  1.1.1.11  christos  *
    480  1.1.1.11  christos  * FUNCTION:    AcpiDmValidateFadtLength
    481  1.1.1.11  christos  *
    482  1.1.1.11  christos  * PARAMETERS:  Revision            - FADT revision (Header->Revision)
    483  1.1.1.11  christos  *              Length              - FADT length (Header->Length
    484  1.1.1.11  christos  *
    485  1.1.1.11  christos  * RETURN:      None
    486  1.1.1.11  christos  *
    487  1.1.1.11  christos  * DESCRIPTION: Check the FADT revision against the expected table length for
    488  1.1.1.11  christos  *              that revision. Issue a warning if the length is not what was
    489  1.1.1.11  christos  *              expected. This seems to be such a common BIOS bug that the
    490  1.1.1.11  christos  *              FADT revision has been rendered virtually meaningless.
    491  1.1.1.11  christos  *
    492  1.1.1.11  christos  ******************************************************************************/
    493  1.1.1.11  christos 
    494  1.1.1.11  christos static void
    495  1.1.1.11  christos AcpiDmValidateFadtLength (
    496  1.1.1.11  christos     UINT32                  Revision,
    497  1.1.1.11  christos     UINT32                  Length)
    498  1.1.1.11  christos {
    499  1.1.1.11  christos     UINT32                  ExpectedLength;
    500  1.1.1.11  christos 
    501  1.1.1.11  christos 
    502  1.1.1.11  christos     switch (Revision)
    503  1.1.1.11  christos     {
    504  1.1.1.11  christos     case 0:
    505  1.1.1.11  christos 
    506  1.1.1.11  christos         AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
    507  1.1.1.11  christos         return;
    508  1.1.1.11  christos 
    509  1.1.1.11  christos     case 1:
    510  1.1.1.11  christos 
    511  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V1_SIZE;
    512  1.1.1.11  christos         break;
    513  1.1.1.11  christos 
    514  1.1.1.11  christos     case 2:
    515  1.1.1.11  christos 
    516  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V2_SIZE;
    517  1.1.1.11  christos         break;
    518  1.1.1.11  christos 
    519  1.1.1.11  christos     case 3:
    520  1.1.1.11  christos     case 4:
    521  1.1.1.11  christos 
    522  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V3_SIZE;
    523  1.1.1.11  christos         break;
    524  1.1.1.11  christos 
    525  1.1.1.11  christos     case 5:
    526  1.1.1.11  christos 
    527  1.1.1.11  christos         ExpectedLength = ACPI_FADT_V5_SIZE;
    528  1.1.1.11  christos         break;
    529  1.1.1.11  christos 
    530  1.1.1.22  christos     case 6:
    531  1.1.1.22  christos 
    532  1.1.1.22  christos         ExpectedLength = ACPI_FADT_V6_SIZE;
    533  1.1.1.22  christos         break;
    534  1.1.1.22  christos 
    535  1.1.1.11  christos     default:
    536  1.1.1.11  christos 
    537  1.1.1.11  christos         return;
    538  1.1.1.11  christos     }
    539  1.1.1.11  christos 
    540  1.1.1.11  christos     if (Length == ExpectedLength)
    541  1.1.1.11  christos     {
    542  1.1.1.11  christos         return;
    543  1.1.1.11  christos     }
    544  1.1.1.11  christos 
    545  1.1.1.11  christos     AcpiOsPrintf (
    546  1.1.1.11  christos         "\n// ACPI Warning: FADT revision %X does not match length: "
    547  1.1.1.11  christos         "found %X expected %X\n",
    548  1.1.1.11  christos         Revision, Length, ExpectedLength);
    549       1.1    jruoho }
    550