Home | History | Annotate | Line # | Download | only in acpixtract
acpixtract.c revision 1.1.1.8
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: acpixtract - convert ascii ACPI tables to binary
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.8  christos  * Copyright (C) 2000 - 2016, 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.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY 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.1.8  christos #include "acpixtract.h"
     45      1.1    jruoho 
     46      1.1    jruoho 
     47  1.1.1.4  christos /******************************************************************************
     48  1.1.1.4  christos  *
     49  1.1.1.8  christos  * FUNCTION:    AxExtractTables
     50  1.1.1.4  christos  *
     51  1.1.1.8  christos  * PARAMETERS:  InputPathname       - Filename for input acpidump file
     52  1.1.1.8  christos  *              Signature           - Requested ACPI signature to extract.
     53  1.1.1.8  christos  *                                    NULL means extract ALL tables.
     54  1.1.1.8  christos  *              MinimumInstances    - Min instances that are acceptable
     55  1.1.1.4  christos  *
     56  1.1.1.8  christos  * RETURN:      Status
     57  1.1.1.4  christos  *
     58  1.1.1.8  christos  * DESCRIPTION: Convert text ACPI tables to binary
     59  1.1.1.4  christos  *
     60  1.1.1.4  christos  ******************************************************************************/
     61  1.1.1.4  christos 
     62  1.1.1.8  christos int
     63  1.1.1.8  christos AxExtractTables (
     64  1.1.1.8  christos     char                    *InputPathname,
     65  1.1.1.8  christos     char                    *Signature,
     66  1.1.1.8  christos     unsigned int            MinimumInstances)
     67  1.1.1.4  christos {
     68  1.1.1.8  christos     FILE                    *InputFile;
     69  1.1.1.8  christos     FILE                    *OutputFile = NULL;
     70  1.1.1.8  christos     unsigned int            BytesConverted;
     71  1.1.1.8  christos     unsigned int            ThisTableBytesWritten = 0;
     72  1.1.1.8  christos     unsigned int            FoundTable = 0;
     73  1.1.1.8  christos     unsigned int            Instances = 0;
     74  1.1.1.8  christos     unsigned int            ThisInstance;
     75  1.1.1.8  christos     char                    ThisSignature[4];
     76  1.1.1.8  christos     int                     Status = 0;
     77  1.1.1.8  christos     unsigned int            State = AX_STATE_FIND_HEADER;
     78  1.1.1.4  christos 
     79  1.1.1.4  christos 
     80  1.1.1.8  christos     /* Open input in text mode, output is in binary mode */
     81  1.1.1.4  christos 
     82  1.1.1.8  christos     InputFile = fopen (InputPathname, "rt");
     83  1.1.1.8  christos     if (!InputFile)
     84  1.1.1.4  christos     {
     85  1.1.1.8  christos         printf ("Could not open input file %s\n", InputPathname);
     86  1.1.1.8  christos         return (-1);
     87  1.1.1.4  christos     }
     88  1.1.1.4  christos 
     89  1.1.1.8  christos     if (Signature)
     90      1.1    jruoho     {
     91  1.1.1.8  christos         /* Are there enough instances of the table to continue? */
     92      1.1    jruoho 
     93  1.1.1.8  christos         AxNormalizeSignature (Signature);
     94      1.1    jruoho 
     95  1.1.1.8  christos         Instances = AxCountTableInstances (InputPathname, Signature);
     96  1.1.1.8  christos         if (Instances < MinimumInstances)
     97  1.1.1.8  christos         {
     98  1.1.1.8  christos             printf ("Table [%s] was not found in %s\n",
     99  1.1.1.8  christos                 Signature, InputPathname);
    100  1.1.1.8  christos             fclose (InputFile);
    101  1.1.1.8  christos             return (-1);
    102  1.1.1.8  christos         }
    103      1.1    jruoho 
    104  1.1.1.8  christos         if (Instances == 0)
    105  1.1.1.8  christos         {
    106  1.1.1.8  christos             fclose (InputFile);
    107  1.1.1.8  christos             return (-1);
    108  1.1.1.8  christos         }
    109      1.1    jruoho     }
    110      1.1    jruoho 
    111  1.1.1.8  christos     /* Convert all instances of the table to binary */
    112      1.1    jruoho 
    113  1.1.1.8  christos     while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile))
    114      1.1    jruoho     {
    115  1.1.1.8  christos         switch (State)
    116  1.1.1.8  christos         {
    117  1.1.1.8  christos         case AX_STATE_FIND_HEADER:
    118      1.1    jruoho 
    119  1.1.1.8  christos             if (!AxIsDataBlockHeader ())
    120  1.1.1.8  christos             {
    121  1.1.1.8  christos                 continue;
    122  1.1.1.8  christos             }
    123      1.1    jruoho 
    124  1.1.1.8  christos             ACPI_MOVE_NAME (ThisSignature, Gbl_LineBuffer);
    125  1.1.1.8  christos             if (Signature)
    126  1.1.1.8  christos             {
    127  1.1.1.8  christos                 /* Ignore signatures that don't match */
    128      1.1    jruoho 
    129  1.1.1.8  christos                 if (!ACPI_COMPARE_NAME (ThisSignature, Signature))
    130  1.1.1.8  christos                 {
    131  1.1.1.8  christos                     continue;
    132  1.1.1.8  christos                 }
    133  1.1.1.8  christos             }
    134      1.1    jruoho 
    135  1.1.1.8  christos             /*
    136  1.1.1.8  christos              * Get the instance number for this signature. Only the
    137  1.1.1.8  christos              * SSDT and PSDT tables can have multiple instances.
    138  1.1.1.8  christos              */
    139  1.1.1.8  christos             ThisInstance = AxGetNextInstance (InputPathname, ThisSignature);
    140      1.1    jruoho 
    141  1.1.1.8  christos             /* Build an output filename and create/open the output file */
    142      1.1    jruoho 
    143  1.1.1.8  christos             if (ThisInstance > 0)
    144  1.1.1.8  christos             {
    145  1.1.1.8  christos                 /* Add instance number to the output filename */
    146      1.1    jruoho 
    147  1.1.1.8  christos                 sprintf (Gbl_OutputFilename, "%4.4s%u.dat",
    148  1.1.1.8  christos                     ThisSignature, ThisInstance);
    149  1.1.1.8  christos             }
    150  1.1.1.8  christos             else
    151  1.1.1.8  christos             {
    152  1.1.1.8  christos                 sprintf (Gbl_OutputFilename, "%4.4s.dat",
    153  1.1.1.8  christos                     ThisSignature);
    154  1.1.1.8  christos             }
    155      1.1    jruoho 
    156  1.1.1.8  christos             AcpiUtStrlwr (Gbl_OutputFilename);
    157  1.1.1.8  christos             OutputFile = fopen (Gbl_OutputFilename, "w+b");
    158  1.1.1.8  christos             if (!OutputFile)
    159  1.1.1.8  christos             {
    160  1.1.1.8  christos                 printf ("Could not open output file %s\n",
    161  1.1.1.8  christos                     Gbl_OutputFilename);
    162  1.1.1.8  christos                 fclose (InputFile);
    163  1.1.1.8  christos                 return (-1);
    164  1.1.1.8  christos             }
    165      1.1    jruoho 
    166  1.1.1.8  christos             /*
    167  1.1.1.8  christos              * Toss this block header of the form "<sig> @ <addr>" line
    168  1.1.1.8  christos              * and move on to the actual data block
    169  1.1.1.8  christos              */
    170  1.1.1.8  christos             Gbl_TableCount++;
    171  1.1.1.8  christos             FoundTable = 1;
    172  1.1.1.8  christos             ThisTableBytesWritten = 0;
    173  1.1.1.8  christos             State = AX_STATE_EXTRACT_DATA;
    174  1.1.1.8  christos             continue;
    175      1.1    jruoho 
    176  1.1.1.8  christos         case AX_STATE_EXTRACT_DATA:
    177      1.1    jruoho 
    178  1.1.1.8  christos             /* Empty line or non-data line terminates the data block */
    179      1.1    jruoho 
    180  1.1.1.8  christos             BytesConverted = AxProcessOneTextLine (
    181  1.1.1.8  christos                 OutputFile, ThisSignature, ThisTableBytesWritten);
    182  1.1.1.8  christos             switch (BytesConverted)
    183  1.1.1.8  christos             {
    184  1.1.1.8  christos             case 0:
    185      1.1    jruoho 
    186  1.1.1.8  christos                 State = AX_STATE_FIND_HEADER; /* No more data block lines */
    187  1.1.1.8  christos                 continue;
    188      1.1    jruoho 
    189  1.1.1.8  christos             case -1:
    190      1.1    jruoho 
    191  1.1.1.8  christos                 goto CleanupAndExit; /* There was a write error */
    192      1.1    jruoho 
    193  1.1.1.8  christos             default: /* Normal case, get next line */
    194      1.1    jruoho 
    195  1.1.1.8  christos                 ThisTableBytesWritten += BytesConverted;
    196  1.1.1.8  christos                 continue;
    197  1.1.1.8  christos             }
    198      1.1    jruoho 
    199  1.1.1.8  christos         default:
    200      1.1    jruoho 
    201  1.1.1.8  christos             Status = -1;
    202  1.1.1.8  christos             goto CleanupAndExit;
    203      1.1    jruoho         }
    204      1.1    jruoho     }
    205      1.1    jruoho 
    206  1.1.1.8  christos     if (!FoundTable)
    207  1.1.1.8  christos     {
    208  1.1.1.8  christos         printf ("Table [%s] was not found in %s\n",
    209  1.1.1.8  christos             Signature, InputPathname);
    210  1.1.1.8  christos     }
    211      1.1    jruoho 
    212      1.1    jruoho 
    213  1.1.1.8  christos CleanupAndExit:
    214      1.1    jruoho 
    215  1.1.1.8  christos     if (State == AX_STATE_EXTRACT_DATA)
    216      1.1    jruoho     {
    217  1.1.1.8  christos         /* Received an input file EOF while extracting data */
    218      1.1    jruoho 
    219  1.1.1.8  christos         printf (AX_TABLE_INFO_FORMAT,
    220  1.1.1.8  christos             ThisSignature, ThisTableBytesWritten, Gbl_OutputFilename);
    221      1.1    jruoho     }
    222      1.1    jruoho 
    223  1.1.1.8  christos     if (Gbl_TableCount > 1)
    224      1.1    jruoho     {
    225  1.1.1.8  christos         printf ("\n%d binary ACPI tables extracted\n",
    226  1.1.1.8  christos             Gbl_TableCount);
    227      1.1    jruoho     }
    228      1.1    jruoho 
    229  1.1.1.8  christos     if (OutputFile)
    230      1.1    jruoho     {
    231  1.1.1.8  christos         fclose (OutputFile);
    232      1.1    jruoho     }
    233      1.1    jruoho 
    234  1.1.1.8  christos     fclose (InputFile);
    235  1.1.1.8  christos     return (Status);
    236      1.1    jruoho }
    237      1.1    jruoho 
    238      1.1    jruoho 
    239      1.1    jruoho /******************************************************************************
    240      1.1    jruoho  *
    241  1.1.1.8  christos  * FUNCTION:    AxExtractToMultiAmlFile
    242      1.1    jruoho  *
    243  1.1.1.8  christos  * PARAMETERS:  InputPathname       - Filename for input acpidump file
    244      1.1    jruoho  *
    245      1.1    jruoho  * RETURN:      Status
    246      1.1    jruoho  *
    247  1.1.1.8  christos  * DESCRIPTION: Convert all DSDT/SSDT tables to binary and append them all
    248  1.1.1.8  christos  *              into a single output file. Used to simplify the loading of
    249  1.1.1.8  christos  *              multiple/many SSDTs into a utility like acpiexec -- instead
    250  1.1.1.8  christos  *              of creating many separate output files.
    251      1.1    jruoho  *
    252      1.1    jruoho  ******************************************************************************/
    253      1.1    jruoho 
    254  1.1.1.4  christos int
    255  1.1.1.8  christos AxExtractToMultiAmlFile (
    256  1.1.1.8  christos     char                    *InputPathname)
    257      1.1    jruoho {
    258      1.1    jruoho     FILE                    *InputFile;
    259  1.1.1.8  christos     FILE                    *OutputFile;
    260      1.1    jruoho     int                     Status = 0;
    261  1.1.1.8  christos     unsigned int            TotalBytesWritten = 0;
    262  1.1.1.8  christos     unsigned int            ThisTableBytesWritten = 0;
    263  1.1.1.8  christos     unsigned int             BytesConverted;
    264  1.1.1.8  christos     char                    ThisSignature[4];
    265  1.1.1.8  christos     unsigned int            State = AX_STATE_FIND_HEADER;
    266      1.1    jruoho 
    267      1.1    jruoho 
    268  1.1.1.8  christos     strcpy (Gbl_OutputFilename, AX_MULTI_TABLE_FILENAME);
    269  1.1.1.8  christos 
    270  1.1.1.8  christos     /* Open the input file in text mode */
    271      1.1    jruoho 
    272      1.1    jruoho     InputFile = fopen (InputPathname, "rt");
    273      1.1    jruoho     if (!InputFile)
    274      1.1    jruoho     {
    275  1.1.1.8  christos         printf ("Could not open input file %s\n", InputPathname);
    276      1.1    jruoho         return (-1);
    277      1.1    jruoho     }
    278      1.1    jruoho 
    279  1.1.1.8  christos     /* Open the output file in binary mode */
    280      1.1    jruoho 
    281  1.1.1.8  christos     OutputFile = fopen (Gbl_OutputFilename, "w+b");
    282  1.1.1.8  christos     if (!OutputFile)
    283  1.1.1.8  christos     {
    284  1.1.1.8  christos         printf ("Could not open output file %s\n", Gbl_OutputFilename);
    285  1.1.1.8  christos         fclose (InputFile);
    286  1.1.1.8  christos         return (-1);
    287      1.1    jruoho     }
    288      1.1    jruoho 
    289  1.1.1.8  christos     /* Convert the DSDT and all SSDTs to binary */
    290      1.1    jruoho 
    291  1.1.1.8  christos     while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile))
    292      1.1    jruoho     {
    293      1.1    jruoho         switch (State)
    294      1.1    jruoho         {
    295  1.1.1.4  christos         case AX_STATE_FIND_HEADER:
    296      1.1    jruoho 
    297  1.1.1.8  christos             if (!AxIsDataBlockHeader ())
    298  1.1.1.3    jruoho             {
    299  1.1.1.3    jruoho                 continue;
    300  1.1.1.3    jruoho             }
    301  1.1.1.3    jruoho 
    302  1.1.1.8  christos             ACPI_MOVE_NAME (ThisSignature, Gbl_LineBuffer);
    303      1.1    jruoho 
    304  1.1.1.8  christos             /* Only want DSDT and SSDTs */
    305      1.1    jruoho 
    306  1.1.1.8  christos             if (!ACPI_COMPARE_NAME (ThisSignature, ACPI_SIG_DSDT) &&
    307  1.1.1.8  christos                 !ACPI_COMPARE_NAME (ThisSignature, ACPI_SIG_SSDT))
    308  1.1.1.3    jruoho             {
    309  1.1.1.3    jruoho                 continue;
    310  1.1.1.3    jruoho             }
    311  1.1.1.3    jruoho 
    312      1.1    jruoho             /*
    313  1.1.1.8  christos              * Toss this block header of the form "<sig> @ <addr>" line
    314  1.1.1.8  christos              * and move on to the actual data block
    315      1.1    jruoho              */
    316  1.1.1.8  christos             Gbl_TableCount++;
    317  1.1.1.8  christos             ThisTableBytesWritten = 0;
    318  1.1.1.4  christos             State = AX_STATE_EXTRACT_DATA;
    319      1.1    jruoho             continue;
    320      1.1    jruoho 
    321  1.1.1.4  christos         case AX_STATE_EXTRACT_DATA:
    322      1.1    jruoho 
    323  1.1.1.8  christos             /* Empty line or non-data line terminates the data block */
    324      1.1    jruoho 
    325  1.1.1.8  christos             BytesConverted = AxProcessOneTextLine (
    326  1.1.1.8  christos                 OutputFile, ThisSignature, ThisTableBytesWritten);
    327  1.1.1.8  christos             switch (BytesConverted)
    328      1.1    jruoho             {
    329  1.1.1.8  christos             case 0:
    330      1.1    jruoho 
    331  1.1.1.8  christos                 State = AX_STATE_FIND_HEADER; /* No more data block lines */
    332      1.1    jruoho                 continue;
    333      1.1    jruoho 
    334  1.1.1.8  christos             case -1:
    335      1.1    jruoho 
    336  1.1.1.8  christos                 goto CleanupAndExit; /* There was a write error */
    337      1.1    jruoho 
    338  1.1.1.8  christos             default: /* Normal case, get next line */
    339      1.1    jruoho 
    340  1.1.1.8  christos                 ThisTableBytesWritten += BytesConverted;
    341  1.1.1.8  christos                 TotalBytesWritten += BytesConverted;
    342  1.1.1.8  christos                 continue;
    343      1.1    jruoho             }
    344      1.1    jruoho 
    345      1.1    jruoho         default:
    346  1.1.1.4  christos 
    347      1.1    jruoho             Status = -1;
    348      1.1    jruoho             goto CleanupAndExit;
    349      1.1    jruoho         }
    350      1.1    jruoho     }
    351      1.1    jruoho 
    352      1.1    jruoho 
    353      1.1    jruoho CleanupAndExit:
    354      1.1    jruoho 
    355  1.1.1.8  christos     if (State == AX_STATE_EXTRACT_DATA)
    356      1.1    jruoho     {
    357  1.1.1.8  christos         /* Received an input file EOF or error while writing data */
    358      1.1    jruoho 
    359  1.1.1.8  christos         printf (AX_TABLE_INFO_FORMAT,
    360  1.1.1.8  christos             ThisSignature, ThisTableBytesWritten, Gbl_OutputFilename);
    361      1.1    jruoho     }
    362      1.1    jruoho 
    363  1.1.1.8  christos     printf ("\n%d binary ACPI tables extracted and written to %s (%u bytes)\n",
    364  1.1.1.8  christos         Gbl_TableCount, Gbl_OutputFilename, TotalBytesWritten);
    365  1.1.1.8  christos 
    366      1.1    jruoho     fclose (InputFile);
    367  1.1.1.8  christos     fclose (OutputFile);
    368      1.1    jruoho     return (Status);
    369      1.1    jruoho }
    370      1.1    jruoho 
    371      1.1    jruoho 
    372      1.1    jruoho /******************************************************************************
    373      1.1    jruoho  *
    374  1.1.1.4  christos  * FUNCTION:    AxListTables
    375      1.1    jruoho  *
    376      1.1    jruoho  * PARAMETERS:  InputPathname       - Filename for acpidump file
    377      1.1    jruoho  *
    378      1.1    jruoho  * RETURN:      Status
    379      1.1    jruoho  *
    380      1.1    jruoho  * DESCRIPTION: Display info for all ACPI tables found in input. Does not
    381      1.1    jruoho  *              perform an actual extraction of the tables.
    382      1.1    jruoho  *
    383      1.1    jruoho  ******************************************************************************/
    384      1.1    jruoho 
    385  1.1.1.4  christos int
    386  1.1.1.4  christos AxListTables (
    387      1.1    jruoho     char                    *InputPathname)
    388      1.1    jruoho {
    389      1.1    jruoho     FILE                    *InputFile;
    390      1.1    jruoho     size_t                  HeaderSize;
    391      1.1    jruoho     unsigned char           Header[48];
    392      1.1    jruoho     ACPI_TABLE_HEADER       *TableHeader = (ACPI_TABLE_HEADER *) (void *) Header;
    393      1.1    jruoho 
    394      1.1    jruoho 
    395      1.1    jruoho     /* Open input in text mode, output is in binary mode */
    396      1.1    jruoho 
    397      1.1    jruoho     InputFile = fopen (InputPathname, "rt");
    398      1.1    jruoho     if (!InputFile)
    399      1.1    jruoho     {
    400  1.1.1.8  christos         printf ("Could not open input file %s\n", InputPathname);
    401      1.1    jruoho         return (-1);
    402      1.1    jruoho     }
    403      1.1    jruoho 
    404      1.1    jruoho     /* Dump the headers for all tables found in the input file */
    405      1.1    jruoho 
    406  1.1.1.4  christos     printf ("\nSignature  Length      Revision   OemId    OemTableId"
    407  1.1.1.8  christos         "   OemRevision CompilerId CompilerRevision\n\n");
    408      1.1    jruoho 
    409  1.1.1.8  christos     while (fgets (Gbl_LineBuffer, AX_LINE_BUFFER_SIZE, InputFile))
    410      1.1    jruoho     {
    411      1.1    jruoho         /* Ignore empty lines and lines that start with a space */
    412      1.1    jruoho 
    413  1.1.1.8  christos         if (AxIsEmptyLine (Gbl_LineBuffer) ||
    414  1.1.1.8  christos             (Gbl_LineBuffer[0] == ' '))
    415      1.1    jruoho         {
    416      1.1    jruoho             continue;
    417      1.1    jruoho         }
    418      1.1    jruoho 
    419      1.1    jruoho         /* Get the 36 byte header and display the fields */
    420      1.1    jruoho 
    421  1.1.1.4  christos         HeaderSize = AxGetTableHeader (InputFile, Header);
    422      1.1    jruoho         if (HeaderSize < 16)
    423      1.1    jruoho         {
    424      1.1    jruoho             continue;
    425      1.1    jruoho         }
    426      1.1    jruoho 
    427      1.1    jruoho         /* RSDP has an oddball signature and header */
    428      1.1    jruoho 
    429      1.1    jruoho         if (!strncmp (TableHeader->Signature, "RSD PTR ", 8))
    430      1.1    jruoho         {
    431  1.1.1.4  christos             AxCheckAscii ((char *) &Header[9], 6);
    432  1.1.1.8  christos             printf ("%7.4s                          \"%6.6s\"\n", "RSDP",
    433  1.1.1.8  christos                 &Header[9]);
    434  1.1.1.8  christos             Gbl_TableCount++;
    435      1.1    jruoho             continue;
    436      1.1    jruoho         }
    437      1.1    jruoho 
    438      1.1    jruoho         /* Minimum size for table with standard header */
    439      1.1    jruoho 
    440  1.1.1.4  christos         if (HeaderSize < sizeof (ACPI_TABLE_HEADER))
    441      1.1    jruoho         {
    442      1.1    jruoho             continue;
    443      1.1    jruoho         }
    444      1.1    jruoho 
    445      1.1    jruoho         /* Signature and Table length */
    446      1.1    jruoho 
    447  1.1.1.8  christos         Gbl_TableCount++;
    448  1.1.1.8  christos         printf ("%7.4s   0x%8.8X", TableHeader->Signature,
    449  1.1.1.8  christos             TableHeader->Length);
    450      1.1    jruoho 
    451      1.1    jruoho         /* FACS has only signature and length */
    452      1.1    jruoho 
    453  1.1.1.4  christos         if (ACPI_COMPARE_NAME (TableHeader->Signature, "FACS"))
    454      1.1    jruoho         {
    455      1.1    jruoho             printf ("\n");
    456      1.1    jruoho             continue;
    457      1.1    jruoho         }
    458      1.1    jruoho 
    459      1.1    jruoho         /* OEM IDs and Compiler IDs */
    460      1.1    jruoho 
    461  1.1.1.4  christos         AxCheckAscii (TableHeader->OemId, 6);
    462  1.1.1.4  christos         AxCheckAscii (TableHeader->OemTableId, 8);
    463  1.1.1.4  christos         AxCheckAscii (TableHeader->AslCompilerId, 4);
    464      1.1    jruoho 
    465  1.1.1.8  christos         printf (
    466  1.1.1.8  christos             "     0x%2.2X    \"%6.6s\"  \"%8.8s\"   0x%8.8X"
    467  1.1.1.8  christos             "    \"%4.4s\"     0x%8.8X\n",
    468      1.1    jruoho             TableHeader->Revision, TableHeader->OemId,
    469      1.1    jruoho             TableHeader->OemTableId, TableHeader->OemRevision,
    470      1.1    jruoho             TableHeader->AslCompilerId, TableHeader->AslCompilerRevision);
    471      1.1    jruoho     }
    472      1.1    jruoho 
    473  1.1.1.8  christos     printf ("\nFound %u ACPI tables\n", Gbl_TableCount);
    474      1.1    jruoho     fclose (InputFile);
    475      1.1    jruoho     return (0);
    476      1.1    jruoho }
    477