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