10b94ba42SJung-uk Kim /****************************************************************************** 20b94ba42SJung-uk Kim * 30b94ba42SJung-uk Kim * Module Name: dtexpress.c - Support for integer expressions and labels 40b94ba42SJung-uk Kim * 50b94ba42SJung-uk Kim *****************************************************************************/ 60b94ba42SJung-uk Kim 7*0d84335fSJung-uk Kim /****************************************************************************** 8*0d84335fSJung-uk Kim * 9*0d84335fSJung-uk Kim * 1. Copyright Notice 10*0d84335fSJung-uk Kim * 11*0d84335fSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 120b94ba42SJung-uk Kim * All rights reserved. 130b94ba42SJung-uk Kim * 14*0d84335fSJung-uk Kim * 2. License 15*0d84335fSJung-uk Kim * 16*0d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 17*0d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 18*0d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 19*0d84335fSJung-uk Kim * property rights. 20*0d84335fSJung-uk Kim * 21*0d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*0d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 23*0d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*0d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 25*0d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 26*0d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 27*0d84335fSJung-uk Kim * 28*0d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*0d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 30*0d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 31*0d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 32*0d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 33*0d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 34*0d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 35*0d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 36*0d84335fSJung-uk Kim * 37*0d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 38*0d84335fSJung-uk Kim * conditions are met: 39*0d84335fSJung-uk Kim * 40*0d84335fSJung-uk Kim * 3. Conditions 41*0d84335fSJung-uk Kim * 42*0d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 44*0d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 45*0d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 46*0d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 47*0d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 48*0d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 49*0d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 50*0d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 51*0d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 52*0d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 53*0d84335fSJung-uk Kim * 54*0d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 56*0d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 57*0d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 58*0d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 59*0d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 60*0d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 61*0d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 62*0d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 63*0d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 64*0d84335fSJung-uk Kim * make. 65*0d84335fSJung-uk Kim * 66*0d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*0d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 68*0d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 69*0d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 70*0d84335fSJung-uk Kim * distribution. 71*0d84335fSJung-uk Kim * 72*0d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 73*0d84335fSJung-uk Kim * Intel Code. 74*0d84335fSJung-uk Kim * 75*0d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*0d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 77*0d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 78*0d84335fSJung-uk Kim * without prior written authorization from Intel. 79*0d84335fSJung-uk Kim * 80*0d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 81*0d84335fSJung-uk Kim * 82*0d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*0d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*0d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*0d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*0d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*0d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*0d84335fSJung-uk Kim * PARTICULAR PURPOSE. 89*0d84335fSJung-uk Kim * 90*0d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*0d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*0d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*0d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*0d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*0d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*0d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*0d84335fSJung-uk Kim * LIMITED REMEDY. 98*0d84335fSJung-uk Kim * 99*0d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*0d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 101*0d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 102*0d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 103*0d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 104*0d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 105*0d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 106*0d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 107*0d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*0d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 109*0d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 110*0d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 111*0d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 112*0d84335fSJung-uk Kim * such license, approval or letter. 113*0d84335fSJung-uk Kim * 114*0d84335fSJung-uk Kim ***************************************************************************** 115*0d84335fSJung-uk Kim * 116*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 117*0d84335fSJung-uk Kim * following license: 118*0d84335fSJung-uk Kim * 1190b94ba42SJung-uk Kim * Redistribution and use in source and binary forms, with or without 1200b94ba42SJung-uk Kim * modification, are permitted provided that the following conditions 1210b94ba42SJung-uk Kim * are met: 1220b94ba42SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 1230b94ba42SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 1240b94ba42SJung-uk Kim * without modification. 1250b94ba42SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1260b94ba42SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 1270b94ba42SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 1280b94ba42SJung-uk Kim * including a substantially similar Disclaimer requirement for further 1290b94ba42SJung-uk Kim * binary redistribution. 1300b94ba42SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 1310b94ba42SJung-uk Kim * of any contributors may be used to endorse or promote products derived 1320b94ba42SJung-uk Kim * from this software without specific prior written permission. 1330b94ba42SJung-uk Kim * 134*0d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135*0d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136*0d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137*0d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138*0d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139*0d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140*0d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141*0d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142*0d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143*0d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144*0d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145*0d84335fSJung-uk Kim * 146*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1470b94ba42SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 1480b94ba42SJung-uk Kim * Software Foundation. 1490b94ba42SJung-uk Kim * 150*0d84335fSJung-uk Kim *****************************************************************************/ 1510b94ba42SJung-uk Kim 1520b94ba42SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 1530b94ba42SJung-uk Kim #include <contrib/dev/acpica/compiler/dtcompiler.h> 154d052a1ccSJung-uk Kim #include "dtparser.y.h" 1550b94ba42SJung-uk Kim 1560b94ba42SJung-uk Kim #define _COMPONENT DT_COMPILER 1570b94ba42SJung-uk Kim ACPI_MODULE_NAME ("dtexpress") 1580b94ba42SJung-uk Kim 1590b94ba42SJung-uk Kim 1600b94ba42SJung-uk Kim /* Local prototypes */ 1610b94ba42SJung-uk Kim 1620b94ba42SJung-uk Kim static void 1630b94ba42SJung-uk Kim DtInsertLabelField ( 1640b94ba42SJung-uk Kim DT_FIELD *Field); 1650b94ba42SJung-uk Kim 1660b94ba42SJung-uk Kim static DT_FIELD * 1670b94ba42SJung-uk Kim DtLookupLabel ( 1680b94ba42SJung-uk Kim char *Name); 1690b94ba42SJung-uk Kim 170d052a1ccSJung-uk Kim /* Global used for errors during parse and related functions */ 171d052a1ccSJung-uk Kim 172d052a1ccSJung-uk Kim DT_FIELD *Gbl_CurrentField; 173d052a1ccSJung-uk Kim 1740b94ba42SJung-uk Kim 1750b94ba42SJung-uk Kim /****************************************************************************** 1760b94ba42SJung-uk Kim * 1770b94ba42SJung-uk Kim * FUNCTION: DtResolveIntegerExpression 1780b94ba42SJung-uk Kim * 1790b94ba42SJung-uk Kim * PARAMETERS: Field - Field object with Integer expression 180d052a1ccSJung-uk Kim * ReturnValue - Where the integer is returned 1810b94ba42SJung-uk Kim * 182d052a1ccSJung-uk Kim * RETURN: Status, and the resolved 64-bit integer value 1830b94ba42SJung-uk Kim * 1840b94ba42SJung-uk Kim * DESCRIPTION: Resolve an integer expression to a single value. Supports 185d052a1ccSJung-uk Kim * both integer constants and labels. 1860b94ba42SJung-uk Kim * 1870b94ba42SJung-uk Kim *****************************************************************************/ 1880b94ba42SJung-uk Kim 189d052a1ccSJung-uk Kim ACPI_STATUS 1900b94ba42SJung-uk Kim DtResolveIntegerExpression ( 191d052a1ccSJung-uk Kim DT_FIELD *Field, 192d052a1ccSJung-uk Kim UINT64 *ReturnValue) 1930b94ba42SJung-uk Kim { 194d052a1ccSJung-uk Kim UINT64 Result; 1950b94ba42SJung-uk Kim 1960b94ba42SJung-uk Kim 1970b94ba42SJung-uk Kim DbgPrint (ASL_DEBUG_OUTPUT, "Full Integer expression: %s\n", 1980b94ba42SJung-uk Kim Field->Value); 1990b94ba42SJung-uk Kim 200d052a1ccSJung-uk Kim Gbl_CurrentField = Field; 2010b94ba42SJung-uk Kim 202d052a1ccSJung-uk Kim Result = DtEvaluateExpression (Field->Value); 203d052a1ccSJung-uk Kim *ReturnValue = Result; 204d052a1ccSJung-uk Kim return (AE_OK); 2050b94ba42SJung-uk Kim } 2060b94ba42SJung-uk Kim 2070b94ba42SJung-uk Kim 208d052a1ccSJung-uk Kim /****************************************************************************** 209d052a1ccSJung-uk Kim * 210d052a1ccSJung-uk Kim * FUNCTION: DtDoOperator 211d052a1ccSJung-uk Kim * 212d052a1ccSJung-uk Kim * PARAMETERS: LeftValue - First 64-bit operand 213d052a1ccSJung-uk Kim * Operator - Parse token for the operator (EXPOP_*) 214d052a1ccSJung-uk Kim * RightValue - Second 64-bit operand 215d052a1ccSJung-uk Kim * 216d052a1ccSJung-uk Kim * RETURN: 64-bit result of the requested operation 217d052a1ccSJung-uk Kim * 218d052a1ccSJung-uk Kim * DESCRIPTION: Perform the various 64-bit integer math functions 219d052a1ccSJung-uk Kim * 220d052a1ccSJung-uk Kim *****************************************************************************/ 221d052a1ccSJung-uk Kim 222d052a1ccSJung-uk Kim UINT64 223d052a1ccSJung-uk Kim DtDoOperator ( 224d052a1ccSJung-uk Kim UINT64 LeftValue, 225d052a1ccSJung-uk Kim UINT32 Operator, 226d052a1ccSJung-uk Kim UINT64 RightValue) 2270b94ba42SJung-uk Kim { 228d052a1ccSJung-uk Kim UINT64 Result; 2290b94ba42SJung-uk Kim 2300b94ba42SJung-uk Kim 2310b94ba42SJung-uk Kim /* Perform the requested operation */ 2320b94ba42SJung-uk Kim 233d052a1ccSJung-uk Kim switch (Operator) 2340b94ba42SJung-uk Kim { 235d052a1ccSJung-uk Kim case EXPOP_ONES_COMPLIMENT: 236a9d8d09cSJung-uk Kim 237d052a1ccSJung-uk Kim Result = ~RightValue; 2380b94ba42SJung-uk Kim break; 2390b94ba42SJung-uk Kim 240d052a1ccSJung-uk Kim case EXPOP_LOGICAL_NOT: 241a9d8d09cSJung-uk Kim 242d052a1ccSJung-uk Kim Result = !RightValue; 2430b94ba42SJung-uk Kim break; 2440b94ba42SJung-uk Kim 245d052a1ccSJung-uk Kim case EXPOP_MULTIPLY: 246a9d8d09cSJung-uk Kim 247d052a1ccSJung-uk Kim Result = LeftValue * RightValue; 2480b94ba42SJung-uk Kim break; 2490b94ba42SJung-uk Kim 250d052a1ccSJung-uk Kim case EXPOP_DIVIDE: 251a9d8d09cSJung-uk Kim 252d052a1ccSJung-uk Kim if (!RightValue) 2530b94ba42SJung-uk Kim { 254d052a1ccSJung-uk Kim DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, 2554c52cad2SJung-uk Kim Gbl_CurrentField, NULL); 2560b94ba42SJung-uk Kim return (0); 2570b94ba42SJung-uk Kim } 258f8146b88SJung-uk Kim 259d052a1ccSJung-uk Kim Result = LeftValue / RightValue; 2600b94ba42SJung-uk Kim break; 2610b94ba42SJung-uk Kim 262d052a1ccSJung-uk Kim case EXPOP_MODULO: 263a9d8d09cSJung-uk Kim 264d052a1ccSJung-uk Kim if (!RightValue) 2650b94ba42SJung-uk Kim { 266d052a1ccSJung-uk Kim DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, 2674c52cad2SJung-uk Kim Gbl_CurrentField, NULL); 2680b94ba42SJung-uk Kim return (0); 2690b94ba42SJung-uk Kim } 270f8146b88SJung-uk Kim 271d052a1ccSJung-uk Kim Result = LeftValue % RightValue; 272d052a1ccSJung-uk Kim break; 273d052a1ccSJung-uk Kim 274d052a1ccSJung-uk Kim case EXPOP_ADD: 275d052a1ccSJung-uk Kim Result = LeftValue + RightValue; 276d052a1ccSJung-uk Kim break; 277d052a1ccSJung-uk Kim 278d052a1ccSJung-uk Kim case EXPOP_SUBTRACT: 279a9d8d09cSJung-uk Kim 280d052a1ccSJung-uk Kim Result = LeftValue - RightValue; 281d052a1ccSJung-uk Kim break; 282d052a1ccSJung-uk Kim 283d052a1ccSJung-uk Kim case EXPOP_SHIFT_RIGHT: 284a9d8d09cSJung-uk Kim 285d052a1ccSJung-uk Kim Result = LeftValue >> RightValue; 286d052a1ccSJung-uk Kim break; 287d052a1ccSJung-uk Kim 288d052a1ccSJung-uk Kim case EXPOP_SHIFT_LEFT: 289a9d8d09cSJung-uk Kim 290d052a1ccSJung-uk Kim Result = LeftValue << RightValue; 291d052a1ccSJung-uk Kim break; 292d052a1ccSJung-uk Kim 293d052a1ccSJung-uk Kim case EXPOP_LESS: 294a9d8d09cSJung-uk Kim 295d052a1ccSJung-uk Kim Result = LeftValue < RightValue; 296d052a1ccSJung-uk Kim break; 297d052a1ccSJung-uk Kim 298d052a1ccSJung-uk Kim case EXPOP_GREATER: 299a9d8d09cSJung-uk Kim 300d052a1ccSJung-uk Kim Result = LeftValue > RightValue; 301d052a1ccSJung-uk Kim break; 302d052a1ccSJung-uk Kim 303d052a1ccSJung-uk Kim case EXPOP_LESS_EQUAL: 304a9d8d09cSJung-uk Kim 305d052a1ccSJung-uk Kim Result = LeftValue <= RightValue; 306d052a1ccSJung-uk Kim break; 307d052a1ccSJung-uk Kim 308d052a1ccSJung-uk Kim case EXPOP_GREATER_EQUAL: 309a9d8d09cSJung-uk Kim 310d052a1ccSJung-uk Kim Result = LeftValue >= RightValue; 311d052a1ccSJung-uk Kim break; 312d052a1ccSJung-uk Kim 313d052a1ccSJung-uk Kim case EXPOP_EQUAL: 314a9d8d09cSJung-uk Kim 3154c52cad2SJung-uk Kim Result = LeftValue == RightValue; 316d052a1ccSJung-uk Kim break; 317d052a1ccSJung-uk Kim 318d052a1ccSJung-uk Kim case EXPOP_NOT_EQUAL: 319a9d8d09cSJung-uk Kim 320d052a1ccSJung-uk Kim Result = LeftValue != RightValue; 321d052a1ccSJung-uk Kim break; 322d052a1ccSJung-uk Kim 323d052a1ccSJung-uk Kim case EXPOP_AND: 324a9d8d09cSJung-uk Kim 325d052a1ccSJung-uk Kim Result = LeftValue & RightValue; 326d052a1ccSJung-uk Kim break; 327d052a1ccSJung-uk Kim 328d052a1ccSJung-uk Kim case EXPOP_XOR: 329a9d8d09cSJung-uk Kim 330d052a1ccSJung-uk Kim Result = LeftValue ^ RightValue; 331d052a1ccSJung-uk Kim break; 332d052a1ccSJung-uk Kim 333d052a1ccSJung-uk Kim case EXPOP_OR: 334a9d8d09cSJung-uk Kim 335d052a1ccSJung-uk Kim Result = LeftValue | RightValue; 336d052a1ccSJung-uk Kim break; 337d052a1ccSJung-uk Kim 338d052a1ccSJung-uk Kim case EXPOP_LOGICAL_AND: 339a9d8d09cSJung-uk Kim 340d052a1ccSJung-uk Kim Result = LeftValue && RightValue; 341d052a1ccSJung-uk Kim break; 342d052a1ccSJung-uk Kim 343d052a1ccSJung-uk Kim case EXPOP_LOGICAL_OR: 344a9d8d09cSJung-uk Kim 345d052a1ccSJung-uk Kim Result = LeftValue || RightValue; 3460b94ba42SJung-uk Kim break; 3470b94ba42SJung-uk Kim 3480b94ba42SJung-uk Kim default: 3490b94ba42SJung-uk Kim 3500b94ba42SJung-uk Kim /* Unknown operator */ 3510b94ba42SJung-uk Kim 352d052a1ccSJung-uk Kim DtFatal (ASL_MSG_INVALID_EXPRESSION, 3534c52cad2SJung-uk Kim Gbl_CurrentField, NULL); 354d052a1ccSJung-uk Kim return (0); 3550b94ba42SJung-uk Kim } 3560b94ba42SJung-uk Kim 357d052a1ccSJung-uk Kim DbgPrint (ASL_DEBUG_OUTPUT, 3584c52cad2SJung-uk Kim "IntegerEval: (%8.8X%8.8X %s %8.8X%8.8X) = %8.8X%8.8X\n", 359d052a1ccSJung-uk Kim ACPI_FORMAT_UINT64 (LeftValue), 360d052a1ccSJung-uk Kim DtGetOpName (Operator), 361d052a1ccSJung-uk Kim ACPI_FORMAT_UINT64 (RightValue), 362d052a1ccSJung-uk Kim ACPI_FORMAT_UINT64 (Result)); 363d052a1ccSJung-uk Kim 364d052a1ccSJung-uk Kim return (Result); 3650b94ba42SJung-uk Kim } 3660b94ba42SJung-uk Kim 3670b94ba42SJung-uk Kim 3680b94ba42SJung-uk Kim /****************************************************************************** 3690b94ba42SJung-uk Kim * 370d052a1ccSJung-uk Kim * FUNCTION: DtResolveLabel 3710b94ba42SJung-uk Kim * 372d052a1ccSJung-uk Kim * PARAMETERS: LabelString - Contains the label 3730b94ba42SJung-uk Kim * 374d052a1ccSJung-uk Kim * RETURN: Table offset associated with the label 3750b94ba42SJung-uk Kim * 376d052a1ccSJung-uk Kim * DESCRIPTION: Lookup a lable and return its value. 3770b94ba42SJung-uk Kim * 3780b94ba42SJung-uk Kim *****************************************************************************/ 3790b94ba42SJung-uk Kim 380d052a1ccSJung-uk Kim UINT64 381d052a1ccSJung-uk Kim DtResolveLabel ( 382d052a1ccSJung-uk Kim char *LabelString) 3830b94ba42SJung-uk Kim { 3840b94ba42SJung-uk Kim DT_FIELD *LabelField; 3850b94ba42SJung-uk Kim 3860b94ba42SJung-uk Kim 387d052a1ccSJung-uk Kim DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Label: %s\n", LabelString); 3880b94ba42SJung-uk Kim 3890b94ba42SJung-uk Kim /* Resolve a label reference to an integer (table offset) */ 3900b94ba42SJung-uk Kim 391d052a1ccSJung-uk Kim if (*LabelString != '$') 3920b94ba42SJung-uk Kim { 393d052a1ccSJung-uk Kim return (0); 394d052a1ccSJung-uk Kim } 395d052a1ccSJung-uk Kim 396d052a1ccSJung-uk Kim LabelField = DtLookupLabel (LabelString); 3970b94ba42SJung-uk Kim if (!LabelField) 3980b94ba42SJung-uk Kim { 399d052a1ccSJung-uk Kim DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL, 400d052a1ccSJung-uk Kim Gbl_CurrentField, LabelString); 4010b94ba42SJung-uk Kim return (0); 4020b94ba42SJung-uk Kim } 4030b94ba42SJung-uk Kim 4040b94ba42SJung-uk Kim /* All we need from the label is the offset in the table */ 4050b94ba42SJung-uk Kim 406d052a1ccSJung-uk Kim DbgPrint (ASL_DEBUG_OUTPUT, "Resolved Label: 0x%8.8X\n", 407d052a1ccSJung-uk Kim LabelField->TableOffset); 4080b94ba42SJung-uk Kim 409d052a1ccSJung-uk Kim return (LabelField->TableOffset); 4100b94ba42SJung-uk Kim } 4110b94ba42SJung-uk Kim 4120b94ba42SJung-uk Kim 4130b94ba42SJung-uk Kim /****************************************************************************** 4140b94ba42SJung-uk Kim * 4150b94ba42SJung-uk Kim * FUNCTION: DtDetectAllLabels 4160b94ba42SJung-uk Kim * 4170b94ba42SJung-uk Kim * PARAMETERS: FieldList - Field object at start of generic list 4180b94ba42SJung-uk Kim * 4190b94ba42SJung-uk Kim * RETURN: None 4200b94ba42SJung-uk Kim * 4210b94ba42SJung-uk Kim * DESCRIPTION: Detect all labels in a list of "generic" opcodes (such as 4220b94ba42SJung-uk Kim * a UEFI table.) and insert them into the global label list. 4230b94ba42SJung-uk Kim * 4240b94ba42SJung-uk Kim *****************************************************************************/ 4250b94ba42SJung-uk Kim 4260b94ba42SJung-uk Kim void 4270b94ba42SJung-uk Kim DtDetectAllLabels ( 4280b94ba42SJung-uk Kim DT_FIELD *FieldList) 4290b94ba42SJung-uk Kim { 4300b94ba42SJung-uk Kim ACPI_DMTABLE_INFO *Info; 4310b94ba42SJung-uk Kim DT_FIELD *GenericField; 4320b94ba42SJung-uk Kim UINT32 TableOffset; 4330b94ba42SJung-uk Kim 4340b94ba42SJung-uk Kim 4350b94ba42SJung-uk Kim TableOffset = Gbl_CurrentTableOffset; 4360b94ba42SJung-uk Kim GenericField = FieldList; 4370b94ba42SJung-uk Kim 4380b94ba42SJung-uk Kim /* 4390b94ba42SJung-uk Kim * Process all "Label:" fields within the parse tree. We need 4400b94ba42SJung-uk Kim * to know the offsets for all labels before we can compile 4410b94ba42SJung-uk Kim * the parse tree in order to handle forward references. Traverse 4420b94ba42SJung-uk Kim * tree and get/set all field lengths of all operators in order to 4430b94ba42SJung-uk Kim * determine the label offsets. 4440b94ba42SJung-uk Kim */ 4450b94ba42SJung-uk Kim while (GenericField) 4460b94ba42SJung-uk Kim { 4470b94ba42SJung-uk Kim Info = DtGetGenericTableInfo (GenericField->Name); 4480b94ba42SJung-uk Kim if (Info) 4490b94ba42SJung-uk Kim { 4500b94ba42SJung-uk Kim /* Maintain table offsets */ 4510b94ba42SJung-uk Kim 4520b94ba42SJung-uk Kim GenericField->TableOffset = TableOffset; 4530b94ba42SJung-uk Kim TableOffset += DtGetFieldLength (GenericField, Info); 4540b94ba42SJung-uk Kim 4550b94ba42SJung-uk Kim /* Insert all labels in the global label list */ 4560b94ba42SJung-uk Kim 4570b94ba42SJung-uk Kim if (Info->Opcode == ACPI_DMT_LABEL) 4580b94ba42SJung-uk Kim { 4590b94ba42SJung-uk Kim DtInsertLabelField (GenericField); 4600b94ba42SJung-uk Kim } 4610b94ba42SJung-uk Kim } 4620b94ba42SJung-uk Kim 4630b94ba42SJung-uk Kim GenericField = GenericField->Next; 4640b94ba42SJung-uk Kim } 4650b94ba42SJung-uk Kim } 4660b94ba42SJung-uk Kim 4670b94ba42SJung-uk Kim 4680b94ba42SJung-uk Kim /****************************************************************************** 4690b94ba42SJung-uk Kim * 4700b94ba42SJung-uk Kim * FUNCTION: DtInsertLabelField 4710b94ba42SJung-uk Kim * 4720b94ba42SJung-uk Kim * PARAMETERS: Field - Field object with Label to be inserted 4730b94ba42SJung-uk Kim * 4740b94ba42SJung-uk Kim * RETURN: None 4750b94ba42SJung-uk Kim * 4760b94ba42SJung-uk Kim * DESCRIPTION: Insert a label field into the global label list 4770b94ba42SJung-uk Kim * 4780b94ba42SJung-uk Kim *****************************************************************************/ 4790b94ba42SJung-uk Kim 4800b94ba42SJung-uk Kim static void 4810b94ba42SJung-uk Kim DtInsertLabelField ( 4820b94ba42SJung-uk Kim DT_FIELD *Field) 4830b94ba42SJung-uk Kim { 4840b94ba42SJung-uk Kim 4850b94ba42SJung-uk Kim DbgPrint (ASL_DEBUG_OUTPUT, 4860b94ba42SJung-uk Kim "DtInsertLabelField: Found Label : %s at output table offset %X\n", 4870b94ba42SJung-uk Kim Field->Value, Field->TableOffset); 4880b94ba42SJung-uk Kim 4890b94ba42SJung-uk Kim Field->NextLabel = Gbl_LabelList; 4900b94ba42SJung-uk Kim Gbl_LabelList = Field; 4910b94ba42SJung-uk Kim } 4920b94ba42SJung-uk Kim 4930b94ba42SJung-uk Kim 4940b94ba42SJung-uk Kim /****************************************************************************** 4950b94ba42SJung-uk Kim * 4960b94ba42SJung-uk Kim * FUNCTION: DtLookupLabel 4970b94ba42SJung-uk Kim * 4980b94ba42SJung-uk Kim * PARAMETERS: Name - Label to be resolved 4990b94ba42SJung-uk Kim * 5000b94ba42SJung-uk Kim * RETURN: Field object associated with the label 5010b94ba42SJung-uk Kim * 5020b94ba42SJung-uk Kim * DESCRIPTION: Lookup a label in the global label list. Used during the 5030b94ba42SJung-uk Kim * resolution of integer expressions. 5040b94ba42SJung-uk Kim * 5050b94ba42SJung-uk Kim *****************************************************************************/ 5060b94ba42SJung-uk Kim 5070b94ba42SJung-uk Kim static DT_FIELD * 5080b94ba42SJung-uk Kim DtLookupLabel ( 5090b94ba42SJung-uk Kim char *Name) 5100b94ba42SJung-uk Kim { 5110b94ba42SJung-uk Kim DT_FIELD *LabelField; 5120b94ba42SJung-uk Kim 5130b94ba42SJung-uk Kim 5140b94ba42SJung-uk Kim /* Skip a leading $ */ 5150b94ba42SJung-uk Kim 5160b94ba42SJung-uk Kim if (*Name == '$') 5170b94ba42SJung-uk Kim { 5180b94ba42SJung-uk Kim Name++; 5190b94ba42SJung-uk Kim } 5200b94ba42SJung-uk Kim 5210b94ba42SJung-uk Kim /* Search global list */ 5220b94ba42SJung-uk Kim 5230b94ba42SJung-uk Kim LabelField = Gbl_LabelList; 5240b94ba42SJung-uk Kim while (LabelField) 5250b94ba42SJung-uk Kim { 5265ef50723SJung-uk Kim if (!strcmp (Name, LabelField->Value)) 5270b94ba42SJung-uk Kim { 5280b94ba42SJung-uk Kim return (LabelField); 5290b94ba42SJung-uk Kim } 530f8146b88SJung-uk Kim 5310b94ba42SJung-uk Kim LabelField = LabelField->NextLabel; 5320b94ba42SJung-uk Kim } 5330b94ba42SJung-uk Kim 5340b94ba42SJung-uk Kim return (NULL); 5350b94ba42SJung-uk Kim } 536