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