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