Home | History | Annotate | Line # | Download | only in compiler
      1   1.1    jruoho /******************************************************************************
      2   1.1    jruoho  *
      3   1.1    jruoho  * Module Name: dtutils.c - Utility routines for the data table compiler
      4   1.1    jruoho  *
      5   1.1    jruoho  *****************************************************************************/
      6   1.1    jruoho 
      7  1.24  christos /******************************************************************************
      8  1.24  christos  *
      9  1.24  christos  * 1. Copyright Notice
     10  1.24  christos  *
     11  1.25  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12   1.1    jruoho  * All rights reserved.
     13   1.1    jruoho  *
     14  1.24  christos  * 2. License
     15  1.24  christos  *
     16  1.24  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.24  christos  * rights. You may have additional license terms from the party that provided
     18  1.24  christos  * you this software, covering your right to use that party's intellectual
     19  1.24  christos  * property rights.
     20  1.24  christos  *
     21  1.24  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.24  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.24  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.24  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.24  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.24  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.24  christos  *
     28  1.24  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.24  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.24  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.24  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.24  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.24  christos  * license, and in no event shall the patent license extend to any additions
     34  1.24  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.24  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.24  christos  *
     37  1.24  christos  * The above copyright and patent license is granted only if the following
     38  1.24  christos  * conditions are met:
     39  1.24  christos  *
     40  1.24  christos  * 3. Conditions
     41  1.24  christos  *
     42  1.24  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.24  christos  * Code or modification with rights to further distribute source must include
     45  1.24  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.24  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.24  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.24  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.24  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.24  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.24  christos  * must include a prominent statement that the modification is derived,
     52  1.24  christos  * directly or indirectly, from Original Intel Code.
     53  1.24  christos  *
     54  1.24  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.24  christos  * Code or modification without rights to further distribute source must
     57  1.24  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.24  christos  * documentation and/or other materials provided with distribution. In
     59  1.24  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.24  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.24  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.24  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.24  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.24  christos  * make.
     65  1.24  christos  *
     66  1.24  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.24  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.24  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.24  christos  * provision in the documentation and/or other materials provided with the
     70  1.24  christos  * distribution.
     71  1.24  christos  *
     72  1.24  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.24  christos  * Intel Code.
     74  1.24  christos  *
     75  1.24  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.24  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.24  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.24  christos  * without prior written authorization from Intel.
     79  1.24  christos  *
     80  1.24  christos  * 4. Disclaimer and Export Compliance
     81  1.24  christos  *
     82  1.24  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.24  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.24  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.24  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.24  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.24  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.24  christos  * PARTICULAR PURPOSE.
     89  1.24  christos  *
     90  1.24  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.24  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.24  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.24  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.24  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.24  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.24  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.24  christos  * LIMITED REMEDY.
     98  1.24  christos  *
     99  1.24  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.24  christos  * software or system incorporating such software without first obtaining any
    101  1.24  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.24  christos  * any other agency or department of the United States Government. In the
    103  1.24  christos  * event Licensee exports any such software from the United States or
    104  1.24  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.24  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.24  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.24  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.24  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.24  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.24  christos  * United States government or any agency thereof requires an export license,
    111  1.24  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.24  christos  * such license, approval or letter.
    113  1.24  christos  *
    114  1.24  christos  *****************************************************************************
    115  1.24  christos  *
    116  1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.24  christos  * following license:
    118  1.24  christos  *
    119   1.2  christos  * Redistribution and use in source and binary forms, with or without
    120   1.2  christos  * modification, are permitted provided that the following conditions
    121   1.2  christos  * are met:
    122   1.2  christos  * 1. Redistributions of source code must retain the above copyright
    123   1.2  christos  *    notice, this list of conditions, and the following disclaimer,
    124   1.2  christos  *    without modification.
    125   1.2  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.2  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.2  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.2  christos  *    including a substantially similar Disclaimer requirement for further
    129   1.2  christos  *    binary redistribution.
    130   1.2  christos  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.2  christos  *    of any contributors may be used to endorse or promote products derived
    132   1.2  christos  *    from this software without specific prior written permission.
    133   1.2  christos  *
    134   1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.2  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.16  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.2  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.24  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.24  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.24  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.24  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.24  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.24  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.24  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.24  christos  *
    146  1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.24  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.24  christos  * Software Foundation.
    149  1.24  christos  *
    150  1.24  christos  *****************************************************************************/
    151   1.1    jruoho 
    152   1.1    jruoho #include "aslcompiler.h"
    153   1.1    jruoho #include "actables.h"
    154   1.1    jruoho 
    155   1.1    jruoho #define _COMPONENT          DT_COMPILER
    156   1.1    jruoho         ACPI_MODULE_NAME    ("dtutils")
    157   1.1    jruoho 
    158   1.1    jruoho /* Local prototypes */
    159   1.1    jruoho 
    160   1.1    jruoho static void
    161   1.1    jruoho DtSum (
    162   1.1    jruoho     DT_SUBTABLE             *Subtable,
    163   1.1    jruoho     void                    *Context,
    164   1.1    jruoho     void                    *ReturnValue);
    165   1.1    jruoho 
    166   1.1    jruoho 
    167   1.1    jruoho /******************************************************************************
    168   1.1    jruoho  *
    169   1.1    jruoho  * FUNCTION:    DtError
    170   1.1    jruoho  *
    171   1.1    jruoho  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
    172   1.1    jruoho  *              MessageId           - Index into global message buffer
    173   1.1    jruoho  *              Op                  - Parse node where error happened
    174   1.1    jruoho  *              ExtraMessage        - additional error message
    175   1.1    jruoho  *
    176   1.1    jruoho  * RETURN:      None
    177   1.1    jruoho  *
    178   1.1    jruoho  * DESCRIPTION: Common error interface for data table compiler
    179   1.1    jruoho  *
    180   1.1    jruoho  *****************************************************************************/
    181   1.1    jruoho 
    182   1.1    jruoho void
    183   1.1    jruoho DtError (
    184   1.1    jruoho     UINT8                   Level,
    185   1.3  christos     UINT16                  MessageId,
    186   1.1    jruoho     DT_FIELD                *FieldObject,
    187   1.1    jruoho     char                    *ExtraMessage)
    188   1.1    jruoho {
    189  1.15  christos     UINT32                  Line = 0;
    190  1.15  christos 
    191  1.15  christos 
    192  1.15  christos     /* Field object could be NULL */
    193  1.15  christos 
    194  1.15  christos     if (FieldObject)
    195  1.15  christos     {
    196  1.15  christos         Line = FieldObject->Line;
    197  1.15  christos     }
    198   1.1    jruoho 
    199   1.2  christos     /* Check if user wants to ignore this exception */
    200   1.2  christos 
    201  1.14  christos     if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename,
    202  1.15  christos         Line, Level, MessageId))
    203   1.1    jruoho     {
    204   1.2  christos         return;
    205   1.1    jruoho     }
    206   1.1    jruoho 
    207   1.1    jruoho     if (FieldObject)
    208   1.1    jruoho     {
    209   1.1    jruoho         AslCommonError (Level, MessageId,
    210   1.1    jruoho             FieldObject->Line,
    211   1.1    jruoho             FieldObject->Line,
    212   1.1    jruoho             FieldObject->ByteOffset,
    213   1.1    jruoho             FieldObject->Column,
    214  1.12  christos             AslGbl_Files[ASL_FILE_INPUT].Filename, ExtraMessage);
    215   1.1    jruoho     }
    216   1.1    jruoho     else
    217   1.1    jruoho     {
    218   1.1    jruoho         AslCommonError (Level, MessageId, 0,
    219   1.1    jruoho             0, 0, 0, 0, ExtraMessage);
    220   1.1    jruoho     }
    221   1.1    jruoho }
    222   1.1    jruoho 
    223   1.1    jruoho 
    224   1.1    jruoho /******************************************************************************
    225   1.1    jruoho  *
    226   1.1    jruoho  * FUNCTION:    DtNameError
    227   1.1    jruoho  *
    228   1.1    jruoho  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
    229   1.1    jruoho  *              MessageId           - Index into global message buffer
    230   1.1    jruoho  *              Op                  - Parse node where error happened
    231   1.1    jruoho  *              ExtraMessage        - additional error message
    232   1.1    jruoho  *
    233   1.1    jruoho  * RETURN:      None
    234   1.1    jruoho  *
    235   1.1    jruoho  * DESCRIPTION: Error interface for named objects
    236   1.1    jruoho  *
    237   1.1    jruoho  *****************************************************************************/
    238   1.1    jruoho 
    239   1.1    jruoho void
    240   1.1    jruoho DtNameError (
    241   1.1    jruoho     UINT8                   Level,
    242   1.3  christos     UINT16                  MessageId,
    243   1.1    jruoho     DT_FIELD                *FieldObject,
    244   1.1    jruoho     char                    *ExtraMessage)
    245   1.1    jruoho {
    246   1.1    jruoho 
    247   1.1    jruoho     switch (Level)
    248   1.1    jruoho     {
    249   1.1    jruoho     case ASL_WARNING2:
    250   1.1    jruoho     case ASL_WARNING3:
    251   1.2  christos 
    252  1.12  christos         if (AslGbl_WarningLevel < Level)
    253   1.1    jruoho         {
    254   1.1    jruoho             return;
    255   1.1    jruoho         }
    256   1.1    jruoho         break;
    257   1.1    jruoho 
    258   1.1    jruoho     default:
    259   1.2  christos 
    260   1.1    jruoho         break;
    261   1.1    jruoho     }
    262   1.1    jruoho 
    263   1.1    jruoho     if (FieldObject)
    264   1.1    jruoho     {
    265   1.1    jruoho         AslCommonError (Level, MessageId,
    266   1.1    jruoho             FieldObject->Line,
    267   1.1    jruoho             FieldObject->Line,
    268   1.1    jruoho             FieldObject->ByteOffset,
    269   1.1    jruoho             FieldObject->NameColumn,
    270  1.12  christos             AslGbl_Files[ASL_FILE_INPUT].Filename, ExtraMessage);
    271   1.1    jruoho     }
    272   1.1    jruoho     else
    273   1.1    jruoho     {
    274   1.1    jruoho         AslCommonError (Level, MessageId, 0,
    275   1.1    jruoho             0, 0, 0, 0, ExtraMessage);
    276   1.1    jruoho     }
    277   1.1    jruoho }
    278   1.1    jruoho 
    279   1.1    jruoho 
    280   1.1    jruoho /*******************************************************************************
    281   1.1    jruoho  *
    282   1.1    jruoho  * FUNCTION:    DtFatal
    283   1.1    jruoho  *
    284   1.1    jruoho  * PARAMETERS:  None
    285   1.1    jruoho  *
    286   1.1    jruoho  * RETURN:      None
    287   1.1    jruoho  *
    288   1.1    jruoho  * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
    289   1.1    jruoho  *              compile or I/O errors
    290   1.1    jruoho  *
    291   1.1    jruoho  ******************************************************************************/
    292   1.1    jruoho 
    293   1.1    jruoho void
    294   1.1    jruoho DtFatal (
    295   1.3  christos     UINT16                  MessageId,
    296   1.1    jruoho     DT_FIELD                *FieldObject,
    297   1.1    jruoho     char                    *ExtraMessage)
    298   1.1    jruoho {
    299   1.1    jruoho 
    300   1.1    jruoho     DtError (ASL_ERROR, MessageId, FieldObject, ExtraMessage);
    301   1.1    jruoho 
    302   1.2  christos /*
    303   1.2  christos  * TBD: remove this entire function, DtFatal
    304   1.2  christos  *
    305   1.2  christos  * We cannot abort the compiler on error, because we may be compiling a
    306   1.2  christos  * list of files. We must move on to the next file.
    307   1.2  christos  */
    308   1.2  christos #ifdef __OBSOLETE
    309   1.1    jruoho     CmCleanupAndExit ();
    310   1.1    jruoho     exit (1);
    311   1.2  christos #endif
    312   1.1    jruoho }
    313   1.1    jruoho 
    314   1.1    jruoho 
    315   1.9  christos /*******************************************************************************
    316   1.9  christos  *
    317   1.9  christos  * FUNCTION:    DtDoConstant
    318   1.9  christos  *
    319   1.9  christos  * PARAMETERS:  String              - Only hex constants are supported,
    320   1.9  christos  *                                    regardless of whether the 0x prefix
    321   1.9  christos  *                                    is used
    322   1.9  christos  *
    323   1.9  christos  * RETURN:      Converted Integer
    324   1.9  christos  *
    325   1.9  christos  * DESCRIPTION: Convert a string to an integer, with overflow/error checking.
    326   1.9  christos  *
    327   1.9  christos  ******************************************************************************/
    328   1.9  christos 
    329   1.9  christos UINT64
    330   1.9  christos DtDoConstant (
    331   1.9  christos     char                    *String)
    332   1.9  christos {
    333   1.9  christos     UINT64                  ConvertedInteger;
    334   1.9  christos 
    335   1.9  christos 
    336   1.9  christos     /*
    337   1.9  christos      * TBD: The ImplicitStrtoul64 function does not report overflow
    338   1.9  christos      * conditions. The input string is simply truncated. If it is
    339   1.9  christos      * desired to report overflow to the table compiler, this should
    340   1.9  christos      * somehow be added here. Note: integers that are prefixed with 0x
    341   1.9  christos      * or not are both hex integers.
    342   1.9  christos      */
    343   1.9  christos     ConvertedInteger = AcpiUtImplicitStrtoul64 (String);
    344   1.9  christos     return (ConvertedInteger);
    345   1.9  christos }
    346   1.9  christos 
    347   1.1    jruoho /******************************************************************************
    348   1.1    jruoho  *
    349   1.1    jruoho  * FUNCTION:    DtGetFieldValue
    350   1.1    jruoho  *
    351   1.1    jruoho  * PARAMETERS:  Field               - Current field list pointer
    352   1.1    jruoho  *
    353   1.1    jruoho  * RETURN:      Field value
    354   1.1    jruoho  *
    355   1.1    jruoho  * DESCRIPTION: Get field value
    356   1.1    jruoho  *
    357   1.1    jruoho  *****************************************************************************/
    358   1.1    jruoho 
    359   1.1    jruoho char *
    360   1.1    jruoho DtGetFieldValue (
    361   1.2  christos     DT_FIELD                *Field)
    362   1.1    jruoho {
    363   1.2  christos     if (!Field)
    364   1.1    jruoho     {
    365   1.2  christos         return (NULL);
    366   1.1    jruoho     }
    367   1.1    jruoho 
    368   1.2  christos     return (Field->Value);
    369   1.1    jruoho }
    370   1.1    jruoho 
    371   1.1    jruoho 
    372   1.1    jruoho /******************************************************************************
    373   1.1    jruoho  *
    374   1.1    jruoho  * FUNCTION:    DtGetFieldType
    375   1.1    jruoho  *
    376   1.1    jruoho  * PARAMETERS:  Info                - Data table info
    377   1.1    jruoho  *
    378   1.1    jruoho  * RETURN:      Field type
    379   1.1    jruoho  *
    380   1.1    jruoho  * DESCRIPTION: Get field type
    381   1.1    jruoho  *
    382   1.1    jruoho  *****************************************************************************/
    383   1.1    jruoho 
    384   1.1    jruoho UINT8
    385   1.1    jruoho DtGetFieldType (
    386   1.1    jruoho     ACPI_DMTABLE_INFO       *Info)
    387   1.1    jruoho {
    388   1.1    jruoho     UINT8                   Type;
    389   1.1    jruoho 
    390   1.1    jruoho 
    391   1.1    jruoho     /* DT_FLAG means that this is the start of a block of flag bits */
    392   1.1    jruoho     /* TBD - we can make these a separate opcode later */
    393   1.1    jruoho 
    394   1.1    jruoho     if (Info->Flags & DT_FLAG)
    395   1.1    jruoho     {
    396   1.1    jruoho         return (DT_FIELD_TYPE_FLAGS_INTEGER);
    397   1.1    jruoho     }
    398   1.1    jruoho 
    399   1.1    jruoho     /* Type is based upon the opcode for this field in the info table */
    400   1.1    jruoho 
    401   1.1    jruoho     switch (Info->Opcode)
    402   1.1    jruoho     {
    403   1.1    jruoho     case ACPI_DMT_FLAG0:
    404   1.1    jruoho     case ACPI_DMT_FLAG1:
    405   1.1    jruoho     case ACPI_DMT_FLAG2:
    406   1.1    jruoho     case ACPI_DMT_FLAG3:
    407   1.1    jruoho     case ACPI_DMT_FLAG4:
    408   1.1    jruoho     case ACPI_DMT_FLAG5:
    409   1.1    jruoho     case ACPI_DMT_FLAG6:
    410   1.1    jruoho     case ACPI_DMT_FLAG7:
    411   1.1    jruoho     case ACPI_DMT_FLAGS0:
    412   1.2  christos     case ACPI_DMT_FLAGS1:
    413   1.1    jruoho     case ACPI_DMT_FLAGS2:
    414  1.20  christos     case ACPI_DMT_FLAGS8_2:
    415   1.2  christos     case ACPI_DMT_FLAGS4:
    416   1.9  christos     case ACPI_DMT_FLAGS4_0:
    417   1.9  christos     case ACPI_DMT_FLAGS4_4:
    418   1.9  christos     case ACPI_DMT_FLAGS4_8:
    419   1.9  christos     case ACPI_DMT_FLAGS4_12:
    420   1.9  christos     case ACPI_DMT_FLAGS16_16:
    421   1.2  christos 
    422   1.1    jruoho         Type = DT_FIELD_TYPE_FLAG;
    423   1.1    jruoho         break;
    424   1.1    jruoho 
    425   1.1    jruoho     case ACPI_DMT_NAME4:
    426   1.1    jruoho     case ACPI_DMT_SIG:
    427   1.1    jruoho     case ACPI_DMT_NAME6:
    428   1.1    jruoho     case ACPI_DMT_NAME8:
    429   1.1    jruoho     case ACPI_DMT_STRING:
    430  1.17  christos     case ACPI_DMT_IVRS_UNTERMINATED_STRING:
    431   1.2  christos 
    432   1.1    jruoho         Type = DT_FIELD_TYPE_STRING;
    433   1.1    jruoho         break;
    434   1.1    jruoho 
    435   1.1    jruoho     case ACPI_DMT_BUFFER:
    436   1.4  christos     case ACPI_DMT_RAW_BUFFER:
    437   1.2  christos     case ACPI_DMT_BUF7:
    438   1.2  christos     case ACPI_DMT_BUF10:
    439  1.25  christos     case ACPI_DMT_BUF11:
    440   1.7  christos     case ACPI_DMT_BUF12:
    441   1.1    jruoho     case ACPI_DMT_BUF16:
    442  1.19  christos     case ACPI_DMT_BUF18:
    443  1.25  christos     case ACPI_DMT_BUF24:
    444  1.25  christos     case ACPI_DMT_BUF26:
    445  1.23  christos     case ACPI_DMT_BUF32:
    446  1.23  christos     case ACPI_DMT_BUF112:
    447   1.2  christos     case ACPI_DMT_BUF128:
    448   1.2  christos     case ACPI_DMT_PCI_PATH:
    449  1.16  christos     case ACPI_DMT_PMTT_VENDOR:
    450   1.2  christos 
    451   1.1    jruoho         Type = DT_FIELD_TYPE_BUFFER;
    452   1.1    jruoho         break;
    453   1.1    jruoho 
    454   1.1    jruoho     case ACPI_DMT_GAS:
    455   1.1    jruoho     case ACPI_DMT_HESTNTFY:
    456   1.5  christos     case ACPI_DMT_IORTMEM:
    457   1.2  christos 
    458   1.1    jruoho         Type = DT_FIELD_TYPE_INLINE_SUBTABLE;
    459   1.1    jruoho         break;
    460   1.1    jruoho 
    461   1.2  christos     case ACPI_DMT_UNICODE:
    462  1.18  christos     case ACPI_DMT_WPBT_UNICODE:
    463   1.2  christos 
    464   1.2  christos         Type = DT_FIELD_TYPE_UNICODE;
    465   1.2  christos         break;
    466   1.2  christos 
    467   1.2  christos     case ACPI_DMT_UUID:
    468   1.2  christos 
    469   1.2  christos         Type = DT_FIELD_TYPE_UUID;
    470   1.2  christos         break;
    471   1.2  christos 
    472   1.2  christos     case ACPI_DMT_DEVICE_PATH:
    473   1.2  christos 
    474   1.2  christos         Type = DT_FIELD_TYPE_DEVICE_PATH;
    475   1.2  christos         break;
    476   1.2  christos 
    477   1.2  christos     case ACPI_DMT_LABEL:
    478   1.2  christos 
    479   1.2  christos         Type = DT_FIELD_TYPE_LABEL;
    480   1.2  christos         break;
    481   1.2  christos 
    482   1.1    jruoho     default:
    483   1.2  christos 
    484   1.1    jruoho         Type = DT_FIELD_TYPE_INTEGER;
    485   1.1    jruoho         break;
    486   1.1    jruoho     }
    487   1.1    jruoho 
    488   1.1    jruoho     return (Type);
    489   1.1    jruoho }
    490   1.1    jruoho 
    491   1.1    jruoho 
    492   1.1    jruoho /******************************************************************************
    493   1.1    jruoho  *
    494   1.1    jruoho  * FUNCTION:    DtGetBufferLength
    495   1.1    jruoho  *
    496   1.1    jruoho  * PARAMETERS:  Buffer              - List of integers,
    497   1.1    jruoho  *                                    for example "10 3A 4F 2E"
    498   1.1    jruoho  *
    499   1.1    jruoho  * RETURN:      Count of integer
    500   1.1    jruoho  *
    501   1.1    jruoho  * DESCRIPTION: Get length of bytes needed to store the integers
    502   1.1    jruoho  *
    503   1.1    jruoho  *****************************************************************************/
    504   1.1    jruoho 
    505   1.1    jruoho UINT32
    506   1.1    jruoho DtGetBufferLength (
    507   1.1    jruoho     char                    *Buffer)
    508   1.1    jruoho {
    509   1.1    jruoho     UINT32                  ByteLength = 0;
    510   1.1    jruoho 
    511   1.1    jruoho 
    512   1.1    jruoho     while (*Buffer)
    513   1.1    jruoho     {
    514   1.1    jruoho         if (*Buffer == ' ')
    515   1.1    jruoho         {
    516   1.1    jruoho             ByteLength++;
    517   1.1    jruoho 
    518   1.1    jruoho             while (*Buffer == ' ')
    519   1.1    jruoho             {
    520   1.1    jruoho                 Buffer++;
    521   1.1    jruoho             }
    522   1.1    jruoho         }
    523   1.1    jruoho 
    524   1.1    jruoho         Buffer++;
    525   1.1    jruoho     }
    526   1.1    jruoho 
    527   1.1    jruoho     return (++ByteLength);
    528   1.1    jruoho }
    529   1.1    jruoho 
    530   1.1    jruoho 
    531   1.1    jruoho /******************************************************************************
    532   1.1    jruoho  *
    533   1.1    jruoho  * FUNCTION:    DtGetFieldLength
    534   1.1    jruoho  *
    535   1.2  christos  * PARAMETERS:  Field               - Current field
    536   1.1    jruoho  *              Info                - Data table info
    537   1.1    jruoho  *
    538   1.1    jruoho  * RETURN:      Field length
    539   1.1    jruoho  *
    540   1.1    jruoho  * DESCRIPTION: Get length of bytes needed to compile the field
    541   1.1    jruoho  *
    542   1.2  christos  * Note: This function must remain in sync with AcpiDmDumpTable.
    543   1.2  christos  *
    544   1.1    jruoho  *****************************************************************************/
    545   1.1    jruoho 
    546   1.1    jruoho UINT32
    547   1.1    jruoho DtGetFieldLength (
    548   1.1    jruoho     DT_FIELD                *Field,
    549   1.1    jruoho     ACPI_DMTABLE_INFO       *Info)
    550   1.1    jruoho {
    551   1.1    jruoho     UINT32                  ByteLength = 0;
    552   1.1    jruoho     char                    *Value;
    553   1.1    jruoho 
    554   1.1    jruoho 
    555   1.1    jruoho     /* Length is based upon the opcode for this field in the info table */
    556   1.1    jruoho 
    557   1.1    jruoho     switch (Info->Opcode)
    558   1.1    jruoho     {
    559   1.1    jruoho     case ACPI_DMT_FLAG0:
    560   1.1    jruoho     case ACPI_DMT_FLAG1:
    561   1.1    jruoho     case ACPI_DMT_FLAG2:
    562   1.1    jruoho     case ACPI_DMT_FLAG3:
    563   1.1    jruoho     case ACPI_DMT_FLAG4:
    564   1.1    jruoho     case ACPI_DMT_FLAG5:
    565   1.1    jruoho     case ACPI_DMT_FLAG6:
    566   1.1    jruoho     case ACPI_DMT_FLAG7:
    567   1.1    jruoho     case ACPI_DMT_FLAGS0:
    568   1.2  christos     case ACPI_DMT_FLAGS1:
    569   1.1    jruoho     case ACPI_DMT_FLAGS2:
    570  1.20  christos     case ACPI_DMT_FLAGS8_2:
    571   1.2  christos     case ACPI_DMT_FLAGS4:
    572   1.9  christos     case ACPI_DMT_FLAGS4_0:
    573   1.9  christos     case ACPI_DMT_FLAGS4_4:
    574   1.9  christos     case ACPI_DMT_FLAGS4_8:
    575   1.9  christos     case ACPI_DMT_FLAGS4_12:
    576   1.9  christos     case ACPI_DMT_FLAGS16_16:
    577   1.2  christos     case ACPI_DMT_LABEL:
    578   1.2  christos     case ACPI_DMT_EXTRA_TEXT:
    579   1.2  christos 
    580   1.1    jruoho         ByteLength = 0;
    581   1.1    jruoho         break;
    582   1.1    jruoho 
    583   1.1    jruoho     case ACPI_DMT_UINT8:
    584   1.1    jruoho     case ACPI_DMT_CHKSUM:
    585   1.1    jruoho     case ACPI_DMT_SPACEID:
    586   1.2  christos     case ACPI_DMT_ACCWIDTH:
    587  1.16  christos     case ACPI_DMT_CEDT:
    588   1.2  christos     case ACPI_DMT_IVRS:
    589  1.17  christos     case ACPI_DMT_IVRS_DE:
    590   1.3  christos     case ACPI_DMT_GTDT:
    591   1.1    jruoho     case ACPI_DMT_MADT:
    592  1.22  christos     case ACPI_DMT_MPAM_LOCATOR:
    593  1.24  christos     case ACPI_DMT_NHLT1:
    594  1.24  christos     case ACPI_DMT_NHLT1a:
    595  1.24  christos     case ACPI_DMT_NHLT1b:
    596  1.24  christos     case ACPI_DMT_NHLT1c:
    597  1.24  christos     case ACPI_DMT_NHLT1d:
    598  1.24  christos     case ACPI_DMT_NHLT1f:
    599   1.2  christos     case ACPI_DMT_PCCT:
    600   1.2  christos     case ACPI_DMT_PMTT:
    601   1.9  christos     case ACPI_DMT_PPTT:
    602  1.17  christos     case ACPI_DMT_RGRT:
    603  1.10  christos     case ACPI_DMT_SDEV:
    604   1.1    jruoho     case ACPI_DMT_SRAT:
    605  1.18  christos     case ACPI_DMT_AEST:
    606  1.18  christos     case ACPI_DMT_AEST_RES:
    607  1.18  christos     case ACPI_DMT_AEST_XFACE:
    608  1.18  christos     case ACPI_DMT_AEST_XRUPT:
    609   1.1    jruoho     case ACPI_DMT_ASF:
    610  1.21  christos     case ACPI_DMT_CDAT:
    611   1.1    jruoho     case ACPI_DMT_HESTNTYP:
    612   1.1    jruoho     case ACPI_DMT_FADTPM:
    613   1.2  christos     case ACPI_DMT_EINJACT:
    614   1.2  christos     case ACPI_DMT_EINJINST:
    615   1.2  christos     case ACPI_DMT_ERSTACT:
    616   1.2  christos     case ACPI_DMT_ERSTINST:
    617   1.3  christos     case ACPI_DMT_DMAR_SCOPE:
    618  1.16  christos     case ACPI_DMT_VIOT:
    619   1.2  christos 
    620   1.1    jruoho         ByteLength = 1;
    621   1.1    jruoho         break;
    622   1.1    jruoho 
    623  1.22  christos     case ACPI_DMT_ASPT:
    624   1.1    jruoho     case ACPI_DMT_UINT16:
    625   1.1    jruoho     case ACPI_DMT_DMAR:
    626  1.25  christos     case ACPI_DMT_ERDT:
    627   1.1    jruoho     case ACPI_DMT_HEST:
    628   1.9  christos     case ACPI_DMT_HMAT:
    629   1.5  christos     case ACPI_DMT_NFIT:
    630  1.24  christos     case ACPI_DMT_NHLT1e:
    631   1.1    jruoho     case ACPI_DMT_PCI_PATH:
    632  1.16  christos     case ACPI_DMT_PHAT:
    633  1.25  christos     case ACPI_DMT_RHCT:
    634   1.2  christos 
    635   1.1    jruoho         ByteLength = 2;
    636   1.1    jruoho         break;
    637   1.1    jruoho 
    638   1.1    jruoho     case ACPI_DMT_UINT24:
    639   1.2  christos 
    640   1.1    jruoho         ByteLength = 3;
    641   1.1    jruoho         break;
    642   1.1    jruoho 
    643   1.1    jruoho     case ACPI_DMT_UINT32:
    644  1.18  christos     case ACPI_DMT_AEST_CACHE:
    645  1.18  christos     case ACPI_DMT_AEST_GIC:
    646   1.1    jruoho     case ACPI_DMT_NAME4:
    647   1.1    jruoho     case ACPI_DMT_SIG:
    648   1.3  christos     case ACPI_DMT_LPIT:
    649  1.10  christos     case ACPI_DMT_TPM2:
    650   1.2  christos 
    651   1.1    jruoho         ByteLength = 4;
    652   1.1    jruoho         break;
    653   1.1    jruoho 
    654   1.2  christos     case ACPI_DMT_UINT40:
    655   1.2  christos 
    656   1.2  christos         ByteLength = 5;
    657   1.2  christos         break;
    658   1.2  christos 
    659   1.2  christos     case ACPI_DMT_UINT48:
    660   1.1    jruoho     case ACPI_DMT_NAME6:
    661   1.2  christos 
    662   1.1    jruoho         ByteLength = 6;
    663   1.1    jruoho         break;
    664   1.1    jruoho 
    665   1.1    jruoho     case ACPI_DMT_UINT56:
    666   1.2  christos     case ACPI_DMT_BUF7:
    667   1.2  christos 
    668   1.1    jruoho         ByteLength = 7;
    669   1.1    jruoho         break;
    670   1.1    jruoho 
    671   1.1    jruoho     case ACPI_DMT_UINT64:
    672   1.1    jruoho     case ACPI_DMT_NAME8:
    673   1.2  christos 
    674   1.1    jruoho         ByteLength = 8;
    675   1.1    jruoho         break;
    676   1.1    jruoho 
    677   1.1    jruoho     case ACPI_DMT_STRING:
    678   1.1    jruoho 
    679   1.2  christos         Value = DtGetFieldValue (Field);
    680   1.2  christos         if (Value)
    681   1.2  christos         {
    682   1.5  christos             ByteLength = strlen (Value) + 1;
    683   1.2  christos         }
    684   1.2  christos         else
    685   1.2  christos         {   /* At this point, this is a fatal error */
    686   1.1    jruoho 
    687  1.12  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    688  1.12  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    689   1.2  christos             return (0);
    690   1.2  christos         }
    691   1.1    jruoho         break;
    692   1.1    jruoho 
    693  1.17  christos     case ACPI_DMT_IVRS_UNTERMINATED_STRING:
    694  1.17  christos 
    695  1.17  christos         Value = DtGetFieldValue (Field);
    696  1.17  christos         if (Value)
    697  1.17  christos         {
    698  1.17  christos             ByteLength = strlen (Value);
    699  1.17  christos         }
    700  1.17  christos         else
    701  1.17  christos         {   /* At this point, this is a fatal error */
    702  1.17  christos 
    703  1.19  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    704  1.17  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    705  1.17  christos             return (0);
    706  1.17  christos         }
    707  1.17  christos         break;
    708  1.17  christos 
    709   1.1    jruoho     case ACPI_DMT_GAS:
    710   1.2  christos 
    711   1.1    jruoho         ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
    712   1.1    jruoho         break;
    713   1.1    jruoho 
    714   1.1    jruoho     case ACPI_DMT_HESTNTFY:
    715   1.2  christos 
    716   1.1    jruoho         ByteLength = sizeof (ACPI_HEST_NOTIFY);
    717   1.1    jruoho         break;
    718   1.1    jruoho 
    719   1.5  christos     case ACPI_DMT_IORTMEM:
    720   1.5  christos 
    721   1.5  christos         ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
    722   1.5  christos         break;
    723   1.5  christos 
    724   1.1    jruoho     case ACPI_DMT_BUFFER:
    725   1.4  christos     case ACPI_DMT_RAW_BUFFER:
    726  1.16  christos     case ACPI_DMT_PMTT_VENDOR:
    727   1.2  christos 
    728   1.2  christos         Value = DtGetFieldValue (Field);
    729   1.1    jruoho         if (Value)
    730   1.1    jruoho         {
    731   1.1    jruoho             ByteLength = DtGetBufferLength (Value);
    732   1.1    jruoho         }
    733   1.1    jruoho         else
    734   1.1    jruoho         {   /* At this point, this is a fatal error */
    735   1.1    jruoho 
    736  1.12  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    737  1.12  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    738   1.2  christos             return (0);
    739   1.1    jruoho         }
    740   1.1    jruoho         break;
    741   1.1    jruoho 
    742   1.2  christos     case ACPI_DMT_BUF10:
    743   1.2  christos 
    744   1.2  christos         ByteLength = 10;
    745   1.2  christos         break;
    746   1.2  christos 
    747  1.25  christos     case ACPI_DMT_BUF11:
    748  1.25  christos 
    749  1.25  christos         ByteLength = 11;
    750  1.25  christos         break;
    751  1.25  christos 
    752   1.7  christos     case ACPI_DMT_BUF12:
    753   1.7  christos 
    754   1.7  christos         ByteLength = 12;
    755   1.7  christos         break;
    756   1.7  christos 
    757   1.1    jruoho     case ACPI_DMT_BUF16:
    758   1.2  christos     case ACPI_DMT_UUID:
    759   1.2  christos 
    760   1.1    jruoho         ByteLength = 16;
    761   1.1    jruoho         break;
    762   1.1    jruoho 
    763  1.19  christos     case ACPI_DMT_BUF18:
    764  1.19  christos 
    765  1.19  christos         ByteLength = 18;
    766  1.19  christos         break;
    767  1.19  christos 
    768  1.25  christos     case ACPI_DMT_BUF24:
    769  1.25  christos 
    770  1.25  christos         ByteLength = 24;
    771  1.25  christos         break;
    772  1.25  christos 
    773  1.25  christos     case ACPI_DMT_BUF26:
    774  1.25  christos 
    775  1.25  christos         ByteLength = 26;
    776  1.25  christos         break;
    777  1.25  christos 
    778  1.23  christos     case ACPI_DMT_BUF32:
    779  1.23  christos 
    780  1.23  christos         ByteLength = 32;
    781  1.23  christos         break;
    782  1.23  christos 
    783  1.23  christos     case ACPI_DMT_BUF112:
    784  1.23  christos 
    785  1.23  christos         ByteLength = 112;
    786  1.23  christos         break;
    787  1.23  christos 
    788   1.2  christos     case ACPI_DMT_BUF128:
    789   1.2  christos 
    790   1.2  christos         ByteLength = 128;
    791   1.2  christos         break;
    792   1.2  christos 
    793   1.2  christos     case ACPI_DMT_UNICODE:
    794  1.18  christos     case ACPI_DMT_WPBT_UNICODE:
    795   1.2  christos 
    796   1.2  christos         Value = DtGetFieldValue (Field);
    797   1.2  christos 
    798   1.2  christos         /* TBD: error if Value is NULL? (as below?) */
    799   1.2  christos 
    800  1.18  christos         ByteLength = (strlen (Value) + 1) * sizeof (UINT16);
    801   1.2  christos         break;
    802   1.2  christos 
    803   1.1    jruoho     default:
    804   1.2  christos 
    805   1.1    jruoho         DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode");
    806   1.2  christos         return (0);
    807   1.1    jruoho     }
    808   1.1    jruoho 
    809   1.1    jruoho     return (ByteLength);
    810   1.1    jruoho }
    811   1.1    jruoho 
    812   1.1    jruoho 
    813   1.1    jruoho /******************************************************************************
    814   1.1    jruoho  *
    815   1.1    jruoho  * FUNCTION:    DtSum
    816   1.1    jruoho  *
    817   1.1    jruoho  * PARAMETERS:  DT_WALK_CALLBACK:
    818   1.1    jruoho  *              Subtable            - Subtable
    819   1.1    jruoho  *              Context             - Unused
    820   1.1    jruoho  *              ReturnValue         - Store the checksum of subtable
    821   1.1    jruoho  *
    822   1.1    jruoho  * RETURN:      Status
    823   1.1    jruoho  *
    824   1.1    jruoho  * DESCRIPTION: Get the checksum of subtable
    825   1.1    jruoho  *
    826   1.1    jruoho  *****************************************************************************/
    827   1.1    jruoho 
    828   1.1    jruoho static void
    829   1.1    jruoho DtSum (
    830   1.1    jruoho     DT_SUBTABLE             *Subtable,
    831   1.1    jruoho     void                    *Context,
    832   1.1    jruoho     void                    *ReturnValue)
    833   1.1    jruoho {
    834   1.1    jruoho     UINT8                   Checksum;
    835   1.1    jruoho     UINT8                   *Sum = ReturnValue;
    836   1.1    jruoho 
    837   1.1    jruoho 
    838  1.21  christos     Checksum = AcpiUtChecksum (Subtable->Buffer, Subtable->Length);
    839   1.1    jruoho     *Sum = (UINT8) (*Sum + Checksum);
    840   1.1    jruoho }
    841   1.1    jruoho 
    842   1.1    jruoho 
    843   1.1    jruoho /******************************************************************************
    844   1.1    jruoho  *
    845   1.1    jruoho  * FUNCTION:    DtSetTableChecksum
    846   1.1    jruoho  *
    847   1.1    jruoho  * PARAMETERS:  ChecksumPointer     - Where to return the checksum
    848   1.1    jruoho  *
    849   1.1    jruoho  * RETURN:      None
    850   1.1    jruoho  *
    851   1.1    jruoho  * DESCRIPTION: Set checksum of the whole data table into the checksum field
    852   1.1    jruoho  *
    853   1.1    jruoho  *****************************************************************************/
    854   1.1    jruoho 
    855   1.1    jruoho void
    856   1.1    jruoho DtSetTableChecksum (
    857   1.1    jruoho     UINT8                   *ChecksumPointer)
    858   1.1    jruoho {
    859   1.1    jruoho     UINT8                   Checksum = 0;
    860   1.1    jruoho     UINT8                   OldSum;
    861   1.1    jruoho 
    862   1.1    jruoho 
    863  1.12  christos     DtWalkTableTree (AslGbl_RootTable, DtSum, NULL, &Checksum);
    864   1.1    jruoho 
    865   1.1    jruoho     OldSum = *ChecksumPointer;
    866   1.1    jruoho     Checksum = (UINT8) (Checksum - OldSum);
    867   1.1    jruoho 
    868   1.1    jruoho     /* Compute the final checksum */
    869   1.1    jruoho 
    870   1.1    jruoho     Checksum = (UINT8) (0 - Checksum);
    871   1.1    jruoho     *ChecksumPointer = Checksum;
    872   1.1    jruoho }
    873   1.1    jruoho 
    874   1.1    jruoho 
    875   1.1    jruoho /******************************************************************************
    876   1.1    jruoho  *
    877   1.1    jruoho  * FUNCTION:    DtSetTableLength
    878   1.1    jruoho  *
    879   1.1    jruoho  * PARAMETERS:  None
    880   1.1    jruoho  *
    881   1.1    jruoho  * RETURN:      None
    882   1.1    jruoho  *
    883   1.1    jruoho  * DESCRIPTION: Walk the subtables and set all the length fields
    884   1.1    jruoho  *
    885   1.1    jruoho  *****************************************************************************/
    886   1.1    jruoho 
    887   1.1    jruoho void
    888   1.1    jruoho DtSetTableLength (
    889   1.1    jruoho     void)
    890   1.1    jruoho {
    891   1.1    jruoho     DT_SUBTABLE             *ParentTable;
    892   1.1    jruoho     DT_SUBTABLE             *ChildTable;
    893   1.1    jruoho 
    894   1.1    jruoho 
    895  1.12  christos     ParentTable = AslGbl_RootTable;
    896   1.1    jruoho     ChildTable = NULL;
    897   1.1    jruoho 
    898   1.1    jruoho     if (!ParentTable)
    899   1.1    jruoho     {
    900   1.1    jruoho         return;
    901   1.1    jruoho     }
    902   1.1    jruoho 
    903   1.1    jruoho     DtSetSubtableLength (ParentTable);
    904   1.1    jruoho 
    905   1.1    jruoho     while (1)
    906   1.1    jruoho     {
    907   1.1    jruoho         ChildTable = DtGetNextSubtable (ParentTable, ChildTable);
    908   1.1    jruoho         if (ChildTable)
    909   1.1    jruoho         {
    910   1.2  christos             if (ChildTable->LengthField)
    911   1.2  christos             {
    912   1.2  christos                 DtSetSubtableLength (ChildTable);
    913   1.2  christos             }
    914   1.2  christos 
    915   1.1    jruoho             if (ChildTable->Child)
    916   1.1    jruoho             {
    917   1.1    jruoho                 ParentTable = ChildTable;
    918   1.1    jruoho                 ChildTable = NULL;
    919   1.1    jruoho             }
    920   1.1    jruoho             else
    921   1.1    jruoho             {
    922   1.1    jruoho                 ParentTable->TotalLength += ChildTable->TotalLength;
    923   1.1    jruoho                 if (ParentTable->LengthField)
    924   1.1    jruoho                 {
    925   1.1    jruoho                     DtSetSubtableLength (ParentTable);
    926   1.1    jruoho                 }
    927   1.1    jruoho             }
    928   1.1    jruoho         }
    929   1.1    jruoho         else
    930   1.1    jruoho         {
    931   1.1    jruoho             ChildTable = ParentTable;
    932   1.1    jruoho 
    933  1.12  christos             if (ChildTable == AslGbl_RootTable)
    934   1.1    jruoho             {
    935   1.1    jruoho                 break;
    936   1.1    jruoho             }
    937   1.1    jruoho 
    938   1.1    jruoho             ParentTable = DtGetParentSubtable (ParentTable);
    939   1.1    jruoho 
    940   1.1    jruoho             ParentTable->TotalLength += ChildTable->TotalLength;
    941   1.1    jruoho             if (ParentTable->LengthField)
    942   1.1    jruoho             {
    943   1.1    jruoho                 DtSetSubtableLength (ParentTable);
    944   1.1    jruoho             }
    945   1.1    jruoho         }
    946   1.1    jruoho     }
    947   1.1    jruoho }
    948   1.1    jruoho 
    949   1.1    jruoho 
    950   1.1    jruoho /******************************************************************************
    951   1.1    jruoho  *
    952   1.1    jruoho  * FUNCTION:    DtWalkTableTree
    953   1.1    jruoho  *
    954   1.1    jruoho  * PARAMETERS:  StartTable          - Subtable in the tree where walking begins
    955   1.1    jruoho  *              UserFunction        - Called during the walk
    956   1.1    jruoho  *              Context             - Passed to user function
    957   1.1    jruoho  *              ReturnValue         - The return value of UserFunction
    958   1.1    jruoho  *
    959   1.1    jruoho  * RETURN:      None
    960   1.1    jruoho  *
    961   1.1    jruoho  * DESCRIPTION: Performs a depth-first walk of the subtable tree
    962   1.1    jruoho  *
    963   1.1    jruoho  *****************************************************************************/
    964   1.1    jruoho 
    965   1.1    jruoho void
    966   1.1    jruoho DtWalkTableTree (
    967   1.1    jruoho     DT_SUBTABLE             *StartTable,
    968   1.1    jruoho     DT_WALK_CALLBACK        UserFunction,
    969   1.1    jruoho     void                    *Context,
    970   1.1    jruoho     void                    *ReturnValue)
    971   1.1    jruoho {
    972   1.1    jruoho     DT_SUBTABLE             *ParentTable;
    973   1.1    jruoho     DT_SUBTABLE             *ChildTable;
    974   1.1    jruoho 
    975   1.1    jruoho 
    976   1.1    jruoho     ParentTable = StartTable;
    977   1.1    jruoho     ChildTable = NULL;
    978   1.1    jruoho 
    979   1.1    jruoho     if (!ParentTable)
    980   1.1    jruoho     {
    981   1.1    jruoho         return;
    982   1.1    jruoho     }
    983   1.1    jruoho 
    984   1.1    jruoho     UserFunction (ParentTable, Context, ReturnValue);
    985   1.1    jruoho 
    986   1.1    jruoho     while (1)
    987   1.1    jruoho     {
    988   1.1    jruoho         ChildTable = DtGetNextSubtable (ParentTable, ChildTable);
    989   1.1    jruoho         if (ChildTable)
    990   1.1    jruoho         {
    991   1.1    jruoho             UserFunction (ChildTable, Context, ReturnValue);
    992   1.1    jruoho 
    993   1.1    jruoho             if (ChildTable->Child)
    994   1.1    jruoho             {
    995   1.1    jruoho                 ParentTable = ChildTable;
    996   1.1    jruoho                 ChildTable = NULL;
    997   1.1    jruoho             }
    998   1.1    jruoho         }
    999   1.1    jruoho         else
   1000   1.1    jruoho         {
   1001   1.1    jruoho             ChildTable = ParentTable;
   1002  1.12  christos             if (ChildTable == AslGbl_RootTable)
   1003   1.1    jruoho             {
   1004   1.1    jruoho                 break;
   1005   1.1    jruoho             }
   1006   1.1    jruoho 
   1007   1.1    jruoho             ParentTable = DtGetParentSubtable (ParentTable);
   1008   1.1    jruoho 
   1009   1.1    jruoho             if (ChildTable->Peer == StartTable)
   1010   1.1    jruoho             {
   1011   1.1    jruoho                 break;
   1012   1.1    jruoho             }
   1013   1.1    jruoho         }
   1014   1.1    jruoho     }
   1015   1.1    jruoho }
   1016