Sync ACPICA with Intel's version 20181213.
[dragonfly.git] / sys / contrib / dev / acpica / source / tools / acpixtract / axutils.c
1 /******************************************************************************
2  *
3  * Module Name: axutils - Utility functions for acpixtract tool.
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151
152 #include "acpixtract.h"
153
154
155 /*******************************************************************************
156  *
157  * FUNCTION:    AxCheckAscii
158  *
159  * PARAMETERS:  Name                - Ascii string, at least as long as Count
160  *              Count               - Number of characters to check
161  *
162  * RETURN:      None
163  *
164  * DESCRIPTION: Ensure that the requested number of characters are printable
165  *              Ascii characters. Sets non-printable and null chars to <space>.
166  *
167  ******************************************************************************/
168
169 void
170 AxCheckAscii (
171     char                    *Name,
172     int                     Count)
173 {
174     int                     i;
175
176
177     for (i = 0; i < Count; i++)
178     {
179         if (!Name[i] || !isprint ((int) Name[i]))
180         {
181             Name[i] = ' ';
182         }
183     }
184 }
185
186
187 /*******************************************************************************
188  *
189  * FUNCTION:    AxIsFileAscii
190  *
191  * PARAMETERS:  Handle              - To open input file
192  *
193  * RETURN:      TRUE if file is entirely ASCII and printable
194  *
195  * DESCRIPTION: Verify that the input file is entirely ASCII.
196  *
197  ******************************************************************************/
198
199 BOOLEAN
200 AxIsFileAscii (
201     FILE                    *Handle)
202 {
203     UINT8                   Byte;
204     UINT32                  Offset = 0;
205
206
207     /* Read the entire file */
208
209     fseek (Handle, 0, SEEK_SET);
210     while (fread (&Byte, 1, 1, Handle) == 1)
211     {
212         /*
213          * Ignore null characters. Some acpidump-type utilities insert
214          * a few of these, probably a bug in the utility. As long as these
215          * characters are in lines that are tossed (non-data), they
216          * won't cause a problem.
217          */
218         if (!Byte)
219         {
220             continue;
221         }
222
223         /* Check for an ASCII character */
224
225         if (!ACPI_IS_ASCII (Byte))
226         {
227             printf ("Found non-ascii char: %2.2X at file offset %u (0x%X)\n",
228                 Byte, Offset, Offset);
229             if (!Gbl_ForceExtraction)
230             {
231                 goto ErrorExit;
232             }
233         }
234
235         /* Ensure character is either printable or a "space" char */
236
237         else if (!isprint (Byte) && !isspace (Byte))
238         {
239             printf ("Found non-printable char: %2.2X at file offset %u (0x%X)\n",
240                 Byte, Offset, Offset);
241             if (!Gbl_ForceExtraction)
242             {
243                 goto ErrorExit;
244             }
245         }
246
247         Offset++;
248     }
249
250     /* File is OK (100% ASCII) */
251
252     fseek (Handle, 0, SEEK_SET);
253     return (TRUE);
254
255 ErrorExit:
256
257     printf ("File appears to be binary "
258         "(contains non-text or non-ascii characters)\n");
259     fseek (Handle, 0, SEEK_SET);
260     return (FALSE);
261 }
262
263
264 /******************************************************************************
265  *
266  * FUNCTION:    AxIsEmptyLine
267  *
268  * PARAMETERS:  Buffer              - Line from input file
269  *
270  * RETURN:      TRUE if line is empty (zero or more blanks only)
271  *
272  * DESCRIPTION: Determine if an input line is empty.
273  *
274  ******************************************************************************/
275
276 BOOLEAN
277 AxIsEmptyLine (
278     char                    *Buffer)
279 {
280
281     /* Skip all spaces */
282
283     while (*Buffer == ' ')
284     {
285         Buffer++;
286     }
287
288     /* Line is empty when a Unix or DOS-style line terminator is found. */
289
290     if ((*Buffer == '\r') || (*Buffer == '\n'))
291     {
292         return (1);
293     }
294
295     return (0);
296 }
297
298
299 /******************************************************************************
300  *
301  * FUNCTION:    AxIsHexDataLine
302  *
303  * PARAMETERS:  None
304  *
305  * RETURN:      Status. 1 if the table header is valid, 0 otherwise.
306  *
307  * DESCRIPTION: Check for a valid line of hex data of the form:
308  *
309  *  00a0: 0c 00 00 00 03 00 00 00 43 48 41 35 0c 00 00 00  ........CHA5....
310  *
311  ******************************************************************************/
312
313 BOOLEAN
314 AxIsHexDataLine (
315     void)
316 {
317
318     if (AxIsEmptyLine (Gbl_LineBuffer) ||
319         (Gbl_LineBuffer[0] != ' '))
320     {
321         return (FALSE);
322     }
323
324     if (!strstr (Gbl_LineBuffer, ": "))
325     {
326         /* Not valid data line */
327
328         return (FALSE);
329     }
330
331     return (TRUE);
332 }
333
334
335 /******************************************************************************
336  *
337  * FUNCTION:    AxIsDataBlockHeader
338  *
339  * PARAMETERS:  None
340  *
341  * RETURN:      Status. 1 if the table header is valid, 0 otherwise.
342  *
343  * DESCRIPTION: Check if the ACPI table identifier in the input acpidump text
344  *              file is valid (of the form: <sig> @ <addr>).
345  *
346  ******************************************************************************/
347
348 BOOLEAN
349 AxIsDataBlockHeader (
350     void)
351 {
352
353     /* Ignore lines that are too short to be header lines */
354
355     if (strlen (Gbl_LineBuffer) < AX_MIN_BLOCK_HEADER_LENGTH)
356     {
357         return (FALSE);
358     }
359
360     /* Ignore empty lines and lines that start with a space */
361
362     if (AxIsEmptyLine (Gbl_LineBuffer) ||
363         (Gbl_LineBuffer[0] == ' '))
364     {
365         return (FALSE);
366     }
367
368     /*
369      * Ignore lines that are not headers of the form <sig> @ <addr>.
370      * Basically, just look for the '@' symbol, surrounded by spaces.
371      *
372      * Examples of headers that must be supported:
373      *
374      * DSDT @ 0x737e4000
375      * XSDT @ 0x737f2fff
376      * RSD PTR @ 0xf6cd0
377      * SSDT @ (nil)
378      */
379     if (!AX_IS_TABLE_BLOCK_HEADER)
380     {
381         return (FALSE);
382     }
383
384     AxNormalizeSignature (Gbl_LineBuffer);
385     return (TRUE);
386 }
387
388
389 /*******************************************************************************
390  *
391  * FUNCTION:    AxNormalizeSignature
392  *
393  * PARAMETERS:  Name                - Ascii string containing an ACPI signature
394  *
395  * RETURN:      None
396  *
397  * DESCRIPTION: Change "RSD PTR" to "RSDP"
398  *
399  ******************************************************************************/
400
401 void
402 AxNormalizeSignature (
403     char                    *Signature)
404 {
405
406     if (!strncmp (Signature, "RSD ", 4))
407     {
408         Signature[3] = 'P';
409     }
410 }
411
412
413 /******************************************************************************
414  *
415  * FUNCTION:    AxConvertToBinary
416  *
417  * PARAMETERS:  InputLine           - One line from the input acpidump file
418  *              OutputData          - Where the converted data is returned
419  *
420  * RETURN:      The number of bytes actually converted
421  *
422  * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes)
423  *
424  * NOTE: Assumes the input data line has been validated to be of the form:
425  *
426  *  0010: 48 53 57 55 4c 54 2d 52 01 00 00 00 49 4e 54 4c  HSWULT-R....INTL
427  *
428  ******************************************************************************/
429
430 int
431 AxConvertToBinary (
432     char                    *InputLine,
433     unsigned char           *OutputData)
434 {
435     char                    *ColonDelimiter;
436     int                     BytesConverted;
437     int                     Converted[16];
438     int                     i;
439
440
441     /*
442      * Terminate input line immediately after the data. Otherwise, the
443      * second line below will not scan correctly.
444      *
445      * This handles varying lengths for the offset: line prefix. This support
446      * for tables larger than 1mb was added 05/2018.
447      *
448      *    00b0: 03 00 00 00 43 48 41 36 0c 00 00 00 03 00 00 00  ....CHA6........
449      *    00c0: 43 48 41 37                                      CHA7
450      *
451      *    012340b0: 03 00 00 00 43 48 41 36 0c 00 00 00 03 00 00 00  ....CHA6........
452      *    012340c0: 43 48 41 37                                      CHA7
453      */
454     ColonDelimiter = strchr (InputLine, ':');
455     ColonDelimiter [AX_HEX_DATA_LENGTH] = 0;
456
457     /*
458      * Convert one line of table data, of the form:
459      * <offset>: <up to 16 bytes of hex data> <ASCII representation> <newline>
460      *
461      * Example:
462      * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08  _SB_LNKD........
463      */
464     BytesConverted = sscanf (InputLine,
465         "%*s %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X",
466         &Converted[0],  &Converted[1],  &Converted[2],  &Converted[3],
467         &Converted[4],  &Converted[5],  &Converted[6],  &Converted[7],
468         &Converted[8],  &Converted[9],  &Converted[10], &Converted[11],
469         &Converted[12], &Converted[13], &Converted[14], &Converted[15]);
470
471     if (BytesConverted == EOF)
472     {
473         printf ("EOF while converting ASCII line to binary\n");
474         return (-1);
475     }
476
477     /*
478      * Pack converted data into a byte array.
479      * Note: BytesConverted == 0 is acceptable.
480      */
481     for (i = 0; i < BytesConverted; i++)
482     {
483         OutputData[i] = (unsigned char) Converted[i];
484     }
485
486     return (BytesConverted);
487 }
488
489
490 /******************************************************************************
491  *
492  * FUNCTION:    AxCountTableInstances
493  *
494  * PARAMETERS:  InputPathname       - Filename for acpidump file
495  *              Signature           - Requested signature to count
496  *
497  * RETURN:      The number of instances of the signature
498  *
499  * DESCRIPTION: Count the instances of tables with the given signature within
500  *              the input acpidump file.
501  *
502  ******************************************************************************/
503
504 unsigned int
505 AxCountTableInstances (
506     char                    *InputPathname,
507     char                    *Signature)
508 {
509     FILE                    *InputFile;
510     unsigned int            Instances = 0;
511
512
513     InputFile = fopen (InputPathname, "r");
514     if (!InputFile)
515     {
516         printf ("Could not open input file %s\n", InputPathname);
517         return (0);
518     }
519
520     /* Count the number of instances of this signature */
521
522     while (fgets (Gbl_InstanceBuffer, AX_LINE_BUFFER_SIZE, InputFile))
523     {
524         /* Ignore empty lines and lines that start with a space */
525
526         if (AxIsEmptyLine (Gbl_InstanceBuffer) ||
527             (Gbl_InstanceBuffer[0] == ' '))
528         {
529             continue;
530         }
531
532         AxNormalizeSignature (Gbl_InstanceBuffer);
533         if (ACPI_COMPARE_NAME (Gbl_InstanceBuffer, Signature))
534         {
535             Instances++;
536         }
537     }
538
539     fclose (InputFile);
540     return (Instances);
541 }
542
543
544 /******************************************************************************
545  *
546  * FUNCTION:    AxGetNextInstance
547  *
548  * PARAMETERS:  InputPathname       - Filename for acpidump file
549  *              Signature           - Requested ACPI signature
550  *
551  * RETURN:      The next instance number for this signature. Zero if this
552  *              is the first instance of this signature.
553  *
554  * DESCRIPTION: Get the next instance number of the specified table. If this
555  *              is the first instance of the table, create a new instance
556  *              block. Note: only SSDT and PSDT tables can have multiple
557  *              instances.
558  *
559  ******************************************************************************/
560
561 unsigned int
562 AxGetNextInstance (
563     char                    *InputPathname,
564     char                    *Signature)
565 {
566     AX_TABLE_INFO           *Info;
567
568
569     Info = Gbl_TableListHead;
570     while (Info)
571     {
572         if (*(UINT32 *) Signature == Info->Signature)
573         {
574             break;
575         }
576
577         Info = Info->Next;
578     }
579
580     if (!Info)
581     {
582         /* Signature not found, create new table info block */
583
584         Info = malloc (sizeof (AX_TABLE_INFO));
585         if (!Info)
586         {
587             printf ("Could not allocate memory (0x%X bytes)\n",
588                 (unsigned int) sizeof (AX_TABLE_INFO));
589             exit (0);
590         }
591
592         Info->Signature = *(UINT32 *) Signature;
593         Info->Instances = AxCountTableInstances (InputPathname, Signature);
594         Info->NextInstance = 1;
595         Info->Next = Gbl_TableListHead;
596         Gbl_TableListHead = Info;
597     }
598
599     if (Info->Instances > 1)
600     {
601         return (Info->NextInstance++);
602     }
603
604     return (0);
605 }
606
607
608 /******************************************************************************
609  *
610  * FUNCTION:    AxConvertAndWrite
611  *
612  * PARAMETERS:  OutputFile              - Where to write the binary data
613  *              ThisSignature           - Signature of current ACPI table
614  *
615  * RETURN:      Length of the converted line
616  *
617  * DESCRIPTION: Convert one line of input hex ascii text to binary, and write
618  *              the binary data to the table output file.
619  *
620  * NOTE: Assumes the input data line has been validated to be of the form:
621  *
622  *  0010: 48 53 57 55 4c 54 2d 52 01 00 00 00 49 4e 54 4c  HSWULT-R....INTL
623  *
624  ******************************************************************************/
625
626 int
627 AxConvertAndWrite (
628     FILE                    *OutputFile,
629     char                    *ThisSignature)
630 {
631     int                     BytesWritten;
632     int                     BytesConverted;
633
634
635     /* Convert one line of ascii hex data to binary */
636
637     BytesConverted = AxConvertToBinary (Gbl_LineBuffer, Gbl_BinaryData);
638     if (BytesConverted == EOF)
639     {
640         return (EOF);
641     }
642     if (!BytesConverted)
643     {
644         return (0);
645     }
646
647     /* Write the binary data */
648
649     BytesWritten = fwrite (Gbl_BinaryData, 1, BytesConverted, OutputFile);
650     if (BytesWritten != BytesConverted)
651     {
652         printf ("Error while writing file %s\n", Gbl_OutputFilename);
653         return (-1);
654     }
655
656     return (BytesWritten);
657 }
658
659
660 /******************************************************************************
661  *
662  * FUNCTION:    AxDumpTableHeader
663  *
664  * PARAMETERS:  Header          - A binary ACPI table header
665  *
666  * RETURN:      None
667  *
668  * DESCRIPTION: Display the contents of a standard ACPI table header
669  *
670  ******************************************************************************/
671
672 void
673 AxDumpTableHeader (
674     unsigned char           *Header)
675 {
676     ACPI_TABLE_HEADER       *TableHeader = (ACPI_TABLE_HEADER *) (void *) Header;
677     ACPI_TABLE_RSDP         *Rsdp = (ACPI_TABLE_RSDP *) (void *) Header;
678     ACPI_TABLE_FACS         *Facs = (ACPI_TABLE_FACS *) (void *) Header;
679
680
681     /* RSDP has an oddball signature and header */
682
683     if (!strncmp (TableHeader->Signature, "RSD PTR ", 8))
684     {
685         AxCheckAscii ((char *) &Header[9], 6);
686
687         Gbl_TableCount++;
688         printf (" %.2u) %5.4s  0x%8.8X  0x%2.2X  \"%6.6s\"\n",
689             Gbl_TableCount, "RSDP", Rsdp->Length, Rsdp->Revision, Rsdp->OemId);
690         return;
691     }
692
693     if (!AcpiUtValidNameseg (TableHeader->Signature))
694     {
695         return;
696     }
697
698     /* Signature and Table length */
699
700     Gbl_TableCount++;
701     printf (" %.2u) %5.4s  0x%8.8X", Gbl_TableCount, TableHeader->Signature,
702         TableHeader->Length);
703
704     /* FACS has only signature and length */
705
706     if (ACPI_COMPARE_NAME (TableHeader->Signature, "FACS"))
707     {
708         printf ("  0x%2.2X\n", Facs->Version);
709         return;
710     }
711
712     /* OEM IDs and Compiler IDs */
713
714     AxCheckAscii (TableHeader->OemId, 6);
715     AxCheckAscii (TableHeader->OemTableId, 8);
716     AxCheckAscii (TableHeader->AslCompilerId, 4);
717
718     printf (
719         "  0x%2.2X  \"%6.6s\"  \"%8.8s\"  0x%8.8X"
720         "  \"%4.4s\"   0x%8.8X\n",
721         TableHeader->Revision, TableHeader->OemId,
722         TableHeader->OemTableId, TableHeader->OemRevision,
723         TableHeader->AslCompilerId, TableHeader->AslCompilerRevision);
724 }
725
726
727 #ifdef _AX_FUTURE_ENHANCEMENTS
728
729 /* Possible enhancement to validate table lengths */
730
731 void
732 AxCheckTableLengths (
733     UINT32                  ByteCount,
734     UINT32                  AmlByteCount)
735 {
736
737     if (AmlByteCount == 0)
738     {
739         return;
740     }
741
742     if (ByteCount == 0)
743     {
744         return;
745     }
746
747     if ((ByteCount < sizeof (ACPI_TABLE_HEADER)) &&
748         (ByteCount >= ACPI_NAME_SIZE))
749     {
750         printf ("  : (Table too short for an ACPI table)");
751     }
752
753     else if (ByteCount != AmlByteCount)
754     {
755         printf ("  : (Hex data length mismatch with AML length 0x%X)",
756             AmlByteCount);
757     }
758
759     printf ("\n");
760 }
761 #endif