1bc36eafdSMike Gerdts /******************************************************************************
2bc36eafdSMike Gerdts *
3bc36eafdSMike Gerdts * Module Name: adisasm - Application-level disassembler routines
4bc36eafdSMike Gerdts *
5bc36eafdSMike Gerdts *****************************************************************************/
6bc36eafdSMike Gerdts
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi *
9*35786f68SRobert Mustacchi * 1. Copyright Notice
10*35786f68SRobert Mustacchi *
11*35786f68SRobert Mustacchi * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12bc36eafdSMike Gerdts * All rights reserved.
13bc36eafdSMike Gerdts *
14*35786f68SRobert Mustacchi * 2. License
15*35786f68SRobert Mustacchi *
16*35786f68SRobert Mustacchi * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi * property rights.
20*35786f68SRobert Mustacchi *
21*35786f68SRobert Mustacchi * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi *
28*35786f68SRobert Mustacchi * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi *
37*35786f68SRobert Mustacchi * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi * conditions are met:
39*35786f68SRobert Mustacchi *
40*35786f68SRobert Mustacchi * 3. Conditions
41*35786f68SRobert Mustacchi *
42*35786f68SRobert Mustacchi * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi *
54*35786f68SRobert Mustacchi * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi * make.
65*35786f68SRobert Mustacchi *
66*35786f68SRobert Mustacchi * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi * distribution.
71*35786f68SRobert Mustacchi *
72*35786f68SRobert Mustacchi * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi * Intel Code.
74*35786f68SRobert Mustacchi *
75*35786f68SRobert Mustacchi * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi *
80*35786f68SRobert Mustacchi * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi *
82*35786f68SRobert Mustacchi * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi *
90*35786f68SRobert Mustacchi * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi * LIMITED REMEDY.
98*35786f68SRobert Mustacchi *
99*35786f68SRobert Mustacchi * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi * such license, approval or letter.
113*35786f68SRobert Mustacchi *
114*35786f68SRobert Mustacchi *****************************************************************************
115*35786f68SRobert Mustacchi *
116*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi * following license:
118*35786f68SRobert Mustacchi *
119bc36eafdSMike Gerdts * Redistribution and use in source and binary forms, with or without
120bc36eafdSMike Gerdts * modification, are permitted provided that the following conditions
121bc36eafdSMike Gerdts * are met:
122bc36eafdSMike Gerdts * 1. Redistributions of source code must retain the above copyright
123bc36eafdSMike Gerdts * notice, this list of conditions, and the following disclaimer,
124bc36eafdSMike Gerdts * without modification.
125bc36eafdSMike Gerdts * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126bc36eafdSMike Gerdts * substantially similar to the "NO WARRANTY" disclaimer below
127bc36eafdSMike Gerdts * ("Disclaimer") and any redistribution must be conditioned upon
128bc36eafdSMike Gerdts * including a substantially similar Disclaimer requirement for further
129bc36eafdSMike Gerdts * binary redistribution.
130bc36eafdSMike Gerdts * 3. Neither the names of the above-listed copyright holders nor the names
131bc36eafdSMike Gerdts * of any contributors may be used to endorse or promote products derived
132bc36eafdSMike Gerdts * from this software without specific prior written permission.
133bc36eafdSMike Gerdts *
134bc36eafdSMike Gerdts * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135bc36eafdSMike Gerdts * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137bc36eafdSMike Gerdts * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi *
146*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi * Software Foundation.
149*35786f68SRobert Mustacchi *
150*35786f68SRobert Mustacchi *****************************************************************************/
151bc36eafdSMike Gerdts
152bc36eafdSMike Gerdts #include "aslcompiler.h"
153bc36eafdSMike Gerdts #include "amlcode.h"
154bc36eafdSMike Gerdts #include "acdisasm.h"
155bc36eafdSMike Gerdts #include "acdispat.h"
156bc36eafdSMike Gerdts #include "acnamesp.h"
157bc36eafdSMike Gerdts #include "acparser.h"
158bc36eafdSMike Gerdts #include "acapps.h"
159bc36eafdSMike Gerdts
160bc36eafdSMike Gerdts
161bc36eafdSMike Gerdts #define _COMPONENT ACPI_TOOLS
162bc36eafdSMike Gerdts ACPI_MODULE_NAME ("adisasm")
163bc36eafdSMike Gerdts
164bc36eafdSMike Gerdts /* Local prototypes */
165bc36eafdSMike Gerdts
166bc36eafdSMike Gerdts static ACPI_STATUS
167bc36eafdSMike Gerdts AdDoExternalFileList (
168bc36eafdSMike Gerdts char *Filename);
169bc36eafdSMike Gerdts
170bc36eafdSMike Gerdts static ACPI_STATUS
171bc36eafdSMike Gerdts AdDisassembleOneTable (
172bc36eafdSMike Gerdts ACPI_TABLE_HEADER *Table,
173bc36eafdSMike Gerdts FILE *File,
174bc36eafdSMike Gerdts char *Filename,
175bc36eafdSMike Gerdts char *DisasmFilename);
176bc36eafdSMike Gerdts
177bc36eafdSMike Gerdts static ACPI_STATUS
178bc36eafdSMike Gerdts AdReparseOneTable (
179bc36eafdSMike Gerdts ACPI_TABLE_HEADER *Table,
180bc36eafdSMike Gerdts FILE *File,
181bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId);
182bc36eafdSMike Gerdts
183bc36eafdSMike Gerdts
184bc36eafdSMike Gerdts ACPI_TABLE_DESC LocalTables[1];
185bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot;
186bc36eafdSMike Gerdts
187bc36eafdSMike Gerdts
188bc36eafdSMike Gerdts /* Stubs for everything except ASL compiler */
189bc36eafdSMike Gerdts
190bc36eafdSMike Gerdts #ifndef ACPI_ASL_COMPILER
191bc36eafdSMike Gerdts BOOLEAN
AcpiDsIsResultUsed(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)192bc36eafdSMike Gerdts AcpiDsIsResultUsed (
193bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
194bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState)
195bc36eafdSMike Gerdts {
196bc36eafdSMike Gerdts return (TRUE);
197bc36eafdSMike Gerdts }
198bc36eafdSMike Gerdts
199bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsMethodError(ACPI_STATUS Status,ACPI_WALK_STATE * WalkState)200bc36eafdSMike Gerdts AcpiDsMethodError (
201bc36eafdSMike Gerdts ACPI_STATUS Status,
202bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState)
203bc36eafdSMike Gerdts {
204bc36eafdSMike Gerdts return (Status);
205bc36eafdSMike Gerdts }
206bc36eafdSMike Gerdts #endif
207bc36eafdSMike Gerdts
208bc36eafdSMike Gerdts
209bc36eafdSMike Gerdts /*******************************************************************************
210bc36eafdSMike Gerdts *
211bc36eafdSMike Gerdts * FUNCTION: AdInitialize
212bc36eafdSMike Gerdts *
213bc36eafdSMike Gerdts * PARAMETERS: None
214bc36eafdSMike Gerdts *
215bc36eafdSMike Gerdts * RETURN: Status
216bc36eafdSMike Gerdts *
217bc36eafdSMike Gerdts * DESCRIPTION: ACPICA and local initialization
218bc36eafdSMike Gerdts *
219bc36eafdSMike Gerdts ******************************************************************************/
220bc36eafdSMike Gerdts
221bc36eafdSMike Gerdts ACPI_STATUS
AdInitialize(void)222bc36eafdSMike Gerdts AdInitialize (
223bc36eafdSMike Gerdts void)
224bc36eafdSMike Gerdts {
225bc36eafdSMike Gerdts ACPI_STATUS Status;
226bc36eafdSMike Gerdts
227bc36eafdSMike Gerdts
228bc36eafdSMike Gerdts /* ACPICA subsystem initialization */
229bc36eafdSMike Gerdts
230bc36eafdSMike Gerdts Status = AcpiOsInitialize ();
231bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
232bc36eafdSMike Gerdts {
233*35786f68SRobert Mustacchi fprintf (stderr, "Could not initialize ACPICA subsystem: %s\n",
234*35786f68SRobert Mustacchi AcpiFormatException (Status));
235*35786f68SRobert Mustacchi
236bc36eafdSMike Gerdts return (Status);
237bc36eafdSMike Gerdts }
238bc36eafdSMike Gerdts
239bc36eafdSMike Gerdts Status = AcpiUtInitGlobals ();
240bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
241bc36eafdSMike Gerdts {
242*35786f68SRobert Mustacchi fprintf (stderr, "Could not initialize ACPICA globals: %s\n",
243*35786f68SRobert Mustacchi AcpiFormatException (Status));
244*35786f68SRobert Mustacchi
245bc36eafdSMike Gerdts return (Status);
246bc36eafdSMike Gerdts }
247bc36eafdSMike Gerdts
248bc36eafdSMike Gerdts Status = AcpiUtMutexInitialize ();
249bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
250bc36eafdSMike Gerdts {
251*35786f68SRobert Mustacchi fprintf (stderr, "Could not initialize ACPICA mutex objects: %s\n",
252*35786f68SRobert Mustacchi AcpiFormatException (Status));
253*35786f68SRobert Mustacchi
254bc36eafdSMike Gerdts return (Status);
255bc36eafdSMike Gerdts }
256bc36eafdSMike Gerdts
257bc36eafdSMike Gerdts Status = AcpiNsRootInitialize ();
258bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
259bc36eafdSMike Gerdts {
260*35786f68SRobert Mustacchi fprintf (stderr, "Could not initialize ACPICA namespace: %s\n",
261*35786f68SRobert Mustacchi AcpiFormatException (Status));
262*35786f68SRobert Mustacchi
263bc36eafdSMike Gerdts return (Status);
264bc36eafdSMike Gerdts }
265bc36eafdSMike Gerdts
266bc36eafdSMike Gerdts /* Setup the Table Manager (cheat - there is no RSDT) */
267bc36eafdSMike Gerdts
268bc36eafdSMike Gerdts AcpiGbl_RootTableList.MaxTableCount = 1;
269bc36eafdSMike Gerdts AcpiGbl_RootTableList.CurrentTableCount = 0;
270bc36eafdSMike Gerdts AcpiGbl_RootTableList.Tables = LocalTables;
271bc36eafdSMike Gerdts
272*35786f68SRobert Mustacchi return (AE_OK);
273bc36eafdSMike Gerdts }
274bc36eafdSMike Gerdts
275bc36eafdSMike Gerdts
276bc36eafdSMike Gerdts /******************************************************************************
277bc36eafdSMike Gerdts *
278bc36eafdSMike Gerdts * FUNCTION: AdAmlDisassemble
279bc36eafdSMike Gerdts *
280bc36eafdSMike Gerdts * PARAMETERS: Filename - AML input filename
281bc36eafdSMike Gerdts * OutToFile - TRUE if output should go to a file
282bc36eafdSMike Gerdts * Prefix - Path prefix for output
283bc36eafdSMike Gerdts * OutFilename - where the filename is returned
284bc36eafdSMike Gerdts *
285bc36eafdSMike Gerdts * RETURN: Status
286bc36eafdSMike Gerdts *
287bc36eafdSMike Gerdts * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table.
288bc36eafdSMike Gerdts *
289bc36eafdSMike Gerdts *****************************************************************************/
290bc36eafdSMike Gerdts
291bc36eafdSMike Gerdts ACPI_STATUS
AdAmlDisassemble(BOOLEAN OutToFile,char * Filename,char * Prefix,char ** OutFilename)292bc36eafdSMike Gerdts AdAmlDisassemble (
293bc36eafdSMike Gerdts BOOLEAN OutToFile,
294bc36eafdSMike Gerdts char *Filename,
295bc36eafdSMike Gerdts char *Prefix,
296bc36eafdSMike Gerdts char **OutFilename)
297bc36eafdSMike Gerdts {
298bc36eafdSMike Gerdts ACPI_STATUS Status;
299bc36eafdSMike Gerdts char *DisasmFilename = NULL;
300bc36eafdSMike Gerdts FILE *File = NULL;
301bc36eafdSMike Gerdts ACPI_TABLE_HEADER *Table = NULL;
302bc36eafdSMike Gerdts ACPI_NEW_TABLE_DESC *ListHead = NULL;
303bc36eafdSMike Gerdts
304bc36eafdSMike Gerdts
305bc36eafdSMike Gerdts /*
306bc36eafdSMike Gerdts * Input: AML code from either a file or via GetTables (memory or
307bc36eafdSMike Gerdts * registry)
308bc36eafdSMike Gerdts */
309bc36eafdSMike Gerdts if (Filename)
310bc36eafdSMike Gerdts {
311bc36eafdSMike Gerdts /* Get the list of all AML tables in the file */
312bc36eafdSMike Gerdts
313bc36eafdSMike Gerdts Status = AcGetAllTablesFromFile (Filename,
314bc36eafdSMike Gerdts ACPI_GET_ALL_TABLES, &ListHead);
315bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
316bc36eafdSMike Gerdts {
317bc36eafdSMike Gerdts AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
318bc36eafdSMike Gerdts Filename, AcpiFormatException (Status));
319bc36eafdSMike Gerdts return (Status);
320bc36eafdSMike Gerdts }
321bc36eafdSMike Gerdts
322bc36eafdSMike Gerdts /* Process any user-specified files for external objects */
323bc36eafdSMike Gerdts
324bc36eafdSMike Gerdts Status = AdDoExternalFileList (Filename);
325bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
326bc36eafdSMike Gerdts {
327bc36eafdSMike Gerdts return (Status);
328bc36eafdSMike Gerdts }
329bc36eafdSMike Gerdts }
330bc36eafdSMike Gerdts else
331bc36eafdSMike Gerdts {
332bc36eafdSMike Gerdts Status = AdGetLocalTables ();
333bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
334bc36eafdSMike Gerdts {
335bc36eafdSMike Gerdts AcpiOsPrintf ("Could not get ACPI tables, %s\n",
336bc36eafdSMike Gerdts AcpiFormatException (Status));
337bc36eafdSMike Gerdts return (Status);
338bc36eafdSMike Gerdts }
339bc36eafdSMike Gerdts
340bc36eafdSMike Gerdts if (!AcpiGbl_DmOpt_Disasm)
341bc36eafdSMike Gerdts {
342bc36eafdSMike Gerdts return (AE_OK);
343bc36eafdSMike Gerdts }
344bc36eafdSMike Gerdts
345bc36eafdSMike Gerdts /* Obtained the local tables, just disassemble the DSDT */
346bc36eafdSMike Gerdts
347bc36eafdSMike Gerdts Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table);
348bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
349bc36eafdSMike Gerdts {
350bc36eafdSMike Gerdts AcpiOsPrintf ("Could not get DSDT, %s\n",
351bc36eafdSMike Gerdts AcpiFormatException (Status));
352bc36eafdSMike Gerdts return (Status);
353bc36eafdSMike Gerdts }
354bc36eafdSMike Gerdts
355bc36eafdSMike Gerdts AcpiOsPrintf ("\nDisassembly of DSDT\n");
356bc36eafdSMike Gerdts Prefix = AdGenerateFilename ("dsdt", Table->OemTableId);
357bc36eafdSMike Gerdts }
358bc36eafdSMike Gerdts
359bc36eafdSMike Gerdts /*
360bc36eafdSMike Gerdts * Output: ASL code. Redirect to a file if requested
361bc36eafdSMike Gerdts */
362bc36eafdSMike Gerdts if (OutToFile)
363bc36eafdSMike Gerdts {
364bc36eafdSMike Gerdts /* Create/Open a disassembly output file */
365bc36eafdSMike Gerdts
366bc36eafdSMike Gerdts DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY);
367bc36eafdSMike Gerdts if (!DisasmFilename)
368bc36eafdSMike Gerdts {
369bc36eafdSMike Gerdts fprintf (stderr, "Could not generate output filename\n");
370bc36eafdSMike Gerdts Status = AE_ERROR;
371bc36eafdSMike Gerdts goto Cleanup;
372bc36eafdSMike Gerdts }
373bc36eafdSMike Gerdts
374bc36eafdSMike Gerdts File = fopen (DisasmFilename, "w+");
375bc36eafdSMike Gerdts if (!File)
376bc36eafdSMike Gerdts {
377bc36eafdSMike Gerdts fprintf (stderr, "Could not open output file %s\n",
378bc36eafdSMike Gerdts DisasmFilename);
379bc36eafdSMike Gerdts Status = AE_ERROR;
380bc36eafdSMike Gerdts goto Cleanup;
381bc36eafdSMike Gerdts }
382bc36eafdSMike Gerdts
383bc36eafdSMike Gerdts AcpiOsRedirectOutput (File);
384bc36eafdSMike Gerdts }
385bc36eafdSMike Gerdts
386bc36eafdSMike Gerdts *OutFilename = DisasmFilename;
387bc36eafdSMike Gerdts
388bc36eafdSMike Gerdts /* Disassemble all AML tables within the file */
389bc36eafdSMike Gerdts
390bc36eafdSMike Gerdts while (ListHead)
391bc36eafdSMike Gerdts {
392bc36eafdSMike Gerdts Status = AdDisassembleOneTable (ListHead->Table,
393bc36eafdSMike Gerdts File, Filename, DisasmFilename);
394bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
395bc36eafdSMike Gerdts {
396bc36eafdSMike Gerdts break;
397bc36eafdSMike Gerdts }
398bc36eafdSMike Gerdts
399bc36eafdSMike Gerdts ListHead = ListHead->Next;
400bc36eafdSMike Gerdts }
401bc36eafdSMike Gerdts
402bc36eafdSMike Gerdts Cleanup:
403bc36eafdSMike Gerdts
404bc36eafdSMike Gerdts if (Table &&
405bc36eafdSMike Gerdts !AcpiGbl_ForceAmlDisassembly &&
406bc36eafdSMike Gerdts !AcpiUtIsAmlTable (Table))
407bc36eafdSMike Gerdts {
408bc36eafdSMike Gerdts ACPI_FREE (Table);
409bc36eafdSMike Gerdts }
410bc36eafdSMike Gerdts
411*35786f68SRobert Mustacchi AcDeleteTableList (ListHead);
412*35786f68SRobert Mustacchi
413bc36eafdSMike Gerdts if (File)
414bc36eafdSMike Gerdts {
415bc36eafdSMike Gerdts fclose (File);
416bc36eafdSMike Gerdts AcpiOsRedirectOutput (stdout);
417bc36eafdSMike Gerdts }
418bc36eafdSMike Gerdts
419bc36eafdSMike Gerdts AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
420bc36eafdSMike Gerdts AcpiGbl_ParseOpRoot = NULL;
421bc36eafdSMike Gerdts return (Status);
422bc36eafdSMike Gerdts }
423bc36eafdSMike Gerdts
424bc36eafdSMike Gerdts
425bc36eafdSMike Gerdts /******************************************************************************
426bc36eafdSMike Gerdts *
427bc36eafdSMike Gerdts * FUNCTION: AdDisassembleOneTable
428bc36eafdSMike Gerdts *
429bc36eafdSMike Gerdts * PARAMETERS: Table - Raw AML table
430bc36eafdSMike Gerdts * File - Pointer for the input file
431bc36eafdSMike Gerdts * Filename - AML input filename
432bc36eafdSMike Gerdts * DisasmFilename - Output filename
433bc36eafdSMike Gerdts *
434bc36eafdSMike Gerdts * RETURN: Status
435bc36eafdSMike Gerdts *
436bc36eafdSMike Gerdts * DESCRIPTION: Disassemble a single ACPI table. AML or data table.
437bc36eafdSMike Gerdts *
438bc36eafdSMike Gerdts *****************************************************************************/
439bc36eafdSMike Gerdts
440bc36eafdSMike Gerdts static ACPI_STATUS
AdDisassembleOneTable(ACPI_TABLE_HEADER * Table,FILE * File,char * Filename,char * DisasmFilename)441bc36eafdSMike Gerdts AdDisassembleOneTable (
442bc36eafdSMike Gerdts ACPI_TABLE_HEADER *Table,
443bc36eafdSMike Gerdts FILE *File,
444bc36eafdSMike Gerdts char *Filename,
445bc36eafdSMike Gerdts char *DisasmFilename)
446bc36eafdSMike Gerdts {
447bc36eafdSMike Gerdts ACPI_STATUS Status;
448bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId;
449bc36eafdSMike Gerdts
450bc36eafdSMike Gerdts
451*35786f68SRobert Mustacchi #ifdef ACPI_ASL_COMPILER
452*35786f68SRobert Mustacchi
453*35786f68SRobert Mustacchi /*
454*35786f68SRobert Mustacchi * For ASL-/ASL+ converter: replace the temporary "XXXX"
455*35786f68SRobert Mustacchi * table signature with the original. This "XXXX" makes
456*35786f68SRobert Mustacchi * it harder for the AML interpreter to run the badaml
457*35786f68SRobert Mustacchi * (.xxx) file produced from the converter in case if
458*35786f68SRobert Mustacchi * it fails to get deleted.
459*35786f68SRobert Mustacchi */
460*35786f68SRobert Mustacchi if (AcpiGbl_CaptureComments)
461*35786f68SRobert Mustacchi {
462*35786f68SRobert Mustacchi strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAME_SIZE);
463*35786f68SRobert Mustacchi }
464*35786f68SRobert Mustacchi #endif
465*35786f68SRobert Mustacchi
466bc36eafdSMike Gerdts /* ForceAmlDisassembly means to assume the table contains valid AML */
467bc36eafdSMike Gerdts
468bc36eafdSMike Gerdts if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
469bc36eafdSMike Gerdts {
470bc36eafdSMike Gerdts AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
471bc36eafdSMike Gerdts
472bc36eafdSMike Gerdts /* This is a "Data Table" (non-AML table) */
473bc36eafdSMike Gerdts
474bc36eafdSMike Gerdts AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
475bc36eafdSMike Gerdts Table->Signature);
476bc36eafdSMike Gerdts AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] "
477bc36eafdSMike Gerdts "FieldName : FieldValue\n */\n\n");
478bc36eafdSMike Gerdts
479bc36eafdSMike Gerdts AcpiDmDumpDataTable (Table);
480bc36eafdSMike Gerdts fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
481bc36eafdSMike Gerdts Table->Signature);
482bc36eafdSMike Gerdts
483bc36eafdSMike Gerdts if (File)
484bc36eafdSMike Gerdts {
485bc36eafdSMike Gerdts fprintf (stderr, "Formatted output: %s - %u bytes\n",
486bc36eafdSMike Gerdts DisasmFilename, CmGetFileSize (File));
487bc36eafdSMike Gerdts }
488bc36eafdSMike Gerdts
489bc36eafdSMike Gerdts return (AE_OK);
490bc36eafdSMike Gerdts }
491bc36eafdSMike Gerdts
492bc36eafdSMike Gerdts /*
493bc36eafdSMike Gerdts * This is an AML table (DSDT or SSDT).
494bc36eafdSMike Gerdts * Always parse the tables, only option is what to display
495bc36eafdSMike Gerdts */
496bc36eafdSMike Gerdts Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
497bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
498bc36eafdSMike Gerdts {
499bc36eafdSMike Gerdts AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
500bc36eafdSMike Gerdts AcpiFormatException (Status));
501bc36eafdSMike Gerdts return (Status);
502bc36eafdSMike Gerdts }
503bc36eafdSMike Gerdts
504bc36eafdSMike Gerdts /* Debug output, namespace and parse tree */
505bc36eafdSMike Gerdts
506bc36eafdSMike Gerdts if (AslCompilerdebug && File)
507bc36eafdSMike Gerdts {
508bc36eafdSMike Gerdts AcpiOsPrintf ("/**** Before second load\n");
509bc36eafdSMike Gerdts
510bc36eafdSMike Gerdts NsSetupNamespaceListing (File);
511bc36eafdSMike Gerdts NsDisplayNamespace ();
512bc36eafdSMike Gerdts
513bc36eafdSMike Gerdts AcpiOsPrintf ("*****/\n");
514bc36eafdSMike Gerdts }
515bc36eafdSMike Gerdts
516bc36eafdSMike Gerdts /* Load namespace from names created within control methods */
517bc36eafdSMike Gerdts
518bc36eafdSMike Gerdts AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
519bc36eafdSMike Gerdts AcpiGbl_RootNode, OwnerId);
520bc36eafdSMike Gerdts
521bc36eafdSMike Gerdts /*
522bc36eafdSMike Gerdts * Cross reference the namespace here, in order to
523bc36eafdSMike Gerdts * generate External() statements
524bc36eafdSMike Gerdts */
525bc36eafdSMike Gerdts AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
526bc36eafdSMike Gerdts AcpiGbl_RootNode, OwnerId);
527bc36eafdSMike Gerdts
528bc36eafdSMike Gerdts if (AslCompilerdebug)
529bc36eafdSMike Gerdts {
530bc36eafdSMike Gerdts AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
531bc36eafdSMike Gerdts }
532bc36eafdSMike Gerdts
533bc36eafdSMike Gerdts /* Find possible calls to external control methods */
534bc36eafdSMike Gerdts
535bc36eafdSMike Gerdts AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
536bc36eafdSMike Gerdts
537bc36eafdSMike Gerdts /*
538bc36eafdSMike Gerdts * If we found any external control methods, we must reparse
539bc36eafdSMike Gerdts * the entire tree with the new information (namely, the
540bc36eafdSMike Gerdts * number of arguments per method)
541bc36eafdSMike Gerdts */
542*35786f68SRobert Mustacchi if (AcpiDmGetUnresolvedExternalMethodCount ())
543bc36eafdSMike Gerdts {
544bc36eafdSMike Gerdts Status = AdReparseOneTable (Table, File, OwnerId);
545bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
546bc36eafdSMike Gerdts {
547bc36eafdSMike Gerdts return (Status);
548bc36eafdSMike Gerdts }
549bc36eafdSMike Gerdts }
550bc36eafdSMike Gerdts
551bc36eafdSMike Gerdts /*
552bc36eafdSMike Gerdts * Now that the namespace is finalized, we can perform namespace
553bc36eafdSMike Gerdts * transforms.
554bc36eafdSMike Gerdts *
555bc36eafdSMike Gerdts * 1) Convert fixed-offset references to resource descriptors
556bc36eafdSMike Gerdts * to symbolic references (Note: modifies namespace)
557bc36eafdSMike Gerdts */
558*35786f68SRobert Mustacchi AcpiDmConvertParseObjects (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
559bc36eafdSMike Gerdts
560bc36eafdSMike Gerdts /* Optional displays */
561bc36eafdSMike Gerdts
562bc36eafdSMike Gerdts if (AcpiGbl_DmOpt_Disasm)
563bc36eafdSMike Gerdts {
564bc36eafdSMike Gerdts /* This is the real disassembly */
565bc36eafdSMike Gerdts
566bc36eafdSMike Gerdts AdDisplayTables (Filename, Table);
567bc36eafdSMike Gerdts
568bc36eafdSMike Gerdts /* Dump hex table if requested (-vt) */
569bc36eafdSMike Gerdts
570bc36eafdSMike Gerdts AcpiDmDumpDataTable (Table);
571bc36eafdSMike Gerdts
572bc36eafdSMike Gerdts fprintf (stderr, "Disassembly completed\n");
573bc36eafdSMike Gerdts if (File)
574bc36eafdSMike Gerdts {
575bc36eafdSMike Gerdts fprintf (stderr, "ASL Output: %s - %u bytes\n",
576bc36eafdSMike Gerdts DisasmFilename, CmGetFileSize (File));
577bc36eafdSMike Gerdts }
578bc36eafdSMike Gerdts
579bc36eafdSMike Gerdts if (Gbl_MapfileFlag)
580bc36eafdSMike Gerdts {
581bc36eafdSMike Gerdts fprintf (stderr, "%14s %s - %u bytes\n",
582bc36eafdSMike Gerdts Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription,
583bc36eafdSMike Gerdts Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
584bc36eafdSMike Gerdts FlGetFileSize (ASL_FILE_MAP_OUTPUT));
585bc36eafdSMike Gerdts }
586bc36eafdSMike Gerdts }
587bc36eafdSMike Gerdts
588bc36eafdSMike Gerdts return (AE_OK);
589bc36eafdSMike Gerdts }
590bc36eafdSMike Gerdts
591bc36eafdSMike Gerdts
592bc36eafdSMike Gerdts /******************************************************************************
593bc36eafdSMike Gerdts *
594bc36eafdSMike Gerdts * FUNCTION: AdReparseOneTable
595bc36eafdSMike Gerdts *
596bc36eafdSMike Gerdts * PARAMETERS: Table - Raw AML table
597bc36eafdSMike Gerdts * File - Pointer for the input file
598bc36eafdSMike Gerdts * OwnerId - ID for this table
599bc36eafdSMike Gerdts *
600bc36eafdSMike Gerdts * RETURN: Status
601bc36eafdSMike Gerdts *
602bc36eafdSMike Gerdts * DESCRIPTION: Reparse a table that has already been loaded. Used to
603bc36eafdSMike Gerdts * integrate information about external control methods.
604bc36eafdSMike Gerdts * These methods may have been previously parsed incorrectly.
605bc36eafdSMike Gerdts *
606bc36eafdSMike Gerdts *****************************************************************************/
607bc36eafdSMike Gerdts
608bc36eafdSMike Gerdts static ACPI_STATUS
AdReparseOneTable(ACPI_TABLE_HEADER * Table,FILE * File,ACPI_OWNER_ID OwnerId)609bc36eafdSMike Gerdts AdReparseOneTable (
610bc36eafdSMike Gerdts ACPI_TABLE_HEADER *Table,
611bc36eafdSMike Gerdts FILE *File,
612bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId)
613bc36eafdSMike Gerdts {
614bc36eafdSMike Gerdts ACPI_STATUS Status;
615*35786f68SRobert Mustacchi ACPI_COMMENT_ADDR_NODE *AddrListHead;
616bc36eafdSMike Gerdts
617bc36eafdSMike Gerdts
618bc36eafdSMike Gerdts fprintf (stderr,
619bc36eafdSMike Gerdts "\nFound %u external control methods, "
620bc36eafdSMike Gerdts "reparsing with new information\n",
621*35786f68SRobert Mustacchi AcpiDmGetUnresolvedExternalMethodCount ());
622bc36eafdSMike Gerdts
623bc36eafdSMike Gerdts /* Reparse, rebuild namespace */
624bc36eafdSMike Gerdts
625bc36eafdSMike Gerdts AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
626bc36eafdSMike Gerdts AcpiGbl_ParseOpRoot = NULL;
627bc36eafdSMike Gerdts AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
628bc36eafdSMike Gerdts
629bc36eafdSMike Gerdts AcpiGbl_RootNode = NULL;
630bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
631bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
632bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
633bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Parent = NULL;
634bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Child = NULL;
635bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Peer = NULL;
636bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Object = NULL;
637bc36eafdSMike Gerdts AcpiGbl_RootNodeStruct.Flags = 0;
638bc36eafdSMike Gerdts
639bc36eafdSMike Gerdts Status = AcpiNsRootInitialize ();
640bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
641bc36eafdSMike Gerdts {
642bc36eafdSMike Gerdts return (Status);
643bc36eafdSMike Gerdts }
644bc36eafdSMike Gerdts
645bc36eafdSMike Gerdts /* New namespace, add the external definitions first */
646bc36eafdSMike Gerdts
647*35786f68SRobert Mustacchi AcpiDmAddExternalListToNamespace ();
648*35786f68SRobert Mustacchi
649*35786f68SRobert Mustacchi /* For -ca option: clear the list of comment addresses. */
650*35786f68SRobert Mustacchi
651*35786f68SRobert Mustacchi while (AcpiGbl_CommentAddrListHead)
652*35786f68SRobert Mustacchi {
653*35786f68SRobert Mustacchi AddrListHead= AcpiGbl_CommentAddrListHead;
654*35786f68SRobert Mustacchi AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next;
655*35786f68SRobert Mustacchi AcpiOsFree(AddrListHead);
656*35786f68SRobert Mustacchi }
657bc36eafdSMike Gerdts
658bc36eafdSMike Gerdts /* Parse the table again. No need to reload it, however */
659bc36eafdSMike Gerdts
660bc36eafdSMike Gerdts Status = AdParseTable (Table, NULL, FALSE, FALSE);
661bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
662bc36eafdSMike Gerdts {
663bc36eafdSMike Gerdts AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
664bc36eafdSMike Gerdts AcpiFormatException (Status));
665bc36eafdSMike Gerdts return (Status);
666bc36eafdSMike Gerdts }
667bc36eafdSMike Gerdts
668bc36eafdSMike Gerdts /* Cross reference the namespace again */
669bc36eafdSMike Gerdts
670bc36eafdSMike Gerdts AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
671bc36eafdSMike Gerdts AcpiGbl_RootNode, OwnerId);
672bc36eafdSMike Gerdts
673bc36eafdSMike Gerdts AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
674bc36eafdSMike Gerdts AcpiGbl_RootNode, OwnerId);
675bc36eafdSMike Gerdts
676bc36eafdSMike Gerdts /* Debug output - namespace and parse tree */
677bc36eafdSMike Gerdts
678bc36eafdSMike Gerdts if (AslCompilerdebug)
679bc36eafdSMike Gerdts {
680bc36eafdSMike Gerdts AcpiOsPrintf ("/**** After second load and resource conversion\n");
681bc36eafdSMike Gerdts if (File)
682bc36eafdSMike Gerdts {
683bc36eafdSMike Gerdts NsSetupNamespaceListing (File);
684bc36eafdSMike Gerdts NsDisplayNamespace ();
685bc36eafdSMike Gerdts }
686bc36eafdSMike Gerdts
687bc36eafdSMike Gerdts AcpiOsPrintf ("*****/\n");
688bc36eafdSMike Gerdts AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
689bc36eafdSMike Gerdts }
690bc36eafdSMike Gerdts
691bc36eafdSMike Gerdts return (AE_OK);
692bc36eafdSMike Gerdts }
693bc36eafdSMike Gerdts
694bc36eafdSMike Gerdts
695bc36eafdSMike Gerdts /******************************************************************************
696bc36eafdSMike Gerdts *
697bc36eafdSMike Gerdts * FUNCTION: AdDoExternalFileList
698bc36eafdSMike Gerdts *
699bc36eafdSMike Gerdts * PARAMETERS: Filename - Input file for the table
700bc36eafdSMike Gerdts *
701bc36eafdSMike Gerdts * RETURN: Status
702bc36eafdSMike Gerdts *
703bc36eafdSMike Gerdts * DESCRIPTION: Process all tables found in the -e external files list
704bc36eafdSMike Gerdts *
705bc36eafdSMike Gerdts *****************************************************************************/
706bc36eafdSMike Gerdts
707bc36eafdSMike Gerdts static ACPI_STATUS
AdDoExternalFileList(char * Filename)708bc36eafdSMike Gerdts AdDoExternalFileList (
709bc36eafdSMike Gerdts char *Filename)
710bc36eafdSMike Gerdts {
711bc36eafdSMike Gerdts ACPI_EXTERNAL_FILE *ExternalFileList;
712bc36eafdSMike Gerdts char *ExternalFilename;
713bc36eafdSMike Gerdts ACPI_NEW_TABLE_DESC *ExternalListHead = NULL;
714bc36eafdSMike Gerdts ACPI_STATUS Status;
715bc36eafdSMike Gerdts ACPI_STATUS GlobalStatus = AE_OK;
716bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId;
717bc36eafdSMike Gerdts
718bc36eafdSMike Gerdts
719bc36eafdSMike Gerdts /*
720bc36eafdSMike Gerdts * External filenames are specified on the command line like this:
721bc36eafdSMike Gerdts * Example: iasl -e file1,file2,file3 -d xxx.aml
722bc36eafdSMike Gerdts */
723bc36eafdSMike Gerdts ExternalFileList = AcpiGbl_ExternalFileList;
724bc36eafdSMike Gerdts
725bc36eafdSMike Gerdts /* Process each external file */
726bc36eafdSMike Gerdts
727bc36eafdSMike Gerdts while (ExternalFileList)
728bc36eafdSMike Gerdts {
729bc36eafdSMike Gerdts ExternalFilename = ExternalFileList->Path;
730bc36eafdSMike Gerdts if (!strcmp (ExternalFilename, Filename))
731bc36eafdSMike Gerdts {
732bc36eafdSMike Gerdts /* Next external file */
733bc36eafdSMike Gerdts
734bc36eafdSMike Gerdts ExternalFileList = ExternalFileList->Next;
735bc36eafdSMike Gerdts continue;
736bc36eafdSMike Gerdts }
737bc36eafdSMike Gerdts
738bc36eafdSMike Gerdts AcpiOsPrintf ("External object resolution file %16s\n",
739bc36eafdSMike Gerdts ExternalFilename);
740bc36eafdSMike Gerdts
741bc36eafdSMike Gerdts Status = AcGetAllTablesFromFile (
742bc36eafdSMike Gerdts ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
743bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
744bc36eafdSMike Gerdts {
745bc36eafdSMike Gerdts if (Status == AE_TYPE)
746bc36eafdSMike Gerdts {
747bc36eafdSMike Gerdts ExternalFileList = ExternalFileList->Next;
748bc36eafdSMike Gerdts GlobalStatus = AE_TYPE;
749bc36eafdSMike Gerdts Status = AE_OK;
750bc36eafdSMike Gerdts continue;
751bc36eafdSMike Gerdts }
752bc36eafdSMike Gerdts
753*35786f68SRobert Mustacchi AcDeleteTableList (ExternalListHead);
754bc36eafdSMike Gerdts return (Status);
755bc36eafdSMike Gerdts }
756bc36eafdSMike Gerdts
757bc36eafdSMike Gerdts /* Load external tables for symbol resolution */
758bc36eafdSMike Gerdts
759bc36eafdSMike Gerdts while (ExternalListHead)
760bc36eafdSMike Gerdts {
761bc36eafdSMike Gerdts Status = AdParseTable (
762bc36eafdSMike Gerdts ExternalListHead->Table, &OwnerId, TRUE, TRUE);
763bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
764bc36eafdSMike Gerdts {
765bc36eafdSMike Gerdts AcpiOsPrintf ("Could not parse external ACPI tables, %s\n",
766bc36eafdSMike Gerdts AcpiFormatException (Status));
767*35786f68SRobert Mustacchi AcDeleteTableList (ExternalListHead);
768bc36eafdSMike Gerdts return (Status);
769bc36eafdSMike Gerdts }
770bc36eafdSMike Gerdts
771bc36eafdSMike Gerdts /*
772bc36eafdSMike Gerdts * Load namespace from names created within control methods
773bc36eafdSMike Gerdts * Set owner id of nodes in external table
774bc36eafdSMike Gerdts */
775bc36eafdSMike Gerdts AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
776bc36eafdSMike Gerdts AcpiGbl_RootNode, OwnerId);
777bc36eafdSMike Gerdts AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
778bc36eafdSMike Gerdts
779bc36eafdSMike Gerdts ExternalListHead = ExternalListHead->Next;
780bc36eafdSMike Gerdts }
781bc36eafdSMike Gerdts
782bc36eafdSMike Gerdts /* Next external file */
783bc36eafdSMike Gerdts
784bc36eafdSMike Gerdts ExternalFileList = ExternalFileList->Next;
785bc36eafdSMike Gerdts }
786bc36eafdSMike Gerdts
787*35786f68SRobert Mustacchi AcDeleteTableList (ExternalListHead);
788*35786f68SRobert Mustacchi
789bc36eafdSMike Gerdts if (ACPI_FAILURE (GlobalStatus))
790bc36eafdSMike Gerdts {
791bc36eafdSMike Gerdts return (GlobalStatus);
792bc36eafdSMike Gerdts }
793bc36eafdSMike Gerdts
794bc36eafdSMike Gerdts /* Clear external list generated by Scope in external tables */
795bc36eafdSMike Gerdts
796bc36eafdSMike Gerdts if (AcpiGbl_ExternalFileList)
797bc36eafdSMike Gerdts {
798bc36eafdSMike Gerdts AcpiDmClearExternalList ();
799bc36eafdSMike Gerdts }
800bc36eafdSMike Gerdts
801bc36eafdSMike Gerdts /* Load any externals defined in the optional external ref file */
802bc36eafdSMike Gerdts
803bc36eafdSMike Gerdts AcpiDmGetExternalsFromFile ();
804bc36eafdSMike Gerdts return (AE_OK);
805bc36eafdSMike Gerdts }
806