Home | History | Annotate | Line # | Download | only in compiler
dtutils.c revision 1.22.6.1
      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.22.6.1  perseant /******************************************************************************
      8  1.22.6.1  perseant  *
      9  1.22.6.1  perseant  * 1. Copyright Notice
     10  1.22.6.1  perseant  *
     11  1.22.6.1  perseant  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
     12       1.1    jruoho  * All rights reserved.
     13       1.1    jruoho  *
     14  1.22.6.1  perseant  * 2. License
     15  1.22.6.1  perseant  *
     16  1.22.6.1  perseant  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.22.6.1  perseant  * rights. You may have additional license terms from the party that provided
     18  1.22.6.1  perseant  * you this software, covering your right to use that party's intellectual
     19  1.22.6.1  perseant  * property rights.
     20  1.22.6.1  perseant  *
     21  1.22.6.1  perseant  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.22.6.1  perseant  * copy of the source code appearing in this file ("Covered Code") an
     23  1.22.6.1  perseant  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.22.6.1  perseant  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.22.6.1  perseant  * make derivatives, distribute, use and display any portion of the Covered
     26  1.22.6.1  perseant  * Code in any form, with the right to sublicense such rights; and
     27  1.22.6.1  perseant  *
     28  1.22.6.1  perseant  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.22.6.1  perseant  * license (with the right to sublicense), under only those claims of Intel
     30  1.22.6.1  perseant  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.22.6.1  perseant  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.22.6.1  perseant  * solely to the minimum extent necessary to exercise the above copyright
     33  1.22.6.1  perseant  * license, and in no event shall the patent license extend to any additions
     34  1.22.6.1  perseant  * to or modifications of the Original Intel Code. No other license or right
     35  1.22.6.1  perseant  * is granted directly or by implication, estoppel or otherwise;
     36  1.22.6.1  perseant  *
     37  1.22.6.1  perseant  * The above copyright and patent license is granted only if the following
     38  1.22.6.1  perseant  * conditions are met:
     39  1.22.6.1  perseant  *
     40  1.22.6.1  perseant  * 3. Conditions
     41  1.22.6.1  perseant  *
     42  1.22.6.1  perseant  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.22.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     44  1.22.6.1  perseant  * Code or modification with rights to further distribute source must include
     45  1.22.6.1  perseant  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.22.6.1  perseant  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.22.6.1  perseant  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.22.6.1  perseant  * contain a file documenting the changes Licensee made to create that Covered
     49  1.22.6.1  perseant  * Code and the date of any change. Licensee must include in that file the
     50  1.22.6.1  perseant  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.22.6.1  perseant  * must include a prominent statement that the modification is derived,
     52  1.22.6.1  perseant  * directly or indirectly, from Original Intel Code.
     53  1.22.6.1  perseant  *
     54  1.22.6.1  perseant  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.22.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     56  1.22.6.1  perseant  * Code or modification without rights to further distribute source must
     57  1.22.6.1  perseant  * include the following Disclaimer and Export Compliance provision in the
     58  1.22.6.1  perseant  * documentation and/or other materials provided with distribution. In
     59  1.22.6.1  perseant  * addition, Licensee may not authorize further sublicense of source of any
     60  1.22.6.1  perseant  * portion of the Covered Code, and must include terms to the effect that the
     61  1.22.6.1  perseant  * license from Licensee to its licensee is limited to the intellectual
     62  1.22.6.1  perseant  * property embodied in the software Licensee provides to its licensee, and
     63  1.22.6.1  perseant  * not to intellectual property embodied in modifications its licensee may
     64  1.22.6.1  perseant  * make.
     65  1.22.6.1  perseant  *
     66  1.22.6.1  perseant  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.22.6.1  perseant  * substantial portion of the Covered Code or modification must reproduce the
     68  1.22.6.1  perseant  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.22.6.1  perseant  * provision in the documentation and/or other materials provided with the
     70  1.22.6.1  perseant  * distribution.
     71  1.22.6.1  perseant  *
     72  1.22.6.1  perseant  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.22.6.1  perseant  * Intel Code.
     74  1.22.6.1  perseant  *
     75  1.22.6.1  perseant  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.22.6.1  perseant  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.22.6.1  perseant  * other dealings in products derived from or relating to the Covered Code
     78  1.22.6.1  perseant  * without prior written authorization from Intel.
     79  1.22.6.1  perseant  *
     80  1.22.6.1  perseant  * 4. Disclaimer and Export Compliance
     81  1.22.6.1  perseant  *
     82  1.22.6.1  perseant  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.22.6.1  perseant  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.22.6.1  perseant  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.22.6.1  perseant  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.22.6.1  perseant  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.22.6.1  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.22.6.1  perseant  * PARTICULAR PURPOSE.
     89  1.22.6.1  perseant  *
     90  1.22.6.1  perseant  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.22.6.1  perseant  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.22.6.1  perseant  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.22.6.1  perseant  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.22.6.1  perseant  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.22.6.1  perseant  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.22.6.1  perseant  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.22.6.1  perseant  * LIMITED REMEDY.
     98  1.22.6.1  perseant  *
     99  1.22.6.1  perseant  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.22.6.1  perseant  * software or system incorporating such software without first obtaining any
    101  1.22.6.1  perseant  * required license or other approval from the U. S. Department of Commerce or
    102  1.22.6.1  perseant  * any other agency or department of the United States Government. In the
    103  1.22.6.1  perseant  * event Licensee exports any such software from the United States or
    104  1.22.6.1  perseant  * re-exports any such software from a foreign destination, Licensee shall
    105  1.22.6.1  perseant  * ensure that the distribution and export/re-export of the software is in
    106  1.22.6.1  perseant  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.22.6.1  perseant  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.22.6.1  perseant  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.22.6.1  perseant  * software, or service, directly or indirectly, to any country for which the
    110  1.22.6.1  perseant  * United States government or any agency thereof requires an export license,
    111  1.22.6.1  perseant  * other governmental approval, or letter of assurance, without first obtaining
    112  1.22.6.1  perseant  * such license, approval or letter.
    113  1.22.6.1  perseant  *
    114  1.22.6.1  perseant  *****************************************************************************
    115  1.22.6.1  perseant  *
    116  1.22.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    117  1.22.6.1  perseant  * following license:
    118  1.22.6.1  perseant  *
    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.22.6.1  perseant  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.22.6.1  perseant  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.22.6.1  perseant  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.22.6.1  perseant  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.22.6.1  perseant  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.22.6.1  perseant  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.22.6.1  perseant  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.22.6.1  perseant  *
    146  1.22.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    147  1.22.6.1  perseant  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.22.6.1  perseant  * Software Foundation.
    149  1.22.6.1  perseant  *
    150  1.22.6.1  perseant  *****************************************************************************/
    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.7  christos     case ACPI_DMT_BUF12:
    440       1.1    jruoho     case ACPI_DMT_BUF16:
    441      1.19  christos     case ACPI_DMT_BUF18:
    442  1.22.6.1  perseant     case ACPI_DMT_BUF32:
    443  1.22.6.1  perseant     case ACPI_DMT_BUF112:
    444       1.2  christos     case ACPI_DMT_BUF128:
    445       1.2  christos     case ACPI_DMT_PCI_PATH:
    446      1.16  christos     case ACPI_DMT_PMTT_VENDOR:
    447       1.2  christos 
    448       1.1    jruoho         Type = DT_FIELD_TYPE_BUFFER;
    449       1.1    jruoho         break;
    450       1.1    jruoho 
    451       1.1    jruoho     case ACPI_DMT_GAS:
    452       1.1    jruoho     case ACPI_DMT_HESTNTFY:
    453       1.5  christos     case ACPI_DMT_IORTMEM:
    454       1.2  christos 
    455       1.1    jruoho         Type = DT_FIELD_TYPE_INLINE_SUBTABLE;
    456       1.1    jruoho         break;
    457       1.1    jruoho 
    458       1.2  christos     case ACPI_DMT_UNICODE:
    459      1.18  christos     case ACPI_DMT_WPBT_UNICODE:
    460       1.2  christos 
    461       1.2  christos         Type = DT_FIELD_TYPE_UNICODE;
    462       1.2  christos         break;
    463       1.2  christos 
    464       1.2  christos     case ACPI_DMT_UUID:
    465       1.2  christos 
    466       1.2  christos         Type = DT_FIELD_TYPE_UUID;
    467       1.2  christos         break;
    468       1.2  christos 
    469       1.2  christos     case ACPI_DMT_DEVICE_PATH:
    470       1.2  christos 
    471       1.2  christos         Type = DT_FIELD_TYPE_DEVICE_PATH;
    472       1.2  christos         break;
    473       1.2  christos 
    474       1.2  christos     case ACPI_DMT_LABEL:
    475       1.2  christos 
    476       1.2  christos         Type = DT_FIELD_TYPE_LABEL;
    477       1.2  christos         break;
    478       1.2  christos 
    479       1.1    jruoho     default:
    480       1.2  christos 
    481       1.1    jruoho         Type = DT_FIELD_TYPE_INTEGER;
    482       1.1    jruoho         break;
    483       1.1    jruoho     }
    484       1.1    jruoho 
    485       1.1    jruoho     return (Type);
    486       1.1    jruoho }
    487       1.1    jruoho 
    488       1.1    jruoho 
    489       1.1    jruoho /******************************************************************************
    490       1.1    jruoho  *
    491       1.1    jruoho  * FUNCTION:    DtGetBufferLength
    492       1.1    jruoho  *
    493       1.1    jruoho  * PARAMETERS:  Buffer              - List of integers,
    494       1.1    jruoho  *                                    for example "10 3A 4F 2E"
    495       1.1    jruoho  *
    496       1.1    jruoho  * RETURN:      Count of integer
    497       1.1    jruoho  *
    498       1.1    jruoho  * DESCRIPTION: Get length of bytes needed to store the integers
    499       1.1    jruoho  *
    500       1.1    jruoho  *****************************************************************************/
    501       1.1    jruoho 
    502       1.1    jruoho UINT32
    503       1.1    jruoho DtGetBufferLength (
    504       1.1    jruoho     char                    *Buffer)
    505       1.1    jruoho {
    506       1.1    jruoho     UINT32                  ByteLength = 0;
    507       1.1    jruoho 
    508       1.1    jruoho 
    509       1.1    jruoho     while (*Buffer)
    510       1.1    jruoho     {
    511       1.1    jruoho         if (*Buffer == ' ')
    512       1.1    jruoho         {
    513       1.1    jruoho             ByteLength++;
    514       1.1    jruoho 
    515       1.1    jruoho             while (*Buffer == ' ')
    516       1.1    jruoho             {
    517       1.1    jruoho                 Buffer++;
    518       1.1    jruoho             }
    519       1.1    jruoho         }
    520       1.1    jruoho 
    521       1.1    jruoho         Buffer++;
    522       1.1    jruoho     }
    523       1.1    jruoho 
    524       1.1    jruoho     return (++ByteLength);
    525       1.1    jruoho }
    526       1.1    jruoho 
    527       1.1    jruoho 
    528       1.1    jruoho /******************************************************************************
    529       1.1    jruoho  *
    530       1.1    jruoho  * FUNCTION:    DtGetFieldLength
    531       1.1    jruoho  *
    532       1.2  christos  * PARAMETERS:  Field               - Current field
    533       1.1    jruoho  *              Info                - Data table info
    534       1.1    jruoho  *
    535       1.1    jruoho  * RETURN:      Field length
    536       1.1    jruoho  *
    537       1.1    jruoho  * DESCRIPTION: Get length of bytes needed to compile the field
    538       1.1    jruoho  *
    539       1.2  christos  * Note: This function must remain in sync with AcpiDmDumpTable.
    540       1.2  christos  *
    541       1.1    jruoho  *****************************************************************************/
    542       1.1    jruoho 
    543       1.1    jruoho UINT32
    544       1.1    jruoho DtGetFieldLength (
    545       1.1    jruoho     DT_FIELD                *Field,
    546       1.1    jruoho     ACPI_DMTABLE_INFO       *Info)
    547       1.1    jruoho {
    548       1.1    jruoho     UINT32                  ByteLength = 0;
    549       1.1    jruoho     char                    *Value;
    550       1.1    jruoho 
    551       1.1    jruoho 
    552       1.1    jruoho     /* Length is based upon the opcode for this field in the info table */
    553       1.1    jruoho 
    554       1.1    jruoho     switch (Info->Opcode)
    555       1.1    jruoho     {
    556       1.1    jruoho     case ACPI_DMT_FLAG0:
    557       1.1    jruoho     case ACPI_DMT_FLAG1:
    558       1.1    jruoho     case ACPI_DMT_FLAG2:
    559       1.1    jruoho     case ACPI_DMT_FLAG3:
    560       1.1    jruoho     case ACPI_DMT_FLAG4:
    561       1.1    jruoho     case ACPI_DMT_FLAG5:
    562       1.1    jruoho     case ACPI_DMT_FLAG6:
    563       1.1    jruoho     case ACPI_DMT_FLAG7:
    564       1.1    jruoho     case ACPI_DMT_FLAGS0:
    565       1.2  christos     case ACPI_DMT_FLAGS1:
    566       1.1    jruoho     case ACPI_DMT_FLAGS2:
    567      1.20  christos     case ACPI_DMT_FLAGS8_2:
    568       1.2  christos     case ACPI_DMT_FLAGS4:
    569       1.9  christos     case ACPI_DMT_FLAGS4_0:
    570       1.9  christos     case ACPI_DMT_FLAGS4_4:
    571       1.9  christos     case ACPI_DMT_FLAGS4_8:
    572       1.9  christos     case ACPI_DMT_FLAGS4_12:
    573       1.9  christos     case ACPI_DMT_FLAGS16_16:
    574       1.2  christos     case ACPI_DMT_LABEL:
    575       1.2  christos     case ACPI_DMT_EXTRA_TEXT:
    576       1.2  christos 
    577       1.1    jruoho         ByteLength = 0;
    578       1.1    jruoho         break;
    579       1.1    jruoho 
    580       1.1    jruoho     case ACPI_DMT_UINT8:
    581       1.1    jruoho     case ACPI_DMT_CHKSUM:
    582       1.1    jruoho     case ACPI_DMT_SPACEID:
    583       1.2  christos     case ACPI_DMT_ACCWIDTH:
    584      1.16  christos     case ACPI_DMT_CEDT:
    585       1.2  christos     case ACPI_DMT_IVRS:
    586      1.17  christos     case ACPI_DMT_IVRS_DE:
    587       1.3  christos     case ACPI_DMT_GTDT:
    588       1.1    jruoho     case ACPI_DMT_MADT:
    589      1.22  christos     case ACPI_DMT_MPAM_LOCATOR:
    590      1.18  christos     case ACPI_DMT_NHLT1:
    591      1.18  christos     case ACPI_DMT_NHLT1a:
    592      1.19  christos     case ACPI_DMT_NHLT1b:
    593      1.19  christos     case ACPI_DMT_NHLT1c:
    594      1.19  christos     case ACPI_DMT_NHLT1d:
    595      1.19  christos     case ACPI_DMT_NHLT1f:
    596       1.2  christos     case ACPI_DMT_PCCT:
    597       1.2  christos     case ACPI_DMT_PMTT:
    598       1.9  christos     case ACPI_DMT_PPTT:
    599      1.17  christos     case ACPI_DMT_RGRT:
    600      1.10  christos     case ACPI_DMT_SDEV:
    601       1.1    jruoho     case ACPI_DMT_SRAT:
    602      1.18  christos     case ACPI_DMT_AEST:
    603      1.18  christos     case ACPI_DMT_AEST_RES:
    604      1.18  christos     case ACPI_DMT_AEST_XFACE:
    605      1.18  christos     case ACPI_DMT_AEST_XRUPT:
    606       1.1    jruoho     case ACPI_DMT_ASF:
    607      1.21  christos     case ACPI_DMT_CDAT:
    608       1.1    jruoho     case ACPI_DMT_HESTNTYP:
    609       1.1    jruoho     case ACPI_DMT_FADTPM:
    610       1.2  christos     case ACPI_DMT_EINJACT:
    611       1.2  christos     case ACPI_DMT_EINJINST:
    612       1.2  christos     case ACPI_DMT_ERSTACT:
    613       1.2  christos     case ACPI_DMT_ERSTINST:
    614       1.3  christos     case ACPI_DMT_DMAR_SCOPE:
    615      1.16  christos     case ACPI_DMT_VIOT:
    616       1.2  christos 
    617       1.1    jruoho         ByteLength = 1;
    618       1.1    jruoho         break;
    619       1.1    jruoho 
    620      1.22  christos     case ACPI_DMT_ASPT:
    621       1.1    jruoho     case ACPI_DMT_UINT16:
    622       1.1    jruoho     case ACPI_DMT_DMAR:
    623       1.1    jruoho     case ACPI_DMT_HEST:
    624       1.9  christos     case ACPI_DMT_HMAT:
    625       1.5  christos     case ACPI_DMT_NFIT:
    626      1.19  christos     case ACPI_DMT_NHLT1e:
    627       1.1    jruoho     case ACPI_DMT_PCI_PATH:
    628      1.16  christos     case ACPI_DMT_PHAT:
    629       1.2  christos 
    630       1.1    jruoho         ByteLength = 2;
    631       1.1    jruoho         break;
    632       1.1    jruoho 
    633       1.1    jruoho     case ACPI_DMT_UINT24:
    634       1.2  christos 
    635       1.1    jruoho         ByteLength = 3;
    636       1.1    jruoho         break;
    637       1.1    jruoho 
    638       1.1    jruoho     case ACPI_DMT_UINT32:
    639      1.18  christos     case ACPI_DMT_AEST_CACHE:
    640      1.18  christos     case ACPI_DMT_AEST_GIC:
    641       1.1    jruoho     case ACPI_DMT_NAME4:
    642       1.1    jruoho     case ACPI_DMT_SIG:
    643       1.3  christos     case ACPI_DMT_LPIT:
    644      1.10  christos     case ACPI_DMT_TPM2:
    645       1.2  christos 
    646       1.1    jruoho         ByteLength = 4;
    647       1.1    jruoho         break;
    648       1.1    jruoho 
    649       1.2  christos     case ACPI_DMT_UINT40:
    650       1.2  christos 
    651       1.2  christos         ByteLength = 5;
    652       1.2  christos         break;
    653       1.2  christos 
    654       1.2  christos     case ACPI_DMT_UINT48:
    655       1.1    jruoho     case ACPI_DMT_NAME6:
    656       1.2  christos 
    657       1.1    jruoho         ByteLength = 6;
    658       1.1    jruoho         break;
    659       1.1    jruoho 
    660       1.1    jruoho     case ACPI_DMT_UINT56:
    661       1.2  christos     case ACPI_DMT_BUF7:
    662       1.2  christos 
    663       1.1    jruoho         ByteLength = 7;
    664       1.1    jruoho         break;
    665       1.1    jruoho 
    666       1.1    jruoho     case ACPI_DMT_UINT64:
    667       1.1    jruoho     case ACPI_DMT_NAME8:
    668       1.2  christos 
    669       1.1    jruoho         ByteLength = 8;
    670       1.1    jruoho         break;
    671       1.1    jruoho 
    672       1.1    jruoho     case ACPI_DMT_STRING:
    673       1.1    jruoho 
    674       1.2  christos         Value = DtGetFieldValue (Field);
    675       1.2  christos         if (Value)
    676       1.2  christos         {
    677       1.5  christos             ByteLength = strlen (Value) + 1;
    678       1.2  christos         }
    679       1.2  christos         else
    680       1.2  christos         {   /* At this point, this is a fatal error */
    681       1.1    jruoho 
    682      1.12  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    683      1.12  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    684       1.2  christos             return (0);
    685       1.2  christos         }
    686       1.1    jruoho         break;
    687       1.1    jruoho 
    688      1.17  christos     case ACPI_DMT_IVRS_UNTERMINATED_STRING:
    689      1.17  christos 
    690      1.17  christos         Value = DtGetFieldValue (Field);
    691      1.17  christos         if (Value)
    692      1.17  christos         {
    693      1.17  christos             ByteLength = strlen (Value);
    694      1.17  christos         }
    695      1.17  christos         else
    696      1.17  christos         {   /* At this point, this is a fatal error */
    697      1.17  christos 
    698      1.19  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    699      1.17  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    700      1.17  christos             return (0);
    701      1.17  christos         }
    702      1.17  christos         break;
    703      1.17  christos 
    704       1.1    jruoho     case ACPI_DMT_GAS:
    705       1.2  christos 
    706       1.1    jruoho         ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
    707       1.1    jruoho         break;
    708       1.1    jruoho 
    709       1.1    jruoho     case ACPI_DMT_HESTNTFY:
    710       1.2  christos 
    711       1.1    jruoho         ByteLength = sizeof (ACPI_HEST_NOTIFY);
    712       1.1    jruoho         break;
    713       1.1    jruoho 
    714       1.5  christos     case ACPI_DMT_IORTMEM:
    715       1.5  christos 
    716       1.5  christos         ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
    717       1.5  christos         break;
    718       1.5  christos 
    719       1.1    jruoho     case ACPI_DMT_BUFFER:
    720       1.4  christos     case ACPI_DMT_RAW_BUFFER:
    721      1.16  christos     case ACPI_DMT_PMTT_VENDOR:
    722       1.2  christos 
    723       1.2  christos         Value = DtGetFieldValue (Field);
    724       1.1    jruoho         if (Value)
    725       1.1    jruoho         {
    726       1.1    jruoho             ByteLength = DtGetBufferLength (Value);
    727       1.1    jruoho         }
    728       1.1    jruoho         else
    729       1.1    jruoho         {   /* At this point, this is a fatal error */
    730       1.1    jruoho 
    731      1.12  christos             snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "Expected \"%s\"", Info->Name);
    732      1.12  christos             DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
    733       1.2  christos             return (0);
    734       1.1    jruoho         }
    735       1.1    jruoho         break;
    736       1.1    jruoho 
    737       1.2  christos     case ACPI_DMT_BUF10:
    738       1.2  christos 
    739       1.2  christos         ByteLength = 10;
    740       1.2  christos         break;
    741       1.2  christos 
    742       1.7  christos     case ACPI_DMT_BUF12:
    743       1.7  christos 
    744       1.7  christos         ByteLength = 12;
    745       1.7  christos         break;
    746       1.7  christos 
    747       1.1    jruoho     case ACPI_DMT_BUF16:
    748       1.2  christos     case ACPI_DMT_UUID:
    749       1.2  christos 
    750       1.1    jruoho         ByteLength = 16;
    751       1.1    jruoho         break;
    752       1.1    jruoho 
    753      1.19  christos     case ACPI_DMT_BUF18:
    754      1.19  christos 
    755      1.19  christos         ByteLength = 18;
    756      1.19  christos         break;
    757      1.19  christos 
    758  1.22.6.1  perseant     case ACPI_DMT_BUF32:
    759  1.22.6.1  perseant 
    760  1.22.6.1  perseant         ByteLength = 32;
    761  1.22.6.1  perseant         break;
    762  1.22.6.1  perseant 
    763  1.22.6.1  perseant     case ACPI_DMT_BUF112:
    764  1.22.6.1  perseant 
    765  1.22.6.1  perseant         ByteLength = 112;
    766  1.22.6.1  perseant         break;
    767  1.22.6.1  perseant 
    768       1.2  christos     case ACPI_DMT_BUF128:
    769       1.2  christos 
    770       1.2  christos         ByteLength = 128;
    771       1.2  christos         break;
    772       1.2  christos 
    773       1.2  christos     case ACPI_DMT_UNICODE:
    774      1.18  christos     case ACPI_DMT_WPBT_UNICODE:
    775       1.2  christos 
    776       1.2  christos         Value = DtGetFieldValue (Field);
    777       1.2  christos 
    778       1.2  christos         /* TBD: error if Value is NULL? (as below?) */
    779       1.2  christos 
    780      1.18  christos         ByteLength = (strlen (Value) + 1) * sizeof (UINT16);
    781       1.2  christos         break;
    782       1.2  christos 
    783       1.1    jruoho     default:
    784       1.2  christos 
    785       1.1    jruoho         DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode");
    786       1.2  christos         return (0);
    787       1.1    jruoho     }
    788       1.1    jruoho 
    789       1.1    jruoho     return (ByteLength);
    790       1.1    jruoho }
    791       1.1    jruoho 
    792       1.1    jruoho 
    793       1.1    jruoho /******************************************************************************
    794       1.1    jruoho  *
    795       1.1    jruoho  * FUNCTION:    DtSum
    796       1.1    jruoho  *
    797       1.1    jruoho  * PARAMETERS:  DT_WALK_CALLBACK:
    798       1.1    jruoho  *              Subtable            - Subtable
    799       1.1    jruoho  *              Context             - Unused
    800       1.1    jruoho  *              ReturnValue         - Store the checksum of subtable
    801       1.1    jruoho  *
    802       1.1    jruoho  * RETURN:      Status
    803       1.1    jruoho  *
    804       1.1    jruoho  * DESCRIPTION: Get the checksum of subtable
    805       1.1    jruoho  *
    806       1.1    jruoho  *****************************************************************************/
    807       1.1    jruoho 
    808       1.1    jruoho static void
    809       1.1    jruoho DtSum (
    810       1.1    jruoho     DT_SUBTABLE             *Subtable,
    811       1.1    jruoho     void                    *Context,
    812       1.1    jruoho     void                    *ReturnValue)
    813       1.1    jruoho {
    814       1.1    jruoho     UINT8                   Checksum;
    815       1.1    jruoho     UINT8                   *Sum = ReturnValue;
    816       1.1    jruoho 
    817       1.1    jruoho 
    818      1.21  christos     Checksum = AcpiUtChecksum (Subtable->Buffer, Subtable->Length);
    819       1.1    jruoho     *Sum = (UINT8) (*Sum + Checksum);
    820       1.1    jruoho }
    821       1.1    jruoho 
    822       1.1    jruoho 
    823       1.1    jruoho /******************************************************************************
    824       1.1    jruoho  *
    825       1.1    jruoho  * FUNCTION:    DtSetTableChecksum
    826       1.1    jruoho  *
    827       1.1    jruoho  * PARAMETERS:  ChecksumPointer     - Where to return the checksum
    828       1.1    jruoho  *
    829       1.1    jruoho  * RETURN:      None
    830       1.1    jruoho  *
    831       1.1    jruoho  * DESCRIPTION: Set checksum of the whole data table into the checksum field
    832       1.1    jruoho  *
    833       1.1    jruoho  *****************************************************************************/
    834       1.1    jruoho 
    835       1.1    jruoho void
    836       1.1    jruoho DtSetTableChecksum (
    837       1.1    jruoho     UINT8                   *ChecksumPointer)
    838       1.1    jruoho {
    839       1.1    jruoho     UINT8                   Checksum = 0;
    840       1.1    jruoho     UINT8                   OldSum;
    841       1.1    jruoho 
    842       1.1    jruoho 
    843      1.12  christos     DtWalkTableTree (AslGbl_RootTable, DtSum, NULL, &Checksum);
    844       1.1    jruoho 
    845       1.1    jruoho     OldSum = *ChecksumPointer;
    846       1.1    jruoho     Checksum = (UINT8) (Checksum - OldSum);
    847       1.1    jruoho 
    848       1.1    jruoho     /* Compute the final checksum */
    849       1.1    jruoho 
    850       1.1    jruoho     Checksum = (UINT8) (0 - Checksum);
    851       1.1    jruoho     *ChecksumPointer = Checksum;
    852       1.1    jruoho }
    853       1.1    jruoho 
    854       1.1    jruoho 
    855       1.1    jruoho /******************************************************************************
    856       1.1    jruoho  *
    857       1.1    jruoho  * FUNCTION:    DtSetTableLength
    858       1.1    jruoho  *
    859       1.1    jruoho  * PARAMETERS:  None
    860       1.1    jruoho  *
    861       1.1    jruoho  * RETURN:      None
    862       1.1    jruoho  *
    863       1.1    jruoho  * DESCRIPTION: Walk the subtables and set all the length fields
    864       1.1    jruoho  *
    865       1.1    jruoho  *****************************************************************************/
    866       1.1    jruoho 
    867       1.1    jruoho void
    868       1.1    jruoho DtSetTableLength (
    869       1.1    jruoho     void)
    870       1.1    jruoho {
    871       1.1    jruoho     DT_SUBTABLE             *ParentTable;
    872       1.1    jruoho     DT_SUBTABLE             *ChildTable;
    873       1.1    jruoho 
    874       1.1    jruoho 
    875      1.12  christos     ParentTable = AslGbl_RootTable;
    876       1.1    jruoho     ChildTable = NULL;
    877       1.1    jruoho 
    878       1.1    jruoho     if (!ParentTable)
    879       1.1    jruoho     {
    880       1.1    jruoho         return;
    881       1.1    jruoho     }
    882       1.1    jruoho 
    883       1.1    jruoho     DtSetSubtableLength (ParentTable);
    884       1.1    jruoho 
    885       1.1    jruoho     while (1)
    886       1.1    jruoho     {
    887       1.1    jruoho         ChildTable = DtGetNextSubtable (ParentTable, ChildTable);
    888       1.1    jruoho         if (ChildTable)
    889       1.1    jruoho         {
    890       1.2  christos             if (ChildTable->LengthField)
    891       1.2  christos             {
    892       1.2  christos                 DtSetSubtableLength (ChildTable);
    893       1.2  christos             }
    894       1.2  christos 
    895       1.1    jruoho             if (ChildTable->Child)
    896       1.1    jruoho             {
    897       1.1    jruoho                 ParentTable = ChildTable;
    898       1.1    jruoho                 ChildTable = NULL;
    899       1.1    jruoho             }
    900       1.1    jruoho             else
    901       1.1    jruoho             {
    902       1.1    jruoho                 ParentTable->TotalLength += ChildTable->TotalLength;
    903       1.1    jruoho                 if (ParentTable->LengthField)
    904       1.1    jruoho                 {
    905       1.1    jruoho                     DtSetSubtableLength (ParentTable);
    906       1.1    jruoho                 }
    907       1.1    jruoho             }
    908       1.1    jruoho         }
    909       1.1    jruoho         else
    910       1.1    jruoho         {
    911       1.1    jruoho             ChildTable = ParentTable;
    912       1.1    jruoho 
    913      1.12  christos             if (ChildTable == AslGbl_RootTable)
    914       1.1    jruoho             {
    915       1.1    jruoho                 break;
    916       1.1    jruoho             }
    917       1.1    jruoho 
    918       1.1    jruoho             ParentTable = DtGetParentSubtable (ParentTable);
    919       1.1    jruoho 
    920       1.1    jruoho             ParentTable->TotalLength += ChildTable->TotalLength;
    921       1.1    jruoho             if (ParentTable->LengthField)
    922       1.1    jruoho             {
    923       1.1    jruoho                 DtSetSubtableLength (ParentTable);
    924       1.1    jruoho             }
    925       1.1    jruoho         }
    926       1.1    jruoho     }
    927       1.1    jruoho }
    928       1.1    jruoho 
    929       1.1    jruoho 
    930       1.1    jruoho /******************************************************************************
    931       1.1    jruoho  *
    932       1.1    jruoho  * FUNCTION:    DtWalkTableTree
    933       1.1    jruoho  *
    934       1.1    jruoho  * PARAMETERS:  StartTable          - Subtable in the tree where walking begins
    935       1.1    jruoho  *              UserFunction        - Called during the walk
    936       1.1    jruoho  *              Context             - Passed to user function
    937       1.1    jruoho  *              ReturnValue         - The return value of UserFunction
    938       1.1    jruoho  *
    939       1.1    jruoho  * RETURN:      None
    940       1.1    jruoho  *
    941       1.1    jruoho  * DESCRIPTION: Performs a depth-first walk of the subtable tree
    942       1.1    jruoho  *
    943       1.1    jruoho  *****************************************************************************/
    944       1.1    jruoho 
    945       1.1    jruoho void
    946       1.1    jruoho DtWalkTableTree (
    947       1.1    jruoho     DT_SUBTABLE             *StartTable,
    948       1.1    jruoho     DT_WALK_CALLBACK        UserFunction,
    949       1.1    jruoho     void                    *Context,
    950       1.1    jruoho     void                    *ReturnValue)
    951       1.1    jruoho {
    952       1.1    jruoho     DT_SUBTABLE             *ParentTable;
    953       1.1    jruoho     DT_SUBTABLE             *ChildTable;
    954       1.1    jruoho 
    955       1.1    jruoho 
    956       1.1    jruoho     ParentTable = StartTable;
    957       1.1    jruoho     ChildTable = NULL;
    958       1.1    jruoho 
    959       1.1    jruoho     if (!ParentTable)
    960       1.1    jruoho     {
    961       1.1    jruoho         return;
    962       1.1    jruoho     }
    963       1.1    jruoho 
    964       1.1    jruoho     UserFunction (ParentTable, Context, ReturnValue);
    965       1.1    jruoho 
    966       1.1    jruoho     while (1)
    967       1.1    jruoho     {
    968       1.1    jruoho         ChildTable = DtGetNextSubtable (ParentTable, ChildTable);
    969       1.1    jruoho         if (ChildTable)
    970       1.1    jruoho         {
    971       1.1    jruoho             UserFunction (ChildTable, Context, ReturnValue);
    972       1.1    jruoho 
    973       1.1    jruoho             if (ChildTable->Child)
    974       1.1    jruoho             {
    975       1.1    jruoho                 ParentTable = ChildTable;
    976       1.1    jruoho                 ChildTable = NULL;
    977       1.1    jruoho             }
    978       1.1    jruoho         }
    979       1.1    jruoho         else
    980       1.1    jruoho         {
    981       1.1    jruoho             ChildTable = ParentTable;
    982      1.12  christos             if (ChildTable == AslGbl_RootTable)
    983       1.1    jruoho             {
    984       1.1    jruoho                 break;
    985       1.1    jruoho             }
    986       1.1    jruoho 
    987       1.1    jruoho             ParentTable = DtGetParentSubtable (ParentTable);
    988       1.1    jruoho 
    989       1.1    jruoho             if (ChildTable->Peer == StartTable)
    990       1.1    jruoho             {
    991       1.1    jruoho                 break;
    992       1.1    jruoho             }
    993       1.1    jruoho         }
    994       1.1    jruoho     }
    995       1.1    jruoho }
    996