159db4265SNate Lawson /****************************************************************************** 259db4265SNate Lawson * 359db4265SNate Lawson * Module Name: adisasm - Application-level disassembler routines 459db4265SNate Lawson * 559db4265SNate Lawson *****************************************************************************/ 659db4265SNate Lawson 7*0d84335fSJung-uk Kim /****************************************************************************** 8*0d84335fSJung-uk Kim * 9*0d84335fSJung-uk Kim * 1. Copyright Notice 10*0d84335fSJung-uk Kim * 11*0d84335fSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1259db4265SNate Lawson * All rights reserved. 1359db4265SNate Lawson * 14*0d84335fSJung-uk Kim * 2. License 15*0d84335fSJung-uk Kim * 16*0d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 17*0d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 18*0d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 19*0d84335fSJung-uk Kim * property rights. 20*0d84335fSJung-uk Kim * 21*0d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*0d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 23*0d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*0d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 25*0d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 26*0d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 27*0d84335fSJung-uk Kim * 28*0d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*0d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 30*0d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 31*0d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 32*0d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 33*0d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 34*0d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 35*0d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 36*0d84335fSJung-uk Kim * 37*0d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 38*0d84335fSJung-uk Kim * conditions are met: 39*0d84335fSJung-uk Kim * 40*0d84335fSJung-uk Kim * 3. Conditions 41*0d84335fSJung-uk Kim * 42*0d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 44*0d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 45*0d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 46*0d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 47*0d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 48*0d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 49*0d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 50*0d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 51*0d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 52*0d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 53*0d84335fSJung-uk Kim * 54*0d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 56*0d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 57*0d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 58*0d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 59*0d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 60*0d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 61*0d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 62*0d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 63*0d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 64*0d84335fSJung-uk Kim * make. 65*0d84335fSJung-uk Kim * 66*0d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*0d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 68*0d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 69*0d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 70*0d84335fSJung-uk Kim * distribution. 71*0d84335fSJung-uk Kim * 72*0d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 73*0d84335fSJung-uk Kim * Intel Code. 74*0d84335fSJung-uk Kim * 75*0d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*0d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 77*0d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 78*0d84335fSJung-uk Kim * without prior written authorization from Intel. 79*0d84335fSJung-uk Kim * 80*0d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 81*0d84335fSJung-uk Kim * 82*0d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*0d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*0d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*0d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*0d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*0d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*0d84335fSJung-uk Kim * PARTICULAR PURPOSE. 89*0d84335fSJung-uk Kim * 90*0d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*0d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*0d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*0d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*0d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*0d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*0d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*0d84335fSJung-uk Kim * LIMITED REMEDY. 98*0d84335fSJung-uk Kim * 99*0d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*0d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 101*0d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 102*0d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 103*0d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 104*0d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 105*0d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 106*0d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 107*0d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*0d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 109*0d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 110*0d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 111*0d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 112*0d84335fSJung-uk Kim * such license, approval or letter. 113*0d84335fSJung-uk Kim * 114*0d84335fSJung-uk Kim ***************************************************************************** 115*0d84335fSJung-uk Kim * 116*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 117*0d84335fSJung-uk Kim * following license: 118*0d84335fSJung-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 * 134*0d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135*0d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136*0d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137*0d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138*0d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139*0d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140*0d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141*0d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142*0d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143*0d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144*0d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145*0d84335fSJung-uk Kim * 146*0d84335fSJung-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 * 150*0d84335fSJung-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> 15959db4265SNate Lawson 16059db4265SNate Lawson 16159db4265SNate Lawson #define _COMPONENT ACPI_TOOLS 16259db4265SNate Lawson ACPI_MODULE_NAME ("adisasm") 16359db4265SNate Lawson 1641a39cfb0SJung-uk Kim /* Local prototypes */ 1651a39cfb0SJung-uk Kim 166f8146b88SJung-uk Kim static ACPI_STATUS 167f8146b88SJung-uk Kim AdDoExternalFileList ( 168f8146b88SJung-uk Kim char *Filename); 1691a39cfb0SJung-uk Kim 1707cf3e94aSJung-uk Kim static ACPI_STATUS 171f8146b88SJung-uk Kim AdDisassembleOneTable ( 1727cf3e94aSJung-uk Kim ACPI_TABLE_HEADER *Table, 173f8146b88SJung-uk Kim FILE *File, 174f8146b88SJung-uk Kim char *Filename, 175f8146b88SJung-uk Kim char *DisasmFilename); 1767cf3e94aSJung-uk Kim 177f8146b88SJung-uk Kim static ACPI_STATUS 178f8146b88SJung-uk Kim AdReparseOneTable ( 179f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 180f8146b88SJung-uk Kim FILE *File, 181f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId); 182f8146b88SJung-uk Kim 183f8146b88SJung-uk Kim 184f8146b88SJung-uk Kim ACPI_TABLE_DESC LocalTables[1]; 185f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; 186f8146b88SJung-uk Kim 187f8146b88SJung-uk Kim 188f8146b88SJung-uk Kim /* Stubs for everything except ASL compiler */ 18959db4265SNate Lawson 190fba7fc7eSJung-uk Kim #ifndef ACPI_ASL_COMPILER 19159db4265SNate Lawson BOOLEAN 19259db4265SNate Lawson AcpiDsIsResultUsed ( 19359db4265SNate Lawson ACPI_PARSE_OBJECT *Op, 19459db4265SNate Lawson ACPI_WALK_STATE *WalkState) 19559db4265SNate Lawson { 196f8146b88SJung-uk Kim return (TRUE); 19759db4265SNate Lawson } 1981a39cfb0SJung-uk Kim 1991a39cfb0SJung-uk Kim ACPI_STATUS 2001a39cfb0SJung-uk Kim AcpiDsMethodError ( 2011a39cfb0SJung-uk Kim ACPI_STATUS Status, 2021a39cfb0SJung-uk Kim ACPI_WALK_STATE *WalkState) 2031a39cfb0SJung-uk Kim { 2041a39cfb0SJung-uk Kim return (Status); 2051a39cfb0SJung-uk Kim } 20659db4265SNate Lawson #endif 20759db4265SNate Lawson 2084c52cad2SJung-uk Kim 2094c52cad2SJung-uk Kim /******************************************************************************* 2104c52cad2SJung-uk Kim * 21159db4265SNate Lawson * FUNCTION: AdInitialize 21259db4265SNate Lawson * 213f556842eSJung-uk Kim * PARAMETERS: None 21459db4265SNate Lawson * 21559db4265SNate Lawson * RETURN: Status 21659db4265SNate Lawson * 217f556842eSJung-uk Kim * DESCRIPTION: ACPICA and local initialization 21859db4265SNate Lawson * 21959db4265SNate Lawson ******************************************************************************/ 22059db4265SNate Lawson 22159db4265SNate Lawson ACPI_STATUS 22259db4265SNate Lawson AdInitialize ( 22359db4265SNate Lawson void) 22459db4265SNate Lawson { 22559db4265SNate Lawson ACPI_STATUS Status; 22659db4265SNate Lawson 22759db4265SNate Lawson 22859db4265SNate Lawson /* ACPICA subsystem initialization */ 22959db4265SNate Lawson 2301a39cfb0SJung-uk Kim Status = AcpiOsInitialize (); 231a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 232a9f12690SJung-uk Kim { 233*0d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA subsystem: %s\n", 234*0d84335fSJung-uk Kim AcpiFormatException (Status)); 235*0d84335fSJung-uk Kim 236a9f12690SJung-uk Kim return (Status); 237a9f12690SJung-uk Kim } 238a9f12690SJung-uk Kim 239a9f12690SJung-uk Kim Status = AcpiUtInitGlobals (); 240a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 241a9f12690SJung-uk Kim { 242*0d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA globals: %s\n", 243*0d84335fSJung-uk Kim AcpiFormatException (Status)); 244*0d84335fSJung-uk Kim 245a9f12690SJung-uk Kim return (Status); 246a9f12690SJung-uk Kim } 2471a39cfb0SJung-uk Kim 24859db4265SNate Lawson Status = AcpiUtMutexInitialize (); 24959db4265SNate Lawson if (ACPI_FAILURE (Status)) 25059db4265SNate Lawson { 251*0d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA mutex objects: %s\n", 252*0d84335fSJung-uk Kim AcpiFormatException (Status)); 253*0d84335fSJung-uk Kim 254a9f12690SJung-uk Kim return (Status); 25559db4265SNate Lawson } 25659db4265SNate Lawson 25759db4265SNate Lawson Status = AcpiNsRootInitialize (); 2581a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 2591a39cfb0SJung-uk Kim { 260*0d84335fSJung-uk Kim fprintf (stderr, "Could not initialize ACPICA namespace: %s\n", 261*0d84335fSJung-uk Kim AcpiFormatException (Status)); 262*0d84335fSJung-uk Kim 263a9f12690SJung-uk Kim return (Status); 2641a39cfb0SJung-uk Kim } 2651a39cfb0SJung-uk Kim 2661a39cfb0SJung-uk Kim /* Setup the Table Manager (cheat - there is no RSDT) */ 2671a39cfb0SJung-uk Kim 2683f5e024cSJung-uk Kim AcpiGbl_RootTableList.MaxTableCount = 1; 2693f5e024cSJung-uk Kim AcpiGbl_RootTableList.CurrentTableCount = 0; 2701a39cfb0SJung-uk Kim AcpiGbl_RootTableList.Tables = LocalTables; 2711a39cfb0SJung-uk Kim 272*0d84335fSJung-uk Kim return (AE_OK); 27359db4265SNate Lawson } 27459db4265SNate Lawson 27559db4265SNate Lawson 27659db4265SNate Lawson /****************************************************************************** 27759db4265SNate Lawson * 27859db4265SNate Lawson * FUNCTION: AdAmlDisassemble 27959db4265SNate Lawson * 280fba7fc7eSJung-uk Kim * PARAMETERS: Filename - AML input filename 281fba7fc7eSJung-uk Kim * OutToFile - TRUE if output should go to a file 282fba7fc7eSJung-uk Kim * Prefix - Path prefix for output 283fba7fc7eSJung-uk Kim * OutFilename - where the filename is returned 28459db4265SNate Lawson * 28559db4265SNate Lawson * RETURN: Status 28659db4265SNate Lawson * 287f8146b88SJung-uk Kim * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table. 28859db4265SNate Lawson * 28959db4265SNate Lawson *****************************************************************************/ 29059db4265SNate Lawson 29159db4265SNate Lawson ACPI_STATUS 29259db4265SNate Lawson AdAmlDisassemble ( 29359db4265SNate Lawson BOOLEAN OutToFile, 29459db4265SNate Lawson char *Filename, 29559db4265SNate Lawson char *Prefix, 296313a0c13SJung-uk Kim char **OutFilename) 29759db4265SNate Lawson { 29859db4265SNate Lawson ACPI_STATUS Status; 29959db4265SNate Lawson char *DisasmFilename = NULL; 30059db4265SNate Lawson FILE *File = NULL; 301a9f12690SJung-uk Kim ACPI_TABLE_HEADER *Table = NULL; 302f8146b88SJung-uk Kim ACPI_NEW_TABLE_DESC *ListHead = NULL; 30359db4265SNate Lawson 30459db4265SNate Lawson 30559db4265SNate Lawson /* 306f556842eSJung-uk Kim * Input: AML code from either a file or via GetTables (memory or 307f556842eSJung-uk Kim * registry) 30859db4265SNate Lawson */ 30959db4265SNate Lawson if (Filename) 31059db4265SNate Lawson { 311f8146b88SJung-uk Kim /* Get the list of all AML tables in the file */ 312f8146b88SJung-uk Kim 313f8146b88SJung-uk Kim Status = AcGetAllTablesFromFile (Filename, 314f8146b88SJung-uk Kim ACPI_GET_ALL_TABLES, &ListHead); 315f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 316f8146b88SJung-uk Kim { 317f8146b88SJung-uk Kim AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n", 318f8146b88SJung-uk Kim Filename, AcpiFormatException (Status)); 319f8146b88SJung-uk Kim return (Status); 320f8146b88SJung-uk Kim } 321f8146b88SJung-uk Kim 322f8146b88SJung-uk Kim /* Process any user-specified files for external objects */ 323f8146b88SJung-uk Kim 324f8146b88SJung-uk Kim Status = AdDoExternalFileList (Filename); 32559db4265SNate Lawson if (ACPI_FAILURE (Status)) 32659db4265SNate Lawson { 3278ef1a331SJung-uk Kim return (Status); 32859db4265SNate Lawson } 32959db4265SNate Lawson } 33059db4265SNate Lawson else 33159db4265SNate Lawson { 332313a0c13SJung-uk Kim Status = AdGetLocalTables (); 33359db4265SNate Lawson if (ACPI_FAILURE (Status)) 33459db4265SNate Lawson { 33559db4265SNate Lawson AcpiOsPrintf ("Could not get ACPI tables, %s\n", 33659db4265SNate Lawson AcpiFormatException (Status)); 3378ef1a331SJung-uk Kim return (Status); 33859db4265SNate Lawson } 33959db4265SNate Lawson 34070e6ab8fSJung-uk Kim if (!AcpiGbl_DmOpt_Disasm) 34159db4265SNate Lawson { 3428ef1a331SJung-uk Kim return (AE_OK); 34359db4265SNate Lawson } 34459db4265SNate Lawson 3451a39cfb0SJung-uk Kim /* Obtained the local tables, just disassemble the DSDT */ 34659db4265SNate Lawson 3471a39cfb0SJung-uk Kim Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table); 3481a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 3491a39cfb0SJung-uk Kim { 3501a39cfb0SJung-uk Kim AcpiOsPrintf ("Could not get DSDT, %s\n", 3511a39cfb0SJung-uk Kim AcpiFormatException (Status)); 3528ef1a331SJung-uk Kim return (Status); 3531a39cfb0SJung-uk Kim } 3541a39cfb0SJung-uk Kim 35559db4265SNate Lawson AcpiOsPrintf ("\nDisassembly of DSDT\n"); 3561a39cfb0SJung-uk Kim Prefix = AdGenerateFilename ("dsdt", Table->OemTableId); 35759db4265SNate Lawson } 35859db4265SNate Lawson 35959db4265SNate Lawson /* 360f556842eSJung-uk Kim * Output: ASL code. Redirect to a file if requested 36159db4265SNate Lawson */ 36259db4265SNate Lawson if (OutToFile) 36359db4265SNate Lawson { 36459db4265SNate Lawson /* Create/Open a disassembly output file */ 36559db4265SNate Lawson 36659db4265SNate Lawson DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY); 367313a0c13SJung-uk Kim if (!DisasmFilename) 36859db4265SNate Lawson { 36959db4265SNate Lawson fprintf (stderr, "Could not generate output filename\n"); 370e50beb51SNate Lawson Status = AE_ERROR; 371e50beb51SNate Lawson goto Cleanup; 37259db4265SNate Lawson } 37359db4265SNate Lawson 37459db4265SNate Lawson File = fopen (DisasmFilename, "w+"); 37559db4265SNate Lawson if (!File) 37659db4265SNate Lawson { 377f8146b88SJung-uk Kim fprintf (stderr, "Could not open output file %s\n", 378f8146b88SJung-uk Kim DisasmFilename); 379e50beb51SNate Lawson Status = AE_ERROR; 380e50beb51SNate Lawson goto Cleanup; 38159db4265SNate Lawson } 38259db4265SNate Lawson 38359db4265SNate Lawson AcpiOsRedirectOutput (File); 38459db4265SNate Lawson } 38559db4265SNate Lawson 38659db4265SNate Lawson *OutFilename = DisasmFilename; 38759db4265SNate Lawson 388f8146b88SJung-uk Kim /* Disassemble all AML tables within the file */ 389f8146b88SJung-uk Kim 390f8146b88SJung-uk Kim while (ListHead) 391f8146b88SJung-uk Kim { 392f8146b88SJung-uk Kim Status = AdDisassembleOneTable (ListHead->Table, 393f8146b88SJung-uk Kim File, Filename, DisasmFilename); 394f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 395f8146b88SJung-uk Kim { 396f8146b88SJung-uk Kim break; 397f8146b88SJung-uk Kim } 398f8146b88SJung-uk Kim 399f8146b88SJung-uk Kim ListHead = ListHead->Next; 400f8146b88SJung-uk Kim } 401f8146b88SJung-uk Kim 402f8146b88SJung-uk Kim Cleanup: 403f8146b88SJung-uk Kim 404f8146b88SJung-uk Kim if (Table && 405f8146b88SJung-uk Kim !AcpiGbl_ForceAmlDisassembly && 406f8146b88SJung-uk Kim !AcpiUtIsAmlTable (Table)) 407f8146b88SJung-uk Kim { 408f8146b88SJung-uk Kim ACPI_FREE (Table); 409f8146b88SJung-uk Kim } 410f8146b88SJung-uk Kim 411f8146b88SJung-uk Kim if (File) 412f8146b88SJung-uk Kim { 413f8146b88SJung-uk Kim fclose (File); 414f8146b88SJung-uk Kim AcpiOsRedirectOutput (stdout); 415f8146b88SJung-uk Kim } 416f8146b88SJung-uk Kim 417f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); 418f8146b88SJung-uk Kim AcpiGbl_ParseOpRoot = NULL; 419f8146b88SJung-uk Kim return (Status); 420f8146b88SJung-uk Kim } 421f8146b88SJung-uk Kim 422f8146b88SJung-uk Kim 423f8146b88SJung-uk Kim /****************************************************************************** 424f8146b88SJung-uk Kim * 425f8146b88SJung-uk Kim * FUNCTION: AdDisassembleOneTable 426f8146b88SJung-uk Kim * 427f8146b88SJung-uk Kim * PARAMETERS: Table - Raw AML table 428f8146b88SJung-uk Kim * File - Pointer for the input file 429f8146b88SJung-uk Kim * Filename - AML input filename 430f8146b88SJung-uk Kim * DisasmFilename - Output filename 431f8146b88SJung-uk Kim * 432f8146b88SJung-uk Kim * RETURN: Status 433f8146b88SJung-uk Kim * 434f8146b88SJung-uk Kim * DESCRIPTION: Disassemble a single ACPI table. AML or data table. 435f8146b88SJung-uk Kim * 436f8146b88SJung-uk Kim *****************************************************************************/ 437f8146b88SJung-uk Kim 438f8146b88SJung-uk Kim static ACPI_STATUS 439f8146b88SJung-uk Kim AdDisassembleOneTable ( 440f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 441f8146b88SJung-uk Kim FILE *File, 442f8146b88SJung-uk Kim char *Filename, 443f8146b88SJung-uk Kim char *DisasmFilename) 444f8146b88SJung-uk Kim { 445f8146b88SJung-uk Kim ACPI_STATUS Status; 446f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId; 447f8146b88SJung-uk Kim 448f8146b88SJung-uk Kim 449*0d84335fSJung-uk Kim #ifdef ACPI_ASL_COMPILER 450*0d84335fSJung-uk Kim 451*0d84335fSJung-uk Kim /* 452*0d84335fSJung-uk Kim * For ASL-/ASL+ converter: replace the temporary "XXXX" 453*0d84335fSJung-uk Kim * table signature with the original. This "XXXX" makes 454*0d84335fSJung-uk Kim * it harder for the AML interpreter to run the badaml 455*0d84335fSJung-uk Kim * (.xxx) file produced from the converter in case if 456*0d84335fSJung-uk Kim * it fails to get deleted. 457*0d84335fSJung-uk Kim */ 458*0d84335fSJung-uk Kim if (Gbl_CaptureComments) 459*0d84335fSJung-uk Kim { 460*0d84335fSJung-uk Kim strncpy (Table->Signature, AcpiGbl_TableSig, 4); 461*0d84335fSJung-uk Kim } 462*0d84335fSJung-uk Kim #endif 463*0d84335fSJung-uk Kim 4647cf3e94aSJung-uk Kim /* ForceAmlDisassembly means to assume the table contains valid AML */ 4657cf3e94aSJung-uk Kim 4667cf3e94aSJung-uk Kim if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) 4671a39cfb0SJung-uk Kim { 4687cf3e94aSJung-uk Kim AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE); 469f8146b88SJung-uk Kim 470f8146b88SJung-uk Kim /* This is a "Data Table" (non-AML table) */ 471f8146b88SJung-uk Kim 4721a39cfb0SJung-uk Kim AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n", 4731a39cfb0SJung-uk Kim Table->Signature); 474ec3fc72fSJung-uk Kim AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] " 475ec3fc72fSJung-uk Kim "FieldName : FieldValue\n */\n\n"); 4761a39cfb0SJung-uk Kim 4771a39cfb0SJung-uk Kim AcpiDmDumpDataTable (Table); 4784c52cad2SJung-uk Kim fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", 4794c52cad2SJung-uk Kim Table->Signature); 4801c0e1b6dSJung-uk Kim 4811c0e1b6dSJung-uk Kim if (File) 4821c0e1b6dSJung-uk Kim { 4834c52cad2SJung-uk Kim fprintf (stderr, "Formatted output: %s - %u bytes\n", 484313a0c13SJung-uk Kim DisasmFilename, CmGetFileSize (File)); 4851a39cfb0SJung-uk Kim } 48659db4265SNate Lawson 487f8146b88SJung-uk Kim return (AE_OK); 488f8146b88SJung-uk Kim } 489f8146b88SJung-uk Kim 490f8146b88SJung-uk Kim /* 491f8146b88SJung-uk Kim * This is an AML table (DSDT or SSDT). 492f8146b88SJung-uk Kim * Always parse the tables, only option is what to display 493f8146b88SJung-uk Kim */ 494a9f12690SJung-uk Kim Status = AdParseTable (Table, &OwnerId, TRUE, FALSE); 49559db4265SNate Lawson if (ACPI_FAILURE (Status)) 49659db4265SNate Lawson { 49759db4265SNate Lawson AcpiOsPrintf ("Could not parse ACPI tables, %s\n", 49859db4265SNate Lawson AcpiFormatException (Status)); 499f8146b88SJung-uk Kim return (Status); 50059db4265SNate Lawson } 50159db4265SNate Lawson 502f8146b88SJung-uk Kim /* Debug output, namespace and parse tree */ 503f8146b88SJung-uk Kim 504f8146b88SJung-uk Kim if (AslCompilerdebug && File) 5051a39cfb0SJung-uk Kim { 5061a39cfb0SJung-uk Kim AcpiOsPrintf ("/**** Before second load\n"); 5071a39cfb0SJung-uk Kim 508efcc2a30SJung-uk Kim NsSetupNamespaceListing (File); 509efcc2a30SJung-uk Kim NsDisplayNamespace (); 510f8146b88SJung-uk Kim 5111a39cfb0SJung-uk Kim AcpiOsPrintf ("*****/\n"); 5121a39cfb0SJung-uk Kim } 5131a39cfb0SJung-uk Kim 514ec3fc72fSJung-uk Kim /* Load namespace from names created within control methods */ 515ec3fc72fSJung-uk Kim 516ec3fc72fSJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, 517ec3fc72fSJung-uk Kim AcpiGbl_RootNode, OwnerId); 5181a39cfb0SJung-uk Kim 5191a39cfb0SJung-uk Kim /* 520ec3fc72fSJung-uk Kim * Cross reference the namespace here, in order to 521ec3fc72fSJung-uk Kim * generate External() statements 5221a39cfb0SJung-uk Kim */ 523ec3fc72fSJung-uk Kim AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, 524ec3fc72fSJung-uk Kim AcpiGbl_RootNode, OwnerId); 5251a39cfb0SJung-uk Kim 5261a39cfb0SJung-uk Kim if (AslCompilerdebug) 5271a39cfb0SJung-uk Kim { 5281a39cfb0SJung-uk Kim AcpiDmDumpTree (AcpiGbl_ParseOpRoot); 5291a39cfb0SJung-uk Kim } 5301a39cfb0SJung-uk Kim 5311a39cfb0SJung-uk Kim /* Find possible calls to external control methods */ 5321a39cfb0SJung-uk Kim 5331a39cfb0SJung-uk Kim AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot); 5341a39cfb0SJung-uk Kim 5351a39cfb0SJung-uk Kim /* 536ec3fc72fSJung-uk Kim * If we found any external control methods, we must reparse 537ec3fc72fSJung-uk Kim * the entire tree with the new information (namely, the 538ec3fc72fSJung-uk Kim * number of arguments per method) 5391a39cfb0SJung-uk Kim */ 540f556842eSJung-uk Kim if (AcpiDmGetExternalMethodCount ()) 5411a39cfb0SJung-uk Kim { 542f8146b88SJung-uk Kim Status = AdReparseOneTable (Table, File, OwnerId); 5431a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 5441a39cfb0SJung-uk Kim { 545f8146b88SJung-uk Kim return (Status); 5461a39cfb0SJung-uk Kim } 5471a39cfb0SJung-uk Kim } 548e0ef747bSNate Lawson 549ec3fc72fSJung-uk Kim /* 550ec3fc72fSJung-uk Kim * Now that the namespace is finalized, we can perform namespace 551ec3fc72fSJung-uk Kim * transforms. 552ec3fc72fSJung-uk Kim * 553ec3fc72fSJung-uk Kim * 1) Convert fixed-offset references to resource descriptors 554ec3fc72fSJung-uk Kim * to symbolic references (Note: modifies namespace) 555ec3fc72fSJung-uk Kim */ 556ec3fc72fSJung-uk Kim AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); 557ec3fc72fSJung-uk Kim 55859db4265SNate Lawson /* Optional displays */ 55959db4265SNate Lawson 56070e6ab8fSJung-uk Kim if (AcpiGbl_DmOpt_Disasm) 56159db4265SNate Lawson { 5628ef1a331SJung-uk Kim /* This is the real disassembly */ 5638ef1a331SJung-uk Kim 56459db4265SNate Lawson AdDisplayTables (Filename, Table); 5658ef1a331SJung-uk Kim 5668ef1a331SJung-uk Kim /* Dump hex table if requested (-vt) */ 5678ef1a331SJung-uk Kim 5688ef1a331SJung-uk Kim AcpiDmDumpDataTable (Table); 5698ef1a331SJung-uk Kim 5704c52cad2SJung-uk Kim fprintf (stderr, "Disassembly completed\n"); 5711c0e1b6dSJung-uk Kim if (File) 5721c0e1b6dSJung-uk Kim { 5734c52cad2SJung-uk Kim fprintf (stderr, "ASL Output: %s - %u bytes\n", 574313a0c13SJung-uk Kim DisasmFilename, CmGetFileSize (File)); 5751c0e1b6dSJung-uk Kim } 576313a0c13SJung-uk Kim 577313a0c13SJung-uk Kim if (Gbl_MapfileFlag) 578313a0c13SJung-uk Kim { 579313a0c13SJung-uk Kim fprintf (stderr, "%14s %s - %u bytes\n", 580313a0c13SJung-uk Kim Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, 581313a0c13SJung-uk Kim Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename, 582313a0c13SJung-uk Kim FlGetFileSize (ASL_FILE_MAP_OUTPUT)); 583313a0c13SJung-uk Kim } 5841a39cfb0SJung-uk Kim } 585f8146b88SJung-uk Kim 586f8146b88SJung-uk Kim return (AE_OK); 58759db4265SNate Lawson } 58859db4265SNate Lawson 589a9f12690SJung-uk Kim 590f8146b88SJung-uk Kim /****************************************************************************** 591f8146b88SJung-uk Kim * 592f8146b88SJung-uk Kim * FUNCTION: AdReparseOneTable 593f8146b88SJung-uk Kim * 594f8146b88SJung-uk Kim * PARAMETERS: Table - Raw AML table 595f8146b88SJung-uk Kim * File - Pointer for the input file 596f8146b88SJung-uk Kim * OwnerId - ID for this table 597f8146b88SJung-uk Kim * 598f8146b88SJung-uk Kim * RETURN: Status 599f8146b88SJung-uk Kim * 600f8146b88SJung-uk Kim * DESCRIPTION: Reparse a table that has already been loaded. Used to 601f8146b88SJung-uk Kim * integrate information about external control methods. 602f8146b88SJung-uk Kim * These methods may have been previously parsed incorrectly. 603f8146b88SJung-uk Kim * 604f8146b88SJung-uk Kim *****************************************************************************/ 605f8146b88SJung-uk Kim 606f8146b88SJung-uk Kim static ACPI_STATUS 607f8146b88SJung-uk Kim AdReparseOneTable ( 608f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 609f8146b88SJung-uk Kim FILE *File, 610f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId) 611a9f12690SJung-uk Kim { 612f8146b88SJung-uk Kim ACPI_STATUS Status; 613*0d84335fSJung-uk Kim ACPI_COMMENT_ADDR_NODE *AddrListHead; 614f8146b88SJung-uk Kim 615f8146b88SJung-uk Kim 616f8146b88SJung-uk Kim fprintf (stderr, 617f8146b88SJung-uk Kim "\nFound %u external control methods, " 618f8146b88SJung-uk Kim "reparsing with new information\n", 619f8146b88SJung-uk Kim AcpiDmGetExternalMethodCount ()); 620f8146b88SJung-uk Kim 621f8146b88SJung-uk Kim /* Reparse, rebuild namespace */ 622f8146b88SJung-uk Kim 623f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); 624f8146b88SJung-uk Kim AcpiGbl_ParseOpRoot = NULL; 625f8146b88SJung-uk Kim AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); 626f8146b88SJung-uk Kim 627f8146b88SJung-uk Kim AcpiGbl_RootNode = NULL; 628f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 629f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; 630f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; 631f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Parent = NULL; 632f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Child = NULL; 633f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Peer = NULL; 634f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Object = NULL; 635f8146b88SJung-uk Kim AcpiGbl_RootNodeStruct.Flags = 0; 636f8146b88SJung-uk Kim 637f8146b88SJung-uk Kim Status = AcpiNsRootInitialize (); 638f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 639f8146b88SJung-uk Kim { 640f8146b88SJung-uk Kim return (Status); 641a9f12690SJung-uk Kim } 642a9f12690SJung-uk Kim 643f8146b88SJung-uk Kim /* New namespace, add the external definitions first */ 644f8146b88SJung-uk Kim 645f8146b88SJung-uk Kim AcpiDmAddExternalsToNamespace (); 646f8146b88SJung-uk Kim 647*0d84335fSJung-uk Kim /* For -ca option: clear the list of comment addresses. */ 648*0d84335fSJung-uk Kim 649*0d84335fSJung-uk Kim while (AcpiGbl_CommentAddrListHead) 650*0d84335fSJung-uk Kim { 651*0d84335fSJung-uk Kim AddrListHead= AcpiGbl_CommentAddrListHead; 652*0d84335fSJung-uk Kim AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next; 653*0d84335fSJung-uk Kim AcpiOsFree(AddrListHead); 654*0d84335fSJung-uk Kim } 655*0d84335fSJung-uk Kim 656f8146b88SJung-uk Kim /* Parse the table again. No need to reload it, however */ 657f8146b88SJung-uk Kim 658f8146b88SJung-uk Kim Status = AdParseTable (Table, NULL, FALSE, FALSE); 659f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 660f8146b88SJung-uk Kim { 661f8146b88SJung-uk Kim AcpiOsPrintf ("Could not parse ACPI tables, %s\n", 662f8146b88SJung-uk Kim AcpiFormatException (Status)); 663f8146b88SJung-uk Kim return (Status); 664f8146b88SJung-uk Kim } 665f8146b88SJung-uk Kim 666f8146b88SJung-uk Kim /* Cross reference the namespace again */ 667f8146b88SJung-uk Kim 668f8146b88SJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, 669f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId); 670f8146b88SJung-uk Kim 671f8146b88SJung-uk Kim AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, 672f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId); 673f8146b88SJung-uk Kim 674f8146b88SJung-uk Kim /* Debug output - namespace and parse tree */ 675f8146b88SJung-uk Kim 676f8146b88SJung-uk Kim if (AslCompilerdebug) 677f8146b88SJung-uk Kim { 678f8146b88SJung-uk Kim AcpiOsPrintf ("/**** After second load and resource conversion\n"); 6791c0e1b6dSJung-uk Kim if (File) 68059db4265SNate Lawson { 681efcc2a30SJung-uk Kim NsSetupNamespaceListing (File); 682efcc2a30SJung-uk Kim NsDisplayNamespace (); 683ec3fc72fSJung-uk Kim } 684ec3fc72fSJung-uk Kim 685f8146b88SJung-uk Kim AcpiOsPrintf ("*****/\n"); 686f8146b88SJung-uk Kim AcpiDmDumpTree (AcpiGbl_ParseOpRoot); 68759db4265SNate Lawson } 68859db4265SNate Lawson 6898ef1a331SJung-uk Kim return (AE_OK); 69059db4265SNate Lawson } 69159db4265SNate Lawson 69259db4265SNate Lawson 693f8146b88SJung-uk Kim /****************************************************************************** 6947cf3e94aSJung-uk Kim * 695f8146b88SJung-uk Kim * FUNCTION: AdDoExternalFileList 6967cf3e94aSJung-uk Kim * 697f8146b88SJung-uk Kim * PARAMETERS: Filename - Input file for the table 6987cf3e94aSJung-uk Kim * 699f8146b88SJung-uk Kim * RETURN: Status 7007cf3e94aSJung-uk Kim * 701f8146b88SJung-uk Kim * DESCRIPTION: Process all tables found in the -e external files list 7027cf3e94aSJung-uk Kim * 703f8146b88SJung-uk Kim *****************************************************************************/ 7047cf3e94aSJung-uk Kim 7057cf3e94aSJung-uk Kim static ACPI_STATUS 706f8146b88SJung-uk Kim AdDoExternalFileList ( 707f8146b88SJung-uk Kim char *Filename) 7087cf3e94aSJung-uk Kim { 709f8146b88SJung-uk Kim ACPI_EXTERNAL_FILE *ExternalFileList; 710f8146b88SJung-uk Kim char *ExternalFilename; 711f8146b88SJung-uk Kim ACPI_NEW_TABLE_DESC *ExternalListHead = NULL; 7127cf3e94aSJung-uk Kim ACPI_STATUS Status; 713f8146b88SJung-uk Kim ACPI_STATUS GlobalStatus = AE_OK; 714f8146b88SJung-uk Kim ACPI_OWNER_ID OwnerId; 7157cf3e94aSJung-uk Kim 7167cf3e94aSJung-uk Kim 717f8146b88SJung-uk Kim /* 718f8146b88SJung-uk Kim * External filenames are specified on the command line like this: 719f8146b88SJung-uk Kim * Example: iasl -e file1,file2,file3 -d xxx.aml 720f8146b88SJung-uk Kim */ 721f8146b88SJung-uk Kim ExternalFileList = AcpiGbl_ExternalFileList; 722f8146b88SJung-uk Kim 723f8146b88SJung-uk Kim /* Process each external file */ 724f8146b88SJung-uk Kim 725f8146b88SJung-uk Kim while (ExternalFileList) 726f8146b88SJung-uk Kim { 727f8146b88SJung-uk Kim ExternalFilename = ExternalFileList->Path; 728f8146b88SJung-uk Kim if (!strcmp (ExternalFilename, Filename)) 729f8146b88SJung-uk Kim { 730f8146b88SJung-uk Kim /* Next external file */ 731f8146b88SJung-uk Kim 732f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next; 733f8146b88SJung-uk Kim continue; 734f8146b88SJung-uk Kim } 735f8146b88SJung-uk Kim 736f8146b88SJung-uk Kim AcpiOsPrintf ("External object resolution file %16s\n", 737f8146b88SJung-uk Kim ExternalFilename); 738f8146b88SJung-uk Kim 739f8146b88SJung-uk Kim Status = AcGetAllTablesFromFile ( 740f8146b88SJung-uk Kim ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead); 7417cf3e94aSJung-uk Kim if (ACPI_FAILURE (Status)) 7427cf3e94aSJung-uk Kim { 743f8146b88SJung-uk Kim if (Status == AE_TYPE) 744f8146b88SJung-uk Kim { 745f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next; 746f8146b88SJung-uk Kim GlobalStatus = AE_TYPE; 747f8146b88SJung-uk Kim Status = AE_OK; 748f8146b88SJung-uk Kim continue; 749f8146b88SJung-uk Kim } 750f8146b88SJung-uk Kim 7517cf3e94aSJung-uk Kim return (Status); 7527cf3e94aSJung-uk Kim } 7537cf3e94aSJung-uk Kim 754f8146b88SJung-uk Kim /* Load external tables for symbol resolution */ 7557cf3e94aSJung-uk Kim 756f8146b88SJung-uk Kim while (ExternalListHead) 75759db4265SNate Lawson { 758f8146b88SJung-uk Kim Status = AdParseTable ( 759f8146b88SJung-uk Kim ExternalListHead->Table, &OwnerId, TRUE, TRUE); 760f556842eSJung-uk Kim if (ACPI_FAILURE (Status)) 761f556842eSJung-uk Kim { 762f8146b88SJung-uk Kim AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", 763f8146b88SJung-uk Kim AcpiFormatException (Status)); 76459db4265SNate Lawson return (Status); 76559db4265SNate Lawson } 76659db4265SNate Lawson 767313a0c13SJung-uk Kim /* 768f8146b88SJung-uk Kim * Load namespace from names created within control methods 769f8146b88SJung-uk Kim * Set owner id of nodes in external table 770313a0c13SJung-uk Kim */ 771f8146b88SJung-uk Kim AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, 772f8146b88SJung-uk Kim AcpiGbl_RootNode, OwnerId); 773f8146b88SJung-uk Kim AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); 7741a39cfb0SJung-uk Kim 775f8146b88SJung-uk Kim ExternalListHead = ExternalListHead->Next; 776f8146b88SJung-uk Kim } 7771a39cfb0SJung-uk Kim 778f8146b88SJung-uk Kim /* Next external file */ 77959db4265SNate Lawson 780f8146b88SJung-uk Kim ExternalFileList = ExternalFileList->Next; 781f8146b88SJung-uk Kim } 782f8146b88SJung-uk Kim 783f8146b88SJung-uk Kim if (ACPI_FAILURE (GlobalStatus)) 784f8146b88SJung-uk Kim { 785f8146b88SJung-uk Kim return (GlobalStatus); 786f8146b88SJung-uk Kim } 787f8146b88SJung-uk Kim 788f8146b88SJung-uk Kim /* Clear external list generated by Scope in external tables */ 789f8146b88SJung-uk Kim 790f8146b88SJung-uk Kim if (AcpiGbl_ExternalFileList) 791f8146b88SJung-uk Kim { 792f8146b88SJung-uk Kim AcpiDmClearExternalList (); 793f8146b88SJung-uk Kim } 794f8146b88SJung-uk Kim 795f8146b88SJung-uk Kim /* Load any externals defined in the optional external ref file */ 796f8146b88SJung-uk Kim 797f8146b88SJung-uk Kim AcpiDmGetExternalsFromFile (); 7988ef1a331SJung-uk Kim return (AE_OK); 79959db4265SNate Lawson } 800