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 - 2023, 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 UINT8 AcpiGbl_UseHwReducedFadt = FALSE;
196 BOOLEAN AcpiGbl_DoInterfaceTests = FALSE;
197 BOOLEAN AcpiGbl_LoadTestTables = FALSE;
198 BOOLEAN AcpiGbl_AeLoadOnly = FALSE;
199 static UINT8 AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP;
200 static char BatchBuffer[AE_BUFFER_SIZE]; /* Batch command buffer */
201 INIT_FILE_ENTRY *AcpiGbl_InitEntries = NULL;
202 UINT32 AcpiGbl_InitFileLineCount = 0;
203
204 #define ACPIEXEC_NAME "AML Execution/Debug Utility"
205 #define AE_SUPPORTED_OPTIONS "?b:d:e:f^ghlm^rt^v^:x:"
206
207
208 /* Stubs for the disassembler */
209
210 void
MpSaveGpioInfo(ACPI_PARSE_OBJECT * Op,AML_RESOURCE * Resource,UINT32 PinCount,UINT16 * PinList,char * DeviceName)211 MpSaveGpioInfo (
212 ACPI_PARSE_OBJECT *Op,
213 AML_RESOURCE *Resource,
214 UINT32 PinCount,
215 UINT16 *PinList,
216 char *DeviceName)
217 {
218 }
219
220 void
MpSaveSerialInfo(ACPI_PARSE_OBJECT * Op,AML_RESOURCE * Resource,char * DeviceName)221 MpSaveSerialInfo (
222 ACPI_PARSE_OBJECT *Op,
223 AML_RESOURCE *Resource,
224 char *DeviceName)
225 {
226 }
227
228
229 /******************************************************************************
230 *
231 * FUNCTION: usage
232 *
233 * PARAMETERS: None
234 *
235 * RETURN: None
236 *
237 * DESCRIPTION: Print a usage message
238 *
239 *****************************************************************************/
240
241 static void
usage(void)242 usage (
243 void)
244 {
245
246 ACPI_USAGE_HEADER ("acpiexec [options] AMLfile1 AMLfile2 ...");
247
248 ACPI_OPTION ("-b \"CommandLine\"", "Batch mode command line execution (cmd1;cmd2;...)");
249 ACPI_OPTION ("-h -?", "Display this help message");
250 ACPI_OPTION ("-m [Method]", "Batch mode method execution. Default=MAIN");
251 printf ("\n");
252
253 ACPI_OPTION ("-da", "Disable method abort on error");
254 ACPI_OPTION ("-df", "Disable Local fault handler");
255 ACPI_OPTION ("-di", "Disable execution of STA/INI methods during init");
256 ACPI_OPTION ("-do", "Disable Operation Region address simulation");
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 ("-eo", "Enable object evaluation log");
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 ("-va", "Display verbose dump of any memory leaks");
283 ACPI_OPTION ("-vd", "Display build date and time");
284 ACPI_OPTION ("-vh", "Verbose exception handler output");
285 ACPI_OPTION ("-vi", "Verbose initialization output");
286 ACPI_OPTION ("-vr", "Verbose region handler output");
287 ACPI_OPTION ("-x <DebugLevel>", "Debug output level");
288
289 printf ("\n From within the interactive mode, use '?' or \"help\" to see\n"
290 " a list of available AML Debugger commands\n");
291 }
292
293
294 /******************************************************************************
295 *
296 * FUNCTION: AeDoOptions
297 *
298 * PARAMETERS: argc/argv - Standard argc/argv
299 *
300 * RETURN: Status
301 *
302 * DESCRIPTION: Command line option processing
303 *
304 *****************************************************************************/
305
306 static int
AeDoOptions(int argc,char ** argv)307 AeDoOptions (
308 int argc,
309 char **argv)
310 {
311 int j;
312 UINT32 Temp;
313
314
315 while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
316 {
317 case 'b':
318
319 if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1))
320 {
321 printf ("**** The length of command line (%u) exceeded maximum (%d)\n",
322 (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1));
323 return (-1);
324 }
325 AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE;
326 strcpy (BatchBuffer, AcpiGbl_Optarg);
327 break;
328
329 case 'd':
330
331 switch (AcpiGbl_Optarg[0])
332 {
333 case 'a':
334
335 AcpiGbl_IgnoreErrors = TRUE;
336 break;
337
338 case 'f':
339
340 AcpiGbl_UseLocalFaultHandler = FALSE;
341 break;
342
343 case 'i':
344
345 AcpiGbl_DbOpt_NoIniMethods = TRUE;
346 break;
347
348 case 'o':
349
350 AcpiGbl_DbOpt_NoRegionSupport = TRUE;
351 break;
352
353 case 'r':
354
355 AcpiGbl_DisableAutoRepair = TRUE;
356 break;
357
358 case 's':
359
360 AcpiGbl_AutoSerializeMethods = FALSE;
361 break;
362
363 case 't':
364
365 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
366 AcpiGbl_DisableMemTracking = TRUE;
367 #endif
368 break;
369
370 default:
371
372 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
373 return (-1);
374 }
375 break;
376
377 case 'e':
378
379 switch (AcpiGbl_Optarg[0])
380 {
381 case 'd':
382
383 AcpiGbl_DisplayDebugTimer = TRUE;
384 break;
385
386 case 'f':
387
388 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
389 AcpiGbl_DisplayFinalMemStats = TRUE;
390 #endif
391 break;
392
393 case 'i':
394
395 AcpiGbl_DoInterfaceTests = TRUE;
396 break;
397
398 case 'l':
399
400 AcpiGbl_LoadTestTables = TRUE;
401 break;
402
403 case 'o':
404
405 AcpiDbgLevel |= ACPI_LV_EVALUATION;
406 AcpiGbl_DbConsoleDebugLevel |= ACPI_LV_EVALUATION;
407 break;
408
409 case 's':
410
411 AcpiGbl_EnableInterpreterSlack = TRUE;
412 printf ("Enabling AML Interpreter slack mode\n");
413 break;
414
415 case 't':
416
417 AcpiGbl_DebugTimeout = TRUE;
418 break;
419
420 default:
421
422 printf ("Unknown option: -e%s\n", AcpiGbl_Optarg);
423 return (-1);
424 }
425 break;
426
427 case 'f':
428
429 switch (AcpiGbl_Optarg[0])
430 {
431 case 'v': /* -fv: region fill value */
432
433 if (AcpiGetoptArgument (argc, argv))
434 {
435 return (-1);
436 }
437
438 AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
439 break;
440
441 case 'i': /* -fi: specify initialization file */
442
443 if (AcpiGetoptArgument (argc, argv))
444 {
445 return (-1);
446 }
447
448 if (AeOpenInitializationFile (AcpiGbl_Optarg))
449 {
450 return (-1);
451 }
452 break;
453
454 default:
455
456 printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
457 return (-1);
458 }
459 break;
460
461 case 'g':
462
463 AcpiGbl_DbFilename = NULL;
464 break;
465
466 case 'h':
467 case '?':
468
469 usage();
470 return (1);
471
472 case 'l':
473
474 AcpiGbl_AeLoadOnly = TRUE;
475 break;
476
477 case 'm':
478
479 AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE;
480 switch (AcpiGbl_Optarg[0])
481 {
482 case '^':
483
484 strcpy (BatchBuffer, "MAIN");
485 break;
486
487 default:
488
489 strcpy (BatchBuffer, AcpiGbl_Optarg);
490 break;
491 }
492 break;
493
494 case 'r':
495
496 AcpiGbl_UseHwReducedFadt = TRUE;
497 printf ("Using ACPI 5.0 Hardware Reduced Mode via version 5 FADT\n");
498 break;
499
500 case 't':
501
502 switch (AcpiGbl_Optarg[0])
503 {
504 case 'o': /* -to: Set loop timeout in seconds */
505
506 if (AcpiGetoptArgument (argc, argv))
507 {
508 return (-1);
509 }
510
511 Temp = strtoul (AcpiGbl_Optarg, NULL, 0);
512 if (!Temp || (Temp > ACPI_UINT16_MAX))
513 {
514 printf ("%s: Invalid loop timeout value\n",
515 AcpiGbl_Optarg);
516 return (-1);
517 }
518
519 AcpiGbl_MaxLoopIterations = (UINT16) Temp;
520 printf ("Automatic loop timeout after %u seconds\n",
521 AcpiGbl_MaxLoopIterations);
522 break;
523
524 case 'e':
525
526 AcpiGbl_AbortLoopOnTimeout = TRUE;
527 break;
528
529 default:
530
531 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
532 return (-1);
533 }
534 break;
535
536 case 'v':
537
538 switch (AcpiGbl_Optarg[0])
539 {
540 case '^': /* -v: (Version): signon already emitted, just exit */
541
542 return (1);
543
544 case 'a':
545
546 AcpiGbl_VerboseLeakDump = TRUE;
547 break;
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
main(int argc,char ** argv)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 /*
626 * Initialize ACPICA and start debugger thread.
627 *
628 * NOTE: After ACPICA initialization, AcpiTerminate MUST be called
629 * before this procedure exits -- otherwise, the console may be
630 * left in an incorrect state.
631 */
632 Status = AcpiInitializeSubsystem ();
633 ACPI_CHECK_OK (AcpiInitializeSubsystem, Status);
634 if (ACPI_FAILURE (Status))
635 {
636 ExitCode = -1;
637 goto ErrorExit;
638 }
639
640 /* Use a shorter timeout value for acpiexec */
641
642 AcpiGbl_MaxLoopIterations = 10;
643
644 /* Initialize the AML debugger */
645
646 Status = AcpiInitializeDebugger ();
647 ACPI_CHECK_OK (AcpiInitializeDebugger, Status);
648 if (ACPI_FAILURE (Status))
649 {
650 ExitCode = -1;
651 goto ErrorExit;
652 }
653
654 printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME));
655 if (argc < 2)
656 {
657 usage ();
658 goto NormalExit;
659 }
660
661 /* Get the command line options */
662
663 ExitCode = AeDoOptions (argc, argv);
664 if (ExitCode)
665 {
666 if (ExitCode > 0)
667 {
668 ExitCode = 0;
669 }
670
671 goto ErrorExit;
672 }
673
674 if (AcpiGbl_UseLocalFaultHandler)
675 {
676 signal (SIGSEGV, AeSignalHandler);
677 }
678
679 /* The remaining arguments are filenames for ACPI tables */
680
681 if (!argv[AcpiGbl_Optind])
682 {
683 goto EnterDebugger;
684 }
685
686 AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */
687
688 /* Get each of the ACPI table files on the command line */
689
690 while (argv[AcpiGbl_Optind])
691 {
692 /* Get all ACPI AML tables in this file */
693
694 Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind],
695 ACPI_GET_ALL_TABLES, &ListHead);
696 if (ACPI_FAILURE (Status))
697 {
698 ExitCode = -1;
699 goto ErrorExit;
700 }
701
702 AcpiGbl_Optind++;
703 }
704
705 printf ("\n");
706
707 /* Build a local RSDT with all tables and let ACPICA process the RSDT */
708
709 Status = AeBuildLocalTables (ListHead);
710 if (ACPI_FAILURE (Status))
711 {
712 ExitCode = -1;
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 /* Read the entire namespace initialization file if requested */
738
739 Status = AeProcessInitFile();
740 if (ACPI_FAILURE (Status))
741 {
742 ExitCode = -1;
743 goto ErrorExit;
744 }
745
746 Status = AeLoadTables ();
747 if (ACPI_FAILURE (Status))
748 {
749 printf ("**** Could not load ACPI tables, %s\n",
750 AcpiFormatException (Status));
751 goto EnterDebugger;
752 }
753
754 /*
755 * Exit namespace initialization for the "load namespace only" option.
756 * No control methods will be executed. However, still enter the
757 * the debugger.
758 */
759 if (AcpiGbl_AeLoadOnly)
760 {
761 goto EnterDebugger;
762 }
763
764 /* Setup initialization flags for ACPICA */
765
766 InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE);
767 if (AcpiGbl_DbOpt_NoIniMethods)
768 {
769 InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
770 }
771
772 /*
773 * Main initialization for ACPICA subsystem
774 * TBD: Need a way to call this after the ACPI table "LOAD" command?
775 *
776 * NOTE: This initialization does not match the _Lxx and _Exx methods
777 * to individual GPEs, as there are no real GPEs when the hardware
778 * is simulated - because there is no namespace until AeLoadTables is
779 * executed. This may have to change if AcpiExec is ever run natively
780 * on actual hardware (such as under UEFI).
781 */
782 Status = AcpiEnableSubsystem (InitFlags);
783 if (ACPI_FAILURE (Status))
784 {
785 printf ("**** Could not EnableSubsystem, %s\n",
786 AcpiFormatException (Status));
787 goto EnterDebugger;
788 }
789
790 /*
791 * Install handlers for "device driver" space IDs (EC,SMBus, etc.)
792 * and fixed event handlers
793 */
794 AeInstallLateHandlers ();
795
796 /* Finish the ACPICA initialization */
797
798 Status = AcpiInitializeObjects (InitFlags);
799 if (ACPI_FAILURE (Status))
800 {
801 printf ("**** Could not InitializeObjects, %s\n",
802 AcpiFormatException (Status));
803 goto EnterDebugger;
804 }
805
806 AeDisplayUnusedInitFileItems ();
807 AeMiscellaneousTests ();
808
809
810 EnterDebugger:
811
812 /* Exit if error above and we are in one of the batch modes */
813
814 if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0))
815 {
816 goto ErrorExit;
817 }
818
819 /* Run a batch command or enter the command loop */
820
821 switch (AcpiGbl_ExecutionMode)
822 {
823 default:
824 case AE_MODE_COMMAND_LOOP:
825
826 AcpiRunDebugger (NULL);
827 break;
828
829 case AE_MODE_BATCH_MULTIPLE:
830
831 AcpiRunDebugger (BatchBuffer);
832 break;
833
834 case AE_MODE_BATCH_SINGLE:
835
836 AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP);
837 break;
838 }
839
840 /* Shut down the debugger and ACPICA */
841
842 AcpiTerminateDebugger ();
843
844 /* re-enable debug output for AcpiTerminate output */
845
846 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
847
848 NormalExit:
849 ExitCode = 0;
850
851 ErrorExit:
852 AeLateTest ();
853
854 AeDeleteInitFileList ();
855
856 (void) AcpiTerminate ();
857 AcDeleteTableList (ListHead);
858 return (ExitCode);
859 }
860