Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 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 - 2010, 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 | #include "aecommon.h" |
||
117 | |||
118 | #ifdef _DEBUG |
||
119 | #include |
||
120 | #endif |
||
121 | |||
122 | #define _COMPONENT PARSER |
||
123 | ACPI_MODULE_NAME ("aemain") |
||
124 | |||
125 | UINT8 AcpiGbl_BatchMode = 0; |
||
126 | UINT8 AcpiGbl_RegionFillValue = 0; |
||
127 | BOOLEAN AcpiGbl_IgnoreErrors = FALSE; |
||
128 | BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; |
||
129 | BOOLEAN AcpiGbl_DebugTimeout = FALSE; |
||
130 | char BatchBuffer[128]; |
||
131 | AE_TABLE_DESC *AeTableListHead = NULL; |
||
132 | |||
133 | #define ASL_MAX_FILES 256 |
||
134 | char *FileList[ASL_MAX_FILES]; |
||
135 | int FileCount; |
||
136 | |||
137 | |||
138 | #define AE_SUPPORTED_OPTIONS "?b:d:e:f:gm^ovx:" |
||
139 | |||
140 | |||
141 | /****************************************************************************** |
||
142 | * |
||
143 | * FUNCTION: usage |
||
144 | * |
||
145 | * PARAMETERS: None |
||
146 | * |
||
147 | * RETURN: None |
||
148 | * |
||
149 | * DESCRIPTION: Print a usage message |
||
150 | * |
||
151 | *****************************************************************************/ |
||
152 | |||
153 | static void |
||
154 | usage (void) |
||
155 | { |
||
156 | printf ("Usage: acpiexec [options] AMLfile1 AMLfile2 ...\n\n"); |
||
157 | |||
158 | printf ("Where:\n"); |
||
159 | printf (" -? Display this message\n"); |
||
160 | printf (" -b |
||
161 | printf (" -m [Method] Batch mode method execution. Default=MAIN\n"); |
||
162 | printf ("\n"); |
||
163 | |||
164 | printf (" -da Disable method abort on error\n"); |
||
165 | printf (" -di Disable execution of STA/INI methods during init\n"); |
||
166 | printf (" -do Disable Operation Region address simulation\n"); |
||
167 | printf (" -dt Disable allocation tracking (performance)\n"); |
||
168 | printf ("\n"); |
||
169 | |||
170 | printf (" -ef Enable display of final memory statistics\n"); |
||
171 | printf (" -em Enable Interpreter Serialized Mode\n"); |
||
172 | printf (" -es Enable Interpreter Slack Mode\n"); |
||
173 | printf (" -et Enable debug semaphore timeout\n"); |
||
174 | printf ("\n"); |
||
175 | |||
176 | printf (" -f |
||
177 | printf (" -v Verbose initialization output\n"); |
||
178 | printf (" -x |
||
179 | } |
||
180 | |||
181 | |||
182 | /****************************************************************************** |
||
183 | * |
||
184 | * FUNCTION: AcpiDbRunBatchMode |
||
185 | * |
||
186 | * PARAMETERS: BatchCommandLine - A semicolon separated list of commands |
||
187 | * to be executed. |
||
188 | * Use only commas to separate elements of |
||
189 | * particular command. |
||
190 | * RETURN: Status |
||
191 | * |
||
192 | * DESCRIPTION: For each command of list separated by ';' prepare the command |
||
193 | * buffer and pass it to AcpiDbCommandDispatch. |
||
194 | * |
||
195 | *****************************************************************************/ |
||
196 | |||
197 | static ACPI_STATUS |
||
198 | AcpiDbRunBatchMode ( |
||
199 | void) |
||
200 | { |
||
201 | ACPI_STATUS Status; |
||
202 | char *Ptr = BatchBuffer; |
||
203 | char *Cmd = Ptr; |
||
204 | UINT8 Run = 0; |
||
205 | |||
206 | AcpiGbl_MethodExecuting = FALSE; |
||
207 | AcpiGbl_StepToNextCall = FALSE; |
||
208 | |||
209 | while (*Ptr) |
||
210 | { |
||
211 | if (*Ptr == ',') |
||
212 | { |
||
213 | /* Convert commas to spaces */ |
||
214 | *Ptr = ' '; |
||
215 | } |
||
216 | else if (*Ptr == ';') |
||
217 | { |
||
218 | *Ptr = '\0'; |
||
219 | Run = 1; |
||
220 | } |
||
221 | |||
222 | Ptr++; |
||
223 | |||
224 | if (Run || (*Ptr == '\0')) |
||
225 | { |
||
226 | (void) AcpiDbCommandDispatch (Cmd, NULL, NULL); |
||
227 | Run = 0; |
||
228 | Cmd = Ptr; |
||
229 | } |
||
230 | } |
||
231 | |||
232 | Status = AcpiTerminate (); |
||
233 | return (Status); |
||
234 | } |
||
235 | |||
236 | |||
237 | /******************************************************************************* |
||
238 | * |
||
239 | * FUNCTION: FlStrdup |
||
240 | * |
||
241 | * DESCRIPTION: Local strdup function |
||
242 | * |
||
243 | ******************************************************************************/ |
||
244 | |||
245 | static char * |
||
246 | FlStrdup ( |
||
247 | char *String) |
||
248 | { |
||
249 | char *NewString; |
||
250 | |||
251 | |||
252 | NewString = AcpiOsAllocate (strlen (String) + 1); |
||
253 | if (!NewString) |
||
254 | { |
||
255 | return (NULL); |
||
256 | } |
||
257 | |||
258 | strcpy (NewString, String); |
||
259 | return (NewString); |
||
260 | } |
||
261 | |||
262 | |||
263 | /******************************************************************************* |
||
264 | * |
||
265 | * FUNCTION: FlSplitInputPathname |
||
266 | * |
||
267 | * PARAMETERS: InputFilename - The user-specified ASL source file to be |
||
268 | * compiled |
||
269 | * OutDirectoryPath - Where the directory path prefix is |
||
270 | * returned |
||
271 | * OutFilename - Where the filename part is returned |
||
272 | * |
||
273 | * RETURN: Status |
||
274 | * |
||
275 | * DESCRIPTION: Split the input path into a directory and filename part |
||
276 | * 1) Directory part used to open include files |
||
277 | * 2) Filename part used to generate output filenames |
||
278 | * |
||
279 | ******************************************************************************/ |
||
280 | |||
281 | ACPI_STATUS |
||
282 | FlSplitInputPathname ( |
||
283 | char *InputPath, |
||
284 | char **OutDirectoryPath, |
||
285 | char **OutFilename) |
||
286 | { |
||
287 | char *Substring; |
||
288 | char *DirectoryPath; |
||
289 | char *Filename; |
||
290 | |||
291 | |||
292 | *OutDirectoryPath = NULL; |
||
293 | *OutFilename = NULL; |
||
294 | |||
295 | if (!InputPath) |
||
296 | { |
||
297 | return (AE_OK); |
||
298 | } |
||
299 | |||
300 | /* Get the path to the input filename's directory */ |
||
301 | |||
302 | DirectoryPath = FlStrdup (InputPath); |
||
303 | if (!DirectoryPath) |
||
304 | { |
||
305 | return (AE_NO_MEMORY); |
||
306 | } |
||
307 | |||
308 | Substring = strrchr (DirectoryPath, '\\'); |
||
309 | if (!Substring) |
||
310 | { |
||
311 | Substring = strrchr (DirectoryPath, '/'); |
||
312 | if (!Substring) |
||
313 | { |
||
314 | Substring = strrchr (DirectoryPath, ':'); |
||
315 | } |
||
316 | } |
||
317 | |||
318 | if (!Substring) |
||
319 | { |
||
320 | DirectoryPath[0] = 0; |
||
321 | Filename = FlStrdup (InputPath); |
||
322 | } |
||
323 | else |
||
324 | { |
||
325 | Filename = FlStrdup (Substring + 1); |
||
326 | *(Substring+1) = 0; |
||
327 | } |
||
328 | |||
329 | if (!Filename) |
||
330 | { |
||
331 | return (AE_NO_MEMORY); |
||
332 | } |
||
333 | |||
334 | *OutDirectoryPath = DirectoryPath; |
||
335 | *OutFilename = Filename; |
||
336 | |||
337 | return (AE_OK); |
||
338 | } |
||
339 | |||
340 | |||
341 | /****************************************************************************** |
||
342 | * |
||
343 | * FUNCTION: AsDoWildcard |
||
344 | * |
||
345 | * PARAMETERS: DirectoryPathname - Path to parent directory |
||
346 | * FileSpecifier - the wildcard specification (*.c, etc.) |
||
347 | * |
||
348 | * RETURN: Pointer to a list of filenames |
||
349 | * |
||
350 | * DESCRIPTION: Process files via wildcards. This function is for the Windows |
||
351 | * case only. |
||
352 | * |
||
353 | ******************************************************************************/ |
||
354 | |||
355 | static char ** |
||
356 | AsDoWildcard ( |
||
357 | char *DirectoryPathname, |
||
358 | char *FileSpecifier) |
||
359 | { |
||
360 | #ifdef WIN32 |
||
361 | void *DirInfo; |
||
362 | char *Filename; |
||
363 | |||
364 | |||
365 | FileCount = 0; |
||
366 | |||
367 | /* Open parent directory */ |
||
368 | |||
369 | DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); |
||
370 | if (!DirInfo) |
||
371 | { |
||
372 | /* Either the directory or file does not exist */ |
||
373 | |||
374 | printf ("File or directory %s%s does not exist\n", DirectoryPathname, FileSpecifier); |
||
375 | return (NULL); |
||
376 | } |
||
377 | |||
378 | /* Process each file that matches the wildcard specification */ |
||
379 | |||
380 | while ((Filename = AcpiOsGetNextFilename (DirInfo))) |
||
381 | { |
||
382 | /* Add the filename to the file list */ |
||
383 | |||
384 | FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); |
||
385 | strcpy (FileList[FileCount], Filename); |
||
386 | FileCount++; |
||
387 | |||
388 | if (FileCount >= ASL_MAX_FILES) |
||
389 | { |
||
390 | printf ("Max files reached\n"); |
||
391 | FileList[0] = NULL; |
||
392 | return (FileList); |
||
393 | } |
||
394 | } |
||
395 | |||
396 | /* Cleanup */ |
||
397 | |||
398 | AcpiOsCloseDirectory (DirInfo); |
||
399 | FileList[FileCount] = NULL; |
||
400 | return (FileList); |
||
401 | |||
402 | #else |
||
403 | if (!FileSpecifier) |
||
404 | { |
||
405 | return (NULL); |
||
406 | } |
||
407 | |||
408 | /* |
||
409 | * Linux/Unix cases - Wildcards are expanded by the shell automatically. |
||
410 | * Just return the filename in a null terminated list |
||
411 | */ |
||
412 | FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); |
||
413 | strcpy (FileList[0], FileSpecifier); |
||
414 | FileList[1] = NULL; |
||
415 | |||
416 | return (FileList); |
||
417 | #endif |
||
418 | } |
||
419 | |||
420 | |||
421 | /****************************************************************************** |
||
422 | * |
||
423 | * FUNCTION: main |
||
424 | * |
||
425 | * PARAMETERS: argc, argv |
||
426 | * |
||
427 | * RETURN: Status |
||
428 | * |
||
429 | * DESCRIPTION: Main routine for AcpiDump utility |
||
430 | * |
||
431 | *****************************************************************************/ |
||
432 | |||
433 | int ACPI_SYSTEM_XFACE |
||
434 | main ( |
||
435 | int argc, |
||
436 | char **argv) |
||
437 | { |
||
438 | int j; |
||
439 | ACPI_STATUS Status; |
||
440 | UINT32 InitFlags; |
||
441 | ACPI_TABLE_HEADER *Table = NULL; |
||
442 | UINT32 TableCount; |
||
443 | AE_TABLE_DESC *TableDesc; |
||
444 | char **FileList; |
||
445 | char *Filename; |
||
446 | char *Directory; |
||
447 | char *FullPathname; |
||
448 | |||
449 | |||
450 | #ifdef _DEBUG |
||
451 | _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | |
||
452 | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); |
||
453 | #endif |
||
454 | |||
455 | printf ("\nIntel ACPI Component Architecture\nAML Execution/Debug Utility"); |
||
456 | printf (" version %8.8X", ((UINT32) ACPI_CA_VERSION)); |
||
457 | printf (" [%s]\n\n", __DATE__); |
||
458 | |||
459 | if (argc < 2) |
||
460 | { |
||
461 | usage (); |
||
462 | return 0; |
||
463 | } |
||
464 | |||
465 | signal (SIGINT, AeCtrlCHandler); |
||
466 | |||
467 | /* Init globals */ |
||
468 | |||
469 | AcpiDbgLevel = ACPI_NORMAL_DEFAULT; |
||
470 | AcpiDbgLayer = 0xFFFFFFFF; |
||
471 | |||
472 | /* Init ACPI and start debugger thread */ |
||
473 | |||
474 | AcpiInitializeSubsystem (); |
||
475 | |||
476 | /* Get the command line options */ |
||
477 | |||
478 | while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch(j) |
||
479 | { |
||
480 | case 'b': |
||
481 | if (strlen (AcpiGbl_Optarg) > 127) |
||
482 | { |
||
483 | printf ("**** The length of command line (%u) exceeded maximum (127)\n", |
||
484 | (UINT32) strlen (AcpiGbl_Optarg)); |
||
485 | return -1; |
||
486 | } |
||
487 | AcpiGbl_BatchMode = 1; |
||
488 | strcpy (BatchBuffer, AcpiGbl_Optarg); |
||
489 | break; |
||
490 | |||
491 | case 'd': |
||
492 | switch (AcpiGbl_Optarg[0]) |
||
493 | { |
||
494 | case 'a': |
||
495 | AcpiGbl_IgnoreErrors = TRUE; |
||
496 | break; |
||
497 | |||
498 | case 'i': |
||
499 | AcpiGbl_DbOpt_ini_methods = FALSE; |
||
500 | break; |
||
501 | |||
502 | case 'o': |
||
503 | AcpiGbl_DbOpt_NoRegionSupport = TRUE; |
||
504 | break; |
||
505 | |||
506 | case 't': |
||
507 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
||
508 | AcpiGbl_DisableMemTracking = TRUE; |
||
509 | #endif |
||
510 | break; |
||
511 | |||
512 | default: |
||
513 | printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); |
||
514 | return (-1); |
||
515 | } |
||
516 | break; |
||
517 | |||
518 | case 'e': |
||
519 | switch (AcpiGbl_Optarg[0]) |
||
520 | { |
||
521 | case 'f': |
||
522 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
||
523 | AcpiGbl_DisplayFinalMemStats = TRUE; |
||
524 | #endif |
||
525 | break; |
||
526 | |||
527 | case 'm': |
||
528 | AcpiGbl_AllMethodsSerialized = TRUE; |
||
529 | printf ("Enabling AML Interpreter serialized mode\n"); |
||
530 | break; |
||
531 | |||
532 | case 's': |
||
533 | AcpiGbl_EnableInterpreterSlack = TRUE; |
||
534 | printf ("Enabling AML Interpreter slack mode\n"); |
||
535 | break; |
||
536 | |||
537 | case 't': |
||
538 | AcpiGbl_DebugTimeout = TRUE; |
||
539 | break; |
||
540 | |||
541 | default: |
||
542 | printf ("Unknown option: -e%s\n", AcpiGbl_Optarg); |
||
543 | return (-1); |
||
544 | } |
||
545 | break; |
||
546 | |||
547 | case 'f': |
||
548 | AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); |
||
549 | break; |
||
550 | |||
551 | case 'g': |
||
552 | AcpiGbl_DbOpt_tables = TRUE; |
||
553 | AcpiGbl_DbFilename = NULL; |
||
554 | break; |
||
555 | |||
556 | case 'm': |
||
557 | AcpiGbl_BatchMode = 2; |
||
558 | switch (AcpiGbl_Optarg[0]) |
||
559 | { |
||
560 | case '^': |
||
561 | strcpy (BatchBuffer, "MAIN"); |
||
562 | break; |
||
563 | |||
564 | default: |
||
565 | strcpy (BatchBuffer, AcpiGbl_Optarg); |
||
566 | break; |
||
567 | } |
||
568 | break; |
||
569 | |||
570 | case 'o': |
||
571 | AcpiGbl_DbOpt_disasm = TRUE; |
||
572 | AcpiGbl_DbOpt_stats = TRUE; |
||
573 | break; |
||
574 | |||
575 | case 'v': |
||
576 | AcpiDbgLevel |= ACPI_LV_INIT_NAMES; |
||
577 | break; |
||
578 | |||
579 | case 'x': |
||
580 | AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); |
||
581 | AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel; |
||
582 | printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); |
||
583 | break; |
||
584 | |||
585 | case '?': |
||
586 | case 'h': |
||
587 | default: |
||
588 | usage(); |
||
589 | return -1; |
||
590 | } |
||
591 | |||
592 | |||
593 | InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); |
||
594 | if (!AcpiGbl_DbOpt_ini_methods) |
||
595 | { |
||
596 | InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); |
||
597 | } |
||
598 | |||
599 | /* The remaining arguments are filenames for ACPI tables */ |
||
600 | |||
601 | if (argv[AcpiGbl_Optind]) |
||
602 | { |
||
603 | AcpiGbl_DbOpt_tables = TRUE; |
||
604 | TableCount = 0; |
||
605 | |||
606 | /* Get each of the ACPI table files on the command line */ |
||
607 | |||
608 | while (argv[AcpiGbl_Optind]) |
||
609 | { |
||
610 | /* Split incoming path into a directory/filename combo */ |
||
611 | |||
612 | Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); |
||
613 | if (ACPI_FAILURE (Status)) |
||
614 | { |
||
615 | return (Status); |
||
616 | } |
||
617 | |||
618 | /* Expand wildcards (Windows only) */ |
||
619 | |||
620 | FileList = AsDoWildcard (Directory, Filename); |
||
621 | if (!FileList) |
||
622 | { |
||
623 | return -1; |
||
624 | } |
||
625 | |||
626 | while (*FileList) |
||
627 | { |
||
628 | FullPathname = AcpiOsAllocate ( |
||
629 | strlen (Directory) + strlen (*FileList) + 1); |
||
630 | |||
631 | /* Construct a full path to the file */ |
||
632 | |||
633 | strcpy (FullPathname, Directory); |
||
634 | strcat (FullPathname, *FileList); |
||
635 | |||
636 | /* Get one table */ |
||
637 | |||
638 | Status = AcpiDbReadTableFromFile (FullPathname, &Table); |
||
639 | if (ACPI_FAILURE (Status)) |
||
640 | { |
||
641 | printf ("**** Could not get input table %s, %s\n", FullPathname, |
||
642 | AcpiFormatException (Status)); |
||
643 | goto enterloop; |
||
644 | } |
||
645 | |||
646 | AcpiOsFree (FullPathname); |
||
647 | AcpiOsFree (*FileList); |
||
648 | *FileList = NULL; |
||
649 | FileList++; |
||
650 | |||
651 | /* |
||
652 | * Ignore an FACS or RSDT, we can't use them. |
||
653 | */ |
||
654 | if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS) || |
||
655 | ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDT)) |
||
656 | { |
||
657 | AcpiOsFree (Table); |
||
658 | continue; |
||
659 | } |
||
660 | |||
661 | /* Allocate and link a table descriptor */ |
||
662 | |||
663 | TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); |
||
664 | TableDesc->Table = Table; |
||
665 | TableDesc->Next = AeTableListHead; |
||
666 | AeTableListHead = TableDesc; |
||
667 | |||
668 | TableCount++; |
||
669 | } |
||
670 | |||
671 | AcpiGbl_Optind++; |
||
672 | } |
||
673 | |||
674 | /* Build a local RSDT with all tables and let ACPICA process the RSDT */ |
||
675 | |||
676 | Status = AeBuildLocalTables (TableCount, AeTableListHead); |
||
677 | if (ACPI_FAILURE (Status)) |
||
678 | { |
||
679 | return -1; |
||
680 | } |
||
681 | |||
682 | Status = AeInstallTables (); |
||
683 | if (ACPI_FAILURE (Status)) |
||
684 | { |
||
685 | printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); |
||
686 | goto enterloop; |
||
687 | } |
||
688 | |||
689 | Status = AeInstallHandlers (); |
||
690 | if (ACPI_FAILURE (Status)) |
||
691 | { |
||
692 | goto enterloop; |
||
693 | } |
||
694 | |||
695 | /* |
||
696 | * TBD: |
||
697 | * Need a way to call this after the "LOAD" command |
||
698 | */ |
||
699 | Status = AcpiEnableSubsystem (InitFlags); |
||
700 | if (ACPI_FAILURE (Status)) |
||
701 | { |
||
702 | printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); |
||
703 | goto enterloop; |
||
704 | } |
||
705 | |||
706 | Status = AcpiInitializeObjects (InitFlags); |
||
707 | if (ACPI_FAILURE (Status)) |
||
708 | { |
||
709 | printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); |
||
710 | goto enterloop; |
||
711 | } |
||
712 | |||
713 | AeMiscellaneousTests (); |
||
714 | } |
||
715 | |||
716 | enterloop: |
||
717 | |||
718 | if (AcpiGbl_BatchMode == 1) |
||
719 | { |
||
720 | AcpiDbRunBatchMode (); |
||
721 | } |
||
722 | else if (AcpiGbl_BatchMode == 2) |
||
723 | { |
||
724 | AcpiDbExecute (BatchBuffer, NULL, EX_NO_SINGLE_STEP); |
||
725 | } |
||
726 | else |
||
727 | { |
||
728 | /* Enter the debugger command loop */ |
||
729 | |||
730 | AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); |
||
731 | } |
||
732 | |||
733 | return 0; |
||
734 | }> |
||
735 |