1 /****************************************************************************** 2 * 3 * Module Name: aemain - Main routine for the AcpiExec utility 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2018, 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 #include "aecommon.h" 153 154 #define _COMPONENT ACPI_TOOLS 155 ACPI_MODULE_NAME ("aemain") 156 157 158 /* 159 * Main routine for the ACPI user-space execution utility. 160 * 161 * Portability note: The utility depends upon the host for command-line 162 * wildcard support - it is not implemented locally. For example: 163 * 164 * Linux/Unix systems: Shell expands wildcards automatically. 165 * 166 * Windows: The setargv.obj module must be linked in to automatically 167 * expand wildcards. 168 */ 169 170 /* Local prototypes */ 171 172 static int 173 AeDoOptions ( 174 int argc, 175 char **argv); 176 177 178 #define AE_BUFFER_SIZE 1024 179 #define ASL_MAX_FILES 256 180 181 /* Execution modes */ 182 183 #define AE_MODE_COMMAND_LOOP 0 /* Normal command execution loop */ 184 #define AE_MODE_BATCH_MULTIPLE 1 /* -b option to execute a command line */ 185 #define AE_MODE_BATCH_SINGLE 2 /* -m option to execute a single control method */ 186 187 188 /* Globals */ 189 190 BOOLEAN AcpiGbl_UseLocalFaultHandler = TRUE; 191 BOOLEAN AcpiGbl_VerboseHandlers = FALSE; 192 UINT8 AcpiGbl_RegionFillValue = 0; 193 BOOLEAN AcpiGbl_IgnoreErrors = FALSE; 194 BOOLEAN AcpiGbl_AbortLoopOnTimeout = FALSE; 195 BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; 196 UINT8 AcpiGbl_UseHwReducedFadt = FALSE; 197 BOOLEAN AcpiGbl_DoInterfaceTests = FALSE; 198 BOOLEAN AcpiGbl_LoadTestTables = FALSE; 199 BOOLEAN AcpiGbl_AeLoadOnly = FALSE; 200 static UINT8 AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP; 201 static char BatchBuffer[AE_BUFFER_SIZE]; /* Batch command buffer */ 202 INIT_FILE_ENTRY *AcpiGbl_InitEntries = NULL; 203 UINT32 AcpiGbl_InitFileLineCount = 0; 204 205 #define ACPIEXEC_NAME "AML Execution/Debug Utility" 206 #define AE_SUPPORTED_OPTIONS "?b:d:e:f^ghlm^rt^v^:x:" 207 208 209 /* Stubs for the disassembler */ 210 211 void 212 MpSaveGpioInfo ( 213 ACPI_PARSE_OBJECT *Op, 214 AML_RESOURCE *Resource, 215 UINT32 PinCount, 216 UINT16 *PinList, 217 char *DeviceName) 218 { 219 } 220 221 void 222 MpSaveSerialInfo ( 223 ACPI_PARSE_OBJECT *Op, 224 AML_RESOURCE *Resource, 225 char *DeviceName) 226 { 227 } 228 229 230 /****************************************************************************** 231 * 232 * FUNCTION: usage 233 * 234 * PARAMETERS: None 235 * 236 * RETURN: None 237 * 238 * DESCRIPTION: Print a usage message 239 * 240 *****************************************************************************/ 241 242 static void 243 usage ( 244 void) 245 { 246 247 ACPI_USAGE_HEADER ("acpiexec [options] AMLfile1 AMLfile2 ..."); 248 249 ACPI_OPTION ("-b \"CommandLine\"", "Batch mode command line execution (cmd1;cmd2;...)"); 250 ACPI_OPTION ("-h -?", "Display this help message"); 251 ACPI_OPTION ("-m [Method]", "Batch mode method execution. Default=MAIN"); 252 printf ("\n"); 253 254 ACPI_OPTION ("-da", "Disable method abort on error"); 255 ACPI_OPTION ("-df", "Disable Local fault handler"); 256 ACPI_OPTION ("-di", "Disable execution of STA/INI methods during init"); 257 ACPI_OPTION ("-do", "Disable Operation Region address simulation"); 258 ACPI_OPTION ("-dp", "Disable TermList parsing for scope objects"); 259 ACPI_OPTION ("-dr", "Disable repair of method return values"); 260 ACPI_OPTION ("-ds", "Disable method auto-serialization"); 261 ACPI_OPTION ("-dt", "Disable allocation tracking (performance)"); 262 printf ("\n"); 263 264 ACPI_OPTION ("-ed", "Enable timer output for Debug Object"); 265 ACPI_OPTION ("-ef", "Enable display of final memory statistics"); 266 ACPI_OPTION ("-ei", "Enable additional tests for ACPICA interfaces"); 267 ACPI_OPTION ("-el", "Enable loading of additional test tables"); 268 ACPI_OPTION ("-em", "Enable (legacy) grouping of module-level code"); 269 ACPI_OPTION ("-es", "Enable Interpreter Slack Mode"); 270 ACPI_OPTION ("-et", "Enable debug semaphore timeout"); 271 printf ("\n"); 272 273 ACPI_OPTION ("-fi <File>", "Specify namespace initialization file"); 274 ACPI_OPTION ("-fv <Value>", "Operation Region initialization fill value"); 275 printf ("\n"); 276 277 ACPI_OPTION ("-l", "Load tables and namespace only"); 278 ACPI_OPTION ("-r", "Use hardware-reduced FADT V5"); 279 ACPI_OPTION ("-te", "Exit loop on timeout instead of aborting method"); 280 ACPI_OPTION ("-to <Seconds>", "Set timeout period for AML while loops"); 281 printf ("\n"); 282 283 ACPI_OPTION ("-v", "Display version information"); 284 ACPI_OPTION ("-vd", "Display build date and time"); 285 ACPI_OPTION ("-vh", "Verbose exception handler output"); 286 ACPI_OPTION ("-vi", "Verbose initialization output"); 287 ACPI_OPTION ("-vr", "Verbose region handler output"); 288 ACPI_OPTION ("-x <DebugLevel>", "Debug output level"); 289 290 printf ("\n From within the interactive mode, use '?' or \"help\" to see\n" 291 " a list of available AML Debugger commands\n"); 292 } 293 294 295 /****************************************************************************** 296 * 297 * FUNCTION: AeDoOptions 298 * 299 * PARAMETERS: argc/argv - Standard argc/argv 300 * 301 * RETURN: Status 302 * 303 * DESCRIPTION: Command line option processing 304 * 305 *****************************************************************************/ 306 307 static int 308 AeDoOptions ( 309 int argc, 310 char **argv) 311 { 312 int j; 313 UINT32 Temp; 314 315 316 while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 317 { 318 case 'b': 319 320 if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1)) 321 { 322 printf ("**** The length of command line (%u) exceeded maximum (%u)\n", 323 (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1)); 324 return (-1); 325 } 326 AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE; 327 strcpy (BatchBuffer, AcpiGbl_Optarg); 328 break; 329 330 case 'd': 331 332 switch (AcpiGbl_Optarg[0]) 333 { 334 case 'a': 335 336 AcpiGbl_IgnoreErrors = TRUE; 337 break; 338 339 case 'f': 340 341 AcpiGbl_UseLocalFaultHandler = FALSE; 342 break; 343 344 case 'i': 345 346 AcpiGbl_DbOpt_NoIniMethods = TRUE; 347 break; 348 349 case 'o': 350 351 AcpiGbl_DbOpt_NoRegionSupport = TRUE; 352 break; 353 354 case 'p': 355 356 AcpiGbl_ExecuteTablesAsMethods = FALSE; 357 break; 358 359 case 'r': 360 361 AcpiGbl_DisableAutoRepair = TRUE; 362 break; 363 364 case 's': 365 366 AcpiGbl_AutoSerializeMethods = FALSE; 367 break; 368 369 case 't': 370 371 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 372 AcpiGbl_DisableMemTracking = TRUE; 373 #endif 374 break; 375 376 default: 377 378 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 379 return (-1); 380 } 381 break; 382 383 case 'e': 384 385 switch (AcpiGbl_Optarg[0]) 386 { 387 case 'd': 388 389 AcpiGbl_DisplayDebugTimer = TRUE; 390 break; 391 392 case 'f': 393 394 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 395 AcpiGbl_DisplayFinalMemStats = TRUE; 396 #endif 397 break; 398 399 case 'i': 400 401 AcpiGbl_DoInterfaceTests = TRUE; 402 break; 403 404 case 'l': 405 406 AcpiGbl_LoadTestTables = TRUE; 407 break; 408 409 case 'm': 410 411 AcpiGbl_GroupModuleLevelCode = TRUE; 412 break; 413 414 case 's': 415 416 AcpiGbl_EnableInterpreterSlack = TRUE; 417 printf ("Enabling AML Interpreter slack mode\n"); 418 break; 419 420 case 't': 421 422 AcpiGbl_DebugTimeout = TRUE; 423 break; 424 425 default: 426 427 printf ("Unknown option: -e%s\n", AcpiGbl_Optarg); 428 return (-1); 429 } 430 break; 431 432 case 'f': 433 434 switch (AcpiGbl_Optarg[0]) 435 { 436 case 'v': /* -fv: region fill value */ 437 438 if (AcpiGetoptArgument (argc, argv)) 439 { 440 return (-1); 441 } 442 443 AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 444 break; 445 446 case 'i': /* -fi: specify initialization file */ 447 448 if (AcpiGetoptArgument (argc, argv)) 449 { 450 return (-1); 451 } 452 453 if (AeOpenInitializationFile (AcpiGbl_Optarg)) 454 { 455 return (-1); 456 } 457 break; 458 459 default: 460 461 printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 462 return (-1); 463 } 464 break; 465 466 case 'g': 467 468 AcpiGbl_DbFilename = NULL; 469 break; 470 471 case 'h': 472 case '?': 473 474 usage(); 475 return (1); 476 477 case 'l': 478 479 AcpiGbl_AeLoadOnly = TRUE; 480 break; 481 482 case 'm': 483 484 AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE; 485 switch (AcpiGbl_Optarg[0]) 486 { 487 case '^': 488 489 strcpy (BatchBuffer, "MAIN"); 490 break; 491 492 default: 493 494 strcpy (BatchBuffer, AcpiGbl_Optarg); 495 break; 496 } 497 break; 498 499 case 'r': 500 501 AcpiGbl_UseHwReducedFadt = TRUE; 502 printf ("Using ACPI 5.0 Hardware Reduced Mode via version 5 FADT\n"); 503 break; 504 505 case 't': 506 507 switch (AcpiGbl_Optarg[0]) 508 { 509 case 'o': /* -to: Set loop timeout in seconds */ 510 511 if (AcpiGetoptArgument (argc, argv)) 512 { 513 return (-1); 514 } 515 516 Temp = strtoul (AcpiGbl_Optarg, NULL, 0); 517 if (!Temp || (Temp > ACPI_UINT16_MAX)) 518 { 519 printf ("%s: Invalid loop timeout value\n", 520 AcpiGbl_Optarg); 521 return (-1); 522 } 523 524 AcpiGbl_MaxLoopIterations = (UINT16) Temp; 525 printf ("Automatic loop timeout after %u seconds\n", 526 AcpiGbl_MaxLoopIterations); 527 break; 528 529 case 'e': 530 531 AcpiGbl_AbortLoopOnTimeout = TRUE; 532 break; 533 534 default: 535 536 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 537 return (-1); 538 } 539 break; 540 541 case 'v': 542 543 switch (AcpiGbl_Optarg[0]) 544 { 545 case '^': /* -v: (Version): signon already emitted, just exit */ 546 547 return (1); 548 549 case 'd': 550 551 printf (ACPI_COMMON_BUILD_TIME); 552 return (1); 553 554 case 'h': 555 556 AcpiGbl_VerboseHandlers = TRUE; 557 break; 558 559 case 'i': 560 561 AcpiDbgLevel |= ACPI_LV_INIT_NAMES; 562 break; 563 564 case 'r': 565 566 AcpiGbl_DisplayRegionAccess = TRUE; 567 break; 568 569 default: 570 571 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 572 return (-1); 573 } 574 break; 575 576 case 'x': 577 578 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 579 AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel; 580 printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); 581 break; 582 583 default: 584 585 usage(); 586 return (-1); 587 } 588 589 return (0); 590 } 591 592 593 /****************************************************************************** 594 * 595 * FUNCTION: main 596 * 597 * PARAMETERS: argc, argv 598 * 599 * RETURN: Status 600 * 601 * DESCRIPTION: Main routine for AcpiExec utility 602 * 603 *****************************************************************************/ 604 605 int ACPI_SYSTEM_XFACE 606 main ( 607 int argc, 608 char **argv) 609 { 610 ACPI_NEW_TABLE_DESC *ListHead = NULL; 611 ACPI_STATUS Status; 612 UINT32 InitFlags; 613 int ExitCode = 0; 614 615 616 ACPI_DEBUG_INITIALIZE (); /* For debug version only */ 617 618 signal (SIGINT, AeSignalHandler); 619 620 /* Init debug globals */ 621 622 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; 623 AcpiDbgLayer = 0xFFFFFFFF; 624 625 /* Module-level code. Use new architecture */ 626 627 AcpiGbl_ExecuteTablesAsMethods = TRUE; 628 AcpiGbl_GroupModuleLevelCode = FALSE; 629 630 /* 631 * Initialize ACPICA and start debugger thread. 632 * 633 * NOTE: After ACPICA initialization, AcpiTerminate MUST be called 634 * before this procedure exits -- otherwise, the console may be 635 * left in an incorrect state. 636 */ 637 Status = AcpiInitializeSubsystem (); 638 ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); 639 if (ACPI_FAILURE (Status)) 640 { 641 goto ErrorExit; 642 } 643 644 /* Use a shorter timeout value for acpiexec */ 645 646 AcpiGbl_MaxLoopIterations = 1; 647 648 /* Initialize the AML debugger */ 649 650 Status = AcpiInitializeDebugger (); 651 ACPI_CHECK_OK (AcpiInitializeDebugger, Status); 652 if (ACPI_FAILURE (Status)) 653 { 654 goto ErrorExit; 655 } 656 657 printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); 658 if (argc < 2) 659 { 660 usage (); 661 goto NormalExit; 662 } 663 664 /* Get the command line options */ 665 666 ExitCode = AeDoOptions (argc, argv); 667 if (ExitCode) 668 { 669 if (ExitCode > 0) 670 { 671 ExitCode = 0; 672 } 673 674 goto ErrorExit; 675 } 676 677 if (AcpiGbl_UseLocalFaultHandler) 678 { 679 signal (SIGSEGV, AeSignalHandler); 680 } 681 682 AeProcessInitFile(); 683 684 /* The remaining arguments are filenames for ACPI tables */ 685 686 if (!argv[AcpiGbl_Optind]) 687 { 688 goto EnterDebugger; 689 } 690 691 AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ 692 693 /* Get each of the ACPI table files on the command line */ 694 695 while (argv[AcpiGbl_Optind]) 696 { 697 /* Get all ACPI AML tables in this file */ 698 699 Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], 700 ACPI_GET_ALL_TABLES, &ListHead); 701 if (ACPI_FAILURE (Status)) 702 { 703 ExitCode = -1; 704 goto ErrorExit; 705 } 706 707 AcpiGbl_Optind++; 708 } 709 710 printf ("\n"); 711 712 /* Build a local RSDT with all tables and let ACPICA process the RSDT */ 713 714 Status = AeBuildLocalTables (ListHead); 715 if (ACPI_FAILURE (Status)) 716 { 717 goto ErrorExit; 718 } 719 720 /* Install all of the ACPI tables */ 721 722 Status = AeInstallTables (); 723 if (ACPI_FAILURE (Status)) 724 { 725 printf ("**** Could not install ACPI tables, %s\n", 726 AcpiFormatException (Status)); 727 goto EnterDebugger; 728 } 729 730 /* 731 * Install most of the handlers (Regions, Notify, Table, etc.) 732 * Override the default region handlers, especially SystemMemory, 733 * which is simulated in this utility. 734 */ 735 Status = AeInstallEarlyHandlers (); 736 if (ACPI_FAILURE (Status)) 737 { 738 goto EnterDebugger; 739 } 740 741 Status = AeLoadTables (); 742 743 /* 744 * Exit namespace initialization for the "load namespace only" option. 745 * No control methods will be executed. However, still enter the 746 * the debugger. 747 */ 748 if (AcpiGbl_AeLoadOnly) 749 { 750 goto EnterDebugger; 751 } 752 753 if (ACPI_FAILURE (Status)) 754 { 755 printf ("**** Could not load ACPI tables, %s\n", 756 AcpiFormatException (Status)); 757 goto EnterDebugger; 758 } 759 760 /* Setup initialization flags for ACPICA */ 761 762 InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); 763 if (AcpiGbl_DbOpt_NoIniMethods) 764 { 765 InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); 766 } 767 768 /* 769 * Main initialization for ACPICA subsystem 770 * TBD: Need a way to call this after the ACPI table "LOAD" command? 771 * 772 * NOTE: This initialization does not match the _Lxx and _Exx methods 773 * to individual GPEs, as there are no real GPEs when the hardware 774 * is simulated - because there is no namespace until AeLoadTables is 775 * executed. This may have to change if AcpiExec is ever run natively 776 * on actual hardware (such as under UEFI). 777 */ 778 Status = AcpiEnableSubsystem (InitFlags); 779 if (ACPI_FAILURE (Status)) 780 { 781 printf ("**** Could not EnableSubsystem, %s\n", 782 AcpiFormatException (Status)); 783 goto EnterDebugger; 784 } 785 786 /* 787 * Install handlers for "device driver" space IDs (EC,SMBus, etc.) 788 * and fixed event handlers 789 */ 790 AeInstallLateHandlers (); 791 792 /* Finish the ACPICA initialization */ 793 794 Status = AcpiInitializeObjects (InitFlags); 795 if (ACPI_FAILURE (Status)) 796 { 797 printf ("**** Could not InitializeObjects, %s\n", 798 AcpiFormatException (Status)); 799 goto EnterDebugger; 800 } 801 802 AeMiscellaneousTests (); 803 804 805 EnterDebugger: 806 807 /* Exit if error above and we are in one of the batch modes */ 808 809 if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) 810 { 811 goto ErrorExit; 812 } 813 814 /* Run a batch command or enter the command loop */ 815 816 switch (AcpiGbl_ExecutionMode) 817 { 818 default: 819 case AE_MODE_COMMAND_LOOP: 820 821 AcpiRunDebugger (NULL); 822 break; 823 824 case AE_MODE_BATCH_MULTIPLE: 825 826 AcpiRunDebugger (BatchBuffer); 827 break; 828 829 case AE_MODE_BATCH_SINGLE: 830 831 AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); 832 break; 833 } 834 835 /* Shut down the debugger and ACPICA */ 836 837 AcpiTerminateDebugger (); 838 839 /* re-enable debug output for AcpiTerminate output */ 840 841 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 842 843 NormalExit: 844 ExitCode = 0; 845 846 ErrorExit: 847 (void) AcpiTerminate (); 848 AcDeleteTableList (ListHead); 849 AcpiOsFree (AcpiGbl_InitEntries); 850 return (ExitCode); 851 } 852