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