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 UINT32 377 MtProcessTypeOp ( 378 ACPI_PARSE_OBJECT *TypeOp); 379 380 UINT8 381 MtProcessParameterTypeList ( 382 ACPI_PARSE_OBJECT *ParamTypeOp, 383 UINT32 *TypeList); 384 385 386 /* 387 * aslbtypes - bitfield data types 388 */ 389 UINT32 390 AnMapObjTypeToBtype ( 391 ACPI_PARSE_OBJECT *Op); 392 393 UINT32 394 AnMapArgTypeToBtype ( 395 UINT32 ArgType); 396 397 UINT32 398 AnGetBtype ( 399 ACPI_PARSE_OBJECT *Op); 400 401 void 402 AnFormatBtype ( 403 char *Buffer, 404 UINT32 Btype); 405 406 407 /* 408 * aslanalyze - Support functions for parse tree walks 409 */ 410 void 411 AnCheckId ( 412 ACPI_PARSE_OBJECT *Op, 413 ACPI_NAME Type); 414 415 /* Values for Type argument above */ 416 417 #define ASL_TYPE_HID 0 418 #define ASL_TYPE_CID 1 419 420 BOOLEAN 421 AnIsInternalMethod ( 422 ACPI_PARSE_OBJECT *Op); 423 424 UINT32 425 AnGetInternalMethodReturnType ( 426 ACPI_PARSE_OBJECT *Op); 427 428 BOOLEAN 429 AnLastStatementIsReturn ( 430 ACPI_PARSE_OBJECT *Op); 431 432 void 433 AnCheckMethodReturnValue ( 434 ACPI_PARSE_OBJECT *Op, 435 const ACPI_OPCODE_INFO *OpInfo, 436 ACPI_PARSE_OBJECT *ArgOp, 437 UINT32 RequiredBtypes, 438 UINT32 ThisNodeBtype); 439 440 BOOLEAN 441 AnIsResultUsed ( 442 ACPI_PARSE_OBJECT *Op); 443 444 void 445 ApCheckForGpeNameConflict ( 446 ACPI_PARSE_OBJECT *Op); 447 448 void 449 ApCheckRegMethod ( 450 ACPI_PARSE_OBJECT *Op); 451 452 BOOLEAN 453 ApFindNameInScope ( 454 char *Name, 455 ACPI_PARSE_OBJECT *Op); 456 457 BOOLEAN 458 ApFindNameInDeviceTree ( 459 char *Name, 460 ACPI_PARSE_OBJECT *Op); 461 462 /* 463 * aslerror - error handling/reporting 464 */ 465 void 466 AslAbort ( 467 void); 468 469 void 470 AslDualParseOpError ( 471 UINT8 Level, 472 UINT16 MainMessageId, 473 ACPI_PARSE_OBJECT *MainOp, 474 char *MainMessage, 475 UINT16 SecondMessageId, 476 ACPI_PARSE_OBJECT *SecondOp, 477 char *SecondaryMessage); 478 479 void 480 AslError ( 481 UINT8 Level, 482 UINT16 MessageId, 483 ACPI_PARSE_OBJECT *Op, 484 char *ExtraMessage); 485 486 void 487 AslCheckExpectedExceptions ( 488 void); 489 490 ACPI_STATUS 491 AslExpectException ( 492 char *MessageIdString); 493 494 ACPI_STATUS 495 AslElevateException ( 496 char *MessageIdString); 497 498 ACPI_STATUS 499 AslDisableException ( 500 char *MessageIdString); 501 502 BOOLEAN 503 AslIsExceptionIgnored ( 504 UINT8 Level, 505 UINT16 MessageId); 506 507 void 508 AslCoreSubsystemError ( 509 ACPI_PARSE_OBJECT *Op, 510 ACPI_STATUS Status, 511 char *ExtraMessage, 512 BOOLEAN Abort); 513 514 int 515 AslCompilererror( 516 const char *s); 517 518 void 519 AslCommonError ( 520 UINT8 Level, 521 UINT16 MessageId, 522 UINT32 CurrentLineNumber, 523 UINT32 LogicalLineNumber, 524 UINT32 LogicalByteOffset, 525 UINT32 Column, 526 char *Filename, 527 char *ExtraMessage); 528 529 void 530 AslCommonError2 ( 531 UINT8 Level, 532 UINT16 MessageId, 533 UINT32 LineNumber, 534 UINT32 Column, 535 char *SourceLine, 536 char *Filename, 537 char *ExtraMessage); 538 539 void 540 AePrintException ( 541 UINT32 FileId, 542 ASL_ERROR_MSG *Enode, 543 char *Header); 544 545 void 546 AePrintErrorLog ( 547 UINT32 FileId); 548 549 void 550 AeClearErrorLog ( 551 void); 552 553 554 /* 555 * asllisting - generate all "listing" type files 556 */ 557 void 558 LsDoListings ( 559 void); 560 561 void 562 LsWriteNodeToAsmListing ( 563 ACPI_PARSE_OBJECT *Op); 564 565 void 566 LsWriteNode ( 567 ACPI_PARSE_OBJECT *Op, 568 UINT32 FileId); 569 570 void 571 LsDumpParseTree ( 572 void); 573 574 575 /* 576 * asllistsup - Listing file support utilities 577 */ 578 void 579 LsDumpAscii ( 580 UINT32 FileId, 581 UINT32 Count, 582 UINT8 *Buffer); 583 584 void 585 LsDumpAsciiInComment ( 586 UINT32 FileId, 587 UINT32 Count, 588 UINT8 *Buffer); 589 590 void 591 LsCheckException ( 592 UINT32 LineNumber, 593 UINT32 FileId); 594 595 void 596 LsFlushListingBuffer ( 597 UINT32 FileId); 598 599 void 600 LsWriteListingHexBytes ( 601 UINT8 *Buffer, 602 UINT32 Length, 603 UINT32 FileId); 604 605 void 606 LsWriteSourceLines ( 607 UINT32 ToLineNumber, 608 UINT32 ToLogicalLineNumber, 609 UINT32 FileId); 610 611 UINT32 612 LsWriteOneSourceLine ( 613 UINT32 FileId); 614 615 void 616 LsPushNode ( 617 char *Filename); 618 619 ASL_LISTING_NODE * 620 LsPopNode ( 621 void); 622 623 624 /* 625 * aslhex - generate all "hex" output files (C, ASM, ASL) 626 */ 627 void 628 HxDoHexOutput ( 629 void); 630 631 632 /* 633 * aslfold - constant folding 634 */ 635 ACPI_STATUS 636 OpcAmlConstantWalk ( 637 ACPI_PARSE_OBJECT *Op, 638 UINT32 Level, 639 void *Context); 640 641 642 /* 643 * aslmessages - exception strings 644 */ 645 const char * 646 AeDecodeMessageId ( 647 UINT16 MessageId); 648 649 const char * 650 AeDecodeExceptionLevel ( 651 UINT8 Level); 652 653 UINT16 654 AeBuildFullExceptionCode ( 655 UINT8 Level, 656 UINT16 MessageId); 657 658 /* 659 * asloffset - generate C offset file for BIOS support 660 */ 661 ACPI_STATUS 662 LsAmlOffsetWalk ( 663 ACPI_PARSE_OBJECT *Op, 664 UINT32 Level, 665 void *Context); 666 667 void 668 LsDoOffsetTableHeader ( 669 UINT32 FileId); 670 671 void 672 LsDoOffsetTableFooter ( 673 UINT32 FileId); 674 675 676 /* 677 * aslopcodes - generate AML opcodes 678 */ 679 ACPI_STATUS 680 OpcAmlOpcodeWalk ( 681 ACPI_PARSE_OBJECT *Op, 682 UINT32 Level, 683 void *Context); 684 685 ACPI_STATUS 686 OpcAmlOpcodeUpdateWalk ( 687 ACPI_PARSE_OBJECT *Op, 688 UINT32 Level, 689 void *Context); 690 691 void 692 OpcGenerateAmlOpcode ( 693 ACPI_PARSE_OBJECT *Op); 694 695 UINT32 696 OpcSetOptimalIntegerSize ( 697 ACPI_PARSE_OBJECT *Op); 698 699 void 700 OpcGetIntegerWidth ( 701 ACPI_PARSE_OBJECT *Op); 702 703 704 /* 705 * asloperands - generate AML operands for the AML opcodes 706 */ 707 ACPI_PARSE_OBJECT * 708 UtGetArg ( 709 ACPI_PARSE_OBJECT *Op, 710 UINT32 Argn); 711 712 void 713 OpnGenerateAmlOperands ( 714 ACPI_PARSE_OBJECT *Op); 715 716 void 717 OpnDoPackage ( 718 ACPI_PARSE_OBJECT *Op); 719 720 721 /* 722 * aslopt - optimization 723 */ 724 void 725 OptOptimizeNamePath ( 726 ACPI_PARSE_OBJECT *Op, 727 UINT32 Flags, 728 ACPI_WALK_STATE *WalkState, 729 char *AmlNameString, 730 ACPI_NAMESPACE_NODE *TargetNode); 731 732 733 /* 734 * aslpld - ToPLD macro support 735 */ 736 void 737 OpcDoPld ( 738 ACPI_PARSE_OBJECT *Op); 739 740 741 /* 742 * aslprintf - Printf/Fprintf macros 743 */ 744 void 745 OpcDoPrintf ( 746 ACPI_PARSE_OBJECT *Op); 747 748 void 749 OpcDoFprintf ( 750 ACPI_PARSE_OBJECT *Op); 751 752 753 /* 754 * aslprune - parse tree pruner 755 */ 756 void 757 AslPruneParseTree ( 758 UINT32 PruneDepth, 759 UINT32 Type); 760 761 762 /* 763 * aslcodegen - code generation 764 */ 765 void 766 CgGenerateAmlOutput ( 767 void); 768 769 void 770 CgLocalWriteAmlData ( 771 ACPI_PARSE_OBJECT *Op, 772 void *Buffer, 773 UINT32 Length); 774 775 776 /* 777 * aslfile 778 */ 779 void 780 FlOpenFile ( 781 UINT32 FileId, 782 char *Filename, 783 char *Mode); 784 785 786 /* 787 * asllength - calculate/adjust AML package lengths 788 */ 789 ACPI_STATUS 790 LnPackageLengthWalk ( 791 ACPI_PARSE_OBJECT *Op, 792 UINT32 Level, 793 void *Context); 794 795 ACPI_STATUS 796 LnInitLengthsWalk ( 797 ACPI_PARSE_OBJECT *Op, 798 UINT32 Level, 799 void *Context); 800 801 void 802 CgGenerateAmlLengths ( 803 ACPI_PARSE_OBJECT *Op); 804 805 806 /* 807 * aslmap - opcode mappings and reserved method names 808 */ 809 ACPI_OBJECT_TYPE 810 AslMapNamedOpcodeToDataType ( 811 UINT16 Opcode); 812 813 814 /* 815 * aslpredef - ACPI predefined names support 816 */ 817 BOOLEAN 818 ApCheckForPredefinedMethod ( 819 ACPI_PARSE_OBJECT *Op, 820 ASL_METHOD_INFO *MethodInfo); 821 822 void 823 ApCheckPredefinedReturnValue ( 824 ACPI_PARSE_OBJECT *Op, 825 ASL_METHOD_INFO *MethodInfo); 826 827 UINT32 828 ApCheckForPredefinedName ( 829 ACPI_PARSE_OBJECT *Op, 830 char *Name); 831 832 void 833 ApCheckForPredefinedObject ( 834 ACPI_PARSE_OBJECT *Op, 835 char *Name); 836 837 ACPI_STATUS 838 ApCheckObjectType ( 839 const char *PredefinedName, 840 ACPI_PARSE_OBJECT *Op, 841 UINT32 ExpectedBtypes, 842 UINT32 PackageIndex); 843 844 void 845 ApDisplayReservedNames ( 846 void); 847 848 849 /* 850 * aslprepkg - ACPI predefined names support for packages 851 */ 852 void 853 ApCheckPackage ( 854 ACPI_PARSE_OBJECT *ParentOp, 855 const ACPI_PREDEFINED_INFO *Predefined); 856 857 858 /* 859 * asltransform - parse tree transformations 860 */ 861 ACPI_STATUS 862 TrAmlTransformWalkBegin ( 863 ACPI_PARSE_OBJECT *Op, 864 UINT32 Level, 865 void *Context); 866 867 ACPI_STATUS 868 TrAmlTransformWalkEnd ( 869 ACPI_PARSE_OBJECT *Op, 870 UINT32 Level, 871 void *Context); 872 873 874 /* 875 * aslexternal - External opcode support 876 */ 877 ACPI_STATUS 878 ExAmlExternalWalkBegin ( 879 ACPI_PARSE_OBJECT *Op, 880 UINT32 Level, 881 void *Context); 882 883 ACPI_STATUS 884 ExAmlExternalWalkEnd ( 885 ACPI_PARSE_OBJECT *Op, 886 UINT32 Level, 887 void *Context); 888 889 void 890 ExDoExternal ( 891 ACPI_PARSE_OBJECT *Op); 892 893 /* Values for "Visitation" parameter above */ 894 895 #define ASL_WALK_VISIT_DOWNWARD 0x01 896 #define ASL_WALK_VISIT_UPWARD 0x02 897 #define ASL_WALK_VISIT_DB_SEPARATELY 0x04 898 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) 899 900 901 /* 902 * aslparseop.c - Parse op create/allocate/cache 903 */ 904 ACPI_PARSE_OBJECT * 905 TrCreateOp ( 906 UINT32 ParseOpcode, 907 UINT32 NumChildren, 908 ...); 909 910 ACPI_PARSE_OBJECT * 911 TrCreateLeafOp ( 912 UINT32 ParseOpcode); 913 914 ACPI_PARSE_OBJECT * 915 TrCreateNullTargetOp ( 916 void); 917 918 ACPI_PARSE_OBJECT * 919 TrCreateAssignmentOp ( 920 ACPI_PARSE_OBJECT *Target, 921 ACPI_PARSE_OBJECT *Source); 922 923 ACPI_PARSE_OBJECT * 924 TrCreateTargetOp ( 925 ACPI_PARSE_OBJECT *OriginalOp, 926 ACPI_PARSE_OBJECT *ParentOp); 927 928 ACPI_PARSE_OBJECT * 929 TrCreateValuedLeafOp ( 930 UINT32 ParseOpcode, 931 UINT64 Value); 932 933 ACPI_PARSE_OBJECT * 934 TrCreateConstantLeafOp ( 935 UINT32 ParseOpcode); 936 937 ACPI_PARSE_OBJECT * 938 TrAllocateOp ( 939 UINT32 ParseOpcode); 940 941 void 942 TrPrintOpFlags ( 943 UINT32 Flags, 944 UINT32 OutputLevel); 945 946 947 /* 948 * asltree.c - Parse tree management 949 */ 950 void 951 TrSetOpParent ( 952 ACPI_PARSE_OBJECT *Op, 953 ACPI_PARSE_OBJECT *ParentOp); 954 955 ACPI_PARSE_OBJECT * 956 TrSetOpIntegerValue ( 957 UINT32 ParseOpcode, 958 ACPI_PARSE_OBJECT *Op); 959 960 void 961 TrSetOpEndLineNumber ( 962 ACPI_PARSE_OBJECT *Op); 963 964 void 965 TrSetOpCurrentFilename ( 966 ACPI_PARSE_OBJECT *Op); 967 968 void 969 TrSetOpIntegerWidth ( 970 ACPI_PARSE_OBJECT *TableSignature, 971 ACPI_PARSE_OBJECT *Revision); 972 973 ACPI_PARSE_OBJECT * 974 TrLinkOpChildren ( 975 ACPI_PARSE_OBJECT *Op, 976 UINT32 NumChildren, 977 ...); 978 979 ACPI_PARSE_OBJECT * 980 TrLinkPeerOp ( 981 ACPI_PARSE_OBJECT *Op1, 982 ACPI_PARSE_OBJECT *Op2); 983 984 ACPI_PARSE_OBJECT * 985 TrLinkChildOp ( 986 ACPI_PARSE_OBJECT *Op1, 987 ACPI_PARSE_OBJECT *Op2); 988 989 ACPI_PARSE_OBJECT * 990 TrSetOpFlags ( 991 ACPI_PARSE_OBJECT *Op, 992 UINT32 Flags); 993 994 ACPI_PARSE_OBJECT * 995 TrSetOpAmlLength ( 996 ACPI_PARSE_OBJECT *Op, 997 UINT32 Length); 998 999 ACPI_PARSE_OBJECT * 1000 TrLinkPeerOps ( 1001 UINT32 NumPeers, 1002 ...); 1003 1004 ACPI_STATUS 1005 TrWalkParseTree ( 1006 ACPI_PARSE_OBJECT *Op, 1007 UINT32 Visitation, 1008 ASL_WALK_CALLBACK DescendingCallback, 1009 ASL_WALK_CALLBACK AscendingCallback, 1010 void *Context); 1011 1012 1013 /* 1014 * aslfiles - File I/O support 1015 */ 1016 void 1017 FlAddIncludeDirectory ( 1018 char *Dir); 1019 1020 char * 1021 FlMergePathnames ( 1022 char *PrefixDir, 1023 char *FilePathname); 1024 1025 void 1026 FlOpenIncludeFile ( 1027 ACPI_PARSE_OBJECT *Op); 1028 1029 void 1030 FlFileError ( 1031 UINT32 FileId, 1032 UINT8 ErrorId); 1033 1034 UINT32 1035 FlGetFileSize ( 1036 UINT32 FileId); 1037 1038 ACPI_STATUS 1039 FlReadFile ( 1040 UINT32 FileId, 1041 void *Buffer, 1042 UINT32 Length); 1043 1044 void 1045 FlWriteFile ( 1046 UINT32 FileId, 1047 void *Buffer, 1048 UINT32 Length); 1049 1050 void 1051 FlSeekFile ( 1052 UINT32 FileId, 1053 long Offset); 1054 1055 void 1056 FlSeekFileSet ( 1057 UINT32 FileId, 1058 long Offset); 1059 1060 void 1061 FlCloseFile ( 1062 UINT32 FileId); 1063 1064 ACPI_PRINTF_LIKE (2) 1065 void 1066 FlPrintFile ( 1067 UINT32 FileId, 1068 char *Format, 1069 ...); 1070 1071 void 1072 FlDeleteFile ( 1073 UINT32 FileId); 1074 1075 void 1076 FlSetLineNumber ( 1077 UINT32 LineNumber); 1078 1079 void 1080 FlSetFilename ( 1081 char *Filename); 1082 1083 ACPI_STATUS 1084 FlOpenInputFile ( 1085 char *InputFilename); 1086 1087 ACPI_STATUS 1088 FlOpenAmlOutputFile ( 1089 char *InputFilename); 1090 1091 ACPI_STATUS 1092 FlOpenMiscOutputFiles ( 1093 char *InputFilename); 1094 1095 ACPI_STATUS 1096 FlInitOneFile ( 1097 char *InputFilename); 1098 1099 ASL_FILE_SWITCH_STATUS 1100 FlSwitchFileSet ( 1101 char *InputFilename); 1102 1103 FILE * 1104 FlGetFileHandle ( 1105 UINT32 OutFileId, 1106 UINT32 InFileId, 1107 char *Filename); 1108 1109 ASL_GLOBAL_FILE_NODE * 1110 FlGetFileNode ( 1111 UINT32 FileId, 1112 char *Filename); 1113 1114 ASL_GLOBAL_FILE_NODE * 1115 FlGetCurrentFileNode ( 1116 void); 1117 1118 1119 /* 1120 * aslhwmap - hardware map summary 1121 */ 1122 void 1123 MpEmitMappingInfo ( 1124 void); 1125 1126 1127 /* 1128 * asload - load namespace in prep for cross reference 1129 */ 1130 ACPI_STATUS 1131 LdLoadNamespace ( 1132 ACPI_PARSE_OBJECT *RootOp); 1133 1134 /* 1135 * asllookup - namespace lookup functions 1136 */ 1137 void 1138 LkFindUnreferencedObjects ( 1139 void); 1140 1141 1142 /* 1143 * aslhelp - help screens 1144 */ 1145 void 1146 Usage ( 1147 void); 1148 1149 void 1150 AslFilenameHelp ( 1151 void); 1152 1153 void 1154 AslDisassemblyHelp ( 1155 void); 1156 1157 1158 /* 1159 * aslnamesp - namespace output file generation 1160 */ 1161 ACPI_STATUS 1162 NsDisplayNamespace ( 1163 void); 1164 1165 void 1166 NsSetupNamespaceListing ( 1167 void *Handle); 1168 1169 1170 /* 1171 * asloptions - command line processing 1172 */ 1173 int 1174 AslCommandLine ( 1175 int argc, 1176 char **argv); 1177 1178 1179 /* 1180 * aslxref - namespace cross reference 1181 */ 1182 ACPI_STATUS 1183 XfCrossReferenceNamespace ( 1184 void); 1185 1186 1187 /* 1188 * aslxrefout 1189 */ 1190 void 1191 OtPrintHeaders ( 1192 char *Message); 1193 1194 void 1195 OtCreateXrefFile ( 1196 void); 1197 1198 void 1199 OtXrefWalkPart1 ( 1200 ACPI_PARSE_OBJECT *Op, 1201 UINT32 Level, 1202 ASL_METHOD_INFO *MethodInfo); 1203 1204 1205 /* 1206 * aslutils - common compiler utilities 1207 */ 1208 ACPI_PRINTF_LIKE(2) 1209 void 1210 DbgPrint ( 1211 UINT32 Type, 1212 char *Format, 1213 ...); 1214 1215 /* Type values for above */ 1216 1217 #define ASL_DEBUG_OUTPUT 0 1218 #define ASL_PARSE_OUTPUT 1 1219 #define ASL_TREE_OUTPUT 2 1220 1221 UINT8 1222 UtIsBigEndianMachine ( 1223 void); 1224 1225 BOOLEAN 1226 UtQueryForOverwrite ( 1227 char *Pathname); 1228 1229 void 1230 UtDumpStringOp ( 1231 ACPI_PARSE_OBJECT *Op, 1232 UINT32 Level); 1233 1234 void 1235 UtDumpIntegerOp ( 1236 ACPI_PARSE_OBJECT *Op, 1237 UINT32 Level, 1238 UINT32 IntegerLength); 1239 1240 void 1241 UtDumpBasicOp ( 1242 ACPI_PARSE_OBJECT *Op, 1243 UINT32 Level); 1244 1245 ACPI_NAMESPACE_NODE * 1246 UtGetParentMethodNode ( 1247 ACPI_NAMESPACE_NODE *Node); 1248 1249 ACPI_PARSE_OBJECT * 1250 UtGetParentMethodOp ( 1251 ACPI_PARSE_OBJECT *Op); 1252 1253 BOOLEAN 1254 UtNodeIsDescendantOf ( 1255 ACPI_NAMESPACE_NODE *Node1, 1256 ACPI_NAMESPACE_NODE *Node2); 1257 1258 void 1259 UtDisplaySupportedTables ( 1260 void); 1261 1262 void 1263 UtDisplayConstantOpcodes ( 1264 void); 1265 1266 UINT8 1267 UtBeginEvent ( 1268 char *Name); 1269 1270 void 1271 UtEndEvent ( 1272 UINT8 Event); 1273 1274 void 1275 UtDisplaySummary ( 1276 UINT32 FileId); 1277 1278 void 1279 UtDisplayOneSummary ( 1280 UINT32 FileId, 1281 BOOLEAN DisplayErrorSummary); 1282 1283 void 1284 UtConvertByteToHex ( 1285 UINT8 RawByte, 1286 UINT8 *Buffer); 1287 1288 void 1289 UtConvertByteToAsmHex ( 1290 UINT8 RawByte, 1291 UINT8 *Buffer); 1292 1293 char * 1294 UtGetOpName ( 1295 UINT32 ParseOpcode); 1296 1297 void 1298 UtSetParseOpName ( 1299 ACPI_PARSE_OBJECT *Op); 1300 1301 ACPI_STATUS 1302 UtInternalizeName ( 1303 char *ExternalName, 1304 char **ConvertedName); 1305 1306 BOOLEAN 1307 UtNameContainsAllPrefix ( 1308 ACPI_PARSE_OBJECT *Op); 1309 1310 void 1311 UtAttachNamepathToOwner ( 1312 ACPI_PARSE_OBJECT *Op, 1313 ACPI_PARSE_OBJECT *NameNode); 1314 1315 ACPI_PARSE_OBJECT * 1316 UtCheckIntegerRange ( 1317 ACPI_PARSE_OBJECT *Op, 1318 UINT32 LowValue, 1319 UINT32 HighValue); 1320 1321 UINT64 1322 UtDoConstant ( 1323 char *String); 1324 1325 char * 1326 AcpiUtStrdup ( 1327 char *String); 1328 1329 char * 1330 AcpiUtStrcat ( 1331 char *String1, 1332 char *String2); 1333 1334 1335 /* 1336 * asluuid - UUID support 1337 */ 1338 ACPI_STATUS 1339 AuValidateUuid ( 1340 char *InString); 1341 1342 ACPI_STATUS 1343 AuConvertUuidToString ( 1344 char *UuIdBuffer, 1345 char *OutString); 1346 1347 1348 /* 1349 * aslresource - Resource template generation utilities 1350 */ 1351 void 1352 RsSmallAddressCheck ( 1353 UINT8 Type, 1354 UINT32 Minimum, 1355 UINT32 Maximum, 1356 UINT32 Length, 1357 UINT32 Alignment, 1358 ACPI_PARSE_OBJECT *MinOp, 1359 ACPI_PARSE_OBJECT *MaxOp, 1360 ACPI_PARSE_OBJECT *LengthOp, 1361 ACPI_PARSE_OBJECT *AlignOp, 1362 ACPI_PARSE_OBJECT *Op); 1363 1364 void 1365 RsLargeAddressCheck ( 1366 UINT64 Minimum, 1367 UINT64 Maximum, 1368 UINT64 Length, 1369 UINT64 Granularity, 1370 UINT8 Flags, 1371 ACPI_PARSE_OBJECT *MinOp, 1372 ACPI_PARSE_OBJECT *MaxOp, 1373 ACPI_PARSE_OBJECT *LengthOp, 1374 ACPI_PARSE_OBJECT *GranOp, 1375 ACPI_PARSE_OBJECT *Op); 1376 1377 UINT16 1378 RsGetStringDataLength ( 1379 ACPI_PARSE_OBJECT *InitializerOp); 1380 1381 ASL_RESOURCE_NODE * 1382 RsAllocateResourceNode ( 1383 UINT32 Size); 1384 1385 void 1386 RsCreateResourceField ( 1387 ACPI_PARSE_OBJECT *Op, 1388 char *Name, 1389 UINT32 ByteOffset, 1390 UINT32 BitOffset, 1391 UINT32 BitLength); 1392 1393 void 1394 RsSetFlagBits ( 1395 UINT8 *Flags, 1396 ACPI_PARSE_OBJECT *Op, 1397 UINT8 Position, 1398 UINT8 DefaultBit); 1399 1400 void 1401 RsSetFlagBits16 ( 1402 UINT16 *Flags, 1403 ACPI_PARSE_OBJECT *Op, 1404 UINT8 Position, 1405 UINT8 DefaultBit); 1406 1407 ACPI_PARSE_OBJECT * 1408 RsCompleteNodeAndGetNext ( 1409 ACPI_PARSE_OBJECT *Op); 1410 1411 void 1412 RsCheckListForDuplicates ( 1413 ACPI_PARSE_OBJECT *Op); 1414 1415 ASL_RESOURCE_NODE * 1416 RsDoOneResourceDescriptor ( 1417 ASL_RESOURCE_INFO *Info, 1418 UINT8 *State); 1419 1420 /* Values for State above */ 1421 1422 #define ACPI_RSTATE_NORMAL 0 1423 #define ACPI_RSTATE_START_DEPENDENT 1 1424 #define ACPI_RSTATE_DEPENDENT_LIST 2 1425 1426 UINT32 1427 RsLinkDescriptorChain ( 1428 ASL_RESOURCE_NODE **PreviousRnode, 1429 ASL_RESOURCE_NODE *Rnode); 1430 1431 void 1432 RsDoResourceTemplate ( 1433 ACPI_PARSE_OBJECT *Op); 1434 1435 1436 /* 1437 * aslrestype1 - Miscellaneous Small descriptors 1438 */ 1439 ASL_RESOURCE_NODE * 1440 RsDoEndTagDescriptor ( 1441 ASL_RESOURCE_INFO *Info); 1442 1443 ASL_RESOURCE_NODE * 1444 RsDoEndDependentDescriptor ( 1445 ASL_RESOURCE_INFO *Info); 1446 1447 ASL_RESOURCE_NODE * 1448 RsDoMemory24Descriptor ( 1449 ASL_RESOURCE_INFO *Info); 1450 1451 ASL_RESOURCE_NODE * 1452 RsDoMemory32Descriptor ( 1453 ASL_RESOURCE_INFO *Info); 1454 1455 ASL_RESOURCE_NODE * 1456 RsDoMemory32FixedDescriptor ( 1457 ASL_RESOURCE_INFO *Info); 1458 1459 ASL_RESOURCE_NODE * 1460 RsDoStartDependentDescriptor ( 1461 ASL_RESOURCE_INFO *Info); 1462 1463 ASL_RESOURCE_NODE * 1464 RsDoStartDependentNoPriDescriptor ( 1465 ASL_RESOURCE_INFO *Info); 1466 1467 ASL_RESOURCE_NODE * 1468 RsDoVendorSmallDescriptor ( 1469 ASL_RESOURCE_INFO *Info); 1470 1471 1472 /* 1473 * aslrestype1i - I/O-related Small descriptors 1474 */ 1475 ASL_RESOURCE_NODE * 1476 RsDoDmaDescriptor ( 1477 ASL_RESOURCE_INFO *Info); 1478 1479 ASL_RESOURCE_NODE * 1480 RsDoFixedDmaDescriptor ( 1481 ASL_RESOURCE_INFO *Info); 1482 1483 ASL_RESOURCE_NODE * 1484 RsDoFixedIoDescriptor ( 1485 ASL_RESOURCE_INFO *Info); 1486 1487 ASL_RESOURCE_NODE * 1488 RsDoIoDescriptor ( 1489 ASL_RESOURCE_INFO *Info); 1490 1491 ASL_RESOURCE_NODE * 1492 RsDoIrqDescriptor ( 1493 ASL_RESOURCE_INFO *Info); 1494 1495 ASL_RESOURCE_NODE * 1496 RsDoIrqNoFlagsDescriptor ( 1497 ASL_RESOURCE_INFO *Info); 1498 1499 1500 /* 1501 * aslrestype2 - Large resource descriptors 1502 */ 1503 ASL_RESOURCE_NODE * 1504 RsDoInterruptDescriptor ( 1505 ASL_RESOURCE_INFO *Info); 1506 1507 ASL_RESOURCE_NODE * 1508 RsDoVendorLargeDescriptor ( 1509 ASL_RESOURCE_INFO *Info); 1510 1511 ASL_RESOURCE_NODE * 1512 RsDoGeneralRegisterDescriptor ( 1513 ASL_RESOURCE_INFO *Info); 1514 1515 ASL_RESOURCE_NODE * 1516 RsDoGpioIntDescriptor ( 1517 ASL_RESOURCE_INFO *Info); 1518 1519 ASL_RESOURCE_NODE * 1520 RsDoGpioIoDescriptor ( 1521 ASL_RESOURCE_INFO *Info); 1522 1523 ASL_RESOURCE_NODE * 1524 RsDoI2cSerialBusDescriptor ( 1525 ASL_RESOURCE_INFO *Info); 1526 1527 ASL_RESOURCE_NODE * 1528 RsDoSpiSerialBusDescriptor ( 1529 ASL_RESOURCE_INFO *Info); 1530 1531 ASL_RESOURCE_NODE * 1532 RsDoUartSerialBusDescriptor ( 1533 ASL_RESOURCE_INFO *Info); 1534 1535 ASL_RESOURCE_NODE * 1536 RsDoPinFunctionDescriptor ( 1537 ASL_RESOURCE_INFO *Info); 1538 1539 ASL_RESOURCE_NODE * 1540 RsDoPinConfigDescriptor ( 1541 ASL_RESOURCE_INFO *Info); 1542 1543 ASL_RESOURCE_NODE * 1544 RsDoPinGroupDescriptor ( 1545 ASL_RESOURCE_INFO *Info); 1546 1547 ASL_RESOURCE_NODE * 1548 RsDoPinGroupFunctionDescriptor ( 1549 ASL_RESOURCE_INFO *Info); 1550 1551 ASL_RESOURCE_NODE * 1552 RsDoPinGroupConfigDescriptor ( 1553 ASL_RESOURCE_INFO *Info); 1554 1555 1556 /* 1557 * aslrestype2d - DWord address descriptors 1558 */ 1559 ASL_RESOURCE_NODE * 1560 RsDoDwordIoDescriptor ( 1561 ASL_RESOURCE_INFO *Info); 1562 1563 ASL_RESOURCE_NODE * 1564 RsDoDwordMemoryDescriptor ( 1565 ASL_RESOURCE_INFO *Info); 1566 1567 ASL_RESOURCE_NODE * 1568 RsDoDwordSpaceDescriptor ( 1569 ASL_RESOURCE_INFO *Info); 1570 1571 1572 /* 1573 * aslrestype2e - Extended address descriptors 1574 */ 1575 ASL_RESOURCE_NODE * 1576 RsDoExtendedIoDescriptor ( 1577 ASL_RESOURCE_INFO *Info); 1578 1579 ASL_RESOURCE_NODE * 1580 RsDoExtendedMemoryDescriptor ( 1581 ASL_RESOURCE_INFO *Info); 1582 1583 ASL_RESOURCE_NODE * 1584 RsDoExtendedSpaceDescriptor ( 1585 ASL_RESOURCE_INFO *Info); 1586 1587 1588 /* 1589 * aslrestype2q - QWord address descriptors 1590 */ 1591 ASL_RESOURCE_NODE * 1592 RsDoQwordIoDescriptor ( 1593 ASL_RESOURCE_INFO *Info); 1594 1595 ASL_RESOURCE_NODE * 1596 RsDoQwordMemoryDescriptor ( 1597 ASL_RESOURCE_INFO *Info); 1598 1599 ASL_RESOURCE_NODE * 1600 RsDoQwordSpaceDescriptor ( 1601 ASL_RESOURCE_INFO *Info); 1602 1603 1604 /* 1605 * aslrestype2w - Word address descriptors 1606 */ 1607 ASL_RESOURCE_NODE * 1608 RsDoWordIoDescriptor ( 1609 ASL_RESOURCE_INFO *Info); 1610 1611 ASL_RESOURCE_NODE * 1612 RsDoWordSpaceDescriptor ( 1613 ASL_RESOURCE_INFO *Info); 1614 1615 ASL_RESOURCE_NODE * 1616 RsDoWordBusNumberDescriptor ( 1617 ASL_RESOURCE_INFO *Info); 1618 1619 1620 /* 1621 * Entry to data table compiler subsystem 1622 */ 1623 ACPI_STATUS 1624 DtDoCompile( 1625 void); 1626 1627 ACPI_STATUS 1628 DtCreateTemplates ( 1629 char **argv); 1630 1631 1632 /* 1633 * ASL/ASL+ converter debug 1634 */ 1635 ACPI_PRINTF_LIKE (1) 1636 void 1637 CvDbgPrint ( 1638 char *Fmt, 1639 ...); 1640 1641 1642 #endif /* __ASLCOMPILER_H */ 1643