1 /******************************************************************************
3 * Module Name: aemain - Main routine for the AcpiExec utility
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
124 #include "acparser.h"
125 #include "acnamesp.h"
126 #include "acinterp.h"
130 #include "aecommon.h"
133 #if ACPI_MACHINE_WIDTH != 16
138 #define _COMPONENT PARSER
139 ACPI_MODULE_NAME ("aemain")
142 UINT8 AcpiGbl_BatchMode = FALSE;
143 char *AcpiGbl_BatchMethodName;
145 #if ACPI_MACHINE_WIDTH == 16
148 AcpiGetIrqRoutingTable (
149 ACPI_HANDLE DeviceHandle,
150 ACPI_BUFFER *RetBuffer)
152 return AE_NOT_IMPLEMENTED;
163 AcpiOsPrintf ("Received a GPE at handler\n");
168 AfInstallGpeBlock (void)
172 ACPI_HANDLE Handle2 = NULL;
173 ACPI_HANDLE Handle3 = NULL;
174 ACPI_GENERIC_ADDRESS BlockAddress;
177 Status = AcpiGetHandle (NULL, "\\_GPE", &Handle);
178 if (ACPI_FAILURE (Status))
183 BlockAddress.AddressSpaceId = 0;
184 #if ACPI_MACHINE_WIDTH != 16
185 ACPI_STORE_ADDRESS (BlockAddress.Address, 0x8000000076540000);
187 ACPI_STORE_ADDRESS (BlockAddress.Address, 0x76540000);
190 // Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 4, 8);
192 /* Above should fail, ignore */
194 Status = AcpiGetHandle (NULL, "\\GPE2", &Handle2);
195 if (ACPI_SUCCESS (Status))
197 Status = AcpiInstallGpeBlock (Handle2, &BlockAddress, 8, 8);
199 AcpiInstallGpeHandler (Handle2, 8, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
200 AcpiSetGpeType (Handle2, 8, ACPI_GPE_TYPE_WAKE);
201 AcpiEnableGpe (Handle2, 8, 0);
204 Status = AcpiGetHandle (NULL, "\\GPE3", &Handle3);
205 if (ACPI_SUCCESS (Status))
207 Status = AcpiInstallGpeBlock (Handle3, &BlockAddress, 8, 11);
210 // Status = AcpiRemoveGpeBlock (Handle);
211 // Status = AcpiRemoveGpeBlock (Handle2);
212 // Status = AcpiRemoveGpeBlock (Handle3);
216 /******************************************************************************
224 * DESCRIPTION: Print a usage message
226 *****************************************************************************/
231 printf ("Usage: acpiexec [-?dgis] [-x DebugLevel] [-o OutputFile] [-b [Method]] [AcpiTableFile]\n");
233 printf (" Input Options\n");
234 printf (" AcpiTableFile Get ACPI tables from this file\n");
235 printf (" Output Options\n");
236 printf (" Miscellaneous Options\n");
237 printf (" -? Display this message\n");
238 printf (" -b [Method] Batch mode method execution\n");
239 printf (" -i Do not run STA/INI methods\n");
240 printf (" -x DebugLevel Specify debug output level\n");
241 printf (" -v Verbose init output\n");
245 /******************************************************************************
249 * PARAMETERS: argc, argv
253 * DESCRIPTION: Main routine for AcpiDump utility
255 *****************************************************************************/
257 int ACPI_SYSTEM_XFACE
265 ACPI_BUFFER ReturnBuf;
266 ACPI_TABLE_HEADER *Table;
271 #if ACPI_MACHINE_WIDTH != 16
272 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
273 _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
277 signal (SIGINT, AeCtrlCHandler);
281 AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
282 AcpiDbgLayer = 0xFFFFFFFF;
284 /* Init ACPI and start debugger thread */
286 AcpiInitializeSubsystem ();
287 AcpiGbl_GlobalLockPresent = TRUE;
289 printf ("\nIntel ACPI Component Architecture\nAML Execution/Debug Utility");
291 #if ACPI_MACHINE_WIDTH == 16
292 printf (" (16-bit)");
295 printf (" version %8.8X", ((UINT32) ACPI_CA_VERSION));
296 printf (" [%s]\n\n", __DATE__);
298 /* Get the command line options */
300 while ((j = AcpiGetopt (argc, argv, "?b^dgio:svx:")) != EOF) switch(j)
303 AcpiGbl_BatchMode = TRUE;
304 switch (AcpiGbl_Optarg[0])
307 AcpiGbl_BatchMethodName = "MAIN";
310 AcpiGbl_BatchMethodName = AcpiGbl_Optarg;
316 AcpiGbl_DbOpt_disasm = TRUE;
317 AcpiGbl_DbOpt_stats = TRUE;
321 AcpiGbl_DbOpt_tables = TRUE;
322 AcpiGbl_DbFilename = NULL;
326 AcpiGbl_DbOpt_ini_methods = FALSE;
330 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0);
331 AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel;
332 printf ("Debug Level: %lX\n", AcpiDbgLevel);
336 printf ("O option is not implemented\n");
340 AcpiGbl_DbOpt_stats = TRUE;
344 AcpiDbgLevel |= ACPI_LV_INIT_NAMES;
354 InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE);
355 if (!AcpiGbl_DbOpt_ini_methods)
357 InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
360 /* Standalone filename is the only argument */
362 if (argv[AcpiGbl_Optind])
364 AcpiGbl_DbOpt_tables = TRUE;
365 AcpiGbl_DbFilename = argv[AcpiGbl_Optind];
367 Status = AcpiDbReadTableFromFile (AcpiGbl_DbFilename, &Table);
368 if (ACPI_FAILURE (Status))
370 printf ("**** Could not get input table, %s\n", AcpiFormatException (Status));
374 AeBuildLocalTables (Table);
375 Status = AeInstallTables ();
376 if (ACPI_FAILURE (Status))
378 printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status));
382 Status = AeInstallHandlers ();
383 if (ACPI_FAILURE (Status))
390 * Need a way to call this after the "LOAD" command
392 Status = AcpiEnableSubsystem (InitFlags);
393 if (ACPI_FAILURE (Status))
395 printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status));
399 Status = AcpiInitializeObjects (InitFlags);
400 if (ACPI_FAILURE (Status))
402 printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status));
407 ReturnBuf.Length = 32;
408 ReturnBuf.Pointer = Buffer;
409 AcpiGetName (AcpiGbl_RootNode, ACPI_FULL_PATHNAME, &ReturnBuf);
410 AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
412 AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
413 AcpiSetGpeType (NULL, 0, ACPI_GPE_TYPE_WAKE_RUN);
414 AcpiEnableGpe (NULL, 0, ACPI_NOT_ISR);
415 AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
417 AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
418 AcpiSetGpeType (NULL, 0, ACPI_GPE_TYPE_WAKE_RUN);
419 AcpiEnableGpe (NULL, 0, ACPI_NOT_ISR);
421 AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
422 AcpiSetGpeType (NULL, 1, ACPI_GPE_TYPE_RUNTIME);
423 AcpiEnableGpe (NULL, 1, ACPI_NOT_ISR);
425 AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
426 AcpiSetGpeType (NULL, 2, ACPI_GPE_TYPE_WAKE);
427 AcpiEnableGpe (NULL, 2, ACPI_NOT_ISR);
429 AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
430 AcpiSetGpeType (NULL, 3, ACPI_GPE_TYPE_WAKE_RUN);
432 AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
433 AcpiSetGpeType (NULL, 4, ACPI_GPE_TYPE_RUNTIME);
435 AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
436 AcpiSetGpeType (NULL, 5, ACPI_GPE_TYPE_WAKE);
438 AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
439 AcpiSetGpeType (NULL, 0x19, ACPI_GPE_TYPE_WAKE_RUN);
440 AcpiEnableGpe (NULL, 0x19, ACPI_NOT_ISR);
443 AfInstallGpeBlock ();
446 #if ACPI_MACHINE_WIDTH == 16
451 Status = AfFindTable (DSDT_SIG, NULL, NULL);
452 if (ACPI_FAILURE (Status))
458 if (ACPI_FAILURE (Status))
460 printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status));
465 Status = AcpiNsLoadNamespace ();
466 if (ACPI_FAILURE (Status))
468 printf ("**** Could not load ACPI namespace, %s\n", AcpiFormatException (Status));
473 Status = AeInstallHandlers ();
474 if (ACPI_FAILURE (Status))
479 * Need a way to call this after the "LOAD" command
481 Status = AcpiEnableSubsystem (InitFlags);
482 if (ACPI_FAILURE (Status))
484 printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status));
488 Status = AcpiInitializeObjects (InitFlags);
489 if (ACPI_FAILURE (Status))
491 printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status));
500 if (AcpiGbl_BatchMode)
502 AcpiDbExecute (AcpiGbl_BatchMethodName, NULL, EX_NO_SINGLE_STEP);
506 /* Enter the debugger command loop */
508 AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL);