1 /****************************************************************************** 2 * 3 * Module Name: aslcompiler.h - common include file for iASL 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #ifndef __ASLCOMPILER_H 153 #define __ASLCOMPILER_H 154 155 #include <contrib/dev/acpica/include/acpi.h> 156 #include <contrib/dev/acpica/include/accommon.h> 157 #include <contrib/dev/acpica/include/amlresrc.h> 158 #include <contrib/dev/acpica/include/acdebug.h> 159 160 /* Microsoft-specific */ 161 162 #if (defined WIN32 || defined WIN64) 163 164 /* warn : used #pragma pack */ 165 #pragma warning(disable:4103) 166 167 /* warn : named type definition in parentheses */ 168 #pragma warning(disable:4115) 169 #endif 170 171 #include <stdio.h> 172 #include <stdlib.h> 173 #include <string.h> 174 #include <errno.h> 175 #include <ctype.h> 176 177 /* Compiler headers */ 178 179 #include <contrib/dev/acpica/compiler/asldefine.h> 180 #include <contrib/dev/acpica/compiler/asltypes.h> 181 #include <contrib/dev/acpica/compiler/aslmessages.h> 182 #include <contrib/dev/acpica/compiler/aslglobal.h> 183 #include <contrib/dev/acpica/compiler/preprocess.h> 184 #include <contrib/dev/acpica/compiler/dtcompiler.h> 185 186 187 /******************************************************************************* 188 * 189 * Compiler prototypes 190 * 191 ******************************************************************************/ 192 193 /* 194 * Main ASL parser - generated from flex/bison, lex/yacc, etc. 195 */ 196 ACPI_PARSE_OBJECT * 197 AslDoError ( 198 void); 199 200 int 201 AslCompilerlex( 202 void); 203 204 void 205 AslResetCurrentLineBuffer ( 206 void); 207 208 void 209 AslInsertLineBuffer ( 210 int SourceChar); 211 212 int 213 AslPopInputFileStack ( 214 void); 215 216 void 217 AslPushInputFileStack ( 218 FILE *InputFile, 219 char *Filename); 220 221 void 222 AslParserCleanup ( 223 void); 224 225 226 /* 227 * aslstartup - entered from main() 228 */ 229 void 230 AslInitializeGlobals ( 231 void); 232 233 typedef 234 ACPI_STATUS (*ASL_PATHNAME_CALLBACK) ( 235 char *); 236 237 ACPI_STATUS 238 AslDoOneFile ( 239 char *Filename); 240 241 ACPI_STATUS 242 AslCheckForErrorExit ( 243 void); 244 245 246 /* 247 * aslcompile - compile mainline 248 */ 249 void 250 AslCompilerSignon ( 251 UINT32 FileId); 252 253 void 254 AslCompilerFileHeader ( 255 UINT32 FileId); 256 257 ACPI_STATUS 258 CmDoCompile ( 259 void); 260 261 int 262 CmDoAslMiddleAndBackEnd ( 263 void); 264 265 void 266 CmDoOutputFiles ( 267 void); 268 269 int 270 CmCleanupAndExit ( 271 void); 272 273 ACPI_STATUS 274 AslDoDisassembly ( 275 void); 276 277 278 /* 279 * aslallocate - memory allocation 280 */ 281 void * 282 UtLocalCalloc ( 283 UINT32 Size); 284 285 void 286 UtExpandLineBuffers ( 287 void); 288 289 void 290 UtReallocLineBuffers ( 291 char **Buffer, 292 UINT32 OldSize, 293 UINT32 NewSize); 294 295 void 296 UtFreeLineBuffers ( 297 void); 298 299 300 /* 301 * aslcache - local cache support 302 */ 303 char * 304 UtLocalCacheCalloc ( 305 UINT32 Length); 306 307 ACPI_PARSE_OBJECT * 308 UtParseOpCacheCalloc ( 309 void); 310 311 DT_SUBTABLE * 312 UtSubtableCacheCalloc ( 313 void); 314 315 DT_FIELD * 316 UtFieldCacheCalloc ( 317 void); 318 319 void 320 UtDeleteLocalCaches ( 321 void); 322 323 324 /* 325 * aslascii - ascii support 326 */ 327 ACPI_STATUS 328 FlIsFileAsciiSource ( 329 char *Filename, 330 BOOLEAN DisplayErrors); 331 332 333 /* 334 * aslwalks - semantic analysis and parse tree walks 335 */ 336 ACPI_STATUS 337 AnOtherSemanticAnalysisWalkBegin ( 338 ACPI_PARSE_OBJECT *Op, 339 UINT32 Level, 340 void *Context); 341 342 ACPI_STATUS 343 AnOtherSemanticAnalysisWalkEnd ( 344 ACPI_PARSE_OBJECT *Op, 345 UINT32 Level, 346 void *Context); 347 348 ACPI_STATUS 349 AnOperandTypecheckWalkEnd ( 350 ACPI_PARSE_OBJECT *Op, 351 UINT32 Level, 352 void *Context); 353 354 ACPI_STATUS 355 AnMethodTypingWalkEnd ( 356 ACPI_PARSE_OBJECT *Op, 357 UINT32 Level, 358 void *Context); 359 360 361 /* 362 * aslmethod - Control method analysis walk 363 */ 364 ACPI_STATUS 365 MtMethodAnalysisWalkBegin ( 366 ACPI_PARSE_OBJECT *Op, 367 UINT32 Level, 368 void *Context); 369 370 ACPI_STATUS 371 MtMethodAnalysisWalkEnd ( 372 ACPI_PARSE_OBJECT *Op, 373 UINT32 Level, 374 void *Context); 375 376 377 /* 378 * aslbtypes - bitfield data types 379 */ 380 UINT32 381 AnMapObjTypeToBtype ( 382 ACPI_PARSE_OBJECT *Op); 383 384 UINT32 385 AnMapArgTypeToBtype ( 386 UINT32 ArgType); 387 388 UINT32 389 AnGetBtype ( 390 ACPI_PARSE_OBJECT *Op); 391 392 void 393 AnFormatBtype ( 394 char *Buffer, 395 UINT32 Btype); 396 397 398 /* 399 * aslanalyze - Support functions for parse tree walks 400 */ 401 void 402 AnCheckId ( 403 ACPI_PARSE_OBJECT *Op, 404 ACPI_NAME Type); 405 406 /* Values for Type argument above */ 407 408 #define ASL_TYPE_HID 0 409 #define ASL_TYPE_CID 1 410 411 BOOLEAN 412 AnIsInternalMethod ( 413 ACPI_PARSE_OBJECT *Op); 414 415 UINT32 416 AnGetInternalMethodReturnType ( 417 ACPI_PARSE_OBJECT *Op); 418 419 BOOLEAN 420 AnLastStatementIsReturn ( 421 ACPI_PARSE_OBJECT *Op); 422 423 void 424 AnCheckMethodReturnValue ( 425 ACPI_PARSE_OBJECT *Op, 426 const ACPI_OPCODE_INFO *OpInfo, 427 ACPI_PARSE_OBJECT *ArgOp, 428 UINT32 RequiredBtypes, 429 UINT32 ThisNodeBtype); 430 431 BOOLEAN 432 AnIsResultUsed ( 433 ACPI_PARSE_OBJECT *Op); 434 435 void 436 ApCheckForGpeNameConflict ( 437 ACPI_PARSE_OBJECT *Op); 438 439 void 440 ApCheckRegMethod ( 441 ACPI_PARSE_OBJECT *Op); 442 443 BOOLEAN 444 ApFindNameInScope ( 445 char *Name, 446 ACPI_PARSE_OBJECT *Op); 447 448 BOOLEAN 449 ApFindNameInDeviceTree ( 450 char *Name, 451 ACPI_PARSE_OBJECT *Op); 452 453 /* 454 * aslerror - error handling/reporting 455 */ 456 void 457 AslAbort ( 458 void); 459 460 void 461 AslDualParseOpError ( 462 UINT8 Level, 463 UINT16 MainMessageId, 464 ACPI_PARSE_OBJECT *MainOp, 465 char *MainMessage, 466 UINT16 SecondMessageId, 467 ACPI_PARSE_OBJECT *SecondOp, 468 char *SecondaryMessage); 469 470 void 471 AslError ( 472 UINT8 Level, 473 UINT16 MessageId, 474 ACPI_PARSE_OBJECT *Op, 475 char *ExtraMessage); 476 477 void 478 AslCheckExpectedExceptions ( 479 void); 480 481 ACPI_STATUS 482 AslExpectException ( 483 char *MessageIdString); 484 485 ACPI_STATUS 486 AslElevateException ( 487 char *MessageIdString); 488 489 ACPI_STATUS 490 AslDisableException ( 491 char *MessageIdString); 492 493 BOOLEAN 494 AslIsExceptionIgnored ( 495 UINT8 Level, 496 UINT16 MessageId); 497 498 void 499 AslCoreSubsystemError ( 500 ACPI_PARSE_OBJECT *Op, 501 ACPI_STATUS Status, 502 char *ExtraMessage, 503 BOOLEAN Abort); 504 505 int 506 AslCompilererror( 507 const char *s); 508 509 void 510 AslCommonError ( 511 UINT8 Level, 512 UINT16 MessageId, 513 UINT32 CurrentLineNumber, 514 UINT32 LogicalLineNumber, 515 UINT32 LogicalByteOffset, 516 UINT32 Column, 517 char *Filename, 518 char *ExtraMessage); 519 520 void 521 AslCommonError2 ( 522 UINT8 Level, 523 UINT16 MessageId, 524 UINT32 LineNumber, 525 UINT32 Column, 526 char *SourceLine, 527 char *Filename, 528 char *ExtraMessage); 529 530 void 531 AePrintException ( 532 UINT32 FileId, 533 ASL_ERROR_MSG *Enode, 534 char *Header); 535 536 void 537 AePrintErrorLog ( 538 UINT32 FileId); 539 540 void 541 AeClearErrorLog ( 542 void); 543 544 545 /* 546 * asllisting - generate all "listing" type files 547 */ 548 void 549 LsDoListings ( 550 void); 551 552 void 553 LsWriteNodeToAsmListing ( 554 ACPI_PARSE_OBJECT *Op); 555 556 void 557 LsWriteNode ( 558 ACPI_PARSE_OBJECT *Op, 559 UINT32 FileId); 560 561 void 562 LsDumpParseTree ( 563 void); 564 565 566 /* 567 * asllistsup - Listing file support utilities 568 */ 569 void 570 LsDumpAscii ( 571 UINT32 FileId, 572 UINT32 Count, 573 UINT8 *Buffer); 574 575 void 576 LsDumpAsciiInComment ( 577 UINT32 FileId, 578 UINT32 Count, 579 UINT8 *Buffer); 580 581 void 582 LsCheckException ( 583 UINT32 LineNumber, 584 UINT32 FileId); 585 586 void 587 LsFlushListingBuffer ( 588 UINT32 FileId); 589 590 void 591 LsWriteListingHexBytes ( 592 UINT8 *Buffer, 593 UINT32 Length, 594 UINT32 FileId); 595 596 void 597 LsWriteSourceLines ( 598 UINT32 ToLineNumber, 599 UINT32 ToLogicalLineNumber, 600 UINT32 FileId); 601 602 UINT32 603 LsWriteOneSourceLine ( 604 UINT32 FileId); 605 606 void 607 LsPushNode ( 608 char *Filename); 609 610 ASL_LISTING_NODE * 611 LsPopNode ( 612 void); 613 614 615 /* 616 * aslhex - generate all "hex" output files (C, ASM, ASL) 617 */ 618 void 619 HxDoHexOutput ( 620 void); 621 622 623 /* 624 * aslfold - constant folding 625 */ 626 ACPI_STATUS 627 OpcAmlConstantWalk ( 628 ACPI_PARSE_OBJECT *Op, 629 UINT32 Level, 630 void *Context); 631 632 633 /* 634 * aslmessages - exception strings 635 */ 636 const char * 637 AeDecodeMessageId ( 638 UINT16 MessageId); 639 640 const char * 641 AeDecodeExceptionLevel ( 642 UINT8 Level); 643 644 UINT16 645 AeBuildFullExceptionCode ( 646 UINT8 Level, 647 UINT16 MessageId); 648 649 /* 650 * asloffset - generate C offset file for BIOS support 651 */ 652 ACPI_STATUS 653 LsAmlOffsetWalk ( 654 ACPI_PARSE_OBJECT *Op, 655 UINT32 Level, 656 void *Context); 657 658 void 659 LsDoOffsetTableHeader ( 660 UINT32 FileId); 661 662 void 663 LsDoOffsetTableFooter ( 664 UINT32 FileId); 665 666 667 /* 668 * aslopcodes - generate AML opcodes 669 */ 670 ACPI_STATUS 671 OpcAmlOpcodeWalk ( 672 ACPI_PARSE_OBJECT *Op, 673 UINT32 Level, 674 void *Context); 675 676 ACPI_STATUS 677 OpcAmlOpcodeUpdateWalk ( 678 ACPI_PARSE_OBJECT *Op, 679 UINT32 Level, 680 void *Context); 681 682 void 683 OpcGenerateAmlOpcode ( 684 ACPI_PARSE_OBJECT *Op); 685 686 UINT32 687 OpcSetOptimalIntegerSize ( 688 ACPI_PARSE_OBJECT *Op); 689 690 void 691 OpcGetIntegerWidth ( 692 ACPI_PARSE_OBJECT *Op); 693 694 695 /* 696 * asloperands - generate AML operands for the AML opcodes 697 */ 698 ACPI_PARSE_OBJECT * 699 UtGetArg ( 700 ACPI_PARSE_OBJECT *Op, 701 UINT32 Argn); 702 703 void 704 OpnGenerateAmlOperands ( 705 ACPI_PARSE_OBJECT *Op); 706 707 void 708 OpnDoPackage ( 709 ACPI_PARSE_OBJECT *Op); 710 711 712 /* 713 * aslopt - optimization 714 */ 715 void 716 OptOptimizeNamePath ( 717 ACPI_PARSE_OBJECT *Op, 718 UINT32 Flags, 719 ACPI_WALK_STATE *WalkState, 720 char *AmlNameString, 721 ACPI_NAMESPACE_NODE *TargetNode); 722 723 724 /* 725 * aslpld - ToPLD macro support 726 */ 727 void 728 OpcDoPld ( 729 ACPI_PARSE_OBJECT *Op); 730 731 732 /* 733 * aslprintf - Printf/Fprintf macros 734 */ 735 void 736 OpcDoPrintf ( 737 ACPI_PARSE_OBJECT *Op); 738 739 void 740 OpcDoFprintf ( 741 ACPI_PARSE_OBJECT *Op); 742 743 744 /* 745 * aslprune - parse tree pruner 746 */ 747 void 748 AslPruneParseTree ( 749 UINT32 PruneDepth, 750 UINT32 Type); 751 752 753 /* 754 * aslcodegen - code generation 755 */ 756 void 757 CgGenerateAmlOutput ( 758 void); 759 760 void 761 CgLocalWriteAmlData ( 762 ACPI_PARSE_OBJECT *Op, 763 void *Buffer, 764 UINT32 Length); 765 766 767 /* 768 * aslfile 769 */ 770 void 771 FlOpenFile ( 772 UINT32 FileId, 773 char *Filename, 774 char *Mode); 775 776 777 /* 778 * asllength - calculate/adjust AML package lengths 779 */ 780 ACPI_STATUS 781 LnPackageLengthWalk ( 782 ACPI_PARSE_OBJECT *Op, 783 UINT32 Level, 784 void *Context); 785 786 ACPI_STATUS 787 LnInitLengthsWalk ( 788 ACPI_PARSE_OBJECT *Op, 789 UINT32 Level, 790 void *Context); 791 792 void 793 CgGenerateAmlLengths ( 794 ACPI_PARSE_OBJECT *Op); 795 796 797 /* 798 * aslmap - opcode mappings and reserved method names 799 */ 800 ACPI_OBJECT_TYPE 801 AslMapNamedOpcodeToDataType ( 802 UINT16 Opcode); 803 804 805 /* 806 * aslpredef - ACPI predefined names support 807 */ 808 BOOLEAN 809 ApCheckForPredefinedMethod ( 810 ACPI_PARSE_OBJECT *Op, 811 ASL_METHOD_INFO *MethodInfo); 812 813 void 814 ApCheckPredefinedReturnValue ( 815 ACPI_PARSE_OBJECT *Op, 816 ASL_METHOD_INFO *MethodInfo); 817 818 UINT32 819 ApCheckForPredefinedName ( 820 ACPI_PARSE_OBJECT *Op, 821 char *Name); 822 823 void 824 ApCheckForPredefinedObject ( 825 ACPI_PARSE_OBJECT *Op, 826 char *Name); 827 828 ACPI_STATUS 829 ApCheckObjectType ( 830 const char *PredefinedName, 831 ACPI_PARSE_OBJECT *Op, 832 UINT32 ExpectedBtypes, 833 UINT32 PackageIndex); 834 835 void 836 ApDisplayReservedNames ( 837 void); 838 839 840 /* 841 * aslprepkg - ACPI predefined names support for packages 842 */ 843 void 844 ApCheckPackage ( 845 ACPI_PARSE_OBJECT *ParentOp, 846 const ACPI_PREDEFINED_INFO *Predefined); 847 848 849 /* 850 * asltransform - parse tree transformations 851 */ 852 ACPI_STATUS 853 TrAmlTransformWalkBegin ( 854 ACPI_PARSE_OBJECT *Op, 855 UINT32 Level, 856 void *Context); 857 858 ACPI_STATUS 859 TrAmlTransformWalkEnd ( 860 ACPI_PARSE_OBJECT *Op, 861 UINT32 Level, 862 void *Context); 863 864 865 /* 866 * aslexternal - External opcode support 867 */ 868 ACPI_STATUS 869 ExAmlExternalWalkBegin ( 870 ACPI_PARSE_OBJECT *Op, 871 UINT32 Level, 872 void *Context); 873 874 ACPI_STATUS 875 ExAmlExternalWalkEnd ( 876 ACPI_PARSE_OBJECT *Op, 877 UINT32 Level, 878 void *Context); 879 880 void 881 ExDoExternal ( 882 ACPI_PARSE_OBJECT *Op); 883 884 /* Values for "Visitation" parameter above */ 885 886 #define ASL_WALK_VISIT_DOWNWARD 0x01 887 #define ASL_WALK_VISIT_UPWARD 0x02 888 #define ASL_WALK_VISIT_DB_SEPARATELY 0x04 889 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) 890 891 892 /* 893 * aslparseop.c - Parse op create/allocate/cache 894 */ 895 ACPI_PARSE_OBJECT * 896 TrCreateOp ( 897 UINT32 ParseOpcode, 898 UINT32 NumChildren, 899 ...); 900 901 ACPI_PARSE_OBJECT * 902 TrCreateLeafOp ( 903 UINT32 ParseOpcode); 904 905 ACPI_PARSE_OBJECT * 906 TrCreateNullTargetOp ( 907 void); 908 909 ACPI_PARSE_OBJECT * 910 TrCreateAssignmentOp ( 911 ACPI_PARSE_OBJECT *Target, 912 ACPI_PARSE_OBJECT *Source); 913 914 ACPI_PARSE_OBJECT * 915 TrCreateTargetOp ( 916 ACPI_PARSE_OBJECT *OriginalOp, 917 ACPI_PARSE_OBJECT *ParentOp); 918 919 ACPI_PARSE_OBJECT * 920 TrCreateValuedLeafOp ( 921 UINT32 ParseOpcode, 922 UINT64 Value); 923 924 ACPI_PARSE_OBJECT * 925 TrCreateConstantLeafOp ( 926 UINT32 ParseOpcode); 927 928 ACPI_PARSE_OBJECT * 929 TrAllocateOp ( 930 UINT32 ParseOpcode); 931 932 void 933 TrPrintOpFlags ( 934 UINT32 Flags, 935 UINT32 OutputLevel); 936 937 938 /* 939 * asltree.c - Parse tree management 940 */ 941 void 942 TrSetOpParent ( 943 ACPI_PARSE_OBJECT *Op, 944 ACPI_PARSE_OBJECT *ParentOp); 945 946 ACPI_PARSE_OBJECT * 947 TrSetOpIntegerValue ( 948 UINT32 ParseOpcode, 949 ACPI_PARSE_OBJECT *Op); 950 951 void 952 TrSetOpEndLineNumber ( 953 ACPI_PARSE_OBJECT *Op); 954 955 void 956 TrSetOpCurrentFilename ( 957 ACPI_PARSE_OBJECT *Op); 958 959 void 960 TrSetOpIntegerWidth ( 961 ACPI_PARSE_OBJECT *TableSignature, 962 ACPI_PARSE_OBJECT *Revision); 963 964 ACPI_PARSE_OBJECT * 965 TrLinkOpChildren ( 966 ACPI_PARSE_OBJECT *Op, 967 UINT32 NumChildren, 968 ...); 969 970 ACPI_PARSE_OBJECT * 971 TrLinkPeerOp ( 972 ACPI_PARSE_OBJECT *Op1, 973 ACPI_PARSE_OBJECT *Op2); 974 975 ACPI_PARSE_OBJECT * 976 TrLinkChildOp ( 977 ACPI_PARSE_OBJECT *Op1, 978 ACPI_PARSE_OBJECT *Op2); 979 980 ACPI_PARSE_OBJECT * 981 TrSetOpFlags ( 982 ACPI_PARSE_OBJECT *Op, 983 UINT32 Flags); 984 985 ACPI_PARSE_OBJECT * 986 TrSetOpAmlLength ( 987 ACPI_PARSE_OBJECT *Op, 988 UINT32 Length); 989 990 ACPI_PARSE_OBJECT * 991 TrLinkPeerOps ( 992 UINT32 NumPeers, 993 ...); 994 995 ACPI_STATUS 996 TrWalkParseTree ( 997 ACPI_PARSE_OBJECT *Op, 998 UINT32 Visitation, 999 ASL_WALK_CALLBACK DescendingCallback, 1000 ASL_WALK_CALLBACK AscendingCallback, 1001 void *Context); 1002 1003 1004 /* 1005 * aslfiles - File I/O support 1006 */ 1007 void 1008 FlAddIncludeDirectory ( 1009 char *Dir); 1010 1011 char * 1012 FlMergePathnames ( 1013 char *PrefixDir, 1014 char *FilePathname); 1015 1016 void 1017 FlOpenIncludeFile ( 1018 ACPI_PARSE_OBJECT *Op); 1019 1020 void 1021 FlFileError ( 1022 UINT32 FileId, 1023 UINT8 ErrorId); 1024 1025 UINT32 1026 FlGetFileSize ( 1027 UINT32 FileId); 1028 1029 ACPI_STATUS 1030 FlReadFile ( 1031 UINT32 FileId, 1032 void *Buffer, 1033 UINT32 Length); 1034 1035 void 1036 FlWriteFile ( 1037 UINT32 FileId, 1038 void *Buffer, 1039 UINT32 Length); 1040 1041 void 1042 FlSeekFile ( 1043 UINT32 FileId, 1044 long Offset); 1045 1046 void 1047 FlSeekFileSet ( 1048 UINT32 FileId, 1049 long Offset); 1050 1051 void 1052 FlCloseFile ( 1053 UINT32 FileId); 1054 1055 ACPI_PRINTF_LIKE (2) 1056 void 1057 FlPrintFile ( 1058 UINT32 FileId, 1059 char *Format, 1060 ...); 1061 1062 void 1063 FlDeleteFile ( 1064 UINT32 FileId); 1065 1066 void 1067 FlSetLineNumber ( 1068 UINT32 LineNumber); 1069 1070 void 1071 FlSetFilename ( 1072 char *Filename); 1073 1074 ACPI_STATUS 1075 FlOpenInputFile ( 1076 char *InputFilename); 1077 1078 ACPI_STATUS 1079 FlOpenAmlOutputFile ( 1080 char *InputFilename); 1081 1082 ACPI_STATUS 1083 FlOpenMiscOutputFiles ( 1084 char *InputFilename); 1085 1086 ACPI_STATUS 1087 FlInitOneFile ( 1088 char *InputFilename); 1089 1090 ASL_FILE_SWITCH_STATUS 1091 FlSwitchFileSet ( 1092 char *InputFilename); 1093 1094 FILE * 1095 FlGetFileHandle ( 1096 UINT32 OutFileId, 1097 UINT32 InFileId, 1098 char *Filename); 1099 1100 ASL_GLOBAL_FILE_NODE * 1101 FlGetFileNode ( 1102 UINT32 FileId, 1103 char *Filename); 1104 1105 ASL_GLOBAL_FILE_NODE * 1106 FlGetCurrentFileNode ( 1107 void); 1108 1109 1110 /* 1111 * aslhwmap - hardware map summary 1112 */ 1113 void 1114 MpEmitMappingInfo ( 1115 void); 1116 1117 1118 /* 1119 * asload - load namespace in prep for cross reference 1120 */ 1121 ACPI_STATUS 1122 LdLoadNamespace ( 1123 ACPI_PARSE_OBJECT *RootOp); 1124 1125 /* 1126 * asllookup - namespace lookup functions 1127 */ 1128 void 1129 LkFindUnreferencedObjects ( 1130 void); 1131 1132 1133 /* 1134 * aslhelp - help screens 1135 */ 1136 void 1137 Usage ( 1138 void); 1139 1140 void 1141 AslFilenameHelp ( 1142 void); 1143 1144 void 1145 AslDisassemblyHelp ( 1146 void); 1147 1148 1149 /* 1150 * aslnamesp - namespace output file generation 1151 */ 1152 ACPI_STATUS 1153 NsDisplayNamespace ( 1154 void); 1155 1156 void 1157 NsSetupNamespaceListing ( 1158 void *Handle); 1159 1160 1161 /* 1162 * asloptions - command line processing 1163 */ 1164 int 1165 AslCommandLine ( 1166 int argc, 1167 char **argv); 1168 1169 1170 /* 1171 * aslxref - namespace cross reference 1172 */ 1173 ACPI_STATUS 1174 XfCrossReferenceNamespace ( 1175 void); 1176 1177 1178 /* 1179 * aslxrefout 1180 */ 1181 void 1182 OtPrintHeaders ( 1183 char *Message); 1184 1185 void 1186 OtCreateXrefFile ( 1187 void); 1188 1189 void 1190 OtXrefWalkPart1 ( 1191 ACPI_PARSE_OBJECT *Op, 1192 UINT32 Level, 1193 ASL_METHOD_INFO *MethodInfo); 1194 1195 1196 /* 1197 * aslutils - common compiler utilities 1198 */ 1199 ACPI_PRINTF_LIKE(2) 1200 void 1201 DbgPrint ( 1202 UINT32 Type, 1203 char *Format, 1204 ...); 1205 1206 /* Type values for above */ 1207 1208 #define ASL_DEBUG_OUTPUT 0 1209 #define ASL_PARSE_OUTPUT 1 1210 #define ASL_TREE_OUTPUT 2 1211 1212 UINT8 1213 UtIsBigEndianMachine ( 1214 void); 1215 1216 BOOLEAN 1217 UtQueryForOverwrite ( 1218 char *Pathname); 1219 1220 void 1221 UtDumpStringOp ( 1222 ACPI_PARSE_OBJECT *Op, 1223 UINT32 Level); 1224 1225 void 1226 UtDumpIntegerOp ( 1227 ACPI_PARSE_OBJECT *Op, 1228 UINT32 Level, 1229 UINT32 IntegerLength); 1230 1231 void 1232 UtDumpBasicOp ( 1233 ACPI_PARSE_OBJECT *Op, 1234 UINT32 Level); 1235 1236 void * 1237 UtGetParentMethod ( 1238 ACPI_NAMESPACE_NODE *Node); 1239 1240 BOOLEAN 1241 UtNodeIsDescendantOf ( 1242 ACPI_NAMESPACE_NODE *Node1, 1243 ACPI_NAMESPACE_NODE *Node2); 1244 1245 void 1246 UtDisplaySupportedTables ( 1247 void); 1248 1249 void 1250 UtDisplayConstantOpcodes ( 1251 void); 1252 1253 UINT8 1254 UtBeginEvent ( 1255 char *Name); 1256 1257 void 1258 UtEndEvent ( 1259 UINT8 Event); 1260 1261 void 1262 UtDisplaySummary ( 1263 UINT32 FileId); 1264 1265 void 1266 UtDisplayOneSummary ( 1267 UINT32 FileId, 1268 BOOLEAN DisplayErrorSummary); 1269 1270 void 1271 UtConvertByteToHex ( 1272 UINT8 RawByte, 1273 UINT8 *Buffer); 1274 1275 void 1276 UtConvertByteToAsmHex ( 1277 UINT8 RawByte, 1278 UINT8 *Buffer); 1279 1280 char * 1281 UtGetOpName ( 1282 UINT32 ParseOpcode); 1283 1284 void 1285 UtSetParseOpName ( 1286 ACPI_PARSE_OBJECT *Op); 1287 1288 ACPI_STATUS 1289 UtInternalizeName ( 1290 char *ExternalName, 1291 char **ConvertedName); 1292 1293 BOOLEAN 1294 UtNameContainsAllPrefix ( 1295 ACPI_PARSE_OBJECT *Op); 1296 1297 void 1298 UtAttachNamepathToOwner ( 1299 ACPI_PARSE_OBJECT *Op, 1300 ACPI_PARSE_OBJECT *NameNode); 1301 1302 ACPI_PARSE_OBJECT * 1303 UtCheckIntegerRange ( 1304 ACPI_PARSE_OBJECT *Op, 1305 UINT32 LowValue, 1306 UINT32 HighValue); 1307 1308 UINT64 1309 UtDoConstant ( 1310 char *String); 1311 1312 char * 1313 AcpiUtStrdup ( 1314 char *String); 1315 1316 char * 1317 AcpiUtStrcat ( 1318 char *String1, 1319 char *String2); 1320 1321 1322 /* 1323 * asluuid - UUID support 1324 */ 1325 ACPI_STATUS 1326 AuValidateUuid ( 1327 char *InString); 1328 1329 ACPI_STATUS 1330 AuConvertUuidToString ( 1331 char *UuIdBuffer, 1332 char *OutString); 1333 1334 1335 /* 1336 * aslresource - Resource template generation utilities 1337 */ 1338 void 1339 RsSmallAddressCheck ( 1340 UINT8 Type, 1341 UINT32 Minimum, 1342 UINT32 Maximum, 1343 UINT32 Length, 1344 UINT32 Alignment, 1345 ACPI_PARSE_OBJECT *MinOp, 1346 ACPI_PARSE_OBJECT *MaxOp, 1347 ACPI_PARSE_OBJECT *LengthOp, 1348 ACPI_PARSE_OBJECT *AlignOp, 1349 ACPI_PARSE_OBJECT *Op); 1350 1351 void 1352 RsLargeAddressCheck ( 1353 UINT64 Minimum, 1354 UINT64 Maximum, 1355 UINT64 Length, 1356 UINT64 Granularity, 1357 UINT8 Flags, 1358 ACPI_PARSE_OBJECT *MinOp, 1359 ACPI_PARSE_OBJECT *MaxOp, 1360 ACPI_PARSE_OBJECT *LengthOp, 1361 ACPI_PARSE_OBJECT *GranOp, 1362 ACPI_PARSE_OBJECT *Op); 1363 1364 UINT16 1365 RsGetStringDataLength ( 1366 ACPI_PARSE_OBJECT *InitializerOp); 1367 1368 ASL_RESOURCE_NODE * 1369 RsAllocateResourceNode ( 1370 UINT32 Size); 1371 1372 void 1373 RsCreateResourceField ( 1374 ACPI_PARSE_OBJECT *Op, 1375 char *Name, 1376 UINT32 ByteOffset, 1377 UINT32 BitOffset, 1378 UINT32 BitLength); 1379 1380 void 1381 RsSetFlagBits ( 1382 UINT8 *Flags, 1383 ACPI_PARSE_OBJECT *Op, 1384 UINT8 Position, 1385 UINT8 DefaultBit); 1386 1387 void 1388 RsSetFlagBits16 ( 1389 UINT16 *Flags, 1390 ACPI_PARSE_OBJECT *Op, 1391 UINT8 Position, 1392 UINT8 DefaultBit); 1393 1394 ACPI_PARSE_OBJECT * 1395 RsCompleteNodeAndGetNext ( 1396 ACPI_PARSE_OBJECT *Op); 1397 1398 void 1399 RsCheckListForDuplicates ( 1400 ACPI_PARSE_OBJECT *Op); 1401 1402 ASL_RESOURCE_NODE * 1403 RsDoOneResourceDescriptor ( 1404 ASL_RESOURCE_INFO *Info, 1405 UINT8 *State); 1406 1407 /* Values for State above */ 1408 1409 #define ACPI_RSTATE_NORMAL 0 1410 #define ACPI_RSTATE_START_DEPENDENT 1 1411 #define ACPI_RSTATE_DEPENDENT_LIST 2 1412 1413 UINT32 1414 RsLinkDescriptorChain ( 1415 ASL_RESOURCE_NODE **PreviousRnode, 1416 ASL_RESOURCE_NODE *Rnode); 1417 1418 void 1419 RsDoResourceTemplate ( 1420 ACPI_PARSE_OBJECT *Op); 1421 1422 1423 /* 1424 * aslrestype1 - Miscellaneous Small descriptors 1425 */ 1426 ASL_RESOURCE_NODE * 1427 RsDoEndTagDescriptor ( 1428 ASL_RESOURCE_INFO *Info); 1429 1430 ASL_RESOURCE_NODE * 1431 RsDoEndDependentDescriptor ( 1432 ASL_RESOURCE_INFO *Info); 1433 1434 ASL_RESOURCE_NODE * 1435 RsDoMemory24Descriptor ( 1436 ASL_RESOURCE_INFO *Info); 1437 1438 ASL_RESOURCE_NODE * 1439 RsDoMemory32Descriptor ( 1440 ASL_RESOURCE_INFO *Info); 1441 1442 ASL_RESOURCE_NODE * 1443 RsDoMemory32FixedDescriptor ( 1444 ASL_RESOURCE_INFO *Info); 1445 1446 ASL_RESOURCE_NODE * 1447 RsDoStartDependentDescriptor ( 1448 ASL_RESOURCE_INFO *Info); 1449 1450 ASL_RESOURCE_NODE * 1451 RsDoStartDependentNoPriDescriptor ( 1452 ASL_RESOURCE_INFO *Info); 1453 1454 ASL_RESOURCE_NODE * 1455 RsDoVendorSmallDescriptor ( 1456 ASL_RESOURCE_INFO *Info); 1457 1458 1459 /* 1460 * aslrestype1i - I/O-related Small descriptors 1461 */ 1462 ASL_RESOURCE_NODE * 1463 RsDoDmaDescriptor ( 1464 ASL_RESOURCE_INFO *Info); 1465 1466 ASL_RESOURCE_NODE * 1467 RsDoFixedDmaDescriptor ( 1468 ASL_RESOURCE_INFO *Info); 1469 1470 ASL_RESOURCE_NODE * 1471 RsDoFixedIoDescriptor ( 1472 ASL_RESOURCE_INFO *Info); 1473 1474 ASL_RESOURCE_NODE * 1475 RsDoIoDescriptor ( 1476 ASL_RESOURCE_INFO *Info); 1477 1478 ASL_RESOURCE_NODE * 1479 RsDoIrqDescriptor ( 1480 ASL_RESOURCE_INFO *Info); 1481 1482 ASL_RESOURCE_NODE * 1483 RsDoIrqNoFlagsDescriptor ( 1484 ASL_RESOURCE_INFO *Info); 1485 1486 1487 /* 1488 * aslrestype2 - Large resource descriptors 1489 */ 1490 ASL_RESOURCE_NODE * 1491 RsDoInterruptDescriptor ( 1492 ASL_RESOURCE_INFO *Info); 1493 1494 ASL_RESOURCE_NODE * 1495 RsDoVendorLargeDescriptor ( 1496 ASL_RESOURCE_INFO *Info); 1497 1498 ASL_RESOURCE_NODE * 1499 RsDoGeneralRegisterDescriptor ( 1500 ASL_RESOURCE_INFO *Info); 1501 1502 ASL_RESOURCE_NODE * 1503 RsDoGpioIntDescriptor ( 1504 ASL_RESOURCE_INFO *Info); 1505 1506 ASL_RESOURCE_NODE * 1507 RsDoGpioIoDescriptor ( 1508 ASL_RESOURCE_INFO *Info); 1509 1510 ASL_RESOURCE_NODE * 1511 RsDoI2cSerialBusDescriptor ( 1512 ASL_RESOURCE_INFO *Info); 1513 1514 ASL_RESOURCE_NODE * 1515 RsDoSpiSerialBusDescriptor ( 1516 ASL_RESOURCE_INFO *Info); 1517 1518 ASL_RESOURCE_NODE * 1519 RsDoUartSerialBusDescriptor ( 1520 ASL_RESOURCE_INFO *Info); 1521 1522 ASL_RESOURCE_NODE * 1523 RsDoPinFunctionDescriptor ( 1524 ASL_RESOURCE_INFO *Info); 1525 1526 ASL_RESOURCE_NODE * 1527 RsDoPinConfigDescriptor ( 1528 ASL_RESOURCE_INFO *Info); 1529 1530 ASL_RESOURCE_NODE * 1531 RsDoPinGroupDescriptor ( 1532 ASL_RESOURCE_INFO *Info); 1533 1534 ASL_RESOURCE_NODE * 1535 RsDoPinGroupFunctionDescriptor ( 1536 ASL_RESOURCE_INFO *Info); 1537 1538 ASL_RESOURCE_NODE * 1539 RsDoPinGroupConfigDescriptor ( 1540 ASL_RESOURCE_INFO *Info); 1541 1542 1543 /* 1544 * aslrestype2d - DWord address descriptors 1545 */ 1546 ASL_RESOURCE_NODE * 1547 RsDoDwordIoDescriptor ( 1548 ASL_RESOURCE_INFO *Info); 1549 1550 ASL_RESOURCE_NODE * 1551 RsDoDwordMemoryDescriptor ( 1552 ASL_RESOURCE_INFO *Info); 1553 1554 ASL_RESOURCE_NODE * 1555 RsDoDwordSpaceDescriptor ( 1556 ASL_RESOURCE_INFO *Info); 1557 1558 1559 /* 1560 * aslrestype2e - Extended address descriptors 1561 */ 1562 ASL_RESOURCE_NODE * 1563 RsDoExtendedIoDescriptor ( 1564 ASL_RESOURCE_INFO *Info); 1565 1566 ASL_RESOURCE_NODE * 1567 RsDoExtendedMemoryDescriptor ( 1568 ASL_RESOURCE_INFO *Info); 1569 1570 ASL_RESOURCE_NODE * 1571 RsDoExtendedSpaceDescriptor ( 1572 ASL_RESOURCE_INFO *Info); 1573 1574 1575 /* 1576 * aslrestype2q - QWord address descriptors 1577 */ 1578 ASL_RESOURCE_NODE * 1579 RsDoQwordIoDescriptor ( 1580 ASL_RESOURCE_INFO *Info); 1581 1582 ASL_RESOURCE_NODE * 1583 RsDoQwordMemoryDescriptor ( 1584 ASL_RESOURCE_INFO *Info); 1585 1586 ASL_RESOURCE_NODE * 1587 RsDoQwordSpaceDescriptor ( 1588 ASL_RESOURCE_INFO *Info); 1589 1590 1591 /* 1592 * aslrestype2w - Word address descriptors 1593 */ 1594 ASL_RESOURCE_NODE * 1595 RsDoWordIoDescriptor ( 1596 ASL_RESOURCE_INFO *Info); 1597 1598 ASL_RESOURCE_NODE * 1599 RsDoWordSpaceDescriptor ( 1600 ASL_RESOURCE_INFO *Info); 1601 1602 ASL_RESOURCE_NODE * 1603 RsDoWordBusNumberDescriptor ( 1604 ASL_RESOURCE_INFO *Info); 1605 1606 1607 /* 1608 * Entry to data table compiler subsystem 1609 */ 1610 ACPI_STATUS 1611 DtDoCompile( 1612 void); 1613 1614 ACPI_STATUS 1615 DtCreateTemplates ( 1616 char **argv); 1617 1618 1619 /* 1620 * ASL/ASL+ converter debug 1621 */ 1622 ACPI_PRINTF_LIKE (1) 1623 void 1624 CvDbgPrint ( 1625 char *Fmt, 1626 ...); 1627 1628 1629 #endif /* __ASLCOMPILER_H */ 1630