diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2014-09-11 21:38:09 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2014-09-11 21:38:09 +0000 |
commit | 754171ae60abbbd707ed8d449f07ef38f596bd22 (patch) | |
tree | 67d2b76905535d056ba6911186285d0325dc703f /source/compiler | |
parent | e599b42ef5047e5546af949d87d2cfd2e17062b0 (diff) |
Notes
Diffstat (limited to 'source/compiler')
59 files changed, 2610 insertions, 1632 deletions
diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index 112c1213986d..94282a081338 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include <string.h> @@ -569,3 +568,51 @@ ApCheckRegMethod ( AslError (ASL_WARNING, ASL_MSG_NO_REGION, Op, NULL); } + + +/******************************************************************************* + * + * FUNCTION: ApFindNameInScope + * + * PARAMETERS: Name - Name to search for + * Op - Current parse op + * + * RETURN: TRUE if name found in the same scope as Op. + * + * DESCRIPTION: Determine if a name appears in the same scope as Op, as either + * a Method() or a Name(). + * + ******************************************************************************/ + +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + + + /* Get the start of the current scope */ + + Parent = Op->Asl.Parent; + Next = Parent->Asl.Child; + + /* Search entire scope for a match to the name */ + + while (Next) + { + if ((Next->Asl.ParseOpcode == PARSEOP_METHOD) || + (Next->Asl.ParseOpcode == PARSEOP_NAME)) + { + if (ACPI_COMPARE_NAME (Name, Next->Asl.NameSeg)) + { + return (TRUE); + } + } + + Next = Next->Asl.Next; + } + + return (FALSE); +} diff --git a/source/compiler/aslascii.c b/source/compiler/aslascii.c new file mode 100644 index 000000000000..3fdf1ac0e22e --- /dev/null +++ b/source/compiler/aslascii.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Module Name: aslascii - ASCII detection and support routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "aslcompiler.h" +#include <acapps.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslascii") + + +/* Local prototypes */ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAcpiTable + * + * PARAMETERS: Handle - Open input file + * + * RETURN: Status + * + * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the + * following checks on what would be the table header: + * 0) File must be at least as long as an ACPI_TABLE_HEADER + * 1) The header length field must match the file size + * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAcpiTable ( + FILE *Handle) +{ + ACPI_TABLE_HEADER Table; + UINT32 FileSize; + size_t Actual; + UINT32 i; + + + /* Read a potential table header */ + + Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); + fseek (Handle, 0, SEEK_SET); + + if (Actual < sizeof (ACPI_TABLE_HEADER)) + { + return (AE_ERROR); + } + + /* Header length field must match the file size */ + + FileSize = CmGetFileSize (Handle); + if (Table.Length != FileSize) + { + return (AE_ERROR); + } + + /* + * These fields must be ASCII: + * Signature, OemId, OemTableId, AslCompilerId. + * We allow a NULL terminator in OemId and OemTableId. + */ + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) + { + return (AE_ERROR); + } + + if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) + { + return (AE_ERROR); + } + } + + printf ("Binary file appears to be a valid ACPI table, disassembling\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAscii + * + * PARAMETERS: Handle - Open input file + * Filename - Input filename + * DisplayErrors - TRUE if error messages desired + * + * RETURN: Status + * + * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters + * within comments. Note: does not handle nested comments and does + * not handle comment delimiters within string literals. However, + * on the rare chance this happens and an invalid character is + * missed, the parser will catch the error by failing in some + * spectactular manner. + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAscii ( + FILE *Handle, + char *Filename, + BOOLEAN DisplayErrors) +{ + UINT8 Byte; + ACPI_SIZE BadBytes = 0; + BOOLEAN OpeningComment = FALSE; + ASL_FILE_STATUS Status; + + + Status.Line = 1; + Status.Offset = 0; + + /* Read the entire file */ + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Ignore comment fields (allow non-ascii within) */ + + if (OpeningComment) + { + /* Check for second comment open delimiter */ + + if (Byte == '*') + { + FlConsumeAnsiComment (Handle, &Status); + } + + if (Byte == '/') + { + FlConsumeNewComment (Handle, &Status); + } + + /* Reset */ + + OpeningComment = FALSE; + } + else if (Byte == '/') + { + OpeningComment = TRUE; + } + + /* Check for an ASCII character */ + + if (!ACPI_IS_ASCII (Byte)) + { + if ((BadBytes < 10) && (DisplayErrors)) + { + AcpiOsPrintf ( + "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", + Byte, Status.Line, Status.Offset); + } + + BadBytes++; + } + + /* Update line counter */ + + else if (Byte == 0x0A) + { + Status.Line++; + } + + Status.Offset++; + } + + /* Seek back to the beginning of the source file */ + + fseek (Handle, 0, SEEK_SET); + + /* Were there any non-ASCII characters in the file? */ + + if (BadBytes) + { + if (DisplayErrors) + { + AcpiOsPrintf ( + "%u non-ASCII characters found in input source text, could be a binary file\n", + BadBytes); + AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); + } + + return (AE_BAD_CHARACTER); + } + + /* File is OK (100% ASCII) */ + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeAnsiComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a normal slash-star type comment + * + ******************************************************************************/ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + BOOLEAN ClosingComment = FALSE; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Scan until comment close is found */ + + if (ClosingComment) + { + if (Byte == '/') + { + return; + } + + if (Byte != '*') + { + /* Reset */ + + ClosingComment = FALSE; + } + } + else if (Byte == '*') + { + ClosingComment = TRUE; + } + + /* Maintain line count */ + + if (Byte == 0x0A) + { + Status->Line++; + } + + Status->Offset++; + } +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeNewComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a slash-slash type of comment + * + ******************************************************************************/ + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + Status->Offset++; + + /* Comment ends at newline */ + + if (Byte == 0x0A) + { + Status->Line++; + return; + } + } +} diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index fc61c0e3abfd..025a416705eb 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 1d10cd7903cd..8cef7555b134 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index cc1a0eb6d08e..060380a4341b 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -43,6 +43,7 @@ #include "aslcompiler.h" #include "dtcompiler.h" +#include "acnamesp.h" #include <stdio.h> #include <time.h> @@ -67,488 +68,12 @@ CmFlushSourceCode ( void); static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - -static void CmDumpAllEvents ( void); /******************************************************************************* * - * FUNCTION: AslCompilerSignon - * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None - * - * DESCRIPTION: Display compiler signon - * - ******************************************************************************/ - -void -AslCompilerSignon ( - UINT32 FileId) -{ - char *Prefix = ""; - char *UtilityName; - - - /* Set line prefix depending on the destination file type */ - - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: - case ASL_FILE_ASM_INCLUDE_OUTPUT: - - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || - (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) - { - FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - Prefix = " * "; - break; - - default: - - /* No other output types supported */ - - break; - } - - /* Running compiler or disassembler? */ - - if (Gbl_DisasmFlag) - { - UtilityName = AML_DISASSEMBLER_NAME; - } - else - { - UtilityName = ASL_COMPILER_NAME; - } - - /* Compiler signon with copyright */ - - FlPrintFile (FileId, "%s\n", Prefix); - FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); -} - - -/******************************************************************************* - * - * FUNCTION: AslCompilerFileHeader - * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None - * - * DESCRIPTION: Header used at the beginning of output files - * - ******************************************************************************/ - -void -AslCompilerFileHeader ( - UINT32 FileId) -{ - struct tm *NewTime; - time_t Aclock; - char *Prefix = ""; - - - /* Set line prefix depending on the destination file type */ - - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: - case ASL_FILE_ASM_INCLUDE_OUTPUT: - - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || - (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) - { - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - Prefix = " * "; - break; - - default: - - /* No other output types supported */ - - break; - } - - /* Compilation header with timestamp */ - - (void) time (&Aclock); - NewTime = localtime (&Aclock); - - FlPrintFile (FileId, - "%sCompilation of \"%s\" - %s%s\n", - Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), - Prefix); - - switch (FileId) - { - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - FlPrintFile (FileId, " */\n"); - break; - - default: - - /* Nothing to do for other output types */ - - break; - } -} - - -/******************************************************************************* - * - * FUNCTION: CmFlushSourceCode - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Read in any remaining source code after the parse tree - * has been constructed. - * - ******************************************************************************/ - -static void -CmFlushSourceCode ( - void) -{ - char Buffer; - - - while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) - { - AslInsertLineBuffer ((int) Buffer); - } - - AslResetCurrentLineBuffer (); -} - - -/******************************************************************************* - * - * FUNCTION: FlConsume* - * - * PARAMETERS: Handle - Open input file - * Status - File current status struct - * - * RETURN: Number of lines consumed - * - * DESCRIPTION: Step over both types of comment during check for ascii chars - * - ******************************************************************************/ - -static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - BOOLEAN ClosingComment = FALSE; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Scan until comment close is found */ - - if (ClosingComment) - { - if (Byte == '/') - { - return; - } - - if (Byte != '*') - { - /* Reset */ - - ClosingComment = FALSE; - } - } - else if (Byte == '*') - { - ClosingComment = TRUE; - } - - /* Maintain line count */ - - if (Byte == 0x0A) - { - Status->Line++; - } - - Status->Offset++; - } -} - - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - Status->Offset++; - - /* Comment ends at newline */ - - if (Byte == 0x0A) - { - Status->Line++; - return; - } - } -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAcpiTable - * - * PARAMETERS: Handle - Open input file - * - * RETURN: Status - * - * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the - * following checks on what would be the table header: - * 0) File must be at least as long as an ACPI_TABLE_HEADER - * 1) The header length field must match the file size - * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle) -{ - ACPI_TABLE_HEADER Table; - UINT32 FileSize; - size_t Actual; - UINT32 i; - - - /* Read a potential table header */ - - Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); - fseek (Handle, 0, SEEK_SET); - - if (Actual < sizeof (ACPI_TABLE_HEADER)) - { - return (AE_ERROR); - } - - /* Header length field must match the file size */ - - FileSize = CmGetFileSize (Handle); - if (Table.Length != FileSize) - { - return (AE_ERROR); - } - - /* - * These fields must be ASCII: - * Signature, OemId, OemTableId, AslCompilerId. - * We allow a NULL terminator in OemId and OemTableId. - */ - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) - { - return (AE_ERROR); - } - - if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) - { - return (AE_ERROR); - } - } - - printf ("Binary file appears to be a valid ACPI table, disassembling\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAscii - * - * PARAMETERS: Handle - Open input file - * Filename - Input filename - * DisplayErrors - TRUE if error messages desired - * - * RETURN: Status - * - * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters - * within comments. Note: does not handle nested comments and does - * not handle comment delimiters within string literals. However, - * on the rare chance this happens and an invalid character is - * missed, the parser will catch the error by failing in some - * spectactular manner. - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAscii ( - FILE *Handle, - char *Filename, - BOOLEAN DisplayErrors) -{ - UINT8 Byte; - ACPI_SIZE BadBytes = 0; - BOOLEAN OpeningComment = FALSE; - ASL_FILE_STATUS Status; - - - Status.Line = 1; - Status.Offset = 0; - - /* Read the entire file */ - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Ignore comment fields (allow non-ascii within) */ - - if (OpeningComment) - { - /* Check for second comment open delimiter */ - - if (Byte == '*') - { - FlConsumeAnsiComment (Handle, &Status); - } - - if (Byte == '/') - { - FlConsumeNewComment (Handle, &Status); - } - - /* Reset */ - - OpeningComment = FALSE; - } - else if (Byte == '/') - { - OpeningComment = TRUE; - } - - /* Check for an ASCII character */ - - if (!ACPI_IS_ASCII (Byte)) - { - if ((BadBytes < 10) && (DisplayErrors)) - { - AcpiOsPrintf ( - "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", - Byte, Status.Line, Status.Offset); - } - - BadBytes++; - } - - /* Update line counter */ - - else if (Byte == 0x0A) - { - Status.Line++; - } - - Status.Offset++; - } - - /* Seek back to the beginning of the source file */ - - fseek (Handle, 0, SEEK_SET); - - /* Were there any non-ASCII characters in the file? */ - - if (BadBytes) - { - if (DisplayErrors) - { - AcpiOsPrintf ( - "%u non-ASCII characters found in input source text, could be a binary file\n", - BadBytes); - AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); - } - - return (AE_BAD_CHARACTER); - } - - /* File is OK (100% ASCII) */ - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: CmDoCompile * * PARAMETERS: None @@ -617,7 +142,6 @@ CmDoCompile ( goto ErrorExit; } - /* Flush out any remaining source after parse tree is complete */ Event = UtBeginEvent ("Flush source input"); @@ -802,6 +326,197 @@ ErrorExit: /******************************************************************************* * + * FUNCTION: AslCompilerSignon + * + * PARAMETERS: FileId - ID of the output file + * + * RETURN: None + * + * DESCRIPTION: Display compiler signon + * + ******************************************************************************/ + +void +AslCompilerSignon ( + UINT32 FileId) +{ + char *Prefix = ""; + char *UtilityName; + + + /* Set line prefix depending on the destination file type */ + + switch (FileId) + { + case ASL_FILE_ASM_SOURCE_OUTPUT: + case ASL_FILE_ASM_INCLUDE_OUTPUT: + + Prefix = "; "; + break; + + case ASL_FILE_HEX_OUTPUT: + + if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) + { + Prefix = "; "; + } + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); + Prefix = " * "; + } + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + Prefix = " * "; + break; + + default: + + /* No other output types supported */ + + break; + } + + /* Running compiler or disassembler? */ + + if (Gbl_DisasmFlag) + { + UtilityName = AML_DISASSEMBLER_NAME; + } + else + { + UtilityName = ASL_COMPILER_NAME; + } + + /* Compiler signon with copyright */ + + FlPrintFile (FileId, "%s\n", Prefix); + FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); +} + + +/******************************************************************************* + * + * FUNCTION: AslCompilerFileHeader + * + * PARAMETERS: FileId - ID of the output file + * + * RETURN: None + * + * DESCRIPTION: Header used at the beginning of output files + * + ******************************************************************************/ + +void +AslCompilerFileHeader ( + UINT32 FileId) +{ + struct tm *NewTime; + time_t Aclock; + char *Prefix = ""; + + + /* Set line prefix depending on the destination file type */ + + switch (FileId) + { + case ASL_FILE_ASM_SOURCE_OUTPUT: + case ASL_FILE_ASM_INCLUDE_OUTPUT: + + Prefix = "; "; + break; + + case ASL_FILE_HEX_OUTPUT: + + if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) + { + Prefix = "; "; + } + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) + { + Prefix = " * "; + } + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + Prefix = " * "; + break; + + default: + + /* No other output types supported */ + + break; + } + + /* Compilation header with timestamp */ + + (void) time (&Aclock); + NewTime = localtime (&Aclock); + + FlPrintFile (FileId, + "%sCompilation of \"%s\" - %s%s\n", + Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), + Prefix); + + switch (FileId) + { + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + FlPrintFile (FileId, " */\n"); + break; + + default: + + /* Nothing to do for other output types */ + + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: CmFlushSourceCode + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Read in any remaining source code after the parse tree + * has been constructed. + * + ******************************************************************************/ + +static void +CmFlushSourceCode ( + void) +{ + char Buffer; + + + while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) + { + AslInsertLineBuffer ((int) Buffer); + } + + AslResetCurrentLineBuffer (); +} + + +/******************************************************************************* + * * FUNCTION: CmDoOutputFiles * * PARAMETERS: None @@ -965,7 +680,8 @@ CmCleanupAndExit ( * We will delete the AML file if there are errors and the * force AML output option has not been used. */ - if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && + if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && + (!Gbl_IgnoreErrors) && Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) { DeleteAmlFile = TRUE; @@ -1025,4 +741,71 @@ CmCleanupAndExit ( { FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); } + + /* Final cleanup after compiling one file */ + + CmDeleteCaches (); +} + + +/******************************************************************************* + * + * FUNCTION: CmDeleteCaches + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all local cache buffer blocks + * + ******************************************************************************/ + +void +CmDeleteCaches ( + void) +{ + UINT32 BufferCount; + ASL_CACHE_INFO *Next; + + + /* Parse Op cache */ + + BufferCount = 0; + while (Gbl_ParseOpCacheList) + { + Next = Gbl_ParseOpCacheList->Next; + ACPI_FREE (Gbl_ParseOpCacheList); + Gbl_ParseOpCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n", + Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE, + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount); + + Gbl_ParseOpCount = 0; + Gbl_ParseOpCacheNext = NULL; + Gbl_ParseOpCacheLast = NULL; + RootNode = NULL; + + /* Generic string cache */ + + BufferCount = 0; + while (Gbl_StringCacheList) + { + Next = Gbl_StringCacheList->Next; + ACPI_FREE (Gbl_StringCacheList); + Gbl_StringCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n", + Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount); + + Gbl_StringSize = 0; + Gbl_StringCount = 0; + Gbl_StringCacheNext = NULL; + Gbl_StringCacheLast = NULL; } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 40dcd692784c..1001f68966ec 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLCOMPILER_H #define __ASLCOMPILER_H @@ -111,6 +110,11 @@ AslPushInputFileStack ( FILE *InputFile, char *Filename); +void +AslParserCleanup ( + void); + + /* * aslstartup - entered from main() */ @@ -154,6 +158,14 @@ void CmCleanupAndExit ( void); +void +CmDeleteCaches ( + void); + + +/* + * aslascii - ascii support + */ ACPI_STATUS FlCheckForAcpiTable ( FILE *Handle); @@ -275,6 +287,11 @@ void ApCheckRegMethod ( ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op); + /* * aslerror - error handling/reporting @@ -890,10 +907,6 @@ void UtDisplaySummary ( UINT32 FileId); -UINT8 -UtHexCharToValue ( - int HexChar); - void UtConvertByteToHex ( UINT8 RawByte, @@ -913,13 +926,17 @@ UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length); void UtExpandLineBuffers ( void); +void +UtFreeLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, @@ -955,11 +972,6 @@ AuValidateUuid ( char *InString); ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuIdBuffer); - -ACPI_STATUS AuConvertUuidToString ( char *UuIdBuffer, char *OutString); diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 286e62815535..523241a5a557 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -110,10 +110,11 @@ NamePathTail [.]{NameSeg} [ \t] { count (0); } -"/*" { if (!AslDoComment ()) yyterminate (); } -"//" { if (!AslDoCommentType2 ()) yyterminate (); } +"/*" { if (!AslDoComment ()) {yyterminate ();} } +"//" { if (!AslDoCommentType2 ()) {yyterminate ();} } -"\"" { if (AslDoStringLiteral ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } +"\"" { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);} + else {yyterminate ();} } ";" { count (0); return(';'); } @@ -607,7 +608,7 @@ NamePathTail [.]{NameSeg} {NameSeg} { char *s; count (0); - s=malloc (ACPI_NAME_SIZE + 1); + s=UtStringCacheCalloc (ACPI_NAME_SIZE + 1); if (strcmp (AslCompilertext, "\\")) { strcpy (s, "____"); @@ -620,10 +621,9 @@ NamePathTail [.]{NameSeg} {NameString} { char *s; count (0); - s=malloc (strlen (AslCompilertext)+1); + s=UtStringCacheCalloc (strlen (AslCompilertext)+1); AcpiUtStrupr (AslCompilertext); strcpy (s, AslCompilertext); - s[strlen (AslCompilertext)] = 0; AslCompilerlval.s = s; DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); return (PARSEOP_NAMESTRING); } @@ -639,9 +639,9 @@ NamePathTail [.]{NameSeg} AslCompilererror (MsgBuffer);} <<EOF>> { if (AslPopInputFileStack ()) - yyterminate(); + {yyterminate();} else - return (PARSEOP_INCLUDE_END);}; + {return (PARSEOP_INCLUDE_END);} }; %% diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 9e42a302563f..c76b4a070b27 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLDEFINE_H #define __ASLDEFINE_H @@ -55,14 +54,14 @@ #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0A" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.1" /* Configuration constants */ #define ASL_MAX_ERROR_COUNT 200 -#define ASL_NODE_CACHE_SIZE 1024 -#define ASL_STRING_CACHE_SIZE 32768 +#define ASL_PARSEOP_CACHE_SIZE (1024 * 16) +#define ASL_STRING_CACHE_SIZE (1024 * 64) #define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS #define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */ diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 14ca99d02ba1..fee96ec0ae26 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -557,7 +557,7 @@ AslCommonError2 ( { /* Allocate a buffer for the message and a new error node */ - MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -571,7 +571,7 @@ AslCommonError2 ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -643,7 +643,7 @@ AslCommonError ( { /* Allocate a buffer for the message and a new error node */ - MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -654,7 +654,7 @@ AslCommonError ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 56d006b5ad7b..6bde7080f8c6 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -319,6 +319,8 @@ FlCloseFile ( AslAbort (); } + /* Do not clear/free the filename string */ + Gbl_Files[FileId].Handle = NULL; return; } diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 514c119d6b49..722e0ee9b620 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -107,6 +107,8 @@ FlSetFilename ( DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n", Filename, Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free any existing filename */ + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; } @@ -216,14 +218,14 @@ FlMergePathnames ( (*FilePathname == '/') || (FilePathname[1] == ':')) { - Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1); + Pathname = UtStringCacheCalloc (strlen (FilePathname) + 1); strcpy (Pathname, FilePathname); goto ConvertBackslashes; } /* Need a local copy of the prefix directory path */ - CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1); + CommonPath = UtStringCacheCalloc (strlen (PrefixDir) + 1); strcpy (CommonPath, PrefixDir); /* @@ -259,14 +261,13 @@ FlMergePathnames ( /* Build the final merged pathname */ ConcatenatePaths: - Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2); + Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2); if (LastElement && *CommonPath) { strcpy (Pathname, CommonPath); strcat (Pathname, "/"); } strcat (Pathname, FilePathname); - ACPI_FREE (CommonPath); /* Convert all backslashes to normal slashes */ diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index 5035c25a34ae..579997516ad1 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 2707f4da8d42..e347e694f86c 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLGLOBAL_H #define __ASLGLOBAL_H @@ -63,11 +62,6 @@ #ifdef _DECLARE_GLOBALS UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; -char AslHexLookup[] = -{ - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -}; - /* Table below must match ASL_FILE_TYPES in asltypes.h */ @@ -92,7 +86,6 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = #else extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern char AslHexLookup[]; extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; #endif @@ -102,12 +95,20 @@ extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; */ extern int yydebug; extern FILE *AslCompilerin; -extern int AslCompilerdebug; extern int DtParserdebug; extern int PrParserdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; extern char *AslCompilertext; +/* + * Older versions of Bison won't emit this external in the generated header. + * Newer versions do emit the external, so we don't need to do it. + */ +#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H +extern int AslCompilerdebug; +#endif + + #define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */ #define ASL_MSG_BUFFER_SIZE 4096 #define ASL_MAX_DISABLED_MESSAGES 32 @@ -207,6 +208,20 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocated, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0); +/* Local caches */ + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ParseOpCount, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_ParseOpCacheList, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheNext, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheLast, NULL); + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringCount, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringSize, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_StringCacheList, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); + + /* Misc */ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); @@ -215,10 +230,6 @@ ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0); ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c index 6405fada9e5b..38766a4db964 100644 --- a/source/compiler/aslhex.c +++ b/source/compiler/aslhex.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index c6938bd6d08d..13af96a00d37 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index 9b1b2afdf924..ff02d5362f05 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -129,6 +129,7 @@ LdLoadNamespace ( /* Dump the namespace if debug is enabled */ AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); + ACPI_FREE (WalkState); return (AE_OK); } diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index f0c79f7e8a6a..67c037e1eca8 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 3034281b3dcf..25dca949054a 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -327,6 +327,7 @@ main ( ACPI_STATUS Status; int Index1; int Index2; + int ReturnStatus = 0; /* @@ -392,16 +393,24 @@ main ( Status = AslDoOneFile (argv[Index2]); if (ACPI_FAILURE (Status)) { - return (-1); + ReturnStatus = -1; + goto CleanupAndExit; } Index2++; } + +CleanupAndExit: + + UtFreeLineBuffers (); + + AslParserCleanup (); + if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalFileList(); } - return (0); + return (ReturnStatus); } diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 926bc465cb68..30b479e1b749 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -233,6 +233,9 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_WRITE */ "Could not write file", /* ASL_MSG_RANGE */ "Constant out of range", /* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", +/* ASL_MSG_MISSING_DEPENDENCY */ "Missing dependency", +/* ASL_MSG_ILLEGAL_FORWARD_REF */ "Illegal forward reference within a method", +/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods" }; /* Table compiler */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 851d46c59ca1..ba0c22b1d297 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -235,6 +235,9 @@ typedef enum ASL_MSG_WRITE, ASL_MSG_RANGE, ASL_MSG_BUFFER_ALLOCATION, + ASL_MSG_MISSING_DEPENDENCY, + ASL_MSG_ILLEGAL_FORWARD_REF, + ASL_MSG_ILLEGAL_METHOD_REF, /* These messages are used by the Data Table compiler only */ diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index a9b064082757..0a5cee2835db 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" @@ -108,6 +107,41 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; + /* + * Special handling for _PSx methods. Dependency rules (same scope): + * + * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3 + * 2) _PS1/_PS2/_PS3: A _PS0 must exist + */ + if (ACPI_COMPARE_NAME (METHOD_NAME__PS0, Op->Asl.NameSeg)) + { + /* For _PS0, one of _PS1/_PS2/_PS3 must exist */ + + if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS2, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS3, Op))) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "_PS0 requires one of _PS1/_PS2/_PS3 in same scope"); + } + } + else if ( + ACPI_COMPARE_NAME (METHOD_NAME__PS1, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS2, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS3, Op->Asl.NameSeg)) + { + /* For _PS1/_PS2/_PS3, a _PS0 must exist */ + + if (!ApFindNameInScope (METHOD_NAME__PS0, Op)) + { + sprintf (MsgBuffer, + "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg); + + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + MsgBuffer); + } + } + /* Get the name node */ Next = Op->Asl.Child; @@ -359,6 +393,17 @@ MtMethodAnalysisWalkBegin ( break; case PARSEOP_DEVICE: + + Next = Op->Asl.Child; + + if (!ApFindNameInScope (METHOD_NAME__HID, Next) && + !ApFindNameInScope (METHOD_NAME__ADR, Next)) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "Device object requires a _HID or _ADR in same scope"); + } + break; + case PARSEOP_EVENT: case PARSEOP_MUTEX: case PARSEOP_OPERATIONREGION: diff --git a/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c index 140e0d4362b7..ede0ff9400d0 100644 --- a/source/compiler/aslnamesp.c +++ b/source/compiler/aslnamesp.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acnamesp.h" diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index 7c1cd5b98970..1ad47532bc3b 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -623,10 +622,10 @@ OpcDoEisaId ( (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 | (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 | - (UtHexCharToValue (InString[3])) << 12 | - (UtHexCharToValue (InString[4])) << 8 | - (UtHexCharToValue (InString[5])) << 4 | - UtHexCharToValue (InString[6]); + (AcpiUtAsciiCharToHex (InString[3])) << 12 | + (AcpiUtAsciiCharToHex (InString[4])) << 8 | + (AcpiUtAsciiCharToHex (InString[5])) << 4 | + AcpiUtAsciiCharToHex (InString[6]); /* Swap to little-endian to get final ID (see function header) */ @@ -666,7 +665,7 @@ OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { char *InString; - char *Buffer; + UINT8 *Buffer; ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *NewOp; @@ -681,7 +680,7 @@ OpcDoUuId ( } else { - (void) AuConvertStringToUuid (InString, Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 4a0f294a330e..b6cf4a4564b2 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -913,8 +912,8 @@ OpnDoDefinitionBlock ( * We will use the AML filename that is embedded in the source file * for the output filename. */ - Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) + - strlen ((char *) Child->Asl.Value.Buffer) + 1); + Filename = UtStringCacheCalloc (strlen (Gbl_DirectoryPath) + + strlen ((char *) Child->Asl.Value.Buffer) + 1); /* Prepend the current directory path */ @@ -969,7 +968,7 @@ OpnDoDefinitionBlock ( if (Child->Asl.Value.String) { Length = ACPI_STRLEN (Child->Asl.Value.String); - Gbl_TableId = AcpiOsAllocate (Length + 1); + Gbl_TableId = UtStringCacheCalloc (Length + 1); ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); /* diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index 05dd27bf5d6e..1e9b55b93ad0 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" @@ -168,7 +167,7 @@ OptSearchToRoot ( /* We must allocate a new string for the name (TargetPath gets deleted) */ - *NewPath = ACPI_ALLOCATE_ZEROED (ACPI_NAME_SIZE + 1); + *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1); ACPI_STRCPY (*NewPath, Path); if (ACPI_STRNCMP (*NewPath, "_T_", 3)) diff --git a/source/compiler/aslparser.y b/source/compiler/aslparser.y new file mode 100644 index 000000000000..bf4a8a74991c --- /dev/null +++ b/source/compiler/aslparser.y @@ -0,0 +1,129 @@ +%{ +/****************************************************************************** + * + * Module Name: aslparser.y - Master Bison/Yacc input file for iASL + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "aslcompiler.h" +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslparse") + +/* + * Global Notes: + * + * October 2005: The following list terms have been optimized (from the + * original ASL grammar in the ACPI specification) to force the immediate + * reduction of each list item so that the parse stack use doesn't increase on + * each list element and possibly overflow on very large lists (>4000 items). + * This dramatically reduces use of the parse stack overall. + * + * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, + * ResourceMacroList, and FieldUnitList + */ + +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#define static +#undef malloc +#define malloc AslLocalAllocate +#undef alloca +#define alloca AslLocalAllocate +#define yytname AslCompilername + +#define YYINITDEPTH 600 /* State stack depth */ +#define YYDEBUG 1 /* Enable debug output */ +#define YYERROR_VERBOSE 1 /* Verbose error messages */ +#define YYFLAG -32768 + +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ + +#define YYMALLOC malloc +#define YYFREE free +%} + +/* + * Declare the type of values in the grammar + */ +%union { + UINT64 i; + char *s; + ACPI_PARSE_OBJECT *n; +} + +/* + * These shift/reduce conflicts are expected. There should be zero + * reduce/reduce conflicts. + */ +%expect 86 + +/*! [Begin] no source code translation */ + +/* + * The M4 macro processor is used to bring in the parser items, + * in order to keep this master file smaller, and to break up + * the various parser items. + */ +m4_define(NoEcho) + +/* Token types */ + +m4_include(asltokens.y) + +/* Production types/names */ + +m4_include(asltypes.y) +%% + +/* Production rules */ + +m4_include(aslrules.y) +%% + +/*! [End] no source code translation !*/ + +/* Local support functions in C */ + +m4_include(aslsupport.y) diff --git a/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index b4f96955def5..f6fed5366a70 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -289,6 +289,41 @@ ApCheckPackage ( Package, 1, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package contains a variable list of UUID Buffer/Package pairs */ + + /* The length of the package must be even */ + + if (Count & 1) + { + sprintf (MsgBuffer, "%4.4s: Package length, %d, must be even.", + Predefined->Info.Name, Count); + + AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, + ParentOp->Asl.Child, MsgBuffer); + } + + /* Validate the alternating types */ + + for (i = 0; i < Count; ++i) + { + if (i & 1) + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType2, i); + } + else + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType1, i); + } + + Op = Op->Asl.Next; + } + + break; + case ACPI_PTYPE2: case ACPI_PTYPE2_FIXED: case ACPI_PTYPE2_MIN: diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index ce2c4b5c8804..f123990cc233 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -123,22 +122,10 @@ RsSmallAddressCheck ( return; } - /* Special case for Memory24, values are compressed */ - - if (Type == ACPI_RESOURCE_NAME_MEMORY24) - { - if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */ - { - Alignment = ACPI_UINT16_MAX + 1; - } - - Minimum <<= 8; - Maximum <<= 8; - Length *= 256; - } - - /* IO descriptor has different definition of min/max, don't check */ - + /* + * Range checks for Memory24 and Memory32. + * IO descriptor has different definition of min/max, don't check. + */ if (Type != ACPI_RESOURCE_NAME_IO) { /* Basic checks on Min/Max/Length */ @@ -151,6 +138,19 @@ RsSmallAddressCheck ( { AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); } + + /* Special case for Memory24, min/max values are compressed */ + + if (Type == ACPI_RESOURCE_NAME_MEMORY24) + { + if (!Alignment) /* Alignment==0 means 64K alignment */ + { + Alignment = ACPI_UINT16_MAX + 1; + } + + Minimum <<= 8; + Maximum <<= 8; + } } /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ diff --git a/source/compiler/aslrestype1.c b/source/compiler/aslrestype1.c index 602e0091cb7b..73f3efe6cabf 100644 --- a/source/compiler/aslrestype1.c +++ b/source/compiler/aslrestype1.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype1i.c b/source/compiler/aslrestype1i.c index 5a68500fc825..bc16d728200c 100644 --- a/source/compiler/aslrestype1i.c +++ b/source/compiler/aslrestype1i.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2.c b/source/compiler/aslrestype2.c index a1e2fbb63e56..9579fe4423ce 100644 --- a/source/compiler/aslrestype2.c +++ b/source/compiler/aslrestype2.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslrestype2d.c b/source/compiler/aslrestype2d.c index d9a560c2f5f7..297f99a2cb3b 100644 --- a/source/compiler/aslrestype2d.c +++ b/source/compiler/aslrestype2d.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2e.c b/source/compiler/aslrestype2e.c index fa2c611dfc66..08590cc57317 100644 --- a/source/compiler/aslrestype2e.c +++ b/source/compiler/aslrestype2e.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/source/compiler/aslrestype2q.c b/source/compiler/aslrestype2q.c index 6ee163973e64..0bd32e79b3bc 100644 --- a/source/compiler/aslrestype2q.c +++ b/source/compiler/aslrestype2q.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2s.c b/source/compiler/aslrestype2s.c index dc42eb79aff1..c607899b5fbe 100644 --- a/source/compiler/aslrestype2s.c +++ b/source/compiler/aslrestype2s.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslrestype2w.c b/source/compiler/aslrestype2w.c index efdf2e7118ac..7f58babf2108 100644 --- a/source/compiler/aslrestype2w.c +++ b/source/compiler/aslrestype2w.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslrules.y index 6860e726d57a..2bc48db11f6a 100644 --- a/source/compiler/aslcompiler.y +++ b/source/compiler/aslrules.y @@ -1,7 +1,7 @@ -%{ +NoEcho(' /****************************************************************************** * - * Module Name: aslcompiler.y - Bison/Yacc input file (ASL grammar and actions) + * Module Name: aslrules.y - Bison/Yacc production rules * *****************************************************************************/ @@ -42,755 +42,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include "aslcompiler.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "acpi.h" -#include "accommon.h" +') -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslparse") - -/* - * Global Notes: - * - * October 2005: The following list terms have been optimized (from the - * original ASL grammar in the ACPI specification) to force the immediate - * reduction of each list item so that the parse stack use doesn't increase on - * each list element and possibly overflow on very large lists (>4000 items). - * This dramatically reduces use of the parse stack overall. - * - * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, - * ResourceMacroList, and FieldUnitList - */ - -void * AslLocalAllocate (unsigned int Size); - -/* Bison/yacc configuration */ - -#define static -#undef alloca -#define alloca AslLocalAllocate -#define yytname AslCompilername - -#define YYINITDEPTH 600 /* State stack depth */ -#define YYDEBUG 1 /* Enable debug output */ -#define YYERROR_VERBOSE 1 /* Verbose error messages */ - -/* Define YYMALLOC/YYFREE to prevent redefinition errors */ - -#define YYMALLOC malloc -#define YYFREE free - -/* - * The windows version of bison defines this incorrectly as "32768" (Not negative). - * We use a custom (edited binary) version of bison that defines YYFLAG as YYFBAD - * instead (#define YYFBAD 32768), so we can define it correctly here. - * - * The problem is that if YYFLAG is positive, the extended syntax error messages - * are disabled. - */ -#define YYFLAG -32768 - -%} - -/* - * Declare the type of values in the grammar - */ -%union { - UINT64 i; - char *s; - ACPI_PARSE_OBJECT *n; -} - -/*! [Begin] no source code translation */ - -/* - * These shift/reduce conflicts are expected. There should be zero - * reduce/reduce conflicts. - */ -%expect 86 - -/****************************************************************************** - * - * Token types: These are returned by the lexer - * - * NOTE: This list MUST match the AslKeywordMapping table found - * in aslmap.c EXACTLY! Double check any changes! - * - *****************************************************************************/ - -%token <i> PARSEOP_ACCESSAS -%token <i> PARSEOP_ACCESSATTRIB_BLOCK -%token <i> PARSEOP_ACCESSATTRIB_BLOCK_CALL -%token <i> PARSEOP_ACCESSATTRIB_BYTE -%token <i> PARSEOP_ACCESSATTRIB_MULTIBYTE -%token <i> PARSEOP_ACCESSATTRIB_QUICK -%token <i> PARSEOP_ACCESSATTRIB_RAW_BYTES -%token <i> PARSEOP_ACCESSATTRIB_RAW_PROCESS -%token <i> PARSEOP_ACCESSATTRIB_SND_RCV -%token <i> PARSEOP_ACCESSATTRIB_WORD -%token <i> PARSEOP_ACCESSATTRIB_WORD_CALL -%token <i> PARSEOP_ACCESSTYPE_ANY -%token <i> PARSEOP_ACCESSTYPE_BUF -%token <i> PARSEOP_ACCESSTYPE_BYTE -%token <i> PARSEOP_ACCESSTYPE_DWORD -%token <i> PARSEOP_ACCESSTYPE_QWORD -%token <i> PARSEOP_ACCESSTYPE_WORD -%token <i> PARSEOP_ACQUIRE -%token <i> PARSEOP_ADD -%token <i> PARSEOP_ADDRESSINGMODE_7BIT -%token <i> PARSEOP_ADDRESSINGMODE_10BIT -%token <i> PARSEOP_ADDRESSTYPE_ACPI -%token <i> PARSEOP_ADDRESSTYPE_MEMORY -%token <i> PARSEOP_ADDRESSTYPE_NVS -%token <i> PARSEOP_ADDRESSTYPE_RESERVED -%token <i> PARSEOP_ALIAS -%token <i> PARSEOP_AND -%token <i> PARSEOP_ARG0 -%token <i> PARSEOP_ARG1 -%token <i> PARSEOP_ARG2 -%token <i> PARSEOP_ARG3 -%token <i> PARSEOP_ARG4 -%token <i> PARSEOP_ARG5 -%token <i> PARSEOP_ARG6 -%token <i> PARSEOP_BANKFIELD -%token <i> PARSEOP_BITSPERBYTE_EIGHT -%token <i> PARSEOP_BITSPERBYTE_FIVE -%token <i> PARSEOP_BITSPERBYTE_NINE -%token <i> PARSEOP_BITSPERBYTE_SEVEN -%token <i> PARSEOP_BITSPERBYTE_SIX -%token <i> PARSEOP_BREAK -%token <i> PARSEOP_BREAKPOINT -%token <i> PARSEOP_BUFFER -%token <i> PARSEOP_BUSMASTERTYPE_MASTER -%token <i> PARSEOP_BUSMASTERTYPE_NOTMASTER -%token <i> PARSEOP_BYTECONST -%token <i> PARSEOP_CASE -%token <i> PARSEOP_CLOCKPHASE_FIRST -%token <i> PARSEOP_CLOCKPHASE_SECOND -%token <i> PARSEOP_CLOCKPOLARITY_HIGH -%token <i> PARSEOP_CLOCKPOLARITY_LOW -%token <i> PARSEOP_CONCATENATE -%token <i> PARSEOP_CONCATENATERESTEMPLATE -%token <i> PARSEOP_CONDREFOF -%token <i> PARSEOP_CONNECTION -%token <i> PARSEOP_CONTINUE -%token <i> PARSEOP_COPYOBJECT -%token <i> PARSEOP_CREATEBITFIELD -%token <i> PARSEOP_CREATEBYTEFIELD -%token <i> PARSEOP_CREATEDWORDFIELD -%token <i> PARSEOP_CREATEFIELD -%token <i> PARSEOP_CREATEQWORDFIELD -%token <i> PARSEOP_CREATEWORDFIELD -%token <i> PARSEOP_DATABUFFER -%token <i> PARSEOP_DATATABLEREGION -%token <i> PARSEOP_DEBUG -%token <i> PARSEOP_DECODETYPE_POS -%token <i> PARSEOP_DECODETYPE_SUB -%token <i> PARSEOP_DECREMENT -%token <i> PARSEOP_DEFAULT -%token <i> PARSEOP_DEFAULT_ARG -%token <i> PARSEOP_DEFINITIONBLOCK -%token <i> PARSEOP_DEREFOF -%token <i> PARSEOP_DEVICE -%token <i> PARSEOP_DEVICEPOLARITY_HIGH -%token <i> PARSEOP_DEVICEPOLARITY_LOW -%token <i> PARSEOP_DIVIDE -%token <i> PARSEOP_DMA -%token <i> PARSEOP_DMATYPE_A -%token <i> PARSEOP_DMATYPE_COMPATIBILITY -%token <i> PARSEOP_DMATYPE_B -%token <i> PARSEOP_DMATYPE_F -%token <i> PARSEOP_DWORDCONST -%token <i> PARSEOP_DWORDIO -%token <i> PARSEOP_DWORDMEMORY -%token <i> PARSEOP_DWORDSPACE -%token <i> PARSEOP_EISAID -%token <i> PARSEOP_ELSE -%token <i> PARSEOP_ELSEIF -%token <i> PARSEOP_ENDDEPENDENTFN -%token <i> PARSEOP_ENDIAN_BIG -%token <i> PARSEOP_ENDIAN_LITTLE -%token <i> PARSEOP_ENDTAG -%token <i> PARSEOP_ERRORNODE -%token <i> PARSEOP_EVENT -%token <i> PARSEOP_EXTENDEDIO -%token <i> PARSEOP_EXTENDEDMEMORY -%token <i> PARSEOP_EXTENDEDSPACE -%token <i> PARSEOP_EXTERNAL -%token <i> PARSEOP_FATAL -%token <i> PARSEOP_FIELD -%token <i> PARSEOP_FINDSETLEFTBIT -%token <i> PARSEOP_FINDSETRIGHTBIT -%token <i> PARSEOP_FIXEDDMA -%token <i> PARSEOP_FIXEDIO -%token <i> PARSEOP_FLOWCONTROL_HW -%token <i> PARSEOP_FLOWCONTROL_NONE -%token <i> PARSEOP_FLOWCONTROL_SW -%token <i> PARSEOP_FROMBCD -%token <i> PARSEOP_FUNCTION -%token <i> PARSEOP_GPIO_INT -%token <i> PARSEOP_GPIO_IO -%token <i> PARSEOP_I2C_SERIALBUS -%token <i> PARSEOP_IF -%token <i> PARSEOP_INCLUDE -%token <i> PARSEOP_INCLUDE_END -%token <i> PARSEOP_INCREMENT -%token <i> PARSEOP_INDEX -%token <i> PARSEOP_INDEXFIELD -%token <i> PARSEOP_INTEGER -%token <i> PARSEOP_INTERRUPT -%token <i> PARSEOP_INTLEVEL_ACTIVEBOTH -%token <i> PARSEOP_INTLEVEL_ACTIVEHIGH -%token <i> PARSEOP_INTLEVEL_ACTIVELOW -%token <i> PARSEOP_INTTYPE_EDGE -%token <i> PARSEOP_INTTYPE_LEVEL -%token <i> PARSEOP_IO -%token <i> PARSEOP_IODECODETYPE_10 -%token <i> PARSEOP_IODECODETYPE_16 -%token <i> PARSEOP_IORESTRICT_IN -%token <i> PARSEOP_IORESTRICT_NONE -%token <i> PARSEOP_IORESTRICT_OUT -%token <i> PARSEOP_IORESTRICT_PRESERVE -%token <i> PARSEOP_IRQ -%token <i> PARSEOP_IRQNOFLAGS -%token <i> PARSEOP_LAND -%token <i> PARSEOP_LEQUAL -%token <i> PARSEOP_LGREATER -%token <i> PARSEOP_LGREATEREQUAL -%token <i> PARSEOP_LLESS -%token <i> PARSEOP_LLESSEQUAL -%token <i> PARSEOP_LNOT -%token <i> PARSEOP_LNOTEQUAL -%token <i> PARSEOP_LOAD -%token <i> PARSEOP_LOADTABLE -%token <i> PARSEOP_LOCAL0 -%token <i> PARSEOP_LOCAL1 -%token <i> PARSEOP_LOCAL2 -%token <i> PARSEOP_LOCAL3 -%token <i> PARSEOP_LOCAL4 -%token <i> PARSEOP_LOCAL5 -%token <i> PARSEOP_LOCAL6 -%token <i> PARSEOP_LOCAL7 -%token <i> PARSEOP_LOCKRULE_LOCK -%token <i> PARSEOP_LOCKRULE_NOLOCK -%token <i> PARSEOP_LOR -%token <i> PARSEOP_MATCH -%token <i> PARSEOP_MATCHTYPE_MEQ -%token <i> PARSEOP_MATCHTYPE_MGE -%token <i> PARSEOP_MATCHTYPE_MGT -%token <i> PARSEOP_MATCHTYPE_MLE -%token <i> PARSEOP_MATCHTYPE_MLT -%token <i> PARSEOP_MATCHTYPE_MTR -%token <i> PARSEOP_MAXTYPE_FIXED -%token <i> PARSEOP_MAXTYPE_NOTFIXED -%token <i> PARSEOP_MEMORY24 -%token <i> PARSEOP_MEMORY32 -%token <i> PARSEOP_MEMORY32FIXED -%token <i> PARSEOP_MEMTYPE_CACHEABLE -%token <i> PARSEOP_MEMTYPE_NONCACHEABLE -%token <i> PARSEOP_MEMTYPE_PREFETCHABLE -%token <i> PARSEOP_MEMTYPE_WRITECOMBINING -%token <i> PARSEOP_METHOD -%token <i> PARSEOP_METHODCALL -%token <i> PARSEOP_MID -%token <i> PARSEOP_MINTYPE_FIXED -%token <i> PARSEOP_MINTYPE_NOTFIXED -%token <i> PARSEOP_MOD -%token <i> PARSEOP_MULTIPLY -%token <i> PARSEOP_MUTEX -%token <i> PARSEOP_NAME -%token <s> PARSEOP_NAMESEG -%token <s> PARSEOP_NAMESTRING -%token <i> PARSEOP_NAND -%token <i> PARSEOP_NOOP -%token <i> PARSEOP_NOR -%token <i> PARSEOP_NOT -%token <i> PARSEOP_NOTIFY -%token <i> PARSEOP_OBJECTTYPE -%token <i> PARSEOP_OBJECTTYPE_BFF -%token <i> PARSEOP_OBJECTTYPE_BUF -%token <i> PARSEOP_OBJECTTYPE_DDB -%token <i> PARSEOP_OBJECTTYPE_DEV -%token <i> PARSEOP_OBJECTTYPE_EVT -%token <i> PARSEOP_OBJECTTYPE_FLD -%token <i> PARSEOP_OBJECTTYPE_INT -%token <i> PARSEOP_OBJECTTYPE_MTH -%token <i> PARSEOP_OBJECTTYPE_MTX -%token <i> PARSEOP_OBJECTTYPE_OPR -%token <i> PARSEOP_OBJECTTYPE_PKG -%token <i> PARSEOP_OBJECTTYPE_POW -%token <i> PARSEOP_OBJECTTYPE_PRO -%token <i> PARSEOP_OBJECTTYPE_STR -%token <i> PARSEOP_OBJECTTYPE_THZ -%token <i> PARSEOP_OBJECTTYPE_UNK -%token <i> PARSEOP_OFFSET -%token <i> PARSEOP_ONE -%token <i> PARSEOP_ONES -%token <i> PARSEOP_OPERATIONREGION -%token <i> PARSEOP_OR -%token <i> PARSEOP_PACKAGE -%token <i> PARSEOP_PACKAGE_LENGTH -%token <i> PARSEOP_PARITYTYPE_EVEN -%token <i> PARSEOP_PARITYTYPE_MARK -%token <i> PARSEOP_PARITYTYPE_NONE -%token <i> PARSEOP_PARITYTYPE_ODD -%token <i> PARSEOP_PARITYTYPE_SPACE -%token <i> PARSEOP_PIN_NOPULL -%token <i> PARSEOP_PIN_PULLDEFAULT -%token <i> PARSEOP_PIN_PULLDOWN -%token <i> PARSEOP_PIN_PULLUP -%token <i> PARSEOP_POWERRESOURCE -%token <i> PARSEOP_PROCESSOR -%token <i> PARSEOP_QWORDCONST -%token <i> PARSEOP_QWORDIO -%token <i> PARSEOP_QWORDMEMORY -%token <i> PARSEOP_QWORDSPACE -%token <i> PARSEOP_RANGETYPE_ENTIRE -%token <i> PARSEOP_RANGETYPE_ISAONLY -%token <i> PARSEOP_RANGETYPE_NONISAONLY -%token <i> PARSEOP_RAW_DATA -%token <i> PARSEOP_READWRITETYPE_BOTH -%token <i> PARSEOP_READWRITETYPE_READONLY -%token <i> PARSEOP_REFOF -%token <i> PARSEOP_REGIONSPACE_CMOS -%token <i> PARSEOP_REGIONSPACE_EC -%token <i> PARSEOP_REGIONSPACE_FFIXEDHW -%token <i> PARSEOP_REGIONSPACE_GPIO -%token <i> PARSEOP_REGIONSPACE_GSBUS -%token <i> PARSEOP_REGIONSPACE_IO -%token <i> PARSEOP_REGIONSPACE_IPMI -%token <i> PARSEOP_REGIONSPACE_MEM -%token <i> PARSEOP_REGIONSPACE_PCC -%token <i> PARSEOP_REGIONSPACE_PCI -%token <i> PARSEOP_REGIONSPACE_PCIBAR -%token <i> PARSEOP_REGIONSPACE_SMBUS -%token <i> PARSEOP_REGISTER -%token <i> PARSEOP_RELEASE -%token <i> PARSEOP_RESERVED_BYTES -%token <i> PARSEOP_RESET -%token <i> PARSEOP_RESOURCETEMPLATE -%token <i> PARSEOP_RESOURCETYPE_CONSUMER -%token <i> PARSEOP_RESOURCETYPE_PRODUCER -%token <i> PARSEOP_RETURN -%token <i> PARSEOP_REVISION -%token <i> PARSEOP_SCOPE -%token <i> PARSEOP_SERIALIZERULE_NOTSERIAL -%token <i> PARSEOP_SERIALIZERULE_SERIAL -%token <i> PARSEOP_SHARETYPE_EXCLUSIVE -%token <i> PARSEOP_SHARETYPE_EXCLUSIVEWAKE -%token <i> PARSEOP_SHARETYPE_SHARED -%token <i> PARSEOP_SHARETYPE_SHAREDWAKE -%token <i> PARSEOP_SHIFTLEFT -%token <i> PARSEOP_SHIFTRIGHT -%token <i> PARSEOP_SIGNAL -%token <i> PARSEOP_SIZEOF -%token <i> PARSEOP_SLAVEMODE_CONTROLLERINIT -%token <i> PARSEOP_SLAVEMODE_DEVICEINIT -%token <i> PARSEOP_SLEEP -%token <i> PARSEOP_SPI_SERIALBUS -%token <i> PARSEOP_STALL -%token <i> PARSEOP_STARTDEPENDENTFN -%token <i> PARSEOP_STARTDEPENDENTFN_NOPRI -%token <i> PARSEOP_STOPBITS_ONE -%token <i> PARSEOP_STOPBITS_ONEPLUSHALF -%token <i> PARSEOP_STOPBITS_TWO -%token <i> PARSEOP_STOPBITS_ZERO -%token <i> PARSEOP_STORE -%token <s> PARSEOP_STRING_LITERAL -%token <i> PARSEOP_SUBTRACT -%token <i> PARSEOP_SWITCH -%token <i> PARSEOP_THERMALZONE -%token <i> PARSEOP_TIMER -%token <i> PARSEOP_TOBCD -%token <i> PARSEOP_TOBUFFER -%token <i> PARSEOP_TODECIMALSTRING -%token <i> PARSEOP_TOHEXSTRING -%token <i> PARSEOP_TOINTEGER -%token <i> PARSEOP_TOSTRING -%token <i> PARSEOP_TOUUID -%token <i> PARSEOP_TRANSLATIONTYPE_DENSE -%token <i> PARSEOP_TRANSLATIONTYPE_SPARSE -%token <i> PARSEOP_TYPE_STATIC -%token <i> PARSEOP_TYPE_TRANSLATION -%token <i> PARSEOP_UART_SERIALBUS -%token <i> PARSEOP_UNICODE -%token <i> PARSEOP_UNLOAD -%token <i> PARSEOP_UPDATERULE_ONES -%token <i> PARSEOP_UPDATERULE_PRESERVE -%token <i> PARSEOP_UPDATERULE_ZEROS -%token <i> PARSEOP_VAR_PACKAGE -%token <i> PARSEOP_VENDORLONG -%token <i> PARSEOP_VENDORSHORT -%token <i> PARSEOP_WAIT -%token <i> PARSEOP_WHILE -%token <i> PARSEOP_WIREMODE_FOUR -%token <i> PARSEOP_WIREMODE_THREE -%token <i> PARSEOP_WORDBUSNUMBER -%token <i> PARSEOP_WORDCONST -%token <i> PARSEOP_WORDIO -%token <i> PARSEOP_WORDSPACE -%token <i> PARSEOP_XFERSIZE_8 -%token <i> PARSEOP_XFERSIZE_16 -%token <i> PARSEOP_XFERSIZE_32 -%token <i> PARSEOP_XFERSIZE_64 -%token <i> PARSEOP_XFERSIZE_128 -%token <i> PARSEOP_XFERSIZE_256 -%token <i> PARSEOP_XFERTYPE_8 -%token <i> PARSEOP_XFERTYPE_8_16 -%token <i> PARSEOP_XFERTYPE_16 -%token <i> PARSEOP_XOR -%token <i> PARSEOP_ZERO - -/* - * Special functions. These should probably stay at the end of this - * table. - */ -%token <i> PARSEOP___DATE__ -%token <i> PARSEOP___FILE__ -%token <i> PARSEOP___LINE__ -%token <i> PARSEOP___PATH__ - - -/****************************************************************************** - * - * Production names - * - *****************************************************************************/ - -%type <n> ArgList -%type <n> ASLCode -%type <n> BufferData -%type <n> BufferTermData -%type <n> CompilerDirective -%type <n> DataObject -%type <n> DefinitionBlockTerm -%type <n> IntegerData -%type <n> NamedObject -%type <n> NameSpaceModifier -%type <n> Object -%type <n> ObjectList -%type <n> PackageData -%type <n> ParameterTypePackage -%type <n> ParameterTypePackageList -%type <n> ParameterTypesPackage -%type <n> ParameterTypesPackageList -%type <n> RequiredTarget -%type <n> SimpleTarget -%type <n> StringData -%type <n> Target -%type <n> Term -%type <n> TermArg -%type <n> TermList -%type <n> UserTerm - -/* Type4Opcode is obsolete */ - -%type <n> Type1Opcode -%type <n> Type2BufferOpcode -%type <n> Type2BufferOrStringOpcode -%type <n> Type2IntegerOpcode -%type <n> Type2Opcode -%type <n> Type2StringOpcode -%type <n> Type3Opcode -%type <n> Type5Opcode -%type <n> Type6Opcode - -%type <n> AccessAsTerm -%type <n> ExternalTerm -%type <n> FieldUnit -%type <n> FieldUnitEntry -%type <n> FieldUnitList -%type <n> IncludeTerm -%type <n> OffsetTerm -%type <n> OptionalAccessAttribTerm - -/* Named Objects */ - -%type <n> BankFieldTerm -%type <n> CreateBitFieldTerm -%type <n> CreateByteFieldTerm -%type <n> CreateDWordFieldTerm -%type <n> CreateFieldTerm -%type <n> CreateQWordFieldTerm -%type <n> CreateWordFieldTerm -%type <n> DataRegionTerm -%type <n> DeviceTerm -%type <n> EventTerm -%type <n> FieldTerm -%type <n> FunctionTerm -%type <n> IndexFieldTerm -%type <n> MethodTerm -%type <n> MutexTerm -%type <n> OpRegionTerm -%type <n> OpRegionSpaceIdTerm -%type <n> PowerResTerm -%type <n> ProcessorTerm -%type <n> ThermalZoneTerm - -/* Namespace modifiers */ - -%type <n> AliasTerm -%type <n> NameTerm -%type <n> ScopeTerm - -/* Type 1 opcodes */ - -%type <n> BreakPointTerm -%type <n> BreakTerm -%type <n> CaseDefaultTermList -%type <n> CaseTerm -%type <n> ContinueTerm -%type <n> DefaultTerm -%type <n> ElseTerm -%type <n> FatalTerm -%type <n> IfElseTerm -%type <n> IfTerm -%type <n> LoadTerm -%type <n> NoOpTerm -%type <n> NotifyTerm -%type <n> ReleaseTerm -%type <n> ResetTerm -%type <n> ReturnTerm -%type <n> SignalTerm -%type <n> SleepTerm -%type <n> StallTerm -%type <n> SwitchTerm -%type <n> UnloadTerm -%type <n> WhileTerm -/* %type <n> CaseTermList */ - -/* Type 2 opcodes */ - -%type <n> AcquireTerm -%type <n> AddTerm -%type <n> AndTerm -%type <n> ConcatResTerm -%type <n> ConcatTerm -%type <n> CondRefOfTerm -%type <n> CopyObjectTerm -%type <n> DecTerm -%type <n> DerefOfTerm -%type <n> DivideTerm -%type <n> FindSetLeftBitTerm -%type <n> FindSetRightBitTerm -%type <n> FromBCDTerm -%type <n> IncTerm -%type <n> IndexTerm -%type <n> LAndTerm -%type <n> LEqualTerm -%type <n> LGreaterEqualTerm -%type <n> LGreaterTerm -%type <n> LLessEqualTerm -%type <n> LLessTerm -%type <n> LNotEqualTerm -%type <n> LNotTerm -%type <n> LoadTableTerm -%type <n> LOrTerm -%type <n> MatchTerm -%type <n> MidTerm -%type <n> ModTerm -%type <n> MultiplyTerm -%type <n> NAndTerm -%type <n> NOrTerm -%type <n> NotTerm -%type <n> ObjectTypeTerm -%type <n> OrTerm -%type <n> RefOfTerm -%type <n> ShiftLeftTerm -%type <n> ShiftRightTerm -%type <n> SizeOfTerm -%type <n> StoreTerm -%type <n> SubtractTerm -%type <n> TimerTerm -%type <n> ToBCDTerm -%type <n> ToBufferTerm -%type <n> ToDecimalStringTerm -%type <n> ToHexStringTerm -%type <n> ToIntegerTerm -%type <n> ToStringTerm -%type <n> WaitTerm -%type <n> XOrTerm - -/* Keywords */ - -%type <n> AccessAttribKeyword -%type <n> AccessTypeKeyword -%type <n> AddressingModeKeyword -%type <n> AddressKeyword -%type <n> AddressSpaceKeyword -%type <n> BitsPerByteKeyword -%type <n> ClockPhaseKeyword -%type <n> ClockPolarityKeyword -%type <n> DecodeKeyword -%type <n> DevicePolarityKeyword -%type <n> DMATypeKeyword -%type <n> EndianKeyword -%type <n> FlowControlKeyword -%type <n> InterruptLevel -%type <n> InterruptTypeKeyword -%type <n> IODecodeKeyword -%type <n> IoRestrictionKeyword -%type <n> LockRuleKeyword -%type <n> MatchOpKeyword -%type <n> MaxKeyword -%type <n> MemTypeKeyword -%type <n> MinKeyword -%type <n> ObjectTypeKeyword -%type <n> OptionalBusMasterKeyword -%type <n> OptionalReadWriteKeyword -%type <n> ParityTypeKeyword -%type <n> PinConfigByte -%type <n> PinConfigKeyword -%type <n> RangeTypeKeyword -%type <n> RegionSpaceKeyword -%type <n> ResourceTypeKeyword -%type <n> SerializeRuleKeyword -%type <n> ShareTypeKeyword -%type <n> SlaveModeKeyword -%type <n> StopBitsKeyword -%type <n> TranslationKeyword -%type <n> TypeKeyword -%type <n> UpdateRuleKeyword -%type <n> WireModeKeyword -%type <n> XferSizeKeyword -%type <n> XferTypeKeyword - -/* Types */ - -%type <n> SuperName -%type <n> ObjectTypeName -%type <n> ArgTerm -%type <n> LocalTerm -%type <n> DebugTerm - -%type <n> Integer -%type <n> ByteConst -%type <n> WordConst -%type <n> DWordConst -%type <n> QWordConst -%type <n> String - -%type <n> ConstTerm -%type <n> ConstExprTerm -%type <n> ByteConstExpr -%type <n> WordConstExpr -%type <n> DWordConstExpr -%type <n> QWordConstExpr - -%type <n> DWordList -%type <n> BufferTerm -%type <n> ByteList - -%type <n> PackageElement -%type <n> PackageList -%type <n> PackageTerm -%type <n> VarPackageLengthTerm - -/* Macros */ - -%type <n> EISAIDTerm -%type <n> ResourceMacroList -%type <n> ResourceMacroTerm -%type <n> ResourceTemplateTerm -%type <n> ToUUIDTerm -%type <n> UnicodeTerm - -/* Resource Descriptors */ - -%type <n> ConnectionTerm -%type <n> DataBufferTerm -%type <n> DMATerm -%type <n> DWordIOTerm -%type <n> DWordMemoryTerm -%type <n> DWordSpaceTerm -%type <n> EndDependentFnTerm -%type <n> ExtendedIOTerm -%type <n> ExtendedMemoryTerm -%type <n> ExtendedSpaceTerm -%type <n> FixedDmaTerm -%type <n> FixedIOTerm -%type <n> GpioIntTerm -%type <n> GpioIoTerm -%type <n> I2cSerialBusTerm -%type <n> InterruptTerm -%type <n> IOTerm -%type <n> IRQNoFlagsTerm -%type <n> IRQTerm -%type <n> Memory24Term -%type <n> Memory32FixedTerm -%type <n> Memory32Term -%type <n> NameSeg -%type <n> NameString -%type <n> QWordIOTerm -%type <n> QWordMemoryTerm -%type <n> QWordSpaceTerm -%type <n> RegisterTerm -%type <n> SpiSerialBusTerm -%type <n> StartDependentFnNoPriTerm -%type <n> StartDependentFnTerm -%type <n> UartSerialBusTerm -%type <n> VendorLongTerm -%type <n> VendorShortTerm -%type <n> WordBusNumberTerm -%type <n> WordIOTerm -%type <n> WordSpaceTerm - -/* Local types that help construct the AML, not in ACPI spec */ - -%type <n> AmlPackageLengthTerm -%type <n> IncludeEndTerm -%type <n> NameStringItem -%type <n> TermArgItem - -%type <n> OptionalAccessSize -%type <n> OptionalAddressingMode -%type <n> OptionalAddressRange -%type <n> OptionalBitsPerByte -%type <n> OptionalBuffer_Last -%type <n> OptionalByteConstExpr -%type <n> OptionalCount -%type <n> OptionalDecodeType -%type <n> OptionalDevicePolarity -%type <n> OptionalDWordConstExpr -%type <n> OptionalEndian -%type <n> OptionalFlowControl -%type <n> OptionalIoRestriction -%type <n> OptionalListString -%type <n> OptionalMaxType -%type <n> OptionalMemType -%type <n> OptionalMinType -%type <n> OptionalNameString -%type <n> OptionalNameString_First -%type <n> OptionalNameString_Last -%type <n> OptionalObjectTypeKeyword -%type <n> OptionalParameterTypePackage -%type <n> OptionalParameterTypesPackage -%type <n> OptionalParityType -%type <n> OptionalQWordConstExpr -%type <n> OptionalRangeType -%type <n> OptionalReference -%type <n> OptionalResourceType -%type <n> OptionalResourceType_First -%type <n> OptionalReturnArg -%type <n> OptionalSerializeRuleKeyword -%type <n> OptionalShareType -%type <n> OptionalShareType_First -%type <n> OptionalSlaveMode -%type <n> OptionalStopBits -%type <n> OptionalStringData -%type <n> OptionalTermArg -%type <n> OptionalTranslationType_Last -%type <n> OptionalType -%type <n> OptionalType_Last -%type <n> OptionalWireMode -%type <n> OptionalWordConst -%type <n> OptionalWordConstExpr -%type <n> OptionalXferSize - -%% /******************************************************************************* * * Production rules start here @@ -799,10 +52,7 @@ void * AslLocalAllocate (unsigned int Size); /* * ASL Names - */ - - -/* + * * Root rule. Allow multiple #line directives before the definition block * to handle output from preprocessors */ @@ -3511,77 +2761,3 @@ OptionalXferSize | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} | ',' XferSizeKeyword {$$ = $2;} ; - -%% -/****************************************************************************** - * - * Local support functions - * - *****************************************************************************/ - -int -AslCompilerwrap(void) -{ - return (1); -} - -/*! [End] no source code translation !*/ - -void * -AslLocalAllocate (unsigned int Size) -{ - void *Mem; - - - DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); - - Mem = ACPI_ALLOCATE_ZEROED (Size); - if (!Mem) - { - AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_InputByteCount, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); - exit (1); - } - - return (Mem); -} - -ACPI_PARSE_OBJECT * -AslDoError (void) -{ - - - return (TrCreateLeafNode (PARSEOP_ERRORNODE)); - -} - - -/******************************************************************************* - * - * FUNCTION: UtGetOpName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * - * RETURN: Pointer to the opcode name - * - * DESCRIPTION: Get the ascii name of the parse opcode - * - ******************************************************************************/ - -char * -UtGetOpName ( - UINT32 ParseOpcode) -{ -#ifdef ASL_YYTNAME_START - /* - * First entries (ASL_YYTNAME_START) in yytname are special reserved names. - * Ignore first 8 characters of the name - */ - return ((char *) yytname - [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); -#else - return ("[Unknown parser generator]"); -#endif -} diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index 1ed69724d2b0..84a23dbeb463 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "actables.h" #include "acdisasm.h" @@ -284,8 +283,11 @@ AslDoDisassembly ( return (AE_CTRL_CONTINUE); } - ACPI_FREE (Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free the filename string */ + Gbl_Files[ASL_FILE_INPUT].Filename = NULL; + + CmDeleteCaches (); return (AE_OK); } @@ -325,8 +327,13 @@ AslDoOneFile ( return (Status); } - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; - UtConvertBackslashes (Filename); + /* Take a copy of the input filename, convert any backslashes */ + + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + UtConvertBackslashes (Gbl_Files[ASL_FILE_INPUT].Filename); /* * AML Disassembly (Optional) @@ -396,7 +403,6 @@ AslDoOneFile ( if (Gbl_Signature) { - ACPI_FREE (Gbl_Signature); Gbl_Signature = NULL; } diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 0317041b4e98..7ea43a07dba7 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* Configuration */ #define ASL_SPACES_PER_TAB 4 @@ -70,6 +69,15 @@ typedef struct asl_file_node ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; +void +AslParserCleanup ( + void) +{ + + yy_delete_buffer (YY_CURRENT_BUFFER); +} + + /******************************************************************************* * * FUNCTION: AslDoLineDirective @@ -259,7 +267,11 @@ AslPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_CurrentLineNumber = 1; yyin = InputFile; } @@ -797,7 +809,7 @@ CompletedString: */ *StringBuffer = 0; - CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); + CleanString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); if (!CleanString) { AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, diff --git a/source/compiler/aslsupport.y b/source/compiler/aslsupport.y new file mode 100644 index 000000000000..a1fdec3437d2 --- /dev/null +++ b/source/compiler/aslsupport.y @@ -0,0 +1,119 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslsupport.y - Bison/Yacc C support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Local support functions + * + *****************************************************************************/ + +/*! [Begin] no source code translation */ +int +AslCompilerwrap(void) +{ + return (1); +} +/*! [End] no source code translation !*/ + + +void * +AslLocalAllocate (unsigned int Size) +{ + void *Mem; + + + DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); + + Mem = UtStringCacheCalloc (Size); + if (!Mem) + { + AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_InputByteCount, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + exit (1); + } + + return (Mem); +} + +ACPI_PARSE_OBJECT * +AslDoError (void) +{ + + + return (TrCreateLeafNode (PARSEOP_ERRORNODE)); + +} + + +/******************************************************************************* + * + * FUNCTION: UtGetOpName + * + * PARAMETERS: ParseOpcode - Parser keyword ID + * + * RETURN: Pointer to the opcode name + * + * DESCRIPTION: Get the ascii name of the parse opcode + * + ******************************************************************************/ + +char * +UtGetOpName ( + UINT32 ParseOpcode) +{ +#ifdef ASL_YYTNAME_START + /* + * First entries (ASL_YYTNAME_START) in yytname are special reserved names. + * Ignore first 8 characters of the name + */ + return ((char *) yytname + [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); +#else + return ("[Unknown parser generator]"); +#endif +} diff --git a/source/compiler/asltokens.y b/source/compiler/asltokens.y new file mode 100644 index 000000000000..c296fea30bec --- /dev/null +++ b/source/compiler/asltokens.y @@ -0,0 +1,386 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltokens.y - Bison/Yacc token types + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Token types: These are returned by the lexer + * + * NOTE: This list MUST match the AslKeywordMapping table found + * in aslmap.c EXACTLY! Double check any changes! + * + *****************************************************************************/ + +%token <i> PARSEOP_ACCESSAS +%token <i> PARSEOP_ACCESSATTRIB_BLOCK +%token <i> PARSEOP_ACCESSATTRIB_BLOCK_CALL +%token <i> PARSEOP_ACCESSATTRIB_BYTE +%token <i> PARSEOP_ACCESSATTRIB_MULTIBYTE +%token <i> PARSEOP_ACCESSATTRIB_QUICK +%token <i> PARSEOP_ACCESSATTRIB_RAW_BYTES +%token <i> PARSEOP_ACCESSATTRIB_RAW_PROCESS +%token <i> PARSEOP_ACCESSATTRIB_SND_RCV +%token <i> PARSEOP_ACCESSATTRIB_WORD +%token <i> PARSEOP_ACCESSATTRIB_WORD_CALL +%token <i> PARSEOP_ACCESSTYPE_ANY +%token <i> PARSEOP_ACCESSTYPE_BUF +%token <i> PARSEOP_ACCESSTYPE_BYTE +%token <i> PARSEOP_ACCESSTYPE_DWORD +%token <i> PARSEOP_ACCESSTYPE_QWORD +%token <i> PARSEOP_ACCESSTYPE_WORD +%token <i> PARSEOP_ACQUIRE +%token <i> PARSEOP_ADD +%token <i> PARSEOP_ADDRESSINGMODE_7BIT +%token <i> PARSEOP_ADDRESSINGMODE_10BIT +%token <i> PARSEOP_ADDRESSTYPE_ACPI +%token <i> PARSEOP_ADDRESSTYPE_MEMORY +%token <i> PARSEOP_ADDRESSTYPE_NVS +%token <i> PARSEOP_ADDRESSTYPE_RESERVED +%token <i> PARSEOP_ALIAS +%token <i> PARSEOP_AND +%token <i> PARSEOP_ARG0 +%token <i> PARSEOP_ARG1 +%token <i> PARSEOP_ARG2 +%token <i> PARSEOP_ARG3 +%token <i> PARSEOP_ARG4 +%token <i> PARSEOP_ARG5 +%token <i> PARSEOP_ARG6 +%token <i> PARSEOP_BANKFIELD +%token <i> PARSEOP_BITSPERBYTE_EIGHT +%token <i> PARSEOP_BITSPERBYTE_FIVE +%token <i> PARSEOP_BITSPERBYTE_NINE +%token <i> PARSEOP_BITSPERBYTE_SEVEN +%token <i> PARSEOP_BITSPERBYTE_SIX +%token <i> PARSEOP_BREAK +%token <i> PARSEOP_BREAKPOINT +%token <i> PARSEOP_BUFFER +%token <i> PARSEOP_BUSMASTERTYPE_MASTER +%token <i> PARSEOP_BUSMASTERTYPE_NOTMASTER +%token <i> PARSEOP_BYTECONST +%token <i> PARSEOP_CASE +%token <i> PARSEOP_CLOCKPHASE_FIRST +%token <i> PARSEOP_CLOCKPHASE_SECOND +%token <i> PARSEOP_CLOCKPOLARITY_HIGH +%token <i> PARSEOP_CLOCKPOLARITY_LOW +%token <i> PARSEOP_CONCATENATE +%token <i> PARSEOP_CONCATENATERESTEMPLATE +%token <i> PARSEOP_CONDREFOF +%token <i> PARSEOP_CONNECTION +%token <i> PARSEOP_CONTINUE +%token <i> PARSEOP_COPYOBJECT +%token <i> PARSEOP_CREATEBITFIELD +%token <i> PARSEOP_CREATEBYTEFIELD +%token <i> PARSEOP_CREATEDWORDFIELD +%token <i> PARSEOP_CREATEFIELD +%token <i> PARSEOP_CREATEQWORDFIELD +%token <i> PARSEOP_CREATEWORDFIELD +%token <i> PARSEOP_DATABUFFER +%token <i> PARSEOP_DATATABLEREGION +%token <i> PARSEOP_DEBUG +%token <i> PARSEOP_DECODETYPE_POS +%token <i> PARSEOP_DECODETYPE_SUB +%token <i> PARSEOP_DECREMENT +%token <i> PARSEOP_DEFAULT +%token <i> PARSEOP_DEFAULT_ARG +%token <i> PARSEOP_DEFINITIONBLOCK +%token <i> PARSEOP_DEREFOF +%token <i> PARSEOP_DEVICE +%token <i> PARSEOP_DEVICEPOLARITY_HIGH +%token <i> PARSEOP_DEVICEPOLARITY_LOW +%token <i> PARSEOP_DIVIDE +%token <i> PARSEOP_DMA +%token <i> PARSEOP_DMATYPE_A +%token <i> PARSEOP_DMATYPE_COMPATIBILITY +%token <i> PARSEOP_DMATYPE_B +%token <i> PARSEOP_DMATYPE_F +%token <i> PARSEOP_DWORDCONST +%token <i> PARSEOP_DWORDIO +%token <i> PARSEOP_DWORDMEMORY +%token <i> PARSEOP_DWORDSPACE +%token <i> PARSEOP_EISAID +%token <i> PARSEOP_ELSE +%token <i> PARSEOP_ELSEIF +%token <i> PARSEOP_ENDDEPENDENTFN +%token <i> PARSEOP_ENDIAN_BIG +%token <i> PARSEOP_ENDIAN_LITTLE +%token <i> PARSEOP_ENDTAG +%token <i> PARSEOP_ERRORNODE +%token <i> PARSEOP_EVENT +%token <i> PARSEOP_EXTENDEDIO +%token <i> PARSEOP_EXTENDEDMEMORY +%token <i> PARSEOP_EXTENDEDSPACE +%token <i> PARSEOP_EXTERNAL +%token <i> PARSEOP_FATAL +%token <i> PARSEOP_FIELD +%token <i> PARSEOP_FINDSETLEFTBIT +%token <i> PARSEOP_FINDSETRIGHTBIT +%token <i> PARSEOP_FIXEDDMA +%token <i> PARSEOP_FIXEDIO +%token <i> PARSEOP_FLOWCONTROL_HW +%token <i> PARSEOP_FLOWCONTROL_NONE +%token <i> PARSEOP_FLOWCONTROL_SW +%token <i> PARSEOP_FROMBCD +%token <i> PARSEOP_FUNCTION +%token <i> PARSEOP_GPIO_INT +%token <i> PARSEOP_GPIO_IO +%token <i> PARSEOP_I2C_SERIALBUS +%token <i> PARSEOP_IF +%token <i> PARSEOP_INCLUDE +%token <i> PARSEOP_INCLUDE_END +%token <i> PARSEOP_INCREMENT +%token <i> PARSEOP_INDEX +%token <i> PARSEOP_INDEXFIELD +%token <i> PARSEOP_INTEGER +%token <i> PARSEOP_INTERRUPT +%token <i> PARSEOP_INTLEVEL_ACTIVEBOTH +%token <i> PARSEOP_INTLEVEL_ACTIVEHIGH +%token <i> PARSEOP_INTLEVEL_ACTIVELOW +%token <i> PARSEOP_INTTYPE_EDGE +%token <i> PARSEOP_INTTYPE_LEVEL +%token <i> PARSEOP_IO +%token <i> PARSEOP_IODECODETYPE_10 +%token <i> PARSEOP_IODECODETYPE_16 +%token <i> PARSEOP_IORESTRICT_IN +%token <i> PARSEOP_IORESTRICT_NONE +%token <i> PARSEOP_IORESTRICT_OUT +%token <i> PARSEOP_IORESTRICT_PRESERVE +%token <i> PARSEOP_IRQ +%token <i> PARSEOP_IRQNOFLAGS +%token <i> PARSEOP_LAND +%token <i> PARSEOP_LEQUAL +%token <i> PARSEOP_LGREATER +%token <i> PARSEOP_LGREATEREQUAL +%token <i> PARSEOP_LLESS +%token <i> PARSEOP_LLESSEQUAL +%token <i> PARSEOP_LNOT +%token <i> PARSEOP_LNOTEQUAL +%token <i> PARSEOP_LOAD +%token <i> PARSEOP_LOADTABLE +%token <i> PARSEOP_LOCAL0 +%token <i> PARSEOP_LOCAL1 +%token <i> PARSEOP_LOCAL2 +%token <i> PARSEOP_LOCAL3 +%token <i> PARSEOP_LOCAL4 +%token <i> PARSEOP_LOCAL5 +%token <i> PARSEOP_LOCAL6 +%token <i> PARSEOP_LOCAL7 +%token <i> PARSEOP_LOCKRULE_LOCK +%token <i> PARSEOP_LOCKRULE_NOLOCK +%token <i> PARSEOP_LOR +%token <i> PARSEOP_MATCH +%token <i> PARSEOP_MATCHTYPE_MEQ +%token <i> PARSEOP_MATCHTYPE_MGE +%token <i> PARSEOP_MATCHTYPE_MGT +%token <i> PARSEOP_MATCHTYPE_MLE +%token <i> PARSEOP_MATCHTYPE_MLT +%token <i> PARSEOP_MATCHTYPE_MTR +%token <i> PARSEOP_MAXTYPE_FIXED +%token <i> PARSEOP_MAXTYPE_NOTFIXED +%token <i> PARSEOP_MEMORY24 +%token <i> PARSEOP_MEMORY32 +%token <i> PARSEOP_MEMORY32FIXED +%token <i> PARSEOP_MEMTYPE_CACHEABLE +%token <i> PARSEOP_MEMTYPE_NONCACHEABLE +%token <i> PARSEOP_MEMTYPE_PREFETCHABLE +%token <i> PARSEOP_MEMTYPE_WRITECOMBINING +%token <i> PARSEOP_METHOD +%token <i> PARSEOP_METHODCALL +%token <i> PARSEOP_MID +%token <i> PARSEOP_MINTYPE_FIXED +%token <i> PARSEOP_MINTYPE_NOTFIXED +%token <i> PARSEOP_MOD +%token <i> PARSEOP_MULTIPLY +%token <i> PARSEOP_MUTEX +%token <i> PARSEOP_NAME +%token <s> PARSEOP_NAMESEG +%token <s> PARSEOP_NAMESTRING +%token <i> PARSEOP_NAND +%token <i> PARSEOP_NOOP +%token <i> PARSEOP_NOR +%token <i> PARSEOP_NOT +%token <i> PARSEOP_NOTIFY +%token <i> PARSEOP_OBJECTTYPE +%token <i> PARSEOP_OBJECTTYPE_BFF +%token <i> PARSEOP_OBJECTTYPE_BUF +%token <i> PARSEOP_OBJECTTYPE_DDB +%token <i> PARSEOP_OBJECTTYPE_DEV +%token <i> PARSEOP_OBJECTTYPE_EVT +%token <i> PARSEOP_OBJECTTYPE_FLD +%token <i> PARSEOP_OBJECTTYPE_INT +%token <i> PARSEOP_OBJECTTYPE_MTH +%token <i> PARSEOP_OBJECTTYPE_MTX +%token <i> PARSEOP_OBJECTTYPE_OPR +%token <i> PARSEOP_OBJECTTYPE_PKG +%token <i> PARSEOP_OBJECTTYPE_POW +%token <i> PARSEOP_OBJECTTYPE_PRO +%token <i> PARSEOP_OBJECTTYPE_STR +%token <i> PARSEOP_OBJECTTYPE_THZ +%token <i> PARSEOP_OBJECTTYPE_UNK +%token <i> PARSEOP_OFFSET +%token <i> PARSEOP_ONE +%token <i> PARSEOP_ONES +%token <i> PARSEOP_OPERATIONREGION +%token <i> PARSEOP_OR +%token <i> PARSEOP_PACKAGE +%token <i> PARSEOP_PACKAGE_LENGTH +%token <i> PARSEOP_PARITYTYPE_EVEN +%token <i> PARSEOP_PARITYTYPE_MARK +%token <i> PARSEOP_PARITYTYPE_NONE +%token <i> PARSEOP_PARITYTYPE_ODD +%token <i> PARSEOP_PARITYTYPE_SPACE +%token <i> PARSEOP_PIN_NOPULL +%token <i> PARSEOP_PIN_PULLDEFAULT +%token <i> PARSEOP_PIN_PULLDOWN +%token <i> PARSEOP_PIN_PULLUP +%token <i> PARSEOP_POWERRESOURCE +%token <i> PARSEOP_PROCESSOR +%token <i> PARSEOP_QWORDCONST +%token <i> PARSEOP_QWORDIO +%token <i> PARSEOP_QWORDMEMORY +%token <i> PARSEOP_QWORDSPACE +%token <i> PARSEOP_RANGETYPE_ENTIRE +%token <i> PARSEOP_RANGETYPE_ISAONLY +%token <i> PARSEOP_RANGETYPE_NONISAONLY +%token <i> PARSEOP_RAW_DATA +%token <i> PARSEOP_READWRITETYPE_BOTH +%token <i> PARSEOP_READWRITETYPE_READONLY +%token <i> PARSEOP_REFOF +%token <i> PARSEOP_REGIONSPACE_CMOS +%token <i> PARSEOP_REGIONSPACE_EC +%token <i> PARSEOP_REGIONSPACE_FFIXEDHW +%token <i> PARSEOP_REGIONSPACE_GPIO +%token <i> PARSEOP_REGIONSPACE_GSBUS +%token <i> PARSEOP_REGIONSPACE_IO +%token <i> PARSEOP_REGIONSPACE_IPMI +%token <i> PARSEOP_REGIONSPACE_MEM +%token <i> PARSEOP_REGIONSPACE_PCC +%token <i> PARSEOP_REGIONSPACE_PCI +%token <i> PARSEOP_REGIONSPACE_PCIBAR +%token <i> PARSEOP_REGIONSPACE_SMBUS +%token <i> PARSEOP_REGISTER +%token <i> PARSEOP_RELEASE +%token <i> PARSEOP_RESERVED_BYTES +%token <i> PARSEOP_RESET +%token <i> PARSEOP_RESOURCETEMPLATE +%token <i> PARSEOP_RESOURCETYPE_CONSUMER +%token <i> PARSEOP_RESOURCETYPE_PRODUCER +%token <i> PARSEOP_RETURN +%token <i> PARSEOP_REVISION +%token <i> PARSEOP_SCOPE +%token <i> PARSEOP_SERIALIZERULE_NOTSERIAL +%token <i> PARSEOP_SERIALIZERULE_SERIAL +%token <i> PARSEOP_SHARETYPE_EXCLUSIVE +%token <i> PARSEOP_SHARETYPE_EXCLUSIVEWAKE +%token <i> PARSEOP_SHARETYPE_SHARED +%token <i> PARSEOP_SHARETYPE_SHAREDWAKE +%token <i> PARSEOP_SHIFTLEFT +%token <i> PARSEOP_SHIFTRIGHT +%token <i> PARSEOP_SIGNAL +%token <i> PARSEOP_SIZEOF +%token <i> PARSEOP_SLAVEMODE_CONTROLLERINIT +%token <i> PARSEOP_SLAVEMODE_DEVICEINIT +%token <i> PARSEOP_SLEEP +%token <i> PARSEOP_SPI_SERIALBUS +%token <i> PARSEOP_STALL +%token <i> PARSEOP_STARTDEPENDENTFN +%token <i> PARSEOP_STARTDEPENDENTFN_NOPRI +%token <i> PARSEOP_STOPBITS_ONE +%token <i> PARSEOP_STOPBITS_ONEPLUSHALF +%token <i> PARSEOP_STOPBITS_TWO +%token <i> PARSEOP_STOPBITS_ZERO +%token <i> PARSEOP_STORE +%token <s> PARSEOP_STRING_LITERAL +%token <i> PARSEOP_SUBTRACT +%token <i> PARSEOP_SWITCH +%token <i> PARSEOP_THERMALZONE +%token <i> PARSEOP_TIMER +%token <i> PARSEOP_TOBCD +%token <i> PARSEOP_TOBUFFER +%token <i> PARSEOP_TODECIMALSTRING +%token <i> PARSEOP_TOHEXSTRING +%token <i> PARSEOP_TOINTEGER +%token <i> PARSEOP_TOSTRING +%token <i> PARSEOP_TOUUID +%token <i> PARSEOP_TRANSLATIONTYPE_DENSE +%token <i> PARSEOP_TRANSLATIONTYPE_SPARSE +%token <i> PARSEOP_TYPE_STATIC +%token <i> PARSEOP_TYPE_TRANSLATION +%token <i> PARSEOP_UART_SERIALBUS +%token <i> PARSEOP_UNICODE +%token <i> PARSEOP_UNLOAD +%token <i> PARSEOP_UPDATERULE_ONES +%token <i> PARSEOP_UPDATERULE_PRESERVE +%token <i> PARSEOP_UPDATERULE_ZEROS +%token <i> PARSEOP_VAR_PACKAGE +%token <i> PARSEOP_VENDORLONG +%token <i> PARSEOP_VENDORSHORT +%token <i> PARSEOP_WAIT +%token <i> PARSEOP_WHILE +%token <i> PARSEOP_WIREMODE_FOUR +%token <i> PARSEOP_WIREMODE_THREE +%token <i> PARSEOP_WORDBUSNUMBER +%token <i> PARSEOP_WORDCONST +%token <i> PARSEOP_WORDIO +%token <i> PARSEOP_WORDSPACE +%token <i> PARSEOP_XFERSIZE_8 +%token <i> PARSEOP_XFERSIZE_16 +%token <i> PARSEOP_XFERSIZE_32 +%token <i> PARSEOP_XFERSIZE_64 +%token <i> PARSEOP_XFERSIZE_128 +%token <i> PARSEOP_XFERSIZE_256 +%token <i> PARSEOP_XFERTYPE_8 +%token <i> PARSEOP_XFERTYPE_8_16 +%token <i> PARSEOP_XFERTYPE_16 +%token <i> PARSEOP_XOR +%token <i> PARSEOP_ZERO + +/* + * Special functions. These should probably stay at the end of this + * table. + */ +%token <i> PARSEOP___DATE__ +%token <i> PARSEOP___FILE__ +%token <i> PARSEOP___LINE__ +%token <i> PARSEOP___PATH__ diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 9615fe6c6e47..34c6ae717583 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" @@ -377,7 +376,6 @@ TrDoDefinitionBlock ( * * RETURN: None * - * * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is * no actual AML opcode for SWITCH -- it must be simulated. * diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 0ea4528baf66..cd84d8bf5667 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acapps.h" @@ -79,15 +78,29 @@ static ACPI_PARSE_OBJECT * TrGetNextNode ( void) { + ASL_CACHE_INFO *Cache; + - if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast) + if (Gbl_ParseOpCacheNext >= Gbl_ParseOpCacheLast) { - Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * - ASL_NODE_CACHE_SIZE); - Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_ParseOpCacheList; + Gbl_ParseOpCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_ParseOpCacheNext = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Cache->Buffer); + Gbl_ParseOpCacheLast = Gbl_ParseOpCacheNext + ASL_PARSEOP_CACHE_SIZE; } - return (Gbl_NodeCacheNext++); + Gbl_ParseOpCount++; + return (Gbl_ParseOpCacheNext++); } diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 7e297d3b6721..44c937f2f63e 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLTYPES_H #define __ASLTYPES_H @@ -175,6 +174,16 @@ typedef enum #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +/* Cache block structure for ParseOps and Strings */ + +typedef struct asl_cache_info +{ + void *Next; + char Buffer[1]; + +} ASL_CACHE_INFO; + + typedef struct asl_include_dir { char *Dir; diff --git a/source/compiler/asltypes.y b/source/compiler/asltypes.y new file mode 100644 index 000000000000..b9914531b4e3 --- /dev/null +++ b/source/compiler/asltypes.y @@ -0,0 +1,381 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltypes.y - Bison/Yacc production types/names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Production names + * + *****************************************************************************/ + +%type <n> ArgList +%type <n> ASLCode +%type <n> BufferData +%type <n> BufferTermData +%type <n> CompilerDirective +%type <n> DataObject +%type <n> DefinitionBlockTerm +%type <n> IntegerData +%type <n> NamedObject +%type <n> NameSpaceModifier +%type <n> Object +%type <n> ObjectList +%type <n> PackageData +%type <n> ParameterTypePackage +%type <n> ParameterTypePackageList +%type <n> ParameterTypesPackage +%type <n> ParameterTypesPackageList +%type <n> RequiredTarget +%type <n> SimpleTarget +%type <n> StringData +%type <n> Target +%type <n> Term +%type <n> TermArg +%type <n> TermList +%type <n> UserTerm + +/* Type4Opcode is obsolete */ + +%type <n> Type1Opcode +%type <n> Type2BufferOpcode +%type <n> Type2BufferOrStringOpcode +%type <n> Type2IntegerOpcode +%type <n> Type2Opcode +%type <n> Type2StringOpcode +%type <n> Type3Opcode +%type <n> Type5Opcode +%type <n> Type6Opcode + +%type <n> AccessAsTerm +%type <n> ExternalTerm +%type <n> FieldUnit +%type <n> FieldUnitEntry +%type <n> FieldUnitList +%type <n> IncludeTerm +%type <n> OffsetTerm +%type <n> OptionalAccessAttribTerm + +/* Named Objects */ + +%type <n> BankFieldTerm +%type <n> CreateBitFieldTerm +%type <n> CreateByteFieldTerm +%type <n> CreateDWordFieldTerm +%type <n> CreateFieldTerm +%type <n> CreateQWordFieldTerm +%type <n> CreateWordFieldTerm +%type <n> DataRegionTerm +%type <n> DeviceTerm +%type <n> EventTerm +%type <n> FieldTerm +%type <n> FunctionTerm +%type <n> IndexFieldTerm +%type <n> MethodTerm +%type <n> MutexTerm +%type <n> OpRegionTerm +%type <n> OpRegionSpaceIdTerm +%type <n> PowerResTerm +%type <n> ProcessorTerm +%type <n> ThermalZoneTerm + +/* Namespace modifiers */ + +%type <n> AliasTerm +%type <n> NameTerm +%type <n> ScopeTerm + +/* Type 1 opcodes */ + +%type <n> BreakPointTerm +%type <n> BreakTerm +%type <n> CaseDefaultTermList +%type <n> CaseTerm +%type <n> ContinueTerm +%type <n> DefaultTerm +%type <n> ElseTerm +%type <n> FatalTerm +%type <n> IfElseTerm +%type <n> IfTerm +%type <n> LoadTerm +%type <n> NoOpTerm +%type <n> NotifyTerm +%type <n> ReleaseTerm +%type <n> ResetTerm +%type <n> ReturnTerm +%type <n> SignalTerm +%type <n> SleepTerm +%type <n> StallTerm +%type <n> SwitchTerm +%type <n> UnloadTerm +%type <n> WhileTerm +/* %type <n> CaseTermList */ + +/* Type 2 opcodes */ + +%type <n> AcquireTerm +%type <n> AddTerm +%type <n> AndTerm +%type <n> ConcatResTerm +%type <n> ConcatTerm +%type <n> CondRefOfTerm +%type <n> CopyObjectTerm +%type <n> DecTerm +%type <n> DerefOfTerm +%type <n> DivideTerm +%type <n> FindSetLeftBitTerm +%type <n> FindSetRightBitTerm +%type <n> FromBCDTerm +%type <n> IncTerm +%type <n> IndexTerm +%type <n> LAndTerm +%type <n> LEqualTerm +%type <n> LGreaterEqualTerm +%type <n> LGreaterTerm +%type <n> LLessEqualTerm +%type <n> LLessTerm +%type <n> LNotEqualTerm +%type <n> LNotTerm +%type <n> LoadTableTerm +%type <n> LOrTerm +%type <n> MatchTerm +%type <n> MidTerm +%type <n> ModTerm +%type <n> MultiplyTerm +%type <n> NAndTerm +%type <n> NOrTerm +%type <n> NotTerm +%type <n> ObjectTypeTerm +%type <n> OrTerm +%type <n> RefOfTerm +%type <n> ShiftLeftTerm +%type <n> ShiftRightTerm +%type <n> SizeOfTerm +%type <n> StoreTerm +%type <n> SubtractTerm +%type <n> TimerTerm +%type <n> ToBCDTerm +%type <n> ToBufferTerm +%type <n> ToDecimalStringTerm +%type <n> ToHexStringTerm +%type <n> ToIntegerTerm +%type <n> ToStringTerm +%type <n> WaitTerm +%type <n> XOrTerm + +/* Keywords */ + +%type <n> AccessAttribKeyword +%type <n> AccessTypeKeyword +%type <n> AddressingModeKeyword +%type <n> AddressKeyword +%type <n> AddressSpaceKeyword +%type <n> BitsPerByteKeyword +%type <n> ClockPhaseKeyword +%type <n> ClockPolarityKeyword +%type <n> DecodeKeyword +%type <n> DevicePolarityKeyword +%type <n> DMATypeKeyword +%type <n> EndianKeyword +%type <n> FlowControlKeyword +%type <n> InterruptLevel +%type <n> InterruptTypeKeyword +%type <n> IODecodeKeyword +%type <n> IoRestrictionKeyword +%type <n> LockRuleKeyword +%type <n> MatchOpKeyword +%type <n> MaxKeyword +%type <n> MemTypeKeyword +%type <n> MinKeyword +%type <n> ObjectTypeKeyword +%type <n> OptionalBusMasterKeyword +%type <n> OptionalReadWriteKeyword +%type <n> ParityTypeKeyword +%type <n> PinConfigByte +%type <n> PinConfigKeyword +%type <n> RangeTypeKeyword +%type <n> RegionSpaceKeyword +%type <n> ResourceTypeKeyword +%type <n> SerializeRuleKeyword +%type <n> ShareTypeKeyword +%type <n> SlaveModeKeyword +%type <n> StopBitsKeyword +%type <n> TranslationKeyword +%type <n> TypeKeyword +%type <n> UpdateRuleKeyword +%type <n> WireModeKeyword +%type <n> XferSizeKeyword +%type <n> XferTypeKeyword + +/* Types */ + +%type <n> SuperName +%type <n> ObjectTypeName +%type <n> ArgTerm +%type <n> LocalTerm +%type <n> DebugTerm + +%type <n> Integer +%type <n> ByteConst +%type <n> WordConst +%type <n> DWordConst +%type <n> QWordConst +%type <n> String + +%type <n> ConstTerm +%type <n> ConstExprTerm +%type <n> ByteConstExpr +%type <n> WordConstExpr +%type <n> DWordConstExpr +%type <n> QWordConstExpr + +%type <n> DWordList +%type <n> BufferTerm +%type <n> ByteList + +%type <n> PackageElement +%type <n> PackageList +%type <n> PackageTerm +%type <n> VarPackageLengthTerm + +/* Macros */ + +%type <n> EISAIDTerm +%type <n> ResourceMacroList +%type <n> ResourceMacroTerm +%type <n> ResourceTemplateTerm +%type <n> ToUUIDTerm +%type <n> UnicodeTerm + +/* Resource Descriptors */ + +%type <n> ConnectionTerm +%type <n> DataBufferTerm +%type <n> DMATerm +%type <n> DWordIOTerm +%type <n> DWordMemoryTerm +%type <n> DWordSpaceTerm +%type <n> EndDependentFnTerm +%type <n> ExtendedIOTerm +%type <n> ExtendedMemoryTerm +%type <n> ExtendedSpaceTerm +%type <n> FixedDmaTerm +%type <n> FixedIOTerm +%type <n> GpioIntTerm +%type <n> GpioIoTerm +%type <n> I2cSerialBusTerm +%type <n> InterruptTerm +%type <n> IOTerm +%type <n> IRQNoFlagsTerm +%type <n> IRQTerm +%type <n> Memory24Term +%type <n> Memory32FixedTerm +%type <n> Memory32Term +%type <n> NameSeg +%type <n> NameString +%type <n> QWordIOTerm +%type <n> QWordMemoryTerm +%type <n> QWordSpaceTerm +%type <n> RegisterTerm +%type <n> SpiSerialBusTerm +%type <n> StartDependentFnNoPriTerm +%type <n> StartDependentFnTerm +%type <n> UartSerialBusTerm +%type <n> VendorLongTerm +%type <n> VendorShortTerm +%type <n> WordBusNumberTerm +%type <n> WordIOTerm +%type <n> WordSpaceTerm + +/* Local types that help construct the AML, not in ACPI spec */ + +%type <n> AmlPackageLengthTerm +%type <n> IncludeEndTerm +%type <n> NameStringItem +%type <n> TermArgItem + +%type <n> OptionalAccessSize +%type <n> OptionalAddressingMode +%type <n> OptionalAddressRange +%type <n> OptionalBitsPerByte +%type <n> OptionalBuffer_Last +%type <n> OptionalByteConstExpr +%type <n> OptionalCount +%type <n> OptionalDecodeType +%type <n> OptionalDevicePolarity +%type <n> OptionalDWordConstExpr +%type <n> OptionalEndian +%type <n> OptionalFlowControl +%type <n> OptionalIoRestriction +%type <n> OptionalListString +%type <n> OptionalMaxType +%type <n> OptionalMemType +%type <n> OptionalMinType +%type <n> OptionalNameString +%type <n> OptionalNameString_First +%type <n> OptionalNameString_Last +%type <n> OptionalObjectTypeKeyword +%type <n> OptionalParameterTypePackage +%type <n> OptionalParameterTypesPackage +%type <n> OptionalParityType +%type <n> OptionalQWordConstExpr +%type <n> OptionalRangeType +%type <n> OptionalReference +%type <n> OptionalResourceType +%type <n> OptionalResourceType_First +%type <n> OptionalReturnArg +%type <n> OptionalSerializeRuleKeyword +%type <n> OptionalShareType +%type <n> OptionalShareType_First +%type <n> OptionalSlaveMode +%type <n> OptionalStopBits +%type <n> OptionalStringData +%type <n> OptionalTermArg +%type <n> OptionalTranslationType_Last +%type <n> OptionalType +%type <n> OptionalType_Last +%type <n> OptionalWireMode +%type <n> OptionalWordConst +%type <n> OptionalWordConstExpr +%type <n> OptionalXferSize diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 7dc0697236b8..c9a9fac6d75d 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acdisasm.h" @@ -243,37 +242,6 @@ UtEndEvent ( /******************************************************************************* * - * FUNCTION: UtHexCharToValue - * - * PARAMETERS: HexChar - Hex character in Ascii - * - * RETURN: The binary value of the hex character - * - * DESCRIPTION: Perform ascii-to-hex translation - * - ******************************************************************************/ - -UINT8 -UtHexCharToValue ( - int HexChar) -{ - - if (HexChar <= 0x39) - { - return ((UINT8) (HexChar - 0x30)); - } - - if (HexChar <= 0x46) - { - return ((UINT8) (HexChar - 0x37)); - } - - return ((UINT8) (HexChar - 0x57)); -} - - -/******************************************************************************* - * * FUNCTION: UtConvertByteToHex * * PARAMETERS: RawByte - Binary data @@ -296,8 +264,8 @@ UtConvertByteToHex ( Buffer[0] = '0'; Buffer[1] = 'x'; - Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); } @@ -312,7 +280,7 @@ UtConvertByteToHex ( * RETURN: Ascii hex byte is stored in Buffer. * * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" + * with '0', and a trailing 'h' is added. * ******************************************************************************/ @@ -323,8 +291,8 @@ UtConvertByteToAsmHex ( { Buffer[0] = '0'; - Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); Buffer[3] = 'h'; } @@ -585,7 +553,7 @@ UtCheckIntegerRange ( /******************************************************************************* * - * FUNCTION: UtGetStringBuffer + * FUNCTION: UtStringCacheCalloc * * PARAMETERS: Length - Size of buffer requested * @@ -598,22 +566,42 @@ UtCheckIntegerRange ( ******************************************************************************/ char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length) { char *Buffer; + ASL_CACHE_INFO *Cache; + if (Length > ASL_STRING_CACHE_SIZE) + { + Buffer = UtLocalCalloc (Length); + return (Buffer); + } + if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast) { - Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); - Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + - Length; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + ASL_STRING_CACHE_SIZE); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_StringCacheList; + Gbl_StringCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_StringCacheNext = Cache->Buffer; + Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE; } + Gbl_StringCount++; + Gbl_StringSize += Length; + Buffer = Gbl_StringCacheNext; Gbl_StringCacheNext += Length; - return (Buffer); } @@ -646,7 +634,8 @@ UtExpandLineBuffers ( NewSize = Gbl_LineBufferSize * 2; if (Gbl_CurrentLineBuffer) { - DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to %u\n", + DbgPrint (ASL_DEBUG_OUTPUT, + "Increasing line buffer size from %u to %u\n", Gbl_LineBufferSize, NewSize); } @@ -691,6 +680,30 @@ ErrorExit: } +/****************************************************************************** + * + * FUNCTION: UtFreeLineBuffers + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all line buffers + * + *****************************************************************************/ + +void +UtFreeLineBuffers ( + void) +{ + + free (Gbl_CurrentLineBuffer); + free (Gbl_MainTokenBuffer); + free (Gbl_MacroTokenBuffer); + free (Gbl_ExpressionTokenBuffer); +} + + /******************************************************************************* * * FUNCTION: UtInternalizeName @@ -723,9 +736,9 @@ UtInternalizeName ( Info.ExternalName = ExternalName; AcpiNsGetInternalNameLength (&Info); - /* We need a segment to store the internal name */ + /* We need a segment to store the internal name */ - Info.InternalName = UtGetStringBuffer (Info.Length); + Info.InternalName = UtStringCacheCalloc (Info.Length); if (!Info.InternalName) { return (AE_NO_MEMORY); diff --git a/source/compiler/asluuid.c b/source/compiler/asluuid.c index f7b1f0c5890f..f79a33b7f879 100644 --- a/source/compiler/asluuid.c +++ b/source/compiler/asluuid.c @@ -41,42 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asluuid") -/* - * UUID support functions. - * - * This table is used to convert an input UUID ascii string to a 16 byte - * buffer and the reverse. The table maps a UUID buffer index 0-15 to - * the index within the 36-byte UUID string where the associated 2-byte - * hex value can be found. - * - * 36-byte UUID strings are of the form: - * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp - * Where aa-pp are one byte hex numbers, made up of two hex digits - * - * Note: This table is basically the inverse of the string-to-offset table - * found in the ACPI spec in the description of the ToUUID macro. - */ -static UINT8 Gbl_MapToUuidOffset[16] = -{ - 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 -}; - -#define UUID_BUFFER_LENGTH 16 -#define UUID_STRING_LENGTH 36 - -/* Positions for required hyphens (dashes) in UUID strings */ - -#define UUID_HYPHEN1_OFFSET 8 -#define UUID_HYPHEN2_OFFSET 13 -#define UUID_HYPHEN3_OFFSET 18 -#define UUID_HYPHEN4_OFFSET 23 +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -137,42 +108,6 @@ AuValidateUuid ( /******************************************************************************* * - * FUNCTION: AuConvertStringToUuid - * - * PARAMETERS: InString - 36-byte formatted UUID string - * UuidBuffer - 16-byte UUID buffer - * - * RETURN: Status - * - * DESCRIPTION: Convert 36-byte formatted UUID string to 16-byte UUID buffer - * - ******************************************************************************/ - -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuidBuffer) -{ - UINT32 i; - - - if (!InString || !UuidBuffer) - { - return (AE_BAD_PARAMETER); - } - - for (i = 0; i < UUID_BUFFER_LENGTH; i++) - { - UuidBuffer[i] = (char) (UtHexCharToValue (InString[Gbl_MapToUuidOffset[i]]) << 4); - UuidBuffer[i] |= (char) UtHexCharToValue (InString[Gbl_MapToUuidOffset[i] + 1]); - } - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AuConvertUuidToString * * PARAMETERS: UuidBuffer - 16-byte UUID buffer @@ -200,8 +135,11 @@ AuConvertUuidToString ( for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - OutString[Gbl_MapToUuidOffset[i]] = (UINT8) AslHexLookup[(UuidBuffer[i] >> 4) & 0xF]; - OutString[Gbl_MapToUuidOffset[i] + 1] = (UINT8) AslHexLookup[UuidBuffer[i] & 0xF]; + OutString[AcpiGbl_MapToUuidOffset[i]] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 4); + + OutString[AcpiGbl_MapToUuidOffset[i] + 1] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 0); } /* Insert required hyphens (dashes) */ diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 960bebcdd3b2..da4e9e31e9e0 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index ee3a0f8828e4..1cbd6e092c70 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" @@ -86,6 +85,20 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *MethodOp1, + ACPI_PARSE_OBJECT *MethodOp2); + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *Node); + /******************************************************************************* * @@ -130,6 +143,8 @@ XfCrossReferenceNamespace ( TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); + + ACPI_FREE (WalkState); return (AE_OK); } @@ -262,6 +277,178 @@ XfCheckFieldRange ( } } + +/******************************************************************************* + * + * FUNCTION: XfIsObjectParental + * + * PARAMETERS: ChildOp - Op to be checked + * PossibleParentOp - Determine if this op is in the family + * + * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp + * + * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to + * detect if a method is declared within another method. + * + ******************************************************************************/ + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *ChildOp, + ACPI_PARSE_OBJECT *PossibleParentOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + /* Search upwards through the tree for possible parent */ + + ParentOp = ChildOp; + while (ParentOp) + { + if (ParentOp == PossibleParentOp) + { + return (TRUE); + } + + ParentOp = ParentOp->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfGetParentMethod + * + * PARAMETERS: Op - Op to be checked + * + * RETURN: Op for parent method. NULL if object is not within a method. + * + * DESCRIPTION: Determine if an object is within a control method. Used to + * implement special rules for named references from within a + * control method. + * + * NOTE: It would be better to have the parser set a flag in the Op if possible. + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + if (!Op) + { + return (NULL); + } + + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (NULL); + } + + /* Walk upwards through the parse tree, up to the root if necessary */ + + ParentOp = Op; + while (ParentOp) + { + if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (ParentOp); + } + + ParentOp = ParentOp->Asl.Parent; + } + + /* Object is not within a method */ + + return (NULL); +} + +/******************************************************************************* + * + * FUNCTION: XfCheckIllegalReference + * + * PARAMETERS: Op - Op referring to the target + * TargetNode - Target of the reference + * + * RETURN: None. Emits error message for an illegal reference + * + * DESCRIPTION: Determine if a named reference is legal. A "named" reference + * is something like: Store(ABCD, ...), where ABCD is an AML + * Nameseg or Namepath. + * + * NOTE: Caller must ensure that the name Op is in fact a reference, and not + * an actual name declaration (creation of a named object). + * + ******************************************************************************/ + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *TargetNode) +{ + ACPI_PARSE_OBJECT *MethodOp1; + ACPI_PARSE_OBJECT *MethodOp2; + ACPI_PARSE_OBJECT *TargetOp; + + + /* + * Check for an illegal reference to a named object: + * + * 1) References from one control method to another, non-parent + * method are not allowed, they will fail at runtime. + * + * 2) Forward references within a control method are not allowed. + * AML interpreters use a one-pass parse of control methods + * so these forward references will fail at runtime. + */ + TargetOp = TargetNode->Op; + + MethodOp1 = XfGetParentMethod (Op); + MethodOp2 = XfGetParentMethod (TargetOp); + + /* Are both objects within control method(s)? */ + + if (!MethodOp1 || !MethodOp2) + { + return; + } + + /* Objects not in the same method? */ + + if (MethodOp1 != MethodOp2) + { + /* + * 1) Cross-method named reference + * + * This is OK if and only if the target reference is within in a + * method that is a parent of current method + */ + if (!XfIsObjectParental (MethodOp1, MethodOp2)) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, + Op->Asl.ExternalName); + } + } + + /* + * 2) Both reference and target are in the same method. Check if this is + * an (illegal) forward reference by examining the exact source code + * location of each (the referenced object and the object declaration). + * This is a bit nasty, yet effective. + */ + else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op, + Op->Asl.ExternalName); + } +} + + /******************************************************************************* * * FUNCTION: XfNamespaceLocateBegin @@ -471,6 +658,10 @@ XfNamespaceLocateBegin ( /* This node has been referenced, mark it for reference check */ Node->Flags |= ANOBJ_IS_REFERENCED; + + /* Check for an illegal reference */ + + XfCheckIllegalReference (Op, Node); } /* Attempt to optimize the NamePath */ diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index aa1f9d1e5d27..5c8fea3092a1 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -141,8 +141,6 @@ DtDoCompile ( Status = DtCompileDataTable (&FieldList); UtEndEvent (Event); - DtFreeFieldList (); - if (ACPI_FAILURE (Status)) { /* TBD: temporary error message. Msgs should come from function above */ @@ -170,6 +168,8 @@ DtDoCompile ( CleanupAndExit: + AcpiUtDeleteCaches (); + DtDeleteCaches (); CmCleanupAndExit (); return (Status); } @@ -298,7 +298,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -461,11 +461,11 @@ DtCompileTable ( return (AE_ERROR); } - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); if (Length > 0) { - Subtable->Buffer = UtLocalCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, UtStringCacheCalloc (Length)); } Subtable->Length = Length; Subtable->TotalLength = Length; @@ -567,8 +567,6 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); - ACPI_FREE (InlineSubtable->Buffer); - ACPI_FREE (InlineSubtable); LocalField = *Field; break; diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index db5d306d2110..553f5e6d1991 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -50,6 +50,10 @@ #include "acdisasm.h" +#define ASL_FIELD_CACHE_SIZE 512 +#define ASL_SUBTABLE_CACHE_SIZE 128 + + #undef DT_EXTERN #ifdef _DECLARE_DT_GLOBALS @@ -143,6 +147,18 @@ DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL); DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0); +/* Local caches */ + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_SubtableCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_SubtableCacheList, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheNext, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheLast, NULL); + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_FieldCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_FieldCacheList, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheNext, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheLast, NULL); + /* dtcompiler - main module */ @@ -368,8 +384,16 @@ void DtSetTableLength( void); +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void); + +DT_FIELD * +UtFieldCacheCalloc ( + void); + void -DtFreeFieldList ( +DtDeleteCaches ( void); @@ -420,6 +444,10 @@ DtCompileFpdt ( void **PFieldList); ACPI_STATUS +DtCompileGtdt ( + void **PFieldList); + +ACPI_STATUS DtCompileHest ( void **PFieldList); diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index ff77242127c5..98c87798c543 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -259,7 +259,7 @@ DtCompileUuid ( } else { - Status = AuConvertStringToUuid (InString, (char *) Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } return (Status); diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 25d84ab059cc..f8e35fdd8a3b 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -133,7 +133,7 @@ DtTrim ( if (!ACPI_STRCMP (String, " ")) { - ReturnString = UtLocalCalloc (1); + ReturnString = UtStringCacheCalloc (1); return (ReturnString); } @@ -181,7 +181,7 @@ DtTrim ( /* Create the trimmed return string */ Length = ACPI_PTR_DIFF (End, Start) + 1; - ReturnString = UtLocalCalloc (Length + 1); + ReturnString = UtStringCacheCalloc (Length + 1); if (ACPI_STRLEN (Start)) { ACPI_STRNCPY (ReturnString, Start, Length); @@ -370,7 +370,7 @@ DtParseLine ( if ((Value && *Value) || IsNullString) { - Field = UtLocalCalloc (sizeof (DT_FIELD)); + Field = UtFieldCacheCalloc (); Field->Name = Name; Field->Value = Value; Field->Line = Line; @@ -380,11 +380,7 @@ DtParseLine ( DtLinkField (Field); } - else /* Ignore this field, it has no valid data */ - { - ACPI_FREE (Name); - ACPI_FREE (Value); - } + /* Else -- Ignore this field, it has no valid data */ return (AE_OK); } @@ -1035,6 +1031,8 @@ DtDumpSubtableList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nSubtable Tree: (Depth, Subtable, Length, TotalLength)\n\n"); DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL); + + DbgPrint (ASL_DEBUG_OUTPUT, "\n"); } diff --git a/source/compiler/dtsubtable.c b/source/compiler/dtsubtable.c index 90cb067bd0ee..a87198d39a65 100644 --- a/source/compiler/dtsubtable.c +++ b/source/compiler/dtsubtable.c @@ -75,11 +75,11 @@ DtCreateSubtable ( DT_SUBTABLE *Subtable; - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); /* Create a new buffer for the subtable data */ - Subtable->Buffer = UtLocalCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, UtStringCacheCalloc (Length)); ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index c341bf20e449..a0dee31e6896 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -736,16 +736,21 @@ DtCompileDmar ( InfoTable = AcpiDmTableInfoDmar1; break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); @@ -762,10 +767,20 @@ DtCompileDmar ( ParentTable = DtPeekSubtable (); DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - /* Optional Device Scope subtables */ + /* + * Optional Device Scope subtables + */ + if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + DtPopSubtable (); + continue; + } + DtPushSubtable (Subtable); DeviceScopeLength = DmarHeader->Length - Subtable->Length - ParentTable->Length; while (DeviceScopeLength) @@ -938,6 +953,125 @@ DtCompileFadt ( return (AE_OK); } +/****************************************************************************** + * + * FUNCTION: DtCompileGtdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile GTDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGtdt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *GtdtHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 GtCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional GT block subtable data + */ + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; + while (GtCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + + DtInsertSubtable (ParentTable, Subtable); + GtCount--; + } + DtPopSubtable (); + break; + + default: + + break; + } + + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -1501,6 +1635,16 @@ DtCompileMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); @@ -1792,6 +1936,11 @@ DtCompilePcct ( InfoTable = AcpiDmTableInfoPcct0; break; + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); @@ -2271,6 +2420,11 @@ DtCompileSrat ( InfoTable = AcpiDmTableInfoSrat2; break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); diff --git a/source/compiler/dttemplate.c b/source/compiler/dttemplate.c index 8cafbf959f80..4fb6be0d389d 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -187,6 +187,12 @@ GetTemplate: } Status = DtCreateOneTemplate (Signature, TableData); + + + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); return (Status); } @@ -397,6 +403,5 @@ DtCreateOneTemplate ( Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); - ACPI_FREE (DisasmFilename); return (Status); } diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 4c8ba08490e2..4011f087287b 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -395,7 +395,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000080 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ @@ -434,16 +434,34 @@ const unsigned char TemplateFpdt[] = const unsigned char TemplateGtdt[] = { - 0x47,0x54,0x44,0x54,0x50,0x00,0x00,0x00, /* 00000000 "GTDTP..." */ - 0x01,0xF1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000048 "........" */ + 0x47,0x54,0x44,0x54,0xe0,0x00,0x00,0x00, /* 00000000 "GTDT...." */ + 0x02,0xb0,0x4c,0x49,0x4e,0x41,0x52,0x4f, /* 00000008 "..LINARO" */ + 0x52,0x54,0x53,0x4d,0x56,0x45,0x56,0x38, /* 00000010 "RTSMVEV8" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x1d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */ + 0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000058 "....`..." */ + 0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".d......" */ + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 00000068 "........" */ + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x1c,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000d8 "........" */ }; const unsigned char TemplateHest[] = @@ -575,41 +593,48 @@ const unsigned char TemplateLpit[] = 0x00,0x00,0x00,0x00 /* 000000B0 "...." */ }; -/* MADT with ACPI 5.0 subtables */ +/* MADT with ACPI 5.1 subtables */ const unsigned char TemplateMadt[] = { - 0x41,0x50,0x49,0x43,0xF6,0x00,0x00,0x00, /* 00000000 "APIC...." */ - 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x41,0x50,0x49,0x43,0x2a,0x01,0x00,0x00, /* 00000000 "APIC*..." */ + 0x04,0x34,0x49,0x4e,0x54,0x45,0x4c,0x20, /* 00000008 ".4INTEL " */ + 0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ - 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x0c,0x01,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */ + 0x02,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x03,0x08,0x0d,0x00,0x01,0x00, /* 00000048 "........" */ 0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */ - 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x05,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ 0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */ + 0x00,0x00,0x00,0x00,0x5c,0x43,0x50,0x55, /* 00000080 "....\CPU" */ 0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */ 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ 0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ - 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x28, /* 000000B0 ".......(" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18, /* 000000D8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00 /* 000000F0 "......" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x0a,0x0c,0x05,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x4c, /* 000000b0 ".......L" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f8 "........" */ + 0x00,0x00,0x0e,0x10,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */ + 0x00,0x00,0x0c,0x18,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00 /* 00000128 ".. " */ }; const unsigned char TemplateMcfg[] = @@ -703,27 +728,27 @@ const unsigned char TemplateMtmr[] = const unsigned char TemplatePcct[] = { 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ - 0x01,0x97,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0xCF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ - 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ - 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ - 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ - 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ - 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ - 0x77,0x77,0x77,0x77,0x88,0x88,0x00,0x3E, /* 00000068 "wwww...>" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, /* 00000070 "........" */ - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xEE, /* 00000078 "........" */ - 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0x01,0x32, /* 00000080 ".......2" */ - 0x00,0x03,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD, /* 00000088 "........" */ - 0xDD,0xDD,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* 00000090 "........" */ - 0xCC,0xCC,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB, /* 00000098 "........" */ - 0xBB,0xBB,0xAA,0xAA,0xAA,0xAA,0x99,0x99, /* 000000A0 "........" */ - 0x99,0x99,0x88,0x88 /* 000000A8 "...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x32,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ".2......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000058 "........" */ + 0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00, /* 00000060 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x3E, /* 00000068 ".......>" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x32, /* 00000080 ".......2" */ + 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000098 "........" */ + 0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x01,0x00 /* 000000A8 "...." */ }; const unsigned char TemplatePmtt[] = @@ -936,11 +961,11 @@ const unsigned char TemplateSpmi[] = const unsigned char TemplateSrat[] = { - 0x53,0x52,0x41,0x54,0x80,0x00,0x00,0x00, /* 00000000 "SRAT...." */ - 0x03,0x5A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".ZINTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x53,0x52,0x41,0x54,0x92,0x00,0x00,0x00, /* 00000000 "SRAT...." */ + 0x03,0x50,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".PINTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x24,0x07,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -951,7 +976,10 @@ const unsigned char TemplateSrat[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ 0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00 /* 00000090 ".." */ }; const unsigned char TemplateTcpa[] = diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 281bfb3725a2..6927c56697f4 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -501,6 +501,7 @@ DtGetFieldLength ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: @@ -512,6 +513,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -843,39 +845,151 @@ DtWalkTableTree ( } -/****************************************************************************** +/******************************************************************************* + * + * FUNCTION: UtSubtableCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure + * + * DESCRIPTION: Allocate a subtable object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_SubtableCacheNext >= Gbl_SubtableCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_SubtableCacheList; + Gbl_SubtableCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_SubtableCacheNext = ACPI_CAST_PTR (DT_SUBTABLE, Cache->Buffer); + Gbl_SubtableCacheLast = Gbl_SubtableCacheNext + ASL_SUBTABLE_CACHE_SIZE; + } + + Gbl_SubtableCount++; + return (Gbl_SubtableCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: UtFieldCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure * - * FUNCTION: DtFreeFieldList + * DESCRIPTION: Allocate a field object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_FIELD * +UtFieldCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_FieldCacheNext >= Gbl_FieldCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_FieldCacheList; + Gbl_FieldCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_FieldCacheNext = ACPI_CAST_PTR (DT_FIELD, Cache->Buffer); + Gbl_FieldCacheLast = Gbl_FieldCacheNext + ASL_FIELD_CACHE_SIZE; + } + + Gbl_FieldCount++; + return (Gbl_FieldCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: DtDeleteCaches * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Free the field list + * DESCRIPTION: Delete all local cache buffer blocks * - *****************************************************************************/ + ******************************************************************************/ void -DtFreeFieldList ( +DtDeleteCaches ( void) { - DT_FIELD *Field = Gbl_FieldList; - DT_FIELD *NextField; + UINT32 BufferCount; + ASL_CACHE_INFO *Next; - /* Walk and free entire field list */ + /* Field cache */ - while (Field) + BufferCount = 0; + while (Gbl_FieldCacheList) { - NextField = Field->Next; /* Save link */ + Next = Gbl_FieldCacheList->Next; + ACPI_FREE (Gbl_FieldCacheList); + Gbl_FieldCacheList = Next; + BufferCount++; + } - if (!(Field->Flags & DT_FIELD_NOT_ALLOCATED)) - { - ACPI_FREE (Field->Name); - ACPI_FREE (Field->Value); - } + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Fields, Buffer size: %u fields (%u bytes), %u Buffers\n", + Gbl_FieldCount, ASL_FIELD_CACHE_SIZE, + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE), BufferCount); + + Gbl_FieldCount = 0; + Gbl_FieldCacheNext = NULL; + Gbl_FieldCacheLast = NULL; + + /* Subtable cache */ - ACPI_FREE (Field); - Field = NextField; + BufferCount = 0; + while (Gbl_SubtableCacheList) + { + Next = Gbl_SubtableCacheList->Next; + ACPI_FREE (Gbl_SubtableCacheList); + Gbl_SubtableCacheList = Next; + BufferCount++; } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Subtables, Buffer size: %u subtables (%u bytes), %u Buffers\n", + Gbl_SubtableCount, ASL_SUBTABLE_CACHE_SIZE, + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE), BufferCount); + + Gbl_SubtableCount = 0; + Gbl_SubtableCacheNext = NULL; + Gbl_SubtableCacheLast = NULL; } diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c index d8b7d45c5d39..a93a14e85e97 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -340,7 +340,6 @@ PrOpenIncludeWithPrefix ( if (!IncludeFile) { fprintf (stderr, "Could not open include file %s\n", Pathname); - ACPI_FREE (Pathname); return (NULL); } @@ -393,15 +392,17 @@ PrPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; Gbl_PreviousLineNumber = 0; Gbl_CurrentLineNumber = 0; /* Emit a new #line directive for the include file */ - FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", - 1, Filename); + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", 1, Filename); } |