Home | History | Annotate | Line # | Download | only in common
dmtbdump.c revision 1.17
      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.2  christos /*
      8  1.16  christos  * Copyright (C) 2000 - 2023, Intel Corp.
      9   1.1    jruoho  * All rights reserved.
     10   1.1    jruoho  *
     11   1.2  christos  * Redistribution and use in source and binary forms, with or without
     12   1.2  christos  * modification, are permitted provided that the following conditions
     13   1.2  christos  * are met:
     14   1.2  christos  * 1. Redistributions of source code must retain the above copyright
     15   1.2  christos  *    notice, this list of conditions, and the following disclaimer,
     16   1.2  christos  *    without modification.
     17   1.2  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18   1.2  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19   1.2  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20   1.2  christos  *    including a substantially similar Disclaimer requirement for further
     21   1.2  christos  *    binary redistribution.
     22   1.2  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23   1.2  christos  *    of any contributors may be used to endorse or promote products derived
     24   1.2  christos  *    from this software without specific prior written permission.
     25   1.2  christos  *
     26   1.2  christos  * Alternatively, this software may be distributed under the terms of the
     27   1.2  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28   1.2  christos  * Software Foundation.
     29   1.2  christos  *
     30   1.2  christos  * NO WARRANTY
     31   1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32   1.2  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.13  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34   1.2  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35   1.2  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36   1.2  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37   1.2  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38   1.2  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39   1.2  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40   1.2  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41   1.2  christos  * POSSIBILITY OF SUCH DAMAGES.
     42   1.2  christos  */
     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.7  christos /* Local prototypes */
     56   1.2  christos 
     57   1.7  christos static void
     58   1.7  christos AcpiDmValidateFadtLength (
     59   1.7  christos     UINT32                  Revision,
     60   1.7  christos     UINT32                  Length);
     61   1.2  christos 
     62   1.2  christos 
     63   1.2  christos /*******************************************************************************
     64   1.2  christos  *
     65   1.2  christos  * FUNCTION:    AcpiDmDumpBuffer
     66   1.2  christos  *
     67   1.2  christos  * PARAMETERS:  Table               - ACPI Table or subtable
     68   1.2  christos  *              BufferOffset        - Offset of buffer from Table above
     69   1.2  christos  *              Length              - Length of the buffer
     70   1.2  christos  *              AbsoluteOffset      - Offset of buffer in the main ACPI table
     71   1.2  christos  *              Header              - Name of the buffer field (printed on the
     72   1.2  christos  *                                    first line only.)
     73   1.2  christos  *
     74   1.2  christos  * RETURN:      None
     75   1.2  christos  *
     76   1.2  christos  * DESCRIPTION: Format the contents of an arbitrary length data buffer (in the
     77   1.2  christos  *              disassembler output format.)
     78   1.2  christos  *
     79   1.2  christos  ******************************************************************************/
     80   1.2  christos 
     81   1.2  christos void
     82   1.2  christos AcpiDmDumpBuffer (
     83   1.2  christos     void                    *Table,
     84   1.2  christos     UINT32                  BufferOffset,
     85   1.2  christos     UINT32                  Length,
     86   1.2  christos     UINT32                  AbsoluteOffset,
     87   1.3  christos     char                    *Header)
     88   1.2  christos {
     89   1.2  christos     UINT8                   *Buffer;
     90  1.17  christos     UINT8                   BufChar;
     91   1.2  christos     UINT32                  i;
     92  1.17  christos     UINT32                  j;
     93   1.2  christos 
     94   1.2  christos 
     95   1.2  christos     if (!Length)
     96   1.2  christos     {
     97   1.2  christos         return;
     98   1.2  christos     }
     99   1.2  christos 
    100   1.2  christos     Buffer = ACPI_CAST_PTR (UINT8, Table) + BufferOffset;
    101   1.2  christos     i = 0;
    102   1.2  christos 
    103   1.2  christos     while (i < Length)
    104   1.2  christos     {
    105  1.17  christos         if ((Length > 16) && (i != 0))
    106   1.2  christos         {
    107  1.17  christos         if ((Length - i) < 16)
    108  1.17  christos             AcpiOsPrintf ("\n/* %3.3Xh %4.4u %3u */                            ", AbsoluteOffset, AbsoluteOffset, Length - i);
    109  1.17  christos         else
    110  1.17  christos             AcpiOsPrintf ("\n/* %3.3Xh %4.4u  16 */                            ", AbsoluteOffset, AbsoluteOffset);
    111  1.17  christos         }
    112  1.17  christos         AbsoluteOffset += 16;
    113  1.17  christos 
    114  1.17  christos         /* Emit the raw data bytes*/
    115   1.3  christos 
    116  1.17  christos         for (j = 0; j < 16; j++)
    117  1.17  christos         {
    118  1.17  christos             if (i + j >= Length)
    119   1.2  christos             {
    120  1.17  christos                 /* Dump fill spaces */
    121  1.17  christos 
    122  1.17  christos                 AcpiOsPrintf ("%*s", (48 - (3 * (Length -i))), " ");
    123  1.17  christos                 break;
    124   1.2  christos             }
    125  1.17  christos             AcpiOsPrintf ("%.02X ", Buffer[(ACPI_SIZE) i + j]);
    126   1.2  christos         }
    127   1.2  christos 
    128  1.17  christos         /* Emit the ASCII equivalent to the raw data bytes */
    129  1.17  christos 
    130  1.17  christos         for (j = 0; j < 16; j++)
    131  1.17  christos         {
    132  1.17  christos             if (i + j >= Length)
    133  1.17  christos             {
    134  1.17  christos                 AcpiOsPrintf (" */\\\n");
    135  1.17  christos                 return;
    136  1.17  christos             }
    137  1.17  christos 
    138  1.17  christos             /*
    139  1.17  christos              * Add comment characters so rest of line is ignored when
    140  1.17  christos              * compiled
    141  1.17  christos              */
    142  1.17  christos             if (j == 0)
    143  1.17  christos             {
    144  1.17  christos                 AcpiOsPrintf ("/* ");
    145  1.17  christos             }
    146  1.17  christos 
    147  1.17  christos             BufChar = Buffer[(ACPI_SIZE) i + j];
    148  1.17  christos             if (isprint (BufChar))
    149  1.17  christos             {
    150  1.17  christos                 AcpiOsPrintf ("%c", BufChar);
    151  1.17  christos             }
    152  1.17  christos             else
    153  1.17  christos             {
    154  1.17  christos                 AcpiOsPrintf (".");
    155  1.17  christos             }
    156  1.17  christos         }
    157  1.17  christos 
    158  1.17  christos         /* Done with that line. */
    159  1.17  christos         /* Close the comment and insert a backslash - line continuation character */
    160  1.17  christos 
    161  1.17  christos         AcpiOsPrintf (" */\\");
    162  1.17  christos 
    163  1.17  christos         i += 16; /* Point to next line */
    164   1.2  christos     }
    165   1.2  christos 
    166   1.2  christos     AcpiOsPrintf ("\n");
    167   1.2  christos }
    168   1.2  christos 
    169   1.2  christos 
    170   1.1    jruoho /*******************************************************************************
    171   1.1    jruoho  *
    172   1.3  christos  * FUNCTION:    AcpiDmDumpUnicode
    173   1.3  christos  *
    174   1.3  christos  * PARAMETERS:  Table               - ACPI Table or subtable
    175   1.3  christos  *              BufferOffset        - Offset of buffer from Table above
    176   1.3  christos  *              ByteLength          - Length of the buffer
    177   1.3  christos  *
    178   1.3  christos  * RETURN:      None
    179   1.3  christos  *
    180   1.3  christos  * DESCRIPTION: Validate and dump the contents of a buffer that contains
    181   1.3  christos  *              unicode data. The output is a standard ASCII string. If it
    182   1.3  christos  *              appears that the data is not unicode, the buffer is dumped
    183   1.3  christos  *              as hex characters.
    184   1.3  christos  *
    185   1.3  christos  ******************************************************************************/
    186   1.3  christos 
    187   1.3  christos void
    188   1.3  christos AcpiDmDumpUnicode (
    189   1.3  christos     void                    *Table,
    190   1.3  christos     UINT32                  BufferOffset,
    191   1.3  christos     UINT32                  ByteLength)
    192   1.3  christos {
    193   1.3  christos     UINT8                   *Buffer;
    194   1.3  christos     UINT32                  Length;
    195   1.3  christos     UINT32                  i;
    196   1.3  christos 
    197   1.3  christos 
    198   1.3  christos     Buffer = ((UINT8 *) Table) + BufferOffset;
    199   1.3  christos     Length = ByteLength - 2; /* Last two bytes are the null terminator */
    200   1.3  christos 
    201   1.3  christos     /* Ensure all low bytes are entirely printable ASCII */
    202   1.3  christos 
    203   1.3  christos     for (i = 0; i < Length; i += 2)
    204   1.3  christos     {
    205   1.3  christos         if (!isprint (Buffer[i]))
    206   1.3  christos         {
    207   1.3  christos             goto DumpRawBuffer;
    208   1.3  christos         }
    209   1.3  christos     }
    210   1.3  christos 
    211   1.3  christos     /* Ensure all high bytes are zero */
    212   1.3  christos 
    213   1.3  christos     for (i = 1; i < Length; i += 2)
    214   1.3  christos     {
    215   1.3  christos         if (Buffer[i])
    216   1.3  christos         {
    217   1.3  christos             goto DumpRawBuffer;
    218   1.3  christos         }
    219   1.3  christos     }
    220   1.3  christos 
    221   1.3  christos     /* Dump the buffer as a normal string */
    222   1.3  christos 
    223   1.3  christos     AcpiOsPrintf ("\"");
    224   1.3  christos     for (i = 0; i < Length; i += 2)
    225   1.3  christos     {
    226   1.3  christos         AcpiOsPrintf ("%c", Buffer[i]);
    227   1.3  christos     }
    228   1.4  christos 
    229   1.3  christos     AcpiOsPrintf ("\"\n");
    230   1.3  christos     return;
    231   1.3  christos 
    232   1.3  christos DumpRawBuffer:
    233   1.3  christos     AcpiDmDumpBuffer (Table, BufferOffset, ByteLength,
    234   1.3  christos         BufferOffset, NULL);
    235   1.3  christos     AcpiOsPrintf ("\n");
    236   1.3  christos }
    237   1.3  christos 
    238   1.3  christos 
    239   1.3  christos /*******************************************************************************
    240   1.3  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.2  christos  * RETURN:      Length of the table (there is not always a length field,
    246   1.2  christos  *              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.2  christos     ACPI_TABLE_RSDP         *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
    257   1.2  christos     UINT32                  Length = sizeof (ACPI_RSDP_COMMON);
    258   1.2  christos     UINT8                   Checksum;
    259   1.3  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.3  christos     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1);
    265   1.3  christos     if (ACPI_FAILURE (Status))
    266   1.3  christos     {
    267   1.3  christos         return (Length);
    268   1.3  christos     }
    269   1.1    jruoho 
    270   1.2  christos     /* Validate the first checksum */
    271   1.2  christos 
    272  1.15  christos     Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
    273   1.4  christos         Rsdp->Checksum);
    274   1.2  christos     if (Checksum != Rsdp->Checksum)
    275   1.2  christos     {
    276   1.2  christos         AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n",
    277   1.2  christos             Checksum);
    278   1.2  christos     }
    279   1.2  christos 
    280   1.2  christos     /* The RSDP for ACPI 2.0+ contains more data and has a Length field */
    281   1.1    jruoho 
    282   1.2  christos     if (Rsdp->Revision > 0)
    283   1.1    jruoho     {
    284   1.2  christos         Length = Rsdp->Length;
    285   1.3  christos         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2);
    286   1.3  christos         if (ACPI_FAILURE (Status))
    287   1.3  christos         {
    288   1.3  christos             return (Length);
    289   1.3  christos         }
    290   1.2  christos 
    291   1.2  christos         /* Validate the extended checksum over entire RSDP */
    292   1.2  christos 
    293  1.15  christos         Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
    294   1.4  christos             Rsdp->ExtendedChecksum);
    295   1.2  christos         if (Checksum != Rsdp->ExtendedChecksum)
    296   1.2  christos         {
    297   1.2  christos             AcpiOsPrintf (
    298   1.2  christos                 "/* Incorrect Extended Checksum above, should be 0x%2.2X */\n",
    299   1.2  christos                 Checksum);
    300   1.2  christos         }
    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.2  christos  * NOTE:        We cannot depend on the FADT version to indicate the actual
    398   1.2  christos  *              contents of the FADT because of BIOS bugs. The table length
    399   1.2  christos  *              is the only reliable indicator.
    400   1.2  christos  *
    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.3  christos     ACPI_STATUS             Status;
    408   1.6  christos 
    409   1.3  christos 
    410   1.7  christos     /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
    411   1.1    jruoho 
    412   1.7  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    413   1.7  christos         AcpiDmTableInfoFadt1);
    414   1.7  christos     if (ACPI_FAILURE (Status))
    415   1.3  christos     {
    416   1.3  christos         return;
    417   1.3  christos     }
    418   1.1    jruoho 
    419   1.7  christos     /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
    420   1.7  christos 
    421   1.7  christos     if ((Table->Length > ACPI_FADT_V1_SIZE) &&
    422   1.7  christos         (Table->Length <= ACPI_FADT_V2_SIZE))
    423   1.6  christos     {
    424   1.7  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    425   1.7  christos             AcpiDmTableInfoFadt2);
    426   1.7  christos         if (ACPI_FAILURE (Status))
    427   1.3  christos         {
    428   1.7  christos             return;
    429   1.3  christos         }
    430   1.1    jruoho     }
    431   1.1    jruoho 
    432   1.7  christos     /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
    433   1.7  christos 
    434   1.7  christos     else if (Table->Length > ACPI_FADT_V2_SIZE)
    435   1.1    jruoho     {
    436   1.7  christos         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    437   1.7  christos             AcpiDmTableInfoFadt3);
    438   1.7  christos         if (ACPI_FAILURE (Status))
    439   1.3  christos         {
    440   1.7  christos             return;
    441   1.3  christos         }
    442   1.2  christos 
    443   1.7  christos         /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
    444   1.2  christos 
    445   1.7  christos         if (Table->Length > ACPI_FADT_V3_SIZE)
    446   1.2  christos         {
    447   1.7  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    448   1.7  christos                 AcpiDmTableInfoFadt5);
    449   1.7  christos             if (ACPI_FAILURE (Status))
    450   1.7  christos             {
    451   1.7  christos                 return;
    452   1.7  christos             }
    453   1.3  christos         }
    454   1.3  christos 
    455   1.7  christos         /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
    456   1.7  christos 
    457  1.17  christos         if (Table->Length > ACPI_FADT_V5_SIZE)
    458   1.3  christos         {
    459   1.7  christos             Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
    460   1.7  christos                 AcpiDmTableInfoFadt6);
    461   1.7  christos             if (ACPI_FAILURE (Status))
    462   1.7  christos             {
    463   1.7  christos                 return;
    464   1.7  christos             }
    465   1.2  christos         }
    466   1.1    jruoho     }
    467   1.1    jruoho 
    468   1.7  christos     /* Validate various fields in the FADT, including length */
    469   1.1    jruoho 
    470   1.1    jruoho     AcpiTbCreateLocalFadt (Table, Table->Length);
    471   1.7  christos 
    472   1.7  christos     /* Validate FADT length against the revision */
    473   1.7  christos 
    474   1.7  christos     AcpiDmValidateFadtLength (Table->Revision, Table->Length);
    475   1.7  christos }
    476   1.7  christos 
    477   1.7  christos 
    478   1.7  christos /*******************************************************************************
    479   1.7  christos  *
    480   1.7  christos  * FUNCTION:    AcpiDmValidateFadtLength
    481   1.7  christos  *
    482   1.7  christos  * PARAMETERS:  Revision            - FADT revision (Header->Revision)
    483   1.7  christos  *              Length              - FADT length (Header->Length
    484   1.7  christos  *
    485   1.7  christos  * RETURN:      None
    486   1.7  christos  *
    487   1.7  christos  * DESCRIPTION: Check the FADT revision against the expected table length for
    488   1.7  christos  *              that revision. Issue a warning if the length is not what was
    489   1.7  christos  *              expected. This seems to be such a common BIOS bug that the
    490   1.7  christos  *              FADT revision has been rendered virtually meaningless.
    491   1.7  christos  *
    492   1.7  christos  ******************************************************************************/
    493   1.7  christos 
    494   1.7  christos static void
    495   1.7  christos AcpiDmValidateFadtLength (
    496   1.7  christos     UINT32                  Revision,
    497   1.7  christos     UINT32                  Length)
    498   1.7  christos {
    499   1.7  christos     UINT32                  ExpectedLength;
    500   1.7  christos 
    501   1.7  christos 
    502   1.7  christos     switch (Revision)
    503   1.7  christos     {
    504   1.7  christos     case 0:
    505   1.7  christos 
    506   1.7  christos         AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
    507   1.7  christos         return;
    508   1.7  christos 
    509   1.7  christos     case 1:
    510   1.7  christos 
    511   1.7  christos         ExpectedLength = ACPI_FADT_V1_SIZE;
    512   1.7  christos         break;
    513   1.7  christos 
    514   1.7  christos     case 2:
    515   1.7  christos 
    516   1.7  christos         ExpectedLength = ACPI_FADT_V2_SIZE;
    517   1.7  christos         break;
    518   1.7  christos 
    519   1.7  christos     case 3:
    520   1.7  christos     case 4:
    521   1.7  christos 
    522   1.7  christos         ExpectedLength = ACPI_FADT_V3_SIZE;
    523   1.7  christos         break;
    524   1.7  christos 
    525   1.7  christos     case 5:
    526   1.7  christos 
    527   1.7  christos         ExpectedLength = ACPI_FADT_V5_SIZE;
    528   1.7  christos         break;
    529   1.7  christos 
    530  1.17  christos     case 6:
    531  1.17  christos 
    532  1.17  christos         ExpectedLength = ACPI_FADT_V6_SIZE;
    533  1.17  christos         break;
    534  1.17  christos 
    535   1.7  christos     default:
    536   1.7  christos 
    537   1.7  christos         return;
    538   1.7  christos     }
    539   1.7  christos 
    540   1.7  christos     if (Length == ExpectedLength)
    541   1.7  christos     {
    542   1.7  christos         return;
    543   1.7  christos     }
    544   1.7  christos 
    545   1.7  christos     AcpiOsPrintf (
    546   1.7  christos         "\n// ACPI Warning: FADT revision %X does not match length: "
    547   1.7  christos         "found %X expected %X\n",
    548   1.7  christos         Revision, Length, ExpectedLength);
    549   1.1    jruoho }
    550