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 - 2019, 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 void 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 void 1056 FlPrintFile ( 1057 UINT32 FileId, 1058 char *Format, 1059 ...); 1060 1061 void 1062 FlDeleteFile ( 1063 UINT32 FileId); 1064 1065 void 1066 FlSetLineNumber ( 1067 UINT32 LineNumber); 1068 1069 void 1070 FlSetFilename ( 1071 char *Filename); 1072 1073 ACPI_STATUS 1074 FlOpenInputFile ( 1075 char *InputFilename); 1076 1077 ACPI_STATUS 1078 FlOpenAmlOutputFile ( 1079 char *InputFilename); 1080 1081 ACPI_STATUS 1082 FlOpenMiscOutputFiles ( 1083 char *InputFilename); 1084 1085 ACPI_STATUS 1086 FlInitOneFile ( 1087 char *InputFilename); 1088 1089 ASL_FILE_SWITCH_STATUS 1090 FlSwitchFileSet ( 1091 char *InputFilename); 1092 1093 FILE * 1094 FlGetFileHandle ( 1095 UINT32 OutFileId, 1096 UINT32 InFileId, 1097 char *Filename); 1098 1099 ASL_GLOBAL_FILE_NODE * 1100 FlGetFileNode ( 1101 UINT32 FileId, 1102 char *Filename); 1103 1104 ASL_GLOBAL_FILE_NODE * 1105 FlGetCurrentFileNode ( 1106 void); 1107 1108 1109 /* 1110 * aslhwmap - hardware map summary 1111 */ 1112 void 1113 MpEmitMappingInfo ( 1114 void); 1115 1116 1117 /* 1118 * asload - load namespace in prep for cross reference 1119 */ 1120 ACPI_STATUS 1121 LdLoadNamespace ( 1122 ACPI_PARSE_OBJECT *RootOp); 1123 1124 /* 1125 * asllookup - namespace lookup functions 1126 */ 1127 void 1128 LkFindUnreferencedObjects ( 1129 void); 1130 1131 1132 /* 1133 * aslhelp - help screens 1134 */ 1135 void 1136 Usage ( 1137 void); 1138 1139 void 1140 AslFilenameHelp ( 1141 void); 1142 1143 void 1144 AslDisassemblyHelp ( 1145 void); 1146 1147 1148 /* 1149 * aslnamesp - namespace output file generation 1150 */ 1151 ACPI_STATUS 1152 NsDisplayNamespace ( 1153 void); 1154 1155 void 1156 NsSetupNamespaceListing ( 1157 void *Handle); 1158 1159 1160 /* 1161 * asloptions - command line processing 1162 */ 1163 int 1164 AslCommandLine ( 1165 int argc, 1166 char **argv); 1167 1168 1169 /* 1170 * aslxref - namespace cross reference 1171 */ 1172 ACPI_STATUS 1173 XfCrossReferenceNamespace ( 1174 void); 1175 1176 1177 /* 1178 * aslxrefout 1179 */ 1180 void 1181 OtPrintHeaders ( 1182 char *Message); 1183 1184 void 1185 OtCreateXrefFile ( 1186 void); 1187 1188 void 1189 OtXrefWalkPart1 ( 1190 ACPI_PARSE_OBJECT *Op, 1191 UINT32 Level, 1192 ASL_METHOD_INFO *MethodInfo); 1193 1194 1195 /* 1196 * aslutils - common compiler utilities 1197 */ 1198 void 1199 DbgPrint ( 1200 UINT32 Type, 1201 char *Format, 1202 ...); 1203 1204 /* Type values for above */ 1205 1206 #define ASL_DEBUG_OUTPUT 0 1207 #define ASL_PARSE_OUTPUT 1 1208 #define ASL_TREE_OUTPUT 2 1209 1210 UINT8 1211 UtIsBigEndianMachine ( 1212 void); 1213 1214 BOOLEAN 1215 UtQueryForOverwrite ( 1216 char *Pathname); 1217 1218 void 1219 UtDumpStringOp ( 1220 ACPI_PARSE_OBJECT *Op, 1221 UINT32 Level); 1222 1223 void 1224 UtDumpIntegerOp ( 1225 ACPI_PARSE_OBJECT *Op, 1226 UINT32 Level, 1227 UINT32 IntegerLength); 1228 1229 void 1230 UtDumpBasicOp ( 1231 ACPI_PARSE_OBJECT *Op, 1232 UINT32 Level); 1233 1234 void * 1235 UtGetParentMethod ( 1236 ACPI_NAMESPACE_NODE *Node); 1237 1238 BOOLEAN 1239 UtNodeIsDescendantOf ( 1240 ACPI_NAMESPACE_NODE *Node1, 1241 ACPI_NAMESPACE_NODE *Node2); 1242 1243 void 1244 UtDisplaySupportedTables ( 1245 void); 1246 1247 void 1248 UtDisplayConstantOpcodes ( 1249 void); 1250 1251 UINT8 1252 UtBeginEvent ( 1253 char *Name); 1254 1255 void 1256 UtEndEvent ( 1257 UINT8 Event); 1258 1259 void 1260 UtDisplaySummary ( 1261 UINT32 FileId); 1262 1263 void 1264 UtDisplayOneSummary ( 1265 UINT32 FileId, 1266 BOOLEAN DisplayErrorSummary); 1267 1268 void 1269 UtConvertByteToHex ( 1270 UINT8 RawByte, 1271 UINT8 *Buffer); 1272 1273 void 1274 UtConvertByteToAsmHex ( 1275 UINT8 RawByte, 1276 UINT8 *Buffer); 1277 1278 char * 1279 UtGetOpName ( 1280 UINT32 ParseOpcode); 1281 1282 void 1283 UtSetParseOpName ( 1284 ACPI_PARSE_OBJECT *Op); 1285 1286 ACPI_STATUS 1287 UtInternalizeName ( 1288 char *ExternalName, 1289 char **ConvertedName); 1290 1291 void 1292 UtAttachNamepathToOwner ( 1293 ACPI_PARSE_OBJECT *Op, 1294 ACPI_PARSE_OBJECT *NameNode); 1295 1296 ACPI_PARSE_OBJECT * 1297 UtCheckIntegerRange ( 1298 ACPI_PARSE_OBJECT *Op, 1299 UINT32 LowValue, 1300 UINT32 HighValue); 1301 1302 UINT64 1303 UtDoConstant ( 1304 char *String); 1305 1306 1307 /* 1308 * asluuid - UUID support 1309 */ 1310 ACPI_STATUS 1311 AuValidateUuid ( 1312 char *InString); 1313 1314 ACPI_STATUS 1315 AuConvertUuidToString ( 1316 char *UuIdBuffer, 1317 char *OutString); 1318 1319 1320 /* 1321 * aslresource - Resource template generation utilities 1322 */ 1323 void 1324 RsSmallAddressCheck ( 1325 UINT8 Type, 1326 UINT32 Minimum, 1327 UINT32 Maximum, 1328 UINT32 Length, 1329 UINT32 Alignment, 1330 ACPI_PARSE_OBJECT *MinOp, 1331 ACPI_PARSE_OBJECT *MaxOp, 1332 ACPI_PARSE_OBJECT *LengthOp, 1333 ACPI_PARSE_OBJECT *AlignOp, 1334 ACPI_PARSE_OBJECT *Op); 1335 1336 void 1337 RsLargeAddressCheck ( 1338 UINT64 Minimum, 1339 UINT64 Maximum, 1340 UINT64 Length, 1341 UINT64 Granularity, 1342 UINT8 Flags, 1343 ACPI_PARSE_OBJECT *MinOp, 1344 ACPI_PARSE_OBJECT *MaxOp, 1345 ACPI_PARSE_OBJECT *LengthOp, 1346 ACPI_PARSE_OBJECT *GranOp, 1347 ACPI_PARSE_OBJECT *Op); 1348 1349 UINT16 1350 RsGetStringDataLength ( 1351 ACPI_PARSE_OBJECT *InitializerOp); 1352 1353 ASL_RESOURCE_NODE * 1354 RsAllocateResourceNode ( 1355 UINT32 Size); 1356 1357 void 1358 RsCreateResourceField ( 1359 ACPI_PARSE_OBJECT *Op, 1360 char *Name, 1361 UINT32 ByteOffset, 1362 UINT32 BitOffset, 1363 UINT32 BitLength); 1364 1365 void 1366 RsSetFlagBits ( 1367 UINT8 *Flags, 1368 ACPI_PARSE_OBJECT *Op, 1369 UINT8 Position, 1370 UINT8 DefaultBit); 1371 1372 void 1373 RsSetFlagBits16 ( 1374 UINT16 *Flags, 1375 ACPI_PARSE_OBJECT *Op, 1376 UINT8 Position, 1377 UINT8 DefaultBit); 1378 1379 ACPI_PARSE_OBJECT * 1380 RsCompleteNodeAndGetNext ( 1381 ACPI_PARSE_OBJECT *Op); 1382 1383 void 1384 RsCheckListForDuplicates ( 1385 ACPI_PARSE_OBJECT *Op); 1386 1387 ASL_RESOURCE_NODE * 1388 RsDoOneResourceDescriptor ( 1389 ASL_RESOURCE_INFO *Info, 1390 UINT8 *State); 1391 1392 /* Values for State above */ 1393 1394 #define ACPI_RSTATE_NORMAL 0 1395 #define ACPI_RSTATE_START_DEPENDENT 1 1396 #define ACPI_RSTATE_DEPENDENT_LIST 2 1397 1398 UINT32 1399 RsLinkDescriptorChain ( 1400 ASL_RESOURCE_NODE **PreviousRnode, 1401 ASL_RESOURCE_NODE *Rnode); 1402 1403 void 1404 RsDoResourceTemplate ( 1405 ACPI_PARSE_OBJECT *Op); 1406 1407 1408 /* 1409 * aslrestype1 - Miscellaneous Small descriptors 1410 */ 1411 ASL_RESOURCE_NODE * 1412 RsDoEndTagDescriptor ( 1413 ASL_RESOURCE_INFO *Info); 1414 1415 ASL_RESOURCE_NODE * 1416 RsDoEndDependentDescriptor ( 1417 ASL_RESOURCE_INFO *Info); 1418 1419 ASL_RESOURCE_NODE * 1420 RsDoMemory24Descriptor ( 1421 ASL_RESOURCE_INFO *Info); 1422 1423 ASL_RESOURCE_NODE * 1424 RsDoMemory32Descriptor ( 1425 ASL_RESOURCE_INFO *Info); 1426 1427 ASL_RESOURCE_NODE * 1428 RsDoMemory32FixedDescriptor ( 1429 ASL_RESOURCE_INFO *Info); 1430 1431 ASL_RESOURCE_NODE * 1432 RsDoStartDependentDescriptor ( 1433 ASL_RESOURCE_INFO *Info); 1434 1435 ASL_RESOURCE_NODE * 1436 RsDoStartDependentNoPriDescriptor ( 1437 ASL_RESOURCE_INFO *Info); 1438 1439 ASL_RESOURCE_NODE * 1440 RsDoVendorSmallDescriptor ( 1441 ASL_RESOURCE_INFO *Info); 1442 1443 1444 /* 1445 * aslrestype1i - I/O-related Small descriptors 1446 */ 1447 ASL_RESOURCE_NODE * 1448 RsDoDmaDescriptor ( 1449 ASL_RESOURCE_INFO *Info); 1450 1451 ASL_RESOURCE_NODE * 1452 RsDoFixedDmaDescriptor ( 1453 ASL_RESOURCE_INFO *Info); 1454 1455 ASL_RESOURCE_NODE * 1456 RsDoFixedIoDescriptor ( 1457 ASL_RESOURCE_INFO *Info); 1458 1459 ASL_RESOURCE_NODE * 1460 RsDoIoDescriptor ( 1461 ASL_RESOURCE_INFO *Info); 1462 1463 ASL_RESOURCE_NODE * 1464 RsDoIrqDescriptor ( 1465 ASL_RESOURCE_INFO *Info); 1466 1467 ASL_RESOURCE_NODE * 1468 RsDoIrqNoFlagsDescriptor ( 1469 ASL_RESOURCE_INFO *Info); 1470 1471 1472 /* 1473 * aslrestype2 - Large resource descriptors 1474 */ 1475 ASL_RESOURCE_NODE * 1476 RsDoInterruptDescriptor ( 1477 ASL_RESOURCE_INFO *Info); 1478 1479 ASL_RESOURCE_NODE * 1480 RsDoVendorLargeDescriptor ( 1481 ASL_RESOURCE_INFO *Info); 1482 1483 ASL_RESOURCE_NODE * 1484 RsDoGeneralRegisterDescriptor ( 1485 ASL_RESOURCE_INFO *Info); 1486 1487 ASL_RESOURCE_NODE * 1488 RsDoGpioIntDescriptor ( 1489 ASL_RESOURCE_INFO *Info); 1490 1491 ASL_RESOURCE_NODE * 1492 RsDoGpioIoDescriptor ( 1493 ASL_RESOURCE_INFO *Info); 1494 1495 ASL_RESOURCE_NODE * 1496 RsDoI2cSerialBusDescriptor ( 1497 ASL_RESOURCE_INFO *Info); 1498 1499 ASL_RESOURCE_NODE * 1500 RsDoSpiSerialBusDescriptor ( 1501 ASL_RESOURCE_INFO *Info); 1502 1503 ASL_RESOURCE_NODE * 1504 RsDoUartSerialBusDescriptor ( 1505 ASL_RESOURCE_INFO *Info); 1506 1507 ASL_RESOURCE_NODE * 1508 RsDoPinFunctionDescriptor ( 1509 ASL_RESOURCE_INFO *Info); 1510 1511 ASL_RESOURCE_NODE * 1512 RsDoPinConfigDescriptor ( 1513 ASL_RESOURCE_INFO *Info); 1514 1515 ASL_RESOURCE_NODE * 1516 RsDoPinGroupDescriptor ( 1517 ASL_RESOURCE_INFO *Info); 1518 1519 ASL_RESOURCE_NODE * 1520 RsDoPinGroupFunctionDescriptor ( 1521 ASL_RESOURCE_INFO *Info); 1522 1523 ASL_RESOURCE_NODE * 1524 RsDoPinGroupConfigDescriptor ( 1525 ASL_RESOURCE_INFO *Info); 1526 1527 1528 /* 1529 * aslrestype2d - DWord address descriptors 1530 */ 1531 ASL_RESOURCE_NODE * 1532 RsDoDwordIoDescriptor ( 1533 ASL_RESOURCE_INFO *Info); 1534 1535 ASL_RESOURCE_NODE * 1536 RsDoDwordMemoryDescriptor ( 1537 ASL_RESOURCE_INFO *Info); 1538 1539 ASL_RESOURCE_NODE * 1540 RsDoDwordSpaceDescriptor ( 1541 ASL_RESOURCE_INFO *Info); 1542 1543 1544 /* 1545 * aslrestype2e - Extended address descriptors 1546 */ 1547 ASL_RESOURCE_NODE * 1548 RsDoExtendedIoDescriptor ( 1549 ASL_RESOURCE_INFO *Info); 1550 1551 ASL_RESOURCE_NODE * 1552 RsDoExtendedMemoryDescriptor ( 1553 ASL_RESOURCE_INFO *Info); 1554 1555 ASL_RESOURCE_NODE * 1556 RsDoExtendedSpaceDescriptor ( 1557 ASL_RESOURCE_INFO *Info); 1558 1559 1560 /* 1561 * aslrestype2q - QWord address descriptors 1562 */ 1563 ASL_RESOURCE_NODE * 1564 RsDoQwordIoDescriptor ( 1565 ASL_RESOURCE_INFO *Info); 1566 1567 ASL_RESOURCE_NODE * 1568 RsDoQwordMemoryDescriptor ( 1569 ASL_RESOURCE_INFO *Info); 1570 1571 ASL_RESOURCE_NODE * 1572 RsDoQwordSpaceDescriptor ( 1573 ASL_RESOURCE_INFO *Info); 1574 1575 1576 /* 1577 * aslrestype2w - Word address descriptors 1578 */ 1579 ASL_RESOURCE_NODE * 1580 RsDoWordIoDescriptor ( 1581 ASL_RESOURCE_INFO *Info); 1582 1583 ASL_RESOURCE_NODE * 1584 RsDoWordSpaceDescriptor ( 1585 ASL_RESOURCE_INFO *Info); 1586 1587 ASL_RESOURCE_NODE * 1588 RsDoWordBusNumberDescriptor ( 1589 ASL_RESOURCE_INFO *Info); 1590 1591 1592 /* 1593 * Entry to data table compiler subsystem 1594 */ 1595 ACPI_STATUS 1596 DtDoCompile( 1597 void); 1598 1599 ACPI_STATUS 1600 DtCreateTemplates ( 1601 char **argv); 1602 1603 1604 /* 1605 * ASL/ASL+ converter debug 1606 */ 1607 void 1608 CvDbgPrint ( 1609 char *Fmt, 1610 ...); 1611 1612 1613 #endif /* __ASLCOMPILER_H */ 1614