Home | History | Annotate | Line # | Download | only in compiler
aslutils.c revision 1.26
      1   1.1    jruoho /******************************************************************************
      2   1.1    jruoho  *
      3   1.1    jruoho  * Module Name: aslutils -- compiler utilities
      4   1.1    jruoho  *
      5   1.1    jruoho  *****************************************************************************/
      6   1.1    jruoho 
      7   1.3    jruoho /*
      8  1.26  christos  * Copyright (C) 2000 - 2020, Intel Corp.
      9   1.1    jruoho  * All rights reserved.
     10   1.1    jruoho  *
     11   1.3    jruoho  * Redistribution and use in source and binary forms, with or without
     12   1.3    jruoho  * modification, are permitted provided that the following conditions
     13   1.3    jruoho  * are met:
     14   1.3    jruoho  * 1. Redistributions of source code must retain the above copyright
     15   1.3    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16   1.3    jruoho  *    without modification.
     17   1.3    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18   1.3    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19   1.3    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20   1.3    jruoho  *    including a substantially similar Disclaimer requirement for further
     21   1.3    jruoho  *    binary redistribution.
     22   1.3    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23   1.3    jruoho  *    of any contributors may be used to endorse or promote products derived
     24   1.3    jruoho  *    from this software without specific prior written permission.
     25   1.3    jruoho  *
     26   1.3    jruoho  * Alternatively, this software may be distributed under the terms of the
     27   1.3    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28   1.3    jruoho  * Software Foundation.
     29   1.3    jruoho  *
     30   1.3    jruoho  * NO WARRANTY
     31   1.3    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32   1.3    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33   1.3    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34   1.3    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35   1.3    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36   1.3    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37   1.3    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38   1.3    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39   1.3    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40   1.3    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41   1.3    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42   1.3    jruoho  */
     43   1.1    jruoho 
     44   1.1    jruoho #include "aslcompiler.h"
     45   1.1    jruoho #include "aslcompiler.y.h"
     46   1.3    jruoho #include "acdisasm.h"
     47   1.1    jruoho #include "acnamesp.h"
     48   1.1    jruoho #include "amlcode.h"
     49  1.13  christos #include "acapps.h"
     50  1.13  christos #include <sys/stat.h>
     51  1.13  christos 
     52   1.1    jruoho 
     53   1.1    jruoho #define _COMPONENT          ACPI_COMPILER
     54   1.1    jruoho         ACPI_MODULE_NAME    ("aslutils")
     55   1.1    jruoho 
     56   1.1    jruoho 
     57   1.1    jruoho /* Local prototypes */
     58   1.1    jruoho 
     59   1.1    jruoho static void
     60   1.1    jruoho UtPadNameWithUnderscores (
     61   1.1    jruoho     char                    *NameSeg,
     62   1.1    jruoho     char                    *PaddedNameSeg);
     63   1.1    jruoho 
     64   1.1    jruoho static void
     65   1.1    jruoho UtAttachNameseg (
     66   1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     67   1.1    jruoho     char                    *Name);
     68   1.1    jruoho 
     69  1.23  christos static void
     70  1.23  christos UtDisplayErrorSummary (
     71  1.23  christos     UINT32                  FileId);
     72  1.23  christos 
     73   1.1    jruoho 
     74  1.14  christos /*******************************************************************************
     75  1.14  christos  *
     76  1.14  christos  * FUNCTION:    UtIsBigEndianMachine
     77  1.14  christos  *
     78  1.14  christos  * PARAMETERS:  None
     79  1.14  christos  *
     80  1.14  christos  * RETURN:      TRUE if machine is big endian
     81  1.14  christos  *              FALSE if machine is little endian
     82  1.14  christos  *
     83  1.14  christos  * DESCRIPTION: Detect whether machine is little endian or big endian.
     84  1.14  christos  *
     85  1.14  christos  ******************************************************************************/
     86  1.14  christos 
     87  1.14  christos UINT8
     88  1.14  christos UtIsBigEndianMachine (
     89  1.14  christos     void)
     90  1.14  christos {
     91  1.14  christos     union {
     92  1.14  christos         UINT32              Integer;
     93  1.14  christos         UINT8               Bytes[4];
     94  1.14  christos     } Overlay =                 {0xFF000000};
     95  1.14  christos 
     96  1.14  christos 
     97  1.14  christos     return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */
     98  1.14  christos }
     99  1.14  christos 
    100  1.14  christos 
    101  1.13  christos /******************************************************************************
    102  1.13  christos  *
    103  1.13  christos  * FUNCTION:    UtQueryForOverwrite
    104  1.13  christos  *
    105  1.13  christos  * PARAMETERS:  Pathname            - Output filename
    106  1.13  christos  *
    107  1.13  christos  * RETURN:      TRUE if file does not exist or overwrite is authorized
    108  1.13  christos  *
    109  1.13  christos  * DESCRIPTION: Query for file overwrite if it already exists.
    110  1.13  christos  *
    111  1.13  christos  ******************************************************************************/
    112  1.13  christos 
    113  1.13  christos BOOLEAN
    114  1.13  christos UtQueryForOverwrite (
    115  1.13  christos     char                    *Pathname)
    116  1.13  christos {
    117  1.13  christos     struct stat             StatInfo;
    118  1.25  christos     int                     InChar;
    119  1.13  christos 
    120  1.13  christos 
    121  1.13  christos     if (!stat (Pathname, &StatInfo))
    122  1.13  christos     {
    123  1.13  christos         fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ",
    124  1.13  christos             Pathname);
    125  1.13  christos 
    126  1.24  christos         InChar = fgetc (stdin);
    127  1.24  christos         if (InChar == '\n')
    128  1.24  christos         {
    129  1.24  christos             InChar = fgetc (stdin);
    130  1.24  christos         }
    131  1.24  christos 
    132  1.24  christos         if ((InChar != 'y') && (InChar != 'Y'))
    133  1.13  christos         {
    134  1.13  christos             return (FALSE);
    135  1.13  christos         }
    136  1.13  christos     }
    137  1.13  christos 
    138  1.13  christos     return (TRUE);
    139  1.13  christos }
    140  1.13  christos 
    141  1.13  christos 
    142   1.1    jruoho /*******************************************************************************
    143   1.1    jruoho  *
    144  1.21  christos  * FUNCTION:    UtNodeIsDescendantOf
    145  1.21  christos  *
    146  1.21  christos  * PARAMETERS:  Node1                   - Child node
    147  1.21  christos  *              Node2                   - Possible parent node
    148  1.21  christos  *
    149  1.21  christos  * RETURN:      Boolean
    150  1.21  christos  *
    151  1.21  christos  * DESCRIPTION: Returns TRUE if Node1 is a descendant of Node2. Otherwise,
    152  1.21  christos  *              return FALSE. Note, we assume a NULL Node2 element to be the
    153  1.21  christos  *              topmost (root) scope. All nodes are descendants of the root.
    154  1.21  christos  *              Note: Nodes at the same level (siblings) are not considered
    155  1.21  christos  *              descendants.
    156  1.21  christos  *
    157  1.21  christos  ******************************************************************************/
    158  1.21  christos 
    159  1.21  christos BOOLEAN
    160  1.21  christos UtNodeIsDescendantOf (
    161  1.21  christos     ACPI_NAMESPACE_NODE     *Node1,
    162  1.21  christos     ACPI_NAMESPACE_NODE     *Node2)
    163  1.21  christos {
    164  1.21  christos 
    165  1.21  christos     if (Node1 == Node2)
    166  1.21  christos     {
    167  1.21  christos         return (FALSE);
    168  1.21  christos     }
    169  1.21  christos 
    170  1.21  christos     if (!Node2)
    171  1.21  christos     {
    172  1.21  christos         return (TRUE); /* All nodes descend from the root */
    173  1.21  christos     }
    174  1.21  christos 
    175  1.21  christos     /* Walk upward until the root is reached or parent is found */
    176  1.21  christos 
    177  1.21  christos     while (Node1)
    178  1.21  christos     {
    179  1.21  christos         if (Node1 == Node2)
    180  1.21  christos         {
    181  1.21  christos             return (TRUE);
    182  1.21  christos         }
    183  1.21  christos 
    184  1.21  christos         Node1 = Node1->Parent;
    185  1.21  christos     }
    186  1.21  christos 
    187  1.21  christos     return (FALSE);
    188  1.21  christos }
    189  1.21  christos 
    190  1.21  christos 
    191  1.21  christos /*******************************************************************************
    192  1.21  christos  *
    193  1.26  christos  * FUNCTION:    UtGetParentMethodNode
    194  1.21  christos  *
    195  1.21  christos  * PARAMETERS:  Node                    - Namespace node for any object
    196  1.21  christos  *
    197  1.21  christos  * RETURN:      Namespace node for the parent method
    198  1.21  christos  *              NULL - object is not within a method
    199  1.21  christos  *
    200  1.21  christos  * DESCRIPTION: Find the parent (owning) method node for a namespace object
    201  1.21  christos  *
    202  1.21  christos  ******************************************************************************/
    203  1.21  christos 
    204  1.26  christos ACPI_NAMESPACE_NODE *
    205  1.26  christos UtGetParentMethodNode (
    206  1.21  christos     ACPI_NAMESPACE_NODE     *Node)
    207  1.21  christos {
    208  1.21  christos     ACPI_NAMESPACE_NODE     *ParentNode;
    209  1.21  christos 
    210  1.21  christos 
    211  1.21  christos     if (!Node)
    212  1.21  christos     {
    213  1.21  christos         return (NULL);
    214  1.21  christos     }
    215  1.21  christos 
    216  1.21  christos     /* Walk upward until a method is found, or the root is reached */
    217  1.21  christos 
    218  1.21  christos     ParentNode = Node->Parent;
    219  1.21  christos     while (ParentNode)
    220  1.21  christos     {
    221  1.21  christos         if (ParentNode->Type == ACPI_TYPE_METHOD)
    222  1.21  christos         {
    223  1.21  christos             return (ParentNode);
    224  1.21  christos         }
    225  1.21  christos 
    226  1.21  christos         ParentNode = ParentNode->Parent;
    227  1.21  christos     }
    228  1.21  christos 
    229  1.21  christos     return (NULL); /* Object is not within a control method */
    230  1.21  christos }
    231  1.21  christos 
    232  1.21  christos 
    233  1.21  christos /*******************************************************************************
    234  1.21  christos  *
    235  1.26  christos  * FUNCTION:    UtGetParentMethodOp
    236  1.26  christos  *
    237  1.26  christos  * PARAMETERS:  Op                      - Parse Op to be checked
    238  1.26  christos  *
    239  1.26  christos  * RETURN:      Control method Op if found. NULL otherwise
    240  1.26  christos  *
    241  1.26  christos  * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if
    242  1.26  christos  *              the input Op is not within a control method.
    243  1.26  christos  *
    244  1.26  christos  ******************************************************************************/
    245  1.26  christos 
    246  1.26  christos ACPI_PARSE_OBJECT *
    247  1.26  christos UtGetParentMethodOp (
    248  1.26  christos     ACPI_PARSE_OBJECT       *Op)
    249  1.26  christos {
    250  1.26  christos     ACPI_PARSE_OBJECT       *NextOp;
    251  1.26  christos 
    252  1.26  christos 
    253  1.26  christos     NextOp = Op->Asl.Parent;
    254  1.26  christos     while (NextOp)
    255  1.26  christos     {
    256  1.26  christos         if (NextOp->Asl.AmlOpcode == AML_METHOD_OP)
    257  1.26  christos         {
    258  1.26  christos             return (NextOp);
    259  1.26  christos         }
    260  1.26  christos 
    261  1.26  christos         NextOp = NextOp->Asl.Parent;
    262  1.26  christos     }
    263  1.26  christos 
    264  1.26  christos     return (NULL); /* No parent method found */
    265  1.26  christos }
    266  1.26  christos 
    267  1.26  christos 
    268  1.26  christos /*******************************************************************************
    269  1.26  christos  *
    270   1.3    jruoho  * FUNCTION:    UtDisplaySupportedTables
    271   1.3    jruoho  *
    272   1.3    jruoho  * PARAMETERS:  None
    273   1.3    jruoho  *
    274   1.3    jruoho  * RETURN:      None
    275   1.3    jruoho  *
    276   1.3    jruoho  * DESCRIPTION: Print all supported ACPI table names.
    277   1.3    jruoho  *
    278   1.3    jruoho  ******************************************************************************/
    279   1.3    jruoho 
    280   1.3    jruoho void
    281   1.3    jruoho UtDisplaySupportedTables (
    282   1.3    jruoho     void)
    283   1.3    jruoho {
    284  1.12  christos     const AH_TABLE          *TableData;
    285   1.6  christos     UINT32                  i;
    286   1.3    jruoho 
    287   1.3    jruoho 
    288   1.6  christos     printf ("\nACPI tables supported by iASL version %8.8X:\n"
    289   1.6  christos         "  (Compiler, Disassembler, Template Generator)\n\n",
    290   1.6  christos         ACPI_CA_VERSION);
    291   1.3    jruoho 
    292  1.12  christos     /* All ACPI tables with the common table header */
    293   1.3    jruoho 
    294  1.12  christos     printf ("\n  Supported ACPI tables:\n");
    295  1.22  christos     for (TableData = AcpiGbl_SupportedTables, i = 1;
    296  1.12  christos          TableData->Signature; TableData++, i++)
    297   1.3    jruoho     {
    298  1.12  christos         printf ("%8u) %s    %s\n", i,
    299  1.12  christos             TableData->Signature, TableData->Description);
    300   1.3    jruoho     }
    301   1.3    jruoho }
    302   1.3    jruoho 
    303   1.3    jruoho 
    304   1.3    jruoho /*******************************************************************************
    305   1.3    jruoho  *
    306   1.6  christos  * FUNCTION:    UtDisplayConstantOpcodes
    307   1.1    jruoho  *
    308   1.1    jruoho  * PARAMETERS:  None
    309   1.1    jruoho  *
    310   1.1    jruoho  * RETURN:      None
    311   1.1    jruoho  *
    312   1.1    jruoho  * DESCRIPTION: Print AML opcodes that can be used in constant expressions.
    313   1.1    jruoho  *
    314   1.1    jruoho  ******************************************************************************/
    315   1.1    jruoho 
    316   1.1    jruoho void
    317   1.1    jruoho UtDisplayConstantOpcodes (
    318   1.1    jruoho     void)
    319   1.1    jruoho {
    320   1.1    jruoho     UINT32                  i;
    321   1.1    jruoho 
    322   1.1    jruoho 
    323   1.1    jruoho     printf ("Constant expression opcode information\n\n");
    324   1.1    jruoho 
    325   1.1    jruoho     for (i = 0; i < sizeof (AcpiGbl_AmlOpInfo) / sizeof (ACPI_OPCODE_INFO); i++)
    326   1.1    jruoho     {
    327   1.1    jruoho         if (AcpiGbl_AmlOpInfo[i].Flags & AML_CONSTANT)
    328   1.1    jruoho         {
    329   1.1    jruoho             printf ("%s\n", AcpiGbl_AmlOpInfo[i].Name);
    330   1.1    jruoho         }
    331   1.1    jruoho     }
    332   1.1    jruoho }
    333   1.1    jruoho 
    334   1.1    jruoho 
    335   1.1    jruoho /*******************************************************************************
    336   1.1    jruoho  *
    337   1.1    jruoho  * FUNCTION:    UtBeginEvent
    338   1.1    jruoho  *
    339   1.6  christos  * PARAMETERS:  Name                - Ascii name of this event
    340   1.1    jruoho  *
    341   1.6  christos  * RETURN:      Event number (integer index)
    342   1.1    jruoho  *
    343   1.1    jruoho  * DESCRIPTION: Saves the current time with this event
    344   1.1    jruoho  *
    345   1.1    jruoho  ******************************************************************************/
    346   1.1    jruoho 
    347   1.1    jruoho UINT8
    348   1.1    jruoho UtBeginEvent (
    349   1.1    jruoho     char                    *Name)
    350   1.1    jruoho {
    351   1.1    jruoho 
    352   1.1    jruoho     if (AslGbl_NextEvent >= ASL_NUM_EVENTS)
    353   1.1    jruoho     {
    354   1.1    jruoho         AcpiOsPrintf ("Ran out of compiler event structs!\n");
    355   1.1    jruoho         return (AslGbl_NextEvent);
    356   1.1    jruoho     }
    357   1.1    jruoho 
    358   1.1    jruoho     /* Init event with current (start) time */
    359   1.1    jruoho 
    360   1.1    jruoho     AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer ();
    361   1.1    jruoho     AslGbl_Events[AslGbl_NextEvent].EventName = Name;
    362   1.1    jruoho     AslGbl_Events[AslGbl_NextEvent].Valid = TRUE;
    363   1.1    jruoho     return (AslGbl_NextEvent++);
    364   1.1    jruoho }
    365   1.1    jruoho 
    366   1.1    jruoho 
    367   1.1    jruoho /*******************************************************************************
    368   1.1    jruoho  *
    369   1.1    jruoho  * FUNCTION:    UtEndEvent
    370   1.1    jruoho  *
    371   1.6  christos  * PARAMETERS:  Event               - Event number (integer index)
    372   1.1    jruoho  *
    373   1.1    jruoho  * RETURN:      None
    374   1.1    jruoho  *
    375   1.1    jruoho  * DESCRIPTION: Saves the current time (end time) with this event
    376   1.1    jruoho  *
    377   1.1    jruoho  ******************************************************************************/
    378   1.1    jruoho 
    379   1.1    jruoho void
    380   1.1    jruoho UtEndEvent (
    381   1.6  christos     UINT8                   Event)
    382   1.1    jruoho {
    383   1.1    jruoho 
    384   1.1    jruoho     if (Event >= ASL_NUM_EVENTS)
    385   1.1    jruoho     {
    386   1.1    jruoho         return;
    387   1.1    jruoho     }
    388   1.1    jruoho 
    389   1.1    jruoho     /* Insert end time for event */
    390   1.1    jruoho 
    391   1.1    jruoho     AslGbl_Events[Event].EndTime = AcpiOsGetTimer ();
    392   1.1    jruoho }
    393   1.1    jruoho 
    394   1.1    jruoho 
    395   1.1    jruoho /*******************************************************************************
    396   1.1    jruoho  *
    397   1.1    jruoho  * FUNCTION:    DbgPrint
    398   1.1    jruoho  *
    399   1.6  christos  * PARAMETERS:  Type                - Type of output
    400   1.6  christos  *              Fmt                 - Printf format string
    401   1.6  christos  *              ...                 - variable printf list
    402   1.1    jruoho  *
    403   1.1    jruoho  * RETURN:      None
    404   1.1    jruoho  *
    405   1.6  christos  * DESCRIPTION: Conditional print statement. Prints to stderr only if the
    406   1.1    jruoho  *              debug flag is set.
    407   1.1    jruoho  *
    408   1.1    jruoho  ******************************************************************************/
    409   1.1    jruoho 
    410   1.1    jruoho void
    411   1.1    jruoho DbgPrint (
    412   1.1    jruoho     UINT32                  Type,
    413   1.1    jruoho     char                    *Fmt,
    414   1.1    jruoho     ...)
    415   1.1    jruoho {
    416   1.1    jruoho     va_list                 Args;
    417   1.1    jruoho 
    418   1.1    jruoho 
    419  1.22  christos     if (!AslGbl_DebugFlag)
    420   1.1    jruoho     {
    421   1.1    jruoho         return;
    422   1.1    jruoho     }
    423   1.1    jruoho 
    424   1.1    jruoho     if ((Type == ASL_PARSE_OUTPUT) &&
    425   1.1    jruoho         (!(AslCompilerdebug)))
    426   1.1    jruoho     {
    427   1.1    jruoho         return;
    428   1.1    jruoho     }
    429   1.1    jruoho 
    430   1.5  christos     va_start (Args, Fmt);
    431   1.1    jruoho     (void) vfprintf (stderr, Fmt, Args);
    432   1.1    jruoho     va_end (Args);
    433   1.1    jruoho     return;
    434   1.1    jruoho }
    435   1.1    jruoho 
    436   1.1    jruoho 
    437   1.1    jruoho /*******************************************************************************
    438   1.1    jruoho  *
    439   1.1    jruoho  * FUNCTION:    UtSetParseOpName
    440   1.1    jruoho  *
    441   1.6  christos  * PARAMETERS:  Op                  - Parse op to be named.
    442   1.1    jruoho  *
    443   1.1    jruoho  * RETURN:      None
    444   1.1    jruoho  *
    445   1.1    jruoho  * DESCRIPTION: Insert the ascii name of the parse opcode
    446   1.1    jruoho  *
    447   1.1    jruoho  ******************************************************************************/
    448   1.1    jruoho 
    449   1.1    jruoho void
    450   1.1    jruoho UtSetParseOpName (
    451   1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    452   1.1    jruoho {
    453   1.1    jruoho 
    454  1.20  christos     AcpiUtSafeStrncpy (Op->Asl.ParseOpName, UtGetOpName (Op->Asl.ParseOpcode),
    455   1.1    jruoho         ACPI_MAX_PARSEOP_NAME);
    456   1.1    jruoho }
    457   1.1    jruoho 
    458   1.1    jruoho 
    459   1.1    jruoho /*******************************************************************************
    460   1.1    jruoho  *
    461  1.23  christos  * FUNCTION:    UtDisplayOneSummary
    462   1.1    jruoho  *
    463   1.6  christos  * PARAMETERS:  FileID              - ID of outpout file
    464   1.1    jruoho  *
    465   1.1    jruoho  * RETURN:      None
    466   1.1    jruoho  *
    467  1.23  christos  * DESCRIPTION: Display compilation statistics for one input file
    468   1.1    jruoho  *
    469   1.1    jruoho  ******************************************************************************/
    470   1.1    jruoho 
    471   1.1    jruoho void
    472  1.23  christos UtDisplayOneSummary (
    473  1.23  christos     UINT32                  FileId,
    474  1.23  christos     BOOLEAN                 DisplayErrorSummary)
    475   1.1    jruoho {
    476   1.6  christos     UINT32                  i;
    477  1.23  christos     ASL_GLOBAL_FILE_NODE    *FileNode;
    478  1.24  christos     BOOLEAN                 DisplayAMLSummary;
    479   1.6  christos 
    480   1.1    jruoho 
    481  1.24  christos     DisplayAMLSummary =
    482  1.24  christos         !AslGbl_PreprocessOnly && !AslGbl_ParserErrorDetected &&
    483  1.24  christos         ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || AslGbl_IgnoreErrors) &&
    484  1.24  christos         AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle;
    485  1.24  christos 
    486   1.1    jruoho     if (FileId != ASL_FILE_STDOUT)
    487   1.1    jruoho     {
    488   1.1    jruoho         /* Compiler name and version number */
    489   1.1    jruoho 
    490  1.16  christos         FlPrintFile (FileId, "%s version %X [%s]\n\n",
    491  1.17  christos             ASL_COMPILER_NAME, (UINT32) ACPI_CA_VERSION, "2017-01-19");
    492   1.1    jruoho     }
    493   1.1    jruoho 
    494   1.6  christos     /* Summary of main input and output files */
    495   1.6  christos 
    496  1.24  christos     FileNode = FlGetCurrentFileNode ();
    497  1.24  christos 
    498  1.24  christos     if (FileNode->ParserErrorDetected)
    499   1.1    jruoho     {
    500   1.1    jruoho         FlPrintFile (FileId,
    501  1.24  christos             "%-14s %s - Compilation aborted due to parser-detected syntax error(s)\n",
    502  1.24  christos             "Input file:", AslGbl_Files[ASL_FILE_INPUT].Filename);
    503  1.24  christos     }
    504  1.24  christos     else if (FileNode->FileType == ASL_INPUT_TYPE_ASCII_DATA)
    505  1.24  christos     {
    506  1.24  christos         FlPrintFile (FileId,
    507  1.24  christos             "%-14s %s - %7u bytes %6u fields %8u source lines\n",
    508   1.6  christos             "Table Input:",
    509  1.24  christos             AslGbl_Files[ASL_FILE_INPUT].Filename,
    510  1.24  christos             FileNode->OriginalInputFileSize, FileNode->TotalFields,
    511  1.24  christos             FileNode->TotalLineCount);
    512   1.1    jruoho 
    513  1.24  christos         FlPrintFile (FileId,
    514  1.24  christos             "%-14s %s - %7u bytes\n",
    515  1.24  christos             "Binary Output:",
    516  1.24  christos             AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename, FileNode->OutputByteLength);
    517   1.1    jruoho     }
    518  1.24  christos     else if (FileNode->FileType == ASL_INPUT_TYPE_ASCII_ASL)
    519   1.1    jruoho     {
    520  1.24  christos         FlPrintFile (FileId,
    521  1.24  christos             "%-14s %s - %7u bytes %6u keywords %6u source lines\n",
    522  1.24  christos             "ASL Input:",
    523  1.24  christos             AslGbl_Files[ASL_FILE_INPUT].Filename,
    524  1.24  christos             FileNode->OriginalInputFileSize,
    525  1.24  christos             FileNode->TotalKeywords,
    526  1.24  christos             FileNode->TotalLineCount);
    527  1.24  christos 
    528  1.24  christos         /* AML summary */
    529  1.24  christos 
    530  1.24  christos         if (DisplayAMLSummary)
    531  1.23  christos         {
    532  1.23  christos             FlPrintFile (FileId,
    533  1.24  christos                 "%-14s %s - %7u bytes %6u opcodes  %6u named objects\n",
    534  1.24  christos                 "AML Output:",
    535  1.24  christos                 AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename,
    536  1.24  christos                 FlGetFileSize (ASL_FILE_AML_OUTPUT),
    537  1.24  christos                 FileNode->TotalExecutableOpcodes,
    538  1.24  christos                 FileNode->TotalNamedObjects);
    539   1.1    jruoho         }
    540   1.1    jruoho     }
    541   1.1    jruoho 
    542   1.6  christos     /* Display summary of any optional files */
    543   1.6  christos 
    544   1.6  christos     for (i = ASL_FILE_SOURCE_OUTPUT; i <= ASL_MAX_FILE_TYPE; i++)
    545   1.6  christos     {
    546  1.22  christos         if (!AslGbl_Files[i].Filename || !AslGbl_Files[i].Handle)
    547   1.6  christos         {
    548   1.6  christos             continue;
    549   1.6  christos         }
    550   1.6  christos 
    551   1.6  christos         /* .SRC is a temp file unless specifically requested */
    552   1.6  christos 
    553  1.22  christos         if ((i == ASL_FILE_SOURCE_OUTPUT) && (!AslGbl_SourceOutputFlag))
    554   1.6  christos         {
    555   1.6  christos             continue;
    556   1.6  christos         }
    557   1.6  christos 
    558  1.12  christos         /* .PRE is the preprocessor intermediate file */
    559   1.6  christos 
    560  1.22  christos         if ((i == ASL_FILE_PREPROCESSOR)  && (!AslGbl_KeepPreprocessorTempFile))
    561   1.6  christos         {
    562   1.6  christos             continue;
    563   1.6  christos         }
    564   1.6  christos 
    565  1.24  christos         FlPrintFile (FileId, "%-14s %s - %7u bytes\n",
    566  1.23  christos             AslGbl_FileDescs[i].ShortDescription,
    567  1.22  christos             AslGbl_Files[i].Filename, FlGetFileSize (i));
    568   1.6  christos     }
    569   1.6  christos 
    570  1.23  christos 
    571  1.23  christos     /*
    572  1.23  christos      * Optionally emit an error summary for a file. This is used to enhance the
    573  1.23  christos      * appearance of listing files.
    574  1.23  christos      */
    575  1.23  christos     if (DisplayErrorSummary)
    576  1.23  christos     {
    577  1.23  christos         UtDisplayErrorSummary (FileId);
    578  1.23  christos     }
    579  1.23  christos }
    580  1.23  christos 
    581  1.23  christos 
    582  1.23  christos /*******************************************************************************
    583  1.23  christos  *
    584  1.23  christos  * FUNCTION:    UtDisplayErrorSummary
    585  1.23  christos  *
    586  1.23  christos  * PARAMETERS:  FileID              - ID of outpout file
    587  1.23  christos  *
    588  1.23  christos  * RETURN:      None
    589  1.23  christos  *
    590  1.23  christos  * DESCRIPTION: Display compilation statistics for all input files
    591  1.23  christos  *
    592  1.23  christos  ******************************************************************************/
    593  1.23  christos 
    594  1.23  christos static void
    595  1.23  christos UtDisplayErrorSummary (
    596  1.23  christos     UINT32                  FileId)
    597  1.23  christos {
    598  1.23  christos     BOOLEAN                 ErrorDetected;
    599  1.23  christos 
    600  1.23  christos 
    601  1.23  christos     ErrorDetected = AslGbl_ParserErrorDetected ||
    602  1.23  christos         ((AslGbl_ExceptionCount[ASL_ERROR] > 0) && !AslGbl_IgnoreErrors);
    603  1.23  christos 
    604  1.23  christos     if (ErrorDetected)
    605  1.23  christos     {
    606  1.23  christos         FlPrintFile (FileId, "\nCompilation failed. ");
    607  1.23  christos     }
    608  1.23  christos     else
    609  1.23  christos     {
    610  1.23  christos         FlPrintFile (FileId, "\nCompilation successful. ");
    611  1.23  christos     }
    612   1.1    jruoho 
    613   1.1    jruoho     FlPrintFile (FileId,
    614  1.23  christos         "%u Errors, %u Warnings, %u Remarks",
    615  1.22  christos         AslGbl_ExceptionCount[ASL_ERROR],
    616  1.22  christos         AslGbl_ExceptionCount[ASL_WARNING] +
    617  1.22  christos             AslGbl_ExceptionCount[ASL_WARNING2] +
    618  1.22  christos             AslGbl_ExceptionCount[ASL_WARNING3],
    619  1.22  christos         AslGbl_ExceptionCount[ASL_REMARK]);
    620   1.1    jruoho 
    621  1.22  christos     if (AslGbl_FileType != ASL_INPUT_TYPE_ASCII_DATA)
    622   1.1    jruoho     {
    623  1.23  christos         if (AslGbl_ParserErrorDetected)
    624  1.23  christos         {
    625  1.23  christos             FlPrintFile (FileId,
    626  1.23  christos                 "\nNo AML files were generated due to syntax error(s)\n");
    627  1.23  christos             return;
    628  1.23  christos         }
    629  1.23  christos         else if (ErrorDetected)
    630  1.23  christos         {
    631  1.23  christos             FlPrintFile (FileId,
    632  1.23  christos                 "\nNo AML files were generated due to compiler error(s)\n");
    633  1.23  christos             return;
    634  1.23  christos         }
    635  1.23  christos 
    636  1.10  christos         FlPrintFile (FileId, ", %u Optimizations",
    637  1.22  christos             AslGbl_ExceptionCount[ASL_OPTIMIZATION]);
    638  1.10  christos 
    639  1.22  christos         if (AslGbl_TotalFolds)
    640  1.10  christos         {
    641  1.22  christos             FlPrintFile (FileId, ", %u Constants Folded", AslGbl_TotalFolds);
    642  1.10  christos         }
    643   1.1    jruoho     }
    644   1.1    jruoho 
    645   1.1    jruoho     FlPrintFile (FileId, "\n");
    646   1.1    jruoho }
    647   1.1    jruoho 
    648   1.1    jruoho 
    649   1.1    jruoho /*******************************************************************************
    650   1.1    jruoho  *
    651  1.23  christos  * FUNCTION:    UtDisplaySummary
    652  1.23  christos  *
    653  1.23  christos  * PARAMETERS:  FileID              - ID of outpout file
    654  1.23  christos  *
    655  1.23  christos  * RETURN:      None
    656  1.23  christos  *
    657  1.23  christos  * DESCRIPTION: Display compilation statistics for all input files
    658  1.23  christos  *
    659  1.23  christos  ******************************************************************************/
    660  1.23  christos 
    661  1.23  christos void
    662  1.23  christos UtDisplaySummary (
    663  1.23  christos     UINT32                  FileId)
    664  1.23  christos {
    665  1.23  christos     ASL_GLOBAL_FILE_NODE    *Current = AslGbl_FilesList;
    666  1.23  christos 
    667  1.23  christos 
    668  1.23  christos     while (Current)
    669  1.23  christos     {
    670  1.23  christos         switch  (FlSwitchFileSet(Current->Files[ASL_FILE_INPUT].Filename))
    671  1.23  christos         {
    672  1.23  christos             case SWITCH_TO_SAME_FILE:
    673  1.23  christos             case SWITCH_TO_DIFFERENT_FILE:
    674  1.23  christos 
    675  1.23  christos                 UtDisplayOneSummary (FileId, FALSE);
    676  1.23  christos                 Current = Current->Next;
    677  1.23  christos                 break;
    678  1.23  christos 
    679  1.23  christos             case FILE_NOT_FOUND:
    680  1.23  christos             default:
    681  1.23  christos 
    682  1.23  christos                 Current = NULL;
    683  1.23  christos                 break;
    684  1.23  christos         }
    685  1.23  christos     }
    686  1.23  christos     UtDisplayErrorSummary (FileId);
    687  1.23  christos }
    688  1.23  christos 
    689  1.23  christos /*******************************************************************************
    690  1.23  christos  *
    691   1.6  christos  * FUNCTION:    UtCheckIntegerRange
    692   1.1    jruoho  *
    693   1.6  christos  * PARAMETERS:  Op                  - Integer parse node
    694   1.6  christos  *              LowValue            - Smallest allowed value
    695   1.6  christos  *              HighValue           - Largest allowed value
    696   1.1    jruoho  *
    697   1.1    jruoho  * RETURN:      Op if OK, otherwise NULL
    698   1.1    jruoho  *
    699   1.1    jruoho  * DESCRIPTION: Check integer for an allowable range
    700   1.1    jruoho  *
    701   1.1    jruoho  ******************************************************************************/
    702   1.1    jruoho 
    703   1.1    jruoho ACPI_PARSE_OBJECT *
    704   1.1    jruoho UtCheckIntegerRange (
    705   1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    706   1.1    jruoho     UINT32                  LowValue,
    707   1.1    jruoho     UINT32                  HighValue)
    708   1.1    jruoho {
    709   1.1    jruoho 
    710   1.1    jruoho     if (!Op)
    711   1.1    jruoho     {
    712   1.6  christos         return (NULL);
    713   1.1    jruoho     }
    714   1.1    jruoho 
    715   1.6  christos     if ((Op->Asl.Value.Integer < LowValue) ||
    716   1.6  christos         (Op->Asl.Value.Integer > HighValue))
    717   1.1    jruoho     {
    718  1.22  christos         snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "0x%X, allowable: 0x%X-0x%X",
    719   1.6  christos             (UINT32) Op->Asl.Value.Integer, LowValue, HighValue);
    720   1.1    jruoho 
    721  1.22  christos         AslError (ASL_ERROR, ASL_MSG_RANGE, Op, AslGbl_MsgBuffer);
    722   1.6  christos         return (NULL);
    723   1.1    jruoho     }
    724   1.1    jruoho 
    725   1.6  christos     return (Op);
    726   1.1    jruoho }
    727   1.1    jruoho 
    728   1.1    jruoho 
    729   1.1    jruoho /*******************************************************************************
    730   1.1    jruoho  *
    731   1.1    jruoho  * FUNCTION:    UtInternalizeName
    732   1.1    jruoho  *
    733   1.6  christos  * PARAMETERS:  ExternalName        - Name to convert
    734   1.6  christos  *              ConvertedName       - Where the converted name is returned
    735   1.1    jruoho  *
    736   1.1    jruoho  * RETURN:      Status
    737   1.1    jruoho  *
    738   1.1    jruoho  * DESCRIPTION: Convert an external (ASL) name to an internal (AML) name
    739   1.1    jruoho  *
    740   1.1    jruoho  ******************************************************************************/
    741   1.1    jruoho 
    742   1.1    jruoho ACPI_STATUS
    743   1.1    jruoho UtInternalizeName (
    744   1.1    jruoho     char                    *ExternalName,
    745   1.1    jruoho     char                    **ConvertedName)
    746   1.1    jruoho {
    747   1.1    jruoho     ACPI_NAMESTRING_INFO    Info;
    748   1.1    jruoho     ACPI_STATUS             Status;
    749   1.1    jruoho 
    750   1.1    jruoho 
    751   1.1    jruoho     if (!ExternalName)
    752   1.1    jruoho     {
    753   1.1    jruoho         return (AE_OK);
    754   1.1    jruoho     }
    755   1.1    jruoho 
    756   1.1    jruoho     /* Get the length of the new internal name */
    757   1.1    jruoho 
    758   1.1    jruoho     Info.ExternalName = ExternalName;
    759   1.1    jruoho     AcpiNsGetInternalNameLength (&Info);
    760   1.1    jruoho 
    761   1.9  christos     /* We need a segment to store the internal name */
    762   1.1    jruoho 
    763  1.19  christos     Info.InternalName = UtLocalCacheCalloc (Info.Length);
    764   1.1    jruoho 
    765   1.1    jruoho     /* Build the name */
    766   1.1    jruoho 
    767   1.1    jruoho     Status = AcpiNsBuildInternalName (&Info);
    768   1.1    jruoho     if (ACPI_FAILURE (Status))
    769   1.1    jruoho     {
    770   1.1    jruoho         return (Status);
    771   1.1    jruoho     }
    772   1.1    jruoho 
    773   1.1    jruoho     *ConvertedName = Info.InternalName;
    774   1.1    jruoho     return (AE_OK);
    775   1.1    jruoho }
    776   1.1    jruoho 
    777   1.1    jruoho 
    778   1.1    jruoho /*******************************************************************************
    779   1.1    jruoho  *
    780   1.1    jruoho  * FUNCTION:    UtPadNameWithUnderscores
    781   1.1    jruoho  *
    782   1.6  christos  * PARAMETERS:  NameSeg             - Input nameseg
    783   1.6  christos  *              PaddedNameSeg       - Output padded nameseg
    784   1.1    jruoho  *
    785   1.1    jruoho  * RETURN:      Padded nameseg.
    786   1.1    jruoho  *
    787   1.1    jruoho  * DESCRIPTION: Pads a NameSeg with underscores if necessary to form a full
    788   1.1    jruoho  *              ACPI_NAME.
    789   1.1    jruoho  *
    790   1.1    jruoho  ******************************************************************************/
    791   1.1    jruoho 
    792   1.1    jruoho static void
    793   1.1    jruoho UtPadNameWithUnderscores (
    794   1.1    jruoho     char                    *NameSeg,
    795   1.1    jruoho     char                    *PaddedNameSeg)
    796   1.1    jruoho {
    797   1.1    jruoho     UINT32                  i;
    798   1.1    jruoho 
    799   1.1    jruoho 
    800  1.23  christos     for (i = 0; (i < ACPI_NAMESEG_SIZE); i++)
    801   1.1    jruoho     {
    802   1.1    jruoho         if (*NameSeg)
    803   1.1    jruoho         {
    804   1.1    jruoho             *PaddedNameSeg = *NameSeg;
    805   1.1    jruoho             NameSeg++;
    806   1.1    jruoho         }
    807   1.1    jruoho         else
    808   1.1    jruoho         {
    809   1.1    jruoho             *PaddedNameSeg = '_';
    810   1.1    jruoho         }
    811  1.13  christos 
    812   1.1    jruoho         PaddedNameSeg++;
    813   1.1    jruoho     }
    814   1.1    jruoho }
    815   1.1    jruoho 
    816   1.1    jruoho 
    817   1.1    jruoho /*******************************************************************************
    818   1.1    jruoho  *
    819   1.1    jruoho  * FUNCTION:    UtAttachNameseg
    820   1.1    jruoho  *
    821   1.6  christos  * PARAMETERS:  Op                  - Parent parse node
    822   1.6  christos  *              Name                - Full ExternalName
    823   1.1    jruoho  *
    824   1.1    jruoho  * RETURN:      None; Sets the NameSeg field in parent node
    825   1.1    jruoho  *
    826   1.1    jruoho  * DESCRIPTION: Extract the last nameseg of the ExternalName and store it
    827   1.1    jruoho  *              in the NameSeg field of the Op.
    828   1.1    jruoho  *
    829   1.1    jruoho  ******************************************************************************/
    830   1.1    jruoho 
    831   1.1    jruoho static void
    832   1.1    jruoho UtAttachNameseg (
    833   1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    834   1.1    jruoho     char                    *Name)
    835   1.1    jruoho {
    836   1.1    jruoho     char                    *NameSeg;
    837   1.1    jruoho     char                    PaddedNameSeg[4];
    838   1.1    jruoho 
    839   1.1    jruoho 
    840   1.1    jruoho     if (!Name)
    841   1.1    jruoho     {
    842   1.1    jruoho         return;
    843   1.1    jruoho     }
    844   1.1    jruoho 
    845   1.1    jruoho     /* Look for the last dot in the namepath */
    846   1.1    jruoho 
    847   1.1    jruoho     NameSeg = strrchr (Name, '.');
    848   1.1    jruoho     if (NameSeg)
    849   1.1    jruoho     {
    850   1.1    jruoho         /* Found last dot, we have also found the final nameseg */
    851   1.1    jruoho 
    852   1.1    jruoho         NameSeg++;
    853   1.1    jruoho         UtPadNameWithUnderscores (NameSeg, PaddedNameSeg);
    854   1.1    jruoho     }
    855   1.1    jruoho     else
    856   1.1    jruoho     {
    857   1.1    jruoho         /* No dots in the namepath, there is only a single nameseg. */
    858   1.1    jruoho         /* Handle prefixes */
    859   1.1    jruoho 
    860   1.6  christos         while (ACPI_IS_ROOT_PREFIX (*Name) ||
    861   1.6  christos                ACPI_IS_PARENT_PREFIX (*Name))
    862   1.1    jruoho         {
    863   1.1    jruoho             Name++;
    864   1.1    jruoho         }
    865   1.1    jruoho 
    866   1.6  christos         /* Remaining string should be one single nameseg */
    867   1.1    jruoho 
    868   1.1    jruoho         UtPadNameWithUnderscores (Name, PaddedNameSeg);
    869   1.1    jruoho     }
    870   1.1    jruoho 
    871  1.23  christos     ACPI_COPY_NAMESEG (Op->Asl.NameSeg, PaddedNameSeg);
    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:    UtAttachNamepathToOwner
    878   1.1    jruoho  *
    879   1.6  christos  * PARAMETERS:  Op                  - Parent parse node
    880   1.6  christos  *              NameOp              - Node that contains the name
    881   1.1    jruoho  *
    882   1.1    jruoho  * RETURN:      Sets the ExternalName and Namepath in the parent node
    883   1.1    jruoho  *
    884   1.6  christos  * DESCRIPTION: Store the name in two forms in the parent node: The original
    885   1.1    jruoho  *              (external) name, and the internalized name that is used within
    886   1.1    jruoho  *              the ACPI namespace manager.
    887   1.1    jruoho  *
    888   1.1    jruoho  ******************************************************************************/
    889   1.1    jruoho 
    890   1.1    jruoho void
    891   1.1    jruoho UtAttachNamepathToOwner (
    892   1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    893   1.1    jruoho     ACPI_PARSE_OBJECT       *NameOp)
    894   1.1    jruoho {
    895   1.1    jruoho     ACPI_STATUS             Status;
    896   1.1    jruoho 
    897   1.1    jruoho 
    898   1.1    jruoho     /* Full external path */
    899   1.1    jruoho 
    900   1.1    jruoho     Op->Asl.ExternalName = NameOp->Asl.Value.String;
    901   1.1    jruoho 
    902   1.1    jruoho     /* Save the NameOp for possible error reporting later */
    903   1.1    jruoho 
    904   1.1    jruoho     Op->Asl.ParentMethod = (void *) NameOp;
    905   1.1    jruoho 
    906   1.1    jruoho     /* Last nameseg of the path */
    907   1.1    jruoho 
    908   1.1    jruoho     UtAttachNameseg (Op, Op->Asl.ExternalName);
    909   1.1    jruoho 
    910   1.1    jruoho     /* Create internalized path */
    911   1.1    jruoho 
    912   1.1    jruoho     Status = UtInternalizeName (NameOp->Asl.Value.String, &Op->Asl.Namepath);
    913   1.1    jruoho     if (ACPI_FAILURE (Status))
    914   1.1    jruoho     {
    915   1.1    jruoho         /* TBD: abort on no memory */
    916   1.1    jruoho     }
    917   1.1    jruoho }
    918   1.1    jruoho 
    919   1.1    jruoho 
    920   1.1    jruoho /*******************************************************************************
    921   1.1    jruoho  *
    922  1.24  christos  * FUNCTION:    UtNameContainsAllPrefix
    923  1.24  christos  *
    924  1.24  christos  * PARAMETERS:  Op                  - Op containing NameString
    925  1.24  christos  *
    926  1.24  christos  * RETURN:      NameString consists of all ^ characters
    927  1.24  christos  *
    928  1.24  christos  * DESCRIPTION: Determine if this Op contains a name segment that consists of
    929  1.24  christos  *              all '^' characters.
    930  1.24  christos  *
    931  1.24  christos  ******************************************************************************/
    932  1.24  christos 
    933  1.24  christos BOOLEAN
    934  1.24  christos UtNameContainsAllPrefix (
    935  1.24  christos     ACPI_PARSE_OBJECT       *Op)
    936  1.24  christos {
    937  1.24  christos     UINT32                  Length = Op->Asl.AmlLength;
    938  1.24  christos     UINT32                  i;
    939  1.24  christos 
    940  1.24  christos     for (i = 0; i < Length; i++)
    941  1.24  christos     {
    942  1.24  christos         if (Op->Asl.Value.String[i] != '^')
    943  1.24  christos         {
    944  1.24  christos             return (FALSE);
    945  1.24  christos         }
    946  1.24  christos     }
    947  1.24  christos 
    948  1.24  christos     return (TRUE);
    949  1.24  christos }
    950  1.24  christos 
    951  1.24  christos /*******************************************************************************
    952  1.24  christos  *
    953   1.1    jruoho  * FUNCTION:    UtDoConstant
    954   1.1    jruoho  *
    955  1.18  christos  * PARAMETERS:  String              - Hex/Decimal/Octal
    956   1.1    jruoho  *
    957   1.1    jruoho  * RETURN:      Converted Integer
    958   1.1    jruoho  *
    959  1.18  christos  * DESCRIPTION: Convert a string to an integer, with overflow/error checking.
    960   1.1    jruoho  *
    961   1.1    jruoho  ******************************************************************************/
    962   1.1    jruoho 
    963   1.1    jruoho UINT64
    964   1.1    jruoho UtDoConstant (
    965   1.1    jruoho     char                    *String)
    966   1.1    jruoho {
    967   1.1    jruoho     ACPI_STATUS             Status;
    968  1.18  christos     UINT64                  ConvertedInteger;
    969   1.1    jruoho     char                    ErrBuf[64];
    970   1.1    jruoho 
    971   1.1    jruoho 
    972  1.18  christos     Status = AcpiUtStrtoul64 (String, &ConvertedInteger);
    973   1.1    jruoho     if (ACPI_FAILURE (Status))
    974   1.1    jruoho     {
    975  1.18  christos         snprintf (ErrBuf, sizeof(ErrBuf), "While creating 64-bit constant: %s\n",
    976   1.1    jruoho             AcpiFormatException (Status));
    977  1.18  christos 
    978  1.22  christos         AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, AslGbl_CurrentLineNumber,
    979  1.22  christos             AslGbl_LogicalLineNumber, AslGbl_CurrentLineOffset,
    980  1.22  christos             AslGbl_CurrentColumn, AslGbl_Files[ASL_FILE_INPUT].Filename, ErrBuf);
    981   1.1    jruoho     }
    982   1.1    jruoho 
    983  1.18  christos     return (ConvertedInteger);
    984   1.1    jruoho }
    985  1.24  christos 
    986  1.24  christos 
    987  1.24  christos /******************************************************************************
    988  1.24  christos  *
    989  1.24  christos  * FUNCTION:    AcpiUtStrdup
    990  1.24  christos  *
    991  1.24  christos  * PARAMETERS:  String1             - string to duplicate
    992  1.24  christos  *
    993  1.24  christos  * RETURN:      int that signifies string relationship. Zero means strings
    994  1.24  christos  *              are equal.
    995  1.24  christos  *
    996  1.24  christos  * DESCRIPTION: Duplicate the string using UtCacheAlloc to avoid manual memory
    997  1.24  christos  *              reclamation.
    998  1.24  christos  *
    999  1.24  christos  ******************************************************************************/
   1000  1.24  christos 
   1001  1.24  christos char *
   1002  1.24  christos AcpiUtStrdup (
   1003  1.24  christos     char                    *String)
   1004  1.24  christos {
   1005  1.24  christos     char                    *NewString = (char *) UtLocalCalloc (strlen (String) + 1);
   1006  1.24  christos 
   1007  1.24  christos 
   1008  1.24  christos     strcpy (NewString, String);
   1009  1.24  christos     return (NewString);
   1010  1.24  christos }
   1011  1.24  christos 
   1012  1.24  christos 
   1013  1.24  christos /******************************************************************************
   1014  1.24  christos  *
   1015  1.24  christos  * FUNCTION:    AcpiUtStrcat
   1016  1.24  christos  *
   1017  1.24  christos  * PARAMETERS:  String1
   1018  1.24  christos  *              String2
   1019  1.24  christos  *
   1020  1.24  christos  * RETURN:      New string with String1 concatenated with String2
   1021  1.24  christos  *
   1022  1.24  christos  * DESCRIPTION: Concatenate string1 and string2
   1023  1.24  christos  *
   1024  1.24  christos  ******************************************************************************/
   1025  1.24  christos 
   1026  1.24  christos char *
   1027  1.24  christos AcpiUtStrcat (
   1028  1.24  christos     char                    *String1,
   1029  1.24  christos     char                    *String2)
   1030  1.24  christos {
   1031  1.24  christos     UINT32                  String1Length = strlen (String1);
   1032  1.24  christos     char                    *NewString = (char *) UtLocalCalloc (strlen (String1) + strlen (String2) + 1);
   1033  1.24  christos 
   1034  1.24  christos     strcpy (NewString, String1);
   1035  1.24  christos     strcpy (NewString + String1Length, String2);
   1036  1.24  christos     return (NewString);
   1037  1.24  christos }
   1038