Home | History | Annotate | Line # | Download | only in compiler
dtio.c revision 1.1.1.2.2.2
      1  1.1.1.2.2.2  bouyer /******************************************************************************
      2  1.1.1.2.2.2  bouyer  *
      3  1.1.1.2.2.2  bouyer  * Module Name: dtio.c - File I/O support for data table compiler
      4  1.1.1.2.2.2  bouyer  *
      5  1.1.1.2.2.2  bouyer  *****************************************************************************/
      6  1.1.1.2.2.2  bouyer 
      7  1.1.1.2.2.2  bouyer /*
      8  1.1.1.2.2.2  bouyer  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.1.1.2.2.2  bouyer  * All rights reserved.
     10  1.1.1.2.2.2  bouyer  *
     11  1.1.1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
     13  1.1.1.2.2.2  bouyer  * are met:
     14  1.1.1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2.2.2  bouyer  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2.2.2  bouyer  *    without modification.
     17  1.1.1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2.2.2  bouyer  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2.2.2  bouyer  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2.2.2  bouyer  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2.2.2  bouyer  *    binary redistribution.
     22  1.1.1.2.2.2  bouyer  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2.2.2  bouyer  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.1.1.2.2.2  bouyer  *
     26  1.1.1.2.2.2  bouyer  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2.2.2  bouyer  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2.2.2  bouyer  * Software Foundation.
     29  1.1.1.2.2.2  bouyer  *
     30  1.1.1.2.2.2  bouyer  * NO WARRANTY
     31  1.1.1.2.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2.2.2  bouyer  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2.2.2  bouyer  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2.2.2  bouyer  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2.2.2  bouyer  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2.2.2  bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2.2.2  bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2.2.2  bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2.2.2  bouyer  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2.2.2  bouyer  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2.2.2  bouyer  */
     43  1.1.1.2.2.2  bouyer 
     44  1.1.1.2.2.2  bouyer #define __DTIO_C__
     45  1.1.1.2.2.2  bouyer 
     46  1.1.1.2.2.2  bouyer #include "aslcompiler.h"
     47  1.1.1.2.2.2  bouyer #include "dtcompiler.h"
     48  1.1.1.2.2.2  bouyer 
     49  1.1.1.2.2.2  bouyer #define _COMPONENT          DT_COMPILER
     50  1.1.1.2.2.2  bouyer         ACPI_MODULE_NAME    ("dtio")
     51  1.1.1.2.2.2  bouyer 
     52  1.1.1.2.2.2  bouyer 
     53  1.1.1.2.2.2  bouyer /* Local prototypes */
     54  1.1.1.2.2.2  bouyer 
     55  1.1.1.2.2.2  bouyer static char *
     56  1.1.1.2.2.2  bouyer DtTrim (
     57  1.1.1.2.2.2  bouyer     char                    *String);
     58  1.1.1.2.2.2  bouyer 
     59  1.1.1.2.2.2  bouyer static void
     60  1.1.1.2.2.2  bouyer DtLinkField (
     61  1.1.1.2.2.2  bouyer     DT_FIELD                *Field);
     62  1.1.1.2.2.2  bouyer 
     63  1.1.1.2.2.2  bouyer static ACPI_STATUS
     64  1.1.1.2.2.2  bouyer DtParseLine (
     65  1.1.1.2.2.2  bouyer     char                    *LineBuffer,
     66  1.1.1.2.2.2  bouyer     UINT32                  Line,
     67  1.1.1.2.2.2  bouyer     UINT32                  Offset);
     68  1.1.1.2.2.2  bouyer 
     69  1.1.1.2.2.2  bouyer UINT32
     70  1.1.1.2.2.2  bouyer DtGetNextLine (
     71  1.1.1.2.2.2  bouyer     FILE                    *Handle);
     72  1.1.1.2.2.2  bouyer 
     73  1.1.1.2.2.2  bouyer static void
     74  1.1.1.2.2.2  bouyer DtWriteBinary (
     75  1.1.1.2.2.2  bouyer     DT_SUBTABLE             *Subtable,
     76  1.1.1.2.2.2  bouyer     void                    *Context,
     77  1.1.1.2.2.2  bouyer     void                    *ReturnValue);
     78  1.1.1.2.2.2  bouyer 
     79  1.1.1.2.2.2  bouyer static void
     80  1.1.1.2.2.2  bouyer DtDumpBuffer (
     81  1.1.1.2.2.2  bouyer     UINT32                  FileId,
     82  1.1.1.2.2.2  bouyer     UINT8                   *Buffer,
     83  1.1.1.2.2.2  bouyer     UINT32                  Offset,
     84  1.1.1.2.2.2  bouyer     UINT32                  Length);
     85  1.1.1.2.2.2  bouyer 
     86  1.1.1.2.2.2  bouyer 
     87  1.1.1.2.2.2  bouyer /* States for DtGetNextLine */
     88  1.1.1.2.2.2  bouyer 
     89  1.1.1.2.2.2  bouyer #define DT_NORMAL_TEXT              0
     90  1.1.1.2.2.2  bouyer #define DT_START_QUOTED_STRING      1
     91  1.1.1.2.2.2  bouyer #define DT_START_COMMENT            2
     92  1.1.1.2.2.2  bouyer #define DT_SLASH_ASTERISK_COMMENT   3
     93  1.1.1.2.2.2  bouyer #define DT_SLASH_SLASH_COMMENT      4
     94  1.1.1.2.2.2  bouyer #define DT_END_COMMENT              5
     95  1.1.1.2.2.2  bouyer 
     96  1.1.1.2.2.2  bouyer static UINT32  Gbl_NextLineOffset;
     97  1.1.1.2.2.2  bouyer 
     98  1.1.1.2.2.2  bouyer 
     99  1.1.1.2.2.2  bouyer /******************************************************************************
    100  1.1.1.2.2.2  bouyer  *
    101  1.1.1.2.2.2  bouyer  * FUNCTION:    DtTrim
    102  1.1.1.2.2.2  bouyer  *
    103  1.1.1.2.2.2  bouyer  * PARAMETERS:  String              - Current source code line to trim
    104  1.1.1.2.2.2  bouyer  *
    105  1.1.1.2.2.2  bouyer  * RETURN:      Trimmed line. Must be freed by caller.
    106  1.1.1.2.2.2  bouyer  *
    107  1.1.1.2.2.2  bouyer  * DESCRIPTION: Trim left and right spaces
    108  1.1.1.2.2.2  bouyer  *
    109  1.1.1.2.2.2  bouyer  *****************************************************************************/
    110  1.1.1.2.2.2  bouyer 
    111  1.1.1.2.2.2  bouyer static char *
    112  1.1.1.2.2.2  bouyer DtTrim (
    113  1.1.1.2.2.2  bouyer     char                    *String)
    114  1.1.1.2.2.2  bouyer {
    115  1.1.1.2.2.2  bouyer     char                    *Start;
    116  1.1.1.2.2.2  bouyer     char                    *End;
    117  1.1.1.2.2.2  bouyer     char                    *ReturnString;
    118  1.1.1.2.2.2  bouyer     ACPI_SIZE               Length;
    119  1.1.1.2.2.2  bouyer 
    120  1.1.1.2.2.2  bouyer 
    121  1.1.1.2.2.2  bouyer     /* Skip lines that start with a space */
    122  1.1.1.2.2.2  bouyer 
    123  1.1.1.2.2.2  bouyer     if (!ACPI_STRCMP (String, " "))
    124  1.1.1.2.2.2  bouyer     {
    125  1.1.1.2.2.2  bouyer         ReturnString = UtLocalCalloc (1);
    126  1.1.1.2.2.2  bouyer         return (ReturnString);
    127  1.1.1.2.2.2  bouyer     }
    128  1.1.1.2.2.2  bouyer 
    129  1.1.1.2.2.2  bouyer     /* Setup pointers to start and end of input string */
    130  1.1.1.2.2.2  bouyer 
    131  1.1.1.2.2.2  bouyer     Start = String;
    132  1.1.1.2.2.2  bouyer     End = String + ACPI_STRLEN (String) - 1;
    133  1.1.1.2.2.2  bouyer 
    134  1.1.1.2.2.2  bouyer     /* Find first non-whitespace character */
    135  1.1.1.2.2.2  bouyer 
    136  1.1.1.2.2.2  bouyer     while ((Start <= End) && ((*Start == ' ') || (*Start == '\t')))
    137  1.1.1.2.2.2  bouyer     {
    138  1.1.1.2.2.2  bouyer         Start++;
    139  1.1.1.2.2.2  bouyer     }
    140  1.1.1.2.2.2  bouyer 
    141  1.1.1.2.2.2  bouyer     /* Find last non-space character */
    142  1.1.1.2.2.2  bouyer 
    143  1.1.1.2.2.2  bouyer     while (End >= Start)
    144  1.1.1.2.2.2  bouyer     {
    145  1.1.1.2.2.2  bouyer         if (*End == '\r' || *End == '\n')
    146  1.1.1.2.2.2  bouyer         {
    147  1.1.1.2.2.2  bouyer             End--;
    148  1.1.1.2.2.2  bouyer             continue;
    149  1.1.1.2.2.2  bouyer         }
    150  1.1.1.2.2.2  bouyer 
    151  1.1.1.2.2.2  bouyer         if (*End != ' ')
    152  1.1.1.2.2.2  bouyer         {
    153  1.1.1.2.2.2  bouyer             break;
    154  1.1.1.2.2.2  bouyer         }
    155  1.1.1.2.2.2  bouyer 
    156  1.1.1.2.2.2  bouyer         End--;
    157  1.1.1.2.2.2  bouyer     }
    158  1.1.1.2.2.2  bouyer 
    159  1.1.1.2.2.2  bouyer     /* Remove any quotes around the string */
    160  1.1.1.2.2.2  bouyer 
    161  1.1.1.2.2.2  bouyer     if (*Start == '\"')
    162  1.1.1.2.2.2  bouyer     {
    163  1.1.1.2.2.2  bouyer         Start++;
    164  1.1.1.2.2.2  bouyer     }
    165  1.1.1.2.2.2  bouyer     if (*End == '\"')
    166  1.1.1.2.2.2  bouyer     {
    167  1.1.1.2.2.2  bouyer         End--;
    168  1.1.1.2.2.2  bouyer     }
    169  1.1.1.2.2.2  bouyer 
    170  1.1.1.2.2.2  bouyer     /* Create the trimmed return string */
    171  1.1.1.2.2.2  bouyer 
    172  1.1.1.2.2.2  bouyer     Length = ACPI_PTR_DIFF (End, Start) + 1;
    173  1.1.1.2.2.2  bouyer     ReturnString = UtLocalCalloc (Length + 1);
    174  1.1.1.2.2.2  bouyer     if (ACPI_STRLEN (Start))
    175  1.1.1.2.2.2  bouyer     {
    176  1.1.1.2.2.2  bouyer         ACPI_STRNCPY (ReturnString, Start, Length);
    177  1.1.1.2.2.2  bouyer     }
    178  1.1.1.2.2.2  bouyer 
    179  1.1.1.2.2.2  bouyer     ReturnString[Length] = 0;
    180  1.1.1.2.2.2  bouyer     return (ReturnString);
    181  1.1.1.2.2.2  bouyer }
    182  1.1.1.2.2.2  bouyer 
    183  1.1.1.2.2.2  bouyer 
    184  1.1.1.2.2.2  bouyer /******************************************************************************
    185  1.1.1.2.2.2  bouyer  *
    186  1.1.1.2.2.2  bouyer  * FUNCTION:    DtLinkField
    187  1.1.1.2.2.2  bouyer  *
    188  1.1.1.2.2.2  bouyer  * PARAMETERS:  Field               - New field object to link
    189  1.1.1.2.2.2  bouyer  *
    190  1.1.1.2.2.2  bouyer  * RETURN:      None
    191  1.1.1.2.2.2  bouyer  *
    192  1.1.1.2.2.2  bouyer  * DESCRIPTION: Link one field name and value to the list
    193  1.1.1.2.2.2  bouyer  *
    194  1.1.1.2.2.2  bouyer  *****************************************************************************/
    195  1.1.1.2.2.2  bouyer 
    196  1.1.1.2.2.2  bouyer static void
    197  1.1.1.2.2.2  bouyer DtLinkField (
    198  1.1.1.2.2.2  bouyer     DT_FIELD                *Field)
    199  1.1.1.2.2.2  bouyer {
    200  1.1.1.2.2.2  bouyer     DT_FIELD                *Prev;
    201  1.1.1.2.2.2  bouyer     DT_FIELD                *Next;
    202  1.1.1.2.2.2  bouyer 
    203  1.1.1.2.2.2  bouyer 
    204  1.1.1.2.2.2  bouyer     Prev = Next = Gbl_FieldList;
    205  1.1.1.2.2.2  bouyer 
    206  1.1.1.2.2.2  bouyer     while (Next)
    207  1.1.1.2.2.2  bouyer     {
    208  1.1.1.2.2.2  bouyer         Prev = Next;
    209  1.1.1.2.2.2  bouyer         Next = Next->Next;
    210  1.1.1.2.2.2  bouyer     }
    211  1.1.1.2.2.2  bouyer 
    212  1.1.1.2.2.2  bouyer     if (Prev)
    213  1.1.1.2.2.2  bouyer     {
    214  1.1.1.2.2.2  bouyer         Prev->Next = Field;
    215  1.1.1.2.2.2  bouyer     }
    216  1.1.1.2.2.2  bouyer     else
    217  1.1.1.2.2.2  bouyer     {
    218  1.1.1.2.2.2  bouyer         Gbl_FieldList = Field;
    219  1.1.1.2.2.2  bouyer     }
    220  1.1.1.2.2.2  bouyer }
    221  1.1.1.2.2.2  bouyer 
    222  1.1.1.2.2.2  bouyer 
    223  1.1.1.2.2.2  bouyer /******************************************************************************
    224  1.1.1.2.2.2  bouyer  *
    225  1.1.1.2.2.2  bouyer  * FUNCTION:    DtParseLine
    226  1.1.1.2.2.2  bouyer  *
    227  1.1.1.2.2.2  bouyer  * PARAMETERS:  LineBuffer          - Current source code line
    228  1.1.1.2.2.2  bouyer  *              Line                - Current line number in the source
    229  1.1.1.2.2.2  bouyer  *              Offset              - Current byte offset of the line
    230  1.1.1.2.2.2  bouyer  *
    231  1.1.1.2.2.2  bouyer  * RETURN:      Status
    232  1.1.1.2.2.2  bouyer  *
    233  1.1.1.2.2.2  bouyer  * DESCRIPTION: Parse one source line
    234  1.1.1.2.2.2  bouyer  *
    235  1.1.1.2.2.2  bouyer  *****************************************************************************/
    236  1.1.1.2.2.2  bouyer 
    237  1.1.1.2.2.2  bouyer static ACPI_STATUS
    238  1.1.1.2.2.2  bouyer DtParseLine (
    239  1.1.1.2.2.2  bouyer     char                    *LineBuffer,
    240  1.1.1.2.2.2  bouyer     UINT32                  Line,
    241  1.1.1.2.2.2  bouyer     UINT32                  Offset)
    242  1.1.1.2.2.2  bouyer {
    243  1.1.1.2.2.2  bouyer     char                    *Start;
    244  1.1.1.2.2.2  bouyer     char                    *End;
    245  1.1.1.2.2.2  bouyer     char                    *TmpName;
    246  1.1.1.2.2.2  bouyer     char                    *TmpValue;
    247  1.1.1.2.2.2  bouyer     char                    *Name;
    248  1.1.1.2.2.2  bouyer     char                    *Value;
    249  1.1.1.2.2.2  bouyer     char                    *Colon;
    250  1.1.1.2.2.2  bouyer     UINT32                  Length;
    251  1.1.1.2.2.2  bouyer     DT_FIELD                *Field;
    252  1.1.1.2.2.2  bouyer     UINT32                  Column;
    253  1.1.1.2.2.2  bouyer     UINT32                  NameColumn;
    254  1.1.1.2.2.2  bouyer 
    255  1.1.1.2.2.2  bouyer 
    256  1.1.1.2.2.2  bouyer     if (!LineBuffer)
    257  1.1.1.2.2.2  bouyer     {
    258  1.1.1.2.2.2  bouyer         return (AE_OK);
    259  1.1.1.2.2.2  bouyer     }
    260  1.1.1.2.2.2  bouyer 
    261  1.1.1.2.2.2  bouyer     /* All lines after "Raw Table Data" are ingored */
    262  1.1.1.2.2.2  bouyer 
    263  1.1.1.2.2.2  bouyer     if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER))
    264  1.1.1.2.2.2  bouyer     {
    265  1.1.1.2.2.2  bouyer         return (AE_NOT_FOUND);
    266  1.1.1.2.2.2  bouyer     }
    267  1.1.1.2.2.2  bouyer 
    268  1.1.1.2.2.2  bouyer     Colon = strchr (LineBuffer, ':');
    269  1.1.1.2.2.2  bouyer     if (!Colon)
    270  1.1.1.2.2.2  bouyer     {
    271  1.1.1.2.2.2  bouyer         return (AE_OK);
    272  1.1.1.2.2.2  bouyer     }
    273  1.1.1.2.2.2  bouyer 
    274  1.1.1.2.2.2  bouyer     Start = LineBuffer;
    275  1.1.1.2.2.2  bouyer     End = Colon;
    276  1.1.1.2.2.2  bouyer 
    277  1.1.1.2.2.2  bouyer     while (Start < Colon)
    278  1.1.1.2.2.2  bouyer     {
    279  1.1.1.2.2.2  bouyer         if (*Start == ' ')
    280  1.1.1.2.2.2  bouyer         {
    281  1.1.1.2.2.2  bouyer             Start++;
    282  1.1.1.2.2.2  bouyer             continue;
    283  1.1.1.2.2.2  bouyer         }
    284  1.1.1.2.2.2  bouyer 
    285  1.1.1.2.2.2  bouyer         /* Found left bracket, go to the right bracket */
    286  1.1.1.2.2.2  bouyer 
    287  1.1.1.2.2.2  bouyer         if (*Start == '[')
    288  1.1.1.2.2.2  bouyer         {
    289  1.1.1.2.2.2  bouyer             while (Start < Colon && *Start != ']')
    290  1.1.1.2.2.2  bouyer             {
    291  1.1.1.2.2.2  bouyer                 Start++;
    292  1.1.1.2.2.2  bouyer             }
    293  1.1.1.2.2.2  bouyer 
    294  1.1.1.2.2.2  bouyer             if (Start == Colon)
    295  1.1.1.2.2.2  bouyer             {
    296  1.1.1.2.2.2  bouyer                 break;
    297  1.1.1.2.2.2  bouyer             }
    298  1.1.1.2.2.2  bouyer 
    299  1.1.1.2.2.2  bouyer             Start++;
    300  1.1.1.2.2.2  bouyer             continue;
    301  1.1.1.2.2.2  bouyer         }
    302  1.1.1.2.2.2  bouyer 
    303  1.1.1.2.2.2  bouyer         break;
    304  1.1.1.2.2.2  bouyer     }
    305  1.1.1.2.2.2  bouyer 
    306  1.1.1.2.2.2  bouyer     /*
    307  1.1.1.2.2.2  bouyer      * There are two column values. One for the field name,
    308  1.1.1.2.2.2  bouyer      * and one for the field value.
    309  1.1.1.2.2.2  bouyer      */
    310  1.1.1.2.2.2  bouyer     Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3;
    311  1.1.1.2.2.2  bouyer     NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1;
    312  1.1.1.2.2.2  bouyer 
    313  1.1.1.2.2.2  bouyer     Length = ACPI_PTR_DIFF (End, Start);
    314  1.1.1.2.2.2  bouyer 
    315  1.1.1.2.2.2  bouyer     TmpName = UtLocalCalloc (Length + 1);
    316  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (TmpName, Start, Length);
    317  1.1.1.2.2.2  bouyer     Name = DtTrim (TmpName);
    318  1.1.1.2.2.2  bouyer     ACPI_FREE (TmpName);
    319  1.1.1.2.2.2  bouyer 
    320  1.1.1.2.2.2  bouyer     Start = End = (Colon + 1);
    321  1.1.1.2.2.2  bouyer 
    322  1.1.1.2.2.2  bouyer     while (*End)
    323  1.1.1.2.2.2  bouyer     {
    324  1.1.1.2.2.2  bouyer         /* Found left quotation, go to the right quotation and break */
    325  1.1.1.2.2.2  bouyer 
    326  1.1.1.2.2.2  bouyer         if (*End == '"')
    327  1.1.1.2.2.2  bouyer         {
    328  1.1.1.2.2.2  bouyer             End++;
    329  1.1.1.2.2.2  bouyer             while (*End && (*End != '"'))
    330  1.1.1.2.2.2  bouyer             {
    331  1.1.1.2.2.2  bouyer                 End++;
    332  1.1.1.2.2.2  bouyer             }
    333  1.1.1.2.2.2  bouyer 
    334  1.1.1.2.2.2  bouyer             End++;
    335  1.1.1.2.2.2  bouyer             break;
    336  1.1.1.2.2.2  bouyer         }
    337  1.1.1.2.2.2  bouyer 
    338  1.1.1.2.2.2  bouyer         /*
    339  1.1.1.2.2.2  bouyer          * Special "comment" fields at line end, ignore them.
    340  1.1.1.2.2.2  bouyer          * Note: normal slash-slash and slash-asterisk comments are
    341  1.1.1.2.2.2  bouyer          * stripped already by the DtGetNextLine parser.
    342  1.1.1.2.2.2  bouyer          *
    343  1.1.1.2.2.2  bouyer          * TBD: Perhaps DtGetNextLine should parse the following type
    344  1.1.1.2.2.2  bouyer          * of comments also.
    345  1.1.1.2.2.2  bouyer          */
    346  1.1.1.2.2.2  bouyer         if (*End == '(' ||
    347  1.1.1.2.2.2  bouyer             *End == '<')
    348  1.1.1.2.2.2  bouyer         {
    349  1.1.1.2.2.2  bouyer             break;
    350  1.1.1.2.2.2  bouyer         }
    351  1.1.1.2.2.2  bouyer 
    352  1.1.1.2.2.2  bouyer         End++;
    353  1.1.1.2.2.2  bouyer     }
    354  1.1.1.2.2.2  bouyer 
    355  1.1.1.2.2.2  bouyer     Length = ACPI_PTR_DIFF (End, Start);
    356  1.1.1.2.2.2  bouyer     TmpValue = UtLocalCalloc (Length + 1);
    357  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (TmpValue, Start, Length);
    358  1.1.1.2.2.2  bouyer     Value = DtTrim (TmpValue);
    359  1.1.1.2.2.2  bouyer     ACPI_FREE (TmpValue);
    360  1.1.1.2.2.2  bouyer 
    361  1.1.1.2.2.2  bouyer     if (Name && Value)
    362  1.1.1.2.2.2  bouyer     {
    363  1.1.1.2.2.2  bouyer         Field = UtLocalCalloc (sizeof (DT_FIELD));
    364  1.1.1.2.2.2  bouyer         Field->Name = Name;
    365  1.1.1.2.2.2  bouyer         Field->Value = Value;
    366  1.1.1.2.2.2  bouyer         Field->Line = Line;
    367  1.1.1.2.2.2  bouyer         Field->ByteOffset = Offset;
    368  1.1.1.2.2.2  bouyer         Field->NameColumn = NameColumn;
    369  1.1.1.2.2.2  bouyer         Field->Column = Column;
    370  1.1.1.2.2.2  bouyer 
    371  1.1.1.2.2.2  bouyer         DtLinkField (Field);
    372  1.1.1.2.2.2  bouyer     }
    373  1.1.1.2.2.2  bouyer 
    374  1.1.1.2.2.2  bouyer     return (AE_OK);
    375  1.1.1.2.2.2  bouyer }
    376  1.1.1.2.2.2  bouyer 
    377  1.1.1.2.2.2  bouyer 
    378  1.1.1.2.2.2  bouyer /******************************************************************************
    379  1.1.1.2.2.2  bouyer  *
    380  1.1.1.2.2.2  bouyer  * FUNCTION:    DtGetNextLine
    381  1.1.1.2.2.2  bouyer  *
    382  1.1.1.2.2.2  bouyer  * PARAMETERS:  Handle              - Open file handle for the source file
    383  1.1.1.2.2.2  bouyer  *
    384  1.1.1.2.2.2  bouyer  * RETURN:      Filled line buffer and offset of start-of-line (zero on EOF)
    385  1.1.1.2.2.2  bouyer  *
    386  1.1.1.2.2.2  bouyer  * DESCRIPTION: Get the next valid source line. Removes all comments.
    387  1.1.1.2.2.2  bouyer  *              Ignores empty lines.
    388  1.1.1.2.2.2  bouyer  *
    389  1.1.1.2.2.2  bouyer  * Handles both slash-asterisk and slash-slash comments.
    390  1.1.1.2.2.2  bouyer  * Also, quoted strings, but no escapes within.
    391  1.1.1.2.2.2  bouyer  *
    392  1.1.1.2.2.2  bouyer  * Line is returned in Gbl_CurrentLineBuffer.
    393  1.1.1.2.2.2  bouyer  * Line number in original file is returned in Gbl_CurrentLineNumber.
    394  1.1.1.2.2.2  bouyer  *
    395  1.1.1.2.2.2  bouyer  *****************************************************************************/
    396  1.1.1.2.2.2  bouyer 
    397  1.1.1.2.2.2  bouyer UINT32
    398  1.1.1.2.2.2  bouyer DtGetNextLine (
    399  1.1.1.2.2.2  bouyer     FILE                    *Handle)
    400  1.1.1.2.2.2  bouyer {
    401  1.1.1.2.2.2  bouyer     UINT32                  State = DT_NORMAL_TEXT;
    402  1.1.1.2.2.2  bouyer     UINT32                  CurrentLineOffset;
    403  1.1.1.2.2.2  bouyer     UINT32                  i;
    404  1.1.1.2.2.2  bouyer     char                    c;
    405  1.1.1.2.2.2  bouyer 
    406  1.1.1.2.2.2  bouyer 
    407  1.1.1.2.2.2  bouyer     for (i = 0; i < ASL_LINE_BUFFER_SIZE;)
    408  1.1.1.2.2.2  bouyer     {
    409  1.1.1.2.2.2  bouyer         c = (char) getc (Handle);
    410  1.1.1.2.2.2  bouyer         if (c == EOF)
    411  1.1.1.2.2.2  bouyer         {
    412  1.1.1.2.2.2  bouyer             switch (State)
    413  1.1.1.2.2.2  bouyer             {
    414  1.1.1.2.2.2  bouyer             case DT_START_QUOTED_STRING:
    415  1.1.1.2.2.2  bouyer             case DT_SLASH_ASTERISK_COMMENT:
    416  1.1.1.2.2.2  bouyer             case DT_SLASH_SLASH_COMMENT:
    417  1.1.1.2.2.2  bouyer 
    418  1.1.1.2.2.2  bouyer                 AcpiOsPrintf ("**** EOF within comment/string %u\n", State);
    419  1.1.1.2.2.2  bouyer                 break;
    420  1.1.1.2.2.2  bouyer 
    421  1.1.1.2.2.2  bouyer             default:
    422  1.1.1.2.2.2  bouyer                 break;
    423  1.1.1.2.2.2  bouyer             }
    424  1.1.1.2.2.2  bouyer 
    425  1.1.1.2.2.2  bouyer             return (0);
    426  1.1.1.2.2.2  bouyer         }
    427  1.1.1.2.2.2  bouyer 
    428  1.1.1.2.2.2  bouyer         switch (State)
    429  1.1.1.2.2.2  bouyer         {
    430  1.1.1.2.2.2  bouyer         case DT_NORMAL_TEXT:
    431  1.1.1.2.2.2  bouyer 
    432  1.1.1.2.2.2  bouyer             /* Normal text, insert char into line buffer */
    433  1.1.1.2.2.2  bouyer 
    434  1.1.1.2.2.2  bouyer             Gbl_CurrentLineBuffer[i] = c;
    435  1.1.1.2.2.2  bouyer             switch (c)
    436  1.1.1.2.2.2  bouyer             {
    437  1.1.1.2.2.2  bouyer             case '/':
    438  1.1.1.2.2.2  bouyer                 State = DT_START_COMMENT;
    439  1.1.1.2.2.2  bouyer                 break;
    440  1.1.1.2.2.2  bouyer 
    441  1.1.1.2.2.2  bouyer             case '"':
    442  1.1.1.2.2.2  bouyer                 State = DT_START_QUOTED_STRING;
    443  1.1.1.2.2.2  bouyer                 i++;
    444  1.1.1.2.2.2  bouyer                 break;
    445  1.1.1.2.2.2  bouyer 
    446  1.1.1.2.2.2  bouyer             case '\n':
    447  1.1.1.2.2.2  bouyer                 CurrentLineOffset = Gbl_NextLineOffset;
    448  1.1.1.2.2.2  bouyer                 Gbl_NextLineOffset = (UINT32) ftell (Handle);
    449  1.1.1.2.2.2  bouyer                 Gbl_CurrentLineNumber++;
    450  1.1.1.2.2.2  bouyer 
    451  1.1.1.2.2.2  bouyer                 /* Exit if line is complete. Ignore blank lines */
    452  1.1.1.2.2.2  bouyer 
    453  1.1.1.2.2.2  bouyer                 if (i != 0)
    454  1.1.1.2.2.2  bouyer                 {
    455  1.1.1.2.2.2  bouyer                     Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate line */
    456  1.1.1.2.2.2  bouyer                     return (CurrentLineOffset);
    457  1.1.1.2.2.2  bouyer                 }
    458  1.1.1.2.2.2  bouyer                 break;
    459  1.1.1.2.2.2  bouyer 
    460  1.1.1.2.2.2  bouyer             default:
    461  1.1.1.2.2.2  bouyer                 i++;
    462  1.1.1.2.2.2  bouyer                 break;
    463  1.1.1.2.2.2  bouyer             }
    464  1.1.1.2.2.2  bouyer             break;
    465  1.1.1.2.2.2  bouyer 
    466  1.1.1.2.2.2  bouyer         case DT_START_QUOTED_STRING:
    467  1.1.1.2.2.2  bouyer 
    468  1.1.1.2.2.2  bouyer             /* Insert raw chars until end of quoted string */
    469  1.1.1.2.2.2  bouyer 
    470  1.1.1.2.2.2  bouyer             Gbl_CurrentLineBuffer[i] = c;
    471  1.1.1.2.2.2  bouyer             i++;
    472  1.1.1.2.2.2  bouyer 
    473  1.1.1.2.2.2  bouyer             if (c == '"')
    474  1.1.1.2.2.2  bouyer             {
    475  1.1.1.2.2.2  bouyer                 State = DT_NORMAL_TEXT;
    476  1.1.1.2.2.2  bouyer             }
    477  1.1.1.2.2.2  bouyer             break;
    478  1.1.1.2.2.2  bouyer 
    479  1.1.1.2.2.2  bouyer         case DT_START_COMMENT:
    480  1.1.1.2.2.2  bouyer 
    481  1.1.1.2.2.2  bouyer             /* Open comment if this character is an asterisk or slash */
    482  1.1.1.2.2.2  bouyer 
    483  1.1.1.2.2.2  bouyer             switch (c)
    484  1.1.1.2.2.2  bouyer             {
    485  1.1.1.2.2.2  bouyer             case '*':
    486  1.1.1.2.2.2  bouyer                 State = DT_SLASH_ASTERISK_COMMENT;
    487  1.1.1.2.2.2  bouyer                 break;
    488  1.1.1.2.2.2  bouyer 
    489  1.1.1.2.2.2  bouyer             case '/':
    490  1.1.1.2.2.2  bouyer                 State = DT_SLASH_SLASH_COMMENT;
    491  1.1.1.2.2.2  bouyer                 break;
    492  1.1.1.2.2.2  bouyer 
    493  1.1.1.2.2.2  bouyer             default:    /* Not a comment */
    494  1.1.1.2.2.2  bouyer                 i++;    /* Save the preceeding slash */
    495  1.1.1.2.2.2  bouyer                 Gbl_CurrentLineBuffer[i] = c;
    496  1.1.1.2.2.2  bouyer                 i++;
    497  1.1.1.2.2.2  bouyer                 State = DT_NORMAL_TEXT;
    498  1.1.1.2.2.2  bouyer                 break;
    499  1.1.1.2.2.2  bouyer             }
    500  1.1.1.2.2.2  bouyer             break;
    501  1.1.1.2.2.2  bouyer 
    502  1.1.1.2.2.2  bouyer         case DT_SLASH_ASTERISK_COMMENT:
    503  1.1.1.2.2.2  bouyer 
    504  1.1.1.2.2.2  bouyer             /* Ignore chars until an asterisk-slash is found */
    505  1.1.1.2.2.2  bouyer 
    506  1.1.1.2.2.2  bouyer             switch (c)
    507  1.1.1.2.2.2  bouyer             {
    508  1.1.1.2.2.2  bouyer             case '\n':
    509  1.1.1.2.2.2  bouyer                 Gbl_NextLineOffset = (UINT32) ftell (Handle);
    510  1.1.1.2.2.2  bouyer                 Gbl_CurrentLineNumber++;
    511  1.1.1.2.2.2  bouyer                 break;
    512  1.1.1.2.2.2  bouyer 
    513  1.1.1.2.2.2  bouyer             case '*':
    514  1.1.1.2.2.2  bouyer                 State = DT_END_COMMENT;
    515  1.1.1.2.2.2  bouyer                 break;
    516  1.1.1.2.2.2  bouyer 
    517  1.1.1.2.2.2  bouyer             default:
    518  1.1.1.2.2.2  bouyer                 break;
    519  1.1.1.2.2.2  bouyer             }
    520  1.1.1.2.2.2  bouyer             break;
    521  1.1.1.2.2.2  bouyer 
    522  1.1.1.2.2.2  bouyer         case DT_SLASH_SLASH_COMMENT:
    523  1.1.1.2.2.2  bouyer 
    524  1.1.1.2.2.2  bouyer             /* Ignore chars until end-of-line */
    525  1.1.1.2.2.2  bouyer 
    526  1.1.1.2.2.2  bouyer             if (c == '\n')
    527  1.1.1.2.2.2  bouyer             {
    528  1.1.1.2.2.2  bouyer                 /* We will exit via the NORMAL_TEXT path */
    529  1.1.1.2.2.2  bouyer 
    530  1.1.1.2.2.2  bouyer                 ungetc (c, Handle);
    531  1.1.1.2.2.2  bouyer                 State = DT_NORMAL_TEXT;
    532  1.1.1.2.2.2  bouyer             }
    533  1.1.1.2.2.2  bouyer             break;
    534  1.1.1.2.2.2  bouyer 
    535  1.1.1.2.2.2  bouyer         case DT_END_COMMENT:
    536  1.1.1.2.2.2  bouyer 
    537  1.1.1.2.2.2  bouyer             /* End comment if this char is a slash */
    538  1.1.1.2.2.2  bouyer 
    539  1.1.1.2.2.2  bouyer             switch (c)
    540  1.1.1.2.2.2  bouyer             {
    541  1.1.1.2.2.2  bouyer             case '/':
    542  1.1.1.2.2.2  bouyer                 State = DT_NORMAL_TEXT;
    543  1.1.1.2.2.2  bouyer                 break;
    544  1.1.1.2.2.2  bouyer 
    545  1.1.1.2.2.2  bouyer             case '\n':
    546  1.1.1.2.2.2  bouyer                 CurrentLineOffset = Gbl_NextLineOffset;
    547  1.1.1.2.2.2  bouyer                 Gbl_NextLineOffset = (UINT32) ftell (Handle);
    548  1.1.1.2.2.2  bouyer                 Gbl_CurrentLineNumber++;
    549  1.1.1.2.2.2  bouyer                 break;
    550  1.1.1.2.2.2  bouyer 
    551  1.1.1.2.2.2  bouyer             case '*':
    552  1.1.1.2.2.2  bouyer                 /* Consume all adjacent asterisks */
    553  1.1.1.2.2.2  bouyer                 break;
    554  1.1.1.2.2.2  bouyer 
    555  1.1.1.2.2.2  bouyer             default:
    556  1.1.1.2.2.2  bouyer                 State = DT_SLASH_ASTERISK_COMMENT;
    557  1.1.1.2.2.2  bouyer                 break;
    558  1.1.1.2.2.2  bouyer             }
    559  1.1.1.2.2.2  bouyer             break;
    560  1.1.1.2.2.2  bouyer 
    561  1.1.1.2.2.2  bouyer         default:
    562  1.1.1.2.2.2  bouyer             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state");
    563  1.1.1.2.2.2  bouyer             return (0);
    564  1.1.1.2.2.2  bouyer         }
    565  1.1.1.2.2.2  bouyer     }
    566  1.1.1.2.2.2  bouyer 
    567  1.1.1.2.2.2  bouyer     printf ("ERROR - Input line is too long (max %u)\n", ASL_LINE_BUFFER_SIZE);
    568  1.1.1.2.2.2  bouyer     return (0);
    569  1.1.1.2.2.2  bouyer }
    570  1.1.1.2.2.2  bouyer 
    571  1.1.1.2.2.2  bouyer 
    572  1.1.1.2.2.2  bouyer /******************************************************************************
    573  1.1.1.2.2.2  bouyer  *
    574  1.1.1.2.2.2  bouyer  * FUNCTION:    DtScanFile
    575  1.1.1.2.2.2  bouyer  *
    576  1.1.1.2.2.2  bouyer  * PARAMETERS:  Handle              - Open file handle for the source file
    577  1.1.1.2.2.2  bouyer  *
    578  1.1.1.2.2.2  bouyer  * RETURN:      Pointer to start of the constructed parse tree.
    579  1.1.1.2.2.2  bouyer  *
    580  1.1.1.2.2.2  bouyer  * DESCRIPTION: Scan source file, link all field names and values
    581  1.1.1.2.2.2  bouyer  *              to the global parse tree: Gbl_FieldList
    582  1.1.1.2.2.2  bouyer  *
    583  1.1.1.2.2.2  bouyer  *****************************************************************************/
    584  1.1.1.2.2.2  bouyer 
    585  1.1.1.2.2.2  bouyer DT_FIELD *
    586  1.1.1.2.2.2  bouyer DtScanFile (
    587  1.1.1.2.2.2  bouyer     FILE                    *Handle)
    588  1.1.1.2.2.2  bouyer {
    589  1.1.1.2.2.2  bouyer     ACPI_STATUS             Status;
    590  1.1.1.2.2.2  bouyer     UINT32                  Offset;
    591  1.1.1.2.2.2  bouyer 
    592  1.1.1.2.2.2  bouyer 
    593  1.1.1.2.2.2  bouyer     ACPI_FUNCTION_NAME (DtScanFile);
    594  1.1.1.2.2.2  bouyer 
    595  1.1.1.2.2.2  bouyer 
    596  1.1.1.2.2.2  bouyer     /* Get the file size */
    597  1.1.1.2.2.2  bouyer 
    598  1.1.1.2.2.2  bouyer     Gbl_InputByteCount = DtGetFileSize (Handle);
    599  1.1.1.2.2.2  bouyer 
    600  1.1.1.2.2.2  bouyer     Gbl_CurrentLineNumber = 0;
    601  1.1.1.2.2.2  bouyer     Gbl_CurrentLineOffset = 0;
    602  1.1.1.2.2.2  bouyer     Gbl_NextLineOffset = 0;
    603  1.1.1.2.2.2  bouyer 
    604  1.1.1.2.2.2  bouyer     /* Scan line-by-line */
    605  1.1.1.2.2.2  bouyer 
    606  1.1.1.2.2.2  bouyer     while ((Offset = DtGetNextLine (Handle)))
    607  1.1.1.2.2.2  bouyer     {
    608  1.1.1.2.2.2  bouyer         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
    609  1.1.1.2.2.2  bouyer             Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
    610  1.1.1.2.2.2  bouyer 
    611  1.1.1.2.2.2  bouyer         Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset);
    612  1.1.1.2.2.2  bouyer         if (Status == AE_NOT_FOUND)
    613  1.1.1.2.2.2  bouyer         {
    614  1.1.1.2.2.2  bouyer             break;
    615  1.1.1.2.2.2  bouyer         }
    616  1.1.1.2.2.2  bouyer     }
    617  1.1.1.2.2.2  bouyer 
    618  1.1.1.2.2.2  bouyer     return (Gbl_FieldList);
    619  1.1.1.2.2.2  bouyer }
    620  1.1.1.2.2.2  bouyer 
    621  1.1.1.2.2.2  bouyer 
    622  1.1.1.2.2.2  bouyer /*
    623  1.1.1.2.2.2  bouyer  * Output functions
    624  1.1.1.2.2.2  bouyer  */
    625  1.1.1.2.2.2  bouyer 
    626  1.1.1.2.2.2  bouyer /******************************************************************************
    627  1.1.1.2.2.2  bouyer  *
    628  1.1.1.2.2.2  bouyer  * FUNCTION:    DtWriteBinary
    629  1.1.1.2.2.2  bouyer  *
    630  1.1.1.2.2.2  bouyer  * PARAMETERS:  DT_WALK_CALLBACK
    631  1.1.1.2.2.2  bouyer  *
    632  1.1.1.2.2.2  bouyer  * RETURN:      Status
    633  1.1.1.2.2.2  bouyer  *
    634  1.1.1.2.2.2  bouyer  * DESCRIPTION: Write one subtable of a binary ACPI table
    635  1.1.1.2.2.2  bouyer  *
    636  1.1.1.2.2.2  bouyer  *****************************************************************************/
    637  1.1.1.2.2.2  bouyer 
    638  1.1.1.2.2.2  bouyer static void
    639  1.1.1.2.2.2  bouyer DtWriteBinary (
    640  1.1.1.2.2.2  bouyer     DT_SUBTABLE             *Subtable,
    641  1.1.1.2.2.2  bouyer     void                    *Context,
    642  1.1.1.2.2.2  bouyer     void                    *ReturnValue)
    643  1.1.1.2.2.2  bouyer {
    644  1.1.1.2.2.2  bouyer 
    645  1.1.1.2.2.2  bouyer     FlWriteFile (ASL_FILE_AML_OUTPUT, Subtable->Buffer, Subtable->Length);
    646  1.1.1.2.2.2  bouyer }
    647  1.1.1.2.2.2  bouyer 
    648  1.1.1.2.2.2  bouyer 
    649  1.1.1.2.2.2  bouyer /******************************************************************************
    650  1.1.1.2.2.2  bouyer  *
    651  1.1.1.2.2.2  bouyer  * FUNCTION:    DtOutputBinary
    652  1.1.1.2.2.2  bouyer  *
    653  1.1.1.2.2.2  bouyer  * PARAMETERS:
    654  1.1.1.2.2.2  bouyer  *
    655  1.1.1.2.2.2  bouyer  * RETURN:      Status
    656  1.1.1.2.2.2  bouyer  *
    657  1.1.1.2.2.2  bouyer  * DESCRIPTION: Write entire binary ACPI table (result of compilation)
    658  1.1.1.2.2.2  bouyer  *
    659  1.1.1.2.2.2  bouyer  *****************************************************************************/
    660  1.1.1.2.2.2  bouyer 
    661  1.1.1.2.2.2  bouyer void
    662  1.1.1.2.2.2  bouyer DtOutputBinary (
    663  1.1.1.2.2.2  bouyer     DT_SUBTABLE             *RootTable)
    664  1.1.1.2.2.2  bouyer {
    665  1.1.1.2.2.2  bouyer 
    666  1.1.1.2.2.2  bouyer     if (!RootTable)
    667  1.1.1.2.2.2  bouyer     {
    668  1.1.1.2.2.2  bouyer         return;
    669  1.1.1.2.2.2  bouyer     }
    670  1.1.1.2.2.2  bouyer 
    671  1.1.1.2.2.2  bouyer     /* Walk the entire parse tree, emitting the binary data */
    672  1.1.1.2.2.2  bouyer 
    673  1.1.1.2.2.2  bouyer     DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL);
    674  1.1.1.2.2.2  bouyer     Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
    675  1.1.1.2.2.2  bouyer }
    676  1.1.1.2.2.2  bouyer 
    677  1.1.1.2.2.2  bouyer 
    678  1.1.1.2.2.2  bouyer /*
    679  1.1.1.2.2.2  bouyer  * Listing support
    680  1.1.1.2.2.2  bouyer  */
    681  1.1.1.2.2.2  bouyer 
    682  1.1.1.2.2.2  bouyer /******************************************************************************
    683  1.1.1.2.2.2  bouyer  *
    684  1.1.1.2.2.2  bouyer  * FUNCTION:    DtDumpBuffer
    685  1.1.1.2.2.2  bouyer  *
    686  1.1.1.2.2.2  bouyer  * PARAMETERS:  FileID              - Where to write buffer data
    687  1.1.1.2.2.2  bouyer  *              Buffer              - Buffer to dump
    688  1.1.1.2.2.2  bouyer  *              Offset              - Offset in current table
    689  1.1.1.2.2.2  bouyer  *              Length              - Buffer Length
    690  1.1.1.2.2.2  bouyer  *
    691  1.1.1.2.2.2  bouyer  * RETURN:      None
    692  1.1.1.2.2.2  bouyer  *
    693  1.1.1.2.2.2  bouyer  * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately).
    694  1.1.1.2.2.2  bouyer  *
    695  1.1.1.2.2.2  bouyer  * TBD: merge dump buffer routines
    696  1.1.1.2.2.2  bouyer  *
    697  1.1.1.2.2.2  bouyer  *****************************************************************************/
    698  1.1.1.2.2.2  bouyer 
    699  1.1.1.2.2.2  bouyer static void
    700  1.1.1.2.2.2  bouyer DtDumpBuffer (
    701  1.1.1.2.2.2  bouyer     UINT32                  FileId,
    702  1.1.1.2.2.2  bouyer     UINT8                   *Buffer,
    703  1.1.1.2.2.2  bouyer     UINT32                  Offset,
    704  1.1.1.2.2.2  bouyer     UINT32                  Length)
    705  1.1.1.2.2.2  bouyer {
    706  1.1.1.2.2.2  bouyer     UINT32                  i;
    707  1.1.1.2.2.2  bouyer     UINT32                  j;
    708  1.1.1.2.2.2  bouyer     UINT8                   BufChar;
    709  1.1.1.2.2.2  bouyer 
    710  1.1.1.2.2.2  bouyer 
    711  1.1.1.2.2.2  bouyer     FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ",
    712  1.1.1.2.2.2  bouyer         Offset, Offset, Length);
    713  1.1.1.2.2.2  bouyer 
    714  1.1.1.2.2.2  bouyer     i = 0;
    715  1.1.1.2.2.2  bouyer     while (i < Length)
    716  1.1.1.2.2.2  bouyer     {
    717  1.1.1.2.2.2  bouyer         if (i >= 16)
    718  1.1.1.2.2.2  bouyer         {
    719  1.1.1.2.2.2  bouyer             FlPrintFile (FileId, "%23s", "");
    720  1.1.1.2.2.2  bouyer         }
    721  1.1.1.2.2.2  bouyer 
    722  1.1.1.2.2.2  bouyer         /* Print 16 hex chars */
    723  1.1.1.2.2.2  bouyer 
    724  1.1.1.2.2.2  bouyer         for (j = 0; j < 16;)
    725  1.1.1.2.2.2  bouyer         {
    726  1.1.1.2.2.2  bouyer             if (i + j >= Length)
    727  1.1.1.2.2.2  bouyer             {
    728  1.1.1.2.2.2  bouyer                 /* Dump fill spaces */
    729  1.1.1.2.2.2  bouyer 
    730  1.1.1.2.2.2  bouyer                 FlPrintFile (FileId, "   ");
    731  1.1.1.2.2.2  bouyer                 j++;
    732  1.1.1.2.2.2  bouyer                 continue;
    733  1.1.1.2.2.2  bouyer             }
    734  1.1.1.2.2.2  bouyer 
    735  1.1.1.2.2.2  bouyer             FlPrintFile (FileId, "%02X ", Buffer[i+j]);
    736  1.1.1.2.2.2  bouyer             j++;
    737  1.1.1.2.2.2  bouyer         }
    738  1.1.1.2.2.2  bouyer 
    739  1.1.1.2.2.2  bouyer         FlPrintFile (FileId, " ");
    740  1.1.1.2.2.2  bouyer         for (j = 0; j < 16; j++)
    741  1.1.1.2.2.2  bouyer         {
    742  1.1.1.2.2.2  bouyer             if (i + j >= Length)
    743  1.1.1.2.2.2  bouyer             {
    744  1.1.1.2.2.2  bouyer                 FlPrintFile (FileId, "\n\n");
    745  1.1.1.2.2.2  bouyer                 return;
    746  1.1.1.2.2.2  bouyer             }
    747  1.1.1.2.2.2  bouyer 
    748  1.1.1.2.2.2  bouyer             BufChar = Buffer[(ACPI_SIZE) i + j];
    749  1.1.1.2.2.2  bouyer             if (ACPI_IS_PRINT (BufChar))
    750  1.1.1.2.2.2  bouyer             {
    751  1.1.1.2.2.2  bouyer                 FlPrintFile (FileId, "%c", BufChar);
    752  1.1.1.2.2.2  bouyer             }
    753  1.1.1.2.2.2  bouyer             else
    754  1.1.1.2.2.2  bouyer             {
    755  1.1.1.2.2.2  bouyer                 FlPrintFile (FileId, ".");
    756  1.1.1.2.2.2  bouyer             }
    757  1.1.1.2.2.2  bouyer         }
    758  1.1.1.2.2.2  bouyer 
    759  1.1.1.2.2.2  bouyer         /* Done with that line. */
    760  1.1.1.2.2.2  bouyer 
    761  1.1.1.2.2.2  bouyer         FlPrintFile (FileId, "\n");
    762  1.1.1.2.2.2  bouyer         i += 16;
    763  1.1.1.2.2.2  bouyer     }
    764  1.1.1.2.2.2  bouyer 
    765  1.1.1.2.2.2  bouyer     FlPrintFile (FileId, "\n\n");
    766  1.1.1.2.2.2  bouyer }
    767  1.1.1.2.2.2  bouyer 
    768  1.1.1.2.2.2  bouyer 
    769  1.1.1.2.2.2  bouyer /******************************************************************************
    770  1.1.1.2.2.2  bouyer  *
    771  1.1.1.2.2.2  bouyer  * FUNCTION:    DtWriteFieldToListing
    772  1.1.1.2.2.2  bouyer  *
    773  1.1.1.2.2.2  bouyer  * PARAMETERS:  Buffer              - Contains the compiled data
    774  1.1.1.2.2.2  bouyer  *              Field               - Field node for the input line
    775  1.1.1.2.2.2  bouyer  *              Length              - Length of the output data
    776  1.1.1.2.2.2  bouyer  *
    777  1.1.1.2.2.2  bouyer  * RETURN:      None
    778  1.1.1.2.2.2  bouyer  *
    779  1.1.1.2.2.2  bouyer  * DESCRIPTION: Write one field to the listing file (if listing is enabled).
    780  1.1.1.2.2.2  bouyer  *
    781  1.1.1.2.2.2  bouyer  *****************************************************************************/
    782  1.1.1.2.2.2  bouyer 
    783  1.1.1.2.2.2  bouyer void
    784  1.1.1.2.2.2  bouyer DtWriteFieldToListing (
    785  1.1.1.2.2.2  bouyer     UINT8                   *Buffer,
    786  1.1.1.2.2.2  bouyer     DT_FIELD                *Field,
    787  1.1.1.2.2.2  bouyer     UINT32                  Length)
    788  1.1.1.2.2.2  bouyer {
    789  1.1.1.2.2.2  bouyer     UINT8                   FileByte;
    790  1.1.1.2.2.2  bouyer 
    791  1.1.1.2.2.2  bouyer 
    792  1.1.1.2.2.2  bouyer     if (!Gbl_ListingFlag || !Field)
    793  1.1.1.2.2.2  bouyer     {
    794  1.1.1.2.2.2  bouyer         return;
    795  1.1.1.2.2.2  bouyer     }
    796  1.1.1.2.2.2  bouyer 
    797  1.1.1.2.2.2  bouyer     /* Dump the original source line */
    798  1.1.1.2.2.2  bouyer 
    799  1.1.1.2.2.2  bouyer     FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input:  ");
    800  1.1.1.2.2.2  bouyer     FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset);
    801  1.1.1.2.2.2  bouyer 
    802  1.1.1.2.2.2  bouyer     while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK)
    803  1.1.1.2.2.2  bouyer     {
    804  1.1.1.2.2.2  bouyer         FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1);
    805  1.1.1.2.2.2  bouyer         if (FileByte == '\n')
    806  1.1.1.2.2.2  bouyer         {
    807  1.1.1.2.2.2  bouyer             break;
    808  1.1.1.2.2.2  bouyer         }
    809  1.1.1.2.2.2  bouyer     }
    810  1.1.1.2.2.2  bouyer 
    811  1.1.1.2.2.2  bouyer     /* Dump the line as parsed and represented internally */
    812  1.1.1.2.2.2  bouyer 
    813  1.1.1.2.2.2  bouyer     FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n",
    814  1.1.1.2.2.2  bouyer         Field->Column-4, Field->Name, Field->Value);
    815  1.1.1.2.2.2  bouyer 
    816  1.1.1.2.2.2  bouyer     /* Dump the hex data that will be output for this field */
    817  1.1.1.2.2.2  bouyer 
    818  1.1.1.2.2.2  bouyer     DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
    819  1.1.1.2.2.2  bouyer }
    820  1.1.1.2.2.2  bouyer 
    821  1.1.1.2.2.2  bouyer 
    822  1.1.1.2.2.2  bouyer /******************************************************************************
    823  1.1.1.2.2.2  bouyer  *
    824  1.1.1.2.2.2  bouyer  * FUNCTION:    DtWriteTableToListing
    825  1.1.1.2.2.2  bouyer  *
    826  1.1.1.2.2.2  bouyer  * PARAMETERS:  None
    827  1.1.1.2.2.2  bouyer  *
    828  1.1.1.2.2.2  bouyer  * RETURN:      None
    829  1.1.1.2.2.2  bouyer  *
    830  1.1.1.2.2.2  bouyer  * DESCRIPTION: Write the entire compiled table to the listing file
    831  1.1.1.2.2.2  bouyer  *              in hex format
    832  1.1.1.2.2.2  bouyer  *
    833  1.1.1.2.2.2  bouyer  *****************************************************************************/
    834  1.1.1.2.2.2  bouyer 
    835  1.1.1.2.2.2  bouyer void
    836  1.1.1.2.2.2  bouyer DtWriteTableToListing (
    837  1.1.1.2.2.2  bouyer     void)
    838  1.1.1.2.2.2  bouyer {
    839  1.1.1.2.2.2  bouyer     UINT8                   *Buffer;
    840  1.1.1.2.2.2  bouyer 
    841  1.1.1.2.2.2  bouyer 
    842  1.1.1.2.2.2  bouyer     if (!Gbl_ListingFlag)
    843  1.1.1.2.2.2  bouyer     {
    844  1.1.1.2.2.2  bouyer         return;
    845  1.1.1.2.2.2  bouyer     }
    846  1.1.1.2.2.2  bouyer 
    847  1.1.1.2.2.2  bouyer     /* Read the entire table from the output file */
    848  1.1.1.2.2.2  bouyer 
    849  1.1.1.2.2.2  bouyer     Buffer = UtLocalCalloc (Gbl_TableLength);
    850  1.1.1.2.2.2  bouyer     FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
    851  1.1.1.2.2.2  bouyer     FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength);
    852  1.1.1.2.2.2  bouyer 
    853  1.1.1.2.2.2  bouyer     /* Dump the raw table data */
    854  1.1.1.2.2.2  bouyer 
    855  1.1.1.2.2.2  bouyer     AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle);
    856  1.1.1.2.2.2  bouyer 
    857  1.1.1.2.2.2  bouyer     AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
    858  1.1.1.2.2.2  bouyer         ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength);
    859  1.1.1.2.2.2  bouyer     AcpiUtDumpBuffer2 (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY);
    860  1.1.1.2.2.2  bouyer 
    861  1.1.1.2.2.2  bouyer     AcpiOsRedirectOutput (stdout);
    862  1.1.1.2.2.2  bouyer }
    863