aemain.c revision 1.1.1.5 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: aemain - Main routine for the AcpiExec utility
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.5 christos * Copyright (C) 2000 - 2014, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "aecommon.h"
45 1.1 jruoho
46 1.1.1.4 christos #define _COMPONENT ACPI_TOOLS
47 1.1 jruoho ACPI_MODULE_NAME ("aemain")
48 1.1 jruoho
49 1.1.1.2 jruoho
50 1.1.1.4 christos /*
51 1.1.1.4 christos * Main routine for the ACPI user-space execution utility.
52 1.1 jruoho *
53 1.1.1.4 christos * Portability note: The utility depends upon the host for command-line
54 1.1.1.4 christos * wildcard support - it is not implemented locally. For example:
55 1.1 jruoho *
56 1.1.1.4 christos * Linux/Unix systems: Shell expands wildcards automatically.
57 1.1 jruoho *
58 1.1.1.4 christos * Windows: The setargv.obj module must be linked in to automatically
59 1.1.1.4 christos * expand wildcards.
60 1.1.1.4 christos */
61 1.1.1.4 christos extern BOOLEAN AcpiGbl_DebugTimeout;
62 1.1 jruoho
63 1.1.1.4 christos /* Local prototypes */
64 1.1 jruoho
65 1.1.1.4 christos static int
66 1.1.1.4 christos AeDoOptions (
67 1.1.1.4 christos int argc,
68 1.1.1.4 christos char **argv);
69 1.1 jruoho
70 1.1 jruoho static ACPI_STATUS
71 1.1 jruoho AcpiDbRunBatchMode (
72 1.1.1.4 christos void);
73 1.1 jruoho
74 1.1 jruoho
75 1.1.1.4 christos #define AE_BUFFER_SIZE 1024
76 1.1.1.4 christos #define ASL_MAX_FILES 256
77 1.1 jruoho
78 1.1.1.4 christos /* Execution modes */
79 1.1 jruoho
80 1.1.1.4 christos #define AE_MODE_COMMAND_LOOP 0 /* Normal command execution loop */
81 1.1.1.4 christos #define AE_MODE_BATCH_MULTIPLE 1 /* -b option to execute a command line */
82 1.1.1.4 christos #define AE_MODE_BATCH_SINGLE 2 /* -m option to execute a single control method */
83 1.1 jruoho
84 1.1 jruoho
85 1.1.1.4 christos /* Globals */
86 1.1 jruoho
87 1.1.1.4 christos UINT8 AcpiGbl_RegionFillValue = 0;
88 1.1.1.4 christos BOOLEAN AcpiGbl_IgnoreErrors = FALSE;
89 1.1.1.4 christos BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE;
90 1.1.1.4 christos UINT8 AcpiGbl_UseHwReducedFadt = FALSE;
91 1.1.1.4 christos BOOLEAN AcpiGbl_DoInterfaceTests = FALSE;
92 1.1.1.5 christos BOOLEAN AcpiGbl_LoadTestTables = FALSE;
93 1.1.1.4 christos static UINT8 AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP;
94 1.1.1.4 christos static char BatchBuffer[AE_BUFFER_SIZE]; /* Batch command buffer */
95 1.1.1.4 christos static AE_TABLE_DESC *AeTableListHead = NULL;
96 1.1 jruoho
97 1.1.1.4 christos #define ACPIEXEC_NAME "AML Execution/Debug Utility"
98 1.1.1.4 christos #define AE_SUPPORTED_OPTIONS "?b:d:e:f:ghm^orv^:x:"
99 1.1 jruoho
100 1.1 jruoho
101 1.1.1.5 christos /* Stubs for the disassembler */
102 1.1.1.5 christos
103 1.1.1.5 christos void
104 1.1.1.5 christos MpSaveGpioInfo (
105 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
106 1.1.1.5 christos AML_RESOURCE *Resource,
107 1.1.1.5 christos UINT32 PinCount,
108 1.1.1.5 christos UINT16 *PinList,
109 1.1.1.5 christos char *DeviceName)
110 1.1.1.5 christos {
111 1.1.1.5 christos }
112 1.1.1.5 christos
113 1.1.1.5 christos void
114 1.1.1.5 christos MpSaveSerialInfo (
115 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
116 1.1.1.5 christos AML_RESOURCE *Resource,
117 1.1.1.5 christos char *DeviceName)
118 1.1.1.5 christos {
119 1.1.1.5 christos }
120 1.1.1.5 christos
121 1.1.1.5 christos
122 1.1 jruoho /******************************************************************************
123 1.1 jruoho *
124 1.1.1.4 christos * FUNCTION: usage
125 1.1 jruoho *
126 1.1.1.4 christos * PARAMETERS: None
127 1.1 jruoho *
128 1.1.1.4 christos * RETURN: None
129 1.1 jruoho *
130 1.1.1.4 christos * DESCRIPTION: Print a usage message
131 1.1 jruoho *
132 1.1.1.4 christos *****************************************************************************/
133 1.1 jruoho
134 1.1.1.4 christos static void
135 1.1.1.4 christos usage (
136 1.1.1.4 christos void)
137 1.1 jruoho {
138 1.1 jruoho
139 1.1.1.4 christos ACPI_USAGE_HEADER ("acpiexec [options] AMLfile1 AMLfile2 ...");
140 1.1 jruoho
141 1.1.1.4 christos ACPI_OPTION ("-b \"CommandLine\"", "Batch mode command line execution (cmd1;cmd2;...)");
142 1.1.1.4 christos ACPI_OPTION ("-h -?", "Display this help message");
143 1.1.1.4 christos ACPI_OPTION ("-m [Method]", "Batch mode method execution. Default=MAIN");
144 1.1.1.4 christos printf ("\n");
145 1.1 jruoho
146 1.1.1.4 christos ACPI_OPTION ("-da", "Disable method abort on error");
147 1.1.1.4 christos ACPI_OPTION ("-di", "Disable execution of STA/INI methods during init");
148 1.1.1.4 christos ACPI_OPTION ("-do", "Disable Operation Region address simulation");
149 1.1.1.4 christos ACPI_OPTION ("-dr", "Disable repair of method return values");
150 1.1.1.5 christos ACPI_OPTION ("-ds", "Disable method auto-serialization");
151 1.1.1.4 christos ACPI_OPTION ("-dt", "Disable allocation tracking (performance)");
152 1.1.1.4 christos printf ("\n");
153 1.1 jruoho
154 1.1.1.4 christos ACPI_OPTION ("-ef", "Enable display of final memory statistics");
155 1.1.1.4 christos ACPI_OPTION ("-ei", "Enable additional tests for ACPICA interfaces");
156 1.1.1.5 christos ACPI_OPTION ("-el", "Enable loading of additional test tables");
157 1.1.1.4 christos ACPI_OPTION ("-es", "Enable Interpreter Slack Mode");
158 1.1.1.4 christos ACPI_OPTION ("-et", "Enable debug semaphore timeout");
159 1.1.1.4 christos printf ("\n");
160 1.1 jruoho
161 1.1.1.4 christos ACPI_OPTION ("-f <Value>", "Operation Region initialization fill value");
162 1.1.1.4 christos ACPI_OPTION ("-r", "Use hardware-reduced FADT V5");
163 1.1.1.4 christos ACPI_OPTION ("-v", "Display version information");
164 1.1.1.4 christos ACPI_OPTION ("-vi", "Verbose initialization output");
165 1.1.1.4 christos ACPI_OPTION ("-vr", "Verbose region handler output");
166 1.1.1.4 christos ACPI_OPTION ("-x <DebugLevel>", "Debug output level");
167 1.1 jruoho }
168 1.1 jruoho
169 1.1 jruoho
170 1.1 jruoho /******************************************************************************
171 1.1 jruoho *
172 1.1.1.4 christos * FUNCTION: AeDoOptions
173 1.1 jruoho *
174 1.1.1.4 christos * PARAMETERS: argc/argv - Standard argc/argv
175 1.1 jruoho *
176 1.1 jruoho * RETURN: Status
177 1.1 jruoho *
178 1.1.1.4 christos * DESCRIPTION: Command line option processing
179 1.1 jruoho *
180 1.1 jruoho *****************************************************************************/
181 1.1 jruoho
182 1.1.1.4 christos static int
183 1.1.1.4 christos AeDoOptions (
184 1.1 jruoho int argc,
185 1.1 jruoho char **argv)
186 1.1 jruoho {
187 1.1 jruoho int j;
188 1.1 jruoho
189 1.1 jruoho
190 1.1.1.5 christos while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
191 1.1 jruoho {
192 1.1 jruoho case 'b':
193 1.1.1.4 christos
194 1.1.1.4 christos if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1))
195 1.1 jruoho {
196 1.1.1.4 christos printf ("**** The length of command line (%u) exceeded maximum (%u)\n",
197 1.1.1.4 christos (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1));
198 1.1.1.2 jruoho return (-1);
199 1.1 jruoho }
200 1.1.1.4 christos AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE;
201 1.1 jruoho strcpy (BatchBuffer, AcpiGbl_Optarg);
202 1.1 jruoho break;
203 1.1 jruoho
204 1.1 jruoho case 'd':
205 1.1.1.4 christos
206 1.1 jruoho switch (AcpiGbl_Optarg[0])
207 1.1 jruoho {
208 1.1 jruoho case 'a':
209 1.1.1.4 christos
210 1.1 jruoho AcpiGbl_IgnoreErrors = TRUE;
211 1.1 jruoho break;
212 1.1 jruoho
213 1.1 jruoho case 'i':
214 1.1.1.4 christos
215 1.1 jruoho AcpiGbl_DbOpt_ini_methods = FALSE;
216 1.1 jruoho break;
217 1.1 jruoho
218 1.1 jruoho case 'o':
219 1.1.1.4 christos
220 1.1 jruoho AcpiGbl_DbOpt_NoRegionSupport = TRUE;
221 1.1 jruoho break;
222 1.1 jruoho
223 1.1.1.3 jruoho case 'r':
224 1.1.1.4 christos
225 1.1.1.3 jruoho AcpiGbl_DisableAutoRepair = TRUE;
226 1.1.1.3 jruoho break;
227 1.1.1.3 jruoho
228 1.1.1.5 christos case 's':
229 1.1.1.5 christos
230 1.1.1.5 christos AcpiGbl_AutoSerializeMethods = FALSE;
231 1.1.1.5 christos break;
232 1.1.1.5 christos
233 1.1 jruoho case 't':
234 1.1.1.4 christos
235 1.1 jruoho #ifdef ACPI_DBG_TRACK_ALLOCATIONS
236 1.1 jruoho AcpiGbl_DisableMemTracking = TRUE;
237 1.1 jruoho #endif
238 1.1 jruoho break;
239 1.1 jruoho
240 1.1 jruoho default:
241 1.1.1.4 christos
242 1.1 jruoho printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
243 1.1 jruoho return (-1);
244 1.1 jruoho }
245 1.1 jruoho break;
246 1.1 jruoho
247 1.1 jruoho case 'e':
248 1.1.1.4 christos
249 1.1 jruoho switch (AcpiGbl_Optarg[0])
250 1.1 jruoho {
251 1.1 jruoho case 'f':
252 1.1.1.4 christos
253 1.1 jruoho #ifdef ACPI_DBG_TRACK_ALLOCATIONS
254 1.1 jruoho AcpiGbl_DisplayFinalMemStats = TRUE;
255 1.1 jruoho #endif
256 1.1 jruoho break;
257 1.1 jruoho
258 1.1.1.4 christos case 'i':
259 1.1.1.4 christos
260 1.1.1.4 christos AcpiGbl_DoInterfaceTests = TRUE;
261 1.1.1.4 christos break;
262 1.1.1.4 christos
263 1.1.1.5 christos case 'l':
264 1.1.1.4 christos
265 1.1.1.5 christos AcpiGbl_LoadTestTables = TRUE;
266 1.1 jruoho break;
267 1.1 jruoho
268 1.1 jruoho case 's':
269 1.1.1.4 christos
270 1.1 jruoho AcpiGbl_EnableInterpreterSlack = TRUE;
271 1.1 jruoho printf ("Enabling AML Interpreter slack mode\n");
272 1.1 jruoho break;
273 1.1 jruoho
274 1.1 jruoho case 't':
275 1.1.1.4 christos
276 1.1 jruoho AcpiGbl_DebugTimeout = TRUE;
277 1.1 jruoho break;
278 1.1 jruoho
279 1.1 jruoho default:
280 1.1.1.4 christos
281 1.1 jruoho printf ("Unknown option: -e%s\n", AcpiGbl_Optarg);
282 1.1 jruoho return (-1);
283 1.1 jruoho }
284 1.1 jruoho break;
285 1.1 jruoho
286 1.1 jruoho case 'f':
287 1.1.1.4 christos
288 1.1 jruoho AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
289 1.1 jruoho break;
290 1.1 jruoho
291 1.1 jruoho case 'g':
292 1.1.1.4 christos
293 1.1 jruoho AcpiGbl_DbOpt_tables = TRUE;
294 1.1 jruoho AcpiGbl_DbFilename = NULL;
295 1.1 jruoho break;
296 1.1 jruoho
297 1.1.1.4 christos case 'h':
298 1.1.1.4 christos case '?':
299 1.1.1.4 christos
300 1.1.1.4 christos usage();
301 1.1.1.4 christos return (0);
302 1.1.1.4 christos
303 1.1 jruoho case 'm':
304 1.1.1.4 christos
305 1.1.1.4 christos AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE;
306 1.1 jruoho switch (AcpiGbl_Optarg[0])
307 1.1 jruoho {
308 1.1 jruoho case '^':
309 1.1.1.4 christos
310 1.1 jruoho strcpy (BatchBuffer, "MAIN");
311 1.1 jruoho break;
312 1.1 jruoho
313 1.1 jruoho default:
314 1.1.1.4 christos
315 1.1 jruoho strcpy (BatchBuffer, AcpiGbl_Optarg);
316 1.1 jruoho break;
317 1.1 jruoho }
318 1.1 jruoho break;
319 1.1 jruoho
320 1.1 jruoho case 'o':
321 1.1.1.4 christos
322 1.1 jruoho AcpiGbl_DbOpt_disasm = TRUE;
323 1.1 jruoho AcpiGbl_DbOpt_stats = TRUE;
324 1.1 jruoho break;
325 1.1 jruoho
326 1.1.1.4 christos case 'r':
327 1.1.1.4 christos
328 1.1.1.4 christos AcpiGbl_UseHwReducedFadt = TRUE;
329 1.1.1.4 christos printf ("Using ACPI 5.0 Hardware Reduced Mode via version 5 FADT\n");
330 1.1.1.4 christos break;
331 1.1.1.4 christos
332 1.1 jruoho case 'v':
333 1.1.1.4 christos
334 1.1.1.4 christos switch (AcpiGbl_Optarg[0])
335 1.1.1.4 christos {
336 1.1.1.4 christos case '^': /* -v: (Version): signon already emitted, just exit */
337 1.1.1.4 christos
338 1.1.1.5 christos (void) AcpiOsTerminate ();
339 1.1.1.4 christos exit (0);
340 1.1.1.4 christos
341 1.1.1.4 christos case 'i':
342 1.1.1.4 christos
343 1.1.1.4 christos AcpiDbgLevel |= ACPI_LV_INIT_NAMES;
344 1.1.1.4 christos break;
345 1.1.1.4 christos
346 1.1.1.4 christos case 'r':
347 1.1.1.4 christos
348 1.1.1.4 christos AcpiGbl_DisplayRegionAccess = TRUE;
349 1.1.1.4 christos break;
350 1.1.1.4 christos
351 1.1.1.4 christos default:
352 1.1.1.4 christos
353 1.1.1.4 christos printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
354 1.1.1.4 christos return (-1);
355 1.1.1.4 christos }
356 1.1 jruoho break;
357 1.1 jruoho
358 1.1 jruoho case 'x':
359 1.1.1.4 christos
360 1.1 jruoho AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0);
361 1.1 jruoho AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel;
362 1.1 jruoho printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel);
363 1.1 jruoho break;
364 1.1 jruoho
365 1.1 jruoho default:
366 1.1.1.4 christos
367 1.1 jruoho usage();
368 1.1.1.2 jruoho return (-1);
369 1.1 jruoho }
370 1.1 jruoho
371 1.1.1.4 christos return (0);
372 1.1.1.4 christos }
373 1.1 jruoho
374 1.1 jruoho
375 1.1.1.4 christos /******************************************************************************
376 1.1.1.4 christos *
377 1.1.1.4 christos * FUNCTION: main
378 1.1.1.4 christos *
379 1.1.1.4 christos * PARAMETERS: argc, argv
380 1.1.1.4 christos *
381 1.1.1.4 christos * RETURN: Status
382 1.1.1.4 christos *
383 1.1.1.4 christos * DESCRIPTION: Main routine for AcpiExec utility
384 1.1.1.4 christos *
385 1.1.1.4 christos *****************************************************************************/
386 1.1 jruoho
387 1.1.1.4 christos int ACPI_SYSTEM_XFACE
388 1.1.1.4 christos main (
389 1.1.1.4 christos int argc,
390 1.1.1.4 christos char **argv)
391 1.1.1.4 christos {
392 1.1.1.4 christos ACPI_STATUS Status;
393 1.1.1.4 christos UINT32 InitFlags;
394 1.1.1.4 christos ACPI_TABLE_HEADER *Table = NULL;
395 1.1.1.4 christos UINT32 TableCount;
396 1.1.1.4 christos AE_TABLE_DESC *TableDesc;
397 1.1 jruoho
398 1.1 jruoho
399 1.1.1.4 christos ACPI_DEBUG_INITIALIZE (); /* For debug version only */
400 1.1.1.4 christos signal (SIGINT, AeCtrlCHandler);
401 1.1 jruoho
402 1.1.1.5 christos /* Init debug globals */
403 1.1 jruoho
404 1.1.1.4 christos AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
405 1.1.1.4 christos AcpiDbgLayer = 0xFFFFFFFF;
406 1.1 jruoho
407 1.1.1.5 christos /* Init ACPICA and start debugger thread */
408 1.1 jruoho
409 1.1.1.4 christos Status = AcpiInitializeSubsystem ();
410 1.1.1.4 christos AE_CHECK_OK (AcpiInitializeSubsystem, Status);
411 1.1.1.4 christos if (ACPI_FAILURE (Status))
412 1.1.1.4 christos {
413 1.1.1.4 christos goto ErrorExit;
414 1.1.1.4 christos }
415 1.1 jruoho
416 1.1.1.5 christos printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME));
417 1.1.1.5 christos if (argc < 2)
418 1.1.1.5 christos {
419 1.1.1.5 christos usage ();
420 1.1.1.5 christos (void) AcpiOsTerminate ();
421 1.1.1.5 christos return (0);
422 1.1.1.5 christos }
423 1.1.1.5 christos
424 1.1.1.4 christos /* Get the command line options */
425 1.1 jruoho
426 1.1.1.4 christos if (AeDoOptions (argc, argv))
427 1.1.1.4 christos {
428 1.1.1.4 christos goto ErrorExit;
429 1.1.1.4 christos }
430 1.1 jruoho
431 1.1.1.4 christos /* The remaining arguments are filenames for ACPI tables */
432 1.1 jruoho
433 1.1.1.4 christos if (!argv[AcpiGbl_Optind])
434 1.1.1.4 christos {
435 1.1.1.4 christos goto EnterDebugger;
436 1.1.1.4 christos }
437 1.1 jruoho
438 1.1.1.4 christos AcpiGbl_DbOpt_tables = TRUE;
439 1.1.1.4 christos TableCount = 0;
440 1.1 jruoho
441 1.1.1.4 christos /* Get each of the ACPI table files on the command line */
442 1.1 jruoho
443 1.1.1.4 christos while (argv[AcpiGbl_Optind])
444 1.1.1.4 christos {
445 1.1.1.4 christos /* Get one entire table */
446 1.1 jruoho
447 1.1.1.5 christos Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table);
448 1.1 jruoho if (ACPI_FAILURE (Status))
449 1.1 jruoho {
450 1.1.1.4 christos printf ("**** Could not get table from file %s, %s\n",
451 1.1.1.4 christos argv[AcpiGbl_Optind], AcpiFormatException (Status));
452 1.1.1.4 christos goto ErrorExit;
453 1.1 jruoho }
454 1.1 jruoho
455 1.1.1.4 christos /* Ignore non-AML tables, we can't use them. Except for an FADT */
456 1.1 jruoho
457 1.1.1.4 christos if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) &&
458 1.1.1.4 christos !AcpiUtIsAmlTable (Table))
459 1.1 jruoho {
460 1.1.1.4 christos ACPI_INFO ((AE_INFO,
461 1.1.1.4 christos "Table [%4.4s] is not an AML table, ignoring",
462 1.1.1.4 christos Table->Signature));
463 1.1.1.4 christos AcpiOsFree (Table);
464 1.1 jruoho }
465 1.1.1.4 christos else
466 1.1 jruoho {
467 1.1.1.4 christos /* Allocate and link a table descriptor */
468 1.1 jruoho
469 1.1.1.4 christos TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC));
470 1.1.1.4 christos TableDesc->Table = Table;
471 1.1.1.4 christos TableDesc->Next = AeTableListHead;
472 1.1.1.4 christos AeTableListHead = TableDesc;
473 1.1.1.4 christos
474 1.1.1.4 christos TableCount++;
475 1.1 jruoho }
476 1.1 jruoho
477 1.1.1.4 christos AcpiGbl_Optind++;
478 1.1 jruoho }
479 1.1 jruoho
480 1.1.1.5 christos printf ("\n");
481 1.1.1.5 christos
482 1.1.1.4 christos /* Build a local RSDT with all tables and let ACPICA process the RSDT */
483 1.1 jruoho
484 1.1.1.4 christos Status = AeBuildLocalTables (TableCount, AeTableListHead);
485 1.1.1.4 christos if (ACPI_FAILURE (Status))
486 1.1 jruoho {
487 1.1.1.4 christos goto ErrorExit;
488 1.1 jruoho }
489 1.1.1.4 christos
490 1.1.1.4 christos Status = AeInstallTables ();
491 1.1.1.4 christos if (ACPI_FAILURE (Status))
492 1.1 jruoho {
493 1.1.1.4 christos printf ("**** Could not load ACPI tables, %s\n",
494 1.1.1.4 christos AcpiFormatException (Status));
495 1.1.1.4 christos goto EnterDebugger;
496 1.1.1.4 christos }
497 1.1.1.4 christos
498 1.1.1.4 christos /*
499 1.1.1.4 christos * Install most of the handlers.
500 1.1.1.4 christos * Override some default region handlers, especially SystemMemory
501 1.1.1.4 christos */
502 1.1.1.4 christos Status = AeInstallEarlyHandlers ();
503 1.1.1.4 christos if (ACPI_FAILURE (Status))
504 1.1.1.4 christos {
505 1.1.1.4 christos goto EnterDebugger;
506 1.1.1.4 christos }
507 1.1.1.4 christos
508 1.1.1.4 christos /* Setup initialization flags for ACPICA */
509 1.1.1.4 christos
510 1.1.1.4 christos InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE);
511 1.1.1.4 christos if (!AcpiGbl_DbOpt_ini_methods)
512 1.1.1.4 christos {
513 1.1.1.4 christos InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
514 1.1.1.4 christos }
515 1.1.1.4 christos
516 1.1.1.4 christos /*
517 1.1.1.4 christos * Main initialization for ACPICA subsystem
518 1.1.1.4 christos * TBD: Need a way to call this after the ACPI table "LOAD" command
519 1.1.1.4 christos */
520 1.1.1.4 christos Status = AcpiEnableSubsystem (InitFlags);
521 1.1.1.4 christos if (ACPI_FAILURE (Status))
522 1.1.1.4 christos {
523 1.1.1.4 christos printf ("**** Could not EnableSubsystem, %s\n",
524 1.1.1.4 christos AcpiFormatException (Status));
525 1.1.1.4 christos goto EnterDebugger;
526 1.1.1.4 christos }
527 1.1.1.4 christos
528 1.1.1.4 christos /*
529 1.1.1.4 christos * Install handlers for "device driver" space IDs (EC,SMBus, etc.)
530 1.1.1.4 christos * and fixed event handlers
531 1.1.1.4 christos */
532 1.1.1.4 christos AeInstallLateHandlers ();
533 1.1.1.4 christos
534 1.1.1.4 christos /* Finish the ACPICA initialization */
535 1.1.1.4 christos
536 1.1.1.4 christos Status = AcpiInitializeObjects (InitFlags);
537 1.1.1.4 christos if (ACPI_FAILURE (Status))
538 1.1.1.4 christos {
539 1.1.1.4 christos printf ("**** Could not InitializeObjects, %s\n",
540 1.1.1.4 christos AcpiFormatException (Status));
541 1.1.1.4 christos goto EnterDebugger;
542 1.1.1.4 christos }
543 1.1.1.4 christos
544 1.1.1.4 christos AeMiscellaneousTests ();
545 1.1.1.4 christos
546 1.1.1.4 christos
547 1.1.1.4 christos EnterDebugger:
548 1.1.1.4 christos
549 1.1.1.4 christos /* Exit if error above and we are in one of the batch modes */
550 1.1.1.4 christos
551 1.1.1.4 christos if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0))
552 1.1.1.4 christos {
553 1.1.1.4 christos goto ErrorExit;
554 1.1 jruoho }
555 1.1.1.4 christos
556 1.1.1.4 christos /* Run a batch command or enter the command loop */
557 1.1.1.4 christos
558 1.1.1.4 christos switch (AcpiGbl_ExecutionMode)
559 1.1 jruoho {
560 1.1.1.4 christos default:
561 1.1.1.4 christos case AE_MODE_COMMAND_LOOP:
562 1.1 jruoho
563 1.1 jruoho AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL);
564 1.1.1.4 christos break;
565 1.1.1.4 christos
566 1.1.1.4 christos case AE_MODE_BATCH_MULTIPLE:
567 1.1.1.4 christos
568 1.1.1.4 christos AcpiDbRunBatchMode ();
569 1.1.1.4 christos break;
570 1.1.1.4 christos
571 1.1.1.4 christos case AE_MODE_BATCH_SINGLE:
572 1.1.1.4 christos
573 1.1.1.4 christos AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP);
574 1.1.1.4 christos Status = AcpiTerminate ();
575 1.1.1.4 christos break;
576 1.1 jruoho }
577 1.1 jruoho
578 1.1.1.2 jruoho return (0);
579 1.1.1.4 christos
580 1.1.1.4 christos
581 1.1.1.4 christos ErrorExit:
582 1.1.1.4 christos
583 1.1.1.4 christos (void) AcpiOsTerminate ();
584 1.1.1.4 christos return (-1);
585 1.1 jruoho }
586 1.1 jruoho
587 1.1.1.4 christos
588 1.1.1.4 christos /******************************************************************************
589 1.1.1.4 christos *
590 1.1.1.4 christos * FUNCTION: AcpiDbRunBatchMode
591 1.1.1.4 christos *
592 1.1.1.4 christos * PARAMETERS: BatchCommandLine - A semicolon separated list of commands
593 1.1.1.4 christos * to be executed.
594 1.1.1.4 christos * Use only commas to separate elements of
595 1.1.1.4 christos * particular command.
596 1.1.1.4 christos * RETURN: Status
597 1.1.1.4 christos *
598 1.1.1.4 christos * DESCRIPTION: For each command of list separated by ';' prepare the command
599 1.1.1.4 christos * buffer and pass it to AcpiDbCommandDispatch.
600 1.1.1.4 christos *
601 1.1.1.4 christos *****************************************************************************/
602 1.1.1.4 christos
603 1.1.1.4 christos static ACPI_STATUS
604 1.1.1.4 christos AcpiDbRunBatchMode (
605 1.1.1.4 christos void)
606 1.1.1.4 christos {
607 1.1.1.4 christos ACPI_STATUS Status;
608 1.1.1.4 christos char *Ptr = BatchBuffer;
609 1.1.1.4 christos char *Cmd = Ptr;
610 1.1.1.4 christos UINT8 Run = 0;
611 1.1.1.4 christos
612 1.1.1.4 christos
613 1.1.1.4 christos AcpiGbl_MethodExecuting = FALSE;
614 1.1.1.4 christos AcpiGbl_StepToNextCall = FALSE;
615 1.1.1.4 christos
616 1.1.1.4 christos while (*Ptr)
617 1.1.1.4 christos {
618 1.1.1.4 christos if (*Ptr == ',')
619 1.1.1.4 christos {
620 1.1.1.4 christos /* Convert commas to spaces */
621 1.1.1.4 christos *Ptr = ' ';
622 1.1.1.4 christos }
623 1.1.1.4 christos else if (*Ptr == ';')
624 1.1.1.4 christos {
625 1.1.1.4 christos *Ptr = '\0';
626 1.1.1.4 christos Run = 1;
627 1.1.1.4 christos }
628 1.1.1.4 christos
629 1.1.1.4 christos Ptr++;
630 1.1.1.4 christos
631 1.1.1.4 christos if (Run || (*Ptr == '\0'))
632 1.1.1.4 christos {
633 1.1.1.4 christos (void) AcpiDbCommandDispatch (Cmd, NULL, NULL);
634 1.1.1.4 christos Run = 0;
635 1.1.1.4 christos Cmd = Ptr;
636 1.1.1.4 christos }
637 1.1.1.4 christos }
638 1.1.1.4 christos
639 1.1.1.4 christos Status = AcpiTerminate ();
640 1.1.1.4 christos return (Status);
641 1.1.1.4 christos }
642