1f8146b88SJung-uk Kim /****************************************************************************** 2f8146b88SJung-uk Kim * 3f8146b88SJung-uk Kim * Module Name: dmtables - disassembler ACPI table support 4f8146b88SJung-uk Kim * 5f8146b88SJung-uk Kim *****************************************************************************/ 6f8146b88SJung-uk Kim 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 11e5e1f58aSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp. 12f8146b88SJung-uk Kim * All rights reserved. 13f8146b88SJung-uk Kim * 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 * 119f8146b88SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120f8146b88SJung-uk Kim * modification, are permitted provided that the following conditions 121f8146b88SJung-uk Kim * are met: 122f8146b88SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123f8146b88SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124f8146b88SJung-uk Kim * without modification. 125f8146b88SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126f8146b88SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127f8146b88SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128f8146b88SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129f8146b88SJung-uk Kim * binary redistribution. 130f8146b88SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131f8146b88SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132f8146b88SJung-uk Kim * from this software without specific prior written permission. 133f8146b88SJung-uk Kim * 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 147f8146b88SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148f8146b88SJung-uk Kim * Software Foundation. 149f8146b88SJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 151f8146b88SJung-uk Kim 152f8146b88SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 153f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h> 154f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 155f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/actables.h> 156f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 157493deb39SJung-uk Kim #include <contrib/dev/acpica/include/acapps.h> 1580d84335fSJung-uk Kim #include <contrib/dev/acpica/include/acmacros.h> 1590d84335fSJung-uk Kim #include <contrib/dev/acpica/include/acconvert.h> 160f8146b88SJung-uk Kim 161f8146b88SJung-uk Kim 162f8146b88SJung-uk Kim #define _COMPONENT ACPI_TOOLS 163f8146b88SJung-uk Kim ACPI_MODULE_NAME ("dmtables") 164f8146b88SJung-uk Kim 165f8146b88SJung-uk Kim 166f8146b88SJung-uk Kim /* Local prototypes */ 167f8146b88SJung-uk Kim 168f8146b88SJung-uk Kim static void 169f8146b88SJung-uk Kim AdCreateTableHeader ( 170f8146b88SJung-uk Kim char *Filename, 171f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table); 172f8146b88SJung-uk Kim 173f8146b88SJung-uk Kim static ACPI_STATUS 174f8146b88SJung-uk Kim AdStoreTable ( 175f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 176f8146b88SJung-uk Kim UINT32 *TableIndex); 177f8146b88SJung-uk Kim 178f8146b88SJung-uk Kim 179f8146b88SJung-uk Kim extern ACPI_TABLE_DESC LocalTables[1]; 180f8146b88SJung-uk Kim extern ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; 181f8146b88SJung-uk Kim 182f8146b88SJung-uk Kim 183f8146b88SJung-uk Kim /****************************************************************************** 184f8146b88SJung-uk Kim * 185f8146b88SJung-uk Kim * FUNCTION: AdDisassemblerHeader 186f8146b88SJung-uk Kim * 187f8146b88SJung-uk Kim * PARAMETERS: Filename - Input file for the table 188f8146b88SJung-uk Kim * TableType - Either AML or DataTable 189f8146b88SJung-uk Kim * 190f8146b88SJung-uk Kim * RETURN: None 191f8146b88SJung-uk Kim * 192f8146b88SJung-uk Kim * DESCRIPTION: Create the disassembler header, including ACPICA signon with 193f8146b88SJung-uk Kim * current time and date. 194f8146b88SJung-uk Kim * 195f8146b88SJung-uk Kim *****************************************************************************/ 196f8146b88SJung-uk Kim 197f8146b88SJung-uk Kim void 198f8146b88SJung-uk Kim AdDisassemblerHeader ( 199f8146b88SJung-uk Kim char *Filename, 200f8146b88SJung-uk Kim UINT8 TableType) 201f8146b88SJung-uk Kim { 202f8146b88SJung-uk Kim time_t Timer; 203f8146b88SJung-uk Kim 204f8146b88SJung-uk Kim 205f8146b88SJung-uk Kim time (&Timer); 206f8146b88SJung-uk Kim 207f8146b88SJung-uk Kim /* Header and input table info */ 208f8146b88SJung-uk Kim 209f8146b88SJung-uk Kim AcpiOsPrintf ("/*\n"); 210f8146b88SJung-uk Kim AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * ")); 211f8146b88SJung-uk Kim 212f8146b88SJung-uk Kim if (TableType == ACPI_IS_AML_TABLE) 213f8146b88SJung-uk Kim { 214f8146b88SJung-uk Kim if (AcpiGbl_CstyleDisassembly) 215f8146b88SJung-uk Kim { 216f8146b88SJung-uk Kim AcpiOsPrintf ( 217f8146b88SJung-uk Kim " * Disassembling to symbolic ASL+ operators\n" 218f8146b88SJung-uk Kim " *\n"); 219f8146b88SJung-uk Kim } 220f8146b88SJung-uk Kim else 221f8146b88SJung-uk Kim { 222f8146b88SJung-uk Kim AcpiOsPrintf ( 223f8146b88SJung-uk Kim " * Disassembling to non-symbolic legacy ASL operators\n" 224f8146b88SJung-uk Kim " *\n"); 225f8146b88SJung-uk Kim } 226f8146b88SJung-uk Kim } 227f8146b88SJung-uk Kim 228f8146b88SJung-uk Kim AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer)); 229f8146b88SJung-uk Kim AcpiOsPrintf (" *\n"); 230f8146b88SJung-uk Kim } 231f8146b88SJung-uk Kim 232f8146b88SJung-uk Kim 233f8146b88SJung-uk Kim /****************************************************************************** 234f8146b88SJung-uk Kim * 235f8146b88SJung-uk Kim * FUNCTION: AdCreateTableHeader 236f8146b88SJung-uk Kim * 237f8146b88SJung-uk Kim * PARAMETERS: Filename - Input file for the table 238f8146b88SJung-uk Kim * Table - Pointer to the raw table 239f8146b88SJung-uk Kim * 240f8146b88SJung-uk Kim * RETURN: None 241f8146b88SJung-uk Kim * 242f8146b88SJung-uk Kim * DESCRIPTION: Create the ASL table header, including ACPICA signon with 243f8146b88SJung-uk Kim * current time and date. 244f8146b88SJung-uk Kim * 245f8146b88SJung-uk Kim *****************************************************************************/ 246f8146b88SJung-uk Kim 247f8146b88SJung-uk Kim static void 248f8146b88SJung-uk Kim AdCreateTableHeader ( 249f8146b88SJung-uk Kim char *Filename, 250f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table) 251f8146b88SJung-uk Kim { 252f8146b88SJung-uk Kim UINT8 Checksum; 253f8146b88SJung-uk Kim 254f8146b88SJung-uk Kim 255f8146b88SJung-uk Kim /* Reset globals for External statements */ 256f8146b88SJung-uk Kim 257f8146b88SJung-uk Kim AcpiGbl_NumExternalMethods = 0; 258f8146b88SJung-uk Kim AcpiGbl_ResolvedExternalMethods = 0; 259f8146b88SJung-uk Kim 260f8146b88SJung-uk Kim /* 261f8146b88SJung-uk Kim * Print file header and dump original table header 262f8146b88SJung-uk Kim */ 263f8146b88SJung-uk Kim AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE); 264f8146b88SJung-uk Kim 265f8146b88SJung-uk Kim AcpiOsPrintf (" * Original Table Header:\n"); 266f8146b88SJung-uk Kim AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); 267f8146b88SJung-uk Kim AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); 268f8146b88SJung-uk Kim 269f8146b88SJung-uk Kim /* Print and validate the revision */ 270f8146b88SJung-uk Kim 271f8146b88SJung-uk Kim AcpiOsPrintf (" * Revision 0x%2.2X", Table->Revision); 272f8146b88SJung-uk Kim 273f8146b88SJung-uk Kim switch (Table->Revision) 274f8146b88SJung-uk Kim { 275f8146b88SJung-uk Kim case 0: 276f8146b88SJung-uk Kim 277f8146b88SJung-uk Kim AcpiOsPrintf (" **** Invalid Revision"); 278f8146b88SJung-uk Kim break; 279f8146b88SJung-uk Kim 280f8146b88SJung-uk Kim case 1: 281f8146b88SJung-uk Kim 282f8146b88SJung-uk Kim /* Revision of DSDT controls the ACPI integer width */ 283f8146b88SJung-uk Kim 284278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT)) 285f8146b88SJung-uk Kim { 286f8146b88SJung-uk Kim AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support"); 287f8146b88SJung-uk Kim } 288f8146b88SJung-uk Kim break; 289f8146b88SJung-uk Kim 290f8146b88SJung-uk Kim default: 291f8146b88SJung-uk Kim 292f8146b88SJung-uk Kim break; 293f8146b88SJung-uk Kim } 294f8146b88SJung-uk Kim 295f8146b88SJung-uk Kim /* Print and validate the table checksum */ 296f8146b88SJung-uk Kim 297f8146b88SJung-uk Kim AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum); 298f8146b88SJung-uk Kim 299f8146b88SJung-uk Kim Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); 300f8146b88SJung-uk Kim if (Checksum) 301f8146b88SJung-uk Kim { 302f8146b88SJung-uk Kim AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", 303f8146b88SJung-uk Kim (UINT8) (Table->Checksum - Checksum)); 304f8146b88SJung-uk Kim } 305f8146b88SJung-uk Kim 306f8146b88SJung-uk Kim AcpiOsPrintf ("\n"); 307f8146b88SJung-uk Kim AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId); 308f8146b88SJung-uk Kim AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId); 309f8146b88SJung-uk Kim AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); 310f8146b88SJung-uk Kim AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); 311f8146b88SJung-uk Kim AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); 312f8146b88SJung-uk Kim AcpiOsPrintf (" */\n"); 313f8146b88SJung-uk Kim 314f8146b88SJung-uk Kim /* 3150d84335fSJung-uk Kim * Print comments that come before this definition block. 3160d84335fSJung-uk Kim */ 317f1db5ef7SJung-uk Kim if (AcpiGbl_CaptureComments) 3180d84335fSJung-uk Kim { 3190d84335fSJung-uk Kim ASL_CV_PRINT_ONE_COMMENT(AcpiGbl_ParseOpRoot,AML_COMMENT_STANDARD, NULL, 0); 3200d84335fSJung-uk Kim } 3210d84335fSJung-uk Kim 3220d84335fSJung-uk Kim /* 323f8146b88SJung-uk Kim * Open the ASL definition block. 324f8146b88SJung-uk Kim * 325f8146b88SJung-uk Kim * Note: the AMLFilename string is left zero-length in order to just let 326f8146b88SJung-uk Kim * the compiler create it when the disassembled file is compiled. This 327f8146b88SJung-uk Kim * makes it easier to rename the disassembled ASL file if needed. 328f8146b88SJung-uk Kim */ 329f8146b88SJung-uk Kim AcpiOsPrintf ( 330a009b7dcSJung-uk Kim "DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n", 331f8146b88SJung-uk Kim Table->Signature, Table->Revision, 332f8146b88SJung-uk Kim Table->OemId, Table->OemTableId, Table->OemRevision); 333f8146b88SJung-uk Kim } 334f8146b88SJung-uk Kim 335f8146b88SJung-uk Kim 336f8146b88SJung-uk Kim /****************************************************************************** 337f8146b88SJung-uk Kim * 338f8146b88SJung-uk Kim * FUNCTION: AdDisplayTables 339f8146b88SJung-uk Kim * 340f8146b88SJung-uk Kim * PARAMETERS: Filename - Input file for the table 341f8146b88SJung-uk Kim * Table - Pointer to the raw table 342f8146b88SJung-uk Kim * 343f8146b88SJung-uk Kim * RETURN: Status 344f8146b88SJung-uk Kim * 345f8146b88SJung-uk Kim * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables 346f8146b88SJung-uk Kim * 347f8146b88SJung-uk Kim *****************************************************************************/ 348f8146b88SJung-uk Kim 349f8146b88SJung-uk Kim ACPI_STATUS 350f8146b88SJung-uk Kim AdDisplayTables ( 351f8146b88SJung-uk Kim char *Filename, 352f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table) 353f8146b88SJung-uk Kim { 354f8146b88SJung-uk Kim 355f8146b88SJung-uk Kim 356f8146b88SJung-uk Kim if (!AcpiGbl_ParseOpRoot) 357f8146b88SJung-uk Kim { 358f8146b88SJung-uk Kim return (AE_NOT_EXIST); 359f8146b88SJung-uk Kim } 360f8146b88SJung-uk Kim 361f8146b88SJung-uk Kim if (!AcpiGbl_DmOpt_Listing) 362f8146b88SJung-uk Kim { 363f8146b88SJung-uk Kim AdCreateTableHeader (Filename, Table); 364f8146b88SJung-uk Kim } 365f8146b88SJung-uk Kim 366f8146b88SJung-uk Kim AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); 367f8146b88SJung-uk Kim MpEmitMappingInfo (); 368f8146b88SJung-uk Kim 369f8146b88SJung-uk Kim if (AcpiGbl_DmOpt_Listing) 370f8146b88SJung-uk Kim { 371f8146b88SJung-uk Kim AcpiOsPrintf ("\n\nTable Header:\n"); 372f8146b88SJung-uk Kim AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER), 373f8146b88SJung-uk Kim DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 374f8146b88SJung-uk Kim 375f8146b88SJung-uk Kim AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length); 376f8146b88SJung-uk Kim AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), 377f8146b88SJung-uk Kim Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 378f8146b88SJung-uk Kim } 379f8146b88SJung-uk Kim 380f8146b88SJung-uk Kim return (AE_OK); 381f8146b88SJung-uk Kim } 382f8146b88SJung-uk Kim 383f8146b88SJung-uk Kim 384f8146b88SJung-uk Kim /******************************************************************************* 385f8146b88SJung-uk Kim * 386f8146b88SJung-uk Kim * FUNCTION: AdStoreTable 387f8146b88SJung-uk Kim * 388f8146b88SJung-uk Kim * PARAMETERS: Table - Table header 389f8146b88SJung-uk Kim * TableIndex - Where the table index is returned 390f8146b88SJung-uk Kim * 391f8146b88SJung-uk Kim * RETURN: Status and table index. 392f8146b88SJung-uk Kim * 393f8146b88SJung-uk Kim * DESCRIPTION: Add an ACPI table to the global table list 394f8146b88SJung-uk Kim * 395f8146b88SJung-uk Kim ******************************************************************************/ 396f8146b88SJung-uk Kim 397f8146b88SJung-uk Kim static ACPI_STATUS 398f8146b88SJung-uk Kim AdStoreTable ( 399f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 400f8146b88SJung-uk Kim UINT32 *TableIndex) 401f8146b88SJung-uk Kim { 402f8146b88SJung-uk Kim ACPI_STATUS Status; 403f8146b88SJung-uk Kim ACPI_TABLE_DESC *TableDesc; 404f8146b88SJung-uk Kim 405f8146b88SJung-uk Kim 406f8146b88SJung-uk Kim Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc); 407f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 408f8146b88SJung-uk Kim { 409f8146b88SJung-uk Kim return (Status); 410f8146b88SJung-uk Kim } 411f8146b88SJung-uk Kim 412f8146b88SJung-uk Kim /* Initialize added table */ 413f8146b88SJung-uk Kim 414f8146b88SJung-uk Kim AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table), 415f8146b88SJung-uk Kim ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table); 416f8146b88SJung-uk Kim Status = AcpiTbValidateTable (TableDesc); 417f8146b88SJung-uk Kim return (Status); 418f8146b88SJung-uk Kim } 419f8146b88SJung-uk Kim 420f8146b88SJung-uk Kim 421f8146b88SJung-uk Kim /****************************************************************************** 422f8146b88SJung-uk Kim * 423f8146b88SJung-uk Kim * FUNCTION: AdGetLocalTables 424f8146b88SJung-uk Kim * 425f8146b88SJung-uk Kim * PARAMETERS: None 426f8146b88SJung-uk Kim * 427f8146b88SJung-uk Kim * RETURN: Status 428f8146b88SJung-uk Kim * 429f8146b88SJung-uk Kim * DESCRIPTION: Get the ACPI tables from either memory or a file 430f8146b88SJung-uk Kim * 431f8146b88SJung-uk Kim *****************************************************************************/ 432f8146b88SJung-uk Kim 433f8146b88SJung-uk Kim ACPI_STATUS 434f8146b88SJung-uk Kim AdGetLocalTables ( 435f8146b88SJung-uk Kim void) 436f8146b88SJung-uk Kim { 437f8146b88SJung-uk Kim ACPI_STATUS Status; 438f8146b88SJung-uk Kim ACPI_TABLE_HEADER TableHeader; 439f8146b88SJung-uk Kim ACPI_TABLE_HEADER *NewTable; 440f8146b88SJung-uk Kim UINT32 TableIndex; 441f8146b88SJung-uk Kim 442f8146b88SJung-uk Kim 443f8146b88SJung-uk Kim /* Get the DSDT via table override */ 444f8146b88SJung-uk Kim 445f8146b88SJung-uk Kim ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT); 446a009b7dcSJung-uk Kim Status = AcpiOsTableOverride (&TableHeader, &NewTable); 447a009b7dcSJung-uk Kim if (ACPI_FAILURE (Status) || !NewTable) 448f8146b88SJung-uk Kim { 449f8146b88SJung-uk Kim fprintf (stderr, "Could not obtain DSDT\n"); 450f8146b88SJung-uk Kim return (AE_NO_ACPI_TABLES); 451f8146b88SJung-uk Kim } 452f8146b88SJung-uk Kim 453f8146b88SJung-uk Kim AdWriteTable (NewTable, NewTable->Length, 454f8146b88SJung-uk Kim ACPI_SIG_DSDT, NewTable->OemTableId); 455f8146b88SJung-uk Kim 456f8146b88SJung-uk Kim /* Store DSDT in the Table Manager */ 457f8146b88SJung-uk Kim 458f8146b88SJung-uk Kim Status = AdStoreTable (NewTable, &TableIndex); 459f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 460f8146b88SJung-uk Kim { 461f8146b88SJung-uk Kim fprintf (stderr, "Could not store DSDT\n"); 462f8146b88SJung-uk Kim return (AE_NO_ACPI_TABLES); 463f8146b88SJung-uk Kim } 464f8146b88SJung-uk Kim 465f8146b88SJung-uk Kim return (AE_OK); 466f8146b88SJung-uk Kim } 467f8146b88SJung-uk Kim 468f8146b88SJung-uk Kim 469f8146b88SJung-uk Kim /****************************************************************************** 470f8146b88SJung-uk Kim * 471f8146b88SJung-uk Kim * FUNCTION: AdParseTable 472f8146b88SJung-uk Kim * 473f8146b88SJung-uk Kim * PARAMETERS: Table - Pointer to the raw table 474f8146b88SJung-uk Kim * OwnerId - Returned OwnerId of the table 475f8146b88SJung-uk Kim * LoadTable - If add table to the global table list 476f8146b88SJung-uk Kim * External - If this is an external table 477f8146b88SJung-uk Kim * 478f8146b88SJung-uk Kim * RETURN: Status 479f8146b88SJung-uk Kim * 480f8146b88SJung-uk Kim * DESCRIPTION: Parse an ACPI AML table 481f8146b88SJung-uk Kim * 482f8146b88SJung-uk Kim *****************************************************************************/ 483f8146b88SJung-uk Kim 484f8146b88SJung-uk Kim ACPI_STATUS 485f8146b88SJung-uk Kim AdParseTable ( 486f8146b88SJung-uk Kim ACPI_TABLE_HEADER *Table, 487f8146b88SJung-uk Kim ACPI_OWNER_ID *OwnerId, 488f8146b88SJung-uk Kim BOOLEAN LoadTable, 489f8146b88SJung-uk Kim BOOLEAN External) 490f8146b88SJung-uk Kim { 491f8146b88SJung-uk Kim ACPI_STATUS Status = AE_OK; 492f8146b88SJung-uk Kim ACPI_WALK_STATE *WalkState; 493f8146b88SJung-uk Kim UINT8 *AmlStart; 494f8146b88SJung-uk Kim UINT32 AmlLength; 495f8146b88SJung-uk Kim UINT32 TableIndex; 496f8146b88SJung-uk Kim 497f8146b88SJung-uk Kim 498f8146b88SJung-uk Kim if (!Table) 499f8146b88SJung-uk Kim { 500f8146b88SJung-uk Kim return (AE_NOT_EXIST); 501f8146b88SJung-uk Kim } 502f8146b88SJung-uk Kim 503f8146b88SJung-uk Kim /* Pass 1: Parse everything except control method bodies */ 504f8146b88SJung-uk Kim 505f8146b88SJung-uk Kim fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature); 506f8146b88SJung-uk Kim 507f8146b88SJung-uk Kim AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); 508f8146b88SJung-uk Kim AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); 5090d84335fSJung-uk Kim ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength); 510f8146b88SJung-uk Kim 511*f9a6772eSJung-uk Kim AcpiUtSetIntegerWidth (Table->Revision); 512*f9a6772eSJung-uk Kim 513f8146b88SJung-uk Kim /* Create the root object */ 514f8146b88SJung-uk Kim 515f8146b88SJung-uk Kim AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart); 516f8146b88SJung-uk Kim if (!AcpiGbl_ParseOpRoot) 517f8146b88SJung-uk Kim { 518f8146b88SJung-uk Kim return (AE_NO_MEMORY); 519f8146b88SJung-uk Kim } 520f8146b88SJung-uk Kim 5210d84335fSJung-uk Kim #ifdef ACPI_ASL_COMPILER 522f1db5ef7SJung-uk Kim if (AcpiGbl_CaptureComments) 5230d84335fSJung-uk Kim { 5240d84335fSJung-uk Kim AcpiGbl_ParseOpRoot->Common.CvFilename = AcpiGbl_FileTreeRoot->Filename; 5250d84335fSJung-uk Kim } 5260d84335fSJung-uk Kim else 5270d84335fSJung-uk Kim { 5280d84335fSJung-uk Kim AcpiGbl_ParseOpRoot->Common.CvFilename = NULL; 5290d84335fSJung-uk Kim } 5300d84335fSJung-uk Kim #endif 5310d84335fSJung-uk Kim 532f8146b88SJung-uk Kim /* Create and initialize a new walk state */ 533f8146b88SJung-uk Kim 534f8146b88SJung-uk Kim WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL); 535f8146b88SJung-uk Kim if (!WalkState) 536f8146b88SJung-uk Kim { 537f8146b88SJung-uk Kim return (AE_NO_MEMORY); 538f8146b88SJung-uk Kim } 539f8146b88SJung-uk Kim 540f8146b88SJung-uk Kim Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot, 541f8146b88SJung-uk Kim NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); 542f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 543f8146b88SJung-uk Kim { 544f8146b88SJung-uk Kim return (Status); 545f8146b88SJung-uk Kim } 546f8146b88SJung-uk Kim 547f8146b88SJung-uk Kim WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; 548f8146b88SJung-uk Kim 549f8146b88SJung-uk Kim Status = AcpiPsParseAml (WalkState); 550f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 551f8146b88SJung-uk Kim { 552f8146b88SJung-uk Kim return (Status); 553f8146b88SJung-uk Kim } 554f8146b88SJung-uk Kim 555f8146b88SJung-uk Kim /* If LoadTable is FALSE, we are parsing the last loaded table */ 556f8146b88SJung-uk Kim 557f8146b88SJung-uk Kim TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; 558f8146b88SJung-uk Kim 559f8146b88SJung-uk Kim /* Pass 2 */ 560f8146b88SJung-uk Kim 561f8146b88SJung-uk Kim if (LoadTable) 562f8146b88SJung-uk Kim { 563f8146b88SJung-uk Kim Status = AdStoreTable (Table, &TableIndex); 564f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 565f8146b88SJung-uk Kim { 566f8146b88SJung-uk Kim return (Status); 567f8146b88SJung-uk Kim } 568f8146b88SJung-uk Kim Status = AcpiTbAllocateOwnerId (TableIndex); 569f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 570f8146b88SJung-uk Kim { 571f8146b88SJung-uk Kim return (Status); 572f8146b88SJung-uk Kim } 573f8146b88SJung-uk Kim if (OwnerId) 574f8146b88SJung-uk Kim { 575f8146b88SJung-uk Kim Status = AcpiTbGetOwnerId (TableIndex, OwnerId); 576f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 577f8146b88SJung-uk Kim { 578f8146b88SJung-uk Kim return (Status); 579f8146b88SJung-uk Kim } 580f8146b88SJung-uk Kim } 581f8146b88SJung-uk Kim } 582f8146b88SJung-uk Kim 583f8146b88SJung-uk Kim fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); 584f8146b88SJung-uk Kim 585f8146b88SJung-uk Kim Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL); 586f8146b88SJung-uk Kim if (ACPI_FAILURE (Status)) 587f8146b88SJung-uk Kim { 588f8146b88SJung-uk Kim return (Status); 589f8146b88SJung-uk Kim } 590f8146b88SJung-uk Kim 591f8146b88SJung-uk Kim /* No need to parse control methods of external table */ 592f8146b88SJung-uk Kim 593f8146b88SJung-uk Kim if (External) 594f8146b88SJung-uk Kim { 595f8146b88SJung-uk Kim return (AE_OK); 596f8146b88SJung-uk Kim } 597f8146b88SJung-uk Kim 598f8146b88SJung-uk Kim /* 599f8146b88SJung-uk Kim * Pass 3: Parse control methods and link their parse trees 600f8146b88SJung-uk Kim * into the main parse tree 601f8146b88SJung-uk Kim */ 602f8146b88SJung-uk Kim fprintf (stderr, 603f8146b88SJung-uk Kim "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); 604f8146b88SJung-uk Kim 605a009b7dcSJung-uk Kim (void) AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); 606f8146b88SJung-uk Kim fprintf (stderr, "\n"); 607f8146b88SJung-uk Kim 608f8146b88SJung-uk Kim /* Process Resource Templates */ 609f8146b88SJung-uk Kim 610f8146b88SJung-uk Kim AcpiDmFindResources (AcpiGbl_ParseOpRoot); 611f8146b88SJung-uk Kim 612f8146b88SJung-uk Kim fprintf (stderr, "Parsing completed\n"); 613f8146b88SJung-uk Kim return (AE_OK); 614f8146b88SJung-uk Kim } 615