159db4265SNate Lawson /******************************************************************************
259db4265SNate Lawson *
359db4265SNate Lawson * Module Name: adisasm - Application-level disassembler routines
459db4265SNate Lawson *
559db4265SNate Lawson *****************************************************************************/
659db4265SNate Lawson
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim *
90d84335fSJung-uk Kim * 1. Copyright Notice
100d84335fSJung-uk Kim *
11*722b1667SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
1259db4265SNate Lawson * All rights reserved.
1359db4265SNate Lawson *
140d84335fSJung-uk Kim * 2. License
150d84335fSJung-uk Kim *
160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim * property rights.
200d84335fSJung-uk Kim *
210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim *
280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim *
370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim * conditions are met:
390d84335fSJung-uk Kim *
400d84335fSJung-uk Kim * 3. Conditions
410d84335fSJung-uk Kim *
420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim *
540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim * make.
650d84335fSJung-uk Kim *
660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim * distribution.
710d84335fSJung-uk Kim *
720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim * Intel Code.
740d84335fSJung-uk Kim *
750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim * without prior written authorization from Intel.
790d84335fSJung-uk Kim *
800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim *
820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim *
900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim * LIMITED REMEDY.
980d84335fSJung-uk Kim *
990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim * such license, approval or letter.
1130d84335fSJung-uk Kim *
1140d84335fSJung-uk Kim *****************************************************************************
1150d84335fSJung-uk Kim *
1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim * following license:
1180d84335fSJung-uk Kim *
119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without
120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions
121d244b227SJung-uk Kim * are met:
122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright
123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer,
124d244b227SJung-uk Kim * without modification.
125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below
127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon
128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further
129d244b227SJung-uk Kim * binary redistribution.
130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names
131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived
132d244b227SJung-uk Kim * from this software without specific prior written permission.
13359db4265SNate Lawson *
1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim *
1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free
148d244b227SJung-uk Kim * Software Foundation.
14959db4265SNate Lawson *
1500d84335fSJung-uk Kim *****************************************************************************/
15159db4265SNate Lawson
152313a0c13SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
153ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h>
154ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h>
155ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h>
156ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
157f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
158ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acapps.h>
159ec0234b4SJung-uk Kim #include <contrib/dev/acpica/include/acconvert.h>
16059db4265SNate Lawson
16159db4265SNate Lawson
16259db4265SNate Lawson #define _COMPONENT ACPI_TOOLS
16359db4265SNate Lawson ACPI_MODULE_NAME ("adisasm")
16459db4265SNate Lawson
1651a39cfb0SJung-uk Kim /* Local prototypes */
1661a39cfb0SJung-uk Kim
167f8146b88SJung-uk Kim static ACPI_STATUS
168f8146b88SJung-uk Kim AdDoExternalFileList (
169f8146b88SJung-uk Kim char *Filename);
1701a39cfb0SJung-uk Kim
1717cf3e94aSJung-uk Kim static ACPI_STATUS
172f8146b88SJung-uk Kim AdDisassembleOneTable (
1737cf3e94aSJung-uk Kim ACPI_TABLE_HEADER *Table,
174f8146b88SJung-uk Kim FILE *File,
175f8146b88SJung-uk Kim char *Filename,
176f8146b88SJung-uk Kim char *DisasmFilename);
1777cf3e94aSJung-uk Kim
178f8146b88SJung-uk Kim static ACPI_STATUS
179f8146b88SJung-uk Kim AdReparseOneTable (
180f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table,
181f8146b88SJung-uk Kim FILE *File,
182f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId);
183f8146b88SJung-uk Kim
184f8146b88SJung-uk Kim
185f8146b88SJung-uk Kim ACPI_TABLE_DESC LocalTables[1];
186f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot;
187f8146b88SJung-uk Kim
188f8146b88SJung-uk Kim
189f8146b88SJung-uk Kim /* Stubs for everything except ASL compiler */
19059db4265SNate Lawson
191fba7fc7eSJung-uk Kim #ifndef ACPI_ASL_COMPILER
19259db4265SNate Lawson BOOLEAN
AcpiDsIsResultUsed(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)19359db4265SNate Lawson AcpiDsIsResultUsed (
19459db4265SNate Lawson ACPI_PARSE_OBJECT *Op,
19559db4265SNate Lawson ACPI_WALK_STATE *WalkState)
19659db4265SNate Lawson {
197f8146b88SJung-uk Kim return (TRUE);
19859db4265SNate Lawson }
1991a39cfb0SJung-uk Kim
2001a39cfb0SJung-uk Kim ACPI_STATUS
AcpiDsMethodError(ACPI_STATUS Status,ACPI_WALK_STATE * WalkState)2011a39cfb0SJung-uk Kim AcpiDsMethodError (
2021a39cfb0SJung-uk Kim ACPI_STATUS Status,
2031a39cfb0SJung-uk Kim ACPI_WALK_STATE *WalkState)
2041a39cfb0SJung-uk Kim {
2051a39cfb0SJung-uk Kim return (Status);
2061a39cfb0SJung-uk Kim }
20759db4265SNate Lawson #endif
20859db4265SNate Lawson
2094c52cad2SJung-uk Kim
2104c52cad2SJung-uk Kim /*******************************************************************************
2114c52cad2SJung-uk Kim *
21259db4265SNate Lawson * FUNCTION: AdInitialize
21359db4265SNate Lawson *
214f556842eSJung-uk Kim * PARAMETERS: None
21559db4265SNate Lawson *
21659db4265SNate Lawson * RETURN: Status
21759db4265SNate Lawson *
218f556842eSJung-uk Kim * DESCRIPTION: ACPICA and local initialization
21959db4265SNate Lawson *
22059db4265SNate Lawson ******************************************************************************/
22159db4265SNate Lawson
22259db4265SNate Lawson ACPI_STATUS
AdInitialize(void)22359db4265SNate Lawson AdInitialize (
22459db4265SNate Lawson void)
22559db4265SNate Lawson {
22659db4265SNate Lawson ACPI_STATUS Status;
22759db4265SNate Lawson
22859db4265SNate Lawson
22959db4265SNate Lawson /* ACPICA subsystem initialization */
23059db4265SNate Lawson
2311a39cfb0SJung-uk Kim Status = AcpiOsInitialize ();
232a9f12690SJung-uk Kim if (ACPI_FAILURE (Status))
233a9f12690SJung-uk Kim {
2340d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA subsystem: %s\n",
2350d84335fSJung-uk Kim AcpiFormatException (Status));
2360d84335fSJung-uk Kim
237a9f12690SJung-uk Kim return (Status);
238a9f12690SJung-uk Kim }
239a9f12690SJung-uk Kim
240a9f12690SJung-uk Kim Status = AcpiUtInitGlobals ();
241a9f12690SJung-uk Kim if (ACPI_FAILURE (Status))
242a9f12690SJung-uk Kim {
2430d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA globals: %s\n",
2440d84335fSJung-uk Kim AcpiFormatException (Status));
2450d84335fSJung-uk Kim
246a9f12690SJung-uk Kim return (Status);
247a9f12690SJung-uk Kim }
2481a39cfb0SJung-uk Kim
24959db4265SNate Lawson Status = AcpiUtMutexInitialize ();
25059db4265SNate Lawson if (ACPI_FAILURE (Status))
25159db4265SNate Lawson {
2520d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA mutex objects: %s\n",
2530d84335fSJung-uk Kim AcpiFormatException (Status));
2540d84335fSJung-uk Kim
255a9f12690SJung-uk Kim return (Status);
25659db4265SNate Lawson }
25759db4265SNate Lawson
25859db4265SNate Lawson Status = AcpiNsRootInitialize ();
2591a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status))
2601a39cfb0SJung-uk Kim {
2610d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA namespace: %s\n",
2620d84335fSJung-uk Kim AcpiFormatException (Status));
2630d84335fSJung-uk Kim
264a9f12690SJung-uk Kim return (Status);
2651a39cfb0SJung-uk Kim }
2661a39cfb0SJung-uk Kim
2671a39cfb0SJung-uk Kim /* Setup the Table Manager (cheat - there is no RSDT) */
2681a39cfb0SJung-uk Kim
2693f5e024cSJung-uk Kim AcpiGbl_RootTableList.MaxTableCount = 1;
2703f5e024cSJung-uk Kim AcpiGbl_RootTableList.CurrentTableCount = 0;
2711a39cfb0SJung-uk Kim AcpiGbl_RootTableList.Tables = LocalTables;
2721a39cfb0SJung-uk Kim
2730d84335fSJung-uk Kim return (AE_OK);
27459db4265SNate Lawson }
27559db4265SNate Lawson
27659db4265SNate Lawson
27759db4265SNate Lawson /******************************************************************************
27859db4265SNate Lawson *
27959db4265SNate Lawson * FUNCTION: AdAmlDisassemble
28059db4265SNate Lawson *
281fba7fc7eSJung-uk Kim * PARAMETERS: Filename - AML input filename
282fba7fc7eSJung-uk Kim * OutToFile - TRUE if output should go to a file
283fba7fc7eSJung-uk Kim * Prefix - Path prefix for output
284fba7fc7eSJung-uk Kim * OutFilename - where the filename is returned
28559db4265SNate Lawson *
28659db4265SNate Lawson * RETURN: Status
28759db4265SNate Lawson *
288f8146b88SJung-uk Kim * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table.
28959db4265SNate Lawson *
29059db4265SNate Lawson *****************************************************************************/
29159db4265SNate Lawson
29259db4265SNate Lawson ACPI_STATUS
AdAmlDisassemble(BOOLEAN OutToFile,char * Filename,char * Prefix,char ** OutFilename)29359db4265SNate Lawson AdAmlDisassemble (
29459db4265SNate Lawson BOOLEAN OutToFile,
29559db4265SNate Lawson char *Filename,
29659db4265SNate Lawson char *Prefix,
297313a0c13SJung-uk Kim char **OutFilename)
29859db4265SNate Lawson {
29959db4265SNate Lawson ACPI_STATUS Status;
30059db4265SNate Lawson char *DisasmFilename = NULL;
30159db4265SNate Lawson FILE *File = NULL;
302a9f12690SJung-uk Kim ACPI_TABLE_HEADER *Table = NULL;
303f8146b88SJung-uk Kim ACPI_NEW_TABLE_DESC *ListHead = NULL;
30459db4265SNate Lawson
30559db4265SNate Lawson
30659db4265SNate Lawson /*
307f556842eSJung-uk Kim * Input: AML code from either a file or via GetTables (memory or
308f556842eSJung-uk Kim * registry)
30959db4265SNate Lawson */
31059db4265SNate Lawson if (Filename)
31159db4265SNate Lawson {
312f8146b88SJung-uk Kim /* Get the list of all AML tables in the file */
313f8146b88SJung-uk Kim
314f8146b88SJung-uk Kim Status = AcGetAllTablesFromFile (Filename,
315f8146b88SJung-uk Kim ACPI_GET_ALL_TABLES, &ListHead);
316f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
317f8146b88SJung-uk Kim {
318f8146b88SJung-uk Kim AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
319f8146b88SJung-uk Kim Filename, AcpiFormatException (Status));
320f8146b88SJung-uk Kim return (Status);
321f8146b88SJung-uk Kim }
322f8146b88SJung-uk Kim
323f8146b88SJung-uk Kim /* Process any user-specified files for external objects */
324f8146b88SJung-uk Kim
325f8146b88SJung-uk Kim Status = AdDoExternalFileList (Filename);
32659db4265SNate Lawson if (ACPI_FAILURE (Status))
32759db4265SNate Lawson {
3288ef1a331SJung-uk Kim return (Status);
32959db4265SNate Lawson }
33059db4265SNate Lawson }
33159db4265SNate Lawson else
33259db4265SNate Lawson {
333313a0c13SJung-uk Kim Status = AdGetLocalTables ();
33459db4265SNate Lawson if (ACPI_FAILURE (Status))
33559db4265SNate Lawson {
33659db4265SNate Lawson AcpiOsPrintf ("Could not get ACPI tables, %s\n",
33759db4265SNate Lawson AcpiFormatException (Status));
3388ef1a331SJung-uk Kim return (Status);
33959db4265SNate Lawson }
34059db4265SNate Lawson
34170e6ab8fSJung-uk Kim if (!AcpiGbl_DmOpt_Disasm)
34259db4265SNate Lawson {
3438ef1a331SJung-uk Kim return (AE_OK);
34459db4265SNate Lawson }
34559db4265SNate Lawson
3461a39cfb0SJung-uk Kim /* Obtained the local tables, just disassemble the DSDT */
34759db4265SNate Lawson
3481a39cfb0SJung-uk Kim Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table);
3491a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status))
3501a39cfb0SJung-uk Kim {
3511a39cfb0SJung-uk Kim AcpiOsPrintf ("Could not get DSDT, %s\n",
3521a39cfb0SJung-uk Kim AcpiFormatException (Status));
3538ef1a331SJung-uk Kim return (Status);
3541a39cfb0SJung-uk Kim }
3551a39cfb0SJung-uk Kim
35659db4265SNate Lawson AcpiOsPrintf ("\nDisassembly of DSDT\n");
3571a39cfb0SJung-uk Kim Prefix = AdGenerateFilename ("dsdt", Table->OemTableId);
35859db4265SNate Lawson }
35959db4265SNate Lawson
36059db4265SNate Lawson /*
361f556842eSJung-uk Kim * Output: ASL code. Redirect to a file if requested
36259db4265SNate Lawson */
36359db4265SNate Lawson if (OutToFile)
36459db4265SNate Lawson {
36559db4265SNate Lawson /* Create/Open a disassembly output file */
36659db4265SNate Lawson
36759db4265SNate Lawson DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY);
368313a0c13SJung-uk Kim if (!DisasmFilename)
36959db4265SNate Lawson {
37059db4265SNate Lawson fprintf (stderr, "Could not generate output filename\n");
371e50beb51SNate Lawson Status = AE_ERROR;
372e50beb51SNate Lawson goto Cleanup;
37359db4265SNate Lawson }
37459db4265SNate Lawson
37559db4265SNate Lawson File = fopen (DisasmFilename, "w+");
37659db4265SNate Lawson if (!File)
37759db4265SNate Lawson {
378f8146b88SJung-uk Kim fprintf (stderr, "Could not open output file %s\n",
379f8146b88SJung-uk Kim DisasmFilename);
380e50beb51SNate Lawson Status = AE_ERROR;
381e50beb51SNate Lawson goto Cleanup;
38259db4265SNate Lawson }
38359db4265SNate Lawson }
38459db4265SNate Lawson
38559db4265SNate Lawson *OutFilename = DisasmFilename;
38659db4265SNate Lawson
387f8146b88SJung-uk Kim /* Disassemble all AML tables within the file */
388f8146b88SJung-uk Kim
389f8146b88SJung-uk Kim while (ListHead)
390f8146b88SJung-uk Kim {
391f8146b88SJung-uk Kim Status = AdDisassembleOneTable (ListHead->Table,
392f8146b88SJung-uk Kim File, Filename, DisasmFilename);
393f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
394f8146b88SJung-uk Kim {
395f8146b88SJung-uk Kim break;
396f8146b88SJung-uk Kim }
397f8146b88SJung-uk Kim
398f8146b88SJung-uk Kim ListHead = ListHead->Next;
399f8146b88SJung-uk Kim }
400f8146b88SJung-uk Kim
401f8146b88SJung-uk Kim Cleanup:
402f8146b88SJung-uk Kim
403f8146b88SJung-uk Kim if (Table &&
404f8146b88SJung-uk Kim !AcpiGbl_ForceAmlDisassembly &&
405f8146b88SJung-uk Kim !AcpiUtIsAmlTable (Table))
406f8146b88SJung-uk Kim {
407f8146b88SJung-uk Kim ACPI_FREE (Table);
408f8146b88SJung-uk Kim }
409f8146b88SJung-uk Kim
4105f9b24faSJung-uk Kim AcDeleteTableList (ListHead);
4115f9b24faSJung-uk Kim
412f8146b88SJung-uk Kim if (File)
413f8146b88SJung-uk Kim {
414f8146b88SJung-uk Kim fclose (File);
415f8146b88SJung-uk Kim AcpiOsRedirectOutput (stdout);
416f8146b88SJung-uk Kim }
417f8146b88SJung-uk Kim
418f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
419f8146b88SJung-uk Kim AcpiGbl_ParseOpRoot = NULL;
420f8146b88SJung-uk Kim return (Status);
421f8146b88SJung-uk Kim }
422f8146b88SJung-uk Kim
423f8146b88SJung-uk Kim
424f8146b88SJung-uk Kim /******************************************************************************
425f8146b88SJung-uk Kim *
426f8146b88SJung-uk Kim * FUNCTION: AdDisassembleOneTable
427f8146b88SJung-uk Kim *
428f8146b88SJung-uk Kim * PARAMETERS: Table - Raw AML table
429f8146b88SJung-uk Kim * File - Pointer for the input file
430f8146b88SJung-uk Kim * Filename - AML input filename
431f8146b88SJung-uk Kim * DisasmFilename - Output filename
432f8146b88SJung-uk Kim *
433f8146b88SJung-uk Kim * RETURN: Status
434f8146b88SJung-uk Kim *
435f8146b88SJung-uk Kim * DESCRIPTION: Disassemble a single ACPI table. AML or data table.
436f8146b88SJung-uk Kim *
437f8146b88SJung-uk Kim *****************************************************************************/
438f8146b88SJung-uk Kim
439f8146b88SJung-uk Kim static ACPI_STATUS
AdDisassembleOneTable(ACPI_TABLE_HEADER * Table,FILE * File,char * Filename,char * DisasmFilename)440f8146b88SJung-uk Kim AdDisassembleOneTable (
441f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table,
442f8146b88SJung-uk Kim FILE *File,
443f8146b88SJung-uk Kim char *Filename,
444f8146b88SJung-uk Kim char *DisasmFilename)
445f8146b88SJung-uk Kim {
446f8146b88SJung-uk Kim ACPI_STATUS Status;
447f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId;
448f8146b88SJung-uk Kim
449f8146b88SJung-uk Kim
4500d84335fSJung-uk Kim #ifdef ACPI_ASL_COMPILER
4510d84335fSJung-uk Kim
4520d84335fSJung-uk Kim /*
4530d84335fSJung-uk Kim * For ASL-/ASL+ converter: replace the temporary "XXXX"
4540d84335fSJung-uk Kim * table signature with the original. This "XXXX" makes
4550d84335fSJung-uk Kim * it harder for the AML interpreter to run the badaml
4560d84335fSJung-uk Kim * (.xxx) file produced from the converter in case if
4570d84335fSJung-uk Kim * it fails to get deleted.
4580d84335fSJung-uk Kim */
459f1db5ef7SJung-uk Kim if (AcpiGbl_CaptureComments)
4600d84335fSJung-uk Kim {
461278f0de6SJung-uk Kim strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAMESEG_SIZE);
4620d84335fSJung-uk Kim }
4630d84335fSJung-uk Kim #endif
4640d84335fSJung-uk Kim
4657cf3e94aSJung-uk Kim /* ForceAmlDisassembly means to assume the table contains valid AML */
4667cf3e94aSJung-uk Kim
4677cf3e94aSJung-uk Kim if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
4681a39cfb0SJung-uk Kim {
469ec0234b4SJung-uk Kim if (File)
470ec0234b4SJung-uk Kim {
471ec0234b4SJung-uk Kim AcpiOsRedirectOutput (File);
472ec0234b4SJung-uk Kim }
473ec0234b4SJung-uk Kim
4747cf3e94aSJung-uk Kim AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
475f8146b88SJung-uk Kim
476f8146b88SJung-uk Kim /* This is a "Data Table" (non-AML table) */
477f8146b88SJung-uk Kim
4781a39cfb0SJung-uk Kim AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
4799a4bc520SJung-uk Kim AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
480ec3fc72fSJung-uk Kim AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] "
48197c0b5abSJung-uk Kim "FieldName : FieldValue (in hex)\n */\n\n");
4821a39cfb0SJung-uk Kim
4831a39cfb0SJung-uk Kim AcpiDmDumpDataTable (Table);
4844c52cad2SJung-uk Kim fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
4859a4bc520SJung-uk Kim AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
4861c0e1b6dSJung-uk Kim
4871c0e1b6dSJung-uk Kim if (File)
4881c0e1b6dSJung-uk Kim {
4894c52cad2SJung-uk Kim fprintf (stderr, "Formatted output: %s - %u bytes\n",
490313a0c13SJung-uk Kim DisasmFilename, CmGetFileSize (File));
4911a39cfb0SJung-uk Kim }
49259db4265SNate Lawson
493f8146b88SJung-uk Kim return (AE_OK);
494f8146b88SJung-uk Kim }
495f8146b88SJung-uk Kim
496ec0234b4SJung-uk Kim /* Initialize the converter output file */
497ec0234b4SJung-uk Kim
498ec0234b4SJung-uk Kim ASL_CV_INIT_FILETREE(Table, File);
499ec0234b4SJung-uk Kim
500f8146b88SJung-uk Kim /*
501f8146b88SJung-uk Kim * This is an AML table (DSDT or SSDT).
502f8146b88SJung-uk Kim * Always parse the tables, only option is what to display
503f8146b88SJung-uk Kim */
504a9f12690SJung-uk Kim Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
50559db4265SNate Lawson if (ACPI_FAILURE (Status))
50659db4265SNate Lawson {
50759db4265SNate Lawson AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
50859db4265SNate Lawson AcpiFormatException (Status));
509f8146b88SJung-uk Kim return (Status);
51059db4265SNate Lawson }
51159db4265SNate Lawson
512ec0234b4SJung-uk Kim /* Redirect output for code generation and debugging output */
513ec0234b4SJung-uk Kim
514ec0234b4SJung-uk Kim if (File)
515ec0234b4SJung-uk Kim {
516ec0234b4SJung-uk Kim AcpiOsRedirectOutput (File);
517ec0234b4SJung-uk Kim }
518ec0234b4SJung-uk Kim
519f8146b88SJung-uk Kim /* Debug output, namespace and parse tree */
520f8146b88SJung-uk Kim
521f8146b88SJung-uk Kim if (AslCompilerdebug && File)
5221a39cfb0SJung-uk Kim {
5231a39cfb0SJung-uk Kim AcpiOsPrintf ("/**** Before second load\n");
5241a39cfb0SJung-uk Kim
525efcc2a30SJung-uk Kim NsSetupNamespaceListing (File);
526efcc2a30SJung-uk Kim NsDisplayNamespace ();
527f8146b88SJung-uk Kim
5281a39cfb0SJung-uk Kim AcpiOsPrintf ("*****/\n");
5291a39cfb0SJung-uk Kim }
5301a39cfb0SJung-uk Kim
531ec3fc72fSJung-uk Kim /* Load namespace from names created within control methods */
532ec3fc72fSJung-uk Kim
533ec3fc72fSJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
534ec3fc72fSJung-uk Kim AcpiGbl_RootNode, OwnerId);
5351a39cfb0SJung-uk Kim
5361a39cfb0SJung-uk Kim /*
537ec3fc72fSJung-uk Kim * Cross reference the namespace here, in order to
538ec3fc72fSJung-uk Kim * generate External() statements
5391a39cfb0SJung-uk Kim */
540ec3fc72fSJung-uk Kim AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
541ec3fc72fSJung-uk Kim AcpiGbl_RootNode, OwnerId);
5421a39cfb0SJung-uk Kim
5431a39cfb0SJung-uk Kim if (AslCompilerdebug)
5441a39cfb0SJung-uk Kim {
5451a39cfb0SJung-uk Kim AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
5461a39cfb0SJung-uk Kim }
5471a39cfb0SJung-uk Kim
5481a39cfb0SJung-uk Kim /* Find possible calls to external control methods */
5491a39cfb0SJung-uk Kim
5501a39cfb0SJung-uk Kim AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
5511a39cfb0SJung-uk Kim
5521a39cfb0SJung-uk Kim /*
553ec3fc72fSJung-uk Kim * If we found any external control methods, we must reparse
554ec3fc72fSJung-uk Kim * the entire tree with the new information (namely, the
555ec3fc72fSJung-uk Kim * number of arguments per method)
5561a39cfb0SJung-uk Kim */
557af051161SJung-uk Kim if (AcpiDmGetUnresolvedExternalMethodCount ())
5581a39cfb0SJung-uk Kim {
559f8146b88SJung-uk Kim Status = AdReparseOneTable (Table, File, OwnerId);
5601a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status))
5611a39cfb0SJung-uk Kim {
562f8146b88SJung-uk Kim return (Status);
5631a39cfb0SJung-uk Kim }
5641a39cfb0SJung-uk Kim }
565e0ef747bSNate Lawson
566ec3fc72fSJung-uk Kim /*
567ec3fc72fSJung-uk Kim * Now that the namespace is finalized, we can perform namespace
568ec3fc72fSJung-uk Kim * transforms.
569ec3fc72fSJung-uk Kim *
570ec3fc72fSJung-uk Kim * 1) Convert fixed-offset references to resource descriptors
571ec3fc72fSJung-uk Kim * to symbolic references (Note: modifies namespace)
572ec3fc72fSJung-uk Kim */
573af051161SJung-uk Kim AcpiDmConvertParseObjects (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
574ec3fc72fSJung-uk Kim
57559db4265SNate Lawson /* Optional displays */
57659db4265SNate Lawson
57770e6ab8fSJung-uk Kim if (AcpiGbl_DmOpt_Disasm)
57859db4265SNate Lawson {
5798ef1a331SJung-uk Kim /* This is the real disassembly */
5808ef1a331SJung-uk Kim
58159db4265SNate Lawson AdDisplayTables (Filename, Table);
5828ef1a331SJung-uk Kim
5838ef1a331SJung-uk Kim /* Dump hex table if requested (-vt) */
5848ef1a331SJung-uk Kim
5858ef1a331SJung-uk Kim AcpiDmDumpDataTable (Table);
5868ef1a331SJung-uk Kim
5874c52cad2SJung-uk Kim fprintf (stderr, "Disassembly completed\n");
5881c0e1b6dSJung-uk Kim if (File)
5891c0e1b6dSJung-uk Kim {
5904c52cad2SJung-uk Kim fprintf (stderr, "ASL Output: %s - %u bytes\n",
591313a0c13SJung-uk Kim DisasmFilename, CmGetFileSize (File));
5921c0e1b6dSJung-uk Kim }
593313a0c13SJung-uk Kim
5946f1f1a63SJung-uk Kim if (AslGbl_MapfileFlag)
595313a0c13SJung-uk Kim {
596313a0c13SJung-uk Kim fprintf (stderr, "%14s %s - %u bytes\n",
59744b0f624SJung-uk Kim AslGbl_FileDescs[ASL_FILE_MAP_OUTPUT].ShortDescription,
5986f1f1a63SJung-uk Kim AslGbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
599313a0c13SJung-uk Kim FlGetFileSize (ASL_FILE_MAP_OUTPUT));
600313a0c13SJung-uk Kim }
6011a39cfb0SJung-uk Kim }
602f8146b88SJung-uk Kim
603f8146b88SJung-uk Kim return (AE_OK);
60459db4265SNate Lawson }
60559db4265SNate Lawson
606a9f12690SJung-uk Kim
607f8146b88SJung-uk Kim /******************************************************************************
608f8146b88SJung-uk Kim *
609f8146b88SJung-uk Kim * FUNCTION: AdReparseOneTable
610f8146b88SJung-uk Kim *
611f8146b88SJung-uk Kim * PARAMETERS: Table - Raw AML table
612f8146b88SJung-uk Kim * File - Pointer for the input file
613f8146b88SJung-uk Kim * OwnerId - ID for this table
614f8146b88SJung-uk Kim *
615f8146b88SJung-uk Kim * RETURN: Status
616f8146b88SJung-uk Kim *
617f8146b88SJung-uk Kim * DESCRIPTION: Reparse a table that has already been loaded. Used to
618f8146b88SJung-uk Kim * integrate information about external control methods.
619f8146b88SJung-uk Kim * These methods may have been previously parsed incorrectly.
620f8146b88SJung-uk Kim *
621f8146b88SJung-uk Kim *****************************************************************************/
622f8146b88SJung-uk Kim
623f8146b88SJung-uk Kim static ACPI_STATUS
AdReparseOneTable(ACPI_TABLE_HEADER * Table,FILE * File,ACPI_OWNER_ID OwnerId)624f8146b88SJung-uk Kim AdReparseOneTable (
625f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table,
626f8146b88SJung-uk Kim FILE *File,
627f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId)
628a9f12690SJung-uk Kim {
629f8146b88SJung-uk Kim ACPI_STATUS Status;
6300d84335fSJung-uk Kim ACPI_COMMENT_ADDR_NODE *AddrListHead;
631f8146b88SJung-uk Kim
632f8146b88SJung-uk Kim
633f8146b88SJung-uk Kim fprintf (stderr,
634f8146b88SJung-uk Kim "\nFound %u external control methods, "
635f8146b88SJung-uk Kim "reparsing with new information\n",
636af051161SJung-uk Kim AcpiDmGetUnresolvedExternalMethodCount ());
637f8146b88SJung-uk Kim
638f8146b88SJung-uk Kim /* Reparse, rebuild namespace */
639f8146b88SJung-uk Kim
640f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
641f8146b88SJung-uk Kim AcpiGbl_ParseOpRoot = NULL;
642f8146b88SJung-uk Kim AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
643f8146b88SJung-uk Kim
644f8146b88SJung-uk Kim AcpiGbl_RootNode = NULL;
645f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
646f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
647f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
648f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Parent = NULL;
649f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Child = NULL;
650f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Peer = NULL;
651f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Object = NULL;
652f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Flags = 0;
653f8146b88SJung-uk Kim
654f8146b88SJung-uk Kim Status = AcpiNsRootInitialize ();
655f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
656f8146b88SJung-uk Kim {
657f8146b88SJung-uk Kim return (Status);
658a9f12690SJung-uk Kim }
659a9f12690SJung-uk Kim
660f8146b88SJung-uk Kim /* New namespace, add the external definitions first */
661f8146b88SJung-uk Kim
662af051161SJung-uk Kim AcpiDmAddExternalListToNamespace ();
663f8146b88SJung-uk Kim
6640d84335fSJung-uk Kim /* For -ca option: clear the list of comment addresses. */
6650d84335fSJung-uk Kim
6660d84335fSJung-uk Kim while (AcpiGbl_CommentAddrListHead)
6670d84335fSJung-uk Kim {
6680d84335fSJung-uk Kim AddrListHead= AcpiGbl_CommentAddrListHead;
6690d84335fSJung-uk Kim AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next;
6700d84335fSJung-uk Kim AcpiOsFree(AddrListHead);
6710d84335fSJung-uk Kim }
6720d84335fSJung-uk Kim
673f8146b88SJung-uk Kim /* Parse the table again. No need to reload it, however */
674f8146b88SJung-uk Kim
675f8146b88SJung-uk Kim Status = AdParseTable (Table, NULL, FALSE, FALSE);
676f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
677f8146b88SJung-uk Kim {
678f8146b88SJung-uk Kim AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
679f8146b88SJung-uk Kim AcpiFormatException (Status));
680f8146b88SJung-uk Kim return (Status);
681f8146b88SJung-uk Kim }
682f8146b88SJung-uk Kim
683f8146b88SJung-uk Kim /* Cross reference the namespace again */
684f8146b88SJung-uk Kim
685f8146b88SJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
686f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId);
687f8146b88SJung-uk Kim
688f8146b88SJung-uk Kim AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
689f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId);
690f8146b88SJung-uk Kim
691f8146b88SJung-uk Kim /* Debug output - namespace and parse tree */
692f8146b88SJung-uk Kim
693f8146b88SJung-uk Kim if (AslCompilerdebug)
694f8146b88SJung-uk Kim {
695f8146b88SJung-uk Kim AcpiOsPrintf ("/**** After second load and resource conversion\n");
6961c0e1b6dSJung-uk Kim if (File)
69759db4265SNate Lawson {
698efcc2a30SJung-uk Kim NsSetupNamespaceListing (File);
699efcc2a30SJung-uk Kim NsDisplayNamespace ();
700ec3fc72fSJung-uk Kim }
701ec3fc72fSJung-uk Kim
702f8146b88SJung-uk Kim AcpiOsPrintf ("*****/\n");
703f8146b88SJung-uk Kim AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
70459db4265SNate Lawson }
70559db4265SNate Lawson
7068ef1a331SJung-uk Kim return (AE_OK);
70759db4265SNate Lawson }
70859db4265SNate Lawson
70959db4265SNate Lawson
710f8146b88SJung-uk Kim /******************************************************************************
7117cf3e94aSJung-uk Kim *
712f8146b88SJung-uk Kim * FUNCTION: AdDoExternalFileList
7137cf3e94aSJung-uk Kim *
714f8146b88SJung-uk Kim * PARAMETERS: Filename - Input file for the table
7157cf3e94aSJung-uk Kim *
716f8146b88SJung-uk Kim * RETURN: Status
7177cf3e94aSJung-uk Kim *
718f8146b88SJung-uk Kim * DESCRIPTION: Process all tables found in the -e external files list
7197cf3e94aSJung-uk Kim *
720f8146b88SJung-uk Kim *****************************************************************************/
7217cf3e94aSJung-uk Kim
7227cf3e94aSJung-uk Kim static ACPI_STATUS
AdDoExternalFileList(char * Filename)723f8146b88SJung-uk Kim AdDoExternalFileList (
724f8146b88SJung-uk Kim char *Filename)
7257cf3e94aSJung-uk Kim {
726f8146b88SJung-uk Kim ACPI_EXTERNAL_FILE *ExternalFileList;
727f8146b88SJung-uk Kim char *ExternalFilename;
728f8146b88SJung-uk Kim ACPI_NEW_TABLE_DESC *ExternalListHead = NULL;
7297cf3e94aSJung-uk Kim ACPI_STATUS Status;
730f8146b88SJung-uk Kim ACPI_STATUS GlobalStatus = AE_OK;
731f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId;
7327cf3e94aSJung-uk Kim
7337cf3e94aSJung-uk Kim
734f8146b88SJung-uk Kim /*
735f8146b88SJung-uk Kim * External filenames are specified on the command line like this:
736f8146b88SJung-uk Kim * Example: iasl -e file1,file2,file3 -d xxx.aml
737f8146b88SJung-uk Kim */
738f8146b88SJung-uk Kim ExternalFileList = AcpiGbl_ExternalFileList;
739f8146b88SJung-uk Kim
740f8146b88SJung-uk Kim /* Process each external file */
741f8146b88SJung-uk Kim
742f8146b88SJung-uk Kim while (ExternalFileList)
743f8146b88SJung-uk Kim {
744f8146b88SJung-uk Kim ExternalFilename = ExternalFileList->Path;
745f8146b88SJung-uk Kim if (!strcmp (ExternalFilename, Filename))
746f8146b88SJung-uk Kim {
747f8146b88SJung-uk Kim /* Next external file */
748f8146b88SJung-uk Kim
749f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next;
750f8146b88SJung-uk Kim continue;
751f8146b88SJung-uk Kim }
752f8146b88SJung-uk Kim
753f8146b88SJung-uk Kim AcpiOsPrintf ("External object resolution file %16s\n",
754f8146b88SJung-uk Kim ExternalFilename);
755f8146b88SJung-uk Kim
756f8146b88SJung-uk Kim Status = AcGetAllTablesFromFile (
757f8146b88SJung-uk Kim ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
7587cf3e94aSJung-uk Kim if (ACPI_FAILURE (Status))
7597cf3e94aSJung-uk Kim {
760f8146b88SJung-uk Kim if (Status == AE_TYPE)
761f8146b88SJung-uk Kim {
762f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next;
763f8146b88SJung-uk Kim GlobalStatus = AE_TYPE;
764f8146b88SJung-uk Kim continue;
765f8146b88SJung-uk Kim }
766f8146b88SJung-uk Kim
7675f9b24faSJung-uk Kim AcDeleteTableList (ExternalListHead);
7687cf3e94aSJung-uk Kim return (Status);
7697cf3e94aSJung-uk Kim }
7707cf3e94aSJung-uk Kim
771f8146b88SJung-uk Kim /* Load external tables for symbol resolution */
7727cf3e94aSJung-uk Kim
773f8146b88SJung-uk Kim while (ExternalListHead)
77459db4265SNate Lawson {
775f8146b88SJung-uk Kim Status = AdParseTable (
776f8146b88SJung-uk Kim ExternalListHead->Table, &OwnerId, TRUE, TRUE);
777f556842eSJung-uk Kim if (ACPI_FAILURE (Status))
778f556842eSJung-uk Kim {
779f8146b88SJung-uk Kim AcpiOsPrintf ("Could not parse external ACPI tables, %s\n",
780f8146b88SJung-uk Kim AcpiFormatException (Status));
7815f9b24faSJung-uk Kim AcDeleteTableList (ExternalListHead);
78259db4265SNate Lawson return (Status);
78359db4265SNate Lawson }
78459db4265SNate Lawson
785313a0c13SJung-uk Kim /*
786f8146b88SJung-uk Kim * Load namespace from names created within control methods
787f8146b88SJung-uk Kim * Set owner id of nodes in external table
788313a0c13SJung-uk Kim */
789f8146b88SJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
790f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId);
791f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
792*722b1667SJung-uk Kim AcpiGbl_ParseOpRoot = NULL;
7931a39cfb0SJung-uk Kim
794f8146b88SJung-uk Kim ExternalListHead = ExternalListHead->Next;
795f8146b88SJung-uk Kim }
7961a39cfb0SJung-uk Kim
797f8146b88SJung-uk Kim /* Next external file */
79859db4265SNate Lawson
799f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next;
800f8146b88SJung-uk Kim }
801f8146b88SJung-uk Kim
8025f9b24faSJung-uk Kim AcDeleteTableList (ExternalListHead);
8035f9b24faSJung-uk Kim
804f8146b88SJung-uk Kim if (ACPI_FAILURE (GlobalStatus))
805f8146b88SJung-uk Kim {
806f8146b88SJung-uk Kim return (GlobalStatus);
807f8146b88SJung-uk Kim }
808f8146b88SJung-uk Kim
809f8146b88SJung-uk Kim /* Clear external list generated by Scope in external tables */
810f8146b88SJung-uk Kim
811f8146b88SJung-uk Kim if (AcpiGbl_ExternalFileList)
812f8146b88SJung-uk Kim {
813f8146b88SJung-uk Kim AcpiDmClearExternalList ();
814f8146b88SJung-uk Kim }
815f8146b88SJung-uk Kim
816f8146b88SJung-uk Kim /* Load any externals defined in the optional external ref file */
817f8146b88SJung-uk Kim
818f8146b88SJung-uk Kim AcpiDmGetExternalsFromFile ();
8198ef1a331SJung-uk Kim return (AE_OK);
82059db4265SNate Lawson }
821