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