1 /******************************************************************************
2 *
3 * Module Name: adisasm - Application-level disassembler routines
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 "aslcompiler.h"
153 #include "amlcode.h"
154 #include "acdisasm.h"
155 #include "acdispat.h"
156 #include "acnamesp.h"
157 #include "acparser.h"
158 #include "acapps.h"
159 #include "acconvert.h"
160
161
162 #define _COMPONENT ACPI_TOOLS
163 ACPI_MODULE_NAME ("adisasm")
164
165 /* Local prototypes */
166
167 static ACPI_STATUS
168 AdDoExternalFileList (
169 char *Filename);
170
171 static ACPI_STATUS
172 AdDisassembleOneTable (
173 ACPI_TABLE_HEADER *Table,
174 FILE *File,
175 char *Filename,
176 char *DisasmFilename);
177
178 static ACPI_STATUS
179 AdReparseOneTable (
180 ACPI_TABLE_HEADER *Table,
181 FILE *File,
182 ACPI_OWNER_ID OwnerId);
183
184
185 ACPI_TABLE_DESC LocalTables[1];
186 ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot;
187
188
189 /* Stubs for everything except ASL compiler */
190
191 #ifndef ACPI_ASL_COMPILER
192 BOOLEAN
AcpiDsIsResultUsed(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)193 AcpiDsIsResultUsed (
194 ACPI_PARSE_OBJECT *Op,
195 ACPI_WALK_STATE *WalkState)
196 {
197 return (TRUE);
198 }
199
200 ACPI_STATUS
AcpiDsMethodError(ACPI_STATUS Status,ACPI_WALK_STATE * WalkState)201 AcpiDsMethodError (
202 ACPI_STATUS Status,
203 ACPI_WALK_STATE *WalkState)
204 {
205 return (Status);
206 }
207 #endif
208
209
210 /*******************************************************************************
211 *
212 * FUNCTION: AdInitialize
213 *
214 * PARAMETERS: None
215 *
216 * RETURN: Status
217 *
218 * DESCRIPTION: ACPICA and local initialization
219 *
220 ******************************************************************************/
221
222 ACPI_STATUS
AdInitialize(void)223 AdInitialize (
224 void)
225 {
226 ACPI_STATUS Status;
227
228
229 /* ACPICA subsystem initialization */
230
231 Status = AcpiOsInitialize ();
232 if (ACPI_FAILURE (Status))
233 {
234 fprintf (stderr, "Could not initialize ACPICA subsystem: %s\n",
235 AcpiFormatException (Status));
236
237 return (Status);
238 }
239
240 Status = AcpiUtInitGlobals ();
241 if (ACPI_FAILURE (Status))
242 {
243 fprintf (stderr, "Could not initialize ACPICA globals: %s\n",
244 AcpiFormatException (Status));
245
246 return (Status);
247 }
248
249 Status = AcpiUtMutexInitialize ();
250 if (ACPI_FAILURE (Status))
251 {
252 fprintf (stderr, "Could not initialize ACPICA mutex objects: %s\n",
253 AcpiFormatException (Status));
254
255 return (Status);
256 }
257
258 Status = AcpiNsRootInitialize ();
259 if (ACPI_FAILURE (Status))
260 {
261 fprintf (stderr, "Could not initialize ACPICA namespace: %s\n",
262 AcpiFormatException (Status));
263
264 return (Status);
265 }
266
267 /* Setup the Table Manager (cheat - there is no RSDT) */
268
269 AcpiGbl_RootTableList.MaxTableCount = 1;
270 AcpiGbl_RootTableList.CurrentTableCount = 0;
271 AcpiGbl_RootTableList.Tables = LocalTables;
272
273 return (AE_OK);
274 }
275
276
277 /******************************************************************************
278 *
279 * FUNCTION: AdAmlDisassemble
280 *
281 * PARAMETERS: Filename - AML input filename
282 * OutToFile - TRUE if output should go to a file
283 * Prefix - Path prefix for output
284 * OutFilename - where the filename is returned
285 *
286 * RETURN: Status
287 *
288 * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table.
289 *
290 *****************************************************************************/
291
292 ACPI_STATUS
AdAmlDisassemble(BOOLEAN OutToFile,char * Filename,char * Prefix,char ** OutFilename)293 AdAmlDisassemble (
294 BOOLEAN OutToFile,
295 char *Filename,
296 char *Prefix,
297 char **OutFilename)
298 {
299 ACPI_STATUS Status;
300 char *DisasmFilename = NULL;
301 FILE *File = NULL;
302 ACPI_TABLE_HEADER *Table = NULL;
303 ACPI_NEW_TABLE_DESC *ListHead = NULL;
304
305
306 /*
307 * Input: AML code from either a file or via GetTables (memory or
308 * registry)
309 */
310 if (Filename)
311 {
312 /* Get the list of all AML tables in the file */
313
314 Status = AcGetAllTablesFromFile (Filename,
315 ACPI_GET_ALL_TABLES, &ListHead);
316 if (ACPI_FAILURE (Status))
317 {
318 AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
319 Filename, AcpiFormatException (Status));
320 return (Status);
321 }
322
323 /* Process any user-specified files for external objects */
324
325 Status = AdDoExternalFileList (Filename);
326 if (ACPI_FAILURE (Status))
327 {
328 return (Status);
329 }
330 }
331 else
332 {
333 Status = AdGetLocalTables ();
334 if (ACPI_FAILURE (Status))
335 {
336 AcpiOsPrintf ("Could not get ACPI tables, %s\n",
337 AcpiFormatException (Status));
338 return (Status);
339 }
340
341 if (!AcpiGbl_DmOpt_Disasm)
342 {
343 return (AE_OK);
344 }
345
346 /* Obtained the local tables, just disassemble the DSDT */
347
348 Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table);
349 if (ACPI_FAILURE (Status))
350 {
351 AcpiOsPrintf ("Could not get DSDT, %s\n",
352 AcpiFormatException (Status));
353 return (Status);
354 }
355
356 AcpiOsPrintf ("\nDisassembly of DSDT\n");
357 Prefix = AdGenerateFilename ("dsdt", Table->OemTableId);
358 }
359
360 /*
361 * Output: ASL code. Redirect to a file if requested
362 */
363 if (OutToFile)
364 {
365 /* Create/Open a disassembly output file */
366
367 DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY);
368 if (!DisasmFilename)
369 {
370 fprintf (stderr, "Could not generate output filename\n");
371 Status = AE_ERROR;
372 goto Cleanup;
373 }
374
375 File = fopen (DisasmFilename, "w+");
376 if (!File)
377 {
378 fprintf (stderr, "Could not open output file %s\n",
379 DisasmFilename);
380 Status = AE_ERROR;
381 goto Cleanup;
382 }
383 }
384
385 *OutFilename = DisasmFilename;
386
387 /* Disassemble all AML tables within the file */
388
389 while (ListHead)
390 {
391 Status = AdDisassembleOneTable (ListHead->Table,
392 File, Filename, DisasmFilename);
393 if (ACPI_FAILURE (Status))
394 {
395 break;
396 }
397
398 ListHead = ListHead->Next;
399 }
400
401 Cleanup:
402
403 if (Table &&
404 !AcpiGbl_ForceAmlDisassembly &&
405 !AcpiUtIsAmlTable (Table))
406 {
407 ACPI_FREE (Table);
408 }
409
410 AcDeleteTableList (ListHead);
411
412 if (File)
413 {
414 fclose (File);
415 AcpiOsRedirectOutput (stdout);
416 }
417
418 AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
419 AcpiGbl_ParseOpRoot = NULL;
420 return (Status);
421 }
422
423
424 /******************************************************************************
425 *
426 * FUNCTION: AdDisassembleOneTable
427 *
428 * PARAMETERS: Table - Raw AML table
429 * File - Pointer for the input file
430 * Filename - AML input filename
431 * DisasmFilename - Output filename
432 *
433 * RETURN: Status
434 *
435 * DESCRIPTION: Disassemble a single ACPI table. AML or data table.
436 *
437 *****************************************************************************/
438
439 static ACPI_STATUS
AdDisassembleOneTable(ACPI_TABLE_HEADER * Table,FILE * File,char * Filename,char * DisasmFilename)440 AdDisassembleOneTable (
441 ACPI_TABLE_HEADER *Table,
442 FILE *File,
443 char *Filename,
444 char *DisasmFilename)
445 {
446 ACPI_STATUS Status;
447 ACPI_OWNER_ID OwnerId;
448
449
450 #ifdef ACPI_ASL_COMPILER
451
452 /*
453 * For ASL-/ASL+ converter: replace the temporary "XXXX"
454 * table signature with the original. This "XXXX" makes
455 * it harder for the AML interpreter to run the badaml
456 * (.xxx) file produced from the converter in case if
457 * it fails to get deleted.
458 */
459 if (AcpiGbl_CaptureComments)
460 {
461 strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAMESEG_SIZE);
462 }
463 #endif
464
465 /* ForceAmlDisassembly means to assume the table contains valid AML */
466
467 if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
468 {
469 if (File)
470 {
471 AcpiOsRedirectOutput (File);
472 }
473
474 AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
475
476 /* This is a "Data Table" (non-AML table) */
477
478 AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
479 AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
480 AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] "
481 "FieldName : FieldValue (in hex)\n */\n\n");
482
483 AcpiDmDumpDataTable (Table);
484 fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
485 AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
486
487 if (File)
488 {
489 fprintf (stderr, "Formatted output: %s - %u bytes\n",
490 DisasmFilename, CmGetFileSize (File));
491 }
492
493 return (AE_OK);
494 }
495
496 /* Initialize the converter output file */
497
498 ASL_CV_INIT_FILETREE(Table, File);
499
500 /*
501 * This is an AML table (DSDT or SSDT).
502 * Always parse the tables, only option is what to display
503 */
504 Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
505 if (ACPI_FAILURE (Status))
506 {
507 AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
508 AcpiFormatException (Status));
509 return (Status);
510 }
511
512 /* Redirect output for code generation and debugging output */
513
514 if (File)
515 {
516 AcpiOsRedirectOutput (File);
517 }
518
519 /* Debug output, namespace and parse tree */
520
521 if (AslCompilerdebug && File)
522 {
523 AcpiOsPrintf ("/**** Before second load\n");
524
525 NsSetupNamespaceListing (File);
526 NsDisplayNamespace ();
527
528 AcpiOsPrintf ("*****/\n");
529 }
530
531 /* Load namespace from names created within control methods */
532
533 AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
534 AcpiGbl_RootNode, OwnerId);
535
536 /*
537 * Cross reference the namespace here, in order to
538 * generate External() statements
539 */
540 AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
541 AcpiGbl_RootNode, OwnerId);
542
543 if (AslCompilerdebug)
544 {
545 AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
546 }
547
548 /* Find possible calls to external control methods */
549
550 AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
551
552 /*
553 * If we found any external control methods, we must reparse
554 * the entire tree with the new information (namely, the
555 * number of arguments per method)
556 */
557 if (AcpiDmGetUnresolvedExternalMethodCount ())
558 {
559 Status = AdReparseOneTable (Table, File, OwnerId);
560 if (ACPI_FAILURE (Status))
561 {
562 return (Status);
563 }
564 }
565
566 /*
567 * Now that the namespace is finalized, we can perform namespace
568 * transforms.
569 *
570 * 1) Convert fixed-offset references to resource descriptors
571 * to symbolic references (Note: modifies namespace)
572 */
573 AcpiDmConvertParseObjects (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
574
575 /* Optional displays */
576
577 if (AcpiGbl_DmOpt_Disasm)
578 {
579 /* This is the real disassembly */
580
581 AdDisplayTables (Filename, Table);
582
583 /* Dump hex table if requested (-vt) */
584
585 AcpiDmDumpDataTable (Table);
586
587 fprintf (stderr, "Disassembly completed\n");
588 if (File)
589 {
590 fprintf (stderr, "ASL Output: %s - %u bytes\n",
591 DisasmFilename, CmGetFileSize (File));
592 }
593
594 if (AslGbl_MapfileFlag)
595 {
596 fprintf (stderr, "%14s %s - %u bytes\n",
597 AslGbl_FileDescs[ASL_FILE_MAP_OUTPUT].ShortDescription,
598 AslGbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
599 FlGetFileSize (ASL_FILE_MAP_OUTPUT));
600 }
601 }
602
603 return (AE_OK);
604 }
605
606
607 /******************************************************************************
608 *
609 * FUNCTION: AdReparseOneTable
610 *
611 * PARAMETERS: Table - Raw AML table
612 * File - Pointer for the input file
613 * OwnerId - ID for this table
614 *
615 * RETURN: Status
616 *
617 * DESCRIPTION: Reparse a table that has already been loaded. Used to
618 * integrate information about external control methods.
619 * These methods may have been previously parsed incorrectly.
620 *
621 *****************************************************************************/
622
623 static ACPI_STATUS
AdReparseOneTable(ACPI_TABLE_HEADER * Table,FILE * File,ACPI_OWNER_ID OwnerId)624 AdReparseOneTable (
625 ACPI_TABLE_HEADER *Table,
626 FILE *File,
627 ACPI_OWNER_ID OwnerId)
628 {
629 ACPI_STATUS Status;
630 ACPI_COMMENT_ADDR_NODE *AddrListHead;
631
632
633 fprintf (stderr,
634 "\nFound %u external control methods, "
635 "reparsing with new information\n",
636 AcpiDmGetUnresolvedExternalMethodCount ());
637
638 /* Reparse, rebuild namespace */
639
640 AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
641 AcpiGbl_ParseOpRoot = NULL;
642 AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
643
644 AcpiGbl_RootNode = NULL;
645 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
646 AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
647 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
648 AcpiGbl_RootNodeStruct.Parent = NULL;
649 AcpiGbl_RootNodeStruct.Child = NULL;
650 AcpiGbl_RootNodeStruct.Peer = NULL;
651 AcpiGbl_RootNodeStruct.Object = NULL;
652 AcpiGbl_RootNodeStruct.Flags = 0;
653
654 Status = AcpiNsRootInitialize ();
655 if (ACPI_FAILURE (Status))
656 {
657 return (Status);
658 }
659
660 /* New namespace, add the external definitions first */
661
662 AcpiDmAddExternalListToNamespace ();
663
664 /* For -ca option: clear the list of comment addresses. */
665
666 while (AcpiGbl_CommentAddrListHead)
667 {
668 AddrListHead= AcpiGbl_CommentAddrListHead;
669 AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next;
670 AcpiOsFree(AddrListHead);
671 }
672
673 /* Parse the table again. No need to reload it, however */
674
675 Status = AdParseTable (Table, NULL, FALSE, FALSE);
676 if (ACPI_FAILURE (Status))
677 {
678 AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
679 AcpiFormatException (Status));
680 return (Status);
681 }
682
683 /* Cross reference the namespace again */
684
685 AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
686 AcpiGbl_RootNode, OwnerId);
687
688 AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
689 AcpiGbl_RootNode, OwnerId);
690
691 /* Debug output - namespace and parse tree */
692
693 if (AslCompilerdebug)
694 {
695 AcpiOsPrintf ("/**** After second load and resource conversion\n");
696 if (File)
697 {
698 NsSetupNamespaceListing (File);
699 NsDisplayNamespace ();
700 }
701
702 AcpiOsPrintf ("*****/\n");
703 AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
704 }
705
706 return (AE_OK);
707 }
708
709
710 /******************************************************************************
711 *
712 * FUNCTION: AdDoExternalFileList
713 *
714 * PARAMETERS: Filename - Input file for the table
715 *
716 * RETURN: Status
717 *
718 * DESCRIPTION: Process all tables found in the -e external files list
719 *
720 *****************************************************************************/
721
722 static ACPI_STATUS
AdDoExternalFileList(char * Filename)723 AdDoExternalFileList (
724 char *Filename)
725 {
726 ACPI_EXTERNAL_FILE *ExternalFileList;
727 char *ExternalFilename;
728 ACPI_NEW_TABLE_DESC *ExternalListHead = NULL;
729 ACPI_STATUS Status;
730 ACPI_STATUS GlobalStatus = AE_OK;
731 ACPI_OWNER_ID OwnerId;
732
733
734 /*
735 * External filenames are specified on the command line like this:
736 * Example: iasl -e file1,file2,file3 -d xxx.aml
737 */
738 ExternalFileList = AcpiGbl_ExternalFileList;
739
740 /* Process each external file */
741
742 while (ExternalFileList)
743 {
744 ExternalFilename = ExternalFileList->Path;
745 if (!strcmp (ExternalFilename, Filename))
746 {
747 /* Next external file */
748
749 ExternalFileList = ExternalFileList->Next;
750 continue;
751 }
752
753 AcpiOsPrintf ("External object resolution file %16s\n",
754 ExternalFilename);
755
756 Status = AcGetAllTablesFromFile (
757 ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
758 if (ACPI_FAILURE (Status))
759 {
760 if (Status == AE_TYPE)
761 {
762 ExternalFileList = ExternalFileList->Next;
763 GlobalStatus = AE_TYPE;
764 continue;
765 }
766
767 AcDeleteTableList (ExternalListHead);
768 return (Status);
769 }
770
771 /* Load external tables for symbol resolution */
772
773 while (ExternalListHead)
774 {
775 Status = AdParseTable (
776 ExternalListHead->Table, &OwnerId, TRUE, TRUE);
777 if (ACPI_FAILURE (Status))
778 {
779 AcpiOsPrintf ("Could not parse external ACPI tables, %s\n",
780 AcpiFormatException (Status));
781 AcDeleteTableList (ExternalListHead);
782 return (Status);
783 }
784
785 /*
786 * Load namespace from names created within control methods
787 * Set owner id of nodes in external table
788 */
789 AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
790 AcpiGbl_RootNode, OwnerId);
791 AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
792 AcpiGbl_ParseOpRoot = NULL;
793
794 ExternalListHead = ExternalListHead->Next;
795 }
796
797 /* Next external file */
798
799 ExternalFileList = ExternalFileList->Next;
800 }
801
802 AcDeleteTableList (ExternalListHead);
803
804 if (ACPI_FAILURE (GlobalStatus))
805 {
806 return (GlobalStatus);
807 }
808
809 /* Clear external list generated by Scope in external tables */
810
811 if (AcpiGbl_ExternalFileList)
812 {
813 AcpiDmClearExternalList ();
814 }
815
816 /* Load any externals defined in the optional external ref file */
817
818 AcpiDmGetExternalsFromFile ();
819 return (AE_OK);
820 }
821