aslcompiler.l revision 138287
1 2%{ 3/****************************************************************************** 4 * 5 * Module Name: aslcompiler.l - Flex input file 6 * $Revision: $ 7 * 8 *****************************************************************************/ 9 10/****************************************************************************** 11 * 12 * 1. Copyright Notice 13 * 14 * Some or all of this work - Copyright (c) 1999 - 2004, 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 120#include <stdlib.h> 121#include <string.h> 122#include "aslcompiler.h" 123#include "aslcompiler.y.h" 124YYSTYPE AslCompilerlval; 125 126/* 127 * Generation: Use the following command line: 128 * 129 * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath) 130 * 131 * -i: Scanner must be case-insensitive 132 */ 133 134#define _COMPONENT ACPI_COMPILER 135 ACPI_MODULE_NAME ("aslscan") 136char 137comment (void); 138char 139comment2 (void); 140void 141count (int type); 142char 143literal (void); 144void 145copy (void); 146 147/*! [Begin] no source code translation */ 148 149%} 150 151 152LeadNameChar [A-Za-z_] 153DigitChar [0-9] 154HexDigitChar [A-Fa-f0-9] 155RootChar [\\] 156Nothing [] 157 158NameChar [A-Za-z_0-9] 159NameSeg1 {LeadNameChar}{NameChar} 160NameSeg2 {LeadNameChar}{NameChar}{NameChar} 161NameSeg3 {LeadNameChar}{NameChar}{NameChar}{NameChar} 162NameSeg {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3} 163 164NameString {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath} 165NamePath {NonEmptyNamePath}? 166NonEmptyNamePath {NameSeg}{NamePathTail}* 167NamePathTail [.]{NameSeg} 168 169%% 170 171[ ] { count (0); } 172[\n] { count (0); } 173[ \t] { count (0); } 174 175 176"/*" { if (!comment ()) yyterminate (); } 177"//" { if (!comment2 ()) yyterminate (); } 178 179"\"" { if (literal ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } 180 181 1820[xX]{HexDigitChar}+ | 183{DigitChar}+ { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext); 184 count (1); return (PARSEOP_INTEGER); } 185 186"Include" { count (1); return (PARSEOP_INCLUDE); } 187"#include" { count (1); return (PARSEOP_INCLUDE_CSTYLE); } 188"#line" { count (1); return (PARSEOP_LINE_CSTYLE); } 189"External" { count (1); return (PARSEOP_EXTERNAL); } 190 191 192"Ones" { count (1); return (PARSEOP_ONES); } 193"One" { count (1); return (PARSEOP_ONE); } 194"Zero" { count (1); return (PARSEOP_ZERO); } 195"Revision" { count (1); return (PARSEOP_REVISION); } 196 197"Offset" { count (1); return (PARSEOP_OFFSET); } 198"AccessAs" { count (1); return (PARSEOP_ACCESSAS); } 199"BankField" { count (2); return (PARSEOP_BANKFIELD); } 200"CreateBitField" { count (2); return (PARSEOP_CREATEBITFIELD); } 201"CreateByteField" { count (2); return (PARSEOP_CREATEBYTEFIELD); } 202"CreateDWordField" { count (2); return (PARSEOP_CREATEDWORDFIELD); } 203"CreateField" { count (2); return (PARSEOP_CREATEFIELD); } 204"CreateQWordField" { count (2); return (PARSEOP_CREATEQWORDFIELD); } 205"CreateWordField" { count (2); return (PARSEOP_CREATEWORDFIELD); } 206"DataTableRegion" { count (2); return (PARSEOP_DATATABLEREGION); } 207"Device" { count (2); return (PARSEOP_DEVICE); } 208"Event" { count (2); return (PARSEOP_EVENT); } 209"Field" { count (2); return (PARSEOP_FIELD); } 210"Function" { count (2); return (PARSEOP_FUNCTION); } 211"IndexField" { count (2); return (PARSEOP_INDEXFIELD); } 212"Method" { count (2); return (PARSEOP_METHOD); } 213"Mutex" { count (2); return (PARSEOP_MUTEX); } 214"OperationRegion" { count (2); return (PARSEOP_OPERATIONREGION); } 215"PowerResource" { count (2); return (PARSEOP_POWERRESOURCE); } 216"Processor" { count (2); return (PARSEOP_PROCESSOR); } 217"ThermalZone" { count (2); return (PARSEOP_THERMALZONE); } 218"Alias" { count (2); return (PARSEOP_ALIAS); } 219"Name" { count (2); return (PARSEOP_NAME); } 220"Scope" { count (2); return (PARSEOP_SCOPE); } 221"Break" { count (3); return (PARSEOP_BREAK); } 222"BreakPoint" { count (3); return (PARSEOP_BREAKPOINT); } 223"Continue" { count (3); return (PARSEOP_CONTINUE); } 224"Fatal" { count (3); return (PARSEOP_FATAL); } 225"If" { count (3); return (PARSEOP_IF); } 226"Else" { count (3); return (PARSEOP_ELSE); } 227"ElseIf" { count (3); return (PARSEOP_ELSEIF); } 228"Load" { count (3); return (PARSEOP_LOAD); } 229"Noop" { count (3); return (PARSEOP_NOOP); } 230"Notify" { count (3); return (PARSEOP_NOTIFY); } 231"Release" { count (3); return (PARSEOP_RELEASE); } 232"Reset" { count (3); return (PARSEOP_RESET); } 233"Return" { count (3); return (PARSEOP_RETURN); } 234"Signal" { count (3); return (PARSEOP_SIGNAL); } 235"Sleep" { count (3); return (PARSEOP_SLEEP); } 236"Stall" { count (3); return (PARSEOP_STALL); } 237"Switch" { count (3); return (PARSEOP_SWITCH); } 238"Case" { count (3); return (PARSEOP_CASE); } 239"Default" { count (3); return (PARSEOP_DEFAULT); } 240"Unload" { count (3); return (PARSEOP_UNLOAD); } 241"While" { count (3); return (PARSEOP_WHILE); } 242 243"Acquire" { count (3); return (PARSEOP_ACQUIRE); } 244"Add" { count (3); return (PARSEOP_ADD); } 245"And" { count (3); return (PARSEOP_AND); } 246"Concatenate" { count (3); return (PARSEOP_CONCATENATE); } 247"ConcatenateResTemplate" { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); } 248"CondRefOf" { count (3); return (PARSEOP_CONDREFOF); } 249"CopyObject" { count (3); return (PARSEOP_COPYOBJECT); } 250"Decrement" { count (3); return (PARSEOP_DECREMENT); } 251"DeRefOf" { count (3); return (PARSEOP_DEREFOF); } 252"Divide" { count (3); return (PARSEOP_DIVIDE); } 253"FindSetLeftBit" { count (3); return (PARSEOP_FINDSETLEFTBIT); } 254"FindSetRightBit" { count (3); return (PARSEOP_FINDSETRIGHTBIT); } 255"FromBCD" { count (3); return (PARSEOP_FROMBCD); } 256"Increment" { count (3); return (PARSEOP_INCREMENT); } 257"Index" { count (3); return (PARSEOP_INDEX); } 258"LAnd" { count (3); return (PARSEOP_LAND); } 259"LEqual" { count (3); return (PARSEOP_LEQUAL); } 260"LGreater" { count (3); return (PARSEOP_LGREATER); } 261"LGreaterEqual" { count (3); return (PARSEOP_LGREATEREQUAL); } 262"LLess" { count (3); return (PARSEOP_LLESS); } 263"LLessEqual" { count (3); return (PARSEOP_LLESSEQUAL); } 264"LNot" { count (3); return (PARSEOP_LNOT); } 265"LNotEqual" { count (3); return (PARSEOP_LNOTEQUAL); } 266"LoadTable" { count (3); return (PARSEOP_LOADTABLE); } 267"LOr" { count (3); return (PARSEOP_LOR); } 268"Match" { count (3); return (PARSEOP_MATCH); } 269"Mid" { count (3); return (PARSEOP_MID); } 270"Mod" { count (3); return (PARSEOP_MOD); } 271"Multiply" { count (3); return (PARSEOP_MULTIPLY); } 272"NAnd" { count (3); return (PARSEOP_NAND); } 273"NOr" { count (3); return (PARSEOP_NOR); } 274"Not" { count (3); return (PARSEOP_NOT); } 275"ObjectType" { count (3); return (PARSEOP_OBJECTTYPE); } 276"Or" { count (3); return (PARSEOP_OR); } 277"RefOf" { count (3); return (PARSEOP_REFOF); } 278"ShiftLeft" { count (3); return (PARSEOP_SHIFTLEFT); } 279"ShiftRight" { count (3); return (PARSEOP_SHIFTRIGHT); } 280"SizeOf" { count (3); return (PARSEOP_SIZEOF); } 281"Store" { count (3); return (PARSEOP_STORE); } 282"Subtract" { count (3); return (PARSEOP_SUBTRACT); } 283"Timer" { count (3); return (PARSEOP_TIMER); } 284"ToBCD" { count (3); return (PARSEOP_TOBCD); } 285"ToBuffer" { count (3); return (PARSEOP_TOBUFFER); } 286"ToDecimalString" { count (3); return (PARSEOP_TODECIMALSTRING); } 287"ToHexString" { count (3); return (PARSEOP_TOHEXSTRING); } 288"ToInteger" { count (3); return (PARSEOP_TOINTEGER); } 289"ToString" { count (3); return (PARSEOP_TOSTRING); } 290"Wait" { count (3); return (PARSEOP_WAIT); } 291"XOr" { count (3); return (PARSEOP_XOR); } 292 293"Arg0" { count (1); return (PARSEOP_ARG0); } 294"Arg1" { count (1); return (PARSEOP_ARG1); } 295"Arg2" { count (1); return (PARSEOP_ARG2); } 296"Arg3" { count (1); return (PARSEOP_ARG3); } 297"Arg4" { count (1); return (PARSEOP_ARG4); } 298"Arg5" { count (1); return (PARSEOP_ARG5); } 299"Arg6" { count (1); return (PARSEOP_ARG6); } 300 301"Local0" { count (1); return (PARSEOP_LOCAL0); } 302"Local1" { count (1); return (PARSEOP_LOCAL1); } 303"Local2" { count (1); return (PARSEOP_LOCAL2); } 304"Local3" { count (1); return (PARSEOP_LOCAL3); } 305"Local4" { count (1); return (PARSEOP_LOCAL4); } 306"Local5" { count (1); return (PARSEOP_LOCAL5); } 307"Local6" { count (1); return (PARSEOP_LOCAL6); } 308"Local7" { count (1); return (PARSEOP_LOCAL7); } 309 310"Debug" { count (1); return (PARSEOP_DEBUG); } 311 312"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); } 313"Buffer" { count (1); return (PARSEOP_BUFFER); } 314"Package" { count (1); return (PARSEOP_PACKAGE); } 315 316"EISAID" { count (1); return (PARSEOP_EISAID); } 317"ResourceTemplate" { count (1); return (PARSEOP_RESOURCETEMPLATE); } 318"ToUUID" { count (1); return (PARSEOP_TOUUID); } 319"Unicode" { count (1); return (PARSEOP_UNICODE); } 320"DMA" { count (1); return (PARSEOP_DMA); } 321"DWordIO" { count (1); return (PARSEOP_DWORDIO); } 322"DWordMemory" { count (1); return (PARSEOP_DWORDMEMORY); } 323"DWordSpace" { count (1); return (PARSEOP_DWORDSPACE); } 324"EndDependentFn" { count (1); return (PARSEOP_ENDDEPENDENTFN); } 325"ExtendedIO" { count (1); return (PARSEOP_EXTENDEDIO); } 326"ExtendedMemory" { count (1); return (PARSEOP_EXTENDEDMEMORY); } 327"ExtendedSpace" { count (1); return (PARSEOP_EXTENDEDSPACE); } 328"FixedIO" { count (1); return (PARSEOP_FIXEDIO); } 329"Interrupt" { count (1); return (PARSEOP_INTERRUPT); } 330"IO" { count (1); return (PARSEOP_IO); } 331"IRQNoFlags" { count (1); return (PARSEOP_IRQNOFLAGS); } 332"IRQ" { count (1); return (PARSEOP_IRQ); } 333"Memory24" { count (1); return (PARSEOP_MEMORY24); } 334"Memory32Fixed" { count (1); return (PARSEOP_MEMORY32FIXED); } 335"Memory32" { count (1); return (PARSEOP_MEMORY32); } 336"QWordIO" { count (1); return (PARSEOP_QWORDIO); } 337"QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); } 338"QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } 339"Register" { count (1); return (PARSEOP_REGISTER); } 340"StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); } 341"StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); } 342"VendorLong" { count (1); return (PARSEOP_VENDORLONG); } 343"VendorShort" { count (1); return (PARSEOP_VENDORSHORT); } 344"WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); } 345"WordIO" { count (1); return (PARSEOP_WORDIO); } 346"WordSpace" { count (1); return (PARSEOP_WORDSPACE); } 347 348"UnknownObj" { count (0); return (PARSEOP_OBJECTTYPE_UNK); } 349"IntObj" { count (0); return (PARSEOP_OBJECTTYPE_INT); } 350"StrObj" { count (0); return (PARSEOP_OBJECTTYPE_STR); } 351"BuffObj" { count (0); return (PARSEOP_OBJECTTYPE_BUF); } 352"PkgObj" { count (0); return (PARSEOP_OBJECTTYPE_PKG); } 353"FieldUnitObj" { count (0); return (PARSEOP_OBJECTTYPE_FLD); } 354"DeviceObj" { count (0); return (PARSEOP_OBJECTTYPE_DEV); } 355"EventObj" { count (0); return (PARSEOP_OBJECTTYPE_EVT); } 356"MethodObj" { count (0); return (PARSEOP_OBJECTTYPE_MTH); } 357"MutexObj" { count (0); return (PARSEOP_OBJECTTYPE_MTX); } 358"OpRegionObj" { count (0); return (PARSEOP_OBJECTTYPE_OPR); } 359"PowerResObj" { count (0); return (PARSEOP_OBJECTTYPE_POW); } 360"ThermalZoneObj" { count (0); return (PARSEOP_OBJECTTYPE_THZ); } 361"BuffFieldObj" { count (0); return (PARSEOP_OBJECTTYPE_BFF); } 362"DDBHandleObj" { count (0); return (PARSEOP_OBJECTTYPE_DDB); } 363 364"AnyAcc" { count (0); return (PARSEOP_ACCESSTYPE_ANY); } 365"ByteAcc" { count (0); return (PARSEOP_ACCESSTYPE_BYTE); } 366"WordAcc" { count (0); return (PARSEOP_ACCESSTYPE_WORD); } 367"DWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_DWORD); } 368"QWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_QWORD); } 369"BufferAcc" { count (0); return (PARSEOP_ACCESSTYPE_BUF); } 370 371"Lock" { count (0); return (PARSEOP_LOCKRULE_LOCK); } 372"NoLock" { count (0); return (PARSEOP_LOCKRULE_NOLOCK); } 373 374"Preserve" { count (0); return (PARSEOP_UPDATERULE_PRESERVE); } 375"WriteAsOnes" { count (0); return (PARSEOP_UPDATERULE_ONES); } 376"WriteAsZeros" { count (0); return (PARSEOP_UPDATERULE_ZEROS); } 377 378"Serialized" { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); } 379"NotSerialized" { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); } 380 381"SystemIO" { count (0); return (PARSEOP_REGIONSPACE_IO); } 382"SystemMemory" { count (0); return (PARSEOP_REGIONSPACE_MEM); } 383"PCI_Config" { count (0); return (PARSEOP_REGIONSPACE_PCI); } 384"EmbeddedControl" { count (0); return (PARSEOP_REGIONSPACE_EC); } 385"SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); } 386"SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); } 387"PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); } 388 389"FFixedHW" { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); } 390 391"SMBQuick" { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); } 392"SMBSendReceive" { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); } 393"SMBByte" { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); } 394"SMBWord" { count (0); return (PARSEOP_ACCESSATTRIB_WORD); } 395"SMBBlock" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); } 396"SMBProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); } 397"SMBBlockProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); } 398 399"MTR" { count (0); return (PARSEOP_MATCHTYPE_MTR); } 400"MEQ" { count (0); return (PARSEOP_MATCHTYPE_MEQ); } 401"MLE" { count (0); return (PARSEOP_MATCHTYPE_MLE); } 402"MLT" { count (0); return (PARSEOP_MATCHTYPE_MLT); } 403"MGE" { count (0); return (PARSEOP_MATCHTYPE_MGE); } 404"MGT" { count (0); return (PARSEOP_MATCHTYPE_MGT); } 405 406"Compatibility" { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); } 407"TypeA" { count (0); return (PARSEOP_DMATYPE_A); } 408"TypeB" { count (0); return (PARSEOP_DMATYPE_B); } 409"TypeF" { count (0); return (PARSEOP_DMATYPE_F); } 410 411"BusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); } 412"NotBusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); } 413 414"Transfer8" { count (0); return (PARSEOP_XFERTYPE_8); } 415"Transfer8_16" { count (0); return (PARSEOP_XFERTYPE_8_16); } 416"Transfer16" { count (0); return (PARSEOP_XFERTYPE_16); } 417 418"ResourceConsumer" { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); } 419"ResourceProducer" { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); } 420 421"MinFixed" { count (0); return (PARSEOP_MINTYPE_FIXED); } 422"MinNotFixed" { count (0); return (PARSEOP_MINTYPE_NOTFIXED); } 423 424"MaxFixed" { count (0); return (PARSEOP_MAXTYPE_FIXED); } 425"MaxNotFixed" { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); } 426 427"PosDecode" { count (0); return (PARSEOP_DECODETYPE_POS); } 428"SubDecode" { count (0); return (PARSEOP_DECODETYPE_SUB); } 429 430"ISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_ISAONLY); } 431"NonISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); } 432"EntireRange" { count (0); return (PARSEOP_RANGETYPE_ENTIRE); } 433 434"Cacheable" { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); } 435"WriteCombining" { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); } 436"Prefetchable" { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); } 437"NonCacheable" { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); } 438 439"ReadWrite" { count (0); return (PARSEOP_READWRITETYPE_BOTH); } 440"ReadOnly" { count (0); return (PARSEOP_READWRITETYPE_READONLY); } 441 442"Edge" { count (0); return (PARSEOP_INTTYPE_EDGE); } 443"Level" { count (0); return (PARSEOP_INTTYPE_LEVEL); } 444 445"ActiveHigh" { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); } 446"ActiveLow" { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); } 447 448"Shared" { count (0); return (PARSEOP_SHARETYPE_SHARED); } 449"Exclusive" { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); } 450 451"Decode10" { count (0); return (PARSEOP_IODECODETYPE_10); } 452"Decode16" { count (0); return (PARSEOP_IODECODETYPE_16); } 453 454"TypeTranslation" { count (0); return (PARSEOP_TYPE_TRANSLATION); } 455"TypeStatic" { count (0); return (PARSEOP_TYPE_STATIC); } 456 457"SparseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); } 458"DenseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); } 459 460"AddressRangeMemory" { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); } 461"AddressRangeReserved" { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); } 462"AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); } 463"AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); } 464 465 466"{" { count (0); return('{'); } 467"}" { count (0); return('}'); } 468"," { count (0); return(','); } 469"(" { count (0); return('('); } 470")" { count (0); return(')'); } 471 472 473{NameSeg} { char *s; 474 count (0); 475 s=malloc (ACPI_NAME_SIZE + 1); 476 if (strcmp (AslCompilertext, "\\")) 477 { 478 strcpy (s, "____"); 479 ACPI_STRUPR (AslCompilertext); 480 } 481 memcpy (s, AslCompilertext, strlen (AslCompilertext)); 482 AslCompilerlval.s = s; 483 DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s); 484 return (PARSEOP_NAMESEG); } 485 486{NameString} { char *s; 487 count (0); 488 s=malloc (strlen (AslCompilertext)+1); 489 ACPI_STRUPR (AslCompilertext); 490 strcpy (s, AslCompilertext); 491 s[strlen (AslCompilertext)] = 0; 492 AslCompilerlval.s = s; 493 DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); 494 return (PARSEOP_NAMESTRING); } 495 496"*" | 497"/" { count (1); 498 AslCompilererror ("Parse error, expecting ASL keyword or name");} 499 500. { count (1); 501 sprintf (MsgBuffer, 502 "Invalid character (0x%2.2X), expecting ASL keyword or name", 503 *AslCompilertext); 504 AslCompilererror (MsgBuffer);} 505 506<<EOF>> { if (AslPopInputFileStack ()) 507 yyterminate(); 508 else 509 return (PARSEOP_INCLUDE_END);}; 510 511%% 512 513/*! [End] no source code translation !*/ 514 515typedef struct asl_file_node 516{ 517 FILE *File; 518 UINT32 CurrentLineNumber; 519 YY_BUFFER_STATE State; 520 char *Filename; 521 struct asl_file_node *Next; 522 523} ASL_FILE_NODE; 524 525ASL_FILE_NODE *InputStack = NULL; 526 527 528/******************************************************************************* 529 * 530 * FUNCTION: AslPopInputFileStack 531 * 532 * PARAMETERS: None 533 * 534 * RETURN: 0 if a node was popped, -1 otherwise 535 * 536 * DESCRIPTION: Pop the top of the input file stack and point the parser to 537 * the saved parse buffer contained in the fnode. Also, set the 538 * global line counters to the saved values. This function is 539 * called when an include file reaches EOF. 540 * 541 ******************************************************************************/ 542 543int 544AslPopInputFileStack ( 545 void) 546{ 547 ASL_FILE_NODE *Fnode; 548 FILE *InputFile = NULL; 549 550 551 Fnode = InputStack; 552 DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); 553 554 555 if (!Fnode) 556 { 557 return -1; 558 } 559 560 /* Close the current include file */ 561 562 fclose (yyin); 563 564 /* Update the top-of-stack */ 565 566 InputStack = Fnode->Next; 567 InputFile = Fnode->File; 568 569 /* Reset global line counter and filename */ 570 571 Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; 572 Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; 573 574 /* Point the parser to the popped file */ 575 576 yy_delete_buffer (YY_CURRENT_BUFFER); 577 yy_switch_to_buffer (Fnode->State); 578 579 /* All done with this node */ 580 581 ACPI_MEM_FREE (Fnode); 582 return 0; 583} 584 585 586/******************************************************************************* 587 * 588 * FUNCTION: AslPushInputFileStack 589 * 590 * PARAMETERS: InputFile - Open file pointer 591 * Filename - Name of the file 592 * 593 * RETURN: None 594 * 595 * DESCRIPTION: Push the InputFile onto the file stack, and point the parser 596 * to this file. Called when an include file is successfully 597 * opened. 598 * 599 ******************************************************************************/ 600 601void 602AslPushInputFileStack ( 603 FILE *InputFile, 604 char *Filename) 605{ 606 ASL_FILE_NODE *Fnode; 607 YY_BUFFER_STATE State; 608 609 610 /* Save the current state in an Fnode */ 611 612 Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); 613 614 Fnode->File = yyin; 615 Fnode->Next = InputStack; 616 Fnode->State = YY_CURRENT_BUFFER; 617 Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; 618 Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; 619 620 /* Push it on the stack */ 621 622 InputStack = Fnode; 623 624 /* Point the parser to this file */ 625 626 State = yy_create_buffer (InputFile, YY_BUF_SIZE); 627 yy_switch_to_buffer (State); 628 629 DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); 630 631 /* Reset the global line count and filename */ 632 633 Gbl_Files[ASL_FILE_INPUT].Filename = Filename; 634 Gbl_CurrentLineNumber = 1; 635 yyin = InputFile; 636} 637 638 639/******************************************************************************* 640 * 641 * FUNCTION: ResetCurrentLineBuffer 642 * 643 * PARAMETERS: None 644 * 645 * RETURN: None 646 * 647 * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers. 648 * 649 ******************************************************************************/ 650 651void 652ResetCurrentLineBuffer ( 653 void) 654{ 655 656 if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle) 657 { 658 FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer, 659 Gbl_LineBufPtr - Gbl_CurrentLineBuffer); 660 } 661 662 Gbl_CurrentLineOffset += Gbl_CurrentColumn; 663 Gbl_CurrentColumn = 0; 664 665 Gbl_CurrentLineNumber++; 666 Gbl_LogicalLineNumber++; 667 Gbl_LineBufPtr = Gbl_CurrentLineBuffer; 668} 669 670 671/******************************************************************************* 672 * 673 * FUNCTION: InsertLineBuffer 674 * 675 * PARAMETERS: SourceChar - One char from the input ASL source file 676 * 677 * RETURN: None 678 * 679 * DESCRIPTION: Put one character of the source file into the temp line buffer 680 * 681 ******************************************************************************/ 682 683#define ASL_SPACES_PER_TAB 4 684 685void 686InsertLineBuffer ( 687 int SourceChar) 688{ 689 UINT32 i; 690 UINT32 Count = 1; 691 692 693 if (SourceChar == EOF) 694 { 695 return; 696 } 697 698 Gbl_InputByteCount++; 699 700 /* Handle tabs. Convert to spaces */ 701 702 if (SourceChar == '\t') 703 { 704 SourceChar = ' '; 705 Count = ASL_SPACES_PER_TAB - 706 (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1)); 707 } 708 709 710 for (i = 0; i < Count; i++) 711 { 712 Gbl_CurrentColumn++; 713 714 /* Insert the character into the line buffer */ 715 716 *Gbl_LineBufPtr = (UINT8) SourceChar; 717 Gbl_LineBufPtr++; 718 719 if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) 720 { 721#if 0 722 /* 723 * Warning if we have split a long source line. 724 * <Probably overkill> 725 */ 726 sprintf (MsgBuffer, "Max %d", ASL_LINE_BUFFER_SIZE); 727 AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, 728 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 729 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 730 Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); 731#endif 732 733 ResetCurrentLineBuffer (); 734 } 735 else if (SourceChar == '\n') 736 { 737 /* End of line */ 738 739 ResetCurrentLineBuffer (); 740 } 741 } 742} 743 744 745/******************************************************************************* 746 * 747 * FUNCTION: count 748 * 749 * PARAMETERS: yytext - Contains the matched keyword. 750 * Type - Keyword/Character type: 751 * 0 = anything except a keyword 752 * 1 = pseudo-keywords 753 * 2 = non-executable ASL keywords 754 * 3 = executable ASL keywords 755 * 756 * RETURN: None 757 * 758 * DESCRIPTION: Count keywords and put them into the line buffer 759 * 760 ******************************************************************************/ 761 762void 763count ( 764 int Type) 765{ 766 int i; 767 768 769 switch (Type) 770 { 771 case 2: 772 TotalKeywords++; 773 TotalNamedObjects++; 774 break; 775 776 case 3: 777 TotalKeywords++; 778 TotalExecutableOpcodes++; 779 break; 780 } 781 782 for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++) 783 { 784 InsertLineBuffer (yytext[i]); 785 *Gbl_LineBufPtr = 0; 786 } 787} 788 789 790/******************************************************************************* 791 * 792 * FUNCTION: comment 793 * 794 * PARAMETERS: none 795 * 796 * RETURN: none 797 * 798 * DESCRIPTION: Process a standard comment. 799 * 800 ******************************************************************************/ 801 802char 803comment (void) 804{ 805 char c; 806 char c1 = 0; 807 808 809 InsertLineBuffer ('/'); 810 InsertLineBuffer ('*'); 811 812loop: 813 814 /* Eat chars until end-of-comment */ 815 816 while ((c = (char) input()) != '*' && c != EOF) 817 { 818 InsertLineBuffer (c); 819 c1 = c; 820 } 821 822 if (c == EOF) 823 { 824 goto EarlyEOF; 825 } 826 827 /* 828 * Check for nested comment -- can help catch cases where a previous 829 * comment was accidently left unterminated 830 */ 831 if ((c1 == '/') && (c == '*')) 832 { 833 AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, 834 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 835 Gbl_InputByteCount, Gbl_CurrentColumn, 836 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 837 } 838 839 /* Comment is closed only if the NEXT character is a slash */ 840 841 InsertLineBuffer (c); 842 843 if ((c1 = (char) input()) != '/' && c1 != EOF) 844 { 845 unput(c1); 846 goto loop; 847 } 848 849 if (c1 == EOF) 850 { 851 goto EarlyEOF; 852 } 853 854 InsertLineBuffer (c1); 855 return TRUE; 856 857 858EarlyEOF: 859 /* 860 * Premature End-Of-File 861 */ 862 AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 863 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 864 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 865 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 866 return (FALSE); 867} 868 869 870/******************************************************************************* 871 * 872 * FUNCTION: comment 873 * 874 * PARAMETERS: none 875 * 876 * RETURN: none 877 * 878 * DESCRIPTION: Process a new "//" comment. 879 * 880 ******************************************************************************/ 881 882char 883comment2 (void) 884{ 885 char c; 886 887 888 InsertLineBuffer ('/'); 889 InsertLineBuffer ('/'); 890 891 while ((c = (char) input()) != '\n' && c != EOF) 892 { 893 InsertLineBuffer (c); 894 } 895 896 if (c == EOF) 897 { 898 /* End of file is OK, change to newline. Let parser detect EOF later */ 899 900 c = '\n'; 901 } 902 903 InsertLineBuffer (c); 904 return (TRUE); 905} 906 907 908/******************************************************************************* 909 * 910 * FUNCTION: literal 911 * 912 * PARAMETERS: none 913 * 914 * RETURN: none 915 * 916 * DESCRIPTION: Process a string literal (surrounded by quotes) 917 * 918 ******************************************************************************/ 919 920#define ASL_NORMAL_CHAR 0 921#define ASL_ESCAPE_SEQUENCE 1 922#define ASL_OCTAL_CONSTANT 2 923#define ASL_HEX_CONSTANT 3 924 925char 926literal (void) 927{ 928 char *s = MsgBuffer; 929 char *CleanString; 930 char StringChar; 931 UINT32 State = ASL_NORMAL_CHAR; 932 UINT32 i = 0; 933 UINT8 Digit; 934 char ConvertBuffer[4]; 935 936 937 /* 938 * Eat chars until end-of-literal. 939 * NOTE: Put back the original surrounding quotes into the 940 * source line buffer. 941 */ 942 InsertLineBuffer ('\"'); 943 while ((StringChar = (char) input()) != EOF) 944 { 945 InsertLineBuffer (StringChar); 946 947DoCharacter: 948 949 switch (State) 950 { 951 case ASL_NORMAL_CHAR: 952 953 switch (StringChar) 954 { 955 case '\\': 956 /* 957 * Special handling for backslash-escape sequence. We will 958 * toss the backslash and translate the escape char(s). 959 */ 960 State = ASL_ESCAPE_SEQUENCE; 961 continue; 962 963 case '\"': 964 965 /* String terminator */ 966 967 goto CompletedString; 968 } 969 break; 970 971 972 case ASL_ESCAPE_SEQUENCE: 973 974 State = ASL_NORMAL_CHAR; 975 switch (StringChar) 976 { 977 case 'a': 978 StringChar = 0x07; /* BELL */ 979 break; 980 981 case 'b': 982 StringChar = 0x08; /* BACKSPACE */ 983 break; 984 985 case 'f': 986 StringChar = 0x0C; /* FORMFEED */ 987 break; 988 989 case 'n': 990 StringChar = 0x0A; /* LINEFEED */ 991 break; 992 993 case 'r': 994 StringChar = 0x0D; /* CARRIAGE RETURN*/ 995 break; 996 997 case 't': 998 StringChar = 0x09; /* HORIZONTAL TAB */ 999 break; 1000 1001 case 'v': 1002 StringChar = 0x0B; /* VERTICAL TAB */ 1003 break; 1004 1005 case 'x': 1006 State = ASL_HEX_CONSTANT; 1007 i = 0; 1008 continue; 1009 1010 case '\'': /* Single Quote */ 1011 case '\"': /* Double Quote */ 1012 case '\\': /* Backslash */ 1013 break; 1014 1015 default: 1016 1017 /* Check for an octal digit (0-7) */ 1018 1019 if (ACPI_IS_OCTAL_DIGIT (StringChar)) 1020 { 1021 State = ASL_OCTAL_CONSTANT; 1022 ConvertBuffer[0] = StringChar; 1023 i = 1; 1024 continue; 1025 } 1026 1027 /* Unknown escape sequence issue warning, but use the character */ 1028 1029 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, 1030 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1031 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1032 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1033 break; 1034 } 1035 break; 1036 1037 1038 case ASL_OCTAL_CONSTANT: 1039 1040 /* Up to three octal digits allowed */ 1041 1042 if (!ACPI_IS_OCTAL_DIGIT (StringChar) || 1043 (i > 2)) 1044 { 1045 /* 1046 * Reached end of the constant. Convert the assembled ASCII 1047 * string and resume processing of the next character 1048 */ 1049 ConvertBuffer[i] = 0; 1050 Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); 1051 1052 /* Check for NULL or non-ascii character (ignore if so) */ 1053 1054 if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 1055 { 1056 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 1057 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1058 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1059 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1060 } 1061 else 1062 { 1063 *s = (char) Digit; 1064 s++; 1065 } 1066 1067 State = ASL_NORMAL_CHAR; 1068 goto DoCharacter; 1069 break; 1070 } 1071 1072 /* Append another digit of the constant */ 1073 1074 ConvertBuffer[i] = StringChar; 1075 i++; 1076 continue; 1077 1078 1079 case ASL_HEX_CONSTANT: 1080 1081 /* Up to two hex digits allowed */ 1082 1083 if (!ACPI_IS_XDIGIT (StringChar) || 1084 (i > 1)) 1085 { 1086 /* 1087 * Reached end of the constant. Convert the assembled ASCII 1088 * string and resume processing of the next character 1089 */ 1090 ConvertBuffer[i] = 0; 1091 Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); 1092 1093 /* Check for NULL or non-ascii character (ignore if so) */ 1094 1095 if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 1096 { 1097 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 1098 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1099 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1100 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1101 } 1102 else 1103 { 1104 *s = (char) Digit; 1105 s++; 1106 } 1107 1108 State = ASL_NORMAL_CHAR; 1109 goto DoCharacter; 1110 break; 1111 } 1112 1113 /* Append another digit of the constant */ 1114 1115 ConvertBuffer[i] = StringChar; 1116 i++; 1117 continue; 1118 } 1119 1120 /* Save the finished character */ 1121 1122 *s = StringChar; 1123 s++; 1124 } 1125 1126 /* 1127 * Premature End-Of-File 1128 */ 1129 AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 1130 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1131 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1132 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1133 return (FALSE); 1134 1135 1136CompletedString: 1137 /* 1138 * Null terminate the input string and copy string to a new buffer 1139 */ 1140 *s = 0; 1141 1142 CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); 1143 if (!CleanString) 1144 { 1145 AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, 1146 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1147 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1148 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1149 return (FALSE); 1150 } 1151 1152 ACPI_STRCPY (CleanString, MsgBuffer); 1153 AslCompilerlval.s = CleanString; 1154 return (TRUE); 1155} 1156 1157 1158