diff options
author | dim <dim@FreeBSD.org> | 2015-04-04 10:17:51 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-04-04 10:17:51 +0000 |
commit | 441da571d47ec226c5c1799fe6e9dad14931a813 (patch) | |
tree | 03ae73b5fa8cee569039a08677ba8f5db4c7032b /sys/contrib/dev/acpica/compiler | |
parent | a66c38928305566ab81042d4242432a649ec767f (diff) | |
download | FreeBSD-src-441da571d47ec226c5c1799fe6e9dad14931a813.zip FreeBSD-src-441da571d47ec226c5c1799fe6e9dad14931a813.tar.gz |
MFC r272444 (by jkim):
Merge ACPICA 20140926.
MFC r278970 (by jkim):
Merge ACPICA 20141107 and 20150204.
Approved by: jkim
Relnotes: yes
Diffstat (limited to 'sys/contrib/dev/acpica/compiler')
80 files changed, 8070 insertions, 2933 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index f5338bc..3c3eee8 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/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/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c new file mode 100644 index 0000000..e6b3311 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslascii.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Module Name: aslascii - ASCII detection and support routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/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/sys/contrib/dev/acpica/compiler/aslbtypes.c b/sys/contrib/dev/acpica/compiler/aslbtypes.c index 16f3a0b..0ba219a 100644 --- a/sys/contrib/dev/acpica/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/compiler/aslbtypes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> @@ -243,7 +242,7 @@ AnMapEtypeToBtype ( return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); - case ACPI_BTYPE_DEBUG_OBJECT: + case ACPI_TYPE_DEBUG_OBJECT: /* Cannot be used as a source operand */ @@ -375,6 +374,12 @@ AnGetBtype ( UINT32 ThisNodeBtype = 0; + if (!Op) + { + AcpiOsPrintf ("Null Op in AnGetBtype\n"); + return (ACPI_UINT32_MAX); + } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index b7d510d..541236a 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> @@ -108,6 +107,12 @@ CgGenerateAmlOutput ( TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); + + DbgPrint (ASL_TREE_OUTPUT, + "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr" + " Parent Child Next Flags AcTyp Final Col L\n", + 76, " "); + CgCloseTable (); } @@ -139,7 +144,8 @@ CgAmlWriteWalk ( DbgPrint (ASL_TREE_OUTPUT, "Final parse tree used for AML output:\n"); DbgPrint (ASL_TREE_OUTPUT, - "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr Child Parent Flags AcTyp Final Col L\n", + "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr" + " Parent Child Next Flags AcTyp Final Col L\n", 76, " "); } @@ -162,7 +168,8 @@ CgAmlWriteWalk ( } DbgPrint (ASL_TREE_OUTPUT, - "%08X %04X %04X %01X %04X %04X %04X %04X %08X %08X %08X %08X %08X %04X %02d %02d\n", + "%08X %04X %04X %01X %04X %04X %04X %04X " + "%08X %08X %08X %08X %08X %08X %04X %02d %02d\n", /* 1 */ (UINT32) Op->Asl.Value.Integer, /* 2 */ Op->Asl.ParseOpcode, /* 3 */ Op->Asl.AmlOpcode, @@ -172,13 +179,14 @@ CgAmlWriteWalk ( /* 7 */ Op->Asl.AmlSubtreeLength, /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, /* 9 */ Op, - /* 10 */ Op->Asl.Child, - /* 11 */ Op->Asl.Parent, - /* 12 */ Op->Asl.CompileFlags, - /* 13 */ Op->Asl.AcpiBtype, - /* 14 */ Op->Asl.FinalAmlLength, - /* 15 */ Op->Asl.Column, - /* 16 */ Op->Asl.LineNumber); + /* 10 */ Op->Asl.Parent, + /* 11 */ Op->Asl.Child, + /* 12 */ Op->Asl.Next, + /* 13 */ Op->Asl.CompileFlags, + /* 14 */ Op->Asl.AcpiBtype, + /* 15 */ Op->Asl.FinalAmlLength, + /* 16 */ Op->Asl.Column, + /* 17 */ Op->Asl.LineNumber); /* Generate the AML for this node */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 48ccfa3..cf37c6a 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> +#include <contrib/dev/acpica/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 = DtGetFileSize (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 @@ -593,10 +118,9 @@ CmDoCompile ( AslCompilerparse(); UtEndEvent (Event); - /* Check for parse errors */ + /* Check for parser-detected syntax errors */ - Status = AslCheckForErrorExit (); - if (ACPI_FAILURE (Status)) + if (Gbl_SyntaxError) { fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); LsDumpParseTree (); @@ -617,12 +141,18 @@ CmDoCompile ( goto ErrorExit; } - /* Flush out any remaining source after parse tree is complete */ Event = UtBeginEvent ("Flush source input"); CmFlushSourceCode (); + /* Prune the parse tree if requested (debug purposes only) */ + + if (Gbl_PruneParseTree) + { + AslPruneParseTree (Gbl_PruneDepth, Gbl_PruneType); + } + /* Optional parse tree dump, compiler debug output only */ LsDumpParseTree (); @@ -802,6 +332,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 @@ -825,6 +546,10 @@ CmDoOutputFiles ( /* Dump the namespace to the .nsp file if requested */ (void) NsDisplayNamespace (); + + /* Dump the device mapping file */ + + MpEmitMappingInfo (); } @@ -965,7 +690,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 +751,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/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 132ae7d..7fb2088 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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() */ @@ -123,11 +127,6 @@ ACPI_STATUS (*ASL_PATHNAME_CALLBACK) ( char *); ACPI_STATUS -AslDoOnePathname ( - char *Pathname, - ASL_PATHNAME_CALLBACK Callback); - -ACPI_STATUS AslDoOneFile ( char *Filename); @@ -159,6 +158,14 @@ void CmCleanupAndExit ( void); +void +CmDeleteCaches ( + void); + + +/* + * aslascii - ascii support + */ ACPI_STATUS FlCheckForAcpiTable ( FILE *Handle); @@ -280,14 +287,23 @@ void ApCheckRegMethod ( ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op); + /* * aslerror - error handling/reporting */ void +AslAbort ( + void); + +void AslError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, ACPI_PARSE_OBJECT *Op, char *ExtraMessage); @@ -298,7 +314,7 @@ AslDisableException ( BOOLEAN AslIsExceptionDisabled ( UINT8 Level, - UINT8 MessageId); + UINT16 MessageId); void AslCoreSubsystemError ( @@ -314,7 +330,7 @@ AslCompilererror( void AslCommonError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 CurrentLineNumber, UINT32 LogicalLineNumber, UINT32 LogicalByteOffset, @@ -325,7 +341,7 @@ AslCommonError ( void AslCommonError2 ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 LineNumber, UINT32 Column, char *SourceLine, @@ -346,10 +362,6 @@ void AeClearErrorLog ( void); -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /* * asllisting - generate all "listing" type files @@ -440,6 +452,22 @@ OpcAmlConstantWalk ( /* + * aslmessages - exception strings + */ +const char * +AeDecodeMessageId ( + UINT16 MessageId); + +const char * +AeDecodeExceptionLevel ( + UINT8 Level); + +UINT16 +AeBuildFullExceptionCode ( + UINT8 Level, + UINT16 MessageId); + +/* * asloffset - generate C offset file for BIOS support */ ACPI_STATUS @@ -515,6 +543,27 @@ OptOptimizeNamePath ( /* + * aslprintf - Printf/Fprintf macros + */ +void +OpcDoPrintf ( + ACPI_PARSE_OBJECT *Op); + +void +OpcDoFprintf ( + ACPI_PARSE_OBJECT *Op); + + +/* + * aslprune - parse tree pruner + */ +void +AslPruneParseTree ( + UINT32 PruneDepth, + UINT32 Type); + + +/* * aslcodegen - code generation */ void @@ -656,6 +705,16 @@ TrCreateLeafNode ( UINT32 ParseOpcode); ACPI_PARSE_OBJECT * +TrCreateAssignmentNode ( + ACPI_PARSE_OBJECT *Target, + ACPI_PARSE_OBJECT *Source); + +ACPI_PARSE_OBJECT * +TrCreateTargetOperand ( + ACPI_PARSE_OBJECT *OriginalOp, + ACPI_PARSE_OBJECT *ParentOp); + +ACPI_PARSE_OBJECT * TrCreateValuedLeafNode ( UINT32 ParseOpcode, UINT64 Value); @@ -708,10 +767,6 @@ TrLinkPeerNodes ( * aslfiles - File I/O support */ void -AslAbort ( - void); - -void FlAddIncludeDirectory ( char *Dir); @@ -784,6 +839,13 @@ ACPI_STATUS FlOpenMiscOutputFiles ( char *InputFilename); +/* + * aslhwmap - hardware map summary + */ +void +MpEmitMappingInfo ( + void); + /* * asload - load namespace in prep for cross reference @@ -883,10 +945,6 @@ void UtDisplaySummary ( UINT32 FileId); -UINT8 -UtHexCharToValue ( - int HexChar); - void UtConvertByteToHex ( UINT8 RawByte, @@ -906,13 +964,17 @@ UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length); void UtExpandLineBuffers ( void); +void +UtFreeLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, @@ -948,11 +1010,6 @@ AuValidateUuid ( char *InString); ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuIdBuffer); - -ACPI_STATUS AuConvertUuidToString ( char *UuIdBuffer, char *OutString); @@ -1026,8 +1083,7 @@ RsCheckListForDuplicates ( ASL_RESOURCE_NODE * RsDoOneResourceDescriptor ( - ACPI_PARSE_OBJECT *DescriptorTypeOp, - UINT32 CurrentByteOffset, + ASL_RESOURCE_INFO *Info, UINT8 *State); /* Values for State above */ @@ -1051,43 +1107,35 @@ RsDoResourceTemplate ( */ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoEndDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory24Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory32Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory32FixedDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoStartDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoStartDependentNoPriDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoVendorSmallDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1095,33 +1143,27 @@ RsDoVendorSmallDescriptor ( */ ASL_RESOURCE_NODE * RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoFixedDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1129,61 +1171,50 @@ RsDoIrqNoFlagsDescriptor ( */ ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGpioIntDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGpioIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoI2cSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoSpiSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoUartSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* * aslrestype2d - DWord address descriptors */ ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1191,18 +1222,15 @@ RsDoDwordSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1210,18 +1238,15 @@ RsDoExtendedSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1229,18 +1254,16 @@ RsDoQwordSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoWordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); + /* * Entry to data table compiler subsystem diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index 5b2d9ce..f831233 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,13 +110,56 @@ 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(';'); } - + /* ASL Extension: Standard C operators */ + +"~" { count (3); return (PARSEOP_EXP_NOT); } +"!" { count (3); return (PARSEOP_EXP_LOGICAL_NOT); } +"*" { count (3); return (PARSEOP_EXP_MULTIPLY); } +"/" { count (3); return (PARSEOP_EXP_DIVIDE); } +"%" { count (3); return (PARSEOP_EXP_MODULO); } +"+" { count (3); return (PARSEOP_EXP_ADD); } +"-" { count (3); return (PARSEOP_EXP_SUBTRACT); } +">>" { count (3); return (PARSEOP_EXP_SHIFT_RIGHT); } +"<<" { count (3); return (PARSEOP_EXP_SHIFT_LEFT); } +"<" { count (3); return (PARSEOP_EXP_LESS); } +">" { count (3); return (PARSEOP_EXP_GREATER); } +"&" { count (3); return (PARSEOP_EXP_AND); } +"<=" { count (3); return (PARSEOP_EXP_LESS_EQUAL); } +">=" { count (3); return (PARSEOP_EXP_GREATER_EQUAL); } +"==" { count (3); return (PARSEOP_EXP_EQUAL); } +"!=" { count (3); return (PARSEOP_EXP_NOT_EQUAL); } +"|" { count (3); return (PARSEOP_EXP_OR); } +"&&" { count (3); return (PARSEOP_EXP_LOGICAL_AND); } +"||" { count (3); return (PARSEOP_EXP_LOGICAL_OR); } +"++" { count (3); return (PARSEOP_EXP_INCREMENT); } +"--" { count (3); return (PARSEOP_EXP_DECREMENT); } +"^ " { count (3); return (PARSEOP_EXP_XOR); } + + /* ASL Extension: Standard C assignment operators */ + +"=" { count (3); return (PARSEOP_EXP_EQUALS); } +"+=" { count (3); return (PARSEOP_EXP_ADD_EQ); } +"-=" { count (3); return (PARSEOP_EXP_SUB_EQ); } +"*=" { count (3); return (PARSEOP_EXP_MUL_EQ); } +"/=" { count (3); return (PARSEOP_EXP_DIV_EQ); } +"%=" { count (3); return (PARSEOP_EXP_MOD_EQ); } +"<<=" { count (3); return (PARSEOP_EXP_SHL_EQ); } +">>=" { count (3); return (PARSEOP_EXP_SHR_EQ); } +"&=" { count (3); return (PARSEOP_EXP_AND_EQ); } +"^=" { count (3); return (PARSEOP_EXP_XOR_EQ); } +"|=" { count (3); return (PARSEOP_EXP_OR_EQ); } + + + /* + * Begin standard ASL grammar + */ 0[xX]{HexDigitChar}+ | {DigitChar}+ { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext); count (1); return (PARSEOP_INTEGER); } @@ -591,6 +634,44 @@ NamePathTail [.]{NameSeg} "Transfer8_16" { count (0); return (PARSEOP_XFERTYPE_8_16); } "Transfer16" { count (0); return (PARSEOP_XFERTYPE_16); } + /* ToPld macro */ + +"ToPLD" { count (0); return (PARSEOP_TOPLD); } + +"PLD_Revision" { count (0); return (PARSEOP_PLD_REVISION); } +"PLD_IgnoreColor" { count (0); return (PARSEOP_PLD_IGNORECOLOR); } +"PLD_Red" { count (0); return (PARSEOP_PLD_RED); } +"PLD_Green" { count (0); return (PARSEOP_PLD_GREEN); } +"PLD_Blue" { count (0); return (PARSEOP_PLD_BLUE); } +"PLD_Width" { count (0); return (PARSEOP_PLD_WIDTH); } +"PLD_Height" { count (0); return (PARSEOP_PLD_HEIGHT); } +"PLD_UserVisible" { count (0); return (PARSEOP_PLD_USERVISIBLE); } +"PLD_Dock" { count (0); return (PARSEOP_PLD_DOCK); } +"PLD_Lid" { count (0); return (PARSEOP_PLD_LID); } +"PLD_Panel" { count (0); return (PARSEOP_PLD_PANEL); } +"PLD_VerticalPosition" { count (0); return (PARSEOP_PLD_VERTICALPOSITION); } +"PLD_HorizontalPosition" { count (0); return (PARSEOP_PLD_HORIZONTALPOSITION); } +"PLD_Shape" { count (0); return (PARSEOP_PLD_SHAPE); } +"PLD_GroupOrientation" { count (0); return (PARSEOP_PLD_GROUPORIENTATION); } +"PLD_GroupToken" { count (0); return (PARSEOP_PLD_GROUPTOKEN); } +"PLD_GroupPosition" { count (0); return (PARSEOP_PLD_GROUPPOSITION); } +"PLD_Bay" { count (0); return (PARSEOP_PLD_BAY); } +"PLD_Ejectable" { count (0); return (PARSEOP_PLD_EJECTABLE); } +"PLD_EjectRequired" { count (0); return (PARSEOP_PLD_EJECTREQUIRED); } +"PLD_CabinetNumber" { count (0); return (PARSEOP_PLD_CABINETNUMBER); } +"PLD_CardCageNumber" { count (0); return (PARSEOP_PLD_CARDCAGENUMBER); } +"PLD_Reference" { count (0); return (PARSEOP_PLD_REFERENCE); } +"PLD_Rotation" { count (0); return (PARSEOP_PLD_ROTATION); } +"PLD_Order" { count (0); return (PARSEOP_PLD_ORDER); } +"PLD_Reserved" { count (0); return (PARSEOP_PLD_RESERVED); } +"PLD_VerticalOffset" { count (0); return (PARSEOP_PLD_VERTICALOFFSET); } +"PLD_HorizontalOffset" { count (0); return (PARSEOP_PLD_HORIZONTALOFFSET); } + + + /* printf debug macros */ +"printf" { count (0); return (PARSEOP_PRINTF); } +"fprintf" { count (0); return (PARSEOP_FPRINTF); } + /* Predefined compiler names */ "__DATE__" { count (0); return (PARSEOP___DATE__); } @@ -607,7 +688,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,18 +701,13 @@ 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); } -"*" | -"/" { count (1); - AslCompilererror ("Parse error, expecting ASL keyword or name");} - . { count (1); sprintf (MsgBuffer, "Invalid character (0x%2.2X), expecting ASL keyword or name", @@ -639,9 +715,9 @@ NamePathTail [.]{NameSeg} AslCompilererror (MsgBuffer);} <<EOF>> { if (AslPopInputFileStack ()) - yyterminate(); + {yyterminate();} else - return (PARSEOP_INCLUDE_END);}; + {return (PARSEOP_INCLUDE_END);} }; %% diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 76e2e12..f639ecc 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLDEFINE_H #define __ASLDEFINE_H @@ -50,19 +49,19 @@ * Compiler versions and names */ #define ASL_REVISION ACPI_CA_VERSION -#define ASL_COMPILER_NAME "ASL Optimizing Compiler" -#define AML_DISASSEMBLER_NAME "AML Disassembler" +#define ASL_COMPILER_NAME "ASL+ Optimizing Compiler" +#define AML_DISASSEMBLER_NAME "AML/ASL+ Disassembler" #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0" +#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 */ @@ -109,6 +108,7 @@ #define FILE_SUFFIX_PREPROCESSOR "i" #define FILE_SUFFIX_AML_CODE "aml" +#define FILE_SUFFIX_MAP "map" #define FILE_SUFFIX_LISTING "lst" #define FILE_SUFFIX_HEX_DUMP "hex" #define FILE_SUFFIX_DEBUG "txt" diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index ff6ec36..9b8928c 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define ASL_EXCEPTIONS #include <contrib/dev/acpica/compiler/aslcompiler.h> #define _COMPONENT ACPI_COMPILER @@ -56,6 +55,36 @@ AeAddToErrorLog ( /******************************************************************************* * + * FUNCTION: AslAbort + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump the error log and abort the compiler. Used for serious + * I/O errors. + * + ******************************************************************************/ + +void +AslAbort ( + void) +{ + + AePrintErrorLog (ASL_FILE_STDERR); + if (Gbl_DebugFlag) + { + /* Print error summary to stdout also */ + + AePrintErrorLog (ASL_FILE_STDOUT); + } + + exit (1); +} + + +/******************************************************************************* + * * FUNCTION: AeClearErrorLog * * PARAMETERS: None @@ -174,7 +203,7 @@ AePrintException ( int Actual; size_t RActual; UINT32 MsgLength; - char *MainMessage; + const char *MainMessage; char *ExtraMessage; UINT32 SourceColumn; UINT32 ErrorColumn; @@ -200,6 +229,16 @@ AePrintException ( switch (Enode->Level) { + case ASL_WARNING: + case ASL_WARNING2: + case ASL_WARNING3: + + if (!Gbl_DisplayWarnings) + { + return; + } + break; + case ASL_REMARK: if (!Gbl_DisplayRemarks) @@ -222,11 +261,10 @@ AePrintException ( } } - /* Get the file handles */ + /* Get the various required file handles */ OutputFile = Gbl_Files[FileId].Handle; - if (!Enode->SourceLine) { /* Use the merged header/source file if present, otherwise use input file */ @@ -360,109 +398,93 @@ AePrintException ( } } - /* NULL message ID, just print the raw message */ + /* If a NULL message ID, just print the raw message */ if (Enode->MessageId == 0) { fprintf (OutputFile, "%s\n", Enode->Message); + return; } - else - { - /* Decode the message ID */ - if (Gbl_VerboseErrors) - { - fprintf (OutputFile, "%s %4.4d -", - AslErrorLevel[Enode->Level], - Enode->MessageId + ((Enode->Level+1) * 1000)); - } - else /* IDE case */ - { - fprintf (OutputFile, "%s %4.4d:", - AslErrorLevelIde[Enode->Level], - Enode->MessageId + ((Enode->Level+1) * 1000)); - } + /* Decode the message ID */ - MainMessage = AslMessages[Enode->MessageId]; - ExtraMessage = Enode->Message; + fprintf (OutputFile, "%s %4.4d -", + AeDecodeExceptionLevel (Enode->Level), + AeBuildFullExceptionCode (Enode->Level, Enode->MessageId)); - if (Enode->LineNumber) - { - /* Main message: try to use string from AslMessages first */ + MainMessage = AeDecodeMessageId (Enode->MessageId); + ExtraMessage = Enode->Message; - if (!MainMessage) - { - MainMessage = ""; - } + /* If a NULL line number, just print the decoded message */ - MsgLength = strlen (MainMessage); - if (MsgLength == 0) - { - /* Use the secondary/extra message as main message */ + if (!Enode->LineNumber) + { + fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); + return; + } - MainMessage = Enode->Message; - if (!MainMessage) - { - MainMessage = ""; - } + MsgLength = strlen (MainMessage); + if (MsgLength == 0) + { + /* Use the secondary/extra message as main message */ - MsgLength = strlen (MainMessage); - ExtraMessage = NULL; - } + MainMessage = Enode->Message; + if (!MainMessage) + { + MainMessage = ""; + } - if (Gbl_VerboseErrors && !PrematureEOF) - { - if (Total >= 256) - { - fprintf (OutputFile, " %s", - MainMessage); - } - else - { - SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; - ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; + MsgLength = strlen (MainMessage); + ExtraMessage = NULL; + } - if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) - { - fprintf (OutputFile, "%*s%s", - (int) ((SourceColumn - 1) - ErrorColumn), - MainMessage, " ^ "); - } - else - { - fprintf (OutputFile, "%*s %s", - (int) ((SourceColumn - ErrorColumn) + 1), "^", - MainMessage); - } - } + if (Gbl_VerboseErrors && !PrematureEOF) + { + if (Total >= 256) + { + fprintf (OutputFile, " %s", + MainMessage); + } + else + { + SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; + ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; + + if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) + { + fprintf (OutputFile, "%*s%s", + (int) ((SourceColumn - 1) - ErrorColumn), + MainMessage, " ^ "); } else { - fprintf (OutputFile, " %s", MainMessage); + fprintf (OutputFile, "%*s %s", + (int) ((SourceColumn - ErrorColumn) + 1), "^", + MainMessage); } + } + } + else + { + fprintf (OutputFile, " %s", MainMessage); + } - /* Print the extra info message if present */ + /* Print the extra info message if present */ - if (ExtraMessage) - { - fprintf (OutputFile, " (%s)", ExtraMessage); - } + if (ExtraMessage) + { + fprintf (OutputFile, " (%s)", ExtraMessage); + } - if (PrematureEOF) - { - fprintf (OutputFile, " and premature End-Of-File"); - } + if (PrematureEOF) + { + fprintf (OutputFile, " and premature End-Of-File"); + } - fprintf (OutputFile, "\n"); - if (Gbl_VerboseErrors) - { - fprintf (OutputFile, "\n"); - } - } - else - { - fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); - } + fprintf (OutputFile, "\n"); + if (Gbl_VerboseErrors) + { + fprintf (OutputFile, "\n"); } } @@ -517,7 +539,7 @@ AePrintErrorLog ( void AslCommonError2 ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 LineNumber, UINT32 Column, char *SourceLine, @@ -535,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 */ @@ -549,7 +571,7 @@ AslCommonError2 ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -603,7 +625,7 @@ AslCommonError2 ( void AslCommonError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 CurrentLineNumber, UINT32 LogicalLineNumber, UINT32 LogicalByteOffset, @@ -611,7 +633,6 @@ AslCommonError ( char *Filename, char *ExtraMessage) { - UINT32 MessageSize; char *MessageBuffer = NULL; ASL_ERROR_MSG *Enode; @@ -622,8 +643,7 @@ AslCommonError ( { /* Allocate a buffer for the message and a new error node */ - MessageSize = strlen (ExtraMessage) + 1; - MessageBuffer = UtLocalCalloc (MessageSize); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -634,7 +654,7 @@ AslCommonError ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -739,7 +759,7 @@ AslDisableException ( BOOLEAN AslIsExceptionDisabled ( UINT8 Level, - UINT8 MessageId) + UINT16 MessageId) { UINT32 EncodedMessageId; UINT32 i; @@ -764,7 +784,7 @@ AslIsExceptionDisabled ( * Ignore this warning/remark if it has been disabled by * the user (-vw option) */ - EncodedMessageId = MessageId + ((Level + 1) * 1000); + EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId); for (i = 0; i < Gbl_DisabledMessagesIndex; i++) { /* Simple implementation via fixed array */ @@ -803,14 +823,15 @@ AslIsExceptionDisabled ( void AslError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, ACPI_PARSE_OBJECT *Op, char *ExtraMessage) { /* Check if user wants to ignore this exception */ - if (AslIsExceptionDisabled (Level, MessageId)) + if (Gbl_AllExceptionsDisabled || + AslIsExceptionDisabled (Level, MessageId)) { return; } @@ -836,14 +857,14 @@ AslError ( * FUNCTION: AslCoreSubsystemError * * PARAMETERS: Op - Parse node where error happened - * Status - The ACPI CA Exception + * Status - The ACPICA Exception * ExtraMessage - additional error message * Abort - TRUE -> Abort compilation * * RETURN: None * - * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI - * CA core subsystem. + * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA + * core subsystem. * ******************************************************************************/ @@ -897,6 +918,8 @@ AslCompilererror ( const char *CompilerMessage) { + Gbl_SyntaxError++; + AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename, diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c index 660b82f..cf726dd 100644 --- a/sys/contrib/dev/acpica/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/compiler/aslfileio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/include/acapps.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfileio") @@ -49,36 +50,6 @@ /******************************************************************************* * - * FUNCTION: AslAbort - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Dump the error log and abort the compiler. Used for serious - * I/O errors. - * - ******************************************************************************/ - -void -AslAbort ( - void) -{ - - AePrintErrorLog (ASL_FILE_STDERR); - if (Gbl_DebugFlag) - { - /* Print error summary to stdout also */ - - AePrintErrorLog (ASL_FILE_STDOUT); - } - - exit (1); -} - - -/******************************************************************************* - * * FUNCTION: FlFileError * * PARAMETERS: FileId - Index into file info array @@ -97,8 +68,8 @@ FlFileError ( UINT8 ErrorId) { - sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, - strerror (errno)); + sprintf (MsgBuffer, "\"%s\" (%s) - %s", Gbl_Files[FileId].Filename, + Gbl_Files[FileId].Description, strerror (errno)); AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); } @@ -127,6 +98,9 @@ FlOpenFile ( FILE *File; + Gbl_Files[FileId].Filename = Filename; + Gbl_Files[FileId].Handle = NULL; + File = fopen (Filename, Mode); if (!File) { @@ -134,8 +108,7 @@ FlOpenFile ( AslAbort (); } - Gbl_Files[FileId].Filename = Filename; - Gbl_Files[FileId].Handle = File; + Gbl_Files[FileId].Handle = File; } @@ -147,7 +120,8 @@ FlOpenFile ( * * RETURN: File Size * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. + * DESCRIPTION: Get current file size. Uses common seek-to-EOF function. + * File must be open. Aborts compiler on error. * ******************************************************************************/ @@ -155,20 +129,15 @@ UINT32 FlGetFileSize ( UINT32 FileId) { - FILE *fp; UINT32 FileSize; - long Offset; - - - fp = Gbl_Files[FileId].Handle; - Offset = ftell (fp); - fseek (fp, 0, SEEK_END); - FileSize = (UINT32) ftell (fp); - /* Restore file pointer */ + FileSize = CmGetFileSize (Gbl_Files[FileId].Handle); + if (FileSize == ACPI_UINT32_MAX) + { + AslAbort(); + } - fseek (fp, Offset, SEEK_SET); return (FileSize); } @@ -352,6 +321,8 @@ FlCloseFile ( AslAbort (); } + /* Do not clear/free the filename string */ + Gbl_Files[FileId].Handle = NULL; return; } diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index 2ed9413..63a8dbb 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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 */ @@ -484,6 +485,8 @@ FlOpenAmlOutputFile ( 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } + + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = Filename; } /* Open the output AML file in binary mode */ @@ -562,9 +565,14 @@ FlOpenMiscOutputFiles ( if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle) { - AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, - 0, 0, 0, 0, NULL, NULL); - return (AE_ERROR); + /* + * A problem with freopen is that on error, + * we no longer have stderr. + */ + Gbl_DebugFlag = FALSE; + memcpy (stderr, stdout, sizeof (FILE)); + FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME); + AslAbort (); } AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); @@ -757,6 +765,26 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT); } + /* Create/Open a map file if requested */ + + if (Gbl_MapfileFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the hex file, text mode (closed at compiler exit) */ + + FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t"); + + AslCompilerSignon (ASL_FILE_MAP_OUTPUT); + AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT); + } + return (AE_OK); } @@ -824,6 +852,7 @@ FlParseInputPathname ( *(Substring+1) = 0; } + UtConvertBackslashes (Gbl_OutputFilenamePrefix); return (AE_OK); } #endif diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 00595af..b8038ec 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index 3f2c401..c61b8ff 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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 */ @@ -87,12 +81,12 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "C Source: ", "C Code Output"}, {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, {NULL, NULL, "C Include: ", "C Header Output"}, - {NULL, NULL, "Offset Table: ", "C Offset Table Output"} + {NULL, NULL, "Offset Table: ", "C Offset Table Output"}, + {NULL, NULL, "Device Map: ", "Device Map Output"} }; #else extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern char AslHexLookup[]; extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; #endif @@ -102,12 +96,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 @@ -125,6 +127,7 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0); +ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_SyntaxError, 0); /* Exception reporting */ @@ -140,6 +143,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisassembleAll, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); @@ -159,16 +163,18 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_WarningsAsErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE); -ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayWarnings, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PruneParseTree, FALSE); #define HEX_OUTPUT_NONE 0 @@ -206,6 +212,25 @@ 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); + +/* Map file */ + +ASL_EXTERN ACPI_GPIO_INFO ASL_INIT_GLOBAL (*Gbl_GpioList, NULL); +ASL_EXTERN ACPI_SERIAL_INFO ASL_INIT_GLOBAL (*Gbl_SerialList, NULL); + + /* Misc */ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); @@ -214,10 +239,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); @@ -232,7 +253,8 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0) ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG"); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID"); -ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswinxf only */ +ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_PruneDepth, 0); +ASL_EXTERN UINT16 ASL_INIT_GLOBAL (Gbl_PruneType, 0); /* Static structures */ diff --git a/sys/contrib/dev/acpica/compiler/aslhex.c b/sys/contrib/dev/acpica/compiler/aslhex.c index 8d69b92..f24de1c 100644 --- a/sys/contrib/dev/acpica/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/compiler/aslhex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #define _COMPONENT ACPI_COMPILER diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index 53e860c..618b63f 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index 2b02541..9c51a93 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/asllistsup.c b/sys/contrib/dev/acpica/compiler/asllistsup.c index 795672e..694fbc8 100644 --- a/sys/contrib/dev/acpica/compiler/asllistsup.c +++ b/sys/contrib/dev/acpica/compiler/asllistsup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index bc4d593..c8ae3ad 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __ASLLOAD_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdispat.h> @@ -129,6 +127,7 @@ LdLoadNamespace ( /* Dump the namespace if debug is enabled */ AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); + ACPI_FREE (WalkState); return (AE_OK); } @@ -359,7 +358,6 @@ LdNamespace1Begin ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", Op, Op->Asl.ParseOpName)); - /* * We are only interested in opcodes that have an associated name * (or multiple names) @@ -373,6 +371,34 @@ LdNamespace1Begin ( Status = LdLoadFieldElements (Op, WalkState); return (Status); + case AML_INT_CONNECTION_OP: + + + if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) + { + break; + } + Arg = Op->Asl.Child; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + break; + } + + if (Node->Type == ACPI_TYPE_BUFFER) + { + Arg->Asl.Node = Node; + + Arg = Node->Op->Asl.Child; /* Get namepath */ + Arg = Arg->Asl.Next; /* Get actual buffer */ + Arg = Arg->Asl.Child; /* Buffer length */ + Arg = Arg->Asl.Next; /* RAW_DATA buffer */ + } + break; + default: /* All other opcodes go below */ @@ -466,7 +492,6 @@ LdNamespace1Begin ( ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); break; - case PARSEOP_SCOPE: /* * The name referenced by Scope(Name) must already exist at this point. diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index 66c0950..a527a38 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/acparser.h> @@ -105,7 +104,9 @@ LkFindUnreferencedObjects ( * DESCRIPTION: Check for an unreferenced namespace object and emit a warning. * We have to be careful, because some types and names are * typically or always unreferenced, we don't want to issue - * excessive warnings. + * excessive warnings. Note: Names that are declared within a + * control method are temporary, so we always issue a remark + * if they are not referenced. * ******************************************************************************/ @@ -117,6 +118,7 @@ LkIsObjectUsed ( void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ACPI_NAMESPACE_NODE *Next; /* Referenced flag is set during the namespace xref */ @@ -126,23 +128,19 @@ LkIsObjectUsed ( return (AE_OK); } - /* - * Ignore names that start with an underscore, - * these are the reserved ACPI names and are typically not referenced, - * they are called by the host OS. - */ - if (Node->Name.Ascii[0] == '_') + if (!Node->Op) { return (AE_OK); } - /* There are some types that are typically not referenced, ignore them */ + /* These types are typically never directly referenced, ignore them */ switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: case ACPI_TYPE_LOCAL_RESOURCE: return (AE_OK); @@ -152,12 +150,47 @@ LkIsObjectUsed ( break; } - /* All others are valid unreferenced namespace objects */ + /* Determine if the name is within a control method */ + + Next = Node->Parent; + while (Next) + { + if (Next->Type == ACPI_TYPE_METHOD) + { + /* + * Name is within a method, therefore it is temporary. + * Issue a remark even if it is a reserved name (starts + * with an underscore). + */ + sprintf (MsgBuffer, "Name is within method [%4.4s]", + Next->Name.Ascii); + AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), MsgBuffer); + return (AE_OK); + } + + Next = Next->Parent; + } + + /* The name is not within a control method */ - if (Node->Op) + /* + * Ignore names that start with an underscore. These are the reserved + * ACPI names and are typically not referenced since they are meant + * to be called by the host OS. + */ + if (Node->Name.Ascii[0] == '_') { - AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL); + return (AE_OK); } + + /* + * What remains is an unresolved user name that is not within a method. + * However, the object could be referenced via another table, so issue + * the warning at level 2. + */ + AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), NULL); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 67e561a..d7ba1ae 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,17 @@ #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslmain") +/* + * Main routine for the iASL compiler. + * + * Portability note: The compiler depends upon the host for command-line + * wildcard support - it is not implemented locally. For example: + * + * Linux/Unix systems: Shell expands wildcards automatically. + * + * Windows: The setargv.obj module must be linked in to automatically + * expand wildcards. + */ /* Local prototypes */ @@ -62,6 +73,36 @@ static void AslInitialize ( void); +UINT8 +AcpiIsBigEndianMachine ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiIsBigEndianMachine + * + * PARAMETERS: None + * + * RETURN: TRUE if machine is big endian + * FALSE if machine is little endian + * + * DESCRIPTION: Detect whether machine is little endian or big endian. + * + ******************************************************************************/ + +UINT8 +AcpiIsBigEndianMachine ( + void) +{ + union { + UINT32 Integer; + UINT8 Bytes[4]; + } Overlay = {0xFF000000}; + + return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ +} + /******************************************************************************* * @@ -83,11 +124,21 @@ Usage ( printf ("%s\n\n", ASL_COMPLIANCE); ACPI_USAGE_HEADER ("iasl [Options] [Files]"); - printf ("\nGlobal:\n"); + printf ("\nGeneral:\n"); ACPI_OPTION ("-@ <file>", "Specify command file"); ACPI_OPTION ("-I <dir>", "Specify additional include directory"); ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); + ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); + ACPI_OPTION ("-vo", "Enable optimization comments"); + ACPI_OPTION ("-vs", "Disable signon"); + + printf ("\nHelp:\n"); + ACPI_OPTION ("-h", "This message"); + ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); + ACPI_OPTION ("-hf", "Display help for output filename generation"); + ACPI_OPTION ("-hr", "Display ACPI reserved method names"); + ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); printf ("\nPreprocessor:\n"); ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use"); @@ -95,13 +146,11 @@ Usage ( ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); ACPI_OPTION ("-Pn", "Disable preprocessor"); - printf ("\nGeneral Processing:\n"); - ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); - ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); + printf ("\nErrors, Warnings, and Remarks:\n"); + ACPI_OPTION ("-va", "Disable all errors/warnings/remarks"); + ACPI_OPTION ("-ve", "Report only errors (ignore warnings and remarks)"); ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); - ACPI_OPTION ("-vo", "Enable optimization comments"); ACPI_OPTION ("-vr", "Disable remarks"); - ACPI_OPTION ("-vs", "Disable signon"); ACPI_OPTION ("-vw <messageid>", "Disable specific warning or remark"); ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); ACPI_OPTION ("-we", "Report warnings as errors"); @@ -123,6 +172,7 @@ Usage ( printf ("\nOptional Listing Files:\n"); ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); + ACPI_OPTION ("-lm", "Create hardware summary map file (*.map)"); ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); @@ -131,27 +181,23 @@ Usage ( ACPI_OPTION ("-vt", "Create verbose template files (full disassembly)"); printf ("\nAML Disassembler:\n"); - ACPI_OPTION ("-d <f1,f2>", "Disassemble or decode binary ACPI tables to file (*.dsl)"); + ACPI_OPTION ("-d <f1 f2 ...>", "Disassemble or decode binary ACPI tables to file (*.dsl)"); ACPI_OPTION ("", " (Optional, file type is automatically detected)"); - ACPI_OPTION ("-da <f1,f2>", "Disassemble multiple tables from single namespace"); + ACPI_OPTION ("-da <f1 f2 ...>", "Disassemble multiple tables from single namespace"); ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); - ACPI_OPTION ("-dc <f1,f2>", "Disassemble AML and immediately compile it"); + ACPI_OPTION ("-dc <f1 f2 ...>", "Disassemble AML and immediately compile it"); ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)"); - ACPI_OPTION ("-e <f1,f2>", "Include ACPI table(s) for external symbol resolution"); + ACPI_OPTION ("-dl", "Emit legacy ASL code only (no C-style operators)"); + ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file"); - ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); ACPI_OPTION ("-in", "Ignore NoOp opcodes"); ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); - printf ("\nHelp:\n"); - ACPI_OPTION ("-h", "This message"); - ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); - ACPI_OPTION ("-hf", "Display help for output filename generation"); - ACPI_OPTION ("-hr", "Display ACPI reserved method names"); - ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); - printf ("\nDebug Options:\n"); - ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); + ACPI_OPTION ("-bf", "Create debug file (full output) (*.txt)"); + ACPI_OPTION ("-bs", "Create debug file (parse tree only) (*.txt)"); + ACPI_OPTION ("-bp <depth>", "Prune ASL parse tree"); + ACPI_OPTION ("-bt <type>", "Object type to be pruned from the parse tree"); ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); ACPI_OPTION ("-m <size>", "Set internal line buffer size (in Kbytes)"); ACPI_OPTION ("-n", "Parse only, no output generation"); @@ -286,8 +332,22 @@ main ( ACPI_STATUS Status; int Index1; int Index2; + int ReturnStatus = 0; + + /* + * Big-endian machines are not currently supported. ACPI tables must + * be little-endian, and support for big-endian machines needs to + * be implemented. + */ + if (AcpiIsBigEndianMachine ()) + { + fprintf (stderr, + "iASL is not currently supported on big-endian machines.\n"); + return (-1); + } + AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Initialize preprocessor and compiler before command line processing */ @@ -307,21 +367,11 @@ main ( /* Perform global actions first/only */ - if (Gbl_GetAllTables) - { - Status = AslDoOneFile (NULL); - if (ACPI_FAILURE (Status)) - { - return (-1); - } - return (0); - } - if (Gbl_DisassembleAll) { while (argv[Index1]) { - Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); + Status = AcpiDmAddToExternalFileList (argv[Index1]); if (ACPI_FAILURE (Status)) { return (-1); @@ -335,19 +385,36 @@ main ( while (argv[Index2]) { - Status = AslDoOnePathname (argv[Index2], AslDoOneFile); + /* + * If -p not specified, we will use the input filename as the + * output filename prefix + */ + if (Gbl_UseDefaultAmlFilename) + { + Gbl_OutputFilenamePrefix = argv[Index2]; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); + } + + 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/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index 0d2e636..3d0e327 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -446,7 +446,38 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* XFERTYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0), /* XOR */ OP_TABLE_ENTRY (AML_BIT_XOR_OP, 0, 0, ACPI_BTYPE_INTEGER), /* ZERO */ OP_TABLE_ENTRY (AML_ZERO_OP, 0, 0, ACPI_BTYPE_INTEGER), - +/* TOPLD */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_INTEGER), +/* XFERSIZE_128 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* REVISION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* IGNORECOLOR */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* RED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* GREEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* BLUE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* WIDTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* HEIGHT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* USERVISIBLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* DOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* LID */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* PANEL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* VERTICALPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* HORIZONTALPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* SHAPE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* GROUPORIENTATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* GROUPTOKEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* GROUPPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* BAY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* EJECTABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* EJECTREQUIRED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* CABINETNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* CARDCAGENUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* REFERENCE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* ROTATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* ORDER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* RESERVED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* VERTICALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* HORIZONTALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* PRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE), +/* FPRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE), /*! [End] no source code translation !*/ }; diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c new file mode 100644 index 0000000..a75ff33 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Module Name: aslmapenter - Build resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/compiler/aslcompiler.h> + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmapenter") + +/* Local prototypes */ + +static ACPI_GPIO_INFO * +MpCreateGpioInfo ( + UINT16 PinNumber, + char *DeviceName); + +static ACPI_SERIAL_INFO * +MpCreateSerialInfo ( + char *DeviceName, + UINT16 Address); + + +/******************************************************************************* + * + * FUNCTION: MpSaveGpioInfo + * + * PARAMETERS: Resource - GPIO resource descriptor + * PinCount - From GPIO descriptor + * PinList - From GPIO descriptor + * DeviceName - The "ResourceSource" name + * + * RETURN: None + * + * DESCRIPTION: External Interface. + * Save GPIO resource descriptor information. + * Creates new GPIO info blocks, one for each pin defined by the + * GPIO descriptor. + * + ******************************************************************************/ + +void +MpSaveGpioInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + UINT32 PinCount, + UINT16 *PinList, + char *DeviceName) +{ + ACPI_GPIO_INFO *Info; + UINT32 i; + + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + /* Create an info block for each pin defined in the descriptor */ + + for (i = 0; i < PinCount; i++) + { + Info = MpCreateGpioInfo (PinList[i], DeviceName); + + Info->Op = Op; + Info->DeviceName = DeviceName; + Info->PinCount = PinCount; + Info->PinIndex = i; + Info->PinNumber = PinList[i]; + Info->Type = Resource->Gpio.ConnectionType; + Info->Direction = (UINT8) (Resource->Gpio.IntFlags & 0x0003); /* _IOR, for IO descriptor */ + Info->Polarity = (UINT8) ((Resource->Gpio.IntFlags >> 1) & 0x0003); /* _POL, for INT descriptor */ + } +} + + +/******************************************************************************* + * + * FUNCTION: MpSaveSerialInfo + * + * PARAMETERS: Resource - A Serial resource descriptor + * DeviceName - The "ResourceSource" name. + * + * RETURN: None + * + * DESCRIPTION: External Interface. + * Save serial resource descriptor information. + * Creates a new serial info block. + * + ******************************************************************************/ + +void +MpSaveSerialInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + char *DeviceName) +{ + ACPI_SERIAL_INFO *Info; + UINT16 Address; + UINT32 Speed; + + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + if (Resource->DescriptorType != ACPI_RESOURCE_NAME_SERIAL_BUS) + { + return; + } + + /* Extract address and speed from the resource descriptor */ + + switch (Resource->CommonSerialBus.Type) + { + case AML_RESOURCE_I2C_SERIALBUSTYPE: + + Address = Resource->I2cSerialBus.SlaveAddress; + Speed = Resource->I2cSerialBus.ConnectionSpeed; + break; + + case AML_RESOURCE_SPI_SERIALBUSTYPE: + + Address = Resource->SpiSerialBus.DeviceSelection; + Speed = Resource->SpiSerialBus.ConnectionSpeed; + break; + + case AML_RESOURCE_UART_SERIALBUSTYPE: + + Address = 0; + Speed = Resource->UartSerialBus.DefaultBaudRate; + break; + + default: /* Invalid bus subtype */ + return; + } + + Info = MpCreateSerialInfo (DeviceName, Address); + + Info->Op = Op; + Info->DeviceName = DeviceName; + Info->Resource = Resource; + Info->Address = Address; + Info->Speed = Speed; +} + + +/******************************************************************************* + * + * FUNCTION: MpCreateGpioInfo + * + * PARAMETERS: PinNumber - GPIO pin number + * DeviceName - The "ResourceSource" name + * + * RETURN: New GPIO info block. + * + * DESCRIPTION: Create a new GPIO info block and place it on the global list. + * The list is sorted by GPIO device names first, and pin numbers + * secondarily. + * + ******************************************************************************/ + +static ACPI_GPIO_INFO * +MpCreateGpioInfo ( + UINT16 PinNumber, + char *DeviceName) +{ + ACPI_GPIO_INFO *Info; + ACPI_GPIO_INFO *NextGpio; + ACPI_GPIO_INFO *PrevGpio; + + + /* + * Allocate a new info block and insert it into the global GPIO list + * sorted by both source device name and then the pin number. There is + * one block per pin. + */ + Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, + UtStringCacheCalloc (sizeof (ACPI_GPIO_INFO))); + + NextGpio = Gbl_GpioList; + PrevGpio = NULL; + if (!Gbl_GpioList) + { + Gbl_GpioList = Info; + Info->Next = NULL; + return (Info); + } + + /* Sort on source DeviceName first */ + + while (NextGpio && + (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0)) + { + PrevGpio = NextGpio; + NextGpio = NextGpio->Next; + } + + /* Now sort on the PinNumber */ + + while (NextGpio && + (NextGpio->PinNumber < PinNumber) && + !ACPI_STRCMP (DeviceName, NextGpio->DeviceName)) + { + PrevGpio = NextGpio; + NextGpio = NextGpio->Next; + } + + /* Finish the list insertion */ + + if (PrevGpio) + { + PrevGpio->Next = Info; + } + else + { + Gbl_GpioList = Info; + } + + Info->Next = NextGpio; + return (Info); +} + + +/******************************************************************************* + * + * FUNCTION: MpCreateSerialInfo + * + * PARAMETERS: DeviceName - The "ResourceSource" name. + * Address - Physical address for the device + * + * RETURN: New Serial info block. + * + * DESCRIPTION: Create a new Serial info block and place it on the global list. + * The list is sorted by Serial device names first, and addresses + * secondarily. + * + ******************************************************************************/ + +static ACPI_SERIAL_INFO * +MpCreateSerialInfo ( + char *DeviceName, + UINT16 Address) +{ + ACPI_SERIAL_INFO *Info; + ACPI_SERIAL_INFO *NextSerial; + ACPI_SERIAL_INFO *PrevSerial; + + + /* + * Allocate a new info block and insert it into the global Serial list + * sorted by both source device name and then the address. + */ + Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, + UtStringCacheCalloc (sizeof (ACPI_SERIAL_INFO))); + + NextSerial = Gbl_SerialList; + PrevSerial = NULL; + if (!Gbl_SerialList) + { + Gbl_SerialList = Info; + Info->Next = NULL; + return (Info); + } + + /* Sort on source DeviceName */ + + while (NextSerial && + (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0)) + { + PrevSerial = NextSerial; + NextSerial = NextSerial->Next; + } + + /* Now sort on the Address */ + + while (NextSerial && + (NextSerial->Address < Address) && + !ACPI_STRCMP (DeviceName, NextSerial->DeviceName)) + { + PrevSerial = NextSerial; + NextSerial = NextSerial->Next; + } + + /* Finish the list insertion */ + + if (PrevSerial) + { + PrevSerial->Next = Info; + } + else + { + Gbl_SerialList = Info; + } + + Info->Next = NextSerial; + return (Info); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c new file mode 100644 index 0000000..622b1bd --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c @@ -0,0 +1,642 @@ +/****************************************************************************** + * + * Module Name: aslmapoutput - Output/emit the resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acparser.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/amlcode.h> + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmapoutput") + +/* Local prototypes */ + +static void +MpEmitGpioInfo ( + void); + +static void +MpEmitSerialInfo ( + void); + +static void +MpEmitDeviceTree ( + void); + +static ACPI_STATUS +MpEmitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static void +MpXrefDevices ( + ACPI_GPIO_INFO *Info); + +static ACPI_STATUS +MpNamespaceXrefBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +/* Strings used to decode flag bits */ + +const char *DirectionDecode[] = +{ + "Both I/O ", + "InputOnly ", + "OutputOnly ", + "Preserve " +}; + +const char *PolarityDecode[] = +{ + "ActiveHigh", + "ActiveLow ", + "ActiveBoth", + "Reserved " +}; + + +/******************************************************************************* + * + * FUNCTION: MpEmitMappingInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: External interface. + * Map file has already been opened. Emit all of the collected + * hardware mapping information. Includes: GPIO information, + * Serial information, and a dump of the entire ACPI device tree. + * + ******************************************************************************/ + +void +MpEmitMappingInfo ( + void) +{ + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + if (!Gbl_GpioList) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\nNo GPIO devices found\n"); + } + + if (!Gbl_SerialList) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\nNo Serial devices found (I2C/SPI/UART)\n"); + } + + if (!Gbl_GpioList && !Gbl_SerialList) + { + return; + } + + /* Headers */ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\nResource Descriptor Connectivity Map\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "------------------------------------\n"); + + /* Emit GPIO and Serial descriptors, then entire ACPI device tree */ + + MpEmitGpioInfo (); + MpEmitSerialInfo (); + MpEmitDeviceTree (); + + /* Clear the lists - no need to free memory here */ + + Gbl_SerialList = NULL; + Gbl_GpioList = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitGpioInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit the info about all GPIO devices found during the + * compile or disassembly. + * + ******************************************************************************/ + +static void +MpEmitGpioInfo ( + void) +{ + ACPI_GPIO_INFO *Info; + char *Type; + char *PrevDeviceName = NULL; + const char *Direction; + const char *Polarity; + char *ParentPathname; + const char *Description; + char *HidString; + const AH_DEVICE_ID *HidInfo; + + + /* Walk the GPIO descriptor list */ + + Info = Gbl_GpioList; + while (Info) + { + HidString = MpGetHidViaNamestring (Info->DeviceName); + + /* Print header info for the controller itself */ + + if (!PrevDeviceName || + ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\n\nGPIO Controller: %-8s %-28s", + HidString, Info->DeviceName); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\n\nPin Type Direction Polarity" + " Dest _HID Destination\n"); + } + + PrevDeviceName = Info->DeviceName; + + /* Setup various strings based upon the type (GpioInt or GpioIo) */ + + switch (Info->Type) + { + case AML_RESOURCE_GPIO_TYPE_INT: + + Type = "GpioInt"; + Direction = "-Interrupt-"; + Polarity = PolarityDecode[Info->Polarity]; + break; + + case AML_RESOURCE_GPIO_TYPE_IO: + + Type = "GpioIo "; + Direction = DirectionDecode[Info->Direction]; + Polarity = " "; + break; + + default: + continue; + } + + /* Emit the GPIO info */ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%4.4X %s %s %s ", + Info->PinNumber, Type, Direction, Polarity); + + ParentPathname = NULL; + HidString = MpGetConnectionInfo (Info->Op, Info->PinIndex, + &Info->TargetNode, &ParentPathname); + if (HidString) + { + /* + * This is a Connection() field + * Attempt to find all references to the field. + */ + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + MpXrefDevices (Info); + } + else + { + /* + * For Devices, attempt to get the _HID description string. + * Failing that (many _HIDs are not recognized), attempt to + * get the _DDN description string. + */ + HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode, + &ParentPathname); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + /* Get the _HID description or _DDN string */ + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((Description = MpGetDdnValue (ParentPathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", + Description); + } + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (ParentPathname); + Info = Info->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitSerialInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit the info about all Serial devices found during the + * compile or disassembly. + * + ******************************************************************************/ + +static void +MpEmitSerialInfo ( + void) +{ + ACPI_SERIAL_INFO *Info; + char *Type; + char *ParentPathname; + char *PrevDeviceName = NULL; + char *HidString; + const AH_DEVICE_ID *HidInfo; + const char *Description; + AML_RESOURCE *Resource; + + + /* Walk the constructed serial descriptor list */ + + Info = Gbl_SerialList; + while (Info) + { + Resource = Info->Resource; + switch (Resource->CommonSerialBus.Type) + { + case AML_RESOURCE_I2C_SERIALBUSTYPE: + Type = "I2C "; + break; + + case AML_RESOURCE_SPI_SERIALBUSTYPE: + Type = "SPI "; + break; + + case AML_RESOURCE_UART_SERIALBUSTYPE: + Type = "UART"; + break; + + default: + Type = "UNKN"; + break; + } + + HidString = MpGetHidViaNamestring (Info->DeviceName); + + /* Print header info for the controller itself */ + + if (!PrevDeviceName || + ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ", + Type); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-8s %-28s", + HidString, Info->DeviceName); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "Type Address Speed Dest _HID Destination\n"); + } + + PrevDeviceName = Info->DeviceName; + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%s %4.4X %8.8X ", + Type, Info->Address, Info->Speed); + + ParentPathname = NULL; + HidString = MpGetConnectionInfo (Info->Op, 0, &Info->TargetNode, + &ParentPathname); + if (HidString) + { + /* + * This is a Connection() field + * Attempt to find all references to the field. + */ + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + } + else + { + /* Normal resource template */ + + HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode, + &ParentPathname); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + /* Get the _HID description or _DDN string */ + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((Description = MpGetDdnValue (ParentPathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", + Description); + } + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (ParentPathname); + Info = Info->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitDeviceTree + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit information about all devices within the ACPI namespace. + * + ******************************************************************************/ + +static void +MpEmitDeviceTree ( + void) +{ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nACPI Device Tree\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "----------------\n\n"); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "Device Pathname " + "_HID Description\n\n"); + + /* Walk the namespace from the root */ + + (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitOneDevice + * + * PARAMETERS: ACPI_NAMESPACE_WALK callback + * + * RETURN: Status + * + * DESCRIPTION: Emit information about one ACPI device in the namespace. Used + * during dump of all device objects within the namespace. + * + ******************************************************************************/ + +static ACPI_STATUS +MpEmitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + char *DevicePathname; + char *DdnString; + char *HidString; + const AH_DEVICE_ID *HidInfo; + + + /* Device pathname */ + + DevicePathname = AcpiNsGetExternalPathname ( + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle)); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-32s", DevicePathname); + + /* _HID or _DDN */ + + HidString = MpGetHidValue ( + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle)); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s", HidString); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((DdnString = MpGetDdnValue (DevicePathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", DdnString); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (DevicePathname); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: MpXrefDevices + * + * PARAMETERS: Info - A GPIO Info block + * + * RETURN: None + * + * DESCRIPTION: Cross-reference the parse tree and find all references to the + * specified GPIO device. + * + ******************************************************************************/ + +static void +MpXrefDevices ( + ACPI_GPIO_INFO *Info) +{ + + /* Walk the entire parse tree */ + + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + MpNamespaceXrefBegin, NULL, Info); + + if (!Info->References) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // **** No references in table"); + } +} + + +/******************************************************************************* + * + * FUNCTION: MpNamespaceXrefBegin + * + * PARAMETERS: WALK_PARSE_TREE callback + * + * RETURN: Status + * + * DESCRIPTION: Walk parse tree callback used to cross-reference GPIO pins. + * + ******************************************************************************/ + +static ACPI_STATUS +MpNamespaceXrefBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_GPIO_INFO *Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Context); + const ACPI_OPCODE_INFO *OpInfo; + char *DevicePathname; + ACPI_PARSE_OBJECT *ParentOp; + char *HidString; + + + ACPI_FUNCTION_TRACE_PTR (MpNamespaceXrefBegin, Op); + + /* + * If this node is the actual declaration of a name + * [such as the XXXX name in "Method (XXXX)"], + * we are not interested in it here. We only care about names that + * are references to other objects within the namespace and the + * parent objects of name declarations + */ + if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) + { + return (AE_OK); + } + + /* We are only interested in opcodes that have an associated name */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + + if ((OpInfo->Flags & AML_NAMED) || + (OpInfo->Flags & AML_CREATE)) + { + return (AE_OK); + } + + if ((Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && + (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + ParentOp = Op->Asl.Parent; + if (ParentOp->Asl.ParseOpcode == PARSEOP_FIELD) + { + return (AE_OK); + } + + if (Op->Asl.Node == Info->TargetNode) + { + while (ParentOp && (!ParentOp->Asl.Node)) + { + ParentOp = ParentOp->Asl.Parent; + } + + if (ParentOp) + { + DevicePathname = AcpiNsGetExternalPathname ( + ParentOp->Asl.Node); + + if (!Info->References) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // References:"); + } + + HidString = MpGetHidViaNamestring (DevicePathname); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, " %s [%s]", + DevicePathname, HidString); + + Info->References++; + + ACPI_FREE (DevicePathname); + } + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmaputils.c b/sys/contrib/dev/acpica/compiler/aslmaputils.c new file mode 100644 index 0000000..7b2e611 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmaputils.c @@ -0,0 +1,402 @@ +/****************************************************************************** + * + * Module Name: aslmaputils - Utilities for the resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/amlcode.h> + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmaputils") + + +/******************************************************************************* + * + * FUNCTION: MpGetHidFromParseTree + * + * PARAMETERS: HidNode - Node for a _HID object + * + * RETURN: An _HID string value. Automatically converts _HID integers + * to strings. Never NULL. + * + * DESCRIPTION: Extract a _HID value from the parse tree, not the namespace. + * Used when a fully initialized namespace is not available. + * + ******************************************************************************/ + +char * +MpGetHidFromParseTree ( + ACPI_NAMESPACE_NODE *HidNode) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Arg; + char *HidString; + + + Op = HidNode->Op; + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAME: + + Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ + Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ + + switch (Arg->Asl.ParseOpcode) + { + case PARSEOP_STRING_LITERAL: + + return (Arg->Asl.Value.String); + + case PARSEOP_INTEGER: + + /* Convert EISAID to a string */ + + HidString = UtStringCacheCalloc (ACPI_EISAID_STRING_SIZE); + AcpiExEisaIdToString (HidString, Arg->Asl.Value.Integer); + return (HidString); + + default: + + return ("UNKNOWN"); + } + + default: + return ("-No HID-"); + } +} + + +/******************************************************************************* + * + * FUNCTION: MpGetHidValue + * + * PARAMETERS: DeviceNode - Node for parent device + * + * RETURN: An _HID string value. Automatically converts _HID integers + * to strings. Never NULL. + * + * DESCRIPTION: Extract _HID value from within a device scope. Does not + * actually execute a method, just gets the string or integer + * value for the _HID. + * + ******************************************************************************/ + +char * +MpGetHidValue ( + ACPI_NAMESPACE_NODE *DeviceNode) +{ + ACPI_NAMESPACE_NODE *HidNode; + char *HidString; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__HID, + ACPI_NS_NO_UPSEARCH, &HidNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* If only partial namespace, get the _HID from the parse tree */ + + if (!HidNode->Object) + { + return (MpGetHidFromParseTree (HidNode)); + } + + /* Handle the different _HID flavors */ + + switch (HidNode->Type) + { + case ACPI_TYPE_STRING: + + return (HidNode->Object->String.Pointer); + + case ACPI_TYPE_INTEGER: + + /* Convert EISAID to a string */ + + HidString = UtStringCacheCalloc (ACPI_EISAID_STRING_SIZE); + AcpiExEisaIdToString (HidString, HidNode->Object->Integer.Value); + return (HidString); + + case ACPI_TYPE_METHOD: + + return ("-Method-"); + + default: + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "BAD HID TYPE: %u", HidNode->Type); + break; + } + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetHidViaNamestring + * + * PARAMETERS: DeviceName - Namepath for parent device + * + * RETURN: _HID string. Never NULL. + * + * DESCRIPTION: Get a _HID value via a device pathname (instead of just simply + * a device node.) + * + ******************************************************************************/ + +char * +MpGetHidViaNamestring ( + char *DeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH, + &DeviceNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + return (MpGetHidValue (DeviceNode)); + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetParentDeviceHid + * + * PARAMETERS: Op - Parse Op to be examined + * TargetNode - Where the field node is returned + * ParentDeviceName - Where the node path is returned + * + * RETURN: _HID string. Never NULL. + * + * DESCRIPTION: Find the parent Device or Scope Op, get the full pathname to + * the parent, and get the _HID associated with the parent. + * + ******************************************************************************/ + +char * +MpGetParentDeviceHid ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE **TargetNode, + char **ParentDeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + + + /* Find parent Device() or Scope() Op */ + + while (Op && + (Op->Asl.AmlOpcode != AML_DEVICE_OP) && + (Op->Asl.AmlOpcode != AML_SCOPE_OP)) + { + Op = Op->Asl.Parent; + } + + if (!Op) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Parent_Device "); + goto ErrorExit; + } + + /* Get the full pathname to the device and the _HID */ + + DeviceNode = Op->Asl.Node; + if (!DeviceNode) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Device_Node "); + goto ErrorExit; + } + + *ParentDeviceName = AcpiNsGetExternalPathname (DeviceNode); + return (MpGetHidValue (DeviceNode)); + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetDdnValue + * + * PARAMETERS: DeviceName - Namepath for parent device + * + * RETURN: _DDN description string. NULL on failure. + * + * DESCRIPTION: Execute the _DDN method for the device. + * + ******************************************************************************/ + +char * +MpGetDdnValue ( + char *DeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_NAMESPACE_NODE *DdnNode; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH, + &DeviceNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__DDN, ACPI_NS_NO_UPSEARCH, + &DdnNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + if ((DdnNode->Type != ACPI_TYPE_STRING) || + !DdnNode->Object) + { + goto ErrorExit; + } + + return (DdnNode->Object->String.Pointer); + + +ErrorExit: + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetConnectionInfo + * + * PARAMETERS: Op - Parse Op to be examined + * PinIndex - Index into GPIO PinList + * TargetNode - Where the field node is returned + * TargetName - Where the node path is returned + * + * RETURN: A substitute _HID string, indicating that the name is actually + * a field. NULL if the Op does not refer to a Connection. + * + * DESCRIPTION: Get the Field Unit that corresponds to the PinIndex after + * a Connection() invocation. + * + ******************************************************************************/ + +char * +MpGetConnectionInfo ( + ACPI_PARSE_OBJECT *Op, + UINT32 PinIndex, + ACPI_NAMESPACE_NODE **TargetNode, + char **TargetName) +{ + ACPI_PARSE_OBJECT *NextOp; + UINT32 i; + + + /* + * Handle Connection() here. Find the next named FieldUnit. + * Note: we look at the ParseOpcode for the compiler, look + * at the AmlOpcode for the disassembler. + */ + if ((Op->Asl.AmlOpcode == AML_INT_CONNECTION_OP) || + (Op->Asl.ParseOpcode == PARSEOP_CONNECTION)) + { + /* Find the correct field unit definition */ + + NextOp = Op; + for (i = 0; i <= PinIndex;) + { + NextOp = NextOp->Asl.Next; + while (NextOp && + (NextOp->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (NextOp->Asl.AmlOpcode != AML_INT_NAMEDFIELD_OP)) + { + NextOp = NextOp->Asl.Next; + } + + if (!NextOp) + { + return ("UNKNOWN"); + } + + /* Add length of this field to the current pin index */ + + if (NextOp->Asl.ParseOpcode == PARSEOP_NAMESEG) + { + i += (UINT32) NextOp->Asl.Child->Asl.Value.Integer; + } + else /* AML_INT_NAMEDFIELD_OP */ + { + i += (UINT32) NextOp->Asl.Value.Integer; + } + } + + /* Return the node and pathname for the field unit */ + + *TargetNode = NextOp->Asl.Node; + *TargetName = AcpiNsGetExternalPathname (*TargetNode); + return ("-Field-"); + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c new file mode 100644 index 0000000..12a4208 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmessages.c @@ -0,0 +1,409 @@ +/****************************************************************************** + * + * Module Name: aslmessages.c - Compiler error/warning message strings + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/compiler/aslcompiler.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmessages") + + +/* + * Strings for message reporting levels, must match error + * type string tables in aslmessages.c + */ +const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { + "Optimize", + "Remark ", + "Warning ", + "Warning ", + "Warning ", + "Error " +}; + +/* All lowercase versions for IDEs */ + +const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { + "optimize", + "remark ", + "warning ", + "warning ", + "warning ", + "error " +}; + + +/* + * Actual message strings for each compiler message ID. There are currently + * three distinct blocks of error messages (so that they can be expanded + * individually): + * Main ASL compiler + * Data Table compiler + * Preprocessor + * + * NOTE1: These tables must match the enum list of message IDs in the file + * aslmessages.h exactly. + * + * NOTE2: With the introduction of the -vw option to disable specific messages, + * new messages should only be added to the end of this list, so that values + * for existing messages are not disturbed. + */ + +/* ASL compiler */ + +const char *AslCompilerMsgs [] = +{ +/* The zeroth message is reserved */ "", +/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", +/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", +/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", +/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", +/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", +/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", +/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", +/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", +/* ASL_MSG_CLOSE */ "Could not close file", +/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", +/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", +/* ASL_MSG_CONNECTION_MISSING */ "A Connection operator is required for this field SpaceId", +/* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator", +/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", +/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", +/* ASL_MSG_CORE_EXCEPTION */ "From ACPICA Subsystem", +/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", +/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", +/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested", +/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", +/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", +/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", +/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", +/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", +/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", +/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", +/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", +/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", +/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", +/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", +/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", +/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method", +/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters", +/* ASL_MSG_HID_PREFIX */ "_HID prefix must be all uppercase or decimal digits", +/* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", +/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", +/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", +/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", +/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", +/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", +/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", +/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", +/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags", +/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", +/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", +/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", +/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", +/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", +/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", +/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", +/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", +/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", +/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", +/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", +/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", +/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", +/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", +/* ASL_MSG_INVALID_TYPE */ "Invalid type", +/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", +/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", +/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk", +/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length", +/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length", +/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", +/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", +/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", +/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", +/* ASL_MSG_LONG_LINE */ "Splitting long input line", +/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", +/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", +/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", +/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", +/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", +/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", +/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", +/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", +/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", +/* ASL_MSG_NO_CASES */ "No Case statements under Switch", +/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region", +/* ASL_MSG_NO_RETVAL */ "Called method returns no value", +/* ASL_MSG_NO_WHILE */ "No enclosing While statement", +/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", +/* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", +/* ASL_MSG_NOT_EXIST */ "Object does not exist", +/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", +/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", +/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", +/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", +/* ASL_MSG_NOT_REFERENCED */ "Object is not referenced", +/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", +/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", +/* ASL_MSG_OPEN */ "Could not open file", +/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", +/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", +/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", +/* ASL_MSG_PREPROCESSOR_FILENAME */ "Could not create preprocessor filename", +/* ASL_MSG_READ */ "Could not read file", +/* ASL_MSG_RECURSION */ "Recursive method call", +/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", +/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", +/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", +/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", +/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", +/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value", +/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name", +/* ASL_MSG_RESERVED_PACKAGE_LENGTH */ "Invalid package length for reserved name", +/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", +/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", +/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", +/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", +/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", +/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", +/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", +/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", +/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", +/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed", +/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", +/* ASL_MSG_SEEK */ "Could not seek file", +/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", +/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", +/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", +/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", +/* ASL_MSG_STRING_LENGTH */ "String literal too long", +/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", +/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", +/* ASL_MSG_SYNTAX */ "", +/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", +/* ASL_MSG_TAG_LARGER */ "ResourceTag larger than Field", +/* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", +/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", +/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", +/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", +/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", +/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", +/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", +/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case", +/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", +/* 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 */ + +const char *AslTableCompilerMsgs [] = +{ +/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list", +/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero", +/* ASL_MSG_FLAG_VALUE */ "Flag value is too large", +/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target", +/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression", +/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name", +/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant", +/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents", +/* ASL_MSG_RESERVED_VALUE */ "Reserved field", +/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined", +/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type", +/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature", +/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero" +}; + +/* Preprocessor */ + +const char *AslPreprocessorMsgs [] = +{ +/* ASL_MSG_DIRECTIVE_SYNTAX */ "Invalid directive syntax", +/* ASL_MSG_ENDIF_MISMATCH */ "Mismatched #endif", +/* ASL_MSG_ERROR_DIRECTIVE */ "#error", +/* ASL_MSG_EXISTING_NAME */ "Name is already defined", +/* ASL_MSG_INVALID_INVOCATION */ "Invalid macro invocation", +/* ASL_MSG_MACRO_SYNTAX */ "Invalid macro syntax", +/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments", +/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive", +/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma", +/* ASL_MSG_WARNING_DIRECTIVE */ "#warning" +}; + + +/******************************************************************************* + * + * FUNCTION: AeDecodeMessageId + * + * PARAMETERS: MessageId - ASL message ID (exception code) to be + * formatted. Possibly fully encoded. + * + * RETURN: A string containing the exception message text. + * + * DESCRIPTION: This function validates and translates an ASL message ID into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AeDecodeMessageId ( + UINT16 MessageId) +{ + UINT32 Index; + const char **MessageTable; + + + /* Main ASL Compiler messages */ + + if (MessageId <= ASL_MSG_MAIN_COMPILER_END) + { + MessageTable = AslCompilerMsgs; + Index = MessageId; + + if (Index >= ACPI_ARRAY_LENGTH (AslCompilerMsgs)) + { + return ("[Unknown ASL Compiler exception ID]"); + } + } + + /* Data Table Compiler messages */ + + else if (MessageId <= ASL_MSG_TABLE_COMPILER_END) + { + MessageTable = AslTableCompilerMsgs; + Index = MessageId - ASL_MSG_TABLE_COMPILER; + + if (Index >= ACPI_ARRAY_LENGTH (AslTableCompilerMsgs)) + { + return ("[Unknown Table Compiler exception ID]"); + } + } + + /* Preprocessor messages */ + + else if (MessageId <= ASL_MSG_PREPROCESSOR_END) + { + MessageTable = AslPreprocessorMsgs; + Index = MessageId - ASL_MSG_PREPROCESSOR; + + if (Index >= ACPI_ARRAY_LENGTH (AslPreprocessorMsgs)) + { + return ("[Unknown Preprocesor exception ID]"); + } + } + + /* Everything else is unknown */ + + else + { + return ("[Unknown exception/component ID]"); + } + + return (MessageTable[Index]); +} + + +/******************************************************************************* + * + * FUNCTION: AeDecodeExceptionLevel + * + * PARAMETERS: Level - The ASL error level to be decoded + * + * RETURN: A string containing the error level text + * + * DESCRIPTION: This function validates and translates an ASL error level into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AeDecodeExceptionLevel ( + UINT8 Level) +{ + /* Range check on Level */ + + if (Level >= ACPI_ARRAY_LENGTH (AslErrorLevel)) + { + return ("Unknown exception level"); + } + + /* Differentiate the string type to be used (IDE is all lower case) */ + + if (Gbl_VerboseErrors) + { + return (AslErrorLevel[Level]); + } + + return (AslErrorLevelIde[Level]); +} + + +/******************************************************************************* + * + * FUNCTION: AeBuildFullExceptionCode + * + * PARAMETERS: Level - ASL error level + * MessageId - ASL exception code to be formatted + * + * RETURN: Fully encoded exception code + * + * DESCRIPTION: Build the full exception code from the error level and the + * actual message ID. + * + ******************************************************************************/ + +UINT16 +AeBuildFullExceptionCode ( + UINT8 Level, + UINT16 MessageId) +{ + + /* + * Error level is in the thousands slot (error/warning/remark, etc.) + * Error codes are 0 - 999 + */ + return (((Level + 1) * 1000) + MessageId); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h index 9fb7229..7a04a63 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/compiler/aslmessages.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,11 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLMESSAGES_H #define __ASLMESSAGES_H +/* These values must match error type string tables in aslmessages.c */ + typedef enum { ASL_OPTIMIZATION = 0, @@ -58,43 +59,41 @@ typedef enum } ASL_MESSAGE_TYPES; -#ifdef ASL_EXCEPTIONS -/* Strings for message reporting levels, must match values above */ +#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings for types above */ -const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { - "Optimize", - "Remark ", - "Warning ", - "Warning ", - "Warning ", - "Error " -}; +/* + * Exception code blocks, 0 - 999 + * Available for new exception blocks: 600 - 999 + */ +#define ASL_MSG_MAIN_COMPILER 0 /* 0 - 299 */ +#define ASL_MSG_MAIN_COMPILER_END 299 -/* All lowercase versions for IDEs */ +#define ASL_MSG_TABLE_COMPILER 300 /* 300 - 499 */ +#define ASL_MSG_TABLE_COMPILER_END 499 -const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { - "optimize", - "remark ", - "warning ", - "warning ", - "warning ", - "error " -}; +#define ASL_MSG_PREPROCESSOR 500 /* 500 - 599 */ +#define ASL_MSG_PREPROCESSOR_END 599 -#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ -#endif /* - * Values for all compiler messages. + * Values (message IDs) for all compiler messages. There are currently + * three distinct blocks of error messages (so that they can be expanded + * individually): + * Main ASL compiler + * Data Table compiler + * Preprocessor + * + * NOTE1: This list must match the tables of message strings in the file + * aslmessages.c exactly. * - * NOTE: With the introduction of the -vw option to disable specific messages, - * new messages should only be added to the end of this list, so that values - * for existing messages are not disturbed. + * NOTE2: With the introduction of the -vw option to disable specific + * messages, new messages should only be added to the end of these + * lists, so that values for existing messages are not disturbed. */ typedef enum { - ASL_MSG_RESERVED = 0, + ASL_MSG_RESERVED = ASL_MSG_MAIN_COMPILER, ASL_MSG_ALIGNMENT, ASL_MSG_ALPHANUMERIC_STRING, @@ -236,23 +235,13 @@ 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 Preprocessor only */ + /* These messages are used by the Data Table compiler only */ - ASL_MSG_DIRECTIVE_SYNTAX, - ASL_MSG_ENDIF_MISMATCH, - ASL_MSG_ERROR_DIRECTIVE, - ASL_MSG_EXISTING_NAME, - ASL_MSG_INVALID_INVOCATION, - ASL_MSG_MACRO_SYNTAX, - ASL_MSG_TOO_MANY_ARGUMENTS, - ASL_MSG_UNKNOWN_DIRECTIVE, - ASL_MSG_UNKNOWN_PRAGMA, - ASL_MSG_WARNING_DIRECTIVE, - - /* These messages are used by the data table compiler only */ - - ASL_MSG_BUFFER_ELEMENT, + ASL_MSG_BUFFER_ELEMENT = ASL_MSG_TABLE_COMPILER, ASL_MSG_DIVIDE_BY_ZERO, ASL_MSG_FLAG_VALUE, ASL_MSG_INTEGER_SIZE, @@ -264,194 +253,22 @@ typedef enum ASL_MSG_UNKNOWN_LABEL, ASL_MSG_UNKNOWN_SUBTABLE, ASL_MSG_UNKNOWN_TABLE, - ASL_MSG_ZERO_VALUE - -} ASL_MESSAGE_IDS; + ASL_MSG_ZERO_VALUE, + /* These messages are used by the Preprocessor only */ -#ifdef ASL_EXCEPTIONS - -/* - * Actual message strings for each compiler message. - * - * NOTE: With the introduction of the -vw option to disable specific messages, - * new messages should only be added to the end of this list, so that values - * for existing messages are not disturbed. - */ -char *AslMessages [] = -{ -/* The zeroth message is reserved */ "", -/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", -/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", -/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", -/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", -/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", -/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", -/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", -/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", -/* ASL_MSG_CLOSE */ "Could not close file", -/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", -/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", -/* ASL_MSG_CONNECTION_MISSING */ "A Connection operator is required for this field SpaceId", -/* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator", -/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", -/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", -/* ASL_MSG_CORE_EXCEPTION */ "From ACPI CA Subsystem", -/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", -/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", -/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",\ -/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", -/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", -/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", -/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", -/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", -/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", -/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", -/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", -/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", -/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", -/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", -/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", -/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method", -/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters", -/* ASL_MSG_HID_PREFIX */ "_HID prefix must be all uppercase or decimal digits", -/* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", -/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", -/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", -/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", -/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", -/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", -/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", -/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", -/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags", -/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", -/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", -/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", -/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", -/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", -/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", -/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", -/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", -/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", -/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", -/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", -/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", -/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", -/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", -/* ASL_MSG_INVALID_TYPE */ "Invalid type", -/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", -/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", -/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk", -/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length", -/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length", -/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", -/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", -/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", -/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", -/* ASL_MSG_LONG_LINE */ "Splitting long input line", -/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", -/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", -/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", -/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", -/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", -/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", -/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", -/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", -/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", -/* ASL_MSG_NO_CASES */ "No Case statements under Switch", -/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region", -/* ASL_MSG_NO_RETVAL */ "Called method returns no value", -/* ASL_MSG_NO_WHILE */ "No enclosing While statement", -/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", -/* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", -/* ASL_MSG_NOT_EXIST */ "Object does not exist", -/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", -/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", -/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", -/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", -/* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", -/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", -/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", -/* ASL_MSG_OPEN */ "Could not open file", -/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", -/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", -/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", -/* ASL_MSG_PREPROCESSOR_FILENAME */ "Could not create preprocessor filename", -/* ASL_MSG_READ */ "Could not read file", -/* ASL_MSG_RECURSION */ "Recursive method call", -/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", -/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", -/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", -/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", -/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", -/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value", -/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name", -/* ASL_MSG_RESERVED_PACKAGE_LENGTH */ "Invalid package length for reserved name", -/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", -/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", -/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", -/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", -/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", -/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", -/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", -/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", -/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", -/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed", -/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", -/* ASL_MSG_SEEK */ "Could not seek file", -/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", -/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", -/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", -/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", -/* ASL_MSG_STRING_LENGTH */ "String literal too long", -/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", -/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", -/* ASL_MSG_SYNTAX */ "", -/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", -/* ASL_MSG_TAG_LARGER */ "ResourceTag larger than Field", -/* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", -/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", -/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", -/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", -/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", -/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", -/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", -/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case", -/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", -/* ASL_MSG_WRITE */ "Could not write file", -/* ASL_MSG_RANGE */ "Constant out of range", -/* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", - -/* Preprocessor */ - -/* ASL_MSG_DIRECTIVE_SYNTAX */ "Invalid directive syntax", -/* ASL_MSG_ENDIF_MISMATCH */ "Mismatched #endif", -/* ASL_MSG_ERROR_DIRECTIVE */ "#error", -/* ASL_MSG_EXISTING_NAME */ "Name is already defined", -/* ASL_MSG_INVALID_INVOCATION */ "Invalid macro invocation", -/* ASL_MSG_MACRO_SYNTAX */ "Invalid macro syntax", -/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments", -/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive", -/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma", -/* ASL_MSG_WARNING_DIRECTIVE */ "#warning", - -/* Table compiler */ + ASL_MSG_DIRECTIVE_SYNTAX = ASL_MSG_PREPROCESSOR, + ASL_MSG_ENDIF_MISMATCH, + ASL_MSG_ERROR_DIRECTIVE, + ASL_MSG_EXISTING_NAME, + ASL_MSG_INVALID_INVOCATION, + ASL_MSG_MACRO_SYNTAX, + ASL_MSG_TOO_MANY_ARGUMENTS, + ASL_MSG_UNKNOWN_DIRECTIVE, + ASL_MSG_UNKNOWN_PRAGMA, + ASL_MSG_WARNING_DIRECTIVE, -/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list", -/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero", -/* ASL_MSG_FLAG_VALUE */ "Flag value is too large", -/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target", -/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression", -/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name", -/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant", -/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents", -/* ASL_MSG_RESERVED_VALUE */ "Reserved field must be zero", -/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined", -/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type", -/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature", -/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero" -}; +} ASL_MESSAGE_IDS; -#endif /* ASL_EXCEPTIONS */ #endif /* __ASLMESSAGES_H */ diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c index 72f7647..fa9216e 100644 --- a/sys/contrib/dev/acpica/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/compiler/aslmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/acparser.h> @@ -108,7 +107,42 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; - /* Get the name node, ignored here */ + /* + * 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: @@ -412,6 +457,7 @@ MtMethodAnalysisWalkBegin ( AnCheckId (Next, ASL_TYPE_CID); } } + break; default: diff --git a/sys/contrib/dev/acpica/compiler/aslnamesp.c b/sys/contrib/dev/acpica/compiler/aslnamesp.c index e7ad672..720d394 100644 --- a/sys/contrib/dev/acpica/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/compiler/aslnamesp.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/acnamesp.h> diff --git a/sys/contrib/dev/acpica/compiler/asloffset.c b/sys/contrib/dev/acpica/compiler/asloffset.c index 390a118..14f7e95 100644 --- a/sys/contrib/dev/acpica/compiler/asloffset.c +++ b/sys/contrib/dev/acpica/compiler/asloffset.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index 6d39da9..d4dbbe3 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> @@ -69,9 +68,62 @@ OpcDoEisaId ( ACPI_PARSE_OBJECT *Op); static void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op); + +static void OpcDoUuId ( ACPI_PARSE_OBJECT *Op); +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo); + + +/* ToPld strings */ + +static char *AslPldPanelList[] = +{ + "TOP", + "BOTTOM", + "LEFT", + "RIGHT", + "FRONT", + "BACK", + "UNKNOWN", + NULL +}; + +static char *AslPldVerticalPositionList[] = +{ + "UPPER", + "CENTER", + "LOWER", + NULL +}; + +static char *AslPldHorizontalPositionList[] = +{ + "LEFT", + "CENTER", + "RIGHT", + NULL +}; + +static char *AslPldShapeList[] = +{ + "ROUND", + "OVAL", + "SQUARE", + "VERTICALRECTANGLE", + "HORIZONTALRECTANGLE", + "VERTICALTRAPEZOID", + "HORIZONTALTRAPEZOID", + "UNKNOWN", + "CHAMFERED", + NULL +}; + /******************************************************************************* * @@ -403,6 +455,7 @@ OpcDoConnection ( ACPI_PARSE_OBJECT *BufferOp; ACPI_PARSE_OBJECT *BufferLengthOp; ACPI_PARSE_OBJECT *BufferDataOp; + ASL_RESOURCE_INFO Info; UINT8 State; @@ -417,8 +470,10 @@ OpcDoConnection ( BufferLengthOp = BufferOp->Asl.Child; BufferDataOp = BufferLengthOp->Asl.Next; + Info.DescriptorTypeOp = BufferDataOp->Asl.Next; + Info.CurrentByteOffset = 0; State = ACPI_RSTATE_NORMAL; - Rnode = RsDoOneResourceDescriptor (BufferDataOp->Asl.Next, 0, &State); + Rnode = RsDoOneResourceDescriptor (&Info, &State); if (!Rnode) { return; /* error */ @@ -623,10 +678,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) */ @@ -651,9 +706,698 @@ OpcDoEisaId ( /******************************************************************************* * + * FUNCTION: OpcEncodePldBuffer + * + * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) + * + * RETURN: Encode _PLD buffer suitable for return value from _PLD + * + * DESCRIPTION: Bit-packs a _PLD buffer struct. + * + ******************************************************************************/ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo) +{ + UINT32 *Buffer; + UINT32 Dword; + + + Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); + if (!Buffer) + { + return (NULL); + } + + /* First 32 bits */ + + Dword = 0; + ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); + ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); + ACPI_PLD_SET_RED (&Dword, PldInfo->Red); + ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); + ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); + ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); + + /* Second 32 bits */ + + Dword = 0; + ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); + ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); + ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); + + /* Third 32 bits */ + + Dword = 0; + ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); + ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); + ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); + ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); + ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); + ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); + ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); + ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); + ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); + ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); + ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); + ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); + + /* Fourth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); + ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); + ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); + ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); + ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); + ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); + ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); + ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); + + if (PldInfo->Revision >= 2) + { + /* Fifth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); + ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); + ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); + } + + return (ACPI_CAST_PTR (UINT8, Buffer)); +} + + +/******************************************************************************* + * + * FUNCTION: OpcStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +static void +OpcStrupr ( + char *SrcString) +{ + char *String; + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) toupper ((int) *String); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: OpcFindName + * + * PARAMETERS: List - Array of char strings to be searched + * Name - Char string to string for + * Index - Index value to set if found + * + * RETURN: TRUE if any names matched, FALSE otherwise + * + * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to + * equivalent parameter value. + * + ******************************************************************************/ + +static BOOLEAN +OpcFindName ( + char **List, + char *Name, + UINT64 *Index) +{ + char *Str; + UINT32 i; + + + OpcStrupr (Name); + + for (i = 0, Str = List[0]; Str; i++, Str = List[i]) + { + if (!(ACPI_STRNCMP (Str, Name, ACPI_STRLEN (Name)))) + { + *Index = i; + return (TRUE); + } + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: OpcDoPld + * + * PARAMETERS: Op - Parse node + * + * RETURN: None + * + * DESCRIPTION: Convert ToPLD macro to 20-byte buffer + * + ******************************************************************************/ + +static void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *Buffer; + ACPI_PARSE_OBJECT *Node; + ACPI_PLD_INFO PldInfo; + ACPI_PARSE_OBJECT *NewOp; + + + if (!Op) + { + AslError(ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL); + return; + } + + if (Op->Asl.ParseOpcode != PARSEOP_TOPLD) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL); + return; + } + + Buffer = UtLocalCalloc (ACPI_PLD_BUFFER_SIZE); + if (!Buffer) + { + AslError(ASL_ERROR, ASL_MSG_BUFFER_ALLOCATION, Op, NULL); + return; + } + + ACPI_MEMSET (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); + + Node = Op->Asl.Child; + while (Node) + { + switch (Node->Asl.ParseOpcode) + { + case PARSEOP_PLD_REVISION: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 127) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + PldInfo.Revision = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_IGNORECOLOR: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 1) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + PldInfo.IgnoreColor = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_RED: + case PARSEOP_PLD_GREEN: + case PARSEOP_PLD_BLUE: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 255) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_RED) + { + PldInfo.Red = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else if (Node->Asl.ParseOpcode == PARSEOP_PLD_GREEN) + { + PldInfo.Green = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_BLUE */ + { + PldInfo.Blue = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + break; + + case PARSEOP_PLD_WIDTH: + case PARSEOP_PLD_HEIGHT: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 65535) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) + { + PldInfo.Width = (UINT16) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_HEIGHT */ + { + PldInfo.Height = (UINT16) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + case PARSEOP_PLD_USERVISIBLE: + case PARSEOP_PLD_DOCK: + case PARSEOP_PLD_LID: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 1) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) + { + PldInfo.UserVisible = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else if (Node->Asl.ParseOpcode == PARSEOP_PLD_DOCK) + { + PldInfo.Dock = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else + { + PldInfo.Lid = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + case PARSEOP_PLD_PANEL: + + if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) + { + if (Node->Asl.Child->Asl.Value.Integer > 6) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName(AslPldPanelList, + Node->Asl.Child->Asl.Value.String, + &Node->Asl.Child->Asl.Value.Integer)) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); + break; + } + } + + PldInfo.Panel = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_VERTICALPOSITION: + + if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) + { + if (Node->Asl.Child->Asl.Value.Integer > 2) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName(AslPldVerticalPositionList, + Node->Asl.Child->Asl.Value.String, + &Node->Asl.Child->Asl.Value.Integer)) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); + break; + } + } + + PldInfo.VerticalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_HORIZONTALPOSITION: + + if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) + { + if (Node->Asl.Child->Asl.Value.Integer > 2) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName(AslPldHorizontalPositionList, + Node->Asl.Child->Asl.Value.String, + &Node->Asl.Child->Asl.Value.Integer)) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); + break; + } + } + + PldInfo.HorizontalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_SHAPE: + + if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) + { + if (Node->Asl.Child->Asl.Value.Integer > 8) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName(AslPldShapeList, + Node->Asl.Child->Asl.Value.String, + &Node->Asl.Child->Asl.Value.Integer)) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); + break; + } + } + + PldInfo.Shape = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_GROUPORIENTATION: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 1) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + PldInfo.GroupOrientation = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_GROUPTOKEN: + case PARSEOP_PLD_GROUPPOSITION: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 255) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) + { + PldInfo.GroupToken = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_GROUPPOSITION */ + { + PldInfo.GroupPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + case PARSEOP_PLD_BAY: + case PARSEOP_PLD_EJECTABLE: + case PARSEOP_PLD_EJECTREQUIRED: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 1) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_BAY) + { + PldInfo.Bay = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else if (Node->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) + { + PldInfo.Ejectable = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_EJECTREQUIRED */ + { + PldInfo.OspmEjectRequired = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + case PARSEOP_PLD_CABINETNUMBER: + case PARSEOP_PLD_CARDCAGENUMBER: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 255) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) + { + PldInfo.CabinetNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_CARDCAGENUMBER */ + { + PldInfo.CardCageNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + case PARSEOP_PLD_REFERENCE: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 1) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + PldInfo.Reference = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_ROTATION: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 7) + { + switch (Node->Asl.Child->Asl.Value.Integer) + { + case 45: + + Node->Asl.Child->Asl.Value.Integer = 1; + break; + + case 90: + + Node->Asl.Child->Asl.Value.Integer = 2; + break; + + case 135: + + Node->Asl.Child->Asl.Value.Integer = 3; + break; + + case 180: + + Node->Asl.Child->Asl.Value.Integer = 4; + break; + + case 225: + + Node->Asl.Child->Asl.Value.Integer = 5; + break; + + case 270: + + Node->Asl.Child->Asl.Value.Integer = 6; + break; + + case 315: + + Node->Asl.Child->Asl.Value.Integer = 7; + break; + + default: + + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + } + + PldInfo.Rotation = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_ORDER: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 31) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + PldInfo.Order = (UINT8) Node->Asl.Child->Asl.Value.Integer; + break; + + case PARSEOP_PLD_VERTICALOFFSET: + case PARSEOP_PLD_HORIZONTALOFFSET: + + if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + if (Node->Asl.Child->Asl.Value.Integer > 65535) + { + AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); + break; + } + + if (Node->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) + { + PldInfo.VerticalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; + } + else /* PARSEOP_PLD_HORIZONTALOFFSET */ + { + PldInfo.HorizontalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; + } + + break; + + default: + + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); + break; + } + + Node = Node->Asl.Next; + } + + Buffer = OpcEncodePldBuffer(&PldInfo); + + /* Change Op to a Buffer */ + + Op->Asl.ParseOpcode = PARSEOP_BUFFER; + Op->Common.AmlOpcode = AML_BUFFER_OP; + + /* Disable further optimization */ + + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; + UtSetParseOpName (Op); + + /* Child node is the buffer length */ + + NewOp = TrAllocateNode (PARSEOP_INTEGER); + + NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.Value.Integer = 20; + NewOp->Asl.Parent = Op; + + Op->Asl.Child = NewOp; + Op = NewOp; + + /* Peer to the child is the raw buffer data */ + + NewOp = TrAllocateNode (PARSEOP_RAW_DATA); + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 20; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); + NewOp->Asl.Parent = Op->Asl.Parent; + + Op->Asl.Next = NewOp; +} + + +/******************************************************************************* + * * FUNCTION: OpcDoUuId * - * PARAMETERS: Op - Parse node + * PARAMETERS: Op - Parse node * * RETURN: None * @@ -666,12 +1410,12 @@ OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { char *InString; - char *Buffer; + UINT8 *Buffer; ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *NewOp; - InString = (char *) Op->Asl.Value.String; + InString = ACPI_CAST_PTR (char, Op->Asl.Value.String); Buffer = UtLocalCalloc (16); Status = AuValidateUuid (InString); @@ -681,7 +1425,7 @@ OpcDoUuId ( } else { - (void) AuConvertStringToUuid (InString, Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ @@ -710,7 +1454,7 @@ OpcDoUuId ( NewOp = TrAllocateNode (PARSEOP_RAW_DATA); NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; NewOp->Asl.AmlLength = 16; - NewOp->Asl.Value.String = (char *) Buffer; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); NewOp->Asl.Parent = Op->Asl.Parent; Op->Asl.Next = NewOp; @@ -721,7 +1465,7 @@ OpcDoUuId ( * * FUNCTION: OpcGenerateAmlOpcode * - * PARAMETERS: Op - Parse node + * PARAMETERS: Op - Parse node * * RETURN: None * @@ -735,7 +1479,6 @@ void OpcGenerateAmlOpcode ( ACPI_PARSE_OBJECT *Op) { - UINT16 Index; @@ -781,6 +1524,21 @@ OpcGenerateAmlOpcode ( OpcDoEisaId (Op); break; + case PARSEOP_PRINTF: + + OpcDoPrintf (Op); + break; + + case PARSEOP_FPRINTF: + + OpcDoFprintf (Op); + break; + + case PARSEOP_TOPLD: + + OpcDoPld (Op); + break; + case PARSEOP_TOUUID: OpcDoUuId (Op); diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index 07bf88f..b2972d4 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/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 */ @@ -922,6 +921,7 @@ OpnDoDefinitionBlock ( strcat (Filename, (char *) Child->Asl.Value.Buffer); Gbl_OutputFilenamePrefix = Filename; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); } Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; @@ -968,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/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 3471006..1079f9c 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/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)) @@ -576,7 +575,8 @@ OptOptimizeNamePath ( return_VOID; } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%5d [%12.12s] [%12.12s] ", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + "PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ", Op->Asl.LogicalLineNumber, AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); @@ -620,7 +620,7 @@ OptOptimizeNamePath ( { /* This is the declaration of a new name */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n")); /* * The node of interest is the parent of this node (the containing @@ -646,7 +646,7 @@ OptOptimizeNamePath ( { /* This is a reference to an existing named object */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REF ")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n")); } /* @@ -688,9 +688,10 @@ OptOptimizeNamePath ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, - "%37s (%2u) ==> %-32s(%2u) %-32s", - (char *) CurrentPath.Pointer, (UINT32) CurrentPath.Length, - (char *) TargetPath.Pointer, (UINT32) TargetPath.Length, ExternalNameString)); + "CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n", + (UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer, + (UINT32) TargetPath.Length, (char *) TargetPath.Pointer, + ExternalNameString)); ACPI_FREE (ExternalNameString); @@ -747,7 +748,8 @@ OptOptimizeNamePath ( HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath)); OptTotal += HowMuchShorter; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2u (%u)", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " REDUCED BY %2u (TOTAL SAVED %2u)", (UINT32) HowMuchShorter, OptTotal)); if (Flags & AML_NAMED) diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c index 66a9249..5868d98 100644 --- a/sys/contrib/dev/acpica/compiler/asloptions.c +++ b/sys/contrib/dev/acpica/compiler/asloptions.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -118,8 +118,7 @@ AslCommandLine ( /* Next parameter must be the input filename */ if (!argv[AcpiGbl_Optind] && - !Gbl_DisasmFlag && - !Gbl_GetAllTables) + !Gbl_DisasmFlag) { printf ("Missing input filename\n"); BadCommandLine = TRUE; @@ -169,7 +168,7 @@ AslDoOptions ( /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case '@': /* Begin a response file */ @@ -185,7 +184,7 @@ AslDoOptions ( } break; - case 'b': /* Debug output options */ + case 'b': /* Debug options */ switch (AcpiGbl_Optarg[0]) { @@ -194,10 +193,37 @@ AslDoOptions ( AslCompilerdebug = 1; /* same as yydebug */ DtParserdebug = 1; PrParserdebug = 1; + Gbl_DebugFlag = TRUE; + break; + + case 'p': /* Prune ASL parse tree */ + + /* Get the required argument */ + + if (AcpiGetoptArgument (argc, argv)) + { + return (-1); + } + + Gbl_PruneParseTree = TRUE; + Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); + break; + + case 's': + + Gbl_DebugFlag = TRUE; break; case 't': + /* Get the required argument */ + + if (AcpiGetoptArgument (argc, argv)) + { + return (-1); + } + + Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); break; default: @@ -206,9 +232,6 @@ AslDoOptions ( return (-1); } - /* Produce debug output file */ - - Gbl_DebugFlag = TRUE; break; case 'c': @@ -251,6 +274,12 @@ AslDoOptions ( break; + case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ + + Gbl_DoCompile = FALSE; + AcpiGbl_CstyleDisassembly = FALSE; + break; + default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); @@ -267,11 +296,22 @@ AslDoOptions ( case 'e': /* External files for disassembler */ - Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); - if (ACPI_FAILURE (Status)) + /* Get entire list of external files */ + + AcpiGbl_Optind--; + argv[AcpiGbl_Optind] = AcpiGbl_Optarg; + + while (argv[AcpiGbl_Optind] && + (argv[AcpiGbl_Optind][0] != '-')) { - printf ("Could not add %s to external list\n", AcpiGbl_Optarg); - return (-1); + Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); + if (ACPI_FAILURE (Status)) + { + printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]); + return (-1); + } + + AcpiGbl_Optind++; } break; @@ -308,9 +348,8 @@ AslDoOptions ( case 'g': /* Get all ACPI tables */ - Gbl_GetAllTables = TRUE; - Gbl_DoCompile = FALSE; - break; + printf ("-g option is deprecated, use acpidump utility instead\n"); + exit (1); case 'h': @@ -404,6 +443,13 @@ AslDoOptions ( Gbl_PreprocessorOutputFlag = TRUE; break; + case 'm': + + /* Produce hardware map summary file */ + + Gbl_MapfileFlag = TRUE; + break; + case 'n': /* Produce namespace file */ @@ -513,6 +559,7 @@ AslDoOptions ( case 'p': /* Override default AML output filename */ Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); Gbl_UseDefaultAmlFilename = FALSE; break; @@ -596,11 +643,19 @@ AslDoOptions ( case 'a': - /* Disable All error/warning messages */ + /* Disable all error/warning/remark messages */ Gbl_NoErrors = TRUE; break; + case 'e': + + /* Disable all warning/remark messages (errors only) */ + + Gbl_DisplayRemarks = FALSE; + Gbl_DisplayWarnings = FALSE; + break; + case 'i': /* * Support for integrated development environment(s). diff --git a/sys/contrib/dev/acpica/compiler/aslparser.y b/sys/contrib/dev/acpica/compiler/aslparser.y new file mode 100644 index 0000000..223a49d --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslparser.y @@ -0,0 +1,131 @@ +%{ +/****************************************************************************** + * + * Module Name: aslparser.y - Master Bison/Yacc input file for iASL + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/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 AslLocalAllocate +#define YYFREE ACPI_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 89 + +/*! [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/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index 7f411fb..9a6778d 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -251,10 +251,16 @@ ApCheckPredefinedReturnValue ( const ACPI_PREDEFINED_INFO *ThisName; - /* Check parent method for a match against the predefined name list */ - + /* + * Check parent method for a match against the predefined name list. + * + * Note: Disable compiler errors/warnings because any errors will be + * caught when analyzing the parent method. Eliminates duplicate errors. + */ + Gbl_AllExceptionsDisabled = TRUE; Index = ApCheckForPredefinedName (MethodInfo->Op, MethodInfo->Op->Asl.NameSeg); + Gbl_AllExceptionsDisabled = FALSE; switch (Index) { diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c index 9cc67f4..37a58df 100644 --- a/sys/contrib/dev/acpica/compiler/aslprepkg.c +++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -169,7 +169,7 @@ ApCheckPackage ( { case ACPI_PTYPE1_FIXED: /* - * The package count is fixed and there are no sub-packages + * The package count is fixed and there are no subpackages * * If package is too small, exit. * If package is larger than expected, issue warning but continue @@ -194,7 +194,7 @@ ApCheckPackage ( case ACPI_PTYPE1_VAR: /* - * The package count is variable, there are no sub-packages, + * The package count is variable, there are no subpackages, * and all elements must be of the same type */ for (i = 0; i < Count; i++) @@ -207,7 +207,7 @@ ApCheckPackage ( case ACPI_PTYPE1_OPTION: /* - * The package count is variable, there are no sub-packages. + * The package count is variable, there are no subpackages. * There are a fixed number of required elements, and a variable * number of optional elements. * @@ -251,7 +251,7 @@ ApCheckPackage ( Op = Op->Asl.Next; Count--; - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, Package, 1, Count); @@ -259,7 +259,7 @@ ApCheckPackage ( case ACPI_PTYPE2_PKG_COUNT: - /* First element is the (Integer) count of sub-packages to follow */ + /* First element is the (Integer) count of subpackages to follow */ Status = ApCheckObjectType (Predefined->Info.Name, Op, ACPI_RTYPE_INTEGER, 0); @@ -283,12 +283,47 @@ ApCheckPackage ( Op = Op->Asl.Next; - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, 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: @@ -296,10 +331,10 @@ ApCheckPackage ( case ACPI_PTYPE2_FIX_VAR: /* * These types all return a single Package that consists of a - * variable number of sub-Packages. + * variable number of subpackages. */ - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, Package, 0, Count); @@ -467,6 +502,12 @@ ApCheckPackageList ( Count, ExpectedCount); break; } + if (Count > ExpectedCount) + { + ApPackageTooLarge (PredefinedName, SubPackageOp, + Count, ExpectedCount); + break; + } ApCheckPackageElements (PredefinedName, Op, Package->RetInfo.ObjectType1, Package->RetInfo.Count1, @@ -494,7 +535,7 @@ ApCheckPackageList ( case ACPI_PTYPE2_FIXED: - /* Each sub-package has a fixed length */ + /* Each subpackage has a fixed length */ ExpectedCount = Package->RetInfo2.Count; if (Count < ExpectedCount) @@ -503,6 +544,12 @@ ApCheckPackageList ( Count, ExpectedCount); break; } + if (Count > ExpectedCount) + { + ApPackageTooLarge (PredefinedName, SubPackageOp, + Count, ExpectedCount); + break; + } /* Check each object/type combination */ @@ -517,7 +564,7 @@ ApCheckPackageList ( case ACPI_PTYPE2_MIN: - /* Each sub-package has a variable but minimum length */ + /* Each subpackage has a variable but minimum length */ ExpectedCount = Package->RetInfo.Count1; if (Count < ExpectedCount) @@ -527,7 +574,7 @@ ApCheckPackageList ( break; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ ApCheckPackageElements (PredefinedName, Op, Package->RetInfo.ObjectType1, Count, 0, 0); @@ -576,7 +623,7 @@ ApCheckPackageList ( Count = ExpectedCount; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ Op = Op->Asl.Next; ApCheckPackageElements (PredefinedName, Op, diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c new file mode 100644 index 0000000..c8647ea --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslprintf.c @@ -0,0 +1,380 @@ +/****************************************************************************** + * + * Module Name: aslprintf - ASL Printf/Fprintf macro support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/amlcode.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslprintf") + + +/* Local prototypes */ + +static void +OpcCreateConcatenateNode ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Node); + +static void +OpcParsePrintf ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *DestOp); + + +/******************************************************************************* + * + * FUNCTION: OpcDoPrintf + * + * PARAMETERS: Op - printf parse node + * + * RETURN: None + * + * DESCRIPTION: Convert printf macro to a Store(..., Debug) AML operation. + * + ******************************************************************************/ + +void +OpcDoPrintf ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *DestOp; + + + /* Store destination is the Debug op */ + + DestOp = TrAllocateNode (PARSEOP_DEBUG); + DestOp->Asl.AmlOpcode = AML_DEBUG_OP; + DestOp->Asl.Parent = Op; + DestOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber; + + OpcParsePrintf (Op, DestOp); +} + + +/******************************************************************************* + * + * FUNCTION: OpcDoFprintf + * + * PARAMETERS: Op - fprintf parse node + * + * RETURN: None + * + * DESCRIPTION: Convert fprintf macro to a Store AML operation. + * + ******************************************************************************/ + +void +OpcDoFprintf ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *DestOp; + + + /* Store destination is the first argument of fprintf */ + + DestOp = Op->Asl.Child; + Op->Asl.Child = DestOp->Asl.Next; + DestOp->Asl.Next = NULL; + + OpcParsePrintf (Op, DestOp); +} + + +/******************************************************************************* + * + * FUNCTION: OpcParsePrintf + * + * PARAMETERS: Op - Printf parse node + * DestOp - Destination of Store operation + * + * RETURN: None + * + * DESCRIPTION: Convert printf macro to a Store AML operation. The printf + * macro parse tree is layed out as follows: + * + * Op - printf parse op + * Op->Child - Format string + * Op->Next - Format string arguments + * + ******************************************************************************/ + +static void +OpcParsePrintf ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *DestOp) +{ + char *Format; + char *StartPosition = NULL; + ACPI_PARSE_OBJECT *ArgNode; + ACPI_PARSE_OBJECT *NextNode; + UINT32 StringLength = 0; + char *NewString; + BOOLEAN StringToProcess = FALSE; + ACPI_PARSE_OBJECT *NewOp; + + + /* Get format string */ + + Format = ACPI_CAST_PTR (char, Op->Asl.Child->Asl.Value.String); + ArgNode = Op->Asl.Child->Asl.Next; + + /* + * Detach argument list so that we can use a NULL check to distinguish + * the first concatenation operation we need to make + */ + Op->Asl.Child = NULL; + + for (; *Format; ++Format) + { + if (*Format != '%') + { + if (!StringToProcess) + { + /* Mark the beginning of a string */ + + StartPosition = Format; + StringToProcess = TRUE; + } + + ++StringLength; + continue; + } + + /* Save string, if any, to new string object and concat it */ + + if (StringToProcess) + { + NewString = UtStringCacheCalloc (StringLength + 1); + ACPI_STRNCPY (NewString, StartPosition, StringLength); + + NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); + NewOp->Asl.Value.String = NewString; + NewOp->Asl.AmlOpcode = AML_STRING_OP; + NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING; + NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber; + + OpcCreateConcatenateNode(Op, NewOp); + + StringLength = 0; + StringToProcess = FALSE; + } + + ++Format; + + /* + * We have a format parameter and will need an argument to go + * with it + */ + if (!ArgNode || + ArgNode->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + AslError(ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, NULL); + return; + } + + /* + * We do not support sub-specifiers of printf (flags, width, + * precision, length). For specifiers we only support %x/%X for + * hex or %s for strings. Also, %o for generic "acpi object". + */ + switch (*Format) + { + case 's': + + if (ArgNode->Asl.ParseOpcode != PARSEOP_STRING_LITERAL) + { + AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgNode, + "String required"); + return; + } + + NextNode = ArgNode->Asl.Next; + ArgNode->Asl.Next = NULL; + OpcCreateConcatenateNode(Op, ArgNode); + ArgNode = NextNode; + continue; + + case 'X': + case 'x': + case 'o': + + NextNode = ArgNode->Asl.Next; + ArgNode->Asl.Next = NULL; + + /* + * Append an empty string if the first argument is + * not a string. This will implicitly conver the 2nd + * concat source to a string per the ACPI specification. + */ + if (!Op->Asl.Child) + { + NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); + NewOp->Asl.Value.String = ""; + NewOp->Asl.AmlOpcode = AML_STRING_OP; + NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING; + NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber; + + OpcCreateConcatenateNode(Op, NewOp); + } + + OpcCreateConcatenateNode(Op, ArgNode); + ArgNode = NextNode; + break; + + default: + + AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Op, + "Unrecognized format specifier"); + continue; + } + } + + /* Process any remaining string */ + + if (StringToProcess) + { + NewString = UtStringCacheCalloc (StringLength + 1); + ACPI_STRNCPY (NewString, StartPosition, StringLength); + + NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); + NewOp->Asl.Value.String = NewString; + NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING; + NewOp->Asl.AmlOpcode = AML_STRING_OP; + NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber; + + OpcCreateConcatenateNode(Op, NewOp); + } + + /* + * If we get here and there's no child node then Format + * was an empty string. Just make a no op. + */ + if (!Op->Asl.Child) + { + Op->Asl.ParseOpcode = PARSEOP_NOOP; + AslError(ASL_WARNING, ASL_MSG_NULL_STRING, Op, + "Converted to NOOP"); + return; + } + + /* Check for erroneous extra arguments */ + + if (ArgNode && + ArgNode->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + AslError(ASL_WARNING, ASL_MSG_ARG_COUNT_HI, ArgNode, + "Extra arguments ignored"); + } + + /* Change Op to a Store */ + + Op->Asl.ParseOpcode = PARSEOP_STORE; + Op->Common.AmlOpcode = AML_STORE_OP; + Op->Asl.CompileFlags = 0; + + /* Disable further optimization */ + + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; + UtSetParseOpName (Op); + + /* Set Store destination */ + + Op->Asl.Child->Asl.Next = DestOp; +} + + +/******************************************************************************* + * + * FUNCTION: OpcCreateConcatenateNode + * + * PARAMETERS: Op - Parse node + * Node - Parse node to be concatenated + * + * RETURN: None + * + * DESCRIPTION: Make Node the child of Op. If child node already exists, then + * concat child with Node and makes concat node the child of Op. + * + ******************************************************************************/ + +static void +OpcCreateConcatenateNode ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Node) +{ + ACPI_PARSE_OBJECT *NewConcatOp; + + + if (!Op->Asl.Child) + { + Op->Asl.Child = Node; + Node->Asl.Parent = Op; + return; + } + + NewConcatOp = TrAllocateNode (PARSEOP_CONCATENATE); + NewConcatOp->Asl.AmlOpcode = AML_CONCAT_OP; + NewConcatOp->Asl.AcpiBtype = 0x7; + NewConcatOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber; + + /* First arg is child of Op*/ + + NewConcatOp->Asl.Child = Op->Asl.Child; + Op->Asl.Child->Asl.Parent = NewConcatOp; + + /* Second arg is Node */ + + NewConcatOp->Asl.Child->Asl.Next = Node; + Node->Asl.Parent = NewConcatOp; + + /* Third arg is Zero (not used) */ + + NewConcatOp->Asl.Child->Asl.Next->Asl.Next = + TrAllocateNode (PARSEOP_ZERO); + NewConcatOp->Asl.Child->Asl.Next->Asl.Next->Asl.Parent = + NewConcatOp; + + Op->Asl.Child = NewConcatOp; + NewConcatOp->Asl.Parent = Op; +} diff --git a/sys/contrib/dev/acpica/compiler/aslprune.c b/sys/contrib/dev/acpica/compiler/aslprune.c new file mode 100644 index 0000000..1a36928 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslprune.c @@ -0,0 +1,239 @@ +/****************************************************************************** + * + * Module Name: aslprune - Parse tree prune utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/acapps.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslprune") + + +/* Local prototypes */ + +static ACPI_STATUS +PrTreePruneWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static void +PrPrintObjectAtLevel ( + UINT32 Level, + const char *ObjectName); + + +typedef struct acpi_prune_info +{ + UINT32 PruneLevel; + UINT16 ParseOpcode; + UINT16 Count; + +} ACPI_PRUNE_INFO; + + +/******************************************************************************* + * + * FUNCTION: AslPruneParseTree + * + * PARAMETERS: PruneDepth - Number of levels to prune + * Type - Prune type (Device, Method, etc.) + * + * RETURN: None + * + * DESCRIPTION: Prune off one or more levels of the ASL parse tree + * + ******************************************************************************/ + +void +AslPruneParseTree ( + UINT32 PruneDepth, + UINT32 Type) +{ + ACPI_PRUNE_INFO PruneObj; + + + PruneObj.PruneLevel = PruneDepth; + PruneObj.Count = 0; + + switch (Type) + { + case 0: + PruneObj.ParseOpcode = (UINT16) PARSEOP_DEVICE; + break; + + case 1: + PruneObj.ParseOpcode = (UINT16) PARSEOP_METHOD; + break; + + case 2: + PruneObj.ParseOpcode = (UINT16) PARSEOP_IF; + break; + + default: + AcpiOsPrintf ("Unsupported type: %u\n", Type); + return; + } + + AcpiOsPrintf ("Pruning parse tree, from depth %u\n", + PruneDepth); + + AcpiOsPrintf ("\nRemoving Objects:\n"); + + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + PrTreePruneWalk, NULL, ACPI_CAST_PTR (void, &PruneObj)); + + AcpiOsPrintf ("\n%u Total Objects Removed\n", PruneObj.Count); +} + + +/******************************************************************************* + * + * FUNCTION: PrPrintObjectAtLevel + * + * PARAMETERS: Level - Current nesting level + * ObjectName - ACPI name for the object + * + * RETURN: None + * + * DESCRIPTION: Print object name with indent + * + ******************************************************************************/ + +static void +PrPrintObjectAtLevel ( + UINT32 Level, + const char *ObjectName) +{ + UINT32 i; + + + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("[%s] at Level [%u]\n", ObjectName, Level); +} + + +/******************************************************************************* + * + * FUNCTION: PrTreePruneWalk + * + * PARAMETERS: Parse tree walk callback + * + * RETURN: Status + * + * DESCRIPTION: Prune off one or more levels of the ASL parse tree + * + * Current objects that can be pruned are: Devices, Methods, and If/Else + * blocks. + * + ******************************************************************************/ + +static ACPI_STATUS +PrTreePruneWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_PRUNE_INFO *PruneObj = (ACPI_PRUNE_INFO *) Context; + + + /* We only care about objects below the Prune Level threshold */ + + if (Level <= PruneObj->PruneLevel) + { + return (AE_OK); + } + + if ((Op->Asl.ParseOpcode != PruneObj->ParseOpcode) && + !(Op->Asl.ParseOpcode == PARSEOP_ELSE && + PruneObj->ParseOpcode == PARSEOP_IF)) + { + return (AE_OK); + } + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_METHOD: + + AcpiOsPrintf ("Method"); + PrPrintObjectAtLevel (Level, Op->Asl.Child->Asl.Value.Name); + Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next->Asl.Next->Asl.Next->Asl.Next = NULL; + PruneObj->Count++; + break; + + case PARSEOP_DEVICE: + + AcpiOsPrintf ("Device"); + PrPrintObjectAtLevel (Level, Op->Asl.Child->Asl.Value.Name); + Op->Asl.Child->Asl.Next = NULL; + PruneObj->Count++; + break; + + case PARSEOP_IF: + case PARSEOP_ELSE: + + if (Op->Asl.ParseOpcode == PARSEOP_ELSE) + { + PrPrintObjectAtLevel(Level, "Else"); + Op->Asl.Child = NULL; + } + else + { + PrPrintObjectAtLevel(Level, "If"); + Op->Asl.Child->Asl.Next = NULL; + } + + PruneObj->Count++; + break; + + default: + + break; + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 0a95a90..5f513d7 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/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 */ @@ -645,8 +645,7 @@ RsCheckListForDuplicates ( ASL_RESOURCE_NODE * RsDoOneResourceDescriptor ( - ACPI_PARSE_OBJECT *DescriptorTypeOp, - UINT32 CurrentByteOffset, + ASL_RESOURCE_INFO *Info, UINT8 *State) { ASL_RESOURCE_NODE *Rnode = NULL; @@ -654,36 +653,31 @@ RsDoOneResourceDescriptor ( /* Construct the resource */ - switch (DescriptorTypeOp->Asl.ParseOpcode) + switch (Info->DescriptorTypeOp->Asl.ParseOpcode) { case PARSEOP_DMA: - Rnode = RsDoDmaDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDmaDescriptor (Info); break; case PARSEOP_FIXEDDMA: - Rnode = RsDoFixedDmaDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoFixedDmaDescriptor (Info); break; case PARSEOP_DWORDIO: - Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordIoDescriptor (Info); break; case PARSEOP_DWORDMEMORY: - Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordMemoryDescriptor (Info); break; case PARSEOP_DWORDSPACE: - Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordSpaceDescriptor (Info); break; case PARSEOP_ENDDEPENDENTFN: @@ -693,13 +687,13 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_NORMAL: AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_DEPENDENT_LIST: @@ -709,104 +703,87 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_NORMAL; - Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoEndDependentDescriptor (Info); break; case PARSEOP_ENDTAG: - Rnode = RsDoEndTagDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoEndTagDescriptor (Info); break; case PARSEOP_EXTENDEDIO: - Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedIoDescriptor (Info); break; case PARSEOP_EXTENDEDMEMORY: - Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedMemoryDescriptor (Info); break; case PARSEOP_EXTENDEDSPACE: - Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedSpaceDescriptor (Info); break; case PARSEOP_FIXEDIO: - Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoFixedIoDescriptor (Info); break; case PARSEOP_INTERRUPT: - Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoInterruptDescriptor (Info); break; case PARSEOP_IO: - Rnode = RsDoIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIoDescriptor (Info); break; case PARSEOP_IRQ: - Rnode = RsDoIrqDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIrqDescriptor (Info); break; case PARSEOP_IRQNOFLAGS: - Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIrqNoFlagsDescriptor (Info); break; case PARSEOP_MEMORY24: - Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory24Descriptor (Info); break; case PARSEOP_MEMORY32: - Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory32Descriptor (Info); break; case PARSEOP_MEMORY32FIXED: - Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory32FixedDescriptor (Info); break; case PARSEOP_QWORDIO: - Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordIoDescriptor (Info); break; case PARSEOP_QWORDMEMORY: - Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordMemoryDescriptor (Info); break; case PARSEOP_QWORDSPACE: - Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordSpaceDescriptor (Info); break; case PARSEOP_REGISTER: - Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGeneralRegisterDescriptor (Info); break; case PARSEOP_STARTDEPENDENTFN: @@ -816,7 +793,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -827,8 +804,7 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoStartDependentDescriptor (Info); *State = ACPI_RSTATE_DEPENDENT_LIST; break; @@ -839,7 +815,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -850,69 +826,58 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoStartDependentNoPriDescriptor (Info); *State = ACPI_RSTATE_DEPENDENT_LIST; break; case PARSEOP_VENDORLONG: - Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoVendorLargeDescriptor (Info); break; case PARSEOP_VENDORSHORT: - Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoVendorSmallDescriptor (Info); break; case PARSEOP_WORDBUSNUMBER: - Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordBusNumberDescriptor (Info); break; case PARSEOP_WORDIO: - Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordIoDescriptor (Info); break; case PARSEOP_WORDSPACE: - Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordSpaceDescriptor (Info); break; case PARSEOP_GPIO_INT: - Rnode = RsDoGpioIntDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGpioIntDescriptor (Info); break; case PARSEOP_GPIO_IO: - Rnode = RsDoGpioIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGpioIoDescriptor (Info); break; case PARSEOP_I2C_SERIALBUS: - Rnode = RsDoI2cSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoI2cSerialBusDescriptor (Info); break; case PARSEOP_SPI_SERIALBUS: - Rnode = RsDoSpiSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoSpiSerialBusDescriptor (Info); break; case PARSEOP_UART_SERIALBUS: - Rnode = RsDoUartSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoUartSerialBusDescriptor (Info); break; case PARSEOP_DEFAULT_ARG: @@ -923,7 +888,7 @@ RsDoOneResourceDescriptor ( default: printf ("Unknown resource descriptor type [%s]\n", - DescriptorTypeOp->Asl.ParseOpName); + Info->DescriptorTypeOp->Asl.ParseOpName); break; } @@ -932,14 +897,14 @@ RsDoOneResourceDescriptor ( * This allows the resource to be installed in the namespace so that * references to the descriptor can be resolved. */ - DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC; - DescriptorTypeOp->Asl.Value.Integer = CurrentByteOffset; + Info->DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + Info->DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC; + Info->DescriptorTypeOp->Asl.Value.Integer = Info->CurrentByteOffset; if (Rnode) { - DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; - DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; + Info->DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; + Info->DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; } return (Rnode); @@ -1023,6 +988,7 @@ RsDoResourceTemplate ( ASL_RESOURCE_NODE HeadRnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *Rnode; + ASL_RESOURCE_INFO Info; UINT8 State; @@ -1055,9 +1021,22 @@ RsDoResourceTemplate ( PreviousRnode = &HeadRnode; while (DescriptorTypeOp) { + /* Save information for optional mapfile */ + + if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) + { + Info.MappingOp = Op->Asl.Parent; + } + else + { + Info.MappingOp = DescriptorTypeOp; + } + + Info.DescriptorTypeOp = DescriptorTypeOp; + Info.CurrentByteOffset = CurrentByteOffset; + DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC; - Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, - &State); + Rnode = RsDoOneResourceDescriptor (&Info, &State); /* * Update current byte offset to indicate the number of bytes from the diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 21a8705..4ac0635 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" @@ -65,9 +64,7 @@ * * FUNCTION: RsDoEndTagDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -77,8 +74,7 @@ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ASL_RESOURCE_NODE *Rnode; @@ -99,9 +95,7 @@ RsDoEndTagDescriptor ( * * FUNCTION: RsDoEndDependentDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -111,8 +105,7 @@ RsDoEndTagDescriptor ( ASL_RESOURCE_NODE * RsDoEndDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ASL_RESOURCE_NODE *Rnode; @@ -131,9 +124,7 @@ RsDoEndDependentDescriptor ( * * FUNCTION: RsDoMemory24Descriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -143,8 +134,7 @@ RsDoEndDependentDescriptor ( ASL_RESOURCE_NODE * RsDoMemory24Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -152,10 +142,12 @@ RsDoMemory24Descriptor ( ACPI_PARSE_OBJECT *MaxOp = NULL; ACPI_PARSE_OBJECT *LengthOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); Descriptor = Rnode->Buffer; @@ -208,7 +200,7 @@ RsDoMemory24Descriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -227,7 +219,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Maximum, Descriptor->Memory24.AddressLength, Descriptor->Memory24.Alignment, - MinOp, MaxOp, LengthOp, NULL, Op); + MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp); return (Rnode); } @@ -237,9 +229,7 @@ RsDoMemory24Descriptor ( * * FUNCTION: RsDoMemory32Descriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -249,8 +239,7 @@ RsDoMemory24Descriptor ( ASL_RESOURCE_NODE * RsDoMemory32Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -259,10 +248,12 @@ RsDoMemory32Descriptor ( ACPI_PARSE_OBJECT *LengthOp = NULL; ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); Descriptor = Rnode->Buffer; @@ -316,7 +307,7 @@ RsDoMemory32Descriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -335,7 +326,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Maximum, Descriptor->Memory32.AddressLength, Descriptor->Memory32.Alignment, - MinOp, MaxOp, LengthOp, AlignOp, Op); + MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp); return (Rnode); } @@ -345,9 +336,7 @@ RsDoMemory32Descriptor ( * * FUNCTION: RsDoMemory32FixedDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -357,16 +346,17 @@ RsDoMemory32Descriptor ( ASL_RESOURCE_NODE * RsDoMemory32FixedDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); Descriptor = Rnode->Buffer; @@ -402,7 +392,7 @@ RsDoMemory32FixedDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -422,9 +412,7 @@ RsDoMemory32FixedDescriptor ( * * FUNCTION: RsDoStartDependentDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -434,19 +422,21 @@ RsDoMemory32FixedDescriptor ( ASL_RESOURCE_NODE * RsDoStartDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *NextRnode; + ASL_RESOURCE_INFO NextInfo; + UINT32 CurrentByteOffset; UINT32 i; UINT8 State; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); PreviousRnode = Rnode; @@ -492,8 +482,10 @@ RsDoStartDependentDescriptor ( default: - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); + NextInfo.CurrentByteOffset = CurrentByteOffset; + NextInfo.DescriptorTypeOp = InitializerOp; + + NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -517,9 +509,7 @@ RsDoStartDependentDescriptor ( * * FUNCTION: RsDoStartDependentNoPriDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -529,18 +519,20 @@ RsDoStartDependentDescriptor ( ASL_RESOURCE_NODE * RsDoStartDependentNoPriDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *NextRnode; + ASL_RESOURCE_INFO NextInfo; + UINT32 CurrentByteOffset; UINT8 State; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); Descriptor = Rnode->Buffer; @@ -557,8 +549,10 @@ RsDoStartDependentNoPriDescriptor ( State = ACPI_RSTATE_START_DEPENDENT; while (InitializerOp) { - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); + NextInfo.CurrentByteOffset = CurrentByteOffset; + NextInfo.DescriptorTypeOp = InitializerOp; + + NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -579,9 +573,7 @@ RsDoStartDependentNoPriDescriptor ( * * FUNCTION: RsDoVendorSmallDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -591,8 +583,7 @@ RsDoStartDependentNoPriDescriptor ( ASL_RESOURCE_NODE * RsDoVendorSmallDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -601,7 +592,7 @@ RsDoVendorSmallDescriptor ( UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; /* Allocate worst case - 7 vendor bytes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c index 4e78c2c..36e2400 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" @@ -63,9 +62,7 @@ * * FUNCTION: RsDoDmaDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -75,18 +72,19 @@ ASL_RESOURCE_NODE * RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; UINT8 DmaChannelMask = 0; UINT8 DmaChannels = 0; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); Descriptor = Rnode->Buffer; @@ -122,7 +120,7 @@ RsDoDmaDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -184,9 +182,7 @@ RsDoDmaDescriptor ( * * FUNCTION: RsDoFixedDmaDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -196,16 +192,17 @@ RsDoDmaDescriptor ( ASL_RESOURCE_NODE * RsDoFixedDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_DMA)); Descriptor = Rnode->Buffer; @@ -241,7 +238,7 @@ RsDoFixedDmaDescriptor ( case 3: /* Descriptor Name (optional) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: /* Ignore any extra nodes */ @@ -260,9 +257,7 @@ RsDoFixedDmaDescriptor ( * * FUNCTION: RsDoFixedIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -272,17 +267,18 @@ RsDoFixedDmaDescriptor ( ASL_RESOURCE_NODE * RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ACPI_PARSE_OBJECT *AddressOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); Descriptor = Rnode->Buffer; @@ -314,7 +310,7 @@ RsDoFixedIoDescriptor ( case 2: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -341,9 +337,7 @@ RsDoFixedIoDescriptor ( * * FUNCTION: RsDoIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -353,8 +347,7 @@ RsDoFixedIoDescriptor ( ASL_RESOURCE_NODE * RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -363,10 +356,12 @@ RsDoIoDescriptor ( ACPI_PARSE_OBJECT *LengthOp = NULL; ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); Descriptor = Rnode->Buffer; @@ -424,7 +419,7 @@ RsDoIoDescriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -443,7 +438,7 @@ RsDoIoDescriptor ( Descriptor->Io.Maximum, Descriptor->Io.AddressLength, Descriptor->Io.Alignment, - MinOp, MaxOp, LengthOp, AlignOp, Op); + MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp); return (Rnode); } @@ -453,9 +448,7 @@ RsDoIoDescriptor ( * * FUNCTION: RsDoIrqDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -465,18 +458,19 @@ RsDoIoDescriptor ( ASL_RESOURCE_NODE * RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 Interrupts = 0; UINT16 IrqMask = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); /* Length = 3 (with flag byte) */ @@ -514,7 +508,7 @@ RsDoIrqDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -576,9 +570,7 @@ RsDoIrqDescriptor ( * * FUNCTION: RsDoIrqNoFlagsDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -588,18 +580,19 @@ RsDoIrqDescriptor ( ASL_RESOURCE_NODE * RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT16 IrqMask = 0; UINT32 Interrupts = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); Descriptor = Rnode->Buffer; @@ -614,7 +607,7 @@ RsDoIrqNoFlagsDescriptor ( { case 0: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index 942d45e..af93a9e 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> @@ -61,9 +60,7 @@ * * FUNCTION: RsDoGeneralRegisterDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -73,16 +70,17 @@ ASL_RESOURCE_NODE * RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); Descriptor = Rnode->Buffer; @@ -138,7 +136,7 @@ RsDoGeneralRegisterDescriptor ( case 5: /* ResourceTag (ACPI 3.0b) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -157,9 +155,7 @@ RsDoGeneralRegisterDescriptor ( * * FUNCTION: RsDoInterruptDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -169,8 +165,7 @@ RsDoGeneralRegisterDescriptor ( ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; AML_RESOURCE *Rover = NULL; @@ -178,13 +173,15 @@ RsDoInterruptDescriptor ( ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN HasResSourceIndex = FALSE; UINT8 ResSourceIndex = 0; UINT8 *ResSourceString = NULL; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; StringLength = RsGetStringDataLength (InitializerOp); /* Count the interrupt numbers */ @@ -211,9 +208,9 @@ RsDoInterruptDescriptor ( OptionIndex += 4; } - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) + - 1 + OptionIndex + StringLength); + 1 + OptionIndex + StringLength); Descriptor = Rnode->Buffer; Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; @@ -303,7 +300,7 @@ RsDoInterruptDescriptor ( case 6: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -396,9 +393,7 @@ RsDoInterruptDescriptor ( * * FUNCTION: RsDoVendorLargeDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -408,8 +403,7 @@ RsDoInterruptDescriptor ( ASL_RESOURCE_NODE * RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -420,7 +414,7 @@ RsDoVendorLargeDescriptor ( /* Count the number of data bytes */ - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); for (i = 0; InitializerOp; i++) @@ -432,7 +426,7 @@ RsDoVendorLargeDescriptor ( InitializerOp = InitializerOp->Asl.Next; } - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c index 035b6ec..25cbed9 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoDwordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoDwordIoDescriptor ( UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT8 *OptionalFields; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -245,7 +243,7 @@ RsDoDwordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -279,10 +277,10 @@ RsDoDwordIoDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -291,9 +289,7 @@ RsDoDwordIoDescriptor ( * * FUNCTION: RsDoDwordMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -303,8 +299,7 @@ RsDoDwordIoDescriptor ( ASL_RESOURCE_NODE * RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -316,12 +311,14 @@ RsDoDwordMemoryDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -480,7 +477,7 @@ RsDoDwordMemoryDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -515,10 +512,10 @@ RsDoDwordMemoryDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -527,9 +524,7 @@ RsDoDwordMemoryDescriptor ( * * FUNCTION: RsDoDwordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -539,8 +534,7 @@ RsDoDwordMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -552,12 +546,14 @@ RsDoDwordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -712,7 +708,7 @@ RsDoDwordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -733,9 +729,9 @@ RsDoDwordSpaceDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c index 5621762..ddb7ea3 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #define _COMPONENT ACPI_COMPILER @@ -59,9 +58,7 @@ * * FUNCTION: RsDoExtendedIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -71,8 +68,7 @@ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -82,11 +78,13 @@ RsDoExtendedIoDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -187,7 +185,7 @@ RsDoExtendedIoDescriptor ( case 11: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 12: /* Type */ @@ -221,9 +219,10 @@ RsDoExtendedIoDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } @@ -232,9 +231,7 @@ RsDoExtendedIoDescriptor ( * * FUNCTION: RsDoExtendedMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -244,8 +241,7 @@ RsDoExtendedIoDescriptor ( ASL_RESOURCE_NODE * RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -255,11 +251,13 @@ RsDoExtendedMemoryDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -367,7 +365,7 @@ RsDoExtendedMemoryDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -402,9 +400,10 @@ RsDoExtendedMemoryDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } @@ -413,9 +412,7 @@ RsDoExtendedMemoryDescriptor ( * * FUNCTION: RsDoExtendedSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -425,8 +422,7 @@ RsDoExtendedMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -436,11 +432,13 @@ RsDoExtendedSpaceDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -545,7 +543,7 @@ RsDoExtendedSpaceDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -565,8 +563,9 @@ RsDoExtendedSpaceDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c index 3a002a4..16398e5 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoQwordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoQwordIoDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -236,7 +234,7 @@ RsDoQwordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -270,10 +268,10 @@ RsDoQwordIoDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -282,9 +280,7 @@ RsDoQwordIoDescriptor ( * * FUNCTION: RsDoQwordMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -294,8 +290,7 @@ RsDoQwordIoDescriptor ( ASL_RESOURCE_NODE * RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -307,12 +302,14 @@ RsDoQwordMemoryDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -465,7 +462,7 @@ RsDoQwordMemoryDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -500,10 +497,10 @@ RsDoQwordMemoryDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -512,9 +509,7 @@ RsDoQwordMemoryDescriptor ( * * FUNCTION: RsDoQwordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -524,8 +519,7 @@ RsDoQwordMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -537,12 +531,14 @@ RsDoQwordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -692,7 +688,7 @@ RsDoQwordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -712,9 +708,9 @@ RsDoQwordSpaceDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/compiler/aslrestype2s.c index 96be2ad..73680c2 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2s.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/amlcode.h> @@ -268,9 +267,7 @@ RsGetVendorData ( * * FUNCTION: RsDoGpioIntDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -280,8 +277,7 @@ RsGetVendorData ( ASL_RESOURCE_NODE * RsDoGpioIntDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -289,14 +285,18 @@ RsDoGpioIntDescriptor ( char *ResourceSource = NULL; UINT8 *VendorData = NULL; UINT16 *InterruptList = NULL; + UINT16 *PinList = NULL; UINT16 ResSourceLength; UINT16 VendorLength; UINT16 InterruptLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; + UINT32 PinCount = 0; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -324,6 +324,7 @@ RsDoGpioIntDescriptor ( /* Build pointers to optional areas */ InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + PinList = InterruptList; ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); @@ -407,7 +408,7 @@ RsDoGpioIntDescriptor ( case 8: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -438,6 +439,7 @@ RsDoGpioIntDescriptor ( */ *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; InterruptList++; + PinCount++; /* Case 10: First interrupt number in list */ @@ -466,6 +468,7 @@ RsDoGpioIntDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); return (Rnode); } @@ -474,9 +477,7 @@ RsDoGpioIntDescriptor ( * * FUNCTION: RsDoGpioIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -486,8 +487,7 @@ RsDoGpioIntDescriptor ( ASL_RESOURCE_NODE * RsDoGpioIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -495,14 +495,18 @@ RsDoGpioIoDescriptor ( char *ResourceSource = NULL; UINT8 *VendorData = NULL; UINT16 *InterruptList = NULL; + UINT16 *PinList = NULL; UINT16 ResSourceLength; UINT16 VendorLength; UINT16 InterruptLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; + UINT32 PinCount = 0; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -513,6 +517,7 @@ RsDoGpioIoDescriptor ( ResSourceLength = RsGetStringDataLength (InitializerOp); VendorLength = RsGetBufferDataLength (InitializerOp); InterruptLength = RsGetInterruptDataLength (InitializerOp); + PinList = InterruptList; DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + ResSourceLength + VendorLength + InterruptLength; @@ -530,6 +535,7 @@ RsDoGpioIoDescriptor ( /* Build pointers to optional areas */ InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + PinList = InterruptList; ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); @@ -613,7 +619,7 @@ RsDoGpioIoDescriptor ( case 8: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -643,6 +649,7 @@ RsDoGpioIoDescriptor ( */ *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; InterruptList++; + PinCount++; /* Case 10: First interrupt number in list */ @@ -671,6 +678,7 @@ RsDoGpioIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); return (Rnode); } @@ -679,9 +687,7 @@ RsDoGpioIoDescriptor ( * * FUNCTION: RsDoI2cSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -691,8 +697,7 @@ RsDoGpioIoDescriptor ( ASL_RESOURCE_NODE * RsDoI2cSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -702,10 +707,12 @@ RsDoI2cSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -801,7 +808,7 @@ RsDoI2cSerialBusDescriptor ( case 7: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -818,6 +825,7 @@ RsDoI2cSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } @@ -826,9 +834,7 @@ RsDoI2cSerialBusDescriptor ( * * FUNCTION: RsDoSpiSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -838,8 +844,7 @@ RsDoI2cSerialBusDescriptor ( ASL_RESOURCE_NODE * RsDoSpiSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -849,10 +854,12 @@ RsDoSpiSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -976,7 +983,7 @@ RsDoSpiSerialBusDescriptor ( case 11: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -993,6 +1000,7 @@ RsDoSpiSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } @@ -1001,9 +1009,7 @@ RsDoSpiSerialBusDescriptor ( * * FUNCTION: RsDoUartSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -1013,8 +1019,7 @@ RsDoSpiSerialBusDescriptor ( ASL_RESOURCE_NODE * RsDoUartSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -1024,10 +1029,12 @@ RsDoUartSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -1168,7 +1175,7 @@ RsDoUartSerialBusDescriptor ( case 12: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -1185,5 +1192,6 @@ RsDoUartSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c index be388b7..a9f4771 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoWordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoWordIoDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -236,7 +234,7 @@ RsDoWordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -270,10 +268,10 @@ RsDoWordIoDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -282,9 +280,7 @@ RsDoWordIoDescriptor ( * * FUNCTION: RsDoWordBusNumberDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -294,8 +290,7 @@ RsDoWordIoDescriptor ( ASL_RESOURCE_NODE * RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -307,12 +302,14 @@ RsDoWordBusNumberDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -456,7 +453,7 @@ RsDoWordBusNumberDescriptor ( case 11: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -476,10 +473,10 @@ RsDoWordBusNumberDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -488,9 +485,7 @@ RsDoWordBusNumberDescriptor ( * * FUNCTION: RsDoWordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -500,8 +495,7 @@ RsDoWordBusNumberDescriptor ( ASL_RESOURCE_NODE * RsDoWordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -513,12 +507,14 @@ RsDoWordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -673,7 +669,7 @@ RsDoWordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -693,9 +689,9 @@ RsDoWordSpaceDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.y b/sys/contrib/dev/acpica/compiler/aslrules.y index 42ff850..67f0413 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica/compiler/aslrules.y @@ -1,12 +1,12 @@ -%{ +NoEcho(' /****************************************************************************** * - * Module Name: aslcompiler.y - Bison/Yacc input file (ASL grammar and actions) + * Module Name: aslrules.y - Bison/Yacc production rules * *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,755 +42,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include <contrib/dev/acpica/compiler/aslcompiler.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <contrib/dev/acpica/include/acpi.h> -#include <contrib/dev/acpica/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 */ @@ -842,6 +92,149 @@ DefinitionBlockTerm '{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} ; + /* + * ASL Extensions: C-style math/logical operators and expressions. + * The implementation transforms these operators into the standard + * AML opcodes and syntax. + * + * Supported operators and precedence rules (high-to-low) + * + * NOTE: The operator precedence and associativity rules are + * implemented by the tokens in asltokens.y + * + * (left-to-right): + * 1) ( ) expr++ expr-- + * + * (right-to-left): + * 2) ! ~ + * + * (left-to-right): + * 3) * / % + * 4) + - + * 5) >> << + * 6) < > <= >= + * 7) == != + * 8) & + * 9) ^ + * 10) | + * 11) && + * 12) || + * + * (right-to-left): + * 13) = += -= *= /= %= <<= >>= &= ^= |= + */ +Expression + + /* Unary operators */ + + : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);} + TermArg {$$ = TrLinkChildren ($<n>2,1,$3);} + | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} + TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateLeafNode (PARSEOP_ZERO));} + + | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);} + {$$ = TrLinkChildren ($<n>3,1,$1);} + | SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + {$$ = TrLinkChildren ($<n>3,1,$1);} + + /* Binary operators: math and logical */ + + | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateLeafNode (PARSEOP_ZERO), + TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + + | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + + | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + | TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + | TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + /* Parentheses */ + + | '(' TermArg ')' { $$ = $2;} + ; + +EqualsTerm + + /* All assignment-type operations */ + + : SuperName PARSEOP_EXP_EQUALS + TermArg {$$ = TrCreateAssignmentNode ($1, $3);} + + | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateLeafNode (PARSEOP_ZERO), + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + ; + + /* ACPI 3.0 -- allow semicolons between terms */ TermList @@ -854,6 +247,7 @@ TermList Term : Object {} + | Expression {} | Type1Opcode {} | Type2Opcode {} | Type2IntegerOpcode {} @@ -961,7 +355,8 @@ Removed from TermArg due to reduce/reduce conflicts */ TermArg - : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + : Expression {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} @@ -1055,6 +450,7 @@ Type2Opcode | RefOfTerm {} | SizeOfTerm {} | StoreTerm {} + | EqualsTerm {} | TimerTerm {} | WaitTerm {} | UserTerm {} @@ -1112,6 +508,8 @@ Type2BufferOpcode /* "Type5" Opcodes */ Type2BufferOrStringOpcode : ConcatTerm {} + | PrintfTerm {} + | FprintfTerm {} | MidTerm {} ; @@ -1137,6 +535,7 @@ Type4Opcode Type5Opcode : ResourceTemplateTerm {} | UnicodeTerm {} + | ToPLDTerm {} | ToUUIDTerm {} ; @@ -2120,6 +1519,86 @@ ToIntegerTerm error ')' {$$ = AslDoError(); yyclearin;} ; +PldKeyword + : PARSEOP_PLD_REVISION {$$ = TrCreateLeafNode (PARSEOP_PLD_REVISION);} + | PARSEOP_PLD_IGNORECOLOR {$$ = TrCreateLeafNode (PARSEOP_PLD_IGNORECOLOR);} + | PARSEOP_PLD_RED {$$ = TrCreateLeafNode (PARSEOP_PLD_RED);} + | PARSEOP_PLD_GREEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GREEN);} + | PARSEOP_PLD_BLUE {$$ = TrCreateLeafNode (PARSEOP_PLD_BLUE);} + | PARSEOP_PLD_WIDTH {$$ = TrCreateLeafNode (PARSEOP_PLD_WIDTH);} + | PARSEOP_PLD_HEIGHT {$$ = TrCreateLeafNode (PARSEOP_PLD_HEIGHT);} + | PARSEOP_PLD_USERVISIBLE {$$ = TrCreateLeafNode (PARSEOP_PLD_USERVISIBLE);} + | PARSEOP_PLD_DOCK {$$ = TrCreateLeafNode (PARSEOP_PLD_DOCK);} + | PARSEOP_PLD_LID {$$ = TrCreateLeafNode (PARSEOP_PLD_LID);} + | PARSEOP_PLD_PANEL {$$ = TrCreateLeafNode (PARSEOP_PLD_PANEL);} + | PARSEOP_PLD_VERTICALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALPOSITION);} + | PARSEOP_PLD_HORIZONTALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALPOSITION);} + | PARSEOP_PLD_SHAPE {$$ = TrCreateLeafNode (PARSEOP_PLD_SHAPE);} + | PARSEOP_PLD_GROUPORIENTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPORIENTATION);} + | PARSEOP_PLD_GROUPTOKEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPTOKEN);} + | PARSEOP_PLD_GROUPPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPPOSITION);} + | PARSEOP_PLD_BAY {$$ = TrCreateLeafNode (PARSEOP_PLD_BAY);} + | PARSEOP_PLD_EJECTABLE {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTABLE);} + | PARSEOP_PLD_EJECTREQUIRED {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTREQUIRED);} + | PARSEOP_PLD_CABINETNUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CABINETNUMBER);} + | PARSEOP_PLD_CARDCAGENUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CARDCAGENUMBER);} + | PARSEOP_PLD_REFERENCE {$$ = TrCreateLeafNode (PARSEOP_PLD_REFERENCE);} + | PARSEOP_PLD_ROTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_ROTATION);} + | PARSEOP_PLD_ORDER {$$ = TrCreateLeafNode (PARSEOP_PLD_ORDER);} + | PARSEOP_PLD_RESERVED {$$ = TrCreateLeafNode (PARSEOP_PLD_RESERVED);} + | PARSEOP_PLD_VERTICALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALOFFSET);} + | PARSEOP_PLD_HORIZONTALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALOFFSET);} + ; + +PldKeywordList + : {$$ = NULL;} + | PldKeyword + PARSEOP_EXP_EQUALS Integer {$$ = TrLinkChildren ($1,1,$3);} + | PldKeyword + PARSEOP_EXP_EQUALS String {$$ = TrLinkChildren ($1,1,$3);} + | PldKeywordList ',' /* Allows a trailing comma at list end */ + | PldKeywordList ',' + PldKeyword + PARSEOP_EXP_EQUALS Integer {$$ = TrLinkPeerNode ($1,TrLinkChildren ($3,1,$5));} + | PldKeywordList ',' + PldKeyword + PARSEOP_EXP_EQUALS String {$$ = TrLinkPeerNode ($1,TrLinkChildren ($3,1,$5));} + ; + +ToPLDTerm + : PARSEOP_TOPLD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOPLD);} + PldKeywordList + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_TOPLD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PrintfArgList + : {$$ = NULL;} + | TermArg {$$ = $1;} + | PrintfArgList ',' + TermArg {$$ = TrLinkPeerNode ($1, $3);} + ; + +PrintfTerm + : PARSEOP_PRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PRINTF);} + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_PRINTF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FprintfTerm + : PARSEOP_FPRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FPRINTF);} + TermArg ',' + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FPRINTF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + ToStringTerm : PARSEOP_TOSTRING '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOSTRING);} TermArg @@ -3511,77 +2990,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/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c index e50b103..c8840b2 100644 --- a/sys/contrib/dev/acpica/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/compiler/aslstartup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/include/actables.h> #include <contrib/dev/acpica/include/acdisasm.h> @@ -51,18 +50,8 @@ ACPI_MODULE_NAME ("aslstartup") -#define ASL_MAX_FILES 256 -static char *FileList[ASL_MAX_FILES]; -static BOOLEAN AslToFile = TRUE; - - /* Local prototypes */ -static char ** -AsDoWildcard ( - char *DirectoryPathname, - char *FileSpecifier); - static UINT8 AslDetectSourceFileType ( ASL_FILE_INFO *Info); @@ -72,6 +61,11 @@ AslDoDisassembly ( void); +/* Globals */ + +static BOOLEAN AslToFile = TRUE; + + /******************************************************************************* * * FUNCTION: AslInitializeGlobals @@ -94,6 +88,7 @@ AslInitializeGlobals ( /* Init compiler globals */ + Gbl_SyntaxError = 0; Gbl_CurrentColumn = 0; Gbl_CurrentLineNumber = 1; Gbl_LogicalLineNumber = 1; @@ -131,82 +126,6 @@ AslInitializeGlobals ( } -/****************************************************************************** - * - * FUNCTION: AsDoWildcard - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Process files via wildcards. This function is for the Windows - * case only. - * - ******************************************************************************/ - -static char ** -AsDoWildcard ( - char *DirectoryPathname, - char *FileSpecifier) -{ -#ifdef WIN32 - void *DirInfo; - char *Filename; - int FileCount; - - - FileCount = 0; - - /* Open parent directory */ - - DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); - if (!DirInfo) - { - /* Either the directory of file does not exist */ - - Gbl_Files[ASL_FILE_INPUT].Filename = FileSpecifier; - FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN); - AslAbort (); - } - - /* Process each file that matches the wildcard specification */ - - while ((Filename = AcpiOsGetNextFilename (DirInfo))) - { - /* Add the filename to the file list */ - - FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); - strcpy (FileList[FileCount], Filename); - FileCount++; - - if (FileCount >= ASL_MAX_FILES) - { - printf ("Max files reached\n"); - FileList[0] = NULL; - return (FileList); - } - } - - /* Cleanup */ - - AcpiOsCloseDirectory (DirInfo); - FileList[FileCount] = NULL; - return (FileList); - -#else - /* - * Linux/Unix cases - Wildcards are expanded by the shell automatically. - * Just return the filename in a null terminated list - */ - FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); - strcpy (FileList[0], FileSpecifier); - FileList[1] = NULL; - - return (FileList); -#endif -} - - /******************************************************************************* * * FUNCTION: AslDetectSourceFileType @@ -332,7 +251,7 @@ AslDoDisassembly ( AcpiGbl_DbOpt_disasm = TRUE; Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix, - &Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_GetAllTables); + &Gbl_Files[ASL_FILE_INPUT].Filename); if (ACPI_FAILURE (Status)) { return (Status); @@ -365,8 +284,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); } @@ -395,12 +317,29 @@ AslDoOneFile ( AslInitializeGlobals (); PrInitializeGlobals (); - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + /* + * Extract the directory path. This path is used for possible include + * files and the optional AML filename embedded in the input file + * DefinitionBlock declaration. + */ + Status = FlSplitInputPathname (Filename, &Gbl_DirectoryPath, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* 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) */ - if (Gbl_DisasmFlag || Gbl_GetAllTables) + if (Gbl_DisasmFlag) { Status = AslDoDisassembly (); if (Status != AE_CTRL_CONTINUE) @@ -465,7 +404,6 @@ AslDoOneFile ( if (Gbl_Signature) { - ACPI_FREE (Gbl_Signature); Gbl_Signature = NULL; } @@ -543,77 +481,6 @@ AslDoOneFile ( /******************************************************************************* * - * FUNCTION: AslDoOnePathname - * - * PARAMETERS: Pathname - Full pathname, possibly with wildcards - * - * RETURN: Status - * - * DESCRIPTION: Process one pathname, possible terminated with a wildcard - * specification. If a wildcard, it is expanded and the multiple - * files are processed. - * - ******************************************************************************/ - -ACPI_STATUS -AslDoOnePathname ( - char *Pathname, - ASL_PATHNAME_CALLBACK PathCallback) -{ - ACPI_STATUS Status = AE_OK; - char **WildcardList; - char *Filename; - char *FullPathname; - - - /* Split incoming path into a directory/filename combo */ - - Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Expand possible wildcard into a file list (Windows/DOS only) */ - - WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename); - while (*WildcardList) - { - FullPathname = ACPI_ALLOCATE ( - strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1); - - /* Construct a full path to the file */ - - strcpy (FullPathname, Gbl_DirectoryPath); - strcat (FullPathname, *WildcardList); - - /* - * If -p not specified, we will use the input filename as the - * output filename prefix - */ - if (Gbl_UseDefaultAmlFilename) - { - Gbl_OutputFilenamePrefix = FullPathname; - } - - /* Save status from all compiles */ - - Status |= (*PathCallback) (FullPathname); - - ACPI_FREE (FullPathname); - ACPI_FREE (*WildcardList); - *WildcardList = NULL; - WildcardList++; - } - - ACPI_FREE (Gbl_DirectoryPath); - ACPI_FREE (Filename); - return (Status); -} - - -/******************************************************************************* - * * FUNCTION: AslCheckForErrorExit * * PARAMETERS: None. Examines global exception count array diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index 9ac9698..2259255 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,17 +53,10 @@ /* - * Stubs to simplify linkage to the ACPI CA core subsystem. + * Stubs to simplify linkage to the ACPICA core subsystem. * Things like Events, Global Lock, etc. are not used * by the compiler, so they are stubbed out here. */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) -{ - return (0); -} - void AcpiNsExecModuleCodeList ( void) @@ -232,21 +225,3 @@ AcpiTbFindTable ( { return (AE_SUPPORT); } - -/* OSL interfaces */ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (0xFFFF); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l index e7d2b1f..b3149cf 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/compiler/aslsupport.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* Configuration */ #define ASL_SPACES_PER_TAB 4 @@ -72,6 +71,23 @@ ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; /******************************************************************************* * + * FUNCTION: AslParserCleanup + * + * Used to delete the current buffer + * + ******************************************************************************/ + +void +AslParserCleanup ( + void) +{ + + yy_delete_buffer (YY_CURRENT_BUFFER); +} + + +/******************************************************************************* + * * FUNCTION: AslDoLineDirective * * PARAMETERS: None. Uses input() to access current source code line @@ -180,7 +196,8 @@ AslPopInputFileStack ( Fnode = Gbl_IncludeFileStack; - DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); + DbgPrint (ASL_PARSE_OUTPUT, + "\nPop InputFile Stack, Fnode %p\n\n", Fnode); if (!Fnode) { @@ -240,11 +257,11 @@ AslPushInputFileStack ( Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); - Fnode->File = yyin; - Fnode->Next = Gbl_IncludeFileStack; - Fnode->State = YY_CURRENT_BUFFER; - Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; - Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; + Fnode->File = yyin; + Fnode->Next = Gbl_IncludeFileStack; + Fnode->State = YY_CURRENT_BUFFER; + Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; + Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; /* Push it on the stack */ @@ -255,11 +272,16 @@ AslPushInputFileStack ( State = yy_create_buffer (InputFile, YY_BUF_SIZE); yy_switch_to_buffer (State); - DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); + DbgPrint (ASL_PARSE_OUTPUT, + "\nPush InputFile Stack, returning %p\n\n", InputFile); /* 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; } @@ -301,7 +323,7 @@ AslResetCurrentLineBuffer ( * * FUNCTION: AslInsertLineBuffer * - * PARAMETERS: SourceChar - One char from the input ASL source file + * PARAMETERS: SourceChar - One char from the input ASL source file * * RETURN: None * @@ -342,7 +364,8 @@ AslInsertLineBuffer ( *Gbl_LineBufPtr = (UINT8) SourceChar; Gbl_LineBufPtr++; - if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (Gbl_LineBufferSize - 1))) + if (Gbl_LineBufPtr > + (Gbl_CurrentLineBuffer + (Gbl_LineBufferSize - 1))) { #if 0 /* @@ -351,9 +374,9 @@ AslInsertLineBuffer ( */ sprintf (MsgBuffer, "Max %u", Gbl_LineBufferSize); AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); #endif AslResetCurrentLineBuffer (); @@ -372,12 +395,12 @@ AslInsertLineBuffer ( * * FUNCTION: count * - * PARAMETERS: yytext - Contains the matched keyword. - * Type - Keyword/Character type: - * 0 = anything except a keyword - * 1 = pseudo-keywords - * 2 = non-executable ASL keywords - * 3 = executable ASL keywords + * PARAMETERS: yytext - Contains the matched keyword. + * Type - Keyword/Character type: + * 0 = anything except a keyword + * 1 = pseudo-keywords + * 2 = non-executable ASL keywords + * 3 = executable ASL keywords * * RETURN: None * @@ -446,7 +469,7 @@ loop: /* Eat chars until end-of-comment */ - while ((c = input()) != '*' && c != EOF) + while (((c = input ()) != '*') && (c != EOF)) { AslInsertLineBuffer (c); c1 = c; @@ -464,16 +487,16 @@ loop: if ((c1 == '/') && (c == '*')) { AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_InputByteCount, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_InputByteCount, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); } /* Comment is closed only if the NEXT character is a slash */ AslInsertLineBuffer (c); - if ((c1 = input()) != '/' && c1 != EOF) + if (((c1 = input ()) != '/') && (c1 != EOF)) { unput(c1); goto loop; @@ -493,9 +516,9 @@ EarlyEOF: * Premature End-Of-File */ AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); return (FALSE); } @@ -522,7 +545,7 @@ AslDoCommentType2 ( AslInsertLineBuffer ('/'); AslInsertLineBuffer ('/'); - while ((c = input()) != '\n' && c != EOF) + while (((c = input ()) != '\n') && (c != EOF)) { AslInsertLineBuffer (c); } @@ -670,9 +693,9 @@ DoCharacter: /* Unknown escape sequence issue warning, but use the character */ AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); break; } break; @@ -697,9 +720,9 @@ DoCharacter: if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) { AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); } else { @@ -741,9 +764,9 @@ DoCharacter: if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) { AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); } else { @@ -785,9 +808,9 @@ DoCharacter: * Premature End-Of-File */ AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); return (FALSE); @@ -797,13 +820,13 @@ CompletedString: */ *StringBuffer = 0; - CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); + CleanString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); if (!CleanString) { AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); return (FALSE); } @@ -817,8 +840,8 @@ BufferOverflow: /* Literal was too long */ AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); return (FALSE); } diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.y b/sys/contrib/dev/acpica/compiler/aslsupport.y new file mode 100644 index 0000000..ba81b7d --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslsupport.y @@ -0,0 +1,120 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslsupport.y - Bison/Yacc C support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 = 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/sys/contrib/dev/acpica/compiler/asltokens.y b/sys/contrib/dev/acpica/compiler/asltokens.y new file mode 100644 index 0000000..511fa9b --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asltokens.y @@ -0,0 +1,468 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltokens.y - Bison/Yacc token types + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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 + +/* ToPld macro */ + +%token <i> PARSEOP_TOPLD +%token <i> PARSEOP_PLD_REVISION +%token <i> PARSEOP_PLD_IGNORECOLOR +%token <i> PARSEOP_PLD_RED +%token <i> PARSEOP_PLD_GREEN +%token <i> PARSEOP_PLD_BLUE +%token <i> PARSEOP_PLD_WIDTH +%token <i> PARSEOP_PLD_HEIGHT +%token <i> PARSEOP_PLD_USERVISIBLE +%token <i> PARSEOP_PLD_DOCK +%token <i> PARSEOP_PLD_LID +%token <i> PARSEOP_PLD_PANEL +%token <i> PARSEOP_PLD_VERTICALPOSITION +%token <i> PARSEOP_PLD_HORIZONTALPOSITION +%token <i> PARSEOP_PLD_SHAPE +%token <i> PARSEOP_PLD_GROUPORIENTATION +%token <i> PARSEOP_PLD_GROUPTOKEN +%token <i> PARSEOP_PLD_GROUPPOSITION +%token <i> PARSEOP_PLD_BAY +%token <i> PARSEOP_PLD_EJECTABLE +%token <i> PARSEOP_PLD_EJECTREQUIRED +%token <i> PARSEOP_PLD_CABINETNUMBER +%token <i> PARSEOP_PLD_CARDCAGENUMBER +%token <i> PARSEOP_PLD_REFERENCE +%token <i> PARSEOP_PLD_ROTATION +%token <i> PARSEOP_PLD_ORDER +%token <i> PARSEOP_PLD_RESERVED +%token <i> PARSEOP_PLD_VERTICALOFFSET +%token <i> PARSEOP_PLD_HORIZONTALOFFSET + +/* + * C-style expression parser. These must appear after all of the + * standard ASL operators and keywords. + * + * Note: The order of these tokens implements the precedence rules + * (low precedence to high). See aslrules.y for an exhaustive list. + */ +%right <i> PARSEOP_EXP_EQUALS + PARSEOP_EXP_ADD_EQ + PARSEOP_EXP_SUB_EQ + PARSEOP_EXP_MUL_EQ + PARSEOP_EXP_DIV_EQ + PARSEOP_EXP_MOD_EQ + PARSEOP_EXP_SHL_EQ + PARSEOP_EXP_SHR_EQ + PARSEOP_EXP_AND_EQ + PARSEOP_EXP_XOR_EQ + PARSEOP_EXP_OR_EQ + +%left <i> PARSEOP_EXP_LOGICAL_OR +%left <i> PARSEOP_EXP_LOGICAL_AND +%left <i> PARSEOP_EXP_OR +%left <i> PARSEOP_EXP_XOR +%left <i> PARSEOP_EXP_AND +%left <i> PARSEOP_EXP_EQUAL + PARSEOP_EXP_NOT_EQUAL +%left <i> PARSEOP_EXP_GREATER + PARSEOP_EXP_LESS + PARSEOP_EXP_GREATER_EQUAL + PARSEOP_EXP_LESS_EQUAL +%left <i> PARSEOP_EXP_SHIFT_RIGHT + PARSEOP_EXP_SHIFT_LEFT +%left <i> PARSEOP_EXP_ADD + PARSEOP_EXP_SUBTRACT +%left <i> PARSEOP_EXP_MULTIPLY + PARSEOP_EXP_DIVIDE + PARSEOP_EXP_MODULO + +%right <i> PARSEOP_EXP_NOT + PARSEOP_EXP_LOGICAL_NOT + +%left <i> PARSEOP_EXP_INCREMENT + PARSEOP_EXP_DECREMENT + +%token <i> PARSEOP_PRINTF +%token <i> PARSEOP_FPRINTF +/* Specific parentheses tokens are not used at this time */ + /* PARSEOP_EXP_PAREN_OPEN */ + /* PARSEOP_EXP_PAREN_CLOSE */ + +/* + * 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/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index 7e6ad39..c46801b 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/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. * @@ -450,10 +448,6 @@ TrDoSwitch ( { /* Add an ELSE to complete the previous CASE */ - if (!Conditional) - { - return; - } NewOp = TrCreateLeafNode (PARSEOP_ELSE); NewOp->Asl.Parent = Conditional->Asl.Parent; TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent); @@ -620,11 +614,6 @@ TrDoSwitch ( { /* Convert the DEFAULT node to an ELSE */ - if (!Conditional) - { - return; - } - TrAmlInitNode (DefaultOp, PARSEOP_ELSE); DefaultOp->Asl.Parent = Conditional->Asl.Parent; diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index b2bbbfd..071231e 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/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++); } @@ -435,6 +448,124 @@ TrSetEndLineNumber ( /******************************************************************************* * + * FUNCTION: TrCreateAssignmentNode + * + * PARAMETERS: Target - Assignment target + * Source - Assignment source + * + * RETURN: Pointer to the new node. Aborts on allocation failure + * + * DESCRIPTION: Implements the C-style '=' operator. It changes the parse + * tree if possible to utilize the last argument of the math + * operators which is a target operand -- thus saving invocation + * of and additional Store() operator. An optimization. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +TrCreateAssignmentNode ( + ACPI_PARSE_OBJECT *Target, + ACPI_PARSE_OBJECT *Source) +{ + ACPI_PARSE_OBJECT *TargetOp; + ACPI_PARSE_OBJECT *SourceOp1; + ACPI_PARSE_OBJECT *SourceOp2; + ACPI_PARSE_OBJECT *Operator; + + + DbgPrint (ASL_PARSE_OUTPUT, + "\nTrCreateAssignmentNode Line [%u to %u] Source %s Target %s\n", + Source->Asl.LineNumber, Source->Asl.EndLine, + UtGetOpName (Source->Asl.ParseOpcode), + UtGetOpName (Target->Asl.ParseOpcode)); + + TrSetNodeFlags (Target, NODE_IS_TARGET); + + switch (Source->Asl.ParseOpcode) + { + /* + * Only these operators can be optimized because they have + * a target operand + */ + case PARSEOP_ADD: + case PARSEOP_AND: + case PARSEOP_DIVIDE: + case PARSEOP_MOD: + case PARSEOP_MULTIPLY: + case PARSEOP_NOT: + case PARSEOP_OR: + case PARSEOP_SHIFTLEFT: + case PARSEOP_SHIFTRIGHT: + case PARSEOP_SUBTRACT: + case PARSEOP_XOR: + + break; + + /* Otherwise, just create a normal Store operator */ + + default: + + goto CannotOptimize; + } + + /* + * Transform the parse tree such that the target is moved to the + * last operand of the operator + */ + SourceOp1 = Source->Asl.Child; + SourceOp2 = SourceOp1->Asl.Next; + + /* NOT only has one operand, but has a target */ + + if (Source->Asl.ParseOpcode == PARSEOP_NOT) + { + SourceOp2 = SourceOp1; + } + + /* DIVIDE has an extra target operand (remainder) */ + + if (Source->Asl.ParseOpcode == PARSEOP_DIVIDE) + { + SourceOp2 = SourceOp2->Asl.Next; + } + + TargetOp = SourceOp2->Asl.Next; + + /* + * Can't perform this optimization if there already is a target + * for the operator (ZERO is a "no target" placeholder). + */ + if (TargetOp->Asl.ParseOpcode != PARSEOP_ZERO) + { + goto CannotOptimize; + } + + /* Link in the target as the final operand */ + + SourceOp2->Asl.Next = Target; + Target->Asl.Parent = Source; + + return (Source); + + +CannotOptimize: + + Operator = TrAllocateNode (PARSEOP_STORE); + TrLinkChildren (Operator, 2, Source, Target); + + /* Set the appropriate line numbers for the new node */ + + Operator->Asl.LineNumber = Target->Asl.LineNumber; + Operator->Asl.LogicalLineNumber = Target->Asl.LogicalLineNumber; + Operator->Asl.LogicalByteOffset = Target->Asl.LogicalByteOffset; + Operator->Asl.Column = Target->Asl.Column; + + return (Operator); +} + + +/******************************************************************************* + * * FUNCTION: TrCreateLeafNode * * PARAMETERS: ParseOpcode - New opcode to be assigned to the node @@ -517,7 +648,6 @@ TrCreateConstantLeafNode ( /* Get the simple filename from the full path */ FlSplitInputPathname (Op->Asl.Filename, &Path, &Filename); - ACPI_FREE (Path); Op->Asl.Value.String = Filename; break; @@ -551,6 +681,81 @@ TrCreateConstantLeafNode ( /******************************************************************************* * + * FUNCTION: TrCreateTargetOperand + * + * PARAMETERS: OriginalOp - Op to be copied + * + * RETURN: Pointer to the new node. Aborts on allocation failure + * + * DESCRIPTION: Copy an existing node (and subtree). Used in ASL+ (C-style) + * expressions where the target is the same as one of the + * operands. A new node and subtree must be created from the + * original so that the parse tree can be linked properly. + * + * NOTE: This code is specific to target operands that are the last + * operand in an ASL/AML operator. Meaning that the top-level + * parse Op in a possible subtree has a NULL Next pointer. + * This simplifies the recursion. + * + * Subtree example: + * DeRefOf (Local1) += 32 + * + * This gets converted to: + * Add (DeRefOf (Local1), 32, DeRefOf (Local1)) + * + * Each DeRefOf has a single child, Local1. Even more complex + * subtrees can be created via the Index and DeRefOf operators. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +TrCreateTargetOperand ( + ACPI_PARSE_OBJECT *OriginalOp, + ACPI_PARSE_OBJECT *ParentOp) +{ + ACPI_PARSE_OBJECT *Op; + + + if (!OriginalOp) + { + return (NULL); + } + + Op = TrGetNextNode (); + + /* Copy the pertinent values (omit link pointer fields) */ + + Op->Asl.Value = OriginalOp->Asl.Value; + Op->Asl.Filename = OriginalOp->Asl.Filename; + Op->Asl.LineNumber = OriginalOp->Asl.LineNumber; + Op->Asl.LogicalLineNumber = OriginalOp->Asl.LogicalLineNumber; + Op->Asl.LogicalByteOffset = OriginalOp->Asl.LogicalByteOffset; + Op->Asl.Column = OriginalOp->Asl.Column; + Op->Asl.Flags = OriginalOp->Asl.Flags; + Op->Asl.CompileFlags = OriginalOp->Asl.CompileFlags; + Op->Asl.AmlOpcode = OriginalOp->Asl.AmlOpcode; + Op->Asl.ParseOpcode = OriginalOp->Asl.ParseOpcode; + Op->Asl.Parent = ParentOp; + UtSetParseOpName (Op); + + /* Copy a possible subtree below this node */ + + if (OriginalOp->Asl.Child) + { + Op->Asl.Child = TrCreateTargetOperand (OriginalOp->Asl.Child, Op); + } + + if (OriginalOp->Asl.Next) /* Null for top-level node */ + { + Op->Asl.Next = TrCreateTargetOperand (OriginalOp->Asl.Next, ParentOp); + } + + return (Op); +} + + +/******************************************************************************* + * * FUNCTION: TrCreateValuedLeafNode * * PARAMETERS: ParseOpcode - New opcode to be assigned to the node diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 5ca17b3..4bd24da 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLTYPES_H #define __ASLTYPES_H @@ -166,15 +165,26 @@ typedef enum ASL_FILE_C_SOURCE_OUTPUT, ASL_FILE_ASM_INCLUDE_OUTPUT, ASL_FILE_C_INCLUDE_OUTPUT, - ASL_FILE_C_OFFSET_OUTPUT + ASL_FILE_C_OFFSET_OUTPUT, + ASL_FILE_MAP_OUTPUT } ASL_FILE_TYPES; -#define ASL_MAX_FILE_TYPE 14 +#define ASL_MAX_FILE_TYPE 15 #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; @@ -196,7 +206,7 @@ typedef struct asl_error_msg char *Filename; char *SourceLine; UINT32 FilenameLength; - UINT8 MessageId; + UINT16 MessageId; UINT8 Level; } ASL_ERROR_MSG; @@ -238,4 +248,35 @@ typedef struct asl_event_info } ASL_EVENT_INFO; +/* Hardware mapping file structures */ + +typedef struct acpi_gpio_info +{ + struct acpi_gpio_info *Next; + ACPI_PARSE_OBJECT *Op; + char *DeviceName; + ACPI_NAMESPACE_NODE *TargetNode; + UINT32 References; + UINT32 PinCount; + UINT32 PinIndex; + UINT16 PinNumber; + UINT8 Type; + UINT8 Direction; + UINT8 Polarity; + +} ACPI_GPIO_INFO; + +typedef struct acpi_serial_info +{ + struct acpi_serial_info *Next; + ACPI_PARSE_OBJECT *Op; + char *DeviceName; + ACPI_NAMESPACE_NODE *TargetNode; + AML_RESOURCE *Resource; + UINT32 Speed; + UINT16 Address; + +} ACPI_SERIAL_INFO; + + #endif /* __ASLTYPES_H */ diff --git a/sys/contrib/dev/acpica/compiler/asltypes.y b/sys/contrib/dev/acpica/compiler/asltypes.y new file mode 100644 index 0000000..3177d1d --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asltypes.y @@ -0,0 +1,393 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltypes.y - Bison/Yacc production types/names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, 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> PldKeyword +%type <n> PldKeywordList +%type <n> ToPLDTerm +%type <n> ToUUIDTerm +%type <n> UnicodeTerm +%type <n> PrintfArgList +%type <n> PrintfTerm +%type <n> FprintfTerm + +/* 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 + +/* + * C-style expression parser + */ +%type <n> Expression +%type <n> EqualsTerm diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index eea5d68..7258daa 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/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,58 @@ UtCheckIntegerRange ( ******************************************************************************/ char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length) { char *Buffer; + ASL_CACHE_INFO *Cache; + UINT32 CacheSize = ASL_STRING_CACHE_SIZE; + + + if (Length > CacheSize) + { + CacheSize = Length; + + if (Gbl_StringCacheList) + { + Cache = UtLocalCalloc (sizeof (Cache->Next) + CacheSize); + + /* Link new cache buffer just following head of list */ + + Cache->Next = Gbl_StringCacheList->Next; + Gbl_StringCacheList->Next = Cache; + /* Leave cache management pointers alone as they pertain to head */ + + Gbl_StringCount++; + Gbl_StringSize += Length; + + return (Cache->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) + CacheSize); + + /* 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 + CacheSize; } + Gbl_StringCount++; + Gbl_StringSize += Length; + Buffer = Gbl_StringCacheNext; Gbl_StringCacheNext += Length; - return (Buffer); } @@ -646,7 +650,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 +696,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 +752,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); @@ -918,7 +947,7 @@ UtDoConstant ( } -/* TBD: use version in ACPI CA main code base? */ +/* TBD: use version in ACPICA main code base? */ /******************************************************************************* * diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c index ed884dc..4e345e9 100644 --- a/sys/contrib/dev/acpica/compiler/asluuid.c +++ b/sys/contrib/dev/acpica/compiler/asluuid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,42 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/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/sys/contrib/dev/acpica/compiler/aslwalks.c b/sys/contrib/dev/acpica/compiler/aslwalks.c index 7dfa7af..c378f2d 100644 --- a/sys/contrib/dev/acpica/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/compiler/aslwalks.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/acparser.h> @@ -295,6 +294,13 @@ AnOperandTypecheckWalkEnd ( { RequiredBtypes = AnMapArgTypeToBtype (ArgType); + if (!ArgOp) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "Null ArgOp in argument loop"); + AslAbort (); + } + ThisNodeBtype = AnGetBtype (ArgOp); if (ThisNodeBtype == ACPI_UINT32_MAX) { @@ -605,6 +611,10 @@ AnOtherSemanticAnalysisWalkBegin ( ArgNode = Op->Asl.Parent; /* Field definition */ ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + if (!Node) + { + break; + } ArgNode = Node->Op; /* OpRegion definition */ ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ diff --git a/sys/contrib/dev/acpica/compiler/aslxref.c b/sys/contrib/dev/acpica/compiler/aslxref.c index 51addc3..cda7ccf 100644 --- a/sys/contrib/dev/acpica/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/compiler/aslxref.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #include <contrib/dev/acpica/include/acparser.h> @@ -86,6 +85,22 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +#ifdef __UNDER_DEVELOPMENT +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *Node); + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *MethodOp1, + ACPI_PARSE_OBJECT *MethodOp2); +#endif + /******************************************************************************* * @@ -130,6 +145,8 @@ XfCrossReferenceNamespace ( TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); + + ACPI_FREE (WalkState); return (AE_OK); } @@ -262,6 +279,182 @@ XfCheckFieldRange ( } } + +#ifdef __UNDER_DEVELOPMENT +/******************************************************************************* + * + * 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); + } + +} +#endif + + /******************************************************************************* * * FUNCTION: XfNamespaceLocateBegin @@ -316,7 +509,7 @@ XfNamespaceLocateBegin ( */ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* We are only interested in opcodes that have an associated name */ @@ -329,7 +522,7 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -340,7 +533,7 @@ XfNamespaceLocateBegin ( if ((Op->Asl.Parent) && (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -459,7 +652,8 @@ XfNamespaceLocateBegin ( Status = AE_OK; } - return (Status); + + return_ACPI_STATUS (Status); } /* Check for a reference vs. name declaration */ @@ -470,6 +664,13 @@ XfNamespaceLocateBegin ( /* This node has been referenced, mark it for reference check */ Node->Flags |= ANOBJ_IS_REFERENCED; + +#ifdef __UNDER_DEVELOPMENT + + /* Check for an illegal reference */ + + XfCheckIllegalReference (Op, Node); +#endif } /* Attempt to optimize the NamePath */ @@ -624,7 +825,6 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - /* * A reference to a method within one of these opcodes is not an * invocation of the method, it is simply a reference to the method. @@ -632,9 +832,11 @@ XfNamespaceLocateBegin ( if ((Op->Asl.Parent) && ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)|| (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* * There are two types of method invocation: @@ -650,7 +852,7 @@ XfNamespaceLocateBegin ( Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Save the method node in the caller's op */ @@ -658,7 +860,7 @@ XfNamespaceLocateBegin ( Op->Asl.Node = Node; if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -822,8 +1024,16 @@ XfNamespaceLocateBegin ( } } + /* 5) Check for a connection object */ +#if 0 + else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) + { + return_ACPI_STATUS (Status); + } +#endif + Op->Asl.Node = Node; - return (Status); + return_ACPI_STATUS (Status); } @@ -858,7 +1068,7 @@ XfNamespaceLocateEnd ( OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); if (!(OpInfo->Flags & AML_NAMED)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Not interested in name references, we did not open a scope for them */ @@ -867,7 +1077,7 @@ XfNamespaceLocateEnd ( (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Pop the scope stack if necessary */ @@ -882,5 +1092,5 @@ XfNamespaceLocateEnd ( (void) AcpiDsScopeStackPop (WalkState); } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c index 3407e1d..e94a222 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/compiler/dtcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTCOMPILE_C__ #define _DECLARE_DT_GLOBALS #include <contrib/dev/acpica/compiler/aslcompiler.h> @@ -141,8 +140,6 @@ DtDoCompile ( Status = DtCompileDataTable (&FieldList); UtEndEvent (Event); - DtFreeFieldList (); - if (ACPI_FAILURE (Status)) { /* TBD: temporary error message. Msgs should come from function above */ @@ -170,6 +167,8 @@ DtDoCompile ( CleanupAndExit: + AcpiUtDeleteCaches (); + DtDeleteCaches (); CmCleanupAndExit (); return (Status); } @@ -298,7 +297,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -437,6 +436,7 @@ DtCompileTable ( UINT8 FieldType; UINT8 *Buffer; UINT8 *FlagBuffer = NULL; + char *String; UINT32 CurrentFlagByteOffset = 0; ACPI_STATUS Status; @@ -446,18 +446,29 @@ DtCompileTable ( return (AE_BAD_PARAMETER); } + /* Ignore optional subtable if name does not match */ + + if ((Info->Flags & DT_OPTIONAL) && + ACPI_STRCMP ((*Field)->Name, Info->Name)) + { + *RetSubtable = NULL; + return (AE_OK); + } + Length = DtGetSubtableLength (*Field, Info); if (Length == ASL_EOF) { return (AE_ERROR); } - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); if (Length > 0) { - Subtable->Buffer = UtLocalCalloc (Length); + String = UtStringCacheCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); } + Subtable->Length = Length; Subtable->TotalLength = Length; Buffer = Subtable->Buffer; @@ -558,8 +569,6 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); - ACPI_FREE (InlineSubtable->Buffer); - ACPI_FREE (InlineSubtable); LocalField = *Field; break; diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h index 51fec6d..307df3f 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,10 @@ #include <contrib/dev/acpica/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 */ @@ -321,20 +337,20 @@ DtWalkTableTree ( void DtError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); void DtNameError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); void DtFatal ( - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); @@ -343,10 +359,6 @@ DtStrtoul64 ( char *String, UINT64 *ReturnInteger); -UINT32 -DtGetFileSize ( - FILE *Handle); - char* DtGetFieldValue ( DT_FIELD *Field); @@ -372,8 +384,16 @@ void DtSetTableLength( void); +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void); + +DT_FIELD * +UtFieldCacheCalloc ( + void); + void -DtFreeFieldList ( +DtDeleteCaches ( void); @@ -400,6 +420,10 @@ DtCompileCsrt ( void **PFieldList); ACPI_STATUS +DtCompileDbg2 ( + void **PFieldList); + +ACPI_STATUS DtCompileDmar ( void **PFieldList); @@ -420,6 +444,10 @@ DtCompileFpdt ( void **PFieldList); ACPI_STATUS +DtCompileGtdt ( + void **PFieldList); + +ACPI_STATUS DtCompileHest ( void **PFieldList); @@ -428,6 +456,10 @@ DtCompileIvrs ( void **PFieldList); ACPI_STATUS +DtCompileLpit ( + void **PFieldList); + +ACPI_STATUS DtCompileMadt ( void **PFieldList); @@ -452,6 +484,10 @@ DtCompilePmtt ( void **PFieldList); ACPI_STATUS +DtCompilePcct ( + void **PFieldList); + +ACPI_STATUS DtCompileRsdt ( void **PFieldList); @@ -503,6 +539,7 @@ extern const unsigned char TemplateBert[]; extern const unsigned char TemplateBgrt[]; extern const unsigned char TemplateCpep[]; extern const unsigned char TemplateCsrt[]; +extern const unsigned char TemplateDbg2[]; extern const unsigned char TemplateDbgp[]; extern const unsigned char TemplateDmar[]; extern const unsigned char TemplateEcdt[]; @@ -514,12 +551,14 @@ extern const unsigned char TemplateGtdt[]; extern const unsigned char TemplateHest[]; extern const unsigned char TemplateHpet[]; extern const unsigned char TemplateIvrs[]; +extern const unsigned char TemplateLpit[]; extern const unsigned char TemplateMadt[]; extern const unsigned char TemplateMcfg[]; extern const unsigned char TemplateMchi[]; extern const unsigned char TemplateMpst[]; extern const unsigned char TemplateMsct[]; extern const unsigned char TemplateMtmr[]; +extern const unsigned char TemplatePcct[]; extern const unsigned char TemplatePmtt[]; extern const unsigned char TemplateRsdt[]; extern const unsigned char TemplateS3pt[]; diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c index 9689ef6..90054c9 100644 --- a/sys/contrib/dev/acpica/compiler/dtexpress.c +++ b/sys/contrib/dev/acpica/compiler/dtexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTEXPRESS_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> #include "dtparser.y.h" diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c index 1f273d9..3b191ab 100644 --- a/sys/contrib/dev/acpica/compiler/dtfield.c +++ b/sys/contrib/dev/acpica/compiler/dtfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTFIELD_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> @@ -259,7 +257,7 @@ DtCompileUuid ( } else { - Status = AuConvertStringToUuid (InString, (char *) Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } return (Status); @@ -311,21 +309,37 @@ DtCompileInteger ( return; } - /* Ensure that reserved fields are set to zero */ - /* TBD: should we set to zero, or just make this an ERROR? */ - /* TBD: Probably better to use a flag */ + /* + * Ensure that reserved fields are set properly. Note: uses + * the DT_NON_ZERO flag to indicate that the reserved value + * must be exactly one. Otherwise, the value must be zero. + * This is sufficient for now. + */ + + /* TBD: Should use a flag rather than compare "Reserved" */ - if (!ACPI_STRCMP (Field->Name, "Reserved") && - (Value != 0)) + if (!ACPI_STRCMP (Field->Name, "Reserved")) { - DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, - "Setting to zero"); - Value = 0; + if (Flags & DT_NON_ZERO) + { + if (Value != 1) + { + DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, + "Must be one, setting to one"); + Value = 1; + } + } + else if (Value != 0) + { + DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, + "Must be zero, setting to zero"); + Value = 0; + } } /* Check if the value must be non-zero */ - if ((Value == 0) && (Flags & DT_NON_ZERO)) + else if ((Flags & DT_NON_ZERO) && (Value == 0)) { DtError (ASL_ERROR, ASL_MSG_ZERO_VALUE, Field, NULL); } @@ -340,7 +354,8 @@ DtCompileInteger ( if (Value > MaxValue) { - sprintf (MsgBuffer, "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Value)); + sprintf (MsgBuffer, "%8.8X%8.8X - max %u bytes", + ACPI_FORMAT_UINT64 (Value), ByteLength); DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c index 39fb9da..e840fc9 100644 --- a/sys/contrib/dev/acpica/compiler/dtio.c +++ b/sys/contrib/dev/acpica/compiler/dtio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,10 +41,9 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTIO_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> +#include <contrib/dev/acpica/include/acapps.h> #define _COMPONENT DT_COMPILER ACPI_MODULE_NAME ("dtio") @@ -132,7 +131,7 @@ DtTrim ( if (!ACPI_STRCMP (String, " ")) { - ReturnString = UtLocalCalloc (1); + ReturnString = UtStringCacheCalloc (1); return (ReturnString); } @@ -180,7 +179,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); @@ -369,7 +368,7 @@ DtParseLine ( if ((Value && *Value) || IsNullString) { - Field = UtLocalCalloc (sizeof (DT_FIELD)); + Field = UtFieldCacheCalloc (); Field->Name = Name; Field->Value = Value; Field->Line = Line; @@ -379,11 +378,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); } @@ -737,7 +732,11 @@ DtScanFile ( /* Get the file size */ - Gbl_InputByteCount = DtGetFileSize (Handle); + Gbl_InputByteCount = CmGetFileSize (Handle); + if (Gbl_InputByteCount == ACPI_UINT32_MAX) + { + AslAbort (); + } Gbl_CurrentLineNumber = 0; Gbl_CurrentLineOffset = 0; @@ -816,7 +815,12 @@ DtOutputBinary ( /* Walk the entire parse tree, emitting the binary data */ DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); - Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + + Gbl_TableLength = CmGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (Gbl_TableLength == ACPI_UINT32_MAX) + { + AslAbort (); + } } @@ -1025,6 +1029,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/sys/contrib/dev/acpica/compiler/dtparser.l b/sys/contrib/dev/acpica/compiler/dtparser.l index b0f6d6c..c6c29ae 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.l +++ b/sys/contrib/dev/acpica/compiler/dtparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y index 47e74bd..0271d78 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.y +++ b/sys/contrib/dev/acpica/compiler/dtparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c index 67fcb9d..1e6a76a 100644 --- a/sys/contrib/dev/acpica/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTSUBTABLE_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> @@ -73,13 +71,15 @@ DtCreateSubtable ( DT_SUBTABLE **RetSubtable) { DT_SUBTABLE *Subtable; + char *String; - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); /* Create a new buffer for the subtable data */ - Subtable->Buffer = UtLocalCalloc (Length); + String = UtStringCacheCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c index bb6c7cb..bc0cbd2 100644 --- a/sys/contrib/dev/acpica/compiler/dttable.c +++ b/sys/contrib/dev/acpica/compiler/dttable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTTABLE_C__ - /* Compile all complex data tables */ #include <contrib/dev/acpica/compiler/aslcompiler.h> @@ -454,7 +452,7 @@ DtCompileCsrt ( UINT32 GroupLength; - /* Sub-tables (Resource Groups) */ + /* Subtables (Resource Groups) */ while (*PFieldList) { @@ -520,6 +518,156 @@ DtCompileCsrt ( /****************************************************************************** * + * FUNCTION: DtCompileDbg2 + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DBG2. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDbg2 ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 SubtableCount; + ACPI_DBG2_HEADER *Dbg2Header; + ACPI_DBG2_DEVICE *DeviceInfo; + UINT16 CurrentOffset; + UINT32 i; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Main table fields */ + + Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer); + Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF ( + ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header); + + SubtableCount = Dbg2Header->InfoCount; + DtPushSubtable (Subtable); + + /* Process all Device Information subtables (Count = InfoCount) */ + + while (*PFieldList && SubtableCount) + { + /* Subtable: Debug Device Information */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Device, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DeviceInfo = ACPI_CAST_PTR (ACPI_DBG2_DEVICE, Subtable->Buffer); + CurrentOffset = (UINT16) sizeof (ACPI_DBG2_DEVICE); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + /* BaseAddressRegister GAS array (Required, size is RegisterCount) */ + + DeviceInfo->BaseAddressOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (ACPI_GENERIC_ADDRESS); + DtInsertSubtable (ParentTable, Subtable); + } + + /* AddressSize array (Required, size = RegisterCount) */ + + DeviceInfo->AddressSizeOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (UINT32); + DtInsertSubtable (ParentTable, Subtable); + } + + /* NamespaceString device identifier (Required, size = NamePathLength) */ + + DeviceInfo->NamepathOffset = CurrentOffset; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header */ + + DeviceInfo->NamepathLength = (UINT16) Subtable->Length; + CurrentOffset += (UINT16) DeviceInfo->NamepathLength; + DtInsertSubtable (ParentTable, Subtable); + + /* OemData - Variable-length data (Optional, size = OemDataLength) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2OemData, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header (zeros if no OEM data present) */ + + DeviceInfo->OemDataOffset = 0; + DeviceInfo->OemDataLength = 0; + + /* Optional subtable (OemData) */ + + if (Subtable && Subtable->Length) + { + DeviceInfo->OemDataOffset = CurrentOffset; + DeviceInfo->OemDataLength = (UINT16) Subtable->Length; + + DtInsertSubtable (ParentTable, Subtable); + } + + SubtableCount--; + DtPopSubtable (); /* Get next Device Information subtable */ + } + + DtPopSubtable (); + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompileDmar * * PARAMETERS: List - Current field list pointer @@ -586,16 +734,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"); @@ -612,10 +765,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) @@ -788,6 +951,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); +} + /****************************************************************************** * @@ -1154,6 +1436,87 @@ DtCompileIvrs ( /****************************************************************************** * + * FUNCTION: DtCompileLpit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile LPIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileLpit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_LPIT_HEADER *LpitHeader; + + + /* Note: Main table consists only of the standard ACPI table header */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + + /* LPIT Subtable header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer); + + switch (LpitHeader->Type) + { + case ACPI_LPIT_TYPE_NATIVE_CSTATE: + + InfoTable = AcpiDmTableInfoLpit0; + break; + + case ACPI_LPIT_TYPE_SIMPLE_IO: + + InfoTable = AcpiDmTableInfoLpit1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT"); + return (AE_ERROR); + } + + /* LPIT Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompileMadt * * PARAMETERS: List - Current field list pointer @@ -1270,6 +1633,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"); @@ -1505,6 +1878,90 @@ DtCompileMtmr ( /****************************************************************************** * + * FUNCTION: DtCompilePcct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile PCCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePcct ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *PcctHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (PcctHeader->Type) + { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompilePmtt * * PARAMETERS: List - Current field list pointer @@ -1961,6 +2418,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/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c index ca66d16..3fcf081 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/compiler/dttemplate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h index f620abd..0398d69 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/compiler/dttemplate.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -174,6 +174,33 @@ const unsigned char TemplateCsrt[] = 0x43,0x48,0x41,0x37 /* 00000148 "CHA7" */ }; +const unsigned char TemplateDbg2[] = +{ + 0x44,0x42,0x47,0x32,0xB2,0x00,0x00,0x00, /* 00000000 "DBG2...." */ + 0x01,0xBA,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x2C,0x00,0x00,0x00, /* 00000020 "... ,..." */ + 0x02,0x00,0x00,0x00,0xEE,0x3F,0x00,0x02, /* 00000028 ".....?.." */ + 0x09,0x00,0x36,0x00,0x00,0x00,0x00,0x00, /* 00000030 "..6....." */ + 0x00,0x80,0x00,0x00,0x00,0x00,0x16,0x00, /* 00000038 "........" */ + 0x2E,0x00,0x01,0x32,0x00,0x03,0x88,0x77, /* 00000040 "...2...w" */ + 0x66,0x55,0x44,0x33,0x22,0x11,0x01,0x64, /* 00000048 "fUD3"..d" */ + 0x00,0x04,0x11,0x00,0xFF,0xEE,0xDD,0xCC, /* 00000050 "........" */ + 0xBB,0xAA,0x10,0x32,0x54,0x76,0x98,0xBA, /* 00000058 "...2Tv.." */ + 0xDC,0xFE,0x4D,0x79,0x44,0x65,0x76,0x69, /* 00000060 "..MyDevi" */ + 0x63,0x65,0x00,0xEE,0x47,0x00,0x01,0x11, /* 00000068 "ce..G..." */ + 0x00,0x26,0x00,0x10,0x00,0x37,0x00,0x00, /* 00000070 ".&...7.." */ + 0x80,0x00,0x00,0x00,0x00,0x16,0x00,0x22, /* 00000078 "......."" */ + 0x00,0x01,0x64,0x00,0x04,0x11,0x00,0xFF, /* 00000080 "..d....." */ + 0xEE,0xDD,0xCC,0xBB,0xAA,0x98,0xBA,0xDC, /* 00000088 "........" */ + 0xFE,0x5C,0x5C,0x5F,0x53,0x42,0x5F,0x2E, /* 00000090 ".\\_SB_." */ + 0x50,0x43,0x49,0x30,0x2E,0x44,0x42,0x47, /* 00000098 "PCI0.DBG" */ + 0x50,0x00,0x41,0x42,0x43,0x44,0x45,0x46, /* 000000A0 "P.ABCDEF" */ + 0x47,0x48,0x49,0x50,0x51,0x52,0x53,0x54, /* 000000A8 "GHIPQRST" */ + 0x55,0x56 /* 000000B0 "UV" */ +}; + const unsigned char TemplateDbgp[] = { 0x44,0x42,0x47,0x50,0x34,0x00,0x00,0x00, /* 00000000 "DBGP4..." */ @@ -353,10 +380,10 @@ const unsigned char TemplateFacs[] = const unsigned char TemplateFadt[] = { 0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00, /* 00000000 "FACP...." */ - 0x05,0x18,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".dINTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x11,0x11,0x20,0x01,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -368,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 "........" */ @@ -379,7 +406,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00, /* 000000C0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ 0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00, /* 000000D0 ". ......" */ - 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x01, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x01, /* 000000D8 ".....@.." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000F0 "........" */ @@ -407,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[] = @@ -521,41 +566,75 @@ const unsigned char TemplateIvrs[] = 0x00,0x00,0x00,0x00 /* 000000B8 "...." */ }; -/* MADT with ACPI 5.0 subtables */ - -const unsigned char TemplateMadt[] = +const unsigned char TemplateLpit[] = { - 0x41,0x50,0x49,0x43,0xF6,0x00,0x00,0x00, /* 00000000 "APIC...." */ - 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x4C,0x50,0x49,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "LPIT...." */ + 0x01,0x20,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 "#.. ...." */ + 0x25,0x03,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "%.. ...." */ + 0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "8......." */ + 0x00,0x00,0x00,0x00,0x7F,0x01,0x02,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x20,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ". ......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000058 "........" */ + 0x58,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000060 "X......." */ + 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 00000068 "........" */ + 0x00,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,0x10,0x00,0x02, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00 /* 000000B0 "...." */ +}; + +/* MADT with ACPI 5.1 subtables */ + +const unsigned char TemplateMadt[] = +{ + 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[] = @@ -646,6 +725,32 @@ const unsigned char TemplateMtmr[] = 0x00,0x00,0x00,0x00 /* 00000048 "...." */ }; +const unsigned char TemplatePcct[] = +{ + 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ + 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" */ + 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 ".>......" */ + 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[] = { 0x50,0x4D,0x54,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "PMTT...." */ @@ -844,10 +949,10 @@ const unsigned char TemplateSpcr[] = const unsigned char TemplateSpmi[] = { 0x53,0x50,0x4D,0x49,0x41,0x00,0x00,0x00, /* 00000000 "SPMIA..." */ - 0x04,0xED,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x04,0x00,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x14,0x01,0x14,0x20,0x00,0x01,0x00,0x00, /* 00000020 "... ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -856,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 "........" */ @@ -871,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/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c index d7ef56e..3635f13 100644 --- a/sys/contrib/dev/acpica/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/compiler/dtutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define __DTUTILS_C__ - #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> #include <contrib/dev/acpica/include/actables.h> @@ -77,7 +75,7 @@ DtSum ( void DtError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -124,7 +122,7 @@ DtError ( void DtNameError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -177,7 +175,7 @@ DtNameError ( void DtFatal ( - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -286,36 +284,6 @@ DtStrtoul64 ( /****************************************************************************** * - * FUNCTION: DtGetFileSize - * - * PARAMETERS: Handle - Open file handler - * - * RETURN: Current file size - * - * DESCRIPTION: Get the current size of a file. Seek to the EOF and get the - * offset. Seek back to the original location. - * - *****************************************************************************/ - -UINT32 -DtGetFileSize ( - FILE *Handle) -{ - int CurrentOffset; - int LastOffset; - - - CurrentOffset = ftell (Handle); - fseek (Handle, 0, SEEK_END); - LastOffset = ftell (Handle); - fseek (Handle, CurrentOffset, SEEK_SET); - - return ((UINT32) LastOffset); -} - - -/****************************************************************************** - * * FUNCTION: DtGetFieldValue * * PARAMETERS: Field - Current field list pointer @@ -531,7 +499,9 @@ 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: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: @@ -541,6 +511,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -562,6 +533,7 @@ DtGetFieldLength ( case ACPI_DMT_NAME4: case ACPI_DMT_SLIC: case ACPI_DMT_SIG: + case ACPI_DMT_LPIT: ByteLength = 4; break; @@ -871,39 +843,151 @@ DtWalkTableTree ( } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: DtFreeFieldList + * 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 + * + * 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; - ACPI_FREE (Field); - Field = NextField; + /* Subtable cache */ + + 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/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h index ae32a8c..d0642877 100644 --- a/sys/contrib/dev/acpica/compiler/preprocess.h +++ b/sys/contrib/dev/acpica/compiler/preprocess.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -257,7 +257,7 @@ PrGetNextToken ( void PrError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 Column); void diff --git a/sys/contrib/dev/acpica/compiler/prexpress.c b/sys/contrib/dev/acpica/compiler/prexpress.c index c0aa565..0f0d938 100644 --- a/sys/contrib/dev/acpica/compiler/prexpress.c +++ b/sys/contrib/dev/acpica/compiler/prexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prmacros.c b/sys/contrib/dev/acpica/compiler/prmacros.c index d76de8b..866d089 100644 --- a/sys/contrib/dev/acpica/compiler/prmacros.c +++ b/sys/contrib/dev/acpica/compiler/prmacros.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -360,7 +360,7 @@ PrAddMacro ( if (ArgCount >= PR_MAX_MACRO_ARGS) { PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, TokenOffset); - return; + goto ErrorExit; } } @@ -400,7 +400,7 @@ PrAddMacro ( PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, THIS_TOKEN_OFFSET (Token)); - return; + goto ErrorExit; } break; } @@ -432,7 +432,7 @@ AddMacroToList: THIS_TOKEN_OFFSET (Name)); } - return; + goto ErrorExit; } DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID @@ -451,6 +451,13 @@ AddMacroToList: DefineInfo->Args = Args; DefineInfo->ArgCount = ArgCount; } + + return; + + +ErrorExit: + ACPI_FREE (Args); + return; } diff --git a/sys/contrib/dev/acpica/compiler/prparser.l b/sys/contrib/dev/acpica/compiler/prparser.l index b580d57..3150b69 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.l +++ b/sys/contrib/dev/acpica/compiler/prparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y index 391ad3f..20d6e6a 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.y +++ b/sys/contrib/dev/acpica/compiler/prparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c index a3ac0c2..12e9b8e 100644 --- a/sys/contrib/dev/acpica/compiler/prscan.c +++ b/sys/contrib/dev/acpica/compiler/prscan.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c index 0dbf307..e36ea1d 100644 --- a/sys/contrib/dev/acpica/compiler/prutils.c +++ b/sys/contrib/dev/acpica/compiler/prutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,7 +149,7 @@ PrGetNextToken ( void PrError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 Column) { #if 0 @@ -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); } |