171e38f1dSchristos /****************************************************************************** 271e38f1dSchristos * 371e38f1dSchristos * Module Name: dmtables - disassembler ACPI table support 471e38f1dSchristos * 571e38f1dSchristos *****************************************************************************/ 671e38f1dSchristos 771e38f1dSchristos /* 82c7d7e3cSchristos * Copyright (C) 2000 - 2023, Intel Corp. 971e38f1dSchristos * All rights reserved. 1071e38f1dSchristos * 1171e38f1dSchristos * Redistribution and use in source and binary forms, with or without 1271e38f1dSchristos * modification, are permitted provided that the following conditions 1371e38f1dSchristos * are met: 1471e38f1dSchristos * 1. Redistributions of source code must retain the above copyright 1571e38f1dSchristos * notice, this list of conditions, and the following disclaimer, 1671e38f1dSchristos * without modification. 1771e38f1dSchristos * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1871e38f1dSchristos * substantially similar to the "NO WARRANTY" disclaimer below 1971e38f1dSchristos * ("Disclaimer") and any redistribution must be conditioned upon 2071e38f1dSchristos * including a substantially similar Disclaimer requirement for further 2171e38f1dSchristos * binary redistribution. 2271e38f1dSchristos * 3. Neither the names of the above-listed copyright holders nor the names 2371e38f1dSchristos * of any contributors may be used to endorse or promote products derived 2471e38f1dSchristos * from this software without specific prior written permission. 2571e38f1dSchristos * 2671e38f1dSchristos * Alternatively, this software may be distributed under the terms of the 2771e38f1dSchristos * GNU General Public License ("GPL") version 2 as published by the Free 2871e38f1dSchristos * Software Foundation. 2971e38f1dSchristos * 3071e38f1dSchristos * NO WARRANTY 3171e38f1dSchristos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3271e38f1dSchristos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3398244dcfSchristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3471e38f1dSchristos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3571e38f1dSchristos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3671e38f1dSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3771e38f1dSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3871e38f1dSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3971e38f1dSchristos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4071e38f1dSchristos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4171e38f1dSchristos * POSSIBILITY OF SUCH DAMAGES. 4271e38f1dSchristos */ 4371e38f1dSchristos 4471e38f1dSchristos #include "aslcompiler.h" 4571e38f1dSchristos #include "acdispat.h" 4671e38f1dSchristos #include "acnamesp.h" 4771e38f1dSchristos #include "actables.h" 4871e38f1dSchristos #include "acparser.h" 49d0e1da26Schristos #include "acapps.h" 50835858a6Schristos #include "acmacros.h" 51835858a6Schristos #include "acconvert.h" 5271e38f1dSchristos 5371e38f1dSchristos 5471e38f1dSchristos #define _COMPONENT ACPI_TOOLS 5571e38f1dSchristos ACPI_MODULE_NAME ("dmtables") 5671e38f1dSchristos 5771e38f1dSchristos 5871e38f1dSchristos /* Local prototypes */ 5971e38f1dSchristos 6071e38f1dSchristos static void 6171e38f1dSchristos AdCreateTableHeader ( 6271e38f1dSchristos char *Filename, 6371e38f1dSchristos ACPI_TABLE_HEADER *Table); 6471e38f1dSchristos 6571e38f1dSchristos static ACPI_STATUS 6671e38f1dSchristos AdStoreTable ( 6771e38f1dSchristos ACPI_TABLE_HEADER *Table, 6871e38f1dSchristos UINT32 *TableIndex); 6971e38f1dSchristos 7071e38f1dSchristos 7171e38f1dSchristos extern ACPI_TABLE_DESC LocalTables[1]; 7271e38f1dSchristos extern ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; 7371e38f1dSchristos 7471e38f1dSchristos 7571e38f1dSchristos /****************************************************************************** 7671e38f1dSchristos * 7771e38f1dSchristos * FUNCTION: AdDisassemblerHeader 7871e38f1dSchristos * 7971e38f1dSchristos * PARAMETERS: Filename - Input file for the table 8071e38f1dSchristos * TableType - Either AML or DataTable 8171e38f1dSchristos * 8271e38f1dSchristos * RETURN: None 8371e38f1dSchristos * 8471e38f1dSchristos * DESCRIPTION: Create the disassembler header, including ACPICA signon with 85*987b04d6Schristos * optional current time and date. 8671e38f1dSchristos * 8771e38f1dSchristos *****************************************************************************/ 8871e38f1dSchristos 8971e38f1dSchristos void 9071e38f1dSchristos AdDisassemblerHeader ( 9171e38f1dSchristos char *Filename, 9271e38f1dSchristos UINT8 TableType) 9371e38f1dSchristos { 9471e38f1dSchristos time_t Timer; 9571e38f1dSchristos 9671e38f1dSchristos 9771e38f1dSchristos /* Header and input table info */ 9871e38f1dSchristos 9971e38f1dSchristos AcpiOsPrintf ("/*\n"); 10071e38f1dSchristos AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * ")); 10171e38f1dSchristos 10271e38f1dSchristos if (TableType == ACPI_IS_AML_TABLE) 10371e38f1dSchristos { 10471e38f1dSchristos if (AcpiGbl_CstyleDisassembly) 10571e38f1dSchristos { 10671e38f1dSchristos AcpiOsPrintf ( 10771e38f1dSchristos " * Disassembling to symbolic ASL+ operators\n" 10871e38f1dSchristos " *\n"); 10971e38f1dSchristos } 11071e38f1dSchristos else 11171e38f1dSchristos { 11271e38f1dSchristos AcpiOsPrintf ( 11371e38f1dSchristos " * Disassembling to non-symbolic legacy ASL operators\n" 11471e38f1dSchristos " *\n"); 11571e38f1dSchristos } 11671e38f1dSchristos } 11771e38f1dSchristos 118*987b04d6Schristos if (AslGbl_Deterministic) 119*987b04d6Schristos { 120*987b04d6Schristos AcpiOsPrintf (" * Disassembly of %s\n", Filename); 121*987b04d6Schristos } 122*987b04d6Schristos else 123*987b04d6Schristos { 124*987b04d6Schristos time (&Timer); 12571e38f1dSchristos AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer)); 126*987b04d6Schristos } 12771e38f1dSchristos AcpiOsPrintf (" *\n"); 12871e38f1dSchristos } 12971e38f1dSchristos 13071e38f1dSchristos 13171e38f1dSchristos /****************************************************************************** 13271e38f1dSchristos * 13371e38f1dSchristos * FUNCTION: AdCreateTableHeader 13471e38f1dSchristos * 13571e38f1dSchristos * PARAMETERS: Filename - Input file for the table 13671e38f1dSchristos * Table - Pointer to the raw table 13771e38f1dSchristos * 13871e38f1dSchristos * RETURN: None 13971e38f1dSchristos * 14071e38f1dSchristos * DESCRIPTION: Create the ASL table header, including ACPICA signon with 14171e38f1dSchristos * current time and date. 14271e38f1dSchristos * 14371e38f1dSchristos *****************************************************************************/ 14471e38f1dSchristos 14571e38f1dSchristos static void 14671e38f1dSchristos AdCreateTableHeader ( 14771e38f1dSchristos char *Filename, 14871e38f1dSchristos ACPI_TABLE_HEADER *Table) 14971e38f1dSchristos { 15071e38f1dSchristos UINT8 Checksum; 15171e38f1dSchristos 15271e38f1dSchristos 153cfbb7280Schristos /* Reset globals for External statements */ 154cfbb7280Schristos 155cfbb7280Schristos AcpiGbl_NumExternalMethods = 0; 156cfbb7280Schristos AcpiGbl_ResolvedExternalMethods = 0; 157cfbb7280Schristos 15871e38f1dSchristos /* 15971e38f1dSchristos * Print file header and dump original table header 16071e38f1dSchristos */ 16171e38f1dSchristos AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE); 16271e38f1dSchristos 16371e38f1dSchristos AcpiOsPrintf (" * Original Table Header:\n"); 16471e38f1dSchristos AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); 16571e38f1dSchristos AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); 16671e38f1dSchristos 16771e38f1dSchristos /* Print and validate the revision */ 16871e38f1dSchristos 16971e38f1dSchristos AcpiOsPrintf (" * Revision 0x%2.2X", Table->Revision); 17071e38f1dSchristos 17171e38f1dSchristos switch (Table->Revision) 17271e38f1dSchristos { 17371e38f1dSchristos case 0: 17471e38f1dSchristos 17571e38f1dSchristos AcpiOsPrintf (" **** Invalid Revision"); 17671e38f1dSchristos break; 17771e38f1dSchristos 17871e38f1dSchristos case 1: 17971e38f1dSchristos 18071e38f1dSchristos /* Revision of DSDT controls the ACPI integer width */ 18171e38f1dSchristos 18294783addSchristos if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT)) 18371e38f1dSchristos { 18471e38f1dSchristos AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support"); 18571e38f1dSchristos } 18671e38f1dSchristos break; 18771e38f1dSchristos 18871e38f1dSchristos default: 18971e38f1dSchristos 19071e38f1dSchristos break; 19171e38f1dSchristos } 19271e38f1dSchristos 19371e38f1dSchristos /* Print and validate the table checksum */ 19471e38f1dSchristos 195cfbb7280Schristos AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum); 19671e38f1dSchristos 197121a0548Schristos Checksum = AcpiUtChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); 19871e38f1dSchristos if (Checksum) 19971e38f1dSchristos { 20071e38f1dSchristos AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", 20171e38f1dSchristos (UINT8) (Table->Checksum - Checksum)); 20271e38f1dSchristos } 20371e38f1dSchristos 20471e38f1dSchristos AcpiOsPrintf ("\n"); 20571e38f1dSchristos AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId); 20671e38f1dSchristos AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId); 20771e38f1dSchristos AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); 20871e38f1dSchristos AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); 20971e38f1dSchristos AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); 21071e38f1dSchristos AcpiOsPrintf (" */\n"); 21171e38f1dSchristos 212cfbb7280Schristos /* 213835858a6Schristos * Print comments that come before this definition block. 214835858a6Schristos */ 215062782b3Schristos if (AcpiGbl_CaptureComments) 216835858a6Schristos { 217835858a6Schristos ASL_CV_PRINT_ONE_COMMENT(AcpiGbl_ParseOpRoot,AML_COMMENT_STANDARD, NULL, 0); 218835858a6Schristos } 219835858a6Schristos 220835858a6Schristos /* 221cfbb7280Schristos * Open the ASL definition block. 222cfbb7280Schristos * 223cfbb7280Schristos * Note: the AMLFilename string is left zero-length in order to just let 224cfbb7280Schristos * the compiler create it when the disassembled file is compiled. This 225cfbb7280Schristos * makes it easier to rename the disassembled ASL file if needed. 226cfbb7280Schristos */ 22771e38f1dSchristos AcpiOsPrintf ( 2281c663068Schristos "DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n", 229cfbb7280Schristos Table->Signature, Table->Revision, 23071e38f1dSchristos Table->OemId, Table->OemTableId, Table->OemRevision); 23171e38f1dSchristos } 23271e38f1dSchristos 23371e38f1dSchristos 23471e38f1dSchristos /****************************************************************************** 23571e38f1dSchristos * 23671e38f1dSchristos * FUNCTION: AdDisplayTables 23771e38f1dSchristos * 23871e38f1dSchristos * PARAMETERS: Filename - Input file for the table 23971e38f1dSchristos * Table - Pointer to the raw table 24071e38f1dSchristos * 24171e38f1dSchristos * RETURN: Status 24271e38f1dSchristos * 24371e38f1dSchristos * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables 24471e38f1dSchristos * 24571e38f1dSchristos *****************************************************************************/ 24671e38f1dSchristos 24771e38f1dSchristos ACPI_STATUS 24871e38f1dSchristos AdDisplayTables ( 24971e38f1dSchristos char *Filename, 25071e38f1dSchristos ACPI_TABLE_HEADER *Table) 25171e38f1dSchristos { 25271e38f1dSchristos 25371e38f1dSchristos 25471e38f1dSchristos if (!AcpiGbl_ParseOpRoot) 25571e38f1dSchristos { 25671e38f1dSchristos return (AE_NOT_EXIST); 25771e38f1dSchristos } 25871e38f1dSchristos 25971e38f1dSchristos if (!AcpiGbl_DmOpt_Listing) 26071e38f1dSchristos { 26171e38f1dSchristos AdCreateTableHeader (Filename, Table); 26271e38f1dSchristos } 26371e38f1dSchristos 26471e38f1dSchristos AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); 26571e38f1dSchristos MpEmitMappingInfo (); 26671e38f1dSchristos 26771e38f1dSchristos if (AcpiGbl_DmOpt_Listing) 26871e38f1dSchristos { 26971e38f1dSchristos AcpiOsPrintf ("\n\nTable Header:\n"); 27071e38f1dSchristos AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER), 27171e38f1dSchristos DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 27271e38f1dSchristos 27371e38f1dSchristos AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length); 27471e38f1dSchristos AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), 27571e38f1dSchristos Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 27671e38f1dSchristos } 27771e38f1dSchristos 27871e38f1dSchristos return (AE_OK); 27971e38f1dSchristos } 28071e38f1dSchristos 28171e38f1dSchristos 28271e38f1dSchristos /******************************************************************************* 28371e38f1dSchristos * 28471e38f1dSchristos * FUNCTION: AdStoreTable 28571e38f1dSchristos * 28671e38f1dSchristos * PARAMETERS: Table - Table header 28771e38f1dSchristos * TableIndex - Where the table index is returned 28871e38f1dSchristos * 28971e38f1dSchristos * RETURN: Status and table index. 29071e38f1dSchristos * 29171e38f1dSchristos * DESCRIPTION: Add an ACPI table to the global table list 29271e38f1dSchristos * 29371e38f1dSchristos ******************************************************************************/ 29471e38f1dSchristos 29571e38f1dSchristos static ACPI_STATUS 29671e38f1dSchristos AdStoreTable ( 29771e38f1dSchristos ACPI_TABLE_HEADER *Table, 29871e38f1dSchristos UINT32 *TableIndex) 29971e38f1dSchristos { 30071e38f1dSchristos ACPI_STATUS Status; 30171e38f1dSchristos ACPI_TABLE_DESC *TableDesc; 30271e38f1dSchristos 30371e38f1dSchristos 30471e38f1dSchristos Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc); 30571e38f1dSchristos if (ACPI_FAILURE (Status)) 30671e38f1dSchristos { 30771e38f1dSchristos return (Status); 30871e38f1dSchristos } 30971e38f1dSchristos 31071e38f1dSchristos /* Initialize added table */ 31171e38f1dSchristos 31271e38f1dSchristos AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table), 31371e38f1dSchristos ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table); 31471e38f1dSchristos Status = AcpiTbValidateTable (TableDesc); 31571e38f1dSchristos return (Status); 31671e38f1dSchristos } 31771e38f1dSchristos 31871e38f1dSchristos 31971e38f1dSchristos /****************************************************************************** 32071e38f1dSchristos * 32171e38f1dSchristos * FUNCTION: AdGetLocalTables 32271e38f1dSchristos * 32371e38f1dSchristos * PARAMETERS: None 32471e38f1dSchristos * 32571e38f1dSchristos * RETURN: Status 32671e38f1dSchristos * 32771e38f1dSchristos * DESCRIPTION: Get the ACPI tables from either memory or a file 32871e38f1dSchristos * 32971e38f1dSchristos *****************************************************************************/ 33071e38f1dSchristos 33171e38f1dSchristos ACPI_STATUS 33271e38f1dSchristos AdGetLocalTables ( 33371e38f1dSchristos void) 33471e38f1dSchristos { 33571e38f1dSchristos ACPI_STATUS Status; 33671e38f1dSchristos ACPI_TABLE_HEADER TableHeader; 33771e38f1dSchristos ACPI_TABLE_HEADER *NewTable; 33871e38f1dSchristos UINT32 TableIndex; 33971e38f1dSchristos 34071e38f1dSchristos 34171e38f1dSchristos /* Get the DSDT via table override */ 34271e38f1dSchristos 34371e38f1dSchristos ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT); 344783af925Schristos Status = AcpiOsTableOverride (&TableHeader, &NewTable); 345783af925Schristos if (ACPI_FAILURE (Status) || !NewTable) 34671e38f1dSchristos { 34771e38f1dSchristos fprintf (stderr, "Could not obtain DSDT\n"); 34871e38f1dSchristos return (AE_NO_ACPI_TABLES); 34971e38f1dSchristos } 35071e38f1dSchristos 35171e38f1dSchristos AdWriteTable (NewTable, NewTable->Length, 35271e38f1dSchristos ACPI_SIG_DSDT, NewTable->OemTableId); 35371e38f1dSchristos 35471e38f1dSchristos /* Store DSDT in the Table Manager */ 35571e38f1dSchristos 35671e38f1dSchristos Status = AdStoreTable (NewTable, &TableIndex); 35771e38f1dSchristos if (ACPI_FAILURE (Status)) 35871e38f1dSchristos { 35971e38f1dSchristos fprintf (stderr, "Could not store DSDT\n"); 36071e38f1dSchristos return (AE_NO_ACPI_TABLES); 36171e38f1dSchristos } 36271e38f1dSchristos 36371e38f1dSchristos return (AE_OK); 36471e38f1dSchristos } 36571e38f1dSchristos 36671e38f1dSchristos 36771e38f1dSchristos /****************************************************************************** 36871e38f1dSchristos * 36971e38f1dSchristos * FUNCTION: AdParseTable 37071e38f1dSchristos * 37171e38f1dSchristos * PARAMETERS: Table - Pointer to the raw table 37271e38f1dSchristos * OwnerId - Returned OwnerId of the table 37371e38f1dSchristos * LoadTable - If add table to the global table list 37471e38f1dSchristos * External - If this is an external table 37571e38f1dSchristos * 37671e38f1dSchristos * RETURN: Status 37771e38f1dSchristos * 37871e38f1dSchristos * DESCRIPTION: Parse an ACPI AML table 37971e38f1dSchristos * 38071e38f1dSchristos *****************************************************************************/ 38171e38f1dSchristos 38271e38f1dSchristos ACPI_STATUS 38371e38f1dSchristos AdParseTable ( 38471e38f1dSchristos ACPI_TABLE_HEADER *Table, 38571e38f1dSchristos ACPI_OWNER_ID *OwnerId, 38671e38f1dSchristos BOOLEAN LoadTable, 38771e38f1dSchristos BOOLEAN External) 38871e38f1dSchristos { 38971e38f1dSchristos ACPI_STATUS Status = AE_OK; 39071e38f1dSchristos ACPI_WALK_STATE *WalkState; 39171e38f1dSchristos UINT8 *AmlStart; 39271e38f1dSchristos UINT32 AmlLength; 39371e38f1dSchristos UINT32 TableIndex; 39471e38f1dSchristos 39571e38f1dSchristos 39671e38f1dSchristos if (!Table) 39771e38f1dSchristos { 39871e38f1dSchristos return (AE_NOT_EXIST); 39971e38f1dSchristos } 40071e38f1dSchristos 40171e38f1dSchristos /* Pass 1: Parse everything except control method bodies */ 40271e38f1dSchristos 40371e38f1dSchristos fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature); 40471e38f1dSchristos 40571e38f1dSchristos AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); 40671e38f1dSchristos AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); 40771e38f1dSchristos 4081c663068Schristos AcpiUtSetIntegerWidth (Table->Revision); 4091c663068Schristos 41071e38f1dSchristos /* Create the root object */ 41171e38f1dSchristos 41271e38f1dSchristos AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart); 41371e38f1dSchristos if (!AcpiGbl_ParseOpRoot) 41471e38f1dSchristos { 41571e38f1dSchristos return (AE_NO_MEMORY); 41671e38f1dSchristos } 41771e38f1dSchristos 418835858a6Schristos #ifdef ACPI_ASL_COMPILER 419062782b3Schristos if (AcpiGbl_CaptureComments) 420835858a6Schristos { 421835858a6Schristos AcpiGbl_ParseOpRoot->Common.CvFilename = AcpiGbl_FileTreeRoot->Filename; 422835858a6Schristos } 423835858a6Schristos else 424835858a6Schristos { 425835858a6Schristos AcpiGbl_ParseOpRoot->Common.CvFilename = NULL; 426835858a6Schristos } 427835858a6Schristos #endif 428835858a6Schristos 42971e38f1dSchristos /* Create and initialize a new walk state */ 43071e38f1dSchristos 43171e38f1dSchristos WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL); 43271e38f1dSchristos if (!WalkState) 43371e38f1dSchristos { 43471e38f1dSchristos return (AE_NO_MEMORY); 43571e38f1dSchristos } 43671e38f1dSchristos 43771e38f1dSchristos Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot, 43871e38f1dSchristos NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); 43971e38f1dSchristos if (ACPI_FAILURE (Status)) 44071e38f1dSchristos { 44171e38f1dSchristos return (Status); 44271e38f1dSchristos } 44371e38f1dSchristos 44471e38f1dSchristos WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; 44571e38f1dSchristos 44671e38f1dSchristos Status = AcpiPsParseAml (WalkState); 44771e38f1dSchristos if (ACPI_FAILURE (Status)) 44871e38f1dSchristos { 44971e38f1dSchristos return (Status); 45071e38f1dSchristos } 45171e38f1dSchristos 45271e38f1dSchristos /* If LoadTable is FALSE, we are parsing the last loaded table */ 45371e38f1dSchristos 45471e38f1dSchristos TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; 45571e38f1dSchristos 45671e38f1dSchristos /* Pass 2 */ 45771e38f1dSchristos 45871e38f1dSchristos if (LoadTable) 45971e38f1dSchristos { 46071e38f1dSchristos Status = AdStoreTable (Table, &TableIndex); 46171e38f1dSchristos if (ACPI_FAILURE (Status)) 46271e38f1dSchristos { 46371e38f1dSchristos return (Status); 46471e38f1dSchristos } 46571e38f1dSchristos Status = AcpiTbAllocateOwnerId (TableIndex); 46671e38f1dSchristos if (ACPI_FAILURE (Status)) 46771e38f1dSchristos { 46871e38f1dSchristos return (Status); 46971e38f1dSchristos } 47071e38f1dSchristos if (OwnerId) 47171e38f1dSchristos { 47271e38f1dSchristos Status = AcpiTbGetOwnerId (TableIndex, OwnerId); 47371e38f1dSchristos if (ACPI_FAILURE (Status)) 47471e38f1dSchristos { 47571e38f1dSchristos return (Status); 47671e38f1dSchristos } 47771e38f1dSchristos } 47871e38f1dSchristos } 47971e38f1dSchristos 48071e38f1dSchristos fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); 48171e38f1dSchristos 48271e38f1dSchristos Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL); 48371e38f1dSchristos if (ACPI_FAILURE (Status)) 48471e38f1dSchristos { 48571e38f1dSchristos return (Status); 48671e38f1dSchristos } 48771e38f1dSchristos 48871e38f1dSchristos /* No need to parse control methods of external table */ 48971e38f1dSchristos 49071e38f1dSchristos if (External) 49171e38f1dSchristos { 49271e38f1dSchristos return (AE_OK); 49371e38f1dSchristos } 49471e38f1dSchristos 49571e38f1dSchristos /* 49671e38f1dSchristos * Pass 3: Parse control methods and link their parse trees 49771e38f1dSchristos * into the main parse tree 49871e38f1dSchristos */ 49971e38f1dSchristos fprintf (stderr, 50071e38f1dSchristos "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); 50171e38f1dSchristos 5021c663068Schristos (void) AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); 50371e38f1dSchristos fprintf (stderr, "\n"); 50471e38f1dSchristos 50571e38f1dSchristos /* Process Resource Templates */ 50671e38f1dSchristos 50771e38f1dSchristos AcpiDmFindResources (AcpiGbl_ParseOpRoot); 50871e38f1dSchristos 50971e38f1dSchristos fprintf (stderr, "Parsing completed\n"); 51071e38f1dSchristos return (AE_OK); 51171e38f1dSchristos } 512