Home | History | Annotate | Line # | Download | only in compiler
dtio.c revision 1.1.1.21.6.1
      1           1.1    jruoho /******************************************************************************
      2           1.1    jruoho  *
      3           1.1    jruoho  * Module Name: dtio.c - File I/O support for data table compiler
      4           1.1    jruoho  *
      5           1.1    jruoho  *****************************************************************************/
      6           1.1    jruoho 
      7  1.1.1.21.6.1  perseant /******************************************************************************
      8  1.1.1.21.6.1  perseant  *
      9  1.1.1.21.6.1  perseant  * 1. Copyright Notice
     10  1.1.1.21.6.1  perseant  *
     11  1.1.1.21.6.1  perseant  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
     12           1.1    jruoho  * All rights reserved.
     13           1.1    jruoho  *
     14  1.1.1.21.6.1  perseant  * 2. License
     15  1.1.1.21.6.1  perseant  *
     16  1.1.1.21.6.1  perseant  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.1.1.21.6.1  perseant  * rights. You may have additional license terms from the party that provided
     18  1.1.1.21.6.1  perseant  * you this software, covering your right to use that party's intellectual
     19  1.1.1.21.6.1  perseant  * property rights.
     20  1.1.1.21.6.1  perseant  *
     21  1.1.1.21.6.1  perseant  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.1.1.21.6.1  perseant  * copy of the source code appearing in this file ("Covered Code") an
     23  1.1.1.21.6.1  perseant  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.1.1.21.6.1  perseant  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.1.1.21.6.1  perseant  * make derivatives, distribute, use and display any portion of the Covered
     26  1.1.1.21.6.1  perseant  * Code in any form, with the right to sublicense such rights; and
     27  1.1.1.21.6.1  perseant  *
     28  1.1.1.21.6.1  perseant  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.1.1.21.6.1  perseant  * license (with the right to sublicense), under only those claims of Intel
     30  1.1.1.21.6.1  perseant  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.1.1.21.6.1  perseant  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.1.1.21.6.1  perseant  * solely to the minimum extent necessary to exercise the above copyright
     33  1.1.1.21.6.1  perseant  * license, and in no event shall the patent license extend to any additions
     34  1.1.1.21.6.1  perseant  * to or modifications of the Original Intel Code. No other license or right
     35  1.1.1.21.6.1  perseant  * is granted directly or by implication, estoppel or otherwise;
     36  1.1.1.21.6.1  perseant  *
     37  1.1.1.21.6.1  perseant  * The above copyright and patent license is granted only if the following
     38  1.1.1.21.6.1  perseant  * conditions are met:
     39  1.1.1.21.6.1  perseant  *
     40  1.1.1.21.6.1  perseant  * 3. Conditions
     41  1.1.1.21.6.1  perseant  *
     42  1.1.1.21.6.1  perseant  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.1.1.21.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     44  1.1.1.21.6.1  perseant  * Code or modification with rights to further distribute source must include
     45  1.1.1.21.6.1  perseant  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.1.1.21.6.1  perseant  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.1.1.21.6.1  perseant  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.1.1.21.6.1  perseant  * contain a file documenting the changes Licensee made to create that Covered
     49  1.1.1.21.6.1  perseant  * Code and the date of any change. Licensee must include in that file the
     50  1.1.1.21.6.1  perseant  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.1.1.21.6.1  perseant  * must include a prominent statement that the modification is derived,
     52  1.1.1.21.6.1  perseant  * directly or indirectly, from Original Intel Code.
     53  1.1.1.21.6.1  perseant  *
     54  1.1.1.21.6.1  perseant  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.1.1.21.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     56  1.1.1.21.6.1  perseant  * Code or modification without rights to further distribute source must
     57  1.1.1.21.6.1  perseant  * include the following Disclaimer and Export Compliance provision in the
     58  1.1.1.21.6.1  perseant  * documentation and/or other materials provided with distribution. In
     59  1.1.1.21.6.1  perseant  * addition, Licensee may not authorize further sublicense of source of any
     60  1.1.1.21.6.1  perseant  * portion of the Covered Code, and must include terms to the effect that the
     61  1.1.1.21.6.1  perseant  * license from Licensee to its licensee is limited to the intellectual
     62  1.1.1.21.6.1  perseant  * property embodied in the software Licensee provides to its licensee, and
     63  1.1.1.21.6.1  perseant  * not to intellectual property embodied in modifications its licensee may
     64  1.1.1.21.6.1  perseant  * make.
     65  1.1.1.21.6.1  perseant  *
     66  1.1.1.21.6.1  perseant  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.1.1.21.6.1  perseant  * substantial portion of the Covered Code or modification must reproduce the
     68  1.1.1.21.6.1  perseant  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.1.1.21.6.1  perseant  * provision in the documentation and/or other materials provided with the
     70  1.1.1.21.6.1  perseant  * distribution.
     71  1.1.1.21.6.1  perseant  *
     72  1.1.1.21.6.1  perseant  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.1.1.21.6.1  perseant  * Intel Code.
     74  1.1.1.21.6.1  perseant  *
     75  1.1.1.21.6.1  perseant  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.1.1.21.6.1  perseant  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.1.1.21.6.1  perseant  * other dealings in products derived from or relating to the Covered Code
     78  1.1.1.21.6.1  perseant  * without prior written authorization from Intel.
     79  1.1.1.21.6.1  perseant  *
     80  1.1.1.21.6.1  perseant  * 4. Disclaimer and Export Compliance
     81  1.1.1.21.6.1  perseant  *
     82  1.1.1.21.6.1  perseant  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.1.1.21.6.1  perseant  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.1.1.21.6.1  perseant  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.1.1.21.6.1  perseant  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.1.1.21.6.1  perseant  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.1.1.21.6.1  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.1.1.21.6.1  perseant  * PARTICULAR PURPOSE.
     89  1.1.1.21.6.1  perseant  *
     90  1.1.1.21.6.1  perseant  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.1.1.21.6.1  perseant  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.1.1.21.6.1  perseant  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.1.1.21.6.1  perseant  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.1.1.21.6.1  perseant  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.1.1.21.6.1  perseant  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.1.1.21.6.1  perseant  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.1.1.21.6.1  perseant  * LIMITED REMEDY.
     98  1.1.1.21.6.1  perseant  *
     99  1.1.1.21.6.1  perseant  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.1.1.21.6.1  perseant  * software or system incorporating such software without first obtaining any
    101  1.1.1.21.6.1  perseant  * required license or other approval from the U. S. Department of Commerce or
    102  1.1.1.21.6.1  perseant  * any other agency or department of the United States Government. In the
    103  1.1.1.21.6.1  perseant  * event Licensee exports any such software from the United States or
    104  1.1.1.21.6.1  perseant  * re-exports any such software from a foreign destination, Licensee shall
    105  1.1.1.21.6.1  perseant  * ensure that the distribution and export/re-export of the software is in
    106  1.1.1.21.6.1  perseant  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.1.1.21.6.1  perseant  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.1.1.21.6.1  perseant  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.1.1.21.6.1  perseant  * software, or service, directly or indirectly, to any country for which the
    110  1.1.1.21.6.1  perseant  * United States government or any agency thereof requires an export license,
    111  1.1.1.21.6.1  perseant  * other governmental approval, or letter of assurance, without first obtaining
    112  1.1.1.21.6.1  perseant  * such license, approval or letter.
    113  1.1.1.21.6.1  perseant  *
    114  1.1.1.21.6.1  perseant  *****************************************************************************
    115  1.1.1.21.6.1  perseant  *
    116  1.1.1.21.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    117  1.1.1.21.6.1  perseant  * following license:
    118  1.1.1.21.6.1  perseant  *
    119       1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
    120       1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
    121       1.1.1.2    jruoho  * are met:
    122       1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
    123       1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124       1.1.1.2    jruoho  *    without modification.
    125       1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126       1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127       1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128       1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
    129       1.1.1.2    jruoho  *    binary redistribution.
    130       1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131       1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
    132       1.1.1.2    jruoho  *    from this software without specific prior written permission.
    133       1.1.1.2    jruoho  *
    134       1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135       1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136      1.1.1.17  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137       1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.1.1.21.6.1  perseant  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.1.1.21.6.1  perseant  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.1.1.21.6.1  perseant  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.1.1.21.6.1  perseant  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.1.1.21.6.1  perseant  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.1.1.21.6.1  perseant  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.1.1.21.6.1  perseant  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.1.1.21.6.1  perseant  *
    146  1.1.1.21.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    147  1.1.1.21.6.1  perseant  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.1.1.21.6.1  perseant  * Software Foundation.
    149  1.1.1.21.6.1  perseant  *
    150  1.1.1.21.6.1  perseant  *****************************************************************************/
    151           1.1    jruoho 
    152           1.1    jruoho #include "aslcompiler.h"
    153       1.1.1.5  christos #include "acapps.h"
    154           1.1    jruoho 
    155           1.1    jruoho #define _COMPONENT          DT_COMPILER
    156           1.1    jruoho         ACPI_MODULE_NAME    ("dtio")
    157           1.1    jruoho 
    158           1.1    jruoho 
    159       1.1.1.2    jruoho /* Local prototypes */
    160           1.1    jruoho 
    161       1.1.1.2    jruoho static char *
    162       1.1.1.2    jruoho DtTrim (
    163       1.1.1.2    jruoho     char                    *String);
    164           1.1    jruoho 
    165       1.1.1.2    jruoho static ACPI_STATUS
    166       1.1.1.2    jruoho DtParseLine (
    167       1.1.1.2    jruoho     char                    *LineBuffer,
    168       1.1.1.2    jruoho     UINT32                  Line,
    169       1.1.1.2    jruoho     UINT32                  Offset);
    170           1.1    jruoho 
    171       1.1.1.2    jruoho static void
    172       1.1.1.2    jruoho DtWriteBinary (
    173       1.1.1.2    jruoho     DT_SUBTABLE             *Subtable,
    174       1.1.1.2    jruoho     void                    *Context,
    175       1.1.1.2    jruoho     void                    *ReturnValue);
    176       1.1.1.2    jruoho 
    177       1.1.1.2    jruoho static void
    178       1.1.1.2    jruoho DtDumpBuffer (
    179       1.1.1.2    jruoho     UINT32                  FileId,
    180       1.1.1.2    jruoho     UINT8                   *Buffer,
    181       1.1.1.2    jruoho     UINT32                  Offset,
    182       1.1.1.2    jruoho     UINT32                  Length);
    183       1.1.1.2    jruoho 
    184       1.1.1.4  christos static void
    185       1.1.1.4  christos DtDumpSubtableInfo (
    186       1.1.1.4  christos     DT_SUBTABLE             *Subtable,
    187       1.1.1.4  christos     void                    *Context,
    188       1.1.1.4  christos     void                    *ReturnValue);
    189       1.1.1.4  christos 
    190       1.1.1.4  christos static void
    191       1.1.1.4  christos DtDumpSubtableTree (
    192       1.1.1.4  christos     DT_SUBTABLE             *Subtable,
    193       1.1.1.4  christos     void                    *Context,
    194       1.1.1.4  christos     void                    *ReturnValue);
    195       1.1.1.4  christos 
    196       1.1.1.2    jruoho 
    197       1.1.1.2    jruoho /* States for DtGetNextLine */
    198       1.1.1.2    jruoho 
    199       1.1.1.2    jruoho #define DT_NORMAL_TEXT              0
    200       1.1.1.2    jruoho #define DT_START_QUOTED_STRING      1
    201       1.1.1.2    jruoho #define DT_START_COMMENT            2
    202       1.1.1.2    jruoho #define DT_SLASH_ASTERISK_COMMENT   3
    203       1.1.1.2    jruoho #define DT_SLASH_SLASH_COMMENT      4
    204       1.1.1.2    jruoho #define DT_END_COMMENT              5
    205       1.1.1.3    jruoho #define DT_MERGE_LINES              6
    206       1.1.1.4  christos #define DT_ESCAPE_SEQUENCE          7
    207       1.1.1.2    jruoho 
    208      1.1.1.12  christos static UINT32               AslGbl_NextLineOffset;
    209           1.1    jruoho 
    210           1.1    jruoho 
    211           1.1    jruoho /******************************************************************************
    212           1.1    jruoho  *
    213           1.1    jruoho  * FUNCTION:    DtTrim
    214           1.1    jruoho  *
    215           1.1    jruoho  * PARAMETERS:  String              - Current source code line to trim
    216           1.1    jruoho  *
    217           1.1    jruoho  * RETURN:      Trimmed line. Must be freed by caller.
    218           1.1    jruoho  *
    219           1.1    jruoho  * DESCRIPTION: Trim left and right spaces
    220           1.1    jruoho  *
    221           1.1    jruoho  *****************************************************************************/
    222           1.1    jruoho 
    223           1.1    jruoho static char *
    224           1.1    jruoho DtTrim (
    225           1.1    jruoho     char                    *String)
    226           1.1    jruoho {
    227           1.1    jruoho     char                    *Start;
    228           1.1    jruoho     char                    *End;
    229           1.1    jruoho     char                    *ReturnString;
    230           1.1    jruoho     ACPI_SIZE               Length;
    231           1.1    jruoho 
    232           1.1    jruoho 
    233           1.1    jruoho     /* Skip lines that start with a space */
    234           1.1    jruoho 
    235      1.1.1.12  christos     if (*String == 0 || !strcmp (String, " "))
    236           1.1    jruoho     {
    237      1.1.1.10  christos         ReturnString = UtLocalCacheCalloc (1);
    238           1.1    jruoho         return (ReturnString);
    239           1.1    jruoho     }
    240           1.1    jruoho 
    241           1.1    jruoho     /* Setup pointers to start and end of input string */
    242           1.1    jruoho 
    243           1.1    jruoho     Start = String;
    244       1.1.1.7  christos     End = String + strlen (String) - 1;
    245           1.1    jruoho 
    246           1.1    jruoho     /* Find first non-whitespace character */
    247           1.1    jruoho 
    248           1.1    jruoho     while ((Start <= End) && ((*Start == ' ') || (*Start == '\t')))
    249           1.1    jruoho     {
    250           1.1    jruoho         Start++;
    251           1.1    jruoho     }
    252           1.1    jruoho 
    253           1.1    jruoho     /* Find last non-space character */
    254           1.1    jruoho 
    255           1.1    jruoho     while (End >= Start)
    256           1.1    jruoho     {
    257      1.1.1.12  christos         if (*End == '\n')
    258           1.1    jruoho         {
    259           1.1    jruoho             End--;
    260           1.1    jruoho             continue;
    261           1.1    jruoho         }
    262           1.1    jruoho 
    263           1.1    jruoho         if (*End != ' ')
    264           1.1    jruoho         {
    265           1.1    jruoho             break;
    266           1.1    jruoho         }
    267           1.1    jruoho 
    268           1.1    jruoho         End--;
    269           1.1    jruoho     }
    270           1.1    jruoho 
    271           1.1    jruoho     /* Remove any quotes around the string */
    272           1.1    jruoho 
    273           1.1    jruoho     if (*Start == '\"')
    274           1.1    jruoho     {
    275           1.1    jruoho         Start++;
    276           1.1    jruoho     }
    277           1.1    jruoho     if (*End == '\"')
    278           1.1    jruoho     {
    279           1.1    jruoho         End--;
    280           1.1    jruoho     }
    281           1.1    jruoho 
    282           1.1    jruoho     /* Create the trimmed return string */
    283           1.1    jruoho 
    284           1.1    jruoho     Length = ACPI_PTR_DIFF (End, Start) + 1;
    285      1.1.1.10  christos     ReturnString = UtLocalCacheCalloc (Length + 1);
    286       1.1.1.7  christos     if (strlen (Start))
    287           1.1    jruoho     {
    288       1.1.1.7  christos         strncpy (ReturnString, Start, Length);
    289           1.1    jruoho     }
    290           1.1    jruoho 
    291           1.1    jruoho     ReturnString[Length] = 0;
    292           1.1    jruoho     return (ReturnString);
    293           1.1    jruoho }
    294           1.1    jruoho 
    295           1.1    jruoho 
    296           1.1    jruoho /******************************************************************************
    297           1.1    jruoho  *
    298           1.1    jruoho  * FUNCTION:    DtParseLine
    299           1.1    jruoho  *
    300           1.1    jruoho  * PARAMETERS:  LineBuffer          - Current source code line
    301           1.1    jruoho  *              Line                - Current line number in the source
    302           1.1    jruoho  *              Offset              - Current byte offset of the line
    303           1.1    jruoho  *
    304       1.1.1.2    jruoho  * RETURN:      Status
    305           1.1    jruoho  *
    306           1.1    jruoho  * DESCRIPTION: Parse one source line
    307           1.1    jruoho  *
    308           1.1    jruoho  *****************************************************************************/
    309           1.1    jruoho 
    310       1.1.1.2    jruoho static ACPI_STATUS
    311           1.1    jruoho DtParseLine (
    312           1.1    jruoho     char                    *LineBuffer,
    313           1.1    jruoho     UINT32                  Line,
    314           1.1    jruoho     UINT32                  Offset)
    315           1.1    jruoho {
    316           1.1    jruoho     char                    *Start;
    317           1.1    jruoho     char                    *End;
    318           1.1    jruoho     char                    *TmpName;
    319           1.1    jruoho     char                    *TmpValue;
    320           1.1    jruoho     char                    *Name;
    321           1.1    jruoho     char                    *Value;
    322           1.1    jruoho     char                    *Colon;
    323           1.1    jruoho     UINT32                  Length;
    324           1.1    jruoho     DT_FIELD                *Field;
    325           1.1    jruoho     UINT32                  Column;
    326           1.1    jruoho     UINT32                  NameColumn;
    327       1.1.1.3    jruoho     BOOLEAN                 IsNullString = FALSE;
    328           1.1    jruoho 
    329           1.1    jruoho 
    330       1.1.1.2    jruoho     if (!LineBuffer)
    331           1.1    jruoho     {
    332       1.1.1.2    jruoho         return (AE_OK);
    333       1.1.1.2    jruoho     }
    334       1.1.1.2    jruoho 
    335      1.1.1.13  christos     /* All lines after "Raw Table Data" are ignored */
    336       1.1.1.2    jruoho 
    337       1.1.1.2    jruoho     if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER))
    338       1.1.1.2    jruoho     {
    339       1.1.1.2    jruoho         return (AE_NOT_FOUND);
    340           1.1    jruoho     }
    341           1.1    jruoho 
    342           1.1    jruoho     Colon = strchr (LineBuffer, ':');
    343       1.1.1.2    jruoho     if (!Colon)
    344           1.1    jruoho     {
    345       1.1.1.2    jruoho         return (AE_OK);
    346           1.1    jruoho     }
    347           1.1    jruoho 
    348           1.1    jruoho     Start = LineBuffer;
    349           1.1    jruoho     End = Colon;
    350           1.1    jruoho 
    351           1.1    jruoho     while (Start < Colon)
    352           1.1    jruoho     {
    353           1.1    jruoho         if (*Start == '[')
    354           1.1    jruoho         {
    355       1.1.1.4  christos             /* Found left bracket, go to the right bracket */
    356       1.1.1.4  christos 
    357           1.1    jruoho             while (Start < Colon && *Start != ']')
    358           1.1    jruoho             {
    359           1.1    jruoho                 Start++;
    360           1.1    jruoho             }
    361       1.1.1.4  christos         }
    362       1.1.1.4  christos         else if (*Start != ' ')
    363       1.1.1.4  christos         {
    364       1.1.1.4  christos             break;
    365           1.1    jruoho         }
    366           1.1    jruoho 
    367       1.1.1.4  christos         Start++;
    368           1.1    jruoho     }
    369           1.1    jruoho 
    370           1.1    jruoho     /*
    371           1.1    jruoho      * There are two column values. One for the field name,
    372           1.1    jruoho      * and one for the field value.
    373           1.1    jruoho      */
    374           1.1    jruoho     Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3;
    375           1.1    jruoho     NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1;
    376           1.1    jruoho 
    377           1.1    jruoho     Length = ACPI_PTR_DIFF (End, Start);
    378           1.1    jruoho 
    379           1.1    jruoho     TmpName = UtLocalCalloc (Length + 1);
    380       1.1.1.7  christos     strncpy (TmpName, Start, Length);
    381           1.1    jruoho     Name = DtTrim (TmpName);
    382           1.1    jruoho     ACPI_FREE (TmpName);
    383           1.1    jruoho 
    384           1.1    jruoho     Start = End = (Colon + 1);
    385           1.1    jruoho     while (*End)
    386           1.1    jruoho     {
    387           1.1    jruoho         /* Found left quotation, go to the right quotation and break */
    388           1.1    jruoho 
    389           1.1    jruoho         if (*End == '"')
    390           1.1    jruoho         {
    391           1.1    jruoho             End++;
    392       1.1.1.3    jruoho 
    393       1.1.1.3    jruoho             /* Check for an explicit null string */
    394       1.1.1.3    jruoho 
    395       1.1.1.3    jruoho             if (*End == '"')
    396       1.1.1.3    jruoho             {
    397       1.1.1.3    jruoho                 IsNullString = TRUE;
    398       1.1.1.3    jruoho             }
    399       1.1.1.2    jruoho             while (*End && (*End != '"'))
    400           1.1    jruoho             {
    401           1.1    jruoho                 End++;
    402           1.1    jruoho             }
    403           1.1    jruoho 
    404           1.1    jruoho             End++;
    405           1.1    jruoho             break;
    406           1.1    jruoho         }
    407           1.1    jruoho 
    408       1.1.1.2    jruoho         /*
    409       1.1.1.2    jruoho          * Special "comment" fields at line end, ignore them.
    410       1.1.1.2    jruoho          * Note: normal slash-slash and slash-asterisk comments are
    411       1.1.1.2    jruoho          * stripped already by the DtGetNextLine parser.
    412       1.1.1.2    jruoho          *
    413       1.1.1.2    jruoho          * TBD: Perhaps DtGetNextLine should parse the following type
    414       1.1.1.2    jruoho          * of comments also.
    415       1.1.1.2    jruoho          */
    416       1.1.1.3    jruoho         if (*End == '[')
    417           1.1    jruoho         {
    418       1.1.1.3    jruoho             End--;
    419           1.1    jruoho             break;
    420           1.1    jruoho         }
    421       1.1.1.8  christos 
    422           1.1    jruoho         End++;
    423           1.1    jruoho     }
    424           1.1    jruoho 
    425           1.1    jruoho     Length = ACPI_PTR_DIFF (End, Start);
    426           1.1    jruoho     TmpValue = UtLocalCalloc (Length + 1);
    427       1.1.1.3    jruoho 
    428       1.1.1.7  christos     strncpy (TmpValue, Start, Length);
    429           1.1    jruoho     Value = DtTrim (TmpValue);
    430           1.1    jruoho     ACPI_FREE (TmpValue);
    431           1.1    jruoho 
    432       1.1.1.3    jruoho     /* Create a new field object only if we have a valid value field */
    433       1.1.1.3    jruoho 
    434       1.1.1.3    jruoho     if ((Value && *Value) || IsNullString)
    435           1.1    jruoho     {
    436       1.1.1.5  christos         Field = UtFieldCacheCalloc ();
    437           1.1    jruoho         Field->Name = Name;
    438           1.1    jruoho         Field->Value = Value;
    439           1.1    jruoho         Field->Line = Line;
    440           1.1    jruoho         Field->ByteOffset = Offset;
    441           1.1    jruoho         Field->NameColumn = NameColumn;
    442           1.1    jruoho         Field->Column = Column;
    443       1.1.1.6  christos         Field->StringLength = Length;
    444           1.1    jruoho 
    445           1.1    jruoho         DtLinkField (Field);
    446           1.1    jruoho     }
    447       1.1.1.5  christos     /* Else -- Ignore this field, it has no valid data */
    448       1.1.1.2    jruoho 
    449       1.1.1.2    jruoho     return (AE_OK);
    450       1.1.1.2    jruoho }
    451       1.1.1.2    jruoho 
    452       1.1.1.2    jruoho 
    453       1.1.1.2    jruoho /******************************************************************************
    454       1.1.1.2    jruoho  *
    455       1.1.1.2    jruoho  * FUNCTION:    DtGetNextLine
    456       1.1.1.2    jruoho  *
    457       1.1.1.2    jruoho  * PARAMETERS:  Handle              - Open file handle for the source file
    458       1.1.1.2    jruoho  *
    459       1.1.1.3    jruoho  * RETURN:      Filled line buffer and offset of start-of-line (ASL_EOF on EOF)
    460       1.1.1.2    jruoho  *
    461       1.1.1.2    jruoho  * DESCRIPTION: Get the next valid source line. Removes all comments.
    462       1.1.1.2    jruoho  *              Ignores empty lines.
    463       1.1.1.2    jruoho  *
    464       1.1.1.2    jruoho  * Handles both slash-asterisk and slash-slash comments.
    465       1.1.1.2    jruoho  * Also, quoted strings, but no escapes within.
    466       1.1.1.2    jruoho  *
    467      1.1.1.12  christos  * Line is returned in AslGbl_CurrentLineBuffer.
    468      1.1.1.12  christos  * Line number in original file is returned in AslGbl_CurrentLineNumber.
    469       1.1.1.2    jruoho  *
    470       1.1.1.2    jruoho  *****************************************************************************/
    471       1.1.1.2    jruoho 
    472       1.1.1.2    jruoho UINT32
    473       1.1.1.2    jruoho DtGetNextLine (
    474       1.1.1.7  christos     FILE                    *Handle,
    475       1.1.1.7  christos     UINT32                  Flags)
    476       1.1.1.2    jruoho {
    477       1.1.1.3    jruoho     BOOLEAN                 LineNotAllBlanks = FALSE;
    478       1.1.1.2    jruoho     UINT32                  State = DT_NORMAL_TEXT;
    479       1.1.1.2    jruoho     UINT32                  CurrentLineOffset;
    480       1.1.1.2    jruoho     UINT32                  i;
    481       1.1.1.4  christos     int                     c;
    482      1.1.1.12  christos     int                     c1;
    483       1.1.1.2    jruoho 
    484       1.1.1.2    jruoho 
    485      1.1.1.12  christos     memset (AslGbl_CurrentLineBuffer, 0, AslGbl_LineBufferSize);
    486       1.1.1.4  christos     for (i = 0; ;)
    487       1.1.1.2    jruoho     {
    488       1.1.1.4  christos         /*
    489       1.1.1.4  christos          * If line is too long, expand the line buffers. Also increases
    490      1.1.1.12  christos          * AslGbl_LineBufferSize.
    491       1.1.1.4  christos          */
    492      1.1.1.12  christos         if (i >= AslGbl_LineBufferSize)
    493       1.1.1.4  christos         {
    494       1.1.1.4  christos             UtExpandLineBuffers ();
    495       1.1.1.4  christos         }
    496       1.1.1.4  christos 
    497       1.1.1.4  christos         c = getc (Handle);
    498       1.1.1.2    jruoho         if (c == EOF)
    499       1.1.1.2    jruoho         {
    500       1.1.1.2    jruoho             switch (State)
    501       1.1.1.2    jruoho             {
    502       1.1.1.2    jruoho             case DT_START_QUOTED_STRING:
    503       1.1.1.2    jruoho             case DT_SLASH_ASTERISK_COMMENT:
    504       1.1.1.2    jruoho 
    505       1.1.1.2    jruoho                 AcpiOsPrintf ("**** EOF within comment/string %u\n", State);
    506       1.1.1.2    jruoho                 break;
    507       1.1.1.2    jruoho 
    508       1.1.1.2    jruoho             default:
    509       1.1.1.4  christos 
    510       1.1.1.2    jruoho                 break;
    511       1.1.1.2    jruoho             }
    512       1.1.1.2    jruoho 
    513       1.1.1.4  christos             /* Standalone EOF is OK */
    514       1.1.1.4  christos 
    515       1.1.1.4  christos             if (i == 0)
    516       1.1.1.4  christos             {
    517       1.1.1.4  christos                 return (ASL_EOF);
    518       1.1.1.4  christos             }
    519       1.1.1.4  christos 
    520       1.1.1.4  christos             /*
    521       1.1.1.4  christos              * Received an EOF in the middle of a line. Terminate the
    522       1.1.1.4  christos              * line with a newline. The next call to this function will
    523       1.1.1.4  christos              * return a standalone EOF. Thus, the upper parsing software
    524       1.1.1.4  christos              * never has to deal with an EOF within a valid line (or
    525       1.1.1.4  christos              * the last line does not get tossed on the floor.)
    526       1.1.1.4  christos              */
    527       1.1.1.4  christos             c = '\n';
    528       1.1.1.4  christos             State = DT_NORMAL_TEXT;
    529       1.1.1.2    jruoho         }
    530      1.1.1.12  christos         else if (c == '\r')
    531      1.1.1.12  christos         {
    532      1.1.1.12  christos             c1 = getc (Handle);
    533      1.1.1.12  christos             if (c1 == '\n')
    534      1.1.1.12  christos             {
    535      1.1.1.12  christos                 /*
    536      1.1.1.12  christos                  * Skip the carriage return as if it didn't exist. This is
    537      1.1.1.12  christos                  * onlt meant for input files in DOS format in unix. fopen in
    538      1.1.1.12  christos                  * unix may not support "text mode" and leaves CRLF intact.
    539      1.1.1.12  christos                  */
    540      1.1.1.12  christos                 c = '\n';
    541      1.1.1.12  christos             }
    542      1.1.1.12  christos             else
    543      1.1.1.12  christos             {
    544      1.1.1.12  christos                 /* This was not a CRLF. Only a CR */
    545      1.1.1.12  christos 
    546      1.1.1.12  christos                 ungetc(c1, Handle);
    547      1.1.1.12  christos 
    548      1.1.1.12  christos                 DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL,
    549      1.1.1.12  christos                     "Carriage return without linefeed detected");
    550      1.1.1.12  christos                 return (ASL_EOF);
    551      1.1.1.12  christos             }
    552      1.1.1.12  christos         }
    553       1.1.1.2    jruoho 
    554       1.1.1.2    jruoho         switch (State)
    555       1.1.1.2    jruoho         {
    556       1.1.1.2    jruoho         case DT_NORMAL_TEXT:
    557       1.1.1.2    jruoho 
    558       1.1.1.2    jruoho             /* Normal text, insert char into line buffer */
    559       1.1.1.2    jruoho 
    560      1.1.1.12  christos             AslGbl_CurrentLineBuffer[i] = (char) c;
    561       1.1.1.2    jruoho             switch (c)
    562       1.1.1.2    jruoho             {
    563       1.1.1.2    jruoho             case '/':
    564       1.1.1.4  christos 
    565       1.1.1.2    jruoho                 State = DT_START_COMMENT;
    566       1.1.1.2    jruoho                 break;
    567       1.1.1.2    jruoho 
    568       1.1.1.2    jruoho             case '"':
    569       1.1.1.4  christos 
    570       1.1.1.2    jruoho                 State = DT_START_QUOTED_STRING;
    571       1.1.1.3    jruoho                 LineNotAllBlanks = TRUE;
    572       1.1.1.2    jruoho                 i++;
    573       1.1.1.2    jruoho                 break;
    574       1.1.1.2    jruoho 
    575       1.1.1.3    jruoho             case '\\':
    576       1.1.1.3    jruoho                 /*
    577       1.1.1.3    jruoho                  * The continuation char MUST be last char on this line.
    578       1.1.1.3    jruoho                  * Otherwise, it will be assumed to be a valid ASL char.
    579       1.1.1.3    jruoho                  */
    580       1.1.1.3    jruoho                 State = DT_MERGE_LINES;
    581       1.1.1.3    jruoho                 break;
    582       1.1.1.3    jruoho 
    583       1.1.1.2    jruoho             case '\n':
    584       1.1.1.4  christos 
    585      1.1.1.12  christos                 CurrentLineOffset = AslGbl_NextLineOffset;
    586      1.1.1.12  christos                 AslGbl_NextLineOffset = (UINT32) ftell (Handle);
    587      1.1.1.12  christos                 AslGbl_CurrentLineNumber++;
    588       1.1.1.2    jruoho 
    589       1.1.1.3    jruoho                 /*
    590       1.1.1.3    jruoho                  * Exit if line is complete. Ignore empty lines (only \n)
    591       1.1.1.3    jruoho                  * or lines that contain nothing but blanks.
    592       1.1.1.3    jruoho                  */
    593       1.1.1.3    jruoho                 if ((i != 0) && LineNotAllBlanks)
    594       1.1.1.2    jruoho                 {
    595      1.1.1.12  christos                     if ((i + 1) >= AslGbl_LineBufferSize)
    596       1.1.1.4  christos                     {
    597       1.1.1.4  christos                         UtExpandLineBuffers ();
    598       1.1.1.4  christos                     }
    599       1.1.1.4  christos 
    600      1.1.1.12  christos                     AslGbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */
    601       1.1.1.2    jruoho                     return (CurrentLineOffset);
    602       1.1.1.2    jruoho                 }
    603       1.1.1.3    jruoho 
    604       1.1.1.3    jruoho                 /* Toss this line and start a new one */
    605       1.1.1.3    jruoho 
    606       1.1.1.3    jruoho                 i = 0;
    607       1.1.1.3    jruoho                 LineNotAllBlanks = FALSE;
    608       1.1.1.2    jruoho                 break;
    609       1.1.1.2    jruoho 
    610       1.1.1.2    jruoho             default:
    611       1.1.1.4  christos 
    612       1.1.1.3    jruoho                 if (c != ' ')
    613       1.1.1.3    jruoho                 {
    614       1.1.1.3    jruoho                     LineNotAllBlanks = TRUE;
    615       1.1.1.3    jruoho                 }
    616       1.1.1.3    jruoho 
    617       1.1.1.2    jruoho                 i++;
    618       1.1.1.2    jruoho                 break;
    619       1.1.1.2    jruoho             }
    620       1.1.1.2    jruoho             break;
    621       1.1.1.2    jruoho 
    622       1.1.1.2    jruoho         case DT_START_QUOTED_STRING:
    623       1.1.1.2    jruoho 
    624       1.1.1.2    jruoho             /* Insert raw chars until end of quoted string */
    625       1.1.1.2    jruoho 
    626      1.1.1.12  christos             AslGbl_CurrentLineBuffer[i] = (char) c;
    627       1.1.1.2    jruoho             i++;
    628       1.1.1.2    jruoho 
    629       1.1.1.4  christos             switch (c)
    630       1.1.1.2    jruoho             {
    631       1.1.1.4  christos             case '"':
    632       1.1.1.4  christos 
    633       1.1.1.4  christos                 State = DT_NORMAL_TEXT;
    634       1.1.1.4  christos                 break;
    635       1.1.1.4  christos 
    636       1.1.1.4  christos             case '\\':
    637       1.1.1.4  christos 
    638       1.1.1.4  christos                 State = DT_ESCAPE_SEQUENCE;
    639       1.1.1.4  christos                 break;
    640       1.1.1.4  christos 
    641       1.1.1.4  christos             case '\n':
    642       1.1.1.4  christos 
    643       1.1.1.7  christos                 if (!(Flags & DT_ALLOW_MULTILINE_QUOTES))
    644       1.1.1.7  christos                 {
    645       1.1.1.8  christos                     AcpiOsPrintf (
    646       1.1.1.8  christos                         "ERROR at line %u: Unterminated quoted string\n",
    647      1.1.1.12  christos                         AslGbl_CurrentLineNumber++);
    648       1.1.1.7  christos                     State = DT_NORMAL_TEXT;
    649       1.1.1.7  christos                 }
    650       1.1.1.4  christos                 break;
    651       1.1.1.4  christos 
    652       1.1.1.4  christos             default:    /* Get next character */
    653       1.1.1.4  christos 
    654       1.1.1.4  christos                 break;
    655       1.1.1.2    jruoho             }
    656       1.1.1.2    jruoho             break;
    657       1.1.1.2    jruoho 
    658       1.1.1.4  christos         case DT_ESCAPE_SEQUENCE:
    659       1.1.1.4  christos 
    660       1.1.1.4  christos             /* Just copy the escaped character. TBD: sufficient for table compiler? */
    661       1.1.1.4  christos 
    662      1.1.1.12  christos             AslGbl_CurrentLineBuffer[i] = (char) c;
    663       1.1.1.4  christos             i++;
    664       1.1.1.4  christos             State = DT_START_QUOTED_STRING;
    665       1.1.1.4  christos             break;
    666       1.1.1.4  christos 
    667       1.1.1.2    jruoho         case DT_START_COMMENT:
    668       1.1.1.2    jruoho 
    669       1.1.1.2    jruoho             /* Open comment if this character is an asterisk or slash */
    670       1.1.1.2    jruoho 
    671       1.1.1.2    jruoho             switch (c)
    672       1.1.1.2    jruoho             {
    673       1.1.1.2    jruoho             case '*':
    674       1.1.1.4  christos 
    675       1.1.1.2    jruoho                 State = DT_SLASH_ASTERISK_COMMENT;
    676       1.1.1.2    jruoho                 break;
    677       1.1.1.2    jruoho 
    678       1.1.1.2    jruoho             case '/':
    679       1.1.1.4  christos 
    680       1.1.1.2    jruoho                 State = DT_SLASH_SLASH_COMMENT;
    681       1.1.1.2    jruoho                 break;
    682       1.1.1.2    jruoho 
    683       1.1.1.2    jruoho             default:    /* Not a comment */
    684       1.1.1.4  christos 
    685       1.1.1.4  christos                 i++;    /* Save the preceding slash */
    686      1.1.1.12  christos                 if (i >= AslGbl_LineBufferSize)
    687       1.1.1.4  christos                 {
    688       1.1.1.4  christos                     UtExpandLineBuffers ();
    689       1.1.1.4  christos                 }
    690       1.1.1.4  christos 
    691      1.1.1.12  christos                 AslGbl_CurrentLineBuffer[i] = (char) c;
    692       1.1.1.2    jruoho                 i++;
    693       1.1.1.2    jruoho                 State = DT_NORMAL_TEXT;
    694       1.1.1.2    jruoho                 break;
    695       1.1.1.2    jruoho             }
    696       1.1.1.2    jruoho             break;
    697       1.1.1.2    jruoho 
    698       1.1.1.2    jruoho         case DT_SLASH_ASTERISK_COMMENT:
    699       1.1.1.2    jruoho 
    700       1.1.1.2    jruoho             /* Ignore chars until an asterisk-slash is found */
    701       1.1.1.2    jruoho 
    702       1.1.1.2    jruoho             switch (c)
    703       1.1.1.2    jruoho             {
    704       1.1.1.2    jruoho             case '\n':
    705       1.1.1.4  christos 
    706      1.1.1.12  christos                 AslGbl_NextLineOffset = (UINT32) ftell (Handle);
    707      1.1.1.12  christos                 AslGbl_CurrentLineNumber++;
    708       1.1.1.2    jruoho                 break;
    709       1.1.1.2    jruoho 
    710       1.1.1.2    jruoho             case '*':
    711       1.1.1.4  christos 
    712       1.1.1.2    jruoho                 State = DT_END_COMMENT;
    713       1.1.1.2    jruoho                 break;
    714       1.1.1.2    jruoho 
    715       1.1.1.2    jruoho             default:
    716       1.1.1.4  christos 
    717       1.1.1.2    jruoho                 break;
    718       1.1.1.2    jruoho             }
    719       1.1.1.2    jruoho             break;
    720       1.1.1.2    jruoho 
    721       1.1.1.2    jruoho         case DT_SLASH_SLASH_COMMENT:
    722       1.1.1.2    jruoho 
    723       1.1.1.2    jruoho             /* Ignore chars until end-of-line */
    724       1.1.1.2    jruoho 
    725       1.1.1.2    jruoho             if (c == '\n')
    726       1.1.1.2    jruoho             {
    727       1.1.1.2    jruoho                 /* We will exit via the NORMAL_TEXT path */
    728       1.1.1.2    jruoho 
    729       1.1.1.2    jruoho                 ungetc (c, Handle);
    730       1.1.1.2    jruoho                 State = DT_NORMAL_TEXT;
    731       1.1.1.2    jruoho             }
    732       1.1.1.2    jruoho             break;
    733       1.1.1.2    jruoho 
    734       1.1.1.2    jruoho         case DT_END_COMMENT:
    735       1.1.1.2    jruoho 
    736       1.1.1.2    jruoho             /* End comment if this char is a slash */
    737       1.1.1.2    jruoho 
    738       1.1.1.2    jruoho             switch (c)
    739       1.1.1.2    jruoho             {
    740       1.1.1.2    jruoho             case '/':
    741       1.1.1.4  christos 
    742       1.1.1.2    jruoho                 State = DT_NORMAL_TEXT;
    743       1.1.1.2    jruoho                 break;
    744       1.1.1.2    jruoho 
    745       1.1.1.2    jruoho             case '\n':
    746       1.1.1.4  christos 
    747      1.1.1.12  christos                 AslGbl_NextLineOffset = (UINT32) ftell (Handle);
    748      1.1.1.12  christos                 AslGbl_CurrentLineNumber++;
    749       1.1.1.2    jruoho                 break;
    750       1.1.1.2    jruoho 
    751       1.1.1.2    jruoho             case '*':
    752       1.1.1.4  christos 
    753       1.1.1.2    jruoho                 /* Consume all adjacent asterisks */
    754       1.1.1.2    jruoho                 break;
    755       1.1.1.2    jruoho 
    756       1.1.1.2    jruoho             default:
    757       1.1.1.4  christos 
    758       1.1.1.2    jruoho                 State = DT_SLASH_ASTERISK_COMMENT;
    759       1.1.1.2    jruoho                 break;
    760       1.1.1.2    jruoho             }
    761       1.1.1.2    jruoho             break;
    762       1.1.1.2    jruoho 
    763       1.1.1.3    jruoho         case DT_MERGE_LINES:
    764       1.1.1.3    jruoho 
    765       1.1.1.3    jruoho             if (c != '\n')
    766       1.1.1.3    jruoho             {
    767       1.1.1.3    jruoho                 /*
    768       1.1.1.3    jruoho                  * This is not a continuation backslash, it is a normal
    769       1.1.1.3    jruoho                  * normal ASL backslash - for example: Scope(\_SB_)
    770       1.1.1.3    jruoho                  */
    771       1.1.1.3    jruoho                 i++; /* Keep the backslash that is already in the buffer */
    772       1.1.1.3    jruoho 
    773       1.1.1.3    jruoho                 ungetc (c, Handle);
    774       1.1.1.3    jruoho                 State = DT_NORMAL_TEXT;
    775       1.1.1.3    jruoho             }
    776       1.1.1.3    jruoho             else
    777       1.1.1.3    jruoho             {
    778       1.1.1.3    jruoho                 /*
    779       1.1.1.3    jruoho                  * This is a continuation line -- a backlash followed
    780       1.1.1.3    jruoho                  * immediately by a newline. Insert a space between the
    781       1.1.1.3    jruoho                  * lines (overwrite the backslash)
    782       1.1.1.3    jruoho                  */
    783      1.1.1.12  christos                 AslGbl_CurrentLineBuffer[i] = ' ';
    784       1.1.1.3    jruoho                 i++;
    785       1.1.1.3    jruoho 
    786       1.1.1.3    jruoho                 /* Ignore newline, this will merge the lines */
    787       1.1.1.3    jruoho 
    788      1.1.1.12  christos                 AslGbl_NextLineOffset = (UINT32) ftell (Handle);
    789      1.1.1.12  christos                 AslGbl_CurrentLineNumber++;
    790       1.1.1.3    jruoho                 State = DT_NORMAL_TEXT;
    791       1.1.1.3    jruoho             }
    792       1.1.1.3    jruoho             break;
    793       1.1.1.3    jruoho 
    794       1.1.1.2    jruoho         default:
    795       1.1.1.4  christos 
    796       1.1.1.2    jruoho             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state");
    797       1.1.1.3    jruoho             return (ASL_EOF);
    798       1.1.1.2    jruoho         }
    799       1.1.1.2    jruoho     }
    800           1.1    jruoho }
    801           1.1    jruoho 
    802           1.1    jruoho 
    803           1.1    jruoho /******************************************************************************
    804           1.1    jruoho  *
    805           1.1    jruoho  * FUNCTION:    DtScanFile
    806           1.1    jruoho  *
    807           1.1    jruoho  * PARAMETERS:  Handle              - Open file handle for the source file
    808           1.1    jruoho  *
    809           1.1    jruoho  * RETURN:      Pointer to start of the constructed parse tree.
    810           1.1    jruoho  *
    811       1.1.1.2    jruoho  * DESCRIPTION: Scan source file, link all field names and values
    812      1.1.1.12  christos  *              to the global parse tree: AslGbl_FieldList
    813           1.1    jruoho  *
    814           1.1    jruoho  *****************************************************************************/
    815           1.1    jruoho 
    816           1.1    jruoho DT_FIELD *
    817           1.1    jruoho DtScanFile (
    818           1.1    jruoho     FILE                    *Handle)
    819           1.1    jruoho {
    820       1.1.1.2    jruoho     ACPI_STATUS             Status;
    821       1.1.1.2    jruoho     UINT32                  Offset;
    822       1.1.1.2    jruoho 
    823       1.1.1.2    jruoho 
    824       1.1.1.2    jruoho     ACPI_FUNCTION_NAME (DtScanFile);
    825           1.1    jruoho 
    826           1.1    jruoho 
    827           1.1    jruoho     /* Get the file size */
    828           1.1    jruoho 
    829      1.1.1.12  christos     AslGbl_InputByteCount = CmGetFileSize (Handle);
    830      1.1.1.12  christos     if (AslGbl_InputByteCount == ACPI_UINT32_MAX)
    831       1.1.1.5  christos     {
    832       1.1.1.5  christos         AslAbort ();
    833       1.1.1.5  christos     }
    834           1.1    jruoho 
    835      1.1.1.12  christos     AslGbl_CurrentLineNumber = 0;
    836      1.1.1.12  christos     AslGbl_CurrentLineOffset = 0;
    837      1.1.1.12  christos     AslGbl_NextLineOffset = 0;
    838       1.1.1.2    jruoho 
    839           1.1    jruoho     /* Scan line-by-line */
    840           1.1    jruoho 
    841       1.1.1.7  christos     while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF)
    842           1.1    jruoho     {
    843       1.1.1.2    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
    844      1.1.1.12  christos             AslGbl_CurrentLineNumber, Offset, AslGbl_CurrentLineBuffer));
    845           1.1    jruoho 
    846      1.1.1.12  christos         Status = DtParseLine (AslGbl_CurrentLineBuffer,
    847      1.1.1.12  christos             AslGbl_CurrentLineNumber, Offset);
    848       1.1.1.2    jruoho         if (Status == AE_NOT_FOUND)
    849       1.1.1.2    jruoho         {
    850       1.1.1.2    jruoho             break;
    851       1.1.1.2    jruoho         }
    852           1.1    jruoho     }
    853           1.1    jruoho 
    854       1.1.1.3    jruoho     /* Dump the parse tree if debug enabled */
    855       1.1.1.3    jruoho 
    856      1.1.1.12  christos     DtDumpFieldList (AslGbl_FieldList);
    857      1.1.1.12  christos     return (AslGbl_FieldList);
    858           1.1    jruoho }
    859           1.1    jruoho 
    860           1.1    jruoho 
    861           1.1    jruoho /*
    862           1.1    jruoho  * Output functions
    863           1.1    jruoho  */
    864           1.1    jruoho 
    865           1.1    jruoho /******************************************************************************
    866           1.1    jruoho  *
    867           1.1    jruoho  * FUNCTION:    DtWriteBinary
    868           1.1    jruoho  *
    869           1.1    jruoho  * PARAMETERS:  DT_WALK_CALLBACK
    870           1.1    jruoho  *
    871           1.1    jruoho  * RETURN:      Status
    872           1.1    jruoho  *
    873           1.1    jruoho  * DESCRIPTION: Write one subtable of a binary ACPI table
    874           1.1    jruoho  *
    875           1.1    jruoho  *****************************************************************************/
    876           1.1    jruoho 
    877           1.1    jruoho static void
    878           1.1    jruoho DtWriteBinary (
    879           1.1    jruoho     DT_SUBTABLE             *Subtable,
    880           1.1    jruoho     void                    *Context,
    881           1.1    jruoho     void                    *ReturnValue)
    882           1.1    jruoho {
    883           1.1    jruoho 
    884           1.1    jruoho     FlWriteFile (ASL_FILE_AML_OUTPUT, Subtable->Buffer, Subtable->Length);
    885           1.1    jruoho }
    886           1.1    jruoho 
    887           1.1    jruoho 
    888           1.1    jruoho /******************************************************************************
    889           1.1    jruoho  *
    890           1.1    jruoho  * FUNCTION:    DtOutputBinary
    891           1.1    jruoho  *
    892           1.1    jruoho  * PARAMETERS:
    893           1.1    jruoho  *
    894           1.1    jruoho  * RETURN:      Status
    895           1.1    jruoho  *
    896           1.1    jruoho  * DESCRIPTION: Write entire binary ACPI table (result of compilation)
    897           1.1    jruoho  *
    898           1.1    jruoho  *****************************************************************************/
    899           1.1    jruoho 
    900           1.1    jruoho void
    901           1.1    jruoho DtOutputBinary (
    902           1.1    jruoho     DT_SUBTABLE             *RootTable)
    903           1.1    jruoho {
    904           1.1    jruoho 
    905           1.1    jruoho     if (!RootTable)
    906           1.1    jruoho     {
    907           1.1    jruoho         return;
    908           1.1    jruoho     }
    909           1.1    jruoho 
    910           1.1    jruoho     /* Walk the entire parse tree, emitting the binary data */
    911           1.1    jruoho 
    912           1.1    jruoho     DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL);
    913       1.1.1.5  christos 
    914      1.1.1.12  christos     AslGbl_TableLength = CmGetFileSize (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
    915      1.1.1.12  christos     if (AslGbl_TableLength == ACPI_UINT32_MAX)
    916       1.1.1.5  christos     {
    917       1.1.1.5  christos         AslAbort ();
    918       1.1.1.5  christos     }
    919           1.1    jruoho }
    920       1.1.1.2    jruoho 
    921       1.1.1.2    jruoho 
    922       1.1.1.2    jruoho /*
    923       1.1.1.2    jruoho  * Listing support
    924       1.1.1.2    jruoho  */
    925       1.1.1.2    jruoho 
    926       1.1.1.2    jruoho /******************************************************************************
    927       1.1.1.2    jruoho  *
    928       1.1.1.2    jruoho  * FUNCTION:    DtDumpBuffer
    929       1.1.1.2    jruoho  *
    930       1.1.1.2    jruoho  * PARAMETERS:  FileID              - Where to write buffer data
    931       1.1.1.2    jruoho  *              Buffer              - Buffer to dump
    932       1.1.1.2    jruoho  *              Offset              - Offset in current table
    933       1.1.1.2    jruoho  *              Length              - Buffer Length
    934       1.1.1.2    jruoho  *
    935       1.1.1.2    jruoho  * RETURN:      None
    936       1.1.1.2    jruoho  *
    937       1.1.1.2    jruoho  * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately).
    938       1.1.1.2    jruoho  *
    939       1.1.1.2    jruoho  * TBD: merge dump buffer routines
    940       1.1.1.2    jruoho  *
    941       1.1.1.2    jruoho  *****************************************************************************/
    942       1.1.1.2    jruoho 
    943       1.1.1.2    jruoho static void
    944       1.1.1.2    jruoho DtDumpBuffer (
    945       1.1.1.2    jruoho     UINT32                  FileId,
    946       1.1.1.2    jruoho     UINT8                   *Buffer,
    947       1.1.1.2    jruoho     UINT32                  Offset,
    948       1.1.1.2    jruoho     UINT32                  Length)
    949       1.1.1.2    jruoho {
    950       1.1.1.2    jruoho     UINT32                  i;
    951       1.1.1.2    jruoho     UINT32                  j;
    952       1.1.1.2    jruoho     UINT8                   BufChar;
    953       1.1.1.2    jruoho 
    954       1.1.1.2    jruoho 
    955      1.1.1.20  christos     FlPrintFile (FileId, "Output: [%3.3Xh %4.4d %3.3Xh] ",
    956       1.1.1.2    jruoho         Offset, Offset, Length);
    957       1.1.1.2    jruoho 
    958       1.1.1.2    jruoho     i = 0;
    959       1.1.1.2    jruoho     while (i < Length)
    960       1.1.1.2    jruoho     {
    961       1.1.1.2    jruoho         if (i >= 16)
    962       1.1.1.2    jruoho         {
    963       1.1.1.3    jruoho             FlPrintFile (FileId, "%24s", "");
    964       1.1.1.2    jruoho         }
    965       1.1.1.2    jruoho 
    966       1.1.1.2    jruoho         /* Print 16 hex chars */
    967       1.1.1.2    jruoho 
    968       1.1.1.2    jruoho         for (j = 0; j < 16;)
    969       1.1.1.2    jruoho         {
    970       1.1.1.2    jruoho             if (i + j >= Length)
    971       1.1.1.2    jruoho             {
    972       1.1.1.2    jruoho                 /* Dump fill spaces */
    973       1.1.1.2    jruoho 
    974       1.1.1.2    jruoho                 FlPrintFile (FileId, "   ");
    975       1.1.1.2    jruoho                 j++;
    976       1.1.1.2    jruoho                 continue;
    977       1.1.1.2    jruoho             }
    978       1.1.1.2    jruoho 
    979       1.1.1.2    jruoho             FlPrintFile (FileId, "%02X ", Buffer[i+j]);
    980       1.1.1.2    jruoho             j++;
    981       1.1.1.2    jruoho         }
    982       1.1.1.2    jruoho 
    983       1.1.1.2    jruoho         FlPrintFile (FileId, " ");
    984       1.1.1.2    jruoho         for (j = 0; j < 16; j++)
    985       1.1.1.2    jruoho         {
    986       1.1.1.2    jruoho             if (i + j >= Length)
    987       1.1.1.2    jruoho             {
    988       1.1.1.2    jruoho                 FlPrintFile (FileId, "\n\n");
    989       1.1.1.2    jruoho                 return;
    990       1.1.1.2    jruoho             }
    991       1.1.1.2    jruoho 
    992       1.1.1.2    jruoho             BufChar = Buffer[(ACPI_SIZE) i + j];
    993       1.1.1.7  christos             if (isprint (BufChar))
    994       1.1.1.2    jruoho             {
    995       1.1.1.2    jruoho                 FlPrintFile (FileId, "%c", BufChar);
    996       1.1.1.2    jruoho             }
    997       1.1.1.2    jruoho             else
    998       1.1.1.2    jruoho             {
    999       1.1.1.2    jruoho                 FlPrintFile (FileId, ".");
   1000       1.1.1.2    jruoho             }
   1001       1.1.1.2    jruoho         }
   1002       1.1.1.2    jruoho 
   1003       1.1.1.2    jruoho         /* Done with that line. */
   1004       1.1.1.2    jruoho 
   1005       1.1.1.2    jruoho         FlPrintFile (FileId, "\n");
   1006       1.1.1.2    jruoho         i += 16;
   1007       1.1.1.2    jruoho     }
   1008       1.1.1.2    jruoho 
   1009       1.1.1.2    jruoho     FlPrintFile (FileId, "\n\n");
   1010       1.1.1.2    jruoho }
   1011       1.1.1.2    jruoho 
   1012       1.1.1.2    jruoho 
   1013       1.1.1.2    jruoho /******************************************************************************
   1014       1.1.1.2    jruoho  *
   1015       1.1.1.4  christos  * FUNCTION:    DtDumpFieldList
   1016       1.1.1.4  christos  *
   1017       1.1.1.4  christos  * PARAMETERS:  Field               - Root field
   1018       1.1.1.4  christos  *
   1019       1.1.1.4  christos  * RETURN:      None
   1020       1.1.1.4  christos  *
   1021       1.1.1.4  christos  * DESCRIPTION: Dump the entire field list
   1022       1.1.1.4  christos  *
   1023       1.1.1.4  christos  *****************************************************************************/
   1024       1.1.1.4  christos 
   1025       1.1.1.4  christos void
   1026       1.1.1.4  christos DtDumpFieldList (
   1027       1.1.1.4  christos     DT_FIELD                *Field)
   1028       1.1.1.4  christos {
   1029       1.1.1.4  christos 
   1030      1.1.1.12  christos     if (!AslGbl_DebugFlag || !Field)
   1031       1.1.1.4  christos     {
   1032       1.1.1.4  christos         return;
   1033       1.1.1.4  christos     }
   1034       1.1.1.4  christos 
   1035       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,  "\nField List:\n"
   1036       1.1.1.4  christos         "LineNo   ByteOff  NameCol  Column   TableOff "
   1037       1.1.1.6  christos         "Flags %32s : %s\n\n", "Name", "Value");
   1038       1.1.1.8  christos 
   1039       1.1.1.4  christos     while (Field)
   1040       1.1.1.4  christos     {
   1041       1.1.1.4  christos         DbgPrint (ASL_DEBUG_OUTPUT,
   1042       1.1.1.6  christos             "%.08X %.08X %.08X %.08X %.08X %2.2X    %32s : %s\n",
   1043       1.1.1.4  christos             Field->Line, Field->ByteOffset, Field->NameColumn,
   1044       1.1.1.4  christos             Field->Column, Field->TableOffset, Field->Flags,
   1045       1.1.1.4  christos             Field->Name, Field->Value);
   1046       1.1.1.4  christos 
   1047       1.1.1.4  christos         Field = Field->Next;
   1048       1.1.1.4  christos     }
   1049       1.1.1.4  christos 
   1050       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,  "\n\n");
   1051       1.1.1.4  christos }
   1052       1.1.1.4  christos 
   1053       1.1.1.4  christos 
   1054       1.1.1.4  christos /******************************************************************************
   1055       1.1.1.4  christos  *
   1056       1.1.1.4  christos  * FUNCTION:    DtDumpSubtableInfo, DtDumpSubtableTree
   1057       1.1.1.4  christos  *
   1058       1.1.1.4  christos  * PARAMETERS:  DT_WALK_CALLBACK
   1059       1.1.1.4  christos  *
   1060       1.1.1.4  christos  * RETURN:      None
   1061       1.1.1.4  christos  *
   1062       1.1.1.4  christos  * DESCRIPTION: Info - dump a subtable tree entry with extra information.
   1063       1.1.1.4  christos  *              Tree - dump a subtable tree formatted by depth indentation.
   1064       1.1.1.4  christos  *
   1065       1.1.1.4  christos  *****************************************************************************/
   1066       1.1.1.4  christos 
   1067       1.1.1.4  christos static void
   1068       1.1.1.4  christos DtDumpSubtableInfo (
   1069       1.1.1.4  christos     DT_SUBTABLE             *Subtable,
   1070       1.1.1.4  christos     void                    *Context,
   1071       1.1.1.4  christos     void                    *ReturnValue)
   1072       1.1.1.4  christos {
   1073       1.1.1.4  christos 
   1074       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,
   1075      1.1.1.14  christos         "[%.04X] %24s %.08X %.08X %.08X %.08X %p %p %p %p\n",
   1076       1.1.1.7  christos         Subtable->Depth, Subtable->Name, Subtable->Length, Subtable->TotalLength,
   1077       1.1.1.4  christos         Subtable->SizeOfLengthField, Subtable->Flags, Subtable,
   1078       1.1.1.4  christos         Subtable->Parent, Subtable->Child, Subtable->Peer);
   1079       1.1.1.4  christos }
   1080       1.1.1.4  christos 
   1081       1.1.1.4  christos static void
   1082       1.1.1.4  christos DtDumpSubtableTree (
   1083       1.1.1.4  christos     DT_SUBTABLE             *Subtable,
   1084       1.1.1.4  christos     void                    *Context,
   1085       1.1.1.4  christos     void                    *ReturnValue)
   1086       1.1.1.4  christos {
   1087       1.1.1.4  christos 
   1088       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,
   1089      1.1.1.18  christos         "[%.04X] %24s %*s%p (%.02X) - (%.02X)        %.02X\n",
   1090       1.1.1.7  christos         Subtable->Depth, Subtable->Name, (4 * Subtable->Depth), " ",
   1091      1.1.1.18  christos         Subtable, Subtable->Length, Subtable->TotalLength, *Subtable->Buffer);
   1092       1.1.1.4  christos }
   1093       1.1.1.4  christos 
   1094       1.1.1.4  christos 
   1095       1.1.1.4  christos /******************************************************************************
   1096       1.1.1.4  christos  *
   1097       1.1.1.4  christos  * FUNCTION:    DtDumpSubtableList
   1098       1.1.1.4  christos  *
   1099       1.1.1.4  christos  * PARAMETERS:  None
   1100       1.1.1.4  christos  *
   1101       1.1.1.4  christos  * RETURN:      None
   1102       1.1.1.4  christos  *
   1103       1.1.1.4  christos  * DESCRIPTION: Dump the raw list of subtables with information, and also
   1104       1.1.1.4  christos  *              dump the subtable list in formatted tree format. Assists with
   1105       1.1.1.4  christos  *              the development of new table code.
   1106       1.1.1.4  christos  *
   1107       1.1.1.4  christos  *****************************************************************************/
   1108       1.1.1.4  christos 
   1109       1.1.1.4  christos void
   1110       1.1.1.4  christos DtDumpSubtableList (
   1111       1.1.1.4  christos     void)
   1112       1.1.1.4  christos {
   1113       1.1.1.4  christos 
   1114      1.1.1.12  christos     if (!AslGbl_DebugFlag || !AslGbl_RootTable)
   1115       1.1.1.4  christos     {
   1116       1.1.1.4  christos         return;
   1117       1.1.1.4  christos     }
   1118       1.1.1.4  christos 
   1119       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,
   1120       1.1.1.4  christos         "Subtable Info:\n"
   1121       1.1.1.7  christos         "Depth                      Name Length   TotalLen LenSize  Flags    "
   1122       1.1.1.4  christos         "This     Parent   Child    Peer\n\n");
   1123      1.1.1.12  christos     DtWalkTableTree (AslGbl_RootTable, DtDumpSubtableInfo, NULL, NULL);
   1124       1.1.1.4  christos 
   1125       1.1.1.4  christos     DbgPrint (ASL_DEBUG_OUTPUT,
   1126      1.1.1.18  christos         "\nSubtable Tree: (Depth, Name, Subtable, Length, TotalLength, Integer Value)\n\n");
   1127      1.1.1.12  christos     DtWalkTableTree (AslGbl_RootTable, DtDumpSubtableTree, NULL, NULL);
   1128       1.1.1.5  christos 
   1129       1.1.1.5  christos     DbgPrint (ASL_DEBUG_OUTPUT, "\n");
   1130       1.1.1.4  christos }
   1131       1.1.1.4  christos 
   1132       1.1.1.4  christos 
   1133       1.1.1.4  christos /******************************************************************************
   1134       1.1.1.4  christos  *
   1135       1.1.1.2    jruoho  * FUNCTION:    DtWriteFieldToListing
   1136       1.1.1.2    jruoho  *
   1137       1.1.1.2    jruoho  * PARAMETERS:  Buffer              - Contains the compiled data
   1138       1.1.1.2    jruoho  *              Field               - Field node for the input line
   1139       1.1.1.2    jruoho  *              Length              - Length of the output data
   1140       1.1.1.2    jruoho  *
   1141       1.1.1.2    jruoho  * RETURN:      None
   1142       1.1.1.2    jruoho  *
   1143       1.1.1.2    jruoho  * DESCRIPTION: Write one field to the listing file (if listing is enabled).
   1144       1.1.1.2    jruoho  *
   1145       1.1.1.2    jruoho  *****************************************************************************/
   1146       1.1.1.2    jruoho 
   1147       1.1.1.2    jruoho void
   1148       1.1.1.2    jruoho DtWriteFieldToListing (
   1149       1.1.1.2    jruoho     UINT8                   *Buffer,
   1150       1.1.1.2    jruoho     DT_FIELD                *Field,
   1151       1.1.1.2    jruoho     UINT32                  Length)
   1152       1.1.1.2    jruoho {
   1153       1.1.1.2    jruoho     UINT8                   FileByte;
   1154       1.1.1.2    jruoho 
   1155       1.1.1.2    jruoho 
   1156      1.1.1.12  christos     if (!AslGbl_ListingFlag || !Field)
   1157       1.1.1.2    jruoho     {
   1158       1.1.1.2    jruoho         return;
   1159       1.1.1.2    jruoho     }
   1160       1.1.1.2    jruoho 
   1161       1.1.1.2    jruoho     /* Dump the original source line */
   1162       1.1.1.2    jruoho 
   1163       1.1.1.2    jruoho     FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input:  ");
   1164       1.1.1.2    jruoho     FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset);
   1165       1.1.1.2    jruoho 
   1166       1.1.1.2    jruoho     while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK)
   1167       1.1.1.2    jruoho     {
   1168       1.1.1.2    jruoho         FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1);
   1169       1.1.1.2    jruoho         if (FileByte == '\n')
   1170       1.1.1.2    jruoho         {
   1171       1.1.1.2    jruoho             break;
   1172       1.1.1.2    jruoho         }
   1173       1.1.1.2    jruoho     }
   1174       1.1.1.2    jruoho 
   1175       1.1.1.2    jruoho     /* Dump the line as parsed and represented internally */
   1176       1.1.1.2    jruoho 
   1177       1.1.1.3    jruoho     FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %.64s",
   1178       1.1.1.2    jruoho         Field->Column-4, Field->Name, Field->Value);
   1179       1.1.1.2    jruoho 
   1180       1.1.1.3    jruoho     if (strlen (Field->Value) > 64)
   1181       1.1.1.3    jruoho     {
   1182       1.1.1.3    jruoho         FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n",
   1183      1.1.1.14  christos             (UINT32) strlen (Field->Value));
   1184       1.1.1.3    jruoho     }
   1185       1.1.1.8  christos 
   1186       1.1.1.3    jruoho     FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n");
   1187       1.1.1.3    jruoho 
   1188       1.1.1.2    jruoho     /* Dump the hex data that will be output for this field */
   1189       1.1.1.2    jruoho 
   1190       1.1.1.2    jruoho     DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
   1191       1.1.1.2    jruoho }
   1192       1.1.1.2    jruoho 
   1193       1.1.1.2    jruoho 
   1194       1.1.1.2    jruoho /******************************************************************************
   1195       1.1.1.2    jruoho  *
   1196       1.1.1.2    jruoho  * FUNCTION:    DtWriteTableToListing
   1197       1.1.1.2    jruoho  *
   1198       1.1.1.2    jruoho  * PARAMETERS:  None
   1199       1.1.1.2    jruoho  *
   1200       1.1.1.2    jruoho  * RETURN:      None
   1201       1.1.1.2    jruoho  *
   1202       1.1.1.2    jruoho  * DESCRIPTION: Write the entire compiled table to the listing file
   1203       1.1.1.2    jruoho  *              in hex format
   1204       1.1.1.2    jruoho  *
   1205       1.1.1.2    jruoho  *****************************************************************************/
   1206       1.1.1.2    jruoho 
   1207       1.1.1.2    jruoho void
   1208       1.1.1.2    jruoho DtWriteTableToListing (
   1209       1.1.1.2    jruoho     void)
   1210       1.1.1.2    jruoho {
   1211       1.1.1.2    jruoho     UINT8                   *Buffer;
   1212       1.1.1.2    jruoho 
   1213       1.1.1.2    jruoho 
   1214      1.1.1.12  christos     if (!AslGbl_ListingFlag)
   1215       1.1.1.2    jruoho     {
   1216       1.1.1.2    jruoho         return;
   1217       1.1.1.2    jruoho     }
   1218       1.1.1.2    jruoho 
   1219       1.1.1.2    jruoho     /* Read the entire table from the output file */
   1220       1.1.1.2    jruoho 
   1221      1.1.1.12  christos     Buffer = UtLocalCalloc (AslGbl_TableLength);
   1222       1.1.1.2    jruoho     FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
   1223      1.1.1.12  christos     FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, AslGbl_TableLength);
   1224       1.1.1.2    jruoho 
   1225       1.1.1.2    jruoho     /* Dump the raw table data */
   1226       1.1.1.2    jruoho 
   1227      1.1.1.12  christos     AcpiOsRedirectOutput (AslGbl_Files[ASL_FILE_LISTING_OUTPUT].Handle);
   1228       1.1.1.2    jruoho 
   1229       1.1.1.2    jruoho     AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
   1230      1.1.1.12  christos         ACPI_RAW_TABLE_DATA_HEADER, AslGbl_TableLength, AslGbl_TableLength);
   1231      1.1.1.12  christos     AcpiUtDumpBuffer (Buffer, AslGbl_TableLength, DB_BYTE_DISPLAY, 0);
   1232       1.1.1.2    jruoho 
   1233       1.1.1.2    jruoho     AcpiOsRedirectOutput (stdout);
   1234       1.1.1.4  christos     ACPI_FREE (Buffer);
   1235       1.1.1.2    jruoho }
   1236