1 NoEcho(' 2 /****************************************************************************** 3 * 4 * Module Name: aslrules.y - Main Bison/Yacc production rules 5 * - Keep this file synched with the 6 * CvParseOpBlockType function in cvcompiler.c 7 * 8 *****************************************************************************/ 9 10 /****************************************************************************** 11 * 12 * 1. Copyright Notice 13 * 14 * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. 15 * All rights reserved. 16 * 17 * 2. License 18 * 19 * 2.1. This is your license from Intel Corp. under its intellectual property 20 * rights. You may have additional license terms from the party that provided 21 * you this software, covering your right to use that party's intellectual 22 * property rights. 23 * 24 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 25 * copy of the source code appearing in this file ("Covered Code") an 26 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 27 * base code distributed originally by Intel ("Original Intel Code") to copy, 28 * make derivatives, distribute, use and display any portion of the Covered 29 * Code in any form, with the right to sublicense such rights; and 30 * 31 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 32 * license (with the right to sublicense), under only those claims of Intel 33 * patents that are infringed by the Original Intel Code, to make, use, sell, 34 * offer to sell, and import the Covered Code and derivative works thereof 35 * solely to the minimum extent necessary to exercise the above copyright 36 * license, and in no event shall the patent license extend to any additions 37 * to or modifications of the Original Intel Code. No other license or right 38 * is granted directly or by implication, estoppel or otherwise; 39 * 40 * The above copyright and patent license is granted only if the following 41 * conditions are met: 42 * 43 * 3. Conditions 44 * 45 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 46 * Redistribution of source code of any substantial portion of the Covered 47 * Code or modification with rights to further distribute source must include 48 * the above Copyright Notice, the above License, this list of Conditions, 49 * and the following Disclaimer and Export Compliance provision. In addition, 50 * Licensee must cause all Covered Code to which Licensee contributes to 51 * contain a file documenting the changes Licensee made to create that Covered 52 * Code and the date of any change. Licensee must include in that file the 53 * documentation of any changes made by any predecessor Licensee. Licensee 54 * must include a prominent statement that the modification is derived, 55 * directly or indirectly, from Original Intel Code. 56 * 57 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 58 * Redistribution of source code of any substantial portion of the Covered 59 * Code or modification without rights to further distribute source must 60 * include the following Disclaimer and Export Compliance provision in the 61 * documentation and/or other materials provided with distribution. In 62 * addition, Licensee may not authorize further sublicense of source of any 63 * portion of the Covered Code, and must include terms to the effect that the 64 * license from Licensee to its licensee is limited to the intellectual 65 * property embodied in the software Licensee provides to its licensee, and 66 * not to intellectual property embodied in modifications its licensee may 67 * make. 68 * 69 * 3.3. Redistribution of Executable. Redistribution in executable form of any 70 * substantial portion of the Covered Code or modification must reproduce the 71 * above Copyright Notice, and the following Disclaimer and Export Compliance 72 * provision in the documentation and/or other materials provided with the 73 * distribution. 74 * 75 * 3.4. Intel retains all right, title, and interest in and to the Original 76 * Intel Code. 77 * 78 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 79 * Intel shall be used in advertising or otherwise to promote the sale, use or 80 * other dealings in products derived from or relating to the Covered Code 81 * without prior written authorization from Intel. 82 * 83 * 4. Disclaimer and Export Compliance 84 * 85 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 86 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 87 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 88 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 89 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 90 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 91 * PARTICULAR PURPOSE. 92 * 93 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 94 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 95 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 96 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 97 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 98 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 99 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 100 * LIMITED REMEDY. 101 * 102 * 4.3. Licensee shall not export, either directly or indirectly, any of this 103 * software or system incorporating such software without first obtaining any 104 * required license or other approval from the U. S. Department of Commerce or 105 * any other agency or department of the United States Government. In the 106 * event Licensee exports any such software from the United States or 107 * re-exports any such software from a foreign destination, Licensee shall 108 * ensure that the distribution and export/re-export of the software is in 109 * compliance with all laws, regulations, orders, or other restrictions of the 110 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 111 * any of its subsidiaries will export/re-export any technical data, process, 112 * software, or service, directly or indirectly, to any country for which the 113 * United States government or any agency thereof requires an export license, 114 * other governmental approval, or letter of assurance, without first obtaining 115 * such license, approval or letter. 116 * 117 ***************************************************************************** 118 * 119 * Alternatively, you may choose to be licensed under the terms of the 120 * following license: 121 * 122 * Redistribution and use in source and binary forms, with or without 123 * modification, are permitted provided that the following conditions 124 * are met: 125 * 1. Redistributions of source code must retain the above copyright 126 * notice, this list of conditions, and the following disclaimer, 127 * without modification. 128 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 129 * substantially similar to the "NO WARRANTY" disclaimer below 130 * ("Disclaimer") and any redistribution must be conditioned upon 131 * including a substantially similar Disclaimer requirement for further 132 * binary redistribution. 133 * 3. Neither the names of the above-listed copyright holders nor the names 134 * of any contributors may be used to endorse or promote products derived 135 * from this software without specific prior written permission. 136 * 137 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 138 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 139 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 140 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 141 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 142 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 143 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 144 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 145 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 146 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 147 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 148 * 149 * Alternatively, you may choose to be licensed under the terms of the 150 * GNU General Public License ("GPL") version 2 as published by the Free 151 * Software Foundation. 152 * 153 *****************************************************************************/ 154 155 ') 156 157 /******************************************************************************* 158 * 159 * ASL Root and Secondary Terms 160 * 161 ******************************************************************************/ 162 163 /* 164 * Root term. Allow multiple #line directives before the definition block 165 * to handle output from preprocessors 166 */ 167 AslCode 168 : DefinitionBlockList {$<n>$ = TrLinkOpChildren ( 169 TrCreateLeafOp (PARSEOP_ASL_CODE),1, $1);} 170 | error {YYABORT; $$ = NULL;} 171 ; 172 173 174 /* 175 * Note concerning support for "module-level code". 176 * 177 * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control 178 * methods (the so-called module-level code.) This support was explicitly 179 * removed in ACPI 2.0, but this type of code continues to be created by 180 * BIOS vendors. In order to support the disassembly and recompilation of 181 * such code (and the porting of ASL code to iASL), iASL supports this 182 * code in violation of the current ACPI specification. 183 * 184 * The grammar change to support module-level code is to revert the 185 * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the 186 * original use of {TermList} instead (see below.) This allows the use 187 * of Type1 and Type2 opcodes at module level. 188 * 189 * 04/2016: The module-level code is now allowed in the following terms: 190 * DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm. 191 * The ObjectList term is obsolete and has been removed. 192 */ 193 DefinitionBlockTerm 194 : PARSEOP_DEFINITION_BLOCK 195 PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_DEFINITION_BLOCK); COMMENT_CAPTURE_OFF;} 196 String ',' 197 String ',' 198 ByteConst ',' 199 String ',' 200 String ',' 201 DWordConst 202 PARSEOP_CLOSE_PAREN {TrSetOpIntegerWidth ($6,$8); 203 TrSetOpEndLineNumber ($<n>3); COMMENT_CAPTURE_ON;} 204 '{' TermList '}' {$$ = TrLinkOpChildren ($<n>3,7, 205 $4,$6,$8,$10,$12,$14,$18);} 206 ; 207 208 DefinitionBlockList 209 : DefinitionBlockTerm 210 | DefinitionBlockTerm 211 DefinitionBlockList {$$ = TrLinkPeerOps (2, $1,$2);} 212 ; 213 214 215 /******* Basic ASCII identifiers **************************************************/ 216 217 /* Allow IO, DMA, IRQ Resource macro and FOR macro names to also be used as identifiers */ 218 219 NameString 220 : NameSeg {} 221 | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) $1);} 222 | PARSEOP_IO {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} 223 | PARSEOP_DMA {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} 224 | PARSEOP_IRQ {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} 225 | PARSEOP_FOR {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "FOR");} 226 ; 227 /* 228 NameSeg 229 : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) 230 TrNormalizeNameSeg ($1));} 231 ; 232 */ 233 234 NameSeg 235 : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, 236 (ACPI_NATIVE_INT) AslCompilerlval.s);} 237 ; 238 239 240 /******* Fundamental argument/statement types ***********************************/ 241 242 Term 243 : Object {} 244 | Type1Opcode {} 245 | Type2Opcode {} 246 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 247 | Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 248 | Type2BufferOpcode {} 249 | Type2BufferOrStringOpcode {} 250 | error {$$ = AslDoError(); yyclearin;} 251 ; 252 253 SuperName 254 : SimpleName {} 255 | DebugTerm {} 256 | Type6Opcode {} 257 ; 258 259 Target 260 : {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */ 261 | ',' {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */ 262 | ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);} 263 ; 264 /* 265 RequiredTarget 266 : ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);} 267 ; 268 */ 269 TermArg 270 : SimpleName {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 271 | Type2Opcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 272 | DataObject {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 273 | PARSEOP_OPEN_PAREN 274 TermArg 275 PARSEOP_CLOSE_PAREN {$$ = TrSetOpFlags ($2, OP_IS_TERM_ARG);} 276 ; 277 278 /* 279 NOTE: Removed from TermArg due to reduce/reduce conflicts: 280 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 281 | Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 282 | Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 283 | Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} 284 285 */ 286 287 MethodInvocationTerm 288 : NameString 289 PARSEOP_OPEN_PAREN {TrSetOpIntegerValue (PARSEOP_METHODCALL, $1); COMMENT_CAPTURE_OFF;} 290 ArgList 291 PARSEOP_CLOSE_PAREN {$$ = TrLinkChildOp ($1,$4); COMMENT_CAPTURE_ON;} 292 ; 293 294 /* OptionalCount must appear before ByteList or an incorrect reduction will result */ 295 296 OptionalCount 297 : {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ 298 | ',' {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ 299 | ',' TermArg {$$ = $2;} 300 ; 301 302 /* 303 * Data count for buffers and packages (byte count for buffers, 304 * element count for packages). 305 */ 306 OptionalDataCount 307 308 /* Legacy ASL */ 309 : {$$ = NULL;} 310 | PARSEOP_OPEN_PAREN 311 TermArg 312 PARSEOP_CLOSE_PAREN {$$ = $2;} 313 | PARSEOP_OPEN_PAREN 314 PARSEOP_CLOSE_PAREN {$$ = NULL;} 315 316 /* C-style (ASL+) -- adds equals term */ 317 318 | PARSEOP_EXP_EQUALS {$$ = NULL;} 319 320 | PARSEOP_OPEN_PAREN 321 TermArg 322 PARSEOP_CLOSE_PAREN 323 PARSEOP_EXP_EQUALS {$$ = $2;} 324 325 | PARSEOP_OPEN_PAREN 326 PARSEOP_CLOSE_PAREN 327 String 328 PARSEOP_EXP_EQUALS {$$ = NULL;} 329 ; 330 331 332 /******* List Terms **************************************************/ 333 334 /* ACPI 3.0 -- allow semicolons between terms */ 335 336 TermList 337 : {$$ = NULL;} 338 | TermList Term {$$ = TrLinkPeerOp ( 339 TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);} 340 | TermList Term ';' {$$ = TrLinkPeerOp ( 341 TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);} 342 | TermList ';' Term {$$ = TrLinkPeerOp ( 343 TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);} 344 | TermList ';' Term ';' {$$ = TrLinkPeerOp ( 345 TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);} 346 ; 347 348 ArgList 349 : {$$ = NULL;} 350 | TermArg 351 | ArgList ',' /* Allows a trailing comma at list end */ 352 | ArgList ',' 353 TermArg {$$ = TrLinkPeerOp ($1,$3);} 354 ; 355 356 ByteList 357 : {$$ = NULL;} 358 | ByteConstExpr 359 | ByteList ',' /* Allows a trailing comma at list end */ 360 | ByteList ',' 361 ByteConstExpr {$$ = TrLinkPeerOp ($1,$3);} 362 ; 363 364 DWordList 365 : {$$ = NULL;} 366 | DWordConstExpr 367 | DWordList ',' /* Allows a trailing comma at list end */ 368 | DWordList ',' 369 DWordConstExpr {$$ = TrLinkPeerOp ($1,$3);} 370 ; 371 372 FieldUnitList 373 : {$$ = NULL;} 374 | FieldUnit 375 | FieldUnitList ',' /* Allows a trailing comma at list end */ 376 | FieldUnitList ',' 377 FieldUnit {$$ = TrLinkPeerOp ($1,$3);} 378 ; 379 380 FieldUnit 381 : FieldUnitEntry {} 382 | OffsetTerm {} 383 | AccessAsTerm {} 384 | ConnectionTerm {} 385 ; 386 387 FieldUnitEntry 388 : ',' AmlPackageLengthTerm {$$ = TrCreateOp (PARSEOP_RESERVED_BYTES,1,$2);} 389 | NameSeg ',' 390 AmlPackageLengthTerm {$$ = TrLinkChildOp ($1,$3);} 391 ; 392 393 Object 394 : CompilerDirective {} 395 | NamedObject {} 396 | NameSpaceModifier {} 397 /* | StructureTerm {} */ 398 ; 399 400 PackageList 401 : {$$ = NULL;} 402 | PackageElement 403 | PackageList ',' /* Allows a trailing comma at list end */ 404 | PackageList ',' 405 PackageElement {$$ = TrLinkPeerOp ($1,$3);} 406 ; 407 408 PackageElement 409 : DataObject {} 410 | NameString {} 411 ; 412 413 /* Rules for specifying the type of one method argument or return value */ 414 415 ParameterTypePackage 416 : {$$ = NULL;} 417 | ObjectTypeKeyword {$$ = $1;} 418 | ParameterTypePackage ',' 419 ObjectTypeKeyword {$$ = TrLinkPeerOps (2,$1,$3);} 420 ; 421 422 ParameterTypePackageList 423 : {$$ = NULL;} 424 | ObjectTypeKeyword {$$ = TrLinkOpChildren ( 425 TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);} 426 | '{' ParameterTypePackage '}' {$$ = TrLinkOpChildren ( 427 TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} 428 ; 429 430 431 OptionalParameterTypePackage 432 : {$$ = NULL;} 433 | ',' ParameterTypePackageList {$$ = $2;} 434 ; 435 436 /* Rules for specifying the types for method arguments */ 437 438 ParameterTypesPackage 439 : ParameterTypePackageList {$$ = $1;} 440 | ParameterTypesPackage ',' 441 ParameterTypePackageList {$$ = TrLinkPeerOps (2,$1,$3);} 442 ; 443 444 ParameterTypesPackageList 445 : {$$ = NULL;} 446 | ObjectTypeKeyword {$$ = TrLinkOpChildren ( 447 TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);} 448 | '{' ParameterTypesPackage '}' {$$ = TrLinkOpChildren ( 449 TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} 450 ; 451 452 OptionalParameterTypesPackage 453 : {$$ = NULL;} 454 | ',' ParameterTypesPackageList {$$ = $2;} 455 ; 456 457 /* 458 * Case-Default list; allow only one Default term and unlimited Case terms 459 */ 460 CaseDefaultTermList 461 : {$$ = NULL;} 462 | CaseTerm {} 463 | DefaultTerm {} 464 | CaseDefaultTermList 465 CaseTerm {$$ = TrLinkPeerOp ($1,$2);} 466 | CaseDefaultTermList 467 DefaultTerm {$$ = TrLinkPeerOp ($1,$2);} 468 469 /* Original - attempts to force zero or one default term within the switch */ 470 471 /* 472 CaseDefaultTermList 473 : {$$ = NULL;} 474 | CaseTermList 475 DefaultTerm 476 CaseTermList {$$ = TrLinkPeerOp ($1,TrLinkPeerOp ($2, $3));} 477 | CaseTermList 478 CaseTerm {$$ = TrLinkPeerOp ($1,$2);} 479 ; 480 481 CaseTermList 482 : {$$ = NULL;} 483 | CaseTerm {} 484 | CaseTermList 485 CaseTerm {$$ = TrLinkPeerOp ($1,$2);} 486 ; 487 */ 488 489 490 /******************************************************************************* 491 * 492 * ASL Data and Constant Terms 493 * 494 ******************************************************************************/ 495 496 DataObject 497 : BufferData {} 498 | PackageData {} 499 | IntegerData {} 500 | StringData {} 501 ; 502 503 BufferData 504 : Type5Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 505 | Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 506 | Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 507 | BufferTerm {} 508 ; 509 510 PackageData 511 : PackageTerm {} 512 ; 513 514 IntegerData 515 : Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 516 | Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 517 | Integer {} 518 | ConstTerm {} 519 ; 520 521 StringData 522 : Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 523 | String {} 524 ; 525 526 StringLiteral 527 : String {} 528 ; 529 530 ByteConst 531 : Integer {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);} 532 ; 533 534 WordConst 535 : Integer {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);} 536 ; 537 538 DWordConst 539 : Integer {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);} 540 ; 541 542 QWordConst 543 : Integer {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);} 544 ; 545 546 /* 547 * The OP_COMPILE_TIME_CONST flag in the following constant expressions 548 * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes 549 * to simple integers. It is an error if these types of expressions cannot be 550 * reduced, since the AML grammar for ****ConstExpr requires a simple constant. 551 * Note: The required byte length of the constant is passed through to the 552 * constant folding code in the node AmlLength field. 553 */ 554 ByteConstExpr 555 : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 556 TrSetOpAmlLength ($1, 1);} 557 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 558 TrSetOpAmlLength ($1, 1);} 559 | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);} 560 | ByteConst {} 561 ; 562 563 WordConstExpr 564 : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 565 TrSetOpAmlLength ($1, 2);} 566 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 567 TrSetOpAmlLength ($1, 2);} 568 | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);} 569 | WordConst {} 570 ; 571 572 DWordConstExpr 573 : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 574 TrSetOpAmlLength ($1, 4);} 575 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 576 TrSetOpAmlLength ($1, 4);} 577 | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);} 578 | DWordConst {} 579 ; 580 581 QWordConstExpr 582 : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 583 TrSetOpAmlLength ($1, 8);} 584 | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); 585 TrSetOpAmlLength ($1, 8);} 586 | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);} 587 | QWordConst {} 588 ; 589 590 ConstTerm 591 : ConstExprTerm {} 592 | PARSEOP_REVISION {$$ = TrCreateLeafOp (PARSEOP_REVISION);} 593 ; 594 595 ConstExprTerm 596 : PARSEOP_ZERO {$$ = TrCreateValuedLeafOp (PARSEOP_ZERO, 0);} 597 | PARSEOP_ONE {$$ = TrCreateValuedLeafOp (PARSEOP_ONE, 1);} 598 | PARSEOP_ONES {$$ = TrCreateValuedLeafOp (PARSEOP_ONES, ACPI_UINT64_MAX);} 599 | PARSEOP___DATE__ {$$ = TrCreateConstantLeafOp (PARSEOP___DATE__);} 600 | PARSEOP___FILE__ {$$ = TrCreateConstantLeafOp (PARSEOP___FILE__);} 601 | PARSEOP___LINE__ {$$ = TrCreateConstantLeafOp (PARSEOP___LINE__);} 602 | PARSEOP___PATH__ {$$ = TrCreateConstantLeafOp (PARSEOP___PATH__);} 603 | PARSEOP___METHOD__ {$$ = TrCreateConstantLeafOp (PARSEOP___METHOD__);} 604 ; 605 606 Integer 607 : PARSEOP_INTEGER {$$ = TrCreateValuedLeafOp (PARSEOP_INTEGER, 608 AslCompilerlval.i);} 609 ; 610 611 String 612 : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafOp (PARSEOP_STRING_LITERAL, 613 (ACPI_NATIVE_INT) AslCompilerlval.s);} 614 ; 615 616 617 /******************************************************************************* 618 * 619 * ASL Opcode Terms 620 * 621 ******************************************************************************/ 622 623 CompilerDirective 624 : IncludeTerm {} 625 | IncludeEndTerm {} 626 | ExternalTerm {} 627 ; 628 629 NamedObject 630 : BankFieldTerm {} 631 | CreateBitFieldTerm {} 632 | CreateByteFieldTerm {} 633 | CreateDWordFieldTerm {} 634 | CreateFieldTerm {} 635 | CreateQWordFieldTerm {} 636 | CreateWordFieldTerm {} 637 | DataRegionTerm {} 638 | DeviceTerm {} 639 | EventTerm {} 640 | FieldTerm {} 641 | FunctionTerm {} 642 | IndexFieldTerm {} 643 | MethodTerm {} 644 | MutexTerm {} 645 | OpRegionTerm {} 646 | PowerResTerm {} 647 | ProcessorTerm {} 648 | ThermalZoneTerm {} 649 ; 650 651 NameSpaceModifier 652 : AliasTerm {} 653 | NameTerm {} 654 /* | NameTermAslPlus {} */ 655 | ScopeTerm {} 656 ; 657 658 SimpleName 659 : NameString {} 660 | LocalTerm {} 661 | ArgTerm {} 662 ; 663 664 /* For ObjectType(), SuperName except for MethodInvocationTerm */ 665 666 ObjectTypeSource 667 : SimpleName {} 668 | DebugTerm {} 669 | RefOfTerm {} 670 | DerefOfTerm {} 671 | IndexTerm {} 672 | IndexExpTerm {} 673 ; 674 675 /* For DeRefOf(), SuperName except for DerefOf and Debug */ 676 677 DerefOfSource 678 : SimpleName {} 679 | RefOfTerm {} 680 | DerefOfTerm {} 681 | IndexTerm {} 682 | IndexExpTerm {} 683 | StoreTerm {} 684 | EqualsTerm {} 685 | MethodInvocationTerm {} 686 ; 687 688 /* For RefOf(), SuperName except for RefOf and MethodInvocationTerm */ 689 690 RefOfSource 691 : SimpleName {} 692 | DebugTerm {} 693 | DerefOfTerm {} 694 | IndexTerm {} 695 | IndexExpTerm {} 696 ; 697 698 /* For CondRefOf(), SuperName except for RefOf and MethodInvocationTerm */ 699 700 CondRefOfSource 701 : SimpleName {} 702 | DebugTerm {} 703 | DerefOfTerm {} 704 | IndexTerm {} 705 | IndexExpTerm {} 706 ; 707 708 /* 709 * Opcode types, as defined in the ACPI specification 710 */ 711 Type1Opcode 712 : BreakTerm {} 713 | BreakPointTerm {} 714 | ContinueTerm {} 715 | FatalTerm {} 716 | ForTerm {} 717 | ElseIfTerm {} 718 | NoOpTerm {} 719 | NotifyTerm {} 720 | ReleaseTerm {} 721 | ResetTerm {} 722 | ReturnTerm {} 723 | SignalTerm {} 724 | SleepTerm {} 725 | StallTerm {} 726 | SwitchTerm {} 727 | UnloadTerm {} 728 | WhileTerm {} 729 ; 730 731 Type2Opcode 732 : AcquireTerm {} 733 | CondRefOfTerm {} 734 | CopyObjectTerm {} 735 | DerefOfTerm {} 736 | LoadTerm {} /* Moved from Type1 -- now returns an integer (ACPI 6.4) */ 737 | ObjectTypeTerm {} 738 | RefOfTerm {} 739 | SizeOfTerm {} 740 | StoreTerm {} 741 | EqualsTerm {} 742 | TimerTerm {} 743 | WaitTerm {} 744 | MethodInvocationTerm {} 745 ; 746 747 /* 748 * Type 3/4/5 opcodes 749 */ 750 Type2IntegerOpcode /* "Type3" opcodes */ 751 : Expression {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 752 | AddTerm {} 753 | AndTerm {} 754 | DecTerm {} 755 | DivideTerm {} 756 | FindSetLeftBitTerm {} 757 | FindSetRightBitTerm {} 758 | FromBCDTerm {} 759 | IncTerm {} 760 | IndexTerm {} 761 /* | StructureIndexTerm {} */ 762 /* | StructurePointerTerm {} */ 763 | LAndTerm {} 764 | LEqualTerm {} 765 | LGreaterTerm {} 766 | LGreaterEqualTerm {} 767 | LLessTerm {} 768 | LLessEqualTerm {} 769 | LNotTerm {} 770 | LNotEqualTerm {} 771 | LoadTableTerm {} 772 | LOrTerm {} 773 | MatchTerm {} 774 | ModTerm {} 775 | MultiplyTerm {} 776 | NAndTerm {} 777 | NOrTerm {} 778 | NotTerm {} 779 | OrTerm {} 780 | ShiftLeftTerm {} 781 | ShiftRightTerm {} 782 | SubtractTerm {} 783 | ToBCDTerm {} 784 | ToIntegerTerm {} 785 | XOrTerm {} 786 ; 787 788 Type2StringOpcode /* "Type4" Opcodes */ 789 : ToDecimalStringTerm {} 790 | ToHexStringTerm {} 791 | ToStringTerm {} 792 ; 793 794 Type2BufferOpcode /* "Type5" Opcodes */ 795 : ToBufferTerm {} 796 | ConcatResTerm {} 797 ; 798 799 Type2BufferOrStringOpcode 800 : ConcatTerm {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} 801 | PrintfTerm {} 802 | FprintfTerm {} 803 | MidTerm {} 804 ; 805 806 /* 807 * A type 3 opcode evaluates to an Integer and cannot have a destination operand 808 */ 809 Type3Opcode 810 : EISAIDTerm {} 811 ; 812 813 /* Obsolete 814 Type4Opcode 815 : ConcatTerm {} 816 | ToDecimalStringTerm {} 817 | ToHexStringTerm {} 818 | MidTerm {} 819 | ToStringTerm {} 820 ; 821 */ 822 823 /* Type 5 opcodes are a subset of Type2 opcodes, and return a constant */ 824 825 Type5Opcode 826 : ResourceTemplateTerm {} 827 | UnicodeTerm {} 828 | ToPLDTerm {} 829 | ToUUIDTerm {} 830 ; 831 832 Type6Opcode 833 : RefOfTerm {} 834 | DerefOfTerm {} 835 | IndexTerm {} 836 | IndexExpTerm {} 837 /* | StructureIndexTerm {} */ 838 /* | StructurePointerTerm {} */ 839 | MethodInvocationTerm {} 840 ; 841 842 843 /******************************************************************************* 844 * 845 * ASL Helper Terms 846 * 847 ******************************************************************************/ 848 849 AmlPackageLengthTerm 850 : Integer {$$ = TrSetOpIntegerValue (PARSEOP_PACKAGE_LENGTH, 851 (ACPI_PARSE_OBJECT *) $1);} 852 ; 853 854 NameStringItem 855 : ',' NameString {$$ = $2;} 856 | ',' error {$$ = AslDoError (); yyclearin;} 857 ; 858 859 TermArgItem 860 : ',' TermArg {$$ = $2;} 861 | ',' error {$$ = AslDoError (); yyclearin;} 862 ; 863 864 OptionalReference 865 : {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ 866 | ',' {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ 867 | ',' TermArg {$$ = $2;} 868 ; 869 870 OptionalReturnArg 871 : {$$ = TrSetOpFlags (TrCreateLeafOp (PARSEOP_ZERO), 872 OP_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ 873 | TermArg {$$ = $1;} 874 ; 875 876 OptionalSerializeRuleKeyword 877 : {$$ = NULL;} 878 | ',' {$$ = NULL;} 879 | ',' SerializeRuleKeyword {$$ = $2;} 880 ; 881 882 OptionalTermArg 883 : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} 884 | TermArg {$$ = $1;} 885 ; 886 887 OptionalWordConst 888 : {$$ = NULL;} 889 | WordConst {$$ = $1;} 890 ; 891