diff options
Diffstat (limited to 'sys/contrib/dev/acpica/compiler')
88 files changed, 11756 insertions, 7793 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index 3c3eee8..8823783 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,15 @@ ACPI_MODULE_NAME ("aslanalyze") +/* Local Prototypes */ + +static ACPI_STATUS +ApDeviceSubtreeWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + /******************************************************************************* * * FUNCTION: AnIsInternalMethod @@ -67,8 +76,8 @@ AnIsInternalMethod ( ACPI_PARSE_OBJECT *Op) { - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) + if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) || + (!strcmp (Op->Asl.ExternalName, "_OSI"))) { return (TRUE); } @@ -94,8 +103,8 @@ AnGetInternalMethodReturnType ( ACPI_PARSE_OBJECT *Op) { - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) + if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) || + (!strcmp (Op->Asl.ExternalName, "_OSI"))) { return (ACPI_BTYPE_STRING); } @@ -139,8 +148,7 @@ AnCheckId ( Length = strlen (Op->Asl.Value.String); if (!Length) { - AslError (ASL_ERROR, ASL_MSG_NULL_STRING, - Op, NULL); + AslError (ASL_ERROR, ASL_MSG_NULL_STRING, Op, NULL); return; } @@ -191,7 +199,7 @@ AnCheckId ( return; } - /* _HID Length is valid (7 or 8), now check the prefix (first 3 or 4 chars) */ + /* _HID Length is valid (7 or 8), now check prefix (first 3 or 4 chars) */ if (Length == 7) { @@ -231,8 +239,8 @@ AnCheckId ( { if (!isxdigit ((int) Op->Asl.Value.String[i])) { - AslError (ASL_ERROR, ASL_MSG_HID_SUFFIX, - Op, &Op->Asl.Value.String[i]); + AslError (ASL_ERROR, ASL_MSG_HID_SUFFIX, + Op, &Op->Asl.Value.String[i]); break; } } @@ -309,6 +317,12 @@ AnCheckMethodReturnValue ( Node = ArgOp->Asl.Node; + if (!Node) + { + /* No error message, this can happen and is OK */ + + return; + } /* Examine the parent op of this method */ @@ -323,7 +337,8 @@ AnCheckMethodReturnValue ( { /* Method SOMETIMES returns a value, SOMETIMES not */ - AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, + Op, Op->Asl.ExternalName); } else if (!(ThisNodeBtype & RequiredBtypes)) { @@ -400,12 +415,13 @@ AnIsResultUsed ( { return (TRUE); } + return (FALSE); /* Not used if one of these is the parent */ case PARSEOP_METHOD: - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: case PARSEOP_ELSE: return (FALSE); @@ -462,7 +478,7 @@ ApCheckForGpeNameConflict ( /* Verify 3rd/4th chars are a valid hex value */ - GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + GpeNumber = strtoul (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { return; @@ -572,6 +588,108 @@ ApCheckRegMethod ( /******************************************************************************* * + * FUNCTION: ApFindNameInDeviceTree + * + * 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(). "Same scope" can mean under an If or + * Else statement. + * + * NOTE: Detects _HID/_ADR in this type of construct (legal in ACPI 6.1+) + * + * Scope (\_SB.PCI0) + * { + * Device (I2C0) + * { + * If (SMD0 != 4) { + * Name (_HID, "INT3442") + * } Else { + * Name (_ADR, 0x400) + * } + * } + * } + ******************************************************************************/ + +BOOLEAN +ApFindNameInDeviceTree ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + + + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD, + ApDeviceSubtreeWalk, NULL, Name); + + if (Status == AE_CTRL_TRUE) + { + return (TRUE); /* Found a match */ + } + + return (FALSE); +} + + +/* Callback function for interface above */ + +static ACPI_STATUS +ApDeviceSubtreeWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + char *Name = ACPI_CAST_PTR (char, Context); + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_DEVICE: + + /* Level 0 is the starting device, ignore it */ + + if (Level > 0) + { + /* Ignore sub-devices */ + + return (AE_CTRL_DEPTH); + } + break; + + case PARSEOP_NAME: + case PARSEOP_METHOD: + + /* These are what we are looking for */ + + if (ACPI_COMPARE_NAME (Name, Op->Asl.NameSeg)) + { + return (AE_CTRL_TRUE); + } + return (AE_CTRL_DEPTH); + + case PARSEOP_SCOPE: + case PARSEOP_FIELD: + case PARSEOP_OPERATIONREGION: + + /* + * We want to ignore these, because either they can be large + * subtrees or open a scope to somewhere else. + */ + return (AE_CTRL_DEPTH); + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: ApFindNameInScope * * PARAMETERS: Name - Name to search for diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c index 08e4630..e2166d8 100644 --- a/sys/contrib/dev/acpica/compiler/aslascii.c +++ b/sys/contrib/dev/acpica/compiler/aslascii.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, 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/actables.h> #include <contrib/dev/acpica/include/acapps.h> #define _COMPONENT ACPI_COMPILER @@ -63,90 +64,7 @@ FlConsumeNewComment ( /******************************************************************************* * - * 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 + * FUNCTION: FlIsFileAsciiSource * * PARAMETERS: Filename - Full input filename * DisplayErrors - TRUE if error messages desired @@ -163,7 +81,7 @@ FlCheckForAcpiTable ( ******************************************************************************/ ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors) { @@ -177,6 +95,11 @@ FlCheckForAscii ( /* Open file in text mode so file offset is always accurate */ Handle = fopen (Filename, "rb"); + if (!Handle) + { + perror ("Could not open input file"); + return (AE_ERROR); + } Status.Line = 1; Status.Offset = 0; @@ -226,7 +149,7 @@ FlCheckForAscii ( /* Ensure character is either printable or a "space" char */ - else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte)) + else if (!isprint (Byte) && !isspace (Byte)) { if ((BadBytes < 10) && (DisplayErrors)) { diff --git a/sys/contrib/dev/acpica/compiler/aslbtypes.c b/sys/contrib/dev/acpica/compiler/aslbtypes.c index 0ba219a..37075e4 100644 --- a/sys/contrib/dev/acpica/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/compiler/aslbtypes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,6 @@ AnMapArgTypeToBtype ( switch (ArgType) { - /* Simple types */ case ARGI_ANYTYPE: @@ -100,9 +99,10 @@ AnMapArgTypeToBtype ( case ARGI_DDBHANDLE: /* * DDBHandleObject := SuperName - * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload + * ACPI_BTYPE_REFERENCE_OBJECT: + * Index reference as parameter of Load/Unload */ - return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE_OBJECT); /* Interchangeable types */ /* @@ -133,9 +133,24 @@ AnMapArgTypeToBtype ( case ARGI_REFERENCE: - return (ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_NAMED_REFERENCE); /* Name or Namestring */ case ARGI_TARGETREF: + + /* + * Target operand for most math and logic operators. + * Package objects not allowed as target. + */ + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DEBUG_OBJECT | + ACPI_BTYPE_REFERENCE_OBJECT); + + case ARGI_STORE_TARGET: + + /* Special target for Store(), includes packages */ + + return (ACPI_BTYPE_DATA | ACPI_BTYPE_DEBUG_OBJECT | + ACPI_BTYPE_REFERENCE_OBJECT); + case ARGI_FIXED_TARGET: case ARGI_SIMPLE_TARGET: @@ -149,28 +164,33 @@ AnMapArgTypeToBtype ( * Used only by SizeOf operator */ return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE_OBJECT); case ARGI_COMPLEXOBJ: /* Buffer, String, or package */ - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); + return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE); case ARGI_REF_OR_STRING: - return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); + /* Used by DeRefOf operator only */ + + return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE_OBJECT); case ARGI_REGION_OR_BUFFER: /* Used by Load() only. Allow buffers in addition to regions/fields */ - return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); + return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_FIELD_UNIT); case ARGI_DATAREFOBJ: - return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + /* Used by Store() only, as the source operand */ + + return (ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_REFERENCE_OBJECT); default: @@ -200,7 +220,6 @@ AnMapEtypeToBtype ( UINT32 Etype) { - if (Etype == ACPI_TYPE_ANY) { return (ACPI_BTYPE_OBJECTS_AND_REFS); @@ -274,7 +293,7 @@ AnMapEtypeToBtype ( case ACPI_TYPE_LOCAL_RESOURCE: case ACPI_TYPE_LOCAL_RESOURCE_FIELD: - return (ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_REFERENCE_OBJECT); default: @@ -307,7 +326,6 @@ AnFormatBtype ( *Buffer = 0; - if (Btype == 0) { strcat (Buffer, "NoReturnValue"); @@ -322,6 +340,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, AcpiUtGetTypeName (Type)); } @@ -334,6 +353,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Reference"); } @@ -345,6 +365,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Resource"); } @@ -387,11 +408,25 @@ AnGetBtype ( Node = Op->Asl.Node; if (!Node) { + /* These are not expected to have a node at this time */ + + if ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEDWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEQWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBYTEFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBITFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + return (ACPI_UINT32_MAX - 1); + } + DbgPrint (ASL_DEBUG_OUTPUT, - "No attached Nsnode: [%s] at line %u name [%s], ignoring typecheck\n", + "No attached Nsnode: [%s] at line %u name [%s], " + "ignoring typecheck. Parent [%s]\n", Op->Asl.ParseOpName, Op->Asl.LineNumber, - Op->Asl.ExternalName); - return (ACPI_UINT32_MAX); + Op->Asl.ExternalName, Op->Asl.Parent->Asl.ParseOpName); + return (ACPI_UINT32_MAX - 1); } ThisNodeBtype = AnMapEtypeToBtype (Node->Type); @@ -401,12 +436,6 @@ AnGetBtype ( "could not map type"); } - /* - * Since it was a named reference, enable the - * reference bit also - */ - ThisNodeBtype |= ACPI_BTYPE_REFERENCE; - if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) { ReferencedNode = Node->Op; diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index 8dd30f3..cf1f170 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,22 +97,16 @@ CgGenerateAmlOutput ( void) { - DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n"); - /* Generate the AML output file */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, 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, " "); - + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); CgCloseTable (); } @@ -136,61 +130,64 @@ CgAmlWriteWalk ( void *Context) { - /* - * Print header at level 0. Alignment assumes 32-bit pointers - */ - if (!Level) + /* Generate the AML for this node */ + + CgWriteNode (Op); + + if (!Gbl_DebugFlag) { - 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" - " Parent Child Next Flags AcTyp Final Col L\n", - 76, " "); + return (AE_OK); } - /* Debug output */ + /* Print header at level 0. Alignment assumes 32-bit pointers */ - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - - if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG || - Op->Asl.ParseOpcode == PARSEOP_NAMESTRING || - Op->Asl.ParseOpcode == PARSEOP_METHODCALL) + if (!Level) { DbgPrint (ASL_TREE_OUTPUT, - "%10.32s ", Op->Asl.ExternalName); + "\nFinal parse tree used for AML output:\n"); + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); } - else + + /* Dump ParseOp name and possible value */ + + switch (Op->Asl.ParseOpcode) { - DbgPrint (ASL_TREE_OUTPUT, " "); - } + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + case PARSEOP_STRING_LITERAL: - DbgPrint (ASL_TREE_OUTPUT, - "%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, - /* 4 */ Op->Asl.AmlOpcodeLength, - /* 5 */ Op->Asl.AmlPkgLenBytes, - /* 6 */ Op->Asl.AmlLength, - /* 7 */ Op->Asl.AmlSubtreeLength, - /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, - /* 9 */ Op, - /* 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); + UtDumpStringOp (Op, Level); + break; - /* Generate the AML for this node */ + default: + + UtDumpBasicOp (Op, Level); + break; + } + + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG2, + /* 1 */ (UINT32) Op->Asl.Value.Integer, + /* 2 */ Op->Asl.ParseOpcode, + /* 3 */ Op->Asl.AmlOpcode, + /* 4 */ Op->Asl.AmlOpcodeLength, + /* 5 */ Op->Asl.AmlPkgLenBytes, + /* 6 */ Op->Asl.AmlLength, + /* 7 */ Op->Asl.AmlSubtreeLength, + /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, + /* 9 */ Op, + /* 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, + /* 18 */ Op->Asl.EndLine, + /* 19 */ Op->Asl.LogicalLineNumber, + /* 20 */ Op->Asl.EndLogicalLine); - CgWriteNode (Op); return (AE_OK); } @@ -271,7 +268,8 @@ CgWriteAmlOpcode ( /* These opcodes should not get here */ printf ("Found a node with an unassigned AML opcode\n"); - FlPrintFile (ASL_FILE_STDERR, "Found a node with an unassigned AML opcode\n"); + FlPrintFile (ASL_FILE_STDERR, + "Found a node with an unassigned AML opcode\n"); return; case AML_INT_RESERVEDFIELD_OP: @@ -354,8 +352,10 @@ CgWriteAmlOpcode ( */ PkgLen.Len >>= 4; - /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */ - + /* + * Now we can write the remaining bytes - + * either 1, 2, or 3 bytes + */ for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++) { CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1); @@ -464,50 +464,100 @@ CgWriteTableHeader ( /* Table length. Checksum zero for now, will rewrite later */ - TableHeader.Length = Gbl_TableLength; + TableHeader.Length = sizeof (ACPI_TABLE_HEADER) + + Op->Asl.AmlSubtreeLength; TableHeader.Checksum = 0; + Op->Asl.FinalAmlOffset = ftell (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + + /* Write entire header and clear the table header global */ + CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + memset (&TableHeader, 0, sizeof (ACPI_TABLE_HEADER)); } /******************************************************************************* * - * FUNCTION: CgCloseTable + * FUNCTION: CgUpdateHeader * - * PARAMETERS: None. + * PARAMETERS: Op - Op for the Definition Block * * RETURN: None. * * DESCRIPTION: Complete the ACPI table by calculating the checksum and - * re-writing the header. + * re-writing the header for the input definition block * ******************************************************************************/ static void -CgCloseTable ( - void) +CgUpdateHeader ( + ACPI_PARSE_OBJECT *Op) { signed char Sum; + UINT32 i; + UINT32 Length; UINT8 FileByte; + UINT8 Checksum; - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - Sum = 0; + /* Calculate the checksum over the entire definition block */ - /* Calculate the checksum over the entire file */ + Sum = 0; + Length = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset); - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK) + for (i = 0; i < Length; i++) { + if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK) + { + printf ("EOF while reading checksum bytes\n"); + return; + } + Sum = (signed char) (Sum + FileByte); } - /* Re-write the table header with the checksum */ + Checksum = (UINT8) (0 - Sum); + + /* Re-write the the checksum byte */ + + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + + ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum)); + + FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1); +} + + +/******************************************************************************* + * + * FUNCTION: CgCloseTable + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Complete the ACPI table by calculating the checksum and + * re-writing each table header. This allows support for + * multiple definition blocks in a single source file. + * + ******************************************************************************/ + +static void +CgCloseTable ( + void) +{ + ACPI_PARSE_OBJECT *Op; + - TableHeader.Checksum = (UINT8) (0 - Sum); + /* Process all definition blocks */ - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + Op = Gbl_ParseTreeRoot->Asl.Child; + while (Op) + { + CgUpdateHeader (Op); + Op = Op->Asl.Next; + } } @@ -534,13 +584,18 @@ CgWriteNode ( /* TBD: this may not be the best place for this check */ if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) || - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_INCLUDE) || (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END)) { return; } + if ((Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + Gbl_DoExternals == FALSE) + { + return; + } + Op->Asl.FinalAmlLength = 0; switch (Op->Asl.AmlOpcode) @@ -583,7 +638,7 @@ CgWriteNode ( break; - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: CgWriteTableHeader (Op); break; diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 0b0ca7a..3dbd0f6 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,9 +100,16 @@ CmDoCompile ( Event = UtBeginEvent ("Preprocess input file"); if (Gbl_PreprocessFlag) { + /* Enter compiler name as a #define */ + + PrAddDefine (ASL_DEFINE, "", FALSE); + /* Preprocessor */ PrDoPreprocess (); + Gbl_CurrentLineNumber = 1; + Gbl_LogicalLineNumber = 1; + if (Gbl_PreprocessOnly) { UtEndEvent (Event); @@ -112,6 +119,7 @@ CmDoCompile ( } UtEndEvent (Event); + /* Build the parse tree */ Event = UtBeginEvent ("Parse source code and build parse tree"); @@ -122,14 +130,15 @@ CmDoCompile ( if (Gbl_SyntaxError) { - fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); + fprintf (stderr, + "Compiler aborting due to parser-detected syntax error(s)\n"); LsDumpParseTree (); goto ErrorExit; } /* Did the parse tree get successfully constructed? */ - if (!RootNode) + if (!Gbl_ParseTreeRoot) { /* * If there are no errors, then we have some sort of @@ -157,29 +166,29 @@ CmDoCompile ( LsDumpParseTree (); - OpcGetIntegerWidth (RootNode); + OpcGetIntegerWidth (Gbl_ParseTreeRoot->Asl.Child); UtEndEvent (Event); /* Pre-process parse tree for any operator transforms */ Event = UtBeginEvent ("Parse tree transforms"); DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - TrAmlTransformWalk, NULL, NULL); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL); UtEndEvent (Event); /* Generate AML opcodes corresponding to the parse tokens */ Event = UtBeginEvent ("Generate AML opcodes"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL); UtEndEvent (Event); /* * Now that the input is parsed, we can open the AML output file. - * Note: by default, the name of this file comes from the table descriptor - * within the input file. + * Note: by default, the name of this file comes from the table + * descriptor within the input file. */ Event = UtBeginEvent ("Open AML output file"); Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); @@ -194,12 +203,12 @@ CmDoCompile ( Event = UtBeginEvent ("Constant folding via AML interpreter"); DbgPrint (ASL_DEBUG_OUTPUT, - "\nInterpreting compile-time constant expressions\n\n"); + "Interpreting compile-time constant expressions\n\n"); if (Gbl_FoldConstants) { - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - OpcAmlConstantWalk, NULL, NULL); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, + NULL, OpcAmlConstantWalk, NULL); } else { @@ -211,16 +220,16 @@ CmDoCompile ( Event = UtBeginEvent ("Updating AML opcodes after constant folding"); DbgPrint (ASL_DEBUG_OUTPUT, - "\nUpdating AML opcodes after constant folding\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + "Updating AML opcodes after constant folding\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeUpdateWalk, NULL); UtEndEvent (Event); /* Calculate all AML package lengths */ Event = UtBeginEvent ("Generate AML package lengths"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); @@ -246,7 +255,8 @@ CmDoCompile ( /* Namespace loading */ Event = UtBeginEvent ("Create ACPI Namespace"); - Status = LdLoadNamespace (RootNode); + DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n"); + Status = LdLoadNamespace (Gbl_ParseTreeRoot); UtEndEvent (Event); if (ACPI_FAILURE (Status)) { @@ -255,7 +265,9 @@ CmDoCompile ( /* Namespace cross-reference */ - AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); + AslGbl_NamespaceEvent = UtBeginEvent ( + "Cross reference parse tree and Namespace"); + DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n"); Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { @@ -267,6 +279,17 @@ CmDoCompile ( LkFindUnreferencedObjects (); UtEndEvent (AslGbl_NamespaceEvent); + /* Resolve External Declarations */ + + if (Gbl_DoExternals) + { + Event = UtBeginEvent ("Resolve all Externals"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); + UtEndEvent (Event); + } + /* * Semantic analysis. This can happen only after the * namespace has been loaded and cross-referenced. @@ -276,33 +299,50 @@ CmDoCompile ( Event = UtBeginEvent ("Analyze control method return types"); AnalysisWalkInfo.MethodStack = NULL; - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n"); + + if (Gbl_CrossReferenceOutput) + { + OtPrintHeaders ("Part 1: Object Reference Map " + "(Object references from within each control method)"); + } + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, MtMethodAnalysisWalkBegin, MtMethodAnalysisWalkEnd, &AnalysisWalkInfo); UtEndEvent (Event); + /* Generate the object cross-reference file if requested */ + + Event = UtBeginEvent ("Generate cross-reference file"); + OtCreateXrefFile (); + UtEndEvent (Event); + /* Semantic error checking part two - typing of method returns */ Event = UtBeginEvent ("Determine object types returned by methods"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); UtEndEvent (Event); /* Semantic error checking part three - operand type checking */ Event = UtBeginEvent ("Analyze AML operand types"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, - NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + DbgPrint (ASL_DEBUG_OUTPUT, + "Semantic analysis - Operand type checking\n\n"); + if (Gbl_DoTypechecking) + { + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, + NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + } UtEndEvent (Event); /* Semantic error checking part four - other miscellaneous checks */ Event = UtBeginEvent ("Miscellaneous analysis"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, AnOtherSemanticAnalysisWalkBegin, NULL, &AnalysisWalkInfo); UtEndEvent (Event); @@ -310,16 +350,17 @@ CmDoCompile ( /* Calculate all AML package lengths */ Event = UtBeginEvent ("Finish AML package length generation"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); /* Code generation - emit the AML */ Event = UtBeginEvent ("Generate AML code and write output files"); + DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n"); CgGenerateAmlOutput (); UtEndEvent (Event); @@ -579,8 +620,8 @@ CmDumpAllEvents ( { ASL_EVENT_INFO *Event; UINT32 Delta; - UINT32 USec; - UINT32 MSec; + UINT32 MicroSeconds; + UINT32 MilliSeconds; UINT32 i; @@ -600,23 +641,23 @@ CmDumpAllEvents ( Delta = (UINT32) (Event->EndTime - Event->StartTime); - USec = Delta / ACPI_100NSEC_PER_USEC; - MSec = Delta / ACPI_100NSEC_PER_MSEC; + MicroSeconds = Delta / ACPI_100NSEC_PER_USEC; + MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC; /* Round milliseconds up */ - if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500) + if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500) { - MSec++; + MilliSeconds++; } DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", - USec, MSec, Event->EventName); + MicroSeconds, MilliSeconds, Event->EventName); if (Gbl_CompileTimesFlag) { printf ("%8u usec %8u msec - %s\n", - USec, MSec, Event->EventName); + MicroSeconds, MilliSeconds, Event->EventName); } } @@ -708,7 +749,7 @@ CmCleanupAndExit ( /* Close all open files */ /* - * Take care with the preprocessor file (.i), it might be the same + * Take care with the preprocessor file (.pre), it might be the same * as the "input" file, depending on where the compiler has terminated * or aborted. Prevent attempt to close the same file twice in * loop below. @@ -733,10 +774,9 @@ CmCleanupAndExit ( FlDeleteFile (ASL_FILE_AML_OUTPUT); } - /* Delete the preprocessor output file (.i) unless -li flag is set */ + /* Delete the preprocessor temp file unless full debug was specified */ - if (!Gbl_PreprocessorOutputFlag && - Gbl_PreprocessFlag) + if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile) { FlDeleteFile (ASL_FILE_PREPROCESSOR); } @@ -752,8 +792,6 @@ CmCleanupAndExit ( * Note: Handles are cleared by FlCloseFile above, so we look at the * filename instead, to determine if the .SRC file was actually * created. - * - * TBD: SourceOutput should be .TMP, then rename if we want to keep it? */ if (!Gbl_SourceOutputFlag) { @@ -805,7 +843,7 @@ CmDeleteCaches ( Gbl_ParseOpCount = 0; Gbl_ParseOpCacheNext = NULL; Gbl_ParseOpCacheLast = NULL; - RootNode = NULL; + Gbl_ParseTreeRoot = NULL; /* Generic string cache */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 181b36c..4062ce2 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -167,11 +167,7 @@ CmDeleteCaches ( * aslascii - ascii support */ ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle); - -ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors); @@ -291,6 +287,10 @@ ApFindNameInScope ( char *Name, ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInDeviceTree ( + char *Name, + ACPI_PARSE_OBJECT *Op); /* * aslerror - error handling/reporting @@ -542,6 +542,14 @@ OptOptimizeNamePath ( /* + * aslpld - ToPLD macro support + */ +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op); + + +/* * aslprintf - Printf/Fprintf macros */ void @@ -656,7 +664,13 @@ ApCheckPackage ( * asltransform - parse tree transformations */ ACPI_STATUS -TrAmlTransformWalk ( +TrAmlTransformWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +ACPI_STATUS +TrAmlTransformWalkEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); @@ -673,6 +687,25 @@ TrWalkParseTree ( ASL_WALK_CALLBACK AscendingCallback, void *Context); +/* + * aslexternal - External opcode support + */ +ACPI_STATUS +ExAmlExternalWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +ACPI_STATUS +ExAmlExternalWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +void +ExDoExternal ( + ACPI_PARSE_OBJECT *Op); + /* Values for "Visitation" parameter above */ #define ASL_WALK_VISIT_DOWNWARD 0x01 @@ -680,6 +713,11 @@ TrWalkParseTree ( #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) +void +TrSetParent ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *ParentOp); + ACPI_PARSE_OBJECT * TrAllocateNode ( UINT32 ParseOpcode); @@ -741,6 +779,10 @@ TrSetEndLineNumber ( ACPI_PARSE_OBJECT *Op); void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op); + +void TrWalkTree ( void); @@ -909,6 +951,24 @@ XfCrossReferenceNamespace ( /* + * aslxrefout + */ +void +OtPrintHeaders ( + char *Message); + +void +OtCreateXrefFile ( + void); + +void +OtXrefWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + ASL_METHOD_INFO *MethodInfo); + + +/* * aslutils - common compiler utilites */ void @@ -923,6 +983,30 @@ DbgPrint ( #define ASL_PARSE_OUTPUT 1 #define ASL_TREE_OUTPUT 2 +UINT8 +UtIsBigEndianMachine ( + void); + +BOOLEAN +UtQueryForOverwrite ( + char *Pathname); + +void +UtDumpStringOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level); + +void +UtDumpIntegerOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 IntegerLength); + +void +UtDumpBasicOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level); + void UtDisplaySupportedTables ( void); @@ -944,11 +1028,6 @@ UtLocalCalloc ( UINT32 Size); void -UtPrintFormattedName ( - UINT16 ParseOpcode, - UINT32 Level); - -void UtDisplaySummary ( UINT32 FileId); @@ -1002,12 +1081,6 @@ UINT64 UtDoConstant ( char *String); -ACPI_STATUS -UtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger); - /* * asluuid - UUID support @@ -1281,6 +1354,6 @@ DtDoCompile( ACPI_STATUS DtCreateTemplates ( - char *Signature); + char **argv); #endif /* __ASLCOMPILER_H */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index 621f5ae..8dd8069 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -156,6 +156,9 @@ NamePathTail [.]{NameSeg} "^=" { count (3); return (PARSEOP_EXP_XOR_EQ); } "|=" { count (3); return (PARSEOP_EXP_OR_EQ); } +"[" { count (3); return(PARSEOP_EXP_INDEX_LEFT); } +"]" { count (0); return(PARSEOP_EXP_INDEX_RIGHT); } + /* * Begin standard ASL grammar @@ -207,7 +210,7 @@ NamePathTail [.]{NameSeg} "Debug" { count (1); return (PARSEOP_DEBUG); } "Decrement" { count (3); return (PARSEOP_DECREMENT); } "Default" { count (3); return (PARSEOP_DEFAULT); } -"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); } +"DefinitionBlock" { count (1); return (PARSEOP_DEFINITION_BLOCK); } "DeRefOf" { count (3); return (PARSEOP_DEREFOF); } "Device" { count (2); return (PARSEOP_DEVICE); } "Divide" { count (3); return (PARSEOP_DIVIDE); } @@ -329,6 +332,7 @@ NamePathTail [.]{NameSeg} "GpioInt" { count (1); return (PARSEOP_GPIO_INT); } "GpioIo" { count (1); return (PARSEOP_GPIO_IO); } "I2cSerialBus" { count (1); return (PARSEOP_I2C_SERIALBUS); } +"I2cSerialBusV2" { count (1); return (PARSEOP_I2C_SERIALBUS_V2); } "Interrupt" { count (1); return (PARSEOP_INTERRUPT); } "IO" { count (1); return (PARSEOP_IO); } "IRQ" { count (1); return (PARSEOP_IRQ); } @@ -341,9 +345,11 @@ NamePathTail [.]{NameSeg} "QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } "Register" { count (1); return (PARSEOP_REGISTER); } "SpiSerialBus" { count (1); return (PARSEOP_SPI_SERIALBUS); } +"SpiSerialBusV2" { count (1); return (PARSEOP_SPI_SERIALBUS_V2); } "StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); } "StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); } "UartSerialBus" { count (1); return (PARSEOP_UART_SERIALBUS); } +"UartSerialBusV2" { count (1); return (PARSEOP_UART_SERIALBUS_V2); } "VendorLong" { count (1); return (PARSEOP_VENDORLONG); } "VendorShort" { count (1); return (PARSEOP_VENDORSHORT); } "WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); } @@ -669,9 +675,14 @@ NamePathTail [.]{NameSeg} /* printf debug macros */ + "printf" { count (0); return (PARSEOP_PRINTF); } "fprintf" { count (0); return (PARSEOP_FPRINTF); } + /* Other macros */ + +"For" { count (0); return (PARSEOP_FOR); } + /* Predefined compiler names */ "__DATE__" { count (0); return (PARSEOP___DATE__); } @@ -709,7 +720,7 @@ NamePathTail [.]{NameSeg} return (PARSEOP_NAMESTRING); } . { count (1); - if (ACPI_IS_PRINT (*AslCompilertext)) + if (isprint ((int) *AslCompilertext)) { sprintf (MsgBuffer, "Invalid character (%c), expecting ASL keyword or name", diff --git a/sys/contrib/dev/acpica/compiler/aslcstyle.y b/sys/contrib/dev/acpica/compiler/aslcstyle.y new file mode 100644 index 0000000..62a7b65 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslcstyle.y @@ -0,0 +1,209 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslcstyle.y - Production rules for symbolic operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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 rules for the symbolic (c-style) operators + * + ******************************************************************************/ + +/* + * 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,TrCreateNullTarget ());} + + | 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,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), + TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + + | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + + | 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;} + + /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ + + | SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT + {$$ = TrCreateLeafNode (PARSEOP_INDEX); + TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} + ; + + /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */ + +IndexExpTerm + + : SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT + {$$ = TrCreateLeafNode (PARSEOP_INDEX); + TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} + ; + +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,TrCreateNullTarget (), + 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));} + ; diff --git a/sys/contrib/dev/acpica/compiler/asldebug.c b/sys/contrib/dev/acpica/compiler/asldebug.c new file mode 100644 index 0000000..0fa8c0a --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asldebug.c @@ -0,0 +1,253 @@ +/****************************************************************************** + * + * Module Name: asldebug -- Debug output support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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" + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asldebug") + + +/* Local prototypes */ + +static void +UtDumpParseOpName ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 DataLength); + + +/******************************************************************************* + * + * FUNCTION: UtDumpIntegerOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * IntegerLength - Output length of the integer (2/4/8/16) + * + * RETURN: None + * + * DESCRIPTION: Emit formatted debug output for "integer" ops. + * Note: IntegerLength must be one of 2,4,8,16. + * + ******************************************************************************/ + +void +UtDumpIntegerOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 IntegerLength) +{ + + /* Emit the ParseOp name, leaving room for the integer */ + + UtDumpParseOpName (Op, Level, IntegerLength); + + /* Emit the integer based upon length */ + + switch (IntegerLength) + { + case 2: /* Byte */ + case 4: /* Word */ + case 8: /* Dword */ + + DbgPrint (ASL_TREE_OUTPUT, + "%*.*X", IntegerLength, IntegerLength, Op->Asl.Value.Integer); + break; + + case 16: /* Qword and Integer */ + + DbgPrint (ASL_TREE_OUTPUT, + "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpStringOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * + * RETURN: None + * + * DESCRIPTION: Emit formatted debug output for String/Pathname ops. + * + ******************************************************************************/ + +void +UtDumpStringOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level) +{ + char *String; + + + String = Op->Asl.Value.String; + + if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL) + { + /* + * For the "path" ops NAMEPATH, NAMESEG, METHODCALL -- if the + * ExternalName is valid, it takes precedence. In these cases the + * Value.String is the raw "internal" name from the AML code, which + * we don't want to use, because it contains non-ascii characters. + */ + if (Op->Asl.ExternalName) + { + String = Op->Asl.ExternalName; + } + } + + if (!String) + { + DbgPrint (ASL_TREE_OUTPUT, + " ERROR: Could not find a valid String/Path pointer\n"); + return; + } + + /* Emit the ParseOp name, leaving room for the string */ + + UtDumpParseOpName (Op, Level, strlen (String)); + DbgPrint (ASL_TREE_OUTPUT, "%s", String); +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpBasicOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * + * RETURN: None + * + * DESCRIPTION: Generic formatted debug output for "basic" ops that have no + * associated strings or integer values. + * + ******************************************************************************/ + +void +UtDumpBasicOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level) +{ + + /* Just print out the ParseOp name, there is no extra data */ + + UtDumpParseOpName (Op, Level, 0); +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpParseOpName + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * DataLength - Length of data to appear after the name + * + * RETURN: None + * + * DESCRIPTION: Indent and emit the ascii ParseOp name for the op + * + ******************************************************************************/ + +static void +UtDumpParseOpName ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 DataLength) +{ + char *ParseOpName; + UINT32 IndentLength; + UINT32 NameLength; + UINT32 LineLength; + UINT32 PaddingLength; + + + /* Emit the LineNumber/IndentLevel prefix on each output line */ + + DbgPrint (ASL_TREE_OUTPUT, + "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + + ParseOpName = UtGetOpName (Op->Asl.ParseOpcode); + + /* Calculate various lengths for output alignment */ + + IndentLength = Level * DEBUG_SPACES_PER_INDENT; + NameLength = strlen (ParseOpName); + LineLength = IndentLength + 1 + NameLength + 1 + DataLength; + PaddingLength = (DEBUG_MAX_LINE_LENGTH + 1) - LineLength; + + /* Parse tree indentation is based upon the nesting/indent level */ + + if (Level) + { + DbgPrint (ASL_TREE_OUTPUT, "%*s", IndentLength, " "); + } + + /* Emit the actual name here */ + + DbgPrint (ASL_TREE_OUTPUT, " %s", ParseOpName); + + /* Emit extra padding blanks for alignment of later data items */ + + if (LineLength > DEBUG_MAX_LINE_LENGTH) + { + /* Split a long line immediately after the ParseOpName string */ + + DbgPrint (ASL_TREE_OUTPUT, "\n%*s", + (DEBUG_FULL_LINE_LENGTH - DataLength), " "); + } + else + { + DbgPrint (ASL_TREE_OUTPUT, "%*s", PaddingLength, " "); + } +} diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 0697276..f615cb2 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,8 +52,9 @@ #define AML_DISASSEMBLER_NAME "AML/ASL+ Disassembler" #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" +#define ASL_DEFINE "__IASL__" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.0" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.1" /* Configuration constants */ @@ -103,31 +104,12 @@ #define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD -/* filename suffixes for output files */ - -#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" -#define FILE_SUFFIX_SOURCE "src" -#define FILE_SUFFIX_NAMESPACE "nsp" -#define FILE_SUFFIX_ASM_SOURCE "asm" -#define FILE_SUFFIX_C_SOURCE "c" -#define FILE_SUFFIX_DISASSEMBLY "dsl" -#define FILE_SUFFIX_ASM_INCLUDE "inc" -#define FILE_SUFFIX_C_INCLUDE "h" -#define FILE_SUFFIX_ASL_CODE "asl" -#define FILE_SUFFIX_C_OFFSET "offset.h" - - /* Types for input files */ -#define ASL_INPUT_TYPE_BINARY 0 -#define ASL_INPUT_TYPE_ACPI_TABLE 1 -#define ASL_INPUT_TYPE_ASCII_ASL 2 -#define ASL_INPUT_TYPE_ASCII_DATA 3 +#define ASL_INPUT_TYPE_BINARY 0 +#define ASL_INPUT_TYPE_BINARY_ACPI_TABLE 1 +#define ASL_INPUT_TYPE_ASCII_ASL 2 +#define ASL_INPUT_TYPE_ASCII_DATA 3 /* Misc */ @@ -136,6 +118,7 @@ #define ASL_ABORT TRUE #define ASL_NO_ABORT FALSE #define ASL_EOF ACPI_UINT32_MAX +#define ASL_IGNORE_LINE (ACPI_UINT32_MAX -1) /* Listings */ @@ -152,12 +135,6 @@ #define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3) -/* String to Integer conversion */ - -#define NEGATIVE 1 -#define POSITIVE 0 - - /* Helper macros for resource tag creation */ #define RsCreateMultiBitField \ @@ -178,4 +155,34 @@ #define RsCreateQwordField(Op, Name, ByteOffset) \ RsCreateResourceField (Op, Name, ByteOffset, 0, 64); + +/* + * Macros for debug output + */ + +#define DEBUG_MAX_LINE_LENGTH 61 +#define DEBUG_SPACES_PER_INDENT 3 +#define DEBUG_FULL_LINE_LENGTH 71 + +#define ASL_PARSE_TREE_FULL_LINE "\n%71.71s" + +/* Header/Trailer for original parse tree directly from the parser */ + +#define ASL_PARSE_TREE_HEADER1 \ + "%*s Value P_Op Flags Line# End# LogL# EndL#\n", 65, " " + +#define ASL_PARSE_TREE_DEBUG1 \ + " %4.4X %8.8X %5d %5d %5d %5d" + +/* Header/Trailer for processed parse tree used for AML generation */ + +#define ASL_PARSE_TREE_HEADER2 \ + "%*s NameString Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"\ + " Parent Child Next Flags AcTyp Final Col"\ + " Line# End# LogL# EndL#\n", 60, " " + +#define ASL_PARSE_TREE_DEBUG2 \ + " %08X %04X %04X %01X %04X %04X %05X %05X "\ + "%08X %08X %08X %08X %08X %08X %04X %02d %5d %5d %5d %5d\n" + #endif /* ASLDEFINE.H */ diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index 9b8928c..f71d56a 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -267,8 +267,10 @@ AePrintException ( if (!Enode->SourceLine) { - /* Use the merged header/source file if present, otherwise use input file */ - + /* + * Use the merged header/source file if present, otherwise + * use input file + */ SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; if (!SourceFile) { @@ -314,18 +316,18 @@ AePrintException ( fprintf (OutputFile, " %6u: ", Enode->LineNumber); /* - * If not at EOF, get the corresponding source code line and - * display it. Don't attempt this if we have a premature EOF - * condition. + * If not at EOF, get the corresponding source code line + * and display it. Don't attempt this if we have a + * premature EOF condition. */ if (!PrematureEOF) { /* - * Seek to the offset in the combined source file, read - * the source line, and write it to the output. + * Seek to the offset in the combined source file, + * read the source line, and write it to the output. */ - Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, - (int) SEEK_SET); + Actual = fseek (SourceFile, + (long) Enode->LogicalByteOffset, (int) SEEK_SET); if (Actual) { fprintf (OutputFile, @@ -561,11 +563,11 @@ AslCommonError2 ( /* Keep a copy of the extra message */ - ACPI_STRCPY (MessageBuffer, ExtraMessage); + strcpy (MessageBuffer, ExtraMessage); } LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1); - ACPI_STRCPY (LineBuffer, SourceLine); + strcpy (LineBuffer, SourceLine); /* Initialize the error node */ @@ -647,7 +649,7 @@ AslCommonError ( /* Keep a copy of the extra message */ - ACPI_STRCPY (MessageBuffer, ExtraMessage); + strcpy (MessageBuffer, ExtraMessage); } /* Initialize the error node */ @@ -880,16 +882,17 @@ AslCoreSubsystemError ( if (Op) { - AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber, - Op->Asl.LogicalLineNumber, - Op->Asl.LogicalByteOffset, - Op->Asl.Column, - Op->Asl.Filename, MsgBuffer); + AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, + Op->Asl.LineNumber, + Op->Asl.LogicalLineNumber, + Op->Asl.LogicalByteOffset, + Op->Asl.Column, + Op->Asl.Filename, MsgBuffer); } else { - AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0, - 0, 0, 0, NULL, MsgBuffer); + AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, + 0, 0, 0, 0, NULL, MsgBuffer); } if (Abort) diff --git a/sys/contrib/dev/acpica/compiler/aslexternal.c b/sys/contrib/dev/acpica/compiler/aslexternal.c new file mode 100644 index 0000000..30d4d0a --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslexternal.c @@ -0,0 +1,498 @@ +/****************************************************************************** + * + * Module Name: aslexternal - ASL External opcode compiler support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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/acparser.h> +#include <contrib/dev/acpica/include/amlcode.h> +#include <contrib/dev/acpica/include/acnamesp.h> + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslexternal") + + +/* Local prototypes */ + +static void +ExInsertArgCount ( + ACPI_PARSE_OBJECT *Op); + +static void +ExMoveExternals ( + ACPI_PARSE_OBJECT *DefinitionBlockOp); + + +/******************************************************************************* + * + * FUNCTION: ExDoExternal + * + * PARAMETERS: Op - Current Parse node + * + * RETURN: None + * + * DESCRIPTION: Add an External() definition to the global list. This list + * is used to generate External opcodes. + * + ******************************************************************************/ + +void +ExDoExternal ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ListOp; + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *ArgCountOp; + + + ArgCountOp = Op->Asl.Child->Asl.Next->Asl.Next; + ArgCountOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST; + ArgCountOp->Asl.Value.Integer = 0; + UtSetParseOpName (ArgCountOp); + + /* Create new list node of arbitrary type */ + + ListOp = TrAllocateNode (PARSEOP_DEFAULT_ARG); + + /* Store External node as child */ + + ListOp->Asl.Child = Op; + ListOp->Asl.Next = NULL; + + if (Gbl_ExternalsListHead) + { + /* Link new External to end of list */ + + Prev = Gbl_ExternalsListHead; + Next = Prev; + while (Next) + { + Prev = Next; + Next = Next->Asl.Next; + } + + Prev->Asl.Next = ListOp; + } + else + { + Gbl_ExternalsListHead = ListOp; + } +} + + +/******************************************************************************* + * + * FUNCTION: ExInsertArgCount + * + * PARAMETERS: Op - Op for a method invocation + * + * RETURN: None + * + * DESCRIPTION: Obtain the number of arguments for a control method -- from + * the actual invocation. + * + ******************************************************************************/ + +static void +ExInsertArgCount ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *NameOp; + ACPI_PARSE_OBJECT *Child; + ACPI_PARSE_OBJECT *ArgCountOp; + char * ExternalName; + char * CallName; + UINT16 ArgCount = 0; + ACPI_STATUS Status; + + + CallName = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); + + Next = Gbl_ExternalsListHead; + while (Next) + { + ArgCount = 0; + + /* Skip if External node already handled */ + + if (Next->Asl.Child->Asl.CompileFlags & NODE_VISITED) + { + Next = Next->Asl.Next; + continue; + } + + NameOp = Next->Asl.Child->Asl.Child; + ExternalName = AcpiNsGetNormalizedPathname (NameOp->Asl.Node, TRUE); + + if (strcmp (CallName, ExternalName)) + { + ACPI_FREE (ExternalName); + Next = Next->Asl.Next; + continue; + } + + Next->Asl.Child->Asl.CompileFlags |= NODE_VISITED; + + /* + * Since we will reposition Externals to the Root, set Namepath + * to the fully qualified name and recalculate the aml length + */ + Status = UtInternalizeName (ExternalName, + &NameOp->Asl.Value.String); + + ACPI_FREE (ExternalName); + if (ACPI_FAILURE (Status)) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, + NULL, "- Could not Internalize External"); + break; + } + + NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String); + + /* Get argument count */ + + Child = Op->Asl.Child; + while (Child) + { + ArgCount++; + Child = Child->Asl.Next; + } + + /* Setup ArgCount operand */ + + ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next; + ArgCountOp->Asl.Value.Integer = ArgCount; + break; + } + + ACPI_FREE (CallName); +} + + +/******************************************************************************* + * + * FUNCTION: ExAmlExternalWalkBegin + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to create external opcode list for methods. + * + ******************************************************************************/ + +ACPI_STATUS +ExAmlExternalWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + /* External list head saved in the definition block op */ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + Gbl_ExternalsListHead = Op->Asl.Value.Arg; + } + + if (!Gbl_ExternalsListHead) + { + return (AE_OK); + } + + if (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) + { + return (AE_OK); + } + + /* + * The NameOp child under an ExternalOp gets turned into PARSE_METHODCALL + * by XfNamespaceLocateBegin(). Ignore these. + */ + if (Op->Asl.Parent && + Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_EXTERNAL) + { + return (AE_OK); + } + + ExInsertArgCount (Op); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: ExAmlExternalWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to create external opcode list for methods. + * Here, we just want to catch the case where a definition block + * has been completed. Then we move all of the externals into + * a single block in the parse tree and thus the AML code. + * + ******************************************************************************/ + +ACPI_STATUS +ExAmlExternalWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + /* + * Process any existing external list. (Support for + * multiple definition blocks in a single file/compile) + */ + ExMoveExternals (Op); + Gbl_ExternalsListHead = NULL; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: ExMoveExternals + * + * PARAMETERS: DefinitionBlockOp - Op for current definition block + * + * RETURN: None + * + * DESCRIPTION: Move all externals present in the source file into a single + * block of AML code, surrounded by an "If (0)" to prevent + * AML interpreters from attempting to execute the External + * opcodes. + * + ******************************************************************************/ + +static void +ExMoveExternals ( + ACPI_PARSE_OBJECT *DefinitionBlockOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + ACPI_PARSE_OBJECT *ExternalOp; + ACPI_PARSE_OBJECT *PredicateOp; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_OBJECT_TYPE ObjType; + UINT32 i; + + + if (!Gbl_ExternalsListHead) + { + return; + } + + /* Remove the External nodes from the tree */ + + NextOp = Gbl_ExternalsListHead; + while (NextOp) + { + /* + * The External is stored in child pointer of each node in the + * list + */ + ExternalOp = NextOp->Asl.Child; + + /* Set line numbers (for listings, etc.) */ + + ExternalOp->Asl.LineNumber = 0; + ExternalOp->Asl.LogicalLineNumber = 0; + + Next = ExternalOp->Asl.Child; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + ParentOp = ExternalOp->Asl.Parent; + Prev = Next = ParentOp->Asl.Child; + + /* Now find the External node's position in parse tree */ + + while (Next != ExternalOp) + { + Prev = Next; + Next = Next->Asl.Next; + } + + /* Remove the External from the parse tree */ + + if (Prev == ExternalOp) + { + /* External was the first child node */ + + ParentOp->Asl.Child = ExternalOp->Asl.Next; + } + + Prev->Asl.Next = ExternalOp->Asl.Next; + ExternalOp->Asl.Next = NULL; + ExternalOp->Asl.Parent = Gbl_ExternalsListHead; + + /* Point the External to the next in the list */ + + if (NextOp->Asl.Next) + { + ExternalOp->Asl.Next = NextOp->Asl.Next->Asl.Child; + } + + NextOp = NextOp->Asl.Next; + } + + /* + * Loop again to remove MethodObj Externals for which + * a MethodCall was not found (dead external reference) + */ + Prev = Gbl_ExternalsListHead->Asl.Child; + Next = Prev; + while (Next) + { + ObjType = (ACPI_OBJECT_TYPE) + Next->Asl.Child->Asl.Next->Asl.Value.Integer; + + if (ObjType == ACPI_TYPE_METHOD && + !(Next->Asl.CompileFlags & NODE_VISITED)) + { + if (Next == Prev) + { + Gbl_ExternalsListHead->Asl.Child = Next->Asl.Next; + Next->Asl.Next = NULL; + Prev = Gbl_ExternalsListHead->Asl.Child; + Next = Prev; + continue; + } + else + { + Prev->Asl.Next = Next->Asl.Next; + Next->Asl.Next = NULL; + Next = Prev->Asl.Next; + continue; + } + } + + Prev = Next; + Next = Next->Asl.Next; + } + + /* If list is now empty, don't bother to make If (0) block */ + + if (!Gbl_ExternalsListHead->Asl.Child) + { + return; + } + + /* Convert Gbl_ExternalsListHead parent to If(). */ + + Gbl_ExternalsListHead->Asl.ParseOpcode = PARSEOP_IF; + Gbl_ExternalsListHead->Asl.AmlOpcode = AML_IF_OP; + Gbl_ExternalsListHead->Asl.CompileFlags = NODE_AML_PACKAGE; + UtSetParseOpName (Gbl_ExternalsListHead); + + /* Create a Zero op for the If predicate */ + + PredicateOp = TrAllocateNode (PARSEOP_ZERO); + PredicateOp->Asl.AmlOpcode = AML_ZERO_OP; + + PredicateOp->Asl.Parent = Gbl_ExternalsListHead; + PredicateOp->Asl.Child = NULL; + PredicateOp->Asl.Next = Gbl_ExternalsListHead->Asl.Child; + Gbl_ExternalsListHead->Asl.Child = PredicateOp; + + /* Set line numbers (for listings, etc.) */ + + Gbl_ExternalsListHead->Asl.LineNumber = 0; + Gbl_ExternalsListHead->Asl.LogicalLineNumber = 0; + + PredicateOp->Asl.LineNumber = 0; + PredicateOp->Asl.LogicalLineNumber = 0; + + /* Insert block back in the list */ + + Prev = DefinitionBlockOp->Asl.Child; + Next = Prev; + + /* Find last default arg */ + + for (i = 0; i < 6; i++) + { + Prev = Next; + Next = Prev->Asl.Next; + } + + if (Next) + { + /* Definition Block is not empty */ + + Gbl_ExternalsListHead->Asl.Next = Next; + } + else + { + /* Definition Block is empty. */ + + Gbl_ExternalsListHead->Asl.Next = NULL; + } + + Prev->Asl.Next = Gbl_ExternalsListHead; + Gbl_ExternalsListHead->Asl.Parent = Prev->Asl.Parent; +} diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c index cf726dd..f1c664f 100644 --- a/sys/contrib/dev/acpica/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/compiler/aslfileio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,7 @@ FlFileError ( 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); } @@ -218,6 +219,19 @@ FlWriteFile ( FlFileError (FileId, ASL_MSG_WRITE); AslAbort (); } + + if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag) + { + /* Duplicate the output to the user preprocessor (.i) file */ + + Actual = fwrite ((char *) Buffer, 1, Length, + Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle); + if (Actual != Length) + { + FlFileError (FileId, ASL_MSG_WRITE); + AslAbort (); + } + } } @@ -247,7 +261,6 @@ FlPrintFile ( va_start (Args, Format); - Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args); va_end (Args); @@ -256,6 +269,30 @@ FlPrintFile ( FlFileError (FileId, ASL_MSG_WRITE); AslAbort (); } + + if ((FileId == ASL_FILE_PREPROCESSOR) && + Gbl_PreprocessorOutputFlag) + { + /* + * Duplicate the output to the user preprocessor (.i) file, + * except: no #line directives. + */ + if (!strncmp (Format, "#line", 5)) + { + return; + } + + va_start (Args, Format); + Actual = vfprintf (Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle, + Format, Args); + va_end (Args); + + if (Actual == -1) + { + FlFileError (FileId, ASL_MSG_WRITE); + AslAbort (); + } + } } diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index d8c9ed5..fc2eaaa 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, 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/include/acapps.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfiles") @@ -55,7 +56,6 @@ FlOpenIncludeWithPrefix ( ACPI_PARSE_OBJECT *Op, char *Filename); - #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS FlParseInputPathname ( @@ -84,7 +84,6 @@ FlSetLineNumber ( LineNumber, Gbl_LogicalLineNumber); Gbl_CurrentLineNumber = LineNumber; - Gbl_LogicalLineNumber = LineNumber; } @@ -262,7 +261,8 @@ FlMergePathnames ( /* Build the final merged pathname */ ConcatenatePaths: - Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2); + Pathname = UtStringCacheCalloc ( + strlen (CommonPath) + strlen (FilePathname) + 2); if (LastElement && *CommonPath) { strcpy (Pathname, CommonPath); @@ -303,6 +303,7 @@ FlOpenIncludeWithPrefix ( { FILE *IncludeFile; char *Pathname; + UINT32 OriginalLineNumber; /* Build the full pathname to the file */ @@ -322,13 +323,21 @@ FlOpenIncludeWithPrefix ( return (NULL); } -#ifdef _MUST_HANDLE_COMMENTS /* - * Check entire include file for any # preprocessor directives. + * Check the entire include file for any # preprocessor directives. * This is because there may be some confusion between the #include - * preprocessor directive and the ASL Include statement. + * preprocessor directive and the ASL Include statement. A file included + * by the ASL include cannot contain preprocessor directives because + * the preprocessor has already run by the time the ASL include is + * recognized (by the compiler, not the preprocessor.) + * + * Note: DtGetNextLine strips/ignores comments. + * Save current line number since DtGetNextLine modifies it. */ - while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile)) + Gbl_CurrentLineNumber--; + OriginalLineNumber = Gbl_CurrentLineNumber; + + while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF) { if (Gbl_CurrentLineBuffer[0] == '#') { @@ -336,7 +345,8 @@ FlOpenIncludeWithPrefix ( Op, "use #include instead"); } } -#endif + + Gbl_CurrentLineNumber = OriginalLineNumber; /* Must seek back to the start of the file */ @@ -414,7 +424,8 @@ FlOpenIncludeFile ( * * Construct the file pathname from the global directory name. */ - IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op, Op->Asl.Value.String); + IncludeFile = FlOpenIncludeWithPrefix ( + Gbl_DirectoryPath, Op, Op->Asl.Value.String); if (IncludeFile) { return; @@ -427,7 +438,8 @@ FlOpenIncludeFile ( NextDir = Gbl_IncludeDirList; while (NextDir) { - IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op, Op->Asl.Value.String); + IncludeFile = FlOpenIncludeWithPrefix ( + NextDir->Dir, Op, Op->Asl.Value.String); if (IncludeFile) { return; @@ -538,9 +550,29 @@ FlOpenMiscOutputFiles ( char *Filename; + /* 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); + } + /* All done for disassembler */ - if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE) + if (Gbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE) { return (AE_OK); } @@ -579,8 +611,6 @@ FlOpenMiscOutputFiles ( /* Open the debug file as STDERR, text mode */ - /* TBD: hide this behind a FlReopenFile function */ - Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr); @@ -588,19 +618,39 @@ FlOpenMiscOutputFiles ( if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle) { /* - * A problem with freopen is that on error, - * we no longer have stderr. + * A problem with freopen is that on error, we no longer + * have stderr and cannot emit normal error messages. + * Emit error to stdout, close files, and exit. */ - Gbl_DebugFlag = FALSE; - memcpy (stderr, stdout, sizeof (FILE)); - FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME); - AslAbort (); + fprintf (stdout, + "\nCould not open debug output file: %s\n\n", Filename); + + CmCleanupAndExit (); + exit (1); } AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); } + /* Create/Open a cross-reference output file if asked */ + + if (Gbl_CrossReferenceOutput) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_XREF); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + FlOpenFile (ASL_FILE_XREF_OUTPUT, Filename, "w+t"); + + AslCompilerSignon (ASL_FILE_XREF_OUTPUT); + AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT); + } + /* Create/Open a listing output file if asked */ if (Gbl_ListingFlag) @@ -621,7 +671,7 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT); } - /* Create the preprocessor output file if preprocessor enabled */ + /* Create the preprocessor output temp file if preprocessor enabled */ if (Gbl_PreprocessFlag) { @@ -636,6 +686,23 @@ FlOpenMiscOutputFiles ( FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t"); } + /* + * Create the "user" preprocessor output file if -li flag set. + * Note, this file contains no embedded #line directives. + */ + if (Gbl_PreprocessorOutputFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t"); + } + /* All done for data table compiler */ if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA) @@ -787,26 +854,6 @@ 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); } diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 26b786d..78a1a60 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,7 +100,8 @@ TrInstallReducedConstant ( * * RETURN: Status * - * DESCRIPTION: Reduce an Op and its subtree to a constant if possible + * DESCRIPTION: Reduce an Op and its subtree to a constant if possible. + * Called during ascent of the parse tree. * ******************************************************************************/ @@ -192,9 +193,7 @@ OpcAmlConstantWalk ( OpcUpdateIntegerNode (Op, 0); } - /* Abort the walk of this subtree, we are done with it */ - - return (AE_CTRL_DEPTH); + return (AE_OK); } @@ -206,7 +205,8 @@ OpcAmlConstantWalk ( * * RETURN: Status * - * DESCRIPTION: Check one Op for a type 3/4/5 AML opcode + * DESCRIPTION: Check one Op for a reducible type 3/4/5 AML opcode. + * This is performed via an upward walk of the parse subtree. * ******************************************************************************/ @@ -218,6 +218,8 @@ OpcAmlCheckForConstant ( { ACPI_WALK_STATE *WalkState = Context; ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *NextOp; + const ACPI_OPCODE_INFO *OpInfo; WalkState->Op = Op; @@ -228,19 +230,6 @@ OpcAmlCheckForConstant ( Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName); /* - * TBD: Ignore buffer constants for now. The problem is that these - * constants have been transformed into RAW_DATA at this point, from - * the parse tree transform process which currently happens before - * the constant folding process. We may need to defer this transform - * for buffer until after the constant folding. - */ - if (WalkState->Opcode == AML_BUFFER_OP) - { - Status = AE_TYPE; - goto CleanupAndExit; - } - - /* * These opcodes do not appear in the OpcodeInfo table, but * they represent constants, so abort the constant walk now. */ @@ -254,11 +243,95 @@ OpcAmlCheckForConstant ( goto CleanupAndExit; } + /* + * Search upwards for a possible Name() operator. This is done + * because a type 3/4/5 opcode within a Name() expression + * MUST be reduced to a simple constant. + */ + NextOp = Op->Asl.Parent; + while (NextOp) + { + /* Finished if we find a Name() opcode */ + + if (NextOp->Asl.AmlOpcode == AML_NAME_OP) + { + break; + } + + /* + * Any "deferred" opcodes contain one or more TermArg parameters, + * and thus are not required to be folded to constants at compile + * time. This affects things like Buffer() and Package() objects. + * We just ignore them here. However, any sub-expressions can and + * will still be typechecked. Note: These are called the + * "deferred" opcodes in the AML interpreter. + */ + OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode); + if (OpInfo->Flags & AML_DEFER) + { + NextOp = NULL; + break; + } + + NextOp = NextOp->Asl.Parent; + } + /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */ if (!(WalkState->OpInfo->Flags & AML_CONSTANT)) { - /* Not 3/4/5 opcode, but maybe can convert to STORE */ + /* + * From the ACPI specification: + * + * "The Type 3/4/5 opcodes return a value and can be used in an + * expression that evaluates to a constant. These opcodes may be + * evaluated at ASL compile-time. To ensure that these opcodes + * will evaluate to a constant, the following rules apply: The + * term cannot have a destination (target) operand, and must have + * either a Type3Opcode, Type4Opcode, Type5Opcode, ConstExprTerm, + * Integer, BufferTerm, Package, or String for all arguments." + */ + + /* + * The value (second) operand for the Name() operator MUST + * reduce to a single constant, as per the ACPI specification + * (the operand is a DataObject). This also implies that there + * can be no target operand. Name() is the only ASL operator + * with a "DataObject" as an operand and is thus special- + * cased here. + */ + if (NextOp) /* Inspect a Name() operator */ + { + /* Error if there is a target operand */ + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, NULL); + Status = AE_TYPE; + } + + /* Error if expression cannot be reduced (folded) */ + + if (!(NextOp->Asl.CompileFlags & NODE_COULD_NOT_REDUCE)) + { + /* Ensure only one error message per statement */ + + NextOp->Asl.CompileFlags |= NODE_COULD_NOT_REDUCE; + DbgPrint (ASL_PARSE_OUTPUT, + "**** Could not reduce operands for NAME opcode ****\n"); + + AslError (ASL_ERROR, ASL_MSG_CONSTANT_REQUIRED, Op, + "Constant is required for Name operator"); + Status = AE_TYPE; + } + } + + if (ACPI_FAILURE (Status)) + { + goto CleanupAndExit; + } + + /* This is not a 3/4/5 opcode, but maybe can convert to STORE */ if (Op->Asl.CompileFlags & NODE_IS_TARGET) { @@ -270,13 +343,35 @@ OpcAmlCheckForConstant ( /* Expression cannot be reduced */ DbgPrint (ASL_PARSE_OUTPUT, - "**** Not a Type 3/4/5 opcode (%s) ****", + "**** Not a Type 3/4/5 opcode or cannot reduce/fold (%s) ****\n", Op->Asl.ParseOpName); Status = AE_TYPE; goto CleanupAndExit; } + /* + * TBD: Ignore buffer constants for now. The problem is that these + * constants have been transformed into RAW_DATA at this point, from + * the parse tree transform process which currently happens before + * the constant folding process. We may need to defer this transform + * for buffer until after the constant folding. + */ + if (WalkState->Opcode == AML_BUFFER_OP) + { + DbgPrint (ASL_PARSE_OUTPUT, + "\nBuffer constant reduction is not supported yet\n"); + + if (NextOp) /* Found a Name() operator, error */ + { + AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, Op, + "Buffer expression cannot be reduced"); + } + + Status = AE_TYPE; + goto CleanupAndExit; + } + /* Debug output */ DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345"); @@ -292,6 +387,7 @@ OpcAmlCheckForConstant ( DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET"); } } + if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) { DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG"); @@ -380,10 +476,12 @@ TrSimpleConstantReduction ( return (Status); } + /* Disconnect any existing children, install new constant */ + + Op->Asl.Child = NULL; TrInstallReducedConstant (Op, ObjDesc); UtSetParseOpName (Op); - Op->Asl.Child = NULL; return (AE_OK); } @@ -419,9 +517,6 @@ TrTransformToStoreOp ( ACPI_STATUS Status; - DbgPrint (ASL_PARSE_OUTPUT, - "Reduction/Transform to StoreOp: Store(Constant, Target)\n"); - /* Extract the operands */ Child1 = Op->Asl.Child; @@ -443,6 +538,10 @@ TrTransformToStoreOp ( } } + DbgPrint (ASL_PARSE_OUTPUT, + "Reduction/Transform to StoreOp: Store(%s, %s)\n", + Child1->Asl.ParseOpName, Child2->Asl.ParseOpName); + /* * Create a NULL (zero) target so that we can use the * interpreter to evaluate the expression. @@ -494,6 +593,10 @@ TrTransformToStoreOp ( goto EvalError; } + /* Truncate any subtree expressions, they have been evaluated */ + + Child1->Asl.Child = NULL; + /* Folded constant is in ObjDesc, store into Child1 */ TrInstallReducedConstant (Child1, ObjDesc); @@ -505,11 +608,6 @@ TrTransformToStoreOp ( UtSetParseOpName (Op); Op->Common.Parent = OriginalParent; - /* Truncate any subtree expressions, they have been evaluated */ - - Child1->Asl.Child = NULL; - Child2->Asl.Child = NULL; - /* First child is the folded constant */ /* Second child will be the target */ @@ -547,7 +645,8 @@ TrInstallReducedConstant ( ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc) { - ACPI_PARSE_OBJECT *RootOp; + ACPI_PARSE_OBJECT *LengthOp; + ACPI_PARSE_OBJECT *DataOp; TotalFolds++; @@ -574,17 +673,22 @@ TrInstallReducedConstant ( Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; Op->Common.AmlOpcode = AML_STRING_OP; - Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1; + Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1; Op->Common.Value.String = ObjDesc->String.Pointer; DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (STRING) %s\n\n", Op->Common.Value.String); - break; case ACPI_TYPE_BUFFER: - + /* + * Create a new parse subtree of the form: + * + * BUFFER (Buffer AML opcode) + * INTEGER (Buffer length in bytes) + * RAW_DATA (Buffer byte data) + */ Op->Asl.ParseOpcode = PARSEOP_BUFFER; Op->Common.AmlOpcode = AML_BUFFER_OP; Op->Asl.CompileFlags = NODE_AML_PACKAGE; @@ -592,28 +696,24 @@ TrInstallReducedConstant ( /* Child node is the buffer length */ - RootOp = TrAllocateNode (PARSEOP_INTEGER); + LengthOp = TrAllocateNode (PARSEOP_INTEGER); - RootOp->Asl.AmlOpcode = AML_DWORD_OP; - RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length; - RootOp->Asl.Parent = Op; + LengthOp->Asl.AmlOpcode = AML_DWORD_OP; + LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length; + LengthOp->Asl.Parent = Op; + (void) OpcSetOptimalIntegerSize (LengthOp); - (void) OpcSetOptimalIntegerSize (RootOp); - - Op->Asl.Child = RootOp; - Op = RootOp; - UtSetParseOpName (Op); + Op->Asl.Child = LengthOp; - /* Peer to the child is the raw buffer data */ + /* Next child is the raw buffer data */ - RootOp = TrAllocateNode (PARSEOP_RAW_DATA); - RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - RootOp->Asl.AmlLength = ObjDesc->Buffer.Length; - RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; - RootOp->Asl.Parent = Op->Asl.Parent; + DataOp = TrAllocateNode (PARSEOP_RAW_DATA); + DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + DataOp->Asl.AmlLength = ObjDesc->Buffer.Length; + DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; + DataOp->Asl.Parent = Op; - Op->Asl.Next = RootOp; - Op = RootOp; + LengthOp->Asl.Next = DataOp; DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (BUFFER) length %X\n\n", diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index c61b8ff..6f35c24 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,6 +73,7 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "Binary Output:", "AML Output"}, {NULL, NULL, "Source Output:", "Source Output"}, {NULL, NULL, "Preprocessor: ", "Preprocessor Output"}, + {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"}, {NULL, NULL, "Listing File: ", "Listing Output"}, {NULL, NULL, "Hex Dump: ", "Hex Table Output"}, {NULL, NULL, "Namespace: ", "Namespace Output"}, @@ -82,7 +83,8 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, {NULL, NULL, "C Include: ", "C Header Output"}, {NULL, NULL, "Offset Table: ", "C Offset Table Output"}, - {NULL, NULL, "Device Map: ", "Device Map Output"} + {NULL, NULL, "Device Map: ", "Device Map Output"}, + {NULL, NULL, "Cross Ref: ", "Cross-reference Output"} }; #else @@ -123,10 +125,10 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NUL ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0); -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 UINT32 ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_SyntaxError, 0); /* Exception reporting */ @@ -146,7 +148,9 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, 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_KeepPreprocessorTempFile, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CrossReferenceOutput, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE); @@ -175,6 +179,9 @@ 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); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTypechecking, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_EnableReferenceTypechecking, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoExternals, TRUE); #define HEX_OUTPUT_NONE 0 @@ -193,6 +200,7 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL); ASL_EXTERN char *Gbl_CurrentInputFilename; ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_PreviousIncludeFilename, NULL); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE); @@ -235,14 +243,15 @@ ASL_EXTERN ACPI_SERIAL_INFO ASL_INIT_GLOBAL (*Gbl_SerialList, NULL); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_TempCount, 0); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseTreeRoot, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ExternalsListHead, 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 *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); -ASL_EXTERN char *Gbl_TemplateSignature; + +ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); @@ -264,7 +273,7 @@ ASL_EXTERN ACPI_TABLE_HEADER TableHeader; /* Event timing */ -#define ASL_NUM_EVENTS 20 +#define ASL_NUM_EVENTS 24 ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[ASL_NUM_EVENTS]; ASL_EXTERN UINT8 AslGbl_NextEvent; ASL_EXTERN UINT8 AslGbl_NamespaceEvent; diff --git a/sys/contrib/dev/acpica/compiler/aslhex.c b/sys/contrib/dev/acpica/compiler/aslhex.c index f24de1c..fd80925 100644 --- a/sys/contrib/dev/acpica/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/compiler/aslhex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,6 @@ * This module emits ASCII hex output files in either C, ASM, or ASL format */ - /* Local prototypes */ static void @@ -223,6 +222,7 @@ HxDoHexOutputC ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", HEX_TABLE_LINE_SIZE - LineLength + 1, " "); @@ -310,6 +310,7 @@ HxDoHexOutputAsl ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", HEX_TABLE_LINE_SIZE - LineLength + 1, " "); @@ -393,6 +394,7 @@ HxDoHexOutputAsm ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); Offset += LineLength; diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index 618b63f..2c57794 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,10 +132,11 @@ LnPackageLengthWalk ( if ((Op->Asl.Parent) && (Op->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) { - Op->Asl.Parent->Asl.AmlSubtreeLength += (Op->Asl.AmlLength + - Op->Asl.AmlOpcodeLength + - Op->Asl.AmlPkgLenBytes + - Op->Asl.AmlSubtreeLength); + Op->Asl.Parent->Asl.AmlSubtreeLength += ( + Op->Asl.AmlLength + + Op->Asl.AmlOpcodeLength + + Op->Asl.AmlPkgLenBytes + + Op->Asl.AmlSubtreeLength); } return (AE_OK); } @@ -229,7 +230,7 @@ CgGenerateAmlOpcodeLength ( if (Op->Asl.CompileFlags & NODE_AML_PACKAGE) { Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount ( - Op, Op->Asl.AmlSubtreeLength); + Op, Op->Asl.AmlSubtreeLength); } /* Data opcode lengths are easy */ @@ -332,10 +333,9 @@ CgGenerateAmlLengths ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: - Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + - Op->Asl.AmlSubtreeLength; + Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; break; case PARSEOP_NAMESEG: @@ -365,7 +365,6 @@ CgGenerateAmlLengths ( Op->Asl.ExternalName = Op->Asl.Value.String; Op->Asl.Value.String = Buffer; Op->Asl.CompileFlags |= NODE_NAME_INTERNALIZED; - Op->Asl.AmlLength = strlen (Buffer); /* @@ -391,7 +390,7 @@ CgGenerateAmlLengths ( Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, - (UINT32) Op->Asl.Value.Integer); + (UINT32) Op->Asl.Value.Integer); break; case PARSEOP_RAW_DATA: @@ -400,7 +399,6 @@ CgGenerateAmlLengths ( break; case PARSEOP_DEFAULT_ARG: - case PARSEOP_EXTERNAL: case PARSEOP_INCLUDE: case PARSEOP_INCLUDE_END: @@ -408,6 +406,14 @@ CgGenerateAmlLengths ( break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == TRUE) + { + CgGenerateAmlOpcodeLength (Op); + } + break; + default: CgGenerateAmlOpcodeLength (Op); diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index a8fe2de..45ab1e2 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -163,16 +163,16 @@ LsGenerateListing ( LsDoOffsetTableHeader (FileId); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); LsDoOffsetTableFooter (FileId); return; } /* Process all parse nodes */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); /* Final processing */ @@ -212,6 +212,12 @@ LsAmlListingWalk ( return (AE_OK); } + if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || + (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) + { + return (AE_OK); + } + /* Write the hex bytes to the listing file(s) (if requested) */ for (i = 0; i < Op->Asl.FinalAmlLength; i++) @@ -221,6 +227,7 @@ LsAmlListingWalk ( FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); AslAbort (); } + LsWriteListingHexBytes (&FileByte, 1, FileId); } @@ -251,8 +258,12 @@ LsDumpParseTree ( } DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, LsTreeWriteWalk, NULL, NULL); + + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1); } @@ -263,15 +274,69 @@ LsTreeWriteWalk ( void *Context) { - /* Debug output */ + /* Dump ParseOp name and possible value */ + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + case PARSEOP_STRING_LITERAL: + + UtDumpStringOp (Op, Level); + break; + + case PARSEOP_BYTECONST: + + UtDumpIntegerOp (Op, Level, 2); + break; + + case PARSEOP_WORDCONST: + case PARSEOP_PACKAGE_LENGTH: + + UtDumpIntegerOp (Op, Level, 4); + break; + + case PARSEOP_DWORDCONST: + case PARSEOP_EISAID: + + UtDumpIntegerOp (Op, Level, 8); + break; + + case PARSEOP_QWORDCONST: + case PARSEOP_INTEGER: + case PARSEOP_ONE: + case PARSEOP_ZERO: + case PARSEOP_ONES: + + UtDumpIntegerOp (Op, Level, 16); + break; + + case PARSEOP_INCLUDE: + + DbgPrint (ASL_TREE_OUTPUT, + "Open: %s\n", Op->Asl.Value.String); + return (AE_OK); + + case PARSEOP_INCLUDE_END: + + DbgPrint (ASL_TREE_OUTPUT, + "Close: %s\n", Op->Asl.Filename); + return (AE_OK); + + default: + + UtDumpBasicOp (Op, Level); + break; + } - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + /* Dump the remaining data */ - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG1, + Op->Asl.ParseOpcode, Op->Asl.CompileFlags, + Op->Asl.LineNumber, Op->Asl.EndLine, + Op->Asl.LogicalLineNumber, Op->Asl.EndLogicalLine); - DbgPrint (ASL_TREE_OUTPUT, " (%.4X) Flags %8.8X", - Op->Asl.ParseOpcode, Op->Asl.CompileFlags); TrPrintNodeCompileFlags (Op->Asl.CompileFlags); DbgPrint (ASL_TREE_OUTPUT, "\n"); return (AE_OK); @@ -316,7 +381,7 @@ LsWriteNodeToListing ( { switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: case PARSEOP_METHODCALL: case PARSEOP_INCLUDE: case PARSEOP_INCLUDE_END: @@ -362,36 +427,49 @@ LsWriteNodeToListing ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: + + /* Always start a definition block at AML offset zero */ + Gbl_CurrentAmlOffset = 0; LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId); /* Use the table Signature and TableId to build a unique name */ - if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) + switch (FileId) { + case ASL_FILE_ASM_SOURCE_OUTPUT: + FlPrintFile (FileId, "%s_%s_Header \\\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + FlPrintFile (FileId, " unsigned char %s_%s_Header [] =\n {\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_ASM_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extrn %s_%s_Header : byte\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_C_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extern unsigned char %s_%s_Header [];\n", Gbl_TableSignature, Gbl_TableId); + break; + + default: + break; } + return; @@ -411,7 +489,7 @@ LsWriteNodeToListing ( /* Create a new listing node and push it */ - LsPushNode (Op->Asl.Child->Asl.Value.String); + LsPushNode (Op->Asl.Value.String); return; @@ -540,31 +618,41 @@ LsWriteNodeToListing ( /* Create the appropriate symbol in the output file */ - if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) + switch (FileId) { + case ASL_FILE_ASM_SOURCE_OUTPUT: + FlPrintFile (FileId, "%s_%s_%s \\\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + FlPrintFile (FileId, " unsigned char %s_%s_%s [] =\n {\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_ASM_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extrn %s_%s_%s : byte\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_C_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extern unsigned char %s_%s_%s [];\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); + break; + + default: + break; } } + ACPI_FREE (Pathname); } break; diff --git a/sys/contrib/dev/acpica/compiler/asllistsup.c b/sys/contrib/dev/acpica/compiler/asllistsup.c index 694fbc8..754f8c9 100644 --- a/sys/contrib/dev/acpica/compiler/asllistsup.c +++ b/sys/contrib/dev/acpica/compiler/asllistsup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,6 +88,7 @@ LsDumpAscii ( FlPrintFile (FileId, "."); } } + FlPrintFile (FileId, "\""); } @@ -185,7 +186,6 @@ LsCheckException ( (LineNumber >= Gbl_NextError->LogicalLineNumber)) { AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); - Gbl_NextError = Gbl_NextError->Next; } @@ -576,6 +576,7 @@ LsFlushListingBuffer ( { FlPrintFile (FileId, ","); } + FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); } diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index c8ae3ad..f14e01d 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -104,8 +104,6 @@ LdLoadNamespace ( ACPI_WALK_STATE *WalkState; - DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n"); - /* Create a new walk state */ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); @@ -196,12 +194,11 @@ LdLoadFieldElements ( default: Status = AcpiNsLookup (WalkState->ScopeInfo, - Child->Asl.Value.String, - ACPI_TYPE_LOCAL_REGION_FIELD, - ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND, - NULL, &Node); + Child->Asl.Value.String, + ACPI_TYPE_LOCAL_REGION_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, NULL, &Node); if (ACPI_FAILURE (Status)) { if (Status != AE_ALREADY_EXISTS) @@ -266,9 +263,9 @@ LdLoadResourceElements ( * This opens a scope, so later field names are guaranteed to be new/unique. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, - ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, - WalkState, &Node); + ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, + WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -296,11 +293,11 @@ LdLoadResourceElements ( if (InitializerOp->Asl.ExternalName) { Status = AcpiNsLookup (WalkState->ScopeInfo, - InitializerOp->Asl.ExternalName, - ACPI_TYPE_LOCAL_RESOURCE_FIELD, - ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &Node); + InitializerOp->Asl.ExternalName, + ACPI_TYPE_LOCAL_RESOURCE_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { return (Status); @@ -344,6 +341,7 @@ LdNamespace1Begin ( { ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *MethodOp; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; @@ -500,8 +498,8 @@ LdNamespace1Begin ( * handle this case. Perhaps someday this case can go away. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -509,9 +507,9 @@ LdNamespace1Begin ( /* The name was not found, go ahead and create it */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, - ACPI_TYPE_LOCAL_SCOPE, - ACPI_IMODE_LOAD_PASS1, Flags, - WalkState, &(Node)); + ACPI_TYPE_LOCAL_SCOPE, + ACPI_IMODE_LOAD_PASS1, Flags, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -534,6 +532,35 @@ LdNamespace1Begin ( return_ACPI_STATUS (Status); } + else /* Status AE_OK */ + { + /* + * Do not allow references to external scopes from the DSDT. + * This is because the DSDT is always loaded first, and the + * external reference cannot be resolved -- causing a runtime + * error because Scope() must be resolved immediately. + * 10/2015. + */ + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (ACPI_COMPARE_NAME (Gbl_TableSignature, "DSDT"))) + { + /* However, allowed if the reference is within a method */ + + MethodOp = Op->Asl.Parent; + while (MethodOp && + (MethodOp->Asl.ParseOpcode != PARSEOP_METHOD)) + { + MethodOp = MethodOp->Asl.Parent; + } + + if (!MethodOp) + { + /* Not in a control method, error */ + + AslError (ASL_ERROR, ASL_MSG_CROSS_TABLE_SCOPE, Op, NULL); + } + } + } /* We found a node with this name, now check the type */ @@ -569,7 +596,7 @@ LdNamespace1Begin ( Node->Type = ACPI_TYPE_LOCAL_SCOPE; Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, - WalkState); + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -591,7 +618,7 @@ LdNamespace1Begin ( */ Node->Type = ACPI_TYPE_LOCAL_SCOPE; Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, - WalkState); + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -611,7 +638,7 @@ LdNamespace1Begin ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", - Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); + Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); /* The name must not already exist */ @@ -624,7 +651,7 @@ LdNamespace1Begin ( * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -658,8 +685,38 @@ LdNamespace1Begin ( return_ACPI_STATUS (Status); } } + + Status = AE_OK; + } + else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * Allow externals in same scope as the definition of the + * actual object. Similar to C. Allows multiple definition + * blocks that refer to each other in the same file. + */ Status = AE_OK; } + else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + (ObjectType == ACPI_TYPE_ANY)) + { + /* Allow update of externals of unknown type. */ + + if (AcpiNsOpensScope (ActualObjectType)) + { + Node->Type = (UINT8) ActualObjectType; + Status = AE_OK; + } + else + { + sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, + AcpiUtGetTypeName (Node->Type)); + AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); + return_ACPI_STATUS (AE_OK); + } + } else { /* Valid error, object already exists */ @@ -818,8 +875,8 @@ LdNamespace2Begin ( /* Get the NS node associated with the target. It must exist. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &TargetNode); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &TargetNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -832,9 +889,9 @@ LdNamespace2Begin ( * This prevents more errors later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, - ACPI_TYPE_ANY, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, - WalkState, &(Node)); + ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, + WalkState, &(Node)); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index a527a38..3e216cc 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,8 +119,73 @@ LkIsObjectUsed ( { ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_NAMESPACE_NODE *Next; + ASL_METHOD_LOCAL *MethodLocals; + ASL_METHOD_LOCAL *MethodArgs; + UINT32 i; + if (Node->Type == ACPI_TYPE_METHOD) + { + if (!Node->Op || !Node->MethodLocals) + { + return (AE_OK); + } + + MethodLocals = (ASL_METHOD_LOCAL *) Node->MethodLocals; + MethodArgs = (ASL_METHOD_LOCAL *) Node->MethodArgs; + + /* + * Analysis of LocalX variables + */ + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + /* Warn for Locals that are set but never referenced */ + + if ((MethodLocals[i].Flags & ASL_LOCAL_INITIALIZED) && + (!(MethodLocals[i].Flags & ASL_LOCAL_REFERENCED))) + { + sprintf (MsgBuffer, "Local%u", i); + AslError (ASL_WARNING, ASL_MSG_LOCAL_NOT_USED, + MethodLocals[i].Op, MsgBuffer); + } + } + + /* + * Analysis of ArgX variables (standard method arguments, + * and remaining unused ArgX can also be used as locals) + */ + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + if (MethodArgs[i].Flags & ASL_ARG_IS_LOCAL) + { + /* Warn if ArgX is being used as a local, but not referenced */ + + if ((MethodArgs[i].Flags & ASL_ARG_INITIALIZED) && + (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED))) + { + sprintf (MsgBuffer, "Arg%u", i); + AslError (ASL_WARNING, ASL_MSG_ARG_AS_LOCAL_NOT_USED, + MethodArgs[i].Op, MsgBuffer); + } + } + else + { + /* + * Remark if a normal method ArgX is not referenced. + * We ignore the predefined methods since often, not + * all arguments are needed or used. + */ + if ((Node->Name.Ascii[0] != '_') && + (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED))) + { + sprintf (MsgBuffer, "Arg%u", i); + AslError (ASL_REMARK, ASL_MSG_ARG_NOT_USED, + MethodArgs[i].Op, MsgBuffer); + } + } + } + } + /* Referenced flag is set during the namespace xref */ if (Node->Flags & ANOBJ_IS_REFERENCED) @@ -142,6 +207,7 @@ LkIsObjectUsed ( case ACPI_TYPE_POWER: case ACPI_TYPE_THERMAL: case ACPI_TYPE_LOCAL_RESOURCE: + case ACPI_TYPE_LOCAL_RESOURCE_FIELD: /* Names assigned to descriptor elements */ return (AE_OK); @@ -162,8 +228,8 @@ LkIsObjectUsed ( * 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); + sprintf (MsgBuffer, "Name [%4.4s] is within a method [%4.4s]", + Node->Name.Ascii, Next->Name.Ascii); AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), MsgBuffer); return (AE_OK); diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 99745ad..25c7b9a 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,36 +73,6 @@ 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 */ -} - /******************************************************************************* * @@ -127,7 +97,8 @@ Usage ( 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 ("-T <sig list>|ALL", "Create ACPI table template/example files"); + ACPI_OPTION ("-T <count>", "Emit DSDT and <count> SSDTs to same file"); ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); ACPI_OPTION ("-vo", "Enable optimization comments"); @@ -160,6 +131,7 @@ Usage ( ACPI_OPTION ("-of", "Disable constant folding"); ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones"); ACPI_OPTION ("-on", "Disable named reference string optimization"); + ACPI_OPTION ("-ot", "Disable typechecking"); ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking"); ACPI_OPTION ("-in", "Ignore NoOp operators"); ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)"); @@ -175,6 +147,7 @@ Usage ( 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)"); + ACPI_OPTION ("-lx", "Create cross-reference file (*.xrf)"); printf ("\nData Table Compiler:\n"); ACPI_OPTION ("-G", "Compile custom table that contains generic operators"); @@ -192,6 +165,7 @@ Usage ( ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file"); ACPI_OPTION ("-in", "Ignore NoOp opcodes"); + ACPI_OPTION ("-l", "Disassemble to mixed ASL and AML code"); ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); printf ("\nDebug Options:\n"); @@ -202,7 +176,7 @@ Usage ( 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"); - ACPI_OPTION ("-ot", "Display compile times and statistics"); + ACPI_OPTION ("-oc", "Display compile times and statistics"); ACPI_OPTION ("-x <level>", "Set debug level for trace output"); ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); } @@ -261,7 +235,7 @@ AslSignalHandler ( /* Close all open files */ - Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ + Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .pre file is same as source file */ for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) { @@ -298,6 +272,14 @@ AslInitialize ( UINT32 i; + AcpiGbl_DmOpt_Verbose = FALSE; + + /* Default integer width is 64 bits */ + + AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerNybbleWidth = 16; + AcpiGbl_IntegerByteWidth = 8; + for (i = 0; i < ASL_NUM_FILES; i++) { Gbl_Files[i].Handle = NULL; @@ -341,7 +323,7 @@ main ( * be little-endian, and support for big-endian machines needs to * be implemented. */ - if (AcpiIsBigEndianMachine ()) + if (UtIsBigEndianMachine ()) { fprintf (stderr, "iASL is not currently supported on big-endian machines.\n"); diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index 90252cb..e213336 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,6 +123,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = { /*! [Begin] no source code translation (keep the table structure) */ + /* AML Opcode Value Flags Btype */ /* ACCESSAS */ OP_TABLE_ENTRY (AML_INT_ACCESSFIELD_OP, 0, 0, 0), /* ACCESSATTRIB_BLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BLOCK, 0, 0), @@ -237,11 +238,12 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* GPIOINT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* GPIOIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* I2CSERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* I2CSERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, NODE_AML_PACKAGE, 0), /* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* INCLUDE_END */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* INCREMENT */ OP_TABLE_ENTRY (AML_INCREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER), -/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE), +/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT), /* INDEXFIELD */ OP_TABLE_ENTRY (AML_INDEX_FIELD_OP, 0, NODE_AML_PACKAGE, 0), /* INTEGER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, ACPI_BTYPE_INTEGER), /* INTERRUPT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), @@ -312,23 +314,23 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0), -/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), -/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER_FIELD, 0, 0), -/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER, 0, 0), -/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DDB_HANDLE, 0, 0), -/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DEVICE, 0, 0), -/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_EVENT, 0, 0), -/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_FIELD_UNIT, 0, 0), -/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_INTEGER, 0, 0), -/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_METHOD, 0, 0), -/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_MUTEX, 0, 0), -/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_REGION, 0, 0), -/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PACKAGE, 0, 0), -/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_POWER, 0, 0), -/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PROCESSOR, 0, 0), -/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_STRING, 0, 0), -/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_THERMAL, 0, 0), -/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_ANY, 0, 0), +/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_OBJECT_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), +/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER_FIELD, 0, 0), +/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER, 0, 0), +/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DDB_HANDLE, 0, 0), +/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DEVICE, 0, 0), +/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_EVENT, 0, 0), +/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_FIELD_UNIT, 0, 0), +/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_INTEGER, 0, 0), +/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_METHOD, 0, 0), +/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_MUTEX, 0, 0), +/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_REGION, 0, 0), +/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PACKAGE, 0, 0), +/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_POWER, 0, 0), +/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PROCESSOR, 0, 0), +/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_STRING, 0, 0), +/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_THERMAL, 0, 0), +/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_ANY, 0, 0), /* OFFSET */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0), /* ONE */ OP_TABLE_ENTRY (AML_ONE_OP, 0, 0, ACPI_BTYPE_INTEGER), /* ONES */ OP_TABLE_ENTRY (AML_ONES_OP, 0, 0, ACPI_BTYPE_INTEGER), @@ -357,7 +359,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* RAW_DATA */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), -/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE), +/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT), /* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_CMOS, 0, 0), /* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_EC, 0, 0), /* REGIONSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_FIXED_HARDWARE, 0, 0), @@ -394,6 +396,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* SLAVEMODE_DEVICEINIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* SLEEP */ OP_TABLE_ENTRY (AML_SLEEP_OP, 0, 0, 0), /* SPISERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* SPISERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* STALL */ OP_TABLE_ENTRY (AML_STALL_OP, 0, 0, 0), /* STARTDEPENDENTFN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* STARTDEPENDENTFN_NOPRI */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), @@ -419,6 +422,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* TYPE_TRANSLATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* UART_SERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* UART_SERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* UNICODE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, 0), /* UNLOAD */ OP_TABLE_ENTRY (AML_UNLOAD_OP, 0, 0, 0), /* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0), @@ -478,6 +482,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* 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), +/* ASLCODE */ OP_TABLE_ENTRY (0, 0, 0, 0) /*! [End] no source code translation !*/ }; diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c index 87ad28a..8aa66b7 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapenter.c +++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -239,7 +239,7 @@ MpCreateGpioInfo ( /* Sort on source DeviceName first */ while (NextGpio && - (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0)) + (strcmp (DeviceName, NextGpio->DeviceName) > 0)) { PrevGpio = NextGpio; NextGpio = NextGpio->Next; @@ -248,8 +248,8 @@ MpCreateGpioInfo ( /* Now sort on the PinNumber */ while (NextGpio && - (NextGpio->PinNumber < PinNumber) && - !ACPI_STRCMP (DeviceName, NextGpio->DeviceName)) + (NextGpio->PinNumber < PinNumber) && + !strcmp (DeviceName, NextGpio->DeviceName)) { PrevGpio = NextGpio; NextGpio = NextGpio->Next; @@ -316,7 +316,7 @@ MpCreateSerialInfo ( /* Sort on source DeviceName */ while (NextSerial && - (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0)) + (strcmp (DeviceName, NextSerial->DeviceName) > 0)) { PrevSerial = NextSerial; NextSerial = NextSerial->Next; @@ -326,7 +326,7 @@ MpCreateSerialInfo ( while (NextSerial && (NextSerial->Address < Address) && - !ACPI_STRCMP (DeviceName, NextSerial->DeviceName)) + !strcmp (DeviceName, NextSerial->DeviceName)) { PrevSerial = NextSerial; NextSerial = NextSerial->Next; diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c index 622b1bd..c8cd545 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapoutput.c +++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -207,7 +207,7 @@ MpEmitGpioInfo ( /* Print header info for the controller itself */ if (!PrevDeviceName || - ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + strcmp (PrevDeviceName, Info->DeviceName)) { FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nGPIO Controller: %-8s %-28s", @@ -360,7 +360,7 @@ MpEmitSerialInfo ( /* Print header info for the controller itself */ if (!PrevDeviceName || - ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + strcmp (PrevDeviceName, Info->DeviceName)) { FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ", Type); @@ -453,7 +453,7 @@ MpEmitDeviceTree ( /* Walk the namespace from the root */ (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); + ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); } @@ -533,7 +533,7 @@ MpXrefDevices ( /* Walk the entire parse tree */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, MpNamespaceXrefBegin, NULL, Info); if (!Info->References) diff --git a/sys/contrib/dev/acpica/compiler/aslmaputils.c b/sys/contrib/dev/acpica/compiler/aslmaputils.c index 7b2e611..a9d5136 100644 --- a/sys/contrib/dev/acpica/compiler/aslmaputils.c +++ b/sys/contrib/dev/acpica/compiler/aslmaputils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c index c57fd2d..1545aba 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.c +++ b/sys/contrib/dev/acpica/compiler/aslmessages.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,7 +130,7 @@ const char *AslCompilerMsgs [] = /* 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_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT or SSDT 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)", @@ -224,7 +224,7 @@ const char *AslCompilerMsgs [] = /* 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_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT or SSDT version < 2)", /* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", /* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", /* ASL_MSG_UNSUPPORTED */ "Unsupported feature", @@ -235,7 +235,12 @@ const char *AslCompilerMsgs [] = /* 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" +/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods", +/* ASL_MSG_LOCAL_NOT_USED */ "Method Local is set but never used", +/* ASL_MSG_ARG_AS_LOCAL_NOT_USED */ "Method Argument (as a local) is set but never used", +/* ASL_MSG_ARG_NOT_USED */ "Method Argument is never used", +/* ASL_MSG_CONSTANT_REQUIRED */ "Non-reducible expression", +/* ASL_MSG_CROSS_TABLE_SCOPE */ "Illegal open scope on external object from within DSDT" }; /* Table compiler */ diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h index 9837d54..0ee063f 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/compiler/aslmessages.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,6 +238,11 @@ typedef enum ASL_MSG_MISSING_DEPENDENCY, ASL_MSG_ILLEGAL_FORWARD_REF, ASL_MSG_ILLEGAL_METHOD_REF, + ASL_MSG_LOCAL_NOT_USED, + ASL_MSG_ARG_AS_LOCAL_NOT_USED, + ASL_MSG_ARG_NOT_USED, + ASL_MSG_CONSTANT_REQUIRED, + ASL_MSG_CROSS_TABLE_SCOPE, /* These messages are used by the Data Table compiler only */ diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c index fa9216e..b16982a 100644 --- a/sys/contrib/dev/acpica/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/compiler/aslmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ /* Local prototypes */ -void +static void MtCheckNamedObjectInMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo); @@ -93,6 +93,13 @@ MtMethodAnalysisWalkBegin ( UINT8 ActualArgs = 0; + /* Build cross-reference output file if requested */ + + if (Gbl_CrossReferenceOutput) + { + OtXrefWalkPart1 (Op, Level, MethodInfo); + } + switch (Op->Asl.ParseOpcode) { case PARSEOP_METHOD: @@ -101,7 +108,7 @@ MtMethodAnalysisWalkBegin ( /* Create and init method info */ - MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); + MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); MethodInfo->Next = WalkInfo->MethodStack; MethodInfo->Op = Op; @@ -186,7 +193,9 @@ MtMethodAnalysisWalkBegin ( NextParamType = NextType->Asl.Child; while (NextParamType) { - MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); + MethodInfo->ValidArgTypes[ActualArgs] |= + AnMapObjTypeToBtype (NextParamType); + NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; NextParamType = NextParamType->Asl.Next; } @@ -195,6 +204,7 @@ MtMethodAnalysisWalkBegin ( { MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; ActualArgs++; } @@ -251,11 +261,12 @@ MtMethodAnalysisWalkBegin ( * Local was used outside a control method, or there was an error * in the method declaration. */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, + Op, Op->Asl.ExternalName); return (AE_ERROR); } - RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); + RegisterNumber = (Op->Asl.AmlOpcode & 0x0007); /* * If the local is being used as a target, mark the local @@ -294,7 +305,8 @@ MtMethodAnalysisWalkBegin ( * Arg was used outside a control method, or there was an error * in the method declaration. */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, + Op, Op->Asl.ExternalName); return (AE_ERROR); } @@ -317,7 +329,7 @@ MtMethodAnalysisWalkBegin ( * The only operator that accepts an uninitialized value is ObjectType() */ else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && - (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) { AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); } @@ -394,10 +406,8 @@ MtMethodAnalysisWalkBegin ( case PARSEOP_DEVICE: - Next = Op->Asl.Child; - - if (!ApFindNameInScope (METHOD_NAME__HID, Next) && - !ApFindNameInScope (METHOD_NAME__ADR, Next)) + if (!ApFindNameInDeviceTree (METHOD_NAME__HID, Op) && + !ApFindNameInDeviceTree (METHOD_NAME__ADR, Op)) { AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, "Device object requires a _HID or _ADR in same scope"); @@ -418,7 +428,8 @@ MtMethodAnalysisWalkBegin ( i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); if (i < ACPI_VALID_RESERVED_NAME_MAX) { - AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, + Op, Op->Asl.ExternalName); } break; @@ -430,7 +441,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _HID */ - if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) + if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; AnCheckId (Next, ASL_TYPE_HID); @@ -438,7 +449,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _CID */ - else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) + else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; @@ -487,7 +498,7 @@ MtMethodAnalysisWalkBegin ( * ******************************************************************************/ -void +static void MtCheckNamedObjectInMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) @@ -495,9 +506,10 @@ MtCheckNamedObjectInMethod ( const ACPI_OPCODE_INFO *OpInfo; - /* We don't care about actual method declarations */ + /* We don't care about actual method declarations or scopes */ - if (Op->Asl.AmlOpcode == AML_METHOD_OP) + if ((Op->Asl.AmlOpcode == AML_METHOD_OP) || + (Op->Asl.AmlOpcode == AML_SCOPE_OP)) { return; } @@ -677,7 +689,8 @@ MtMethodAnalysisWalkEnd ( */ if (Op->Asl.Next) { - AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); + AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, + Op->Asl.Next, NULL); } break; diff --git a/sys/contrib/dev/acpica/compiler/aslnamesp.c b/sys/contrib/dev/acpica/compiler/aslnamesp.c index 720d394..f8149c5 100644 --- a/sys/contrib/dev/acpica/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/compiler/aslnamesp.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,16 +124,16 @@ NsDisplayNamespace ( /* Walk entire namespace from the root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL, - NULL, NULL); + ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL, + NULL, NULL); /* Print the full pathname for each namespace node */ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL, - NULL, NULL); + ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL, + NULL, NULL); return (Status); } @@ -168,8 +168,7 @@ NsDoOneNamespaceObject ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u [%u] %*s %4.4s - %s", Gbl_NumNamespaceObjects, Level, (Level * 3), " ", - &Node->Name, - AcpiUtGetTypeName (Node->Type)); + &Node->Name, AcpiUtGetTypeName (Node->Type)); Op = Node->Op; ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); @@ -218,11 +217,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value 0x%8.8X%8.8X]", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); @@ -234,11 +235,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value \"%s\"]", Op->Asl.Value.String); @@ -251,6 +254,7 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Offset 0x%04X Length 0x%04X bits]", Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); @@ -303,11 +307,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + Op = Op->Asl.Child; if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) || @@ -325,11 +331,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + Op = Op->Asl.Child; if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER)) @@ -409,7 +417,7 @@ NsDoOnePathname ( TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &TargetPath); + Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return (Status); @@ -417,6 +425,5 @@ NsDoOnePathname ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); ACPI_FREE (TargetPath.Pointer); - return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asloffset.c b/sys/contrib/dev/acpica/compiler/asloffset.c index 14f7e95..bb57d35 100644 --- a/sys/contrib/dev/acpica/compiler/asloffset.c +++ b/sys/contrib/dev/acpica/compiler/asloffset.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -363,7 +363,7 @@ LsEmitOffsetTableEntry ( /* Get the full pathname to the namespace node */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &TargetPath); + Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return; diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index d4dbbe3..41de07e 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,62 +68,9 @@ 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 -}; - /******************************************************************************* * @@ -260,7 +207,7 @@ OpcSetOptimalIntegerSize ( */ if (Op->Asl.Parent && Op->Asl.Parent->Asl.Parent && - (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) + (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) { return (0); } @@ -330,11 +277,13 @@ OpcSetOptimalIntegerSize ( Op->Asl.AmlOpcode = AML_BYTE_OP; return (1); } + if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX) { Op->Asl.AmlOpcode = AML_WORD_OP; return (2); } + if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX) { Op->Asl.AmlOpcode = AML_DWORD_OP; @@ -398,6 +347,7 @@ OpcDoAccessAs ( { AttribOp->Asl.Value.Integer = 0; } + AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; @@ -486,21 +436,21 @@ OpcDoConnection ( * First Child -> BufferLength * Second Child -> Descriptor Buffer (raw byte data) */ - BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER; - BufferOp->Asl.AmlOpcode = AML_BUFFER_OP; - BufferOp->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC; + BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER; + BufferOp->Asl.AmlOpcode = AML_BUFFER_OP; + BufferOp->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC; UtSetParseOpName (BufferOp); - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; BufferLengthOp->Asl.Value.Integer = Rnode->BufferLength; (void) OpcSetOptimalIntegerSize (BufferLengthOp); UtSetParseOpName (BufferLengthOp); - BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; - BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; - BufferDataOp->Asl.AmlOpcodeLength = 0; - BufferDataOp->Asl.AmlLength = Rnode->BufferLength; - BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode; + BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; + BufferDataOp->Asl.AmlOpcodeLength = 0; + BufferDataOp->Asl.AmlLength = Rnode->BufferLength; + BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode; UtSetParseOpName (BufferDataOp); } @@ -564,8 +514,8 @@ OpcDoUnicode ( * Just set the buffer size node to be the buffer length, regardless * of whether it was previously an integer or a default_arg placeholder */ - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; - BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; BufferLengthOp->Asl.Value.Integer = Length; UtSetParseOpName (BufferLengthOp); @@ -573,11 +523,11 @@ OpcDoUnicode ( /* The Unicode string is a raw data buffer */ - InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString; - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - InitializerOp->Asl.AmlLength = Length; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; - InitializerOp->Asl.Child = NULL; + InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + InitializerOp->Asl.AmlLength = Length; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.Child = NULL; UtSetParseOpName (InitializerOp); } @@ -636,7 +586,7 @@ OpcDoEisaId ( * The EISAID string must be exactly 7 characters and of the form * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001") */ - if (ACPI_STRLEN (InString) != 7) + if (strlen (InString) != 7) { Status = AE_BAD_PARAMETER; } @@ -706,695 +656,6 @@ 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 @@ -1442,9 +703,9 @@ OpcDoUuId ( NewOp = TrAllocateNode (PARSEOP_INTEGER); - NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.AmlOpcode = AML_BYTE_OP; NewOp->Asl.Value.Integer = 16; - NewOp->Asl.Parent = Op; + NewOp->Asl.Parent = Op; Op->Asl.Child = NewOp; Op = NewOp; @@ -1452,10 +713,10 @@ OpcDoUuId ( /* Peer to the child is the raw buffer data */ NewOp = TrAllocateNode (PARSEOP_RAW_DATA); - NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - NewOp->Asl.AmlLength = 16; - NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); - NewOp->Asl.Parent = Op->Asl.Parent; + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 16; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); + NewOp->Asl.Parent = Op->Asl.Parent; Op->Asl.Next = NewOp; } @@ -1551,14 +812,16 @@ OpcGenerateAmlOpcode ( case PARSEOP_INCLUDE: - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; Gbl_HasIncludeFiles = TRUE; break; case PARSEOP_EXTERNAL: - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + if (Gbl_DoExternals == FALSE) + { + Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + } break; case PARSEOP_TIMER: diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index b2972d4..68e760c 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -188,14 +188,16 @@ OpnDoMethod ( { AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); } + Concurrency = (UINT8) Next->Asl.Value.Integer; } /* Put the bits in their proper places */ - MethodFlags = (UINT8) ((NumArgs & 0x7) | - ((Serialized & 0x1) << 3) | - ((Concurrency & 0xF) << 4)); + MethodFlags = (UINT8) + ((NumArgs & 0x7) | + ((Serialized & 0x1) << 3) | + ((Concurrency & 0xF) << 4)); /* Use the last node for the combined flags byte */ @@ -272,9 +274,9 @@ OpnDoFieldCommon ( /* Set the node to RAW_DATA */ Next->Asl.Value.Integer = FieldFlags; - Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; - Next->Asl.AmlLength = 1; - Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; + Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + Next->Asl.AmlLength = 1; + Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; /* Process the FieldUnitList */ @@ -345,8 +347,8 @@ OpnDoFieldCommon ( /* Named or reserved field entry */ - PkgLengthNode = Next->Asl.Child; - NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; + PkgLengthNode = Next->Asl.Child; + NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; CurrentBitOffset += NewBitOffset; /* Save the current AccessAs value for error checking later */ @@ -601,9 +603,9 @@ OpnDoBuffer ( { /* For buffers, this is a list of raw bytes */ - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; - InitializerOp->Asl.AmlLength = 1; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + InitializerOp->Asl.AmlLength = 1; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; BufferLength++; InitializerOp = ASL_GET_PEER_NODE (InitializerOp); @@ -618,9 +620,9 @@ OpnDoBuffer ( */ BufferLength = strlen (InitializerOp->Asl.Value.String) + 1; - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - InitializerOp->Asl.AmlLength = BufferLength; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + InitializerOp->Asl.AmlLength = BufferLength; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; break; case PARSEOP_RAW_DATA: @@ -636,7 +638,7 @@ OpnDoBuffer ( AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp, "Unknown buffer initializer opcode"); printf ("Unknown buffer initializer opcode [%s]\n", - UtGetOpName (InitializerOp->Asl.ParseOpcode)); + UtGetOpName (InitializerOp->Asl.ParseOpcode)); return; } @@ -660,8 +662,8 @@ OpnDoBuffer ( * Just set the buffer size node to be the buffer length, regardless * of whether it was previously an integer or a default_arg placeholder */ - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; - BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; BufferLengthOp->Asl.Value.Integer = BufferLength; (void) OpcSetOptimalIntegerSize (BufferLengthOp); @@ -839,9 +841,9 @@ OpnDoLoadTable ( Next = Next->Asl.Next; if (Next->Asl.ParseOpcode == PARSEOP_ZERO) { - Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; - Next->Asl.Value.String = "\\"; - Next->Asl.AmlLength = 2; + Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; + Next->Asl.Value.String = "\\"; + Next->Asl.AmlLength = 2; OpcGenerateAmlOpcode (Next); } @@ -923,6 +925,7 @@ OpnDoDefinitionBlock ( Gbl_OutputFilenamePrefix = Filename; UtConvertBackslashes (Gbl_OutputFilenamePrefix); } + Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; /* Signature */ @@ -932,13 +935,13 @@ OpnDoDefinitionBlock ( if (Child->Asl.Value.String) { Gbl_TableSignature = Child->Asl.Value.String; - if (ACPI_STRLEN (Gbl_TableSignature) != 4) + if (strlen (Gbl_TableSignature) != ACPI_NAME_SIZE) { AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, - "Length not exactly 4"); + "Length is not exactly 4"); } - for (i = 0; i < 4; i++) + for (i = 0; i < ACPI_NAME_SIZE; i++) { if (!isalnum ((int) Gbl_TableSignature[i])) { @@ -967,9 +970,9 @@ OpnDoDefinitionBlock ( Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; if (Child->Asl.Value.String) { - Length = ACPI_STRLEN (Child->Asl.Value.String); + Length = strlen (Child->Asl.Value.String); Gbl_TableId = UtStringCacheCalloc (Length + 1); - ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); + strcpy (Gbl_TableId, Child->Asl.Value.String); /* * Convert anything non-alphanumeric to an underscore. This @@ -1046,15 +1049,12 @@ OpnAttachNameToNode ( ACPI_PARSE_OBJECT *Child = NULL; - if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) - { - Child = UtGetArg (Op, 0); - } - else switch (Op->Asl.AmlOpcode) + switch (Op->Asl.AmlOpcode) { case AML_DATA_REGION_OP: case AML_DEVICE_OP: case AML_EVENT_OP: + case AML_EXTERNAL_OP: case AML_METHOD_OP: case AML_MUTEX_OP: case AML_REGION_OP: @@ -1131,7 +1131,7 @@ OpnGenerateAmlOperands ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: OpnDoDefinitionBlock (Op); break; @@ -1185,9 +1185,6 @@ OpnGenerateAmlOperands ( case PARSEOP_NAMESTRING: case PARSEOP_METHODCALL: case PARSEOP_STRING_LITERAL: - - break; - default: break; diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 1079f9c..9c26d27 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ ACPI_MODULE_NAME ("aslopt") -static UINT32 OptTotal = 0; +static UINT32 OptTotal = 0; /* Local prototypes */ @@ -132,15 +132,15 @@ OptSearchToRoot ( * name in the search path before the one we want, the nodes will * not match, and we cannot use this optimization. */ - Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - - ACPI_NAME_SIZE]), + Path = &(((char *) TargetPath->Pointer)[ + TargetPath->Length - ACPI_NAME_SIZE]), ScopeInfo.Scope.Node = CurrentNode; /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */ Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &(Node)); + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { return (Status); @@ -168,12 +168,12 @@ OptSearchToRoot ( /* We must allocate a new string for the name (TargetPath gets deleted) */ *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1); - ACPI_STRCPY (*NewPath, Path); + strcpy (*NewPath, Path); - if (ACPI_STRNCMP (*NewPath, "_T_", 3)) + if (strncmp (*NewPath, "_T_", 3)) { - AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op, - *NewPath); + AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, + Op, *NewPath); } return (AE_OK); @@ -217,7 +217,7 @@ OptBuildShortestPath ( UINT32 Index; UINT32 NumCarats; UINT32 i; - char *NewPath; + char *NewPathInternal; char *NewPathExternal; ACPI_NAMESPACE_NODE *Node; ACPI_GENERIC_STATE ScopeInfo; @@ -253,11 +253,11 @@ OptBuildShortestPath ( { /* Compare two single NameSegs */ + Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1; + if (!ACPI_COMPARE_NAME ( - &((char *) TargetPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1], - &((char *) CurrentPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1])) + &(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index], + &(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index])) { /* Mismatch */ @@ -292,13 +292,13 @@ OptBuildShortestPath ( /* Determine how many prefix Carats are required */ NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - - NumCommonSegments; + NumCommonSegments; /* * Construct a new target string */ - NewPathExternal = ACPI_ALLOCATE_ZEROED ( - TargetPath->Length + NumCarats + 1); + NewPathExternal = + ACPI_ALLOCATE_ZEROED (TargetPath->Length + NumCarats + 1); /* Insert the Carats into the Target string */ @@ -315,7 +315,8 @@ OptBuildShortestPath ( /* Special handling for exact subpath in a name declaration */ - if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length)) + if (IsDeclaration && SubPath && + (CurrentPath->Length > TargetPath->Length)) { /* * The current path is longer than the target, and the target is a @@ -341,7 +342,8 @@ OptBuildShortestPath ( Index = TargetPath->Length; } - ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]); + strcpy (&NewPathExternal[i], + &(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal)); /* @@ -349,22 +351,24 @@ OptBuildShortestPath ( * string to make sure that this is in fact an optimization. If the * original string is already optimal, there is no point in continuing. */ - Status = AcpiNsInternalizeName (NewPathExternal, &NewPath); + Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT); - ACPI_FREE (NewPathExternal); - return (Status); + goto Cleanup; } - if (ACPI_STRLEN (NewPath) >= AmlNameStringLength) + if (strlen (NewPathInternal) >= AmlNameStringLength) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %u old %u)", - (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength)); - ACPI_FREE (NewPathExternal); - return (AE_NOT_FOUND); + (UINT32) strlen (NewPathInternal), + (UINT32) AmlNameStringLength)); + + ACPI_FREE (NewPathInternal); + Status = AE_NOT_FOUND; + goto Cleanup; } /* @@ -372,9 +376,9 @@ OptBuildShortestPath ( * looking for. This is simply a sanity check on the new * path that has been created. */ - Status = AcpiNsLookup (&ScopeInfo, NewPath, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); + Status = AcpiNsLookup (&ScopeInfo, NewPathInternal, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) { /* Found the namepath, but make sure the node is correct */ @@ -385,7 +389,7 @@ OptBuildShortestPath ( AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION, Op, NewPathExternal); - *ReturnNewPath = NewPath; + *ReturnNewPath = NewPathInternal; } else { @@ -401,11 +405,15 @@ OptBuildShortestPath ( { /* The lookup failed, we obviously cannot use this optimization */ + ACPI_FREE (NewPathInternal); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND")); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op, "Not using optimized name - did not find node"); } +Cleanup: + ACPI_FREE (NewPathExternal); return (Status); } @@ -446,7 +454,7 @@ OptOptimizeNameDeclaration ( if (((CurrentNode == AcpiGbl_RootNode) || - (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) && + (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) && (ACPI_IS_ROOT_PREFIX (AmlNameString[0]))) { /* @@ -458,7 +466,7 @@ OptOptimizeNameDeclaration ( /* Debug output */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath, - NULL, &NewPathExternal); + NULL, &NewPathExternal); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Externalizing NamePath", @@ -474,8 +482,8 @@ OptOptimizeNameDeclaration ( * We know that we are at the root, so NULL is used for the scope. */ Status = AcpiNsLookup (NULL, *NewPath, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) { /* Found the namepath, but make sure the node is correct */ @@ -597,7 +605,7 @@ OptOptimizeNamePath ( * The original path must be longer than one NameSeg (4 chars) for there * to be any possibility that it can be optimized to a shorter string */ - AmlNameStringLength = ACPI_STRLEN (AmlNameString); + AmlNameStringLength = strlen (AmlNameString); if (AmlNameStringLength <= ACPI_NAME_SIZE) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, @@ -633,6 +641,7 @@ OptOptimizeNamePath ( { NextOp = NextOp->Asl.Parent; } + if (NextOp && NextOp->Asl.Node) { CurrentNode = NextOp->Asl.Node; @@ -655,31 +664,33 @@ OptOptimizeNamePath ( * format -- something we can easily manipulate */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (TargetNode, &TargetPath); + Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT); return_VOID; } + TargetPath.Length--; /* Subtract one for null terminator */ /* CurrentPath is the path to this scope (where we are in the namespace) */ CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath); + Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT); return_VOID; } + CurrentPath.Length--; /* Subtract one for null terminator */ /* Debug output only */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString, - NULL, &ExternalNameString); + NULL, &ExternalNameString); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Externalizing NamePath", @@ -705,7 +716,7 @@ OptOptimizeNamePath ( * a reference. */ Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode, - TargetNode, AmlNameString, &NewPath); + TargetNode, AmlNameString, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -713,8 +724,8 @@ OptOptimizeNamePath ( * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, - TargetNode, &CurrentPath, &TargetPath, - AmlNameStringLength, 1, &NewPath); + TargetNode, &CurrentPath, &TargetPath, + AmlNameStringLength, 1, &NewPath); } } else @@ -726,7 +737,7 @@ OptOptimizeNamePath ( * NameSeg of the NamePath */ Status = OptSearchToRoot (Op, WalkState, CurrentNode, - TargetNode, &TargetPath, &NewPath); + TargetNode, &TargetPath, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -734,8 +745,8 @@ OptOptimizeNamePath ( * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, - TargetNode, &CurrentPath, &TargetPath, - AmlNameStringLength, 0, &NewPath); + TargetNode, &CurrentPath, &TargetPath, + AmlNameStringLength, 0, &NewPath); } } @@ -745,7 +756,7 @@ OptOptimizeNamePath ( */ if (ACPI_SUCCESS (Status)) { - HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath)); + HowMuchShorter = (AmlNameStringLength - strlen (NewPath)); OptTotal += HowMuchShorter; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, @@ -761,12 +772,12 @@ OptOptimizeNamePath ( * (alias name) is the second operand */ Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath; - Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath); } else { Op->Asl.Child->Asl.Value.String = NewPath; - Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.Child->Asl.AmlLength = strlen (NewPath); } } else if (Flags & AML_CREATE) @@ -781,14 +792,14 @@ OptOptimizeNamePath ( /* Update the parse node with the new NamePath */ NextOp->Asl.Value.String = NewPath; - NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath); + NextOp->Asl.AmlLength = strlen (NewPath); } else { /* Update the parse node with the new NamePath */ Op->Asl.Value.String = NewPath; - Op->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.AmlLength = strlen (NewPath); } } else diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c index cc20bcd..aee4564 100644 --- a/sys/contrib/dev/acpica/compiler/asloptions.c +++ b/sys/contrib/dev/acpica/compiler/asloptions.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" +#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" /******************************************************************************* @@ -107,7 +107,7 @@ AslCommandLine ( if (Gbl_DoTemplates) { - Status = DtCreateTemplates (Gbl_TemplateSignature); + Status = DtCreateTemplates (argv); if (ACPI_FAILURE (Status)) { exit (-1); @@ -184,6 +184,24 @@ AslDoOptions ( } break; + case 'a': /* Debug options */ + + switch (AcpiGbl_Optarg[0]) + { + case 'r': + + Gbl_EnableReferenceTypechecking = TRUE; + break; + + default: + + printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); + return (-1); + } + + break; + + case 'b': /* Debug options */ switch (AcpiGbl_Optarg[0]) @@ -194,6 +212,7 @@ AslDoOptions ( DtParserdebug = 1; PrParserdebug = 1; Gbl_DebugFlag = TRUE; + Gbl_KeepPreprocessorTempFile = TRUE; break; case 'p': /* Prune ASL parse tree */ @@ -312,7 +331,8 @@ AslDoOptions ( Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); if (ACPI_FAILURE (Status)) { - printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]); + printf ("Could not add %s to external list\n", + argv[AcpiGbl_Optind]); return (-1); } @@ -439,6 +459,7 @@ AslDoOptions ( /* Produce listing file (Mixed source/aml) */ Gbl_ListingFlag = TRUE; + AcpiGbl_DmOpt_Listing = TRUE; break; case 'i': @@ -469,6 +490,13 @@ AslDoOptions ( Gbl_SourceOutputFlag = TRUE; break; + case 'x': + + /* Produce cross-reference file */ + + Gbl_CrossReferenceOutput = TRUE; + break; + default: printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); @@ -504,6 +532,24 @@ AslDoOptions ( Gbl_ReferenceOptimizationFlag = FALSE; break; + case 'c': + + /* Display compile time(s) */ + + Gbl_CompileTimesFlag = TRUE; + break; + + case 'e': + + /* iASL: Disable External opcode generation */ + + Gbl_DoExternals = FALSE; + + /* Disassembler: Emit embedded external operators */ + + AcpiGbl_DmEmitExternalOpcodes = TRUE; + break; + case 'f': /* Disable folding on "normal" expressions */ @@ -527,9 +573,9 @@ AslDoOptions ( case 't': - /* Display compile time(s) */ + /* Disable heavy typechecking */ - Gbl_CompileTimesFlag = TRUE; + Gbl_DoTypechecking = FALSE; break; default: @@ -634,7 +680,6 @@ AslDoOptions ( case 'T': /* Create a ACPI table template file */ Gbl_DoTemplates = TRUE; - Gbl_TemplateSignature = AcpiGbl_Optarg; break; case 'v': /* Version and verbosity settings */ diff --git a/sys/contrib/dev/acpica/compiler/aslparser.y b/sys/contrib/dev/acpica/compiler/aslparser.y index 223a49d..17cd5be 100644 --- a/sys/contrib/dev/acpica/compiler/aslparser.y +++ b/sys/contrib/dev/acpica/compiler/aslparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,7 @@ * 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, + * ArgList, TermList, ByteList, DWordList, PackageList, * ResourceMacroList, and FieldUnitList */ @@ -99,7 +99,7 @@ AslLocalAllocate ( * These shift/reduce conflicts are expected. There should be zero * reduce/reduce conflicts. */ -%expect 89 +%expect 101 /*! [Begin] no source code translation */ @@ -122,6 +122,8 @@ m4_include(asltypes.y) /* Production rules */ m4_include(aslrules.y) +m4_include(aslcstyle.y) +m4_include(aslresources.y) %% /*! [End] no source code translation !*/ diff --git a/sys/contrib/dev/acpica/compiler/aslpld.c b/sys/contrib/dev/acpica/compiler/aslpld.c new file mode 100644 index 0000000..39f51e1 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslpld.c @@ -0,0 +1,729 @@ +/****************************************************************************** + * + * Module Name: aslpld - Implementation of ASL ToPLD macro + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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 ("aslpld") + + +/* Local prototypes */ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo); + +static BOOLEAN +OpcFindName ( + const char **List, + char *Name, + UINT32 *Index); + + +/******************************************************************************* + * + * FUNCTION: OpcDoPld + * + * PARAMETERS: Op - Current parse node + * + * RETURN: None + * + * DESCRIPTION: Convert ToPLD macro to 20-byte buffer + * + * The ToPLD parse tree looks like this: + * + * TOPLD + * PLD_REVISION + * INTEGER + * PLD_IGNORECOLOR + * INTEGER + * ... + * etc. + * + ******************************************************************************/ + +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PLD_INFO PldInfo; + UINT8 *Buffer; + ACPI_PARSE_OBJECT *ThisOp; + ACPI_PARSE_OBJECT *NewOp; + UINT16 ParseOpcode; + UINT32 Value; + + + 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; + } + + memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); + + /* Traverse the list of PLD Ops (one per PLD field) */ + + ThisOp = Op->Asl.Child; + while (ThisOp) + { + /* Get child values */ + + ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode; + Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer; + + switch (ThisOp->Asl.ParseOpcode) + { + case PARSEOP_PLD_REVISION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 127) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Revision = (UINT8) Value; + break; + + case PARSEOP_PLD_IGNORECOLOR: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.IgnoreColor = (UINT8) Value; + break; + + case PARSEOP_PLD_RED: + case PARSEOP_PLD_GREEN: + case PARSEOP_PLD_BLUE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED) + { + PldInfo.Red = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN) + { + PldInfo.Green = (UINT8) Value; + } + else /* PARSEOP_PLD_BLUE */ + { + PldInfo.Blue = (UINT8) Value; + } + break; + + case PARSEOP_PLD_WIDTH: + case PARSEOP_PLD_HEIGHT: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) + { + PldInfo.Width = (UINT16) Value; + } + else /* PARSEOP_PLD_HEIGHT */ + { + PldInfo.Height = (UINT16) Value; + } + + break; + + case PARSEOP_PLD_USERVISIBLE: + case PARSEOP_PLD_DOCK: + case PARSEOP_PLD_LID: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) + { + PldInfo.UserVisible = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK) + { + PldInfo.Dock = (UINT8) Value; + } + else + { + PldInfo.Lid = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_PANEL: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 6) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldPanelList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Panel = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldVerticalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.VerticalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_HORIZONTALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldHorizontalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.HorizontalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_SHAPE: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 8) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldShapeList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Shape = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPORIENTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.GroupOrientation = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPTOKEN: + case PARSEOP_PLD_GROUPPOSITION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) + { + PldInfo.GroupToken = (UINT8) Value; + } + else /* PARSEOP_PLD_GROUPPOSITION */ + { + PldInfo.GroupPosition = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_BAY: + case PARSEOP_PLD_EJECTABLE: + case PARSEOP_PLD_EJECTREQUIRED: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY) + { + PldInfo.Bay = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) + { + PldInfo.Ejectable = (UINT8) Value; + } + else /* PARSEOP_PLD_EJECTREQUIRED */ + { + PldInfo.OspmEjectRequired = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_CABINETNUMBER: + case PARSEOP_PLD_CARDCAGENUMBER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) + { + PldInfo.CabinetNumber = (UINT8) Value; + } + else /* PARSEOP_PLD_CARDCAGENUMBER */ + { + PldInfo.CardCageNumber = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_REFERENCE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Reference = (UINT8) Value; + break; + + case PARSEOP_PLD_ROTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 7) + { + switch (Value) + { + case 45: + + Value = 1; + break; + + case 90: + + Value = 2; + break; + + case 135: + + Value = 3; + break; + + case 180: + + Value = 4; + break; + + case 225: + + Value = 5; + break; + + case 270: + + Value = 6; + break; + + case 315: + + Value = 7; + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + + PldInfo.Rotation = (UINT8) Value; + break; + + case PARSEOP_PLD_ORDER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 31) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Order = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALOFFSET: + case PARSEOP_PLD_HORIZONTALOFFSET: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) + { + PldInfo.VerticalOffset = (UINT16) Value; + } + else /* PARSEOP_PLD_HORIZONTALOFFSET */ + { + PldInfo.HorizontalOffset = (UINT16) Value; + } + + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + ThisOp = ThisOp->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: 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); + + /* Revision 2 adds an additional 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: 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 ( + const char **List, + char *Name, + UINT32 *Index) +{ + const char *NameString; + UINT32 i; + + + AcpiUtStrupr (Name); + + for (i = 0, NameString = List[0]; + NameString; + i++, NameString = List[i]) + { + if (!(strncmp (NameString, Name, strlen (Name)))) + { + *Index = i; + return (TRUE); + } + } + + return (FALSE); +} diff --git a/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index 9a6778d..673a4ba 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -259,7 +259,7 @@ ApCheckPredefinedReturnValue ( */ Gbl_AllExceptionsDisabled = TRUE; Index = ApCheckForPredefinedName (MethodInfo->Op, - MethodInfo->Op->Asl.NameSeg); + MethodInfo->Op->Asl.NameSeg); Gbl_AllExceptionsDisabled = FALSE; switch (Index) @@ -454,8 +454,8 @@ ApCheckForPredefinedName ( if (Name[0] == 0) { - AcpiOsPrintf ("Found a null name, external = %s\n", - Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "zero length name found"); } /* All reserved names are prefixed with a single underscore */ @@ -571,7 +571,8 @@ ApCheckForSpecialName ( * warning and force the user to manually change the names. So, we * will issue a remark instead. */ - AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, + Op, Op->Asl.ExternalName); return (ACPI_COMPILER_RESERVED_NAME); } @@ -580,8 +581,8 @@ ApCheckForSpecialName ( * warning, since the entire namespace starting with an underscore is * reserved by the ACPI spec. */ - AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, - Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, + Op, Op->Asl.ExternalName); return (ACPI_NOT_RESERVED_NAME); } diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c index be0a4c4..c70144a 100644 --- a/sys/contrib/dev/acpica/compiler/aslprepkg.c +++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ /* Local prototypes */ -static void +static ACPI_PARSE_OBJECT * ApCheckPackageElements ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, @@ -88,6 +88,11 @@ ApPackageTooLarge ( UINT32 Count, UINT32 ExpectedCount); +static void +ApCustomPackage ( + ACPI_PARSE_OBJECT *ParentOp, + const ACPI_PREDEFINED_INFO *Predefined); + /******************************************************************************* * @@ -168,6 +173,11 @@ ApCheckPackage ( switch (Package->RetInfo.Type) { + case ACPI_PTYPE_CUSTOM: + + ApCustomPackage (ParentOp, Predefined); + break; + case ACPI_PTYPE1_FIXED: /* * The package count is fixed and there are no subpackages @@ -238,6 +248,7 @@ ApCheckPackage ( ApCheckObjectType (Predefined->Info.Name, Op, Package->RetInfo3.TailObjectType, i); } + Op = Op->Asl.Next; } break; @@ -381,6 +392,86 @@ PackageTooSmall: /******************************************************************************* * + * FUNCTION: ApCustomPackage + * + * PARAMETERS: ParentOp - Parse op for the package + * Predefined - Pointer to package-specific info for + * the method + * + * RETURN: None + * + * DESCRIPTION: Validate packages that don't fit into the standard model and + * require custom code. + * + * NOTE: Currently used for the _BIX method only. When needed for two or more + * methods, probably a detect/dispatch mechanism will be required. + * + ******************************************************************************/ + +static void +ApCustomPackage ( + ACPI_PARSE_OBJECT *ParentOp, + const ACPI_PREDEFINED_INFO *Predefined) +{ + ACPI_PARSE_OBJECT *Op; + UINT32 Count; + UINT32 ExpectedCount; + UINT32 Version; + + + /* First child is the package length */ + + Op = ParentOp->Asl.Child; + Count = (UINT32) Op->Asl.Value.Integer; + + /* Get the version number, must be Integer */ + + Op = Op->Asl.Next; + Version = (UINT32) Op->Asl.Value.Integer; + if (Op->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer); + return; + } + + /* Validate count (# of elements) */ + + ExpectedCount = 21; /* Version 1 */ + if (Version == 0) + { + ExpectedCount = 20; /* Version 0 */ + } + + if (Count < ExpectedCount) + { + ApPackageTooSmall (Predefined->Info.Name, ParentOp, + Count, ExpectedCount); + return; + } + else if (Count > ExpectedCount) + { + ApPackageTooLarge (Predefined->Info.Name, ParentOp, + Count, ExpectedCount); + } + + /* Validate all elements of the package */ + + Op = ApCheckPackageElements (Predefined->Info.Name, Op, + ACPI_RTYPE_INTEGER, 16, + ACPI_RTYPE_STRING, 4); + + /* Version 1 has a single trailing integer */ + + if (Version > 0) + { + ApCheckPackageElements (Predefined->Info.Name, Op, + ACPI_RTYPE_INTEGER, 1, 0, 0); + } +} + + +/******************************************************************************* + * * FUNCTION: ApCheckPackageElements * * PARAMETERS: PredefinedName - Name of the predefined object @@ -390,7 +481,9 @@ PackageTooSmall: * Type2 - Object type for second group * Count2 - Count for second group * - * RETURN: None + * RETURN: Next Op peer in the parse tree, after all specified elements + * have been validated. Used for multiple validations (calls + * to this function). * * DESCRIPTION: Validate all elements of a package. Works with packages that * are defined to contain up to two groups of different object @@ -398,7 +491,7 @@ PackageTooSmall: * ******************************************************************************/ -static void +static ACPI_PARSE_OBJECT * ApCheckPackageElements ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, @@ -430,6 +523,8 @@ ApCheckPackageElements ( ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1)); Op = Op->Asl.Next; } + + return (Op); } diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c index c8647ea..7ec3e10 100644 --- a/sys/contrib/dev/acpica/compiler/aslprintf.c +++ b/sys/contrib/dev/acpica/compiler/aslprintf.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -186,7 +186,7 @@ OpcParsePrintf ( if (StringToProcess) { NewString = UtStringCacheCalloc (StringLength + 1); - ACPI_STRNCPY (NewString, StartPosition, StringLength); + strncpy (NewString, StartPosition, StringLength); NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); NewOp->Asl.Value.String = NewString; @@ -275,7 +275,7 @@ OpcParsePrintf ( if (StringToProcess) { NewString = UtStringCacheCalloc (StringLength + 1); - ACPI_STRNCPY (NewString, StartPosition, StringLength); + strncpy (NewString, StartPosition, StringLength); NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); NewOp->Asl.Value.String = NewString; diff --git a/sys/contrib/dev/acpica/compiler/aslprune.c b/sys/contrib/dev/acpica/compiler/aslprune.c index 1a36928..b392621 100644 --- a/sys/contrib/dev/acpica/compiler/aslprune.c +++ b/sys/contrib/dev/acpica/compiler/aslprune.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,6 +63,8 @@ PrPrintObjectAtLevel ( const char *ObjectName); +/* Structure used for the pruning parse tree walk */ + typedef struct acpi_prune_info { UINT32 PruneLevel; @@ -120,7 +122,7 @@ AslPruneParseTree ( AcpiOsPrintf ("\nRemoving Objects:\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, PrTreePruneWalk, NULL, ACPI_CAST_PTR (void, &PruneObj)); AcpiOsPrintf ("\n%u Total Objects Removed\n", PruneObj.Count); diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 5f513d7..cdeb1db 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -396,6 +396,7 @@ RsGetStringDataLength ( { return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); } + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); } @@ -431,7 +432,6 @@ RsAllocateResourceNode ( Rnode->Buffer = UtLocalCalloc (Size); Rnode->BufferLength = Size; - return (Rnode); } @@ -467,7 +467,6 @@ RsCreateResourceField ( Op->Asl.ExternalName = Name; Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; - Op->Asl.Value.Tag.BitOffset = (ByteOffset * 8) + BitOffset; Op->Asl.Value.Tag.BitLength = BitLength; } @@ -866,16 +865,19 @@ RsDoOneResourceDescriptor ( break; case PARSEOP_I2C_SERIALBUS: + case PARSEOP_I2C_SERIALBUS_V2: Rnode = RsDoI2cSerialBusDescriptor (Info); break; case PARSEOP_SPI_SERIALBUS: + case PARSEOP_SPI_SERIALBUS_V2: Rnode = RsDoSpiSerialBusDescriptor (Info); break; case PARSEOP_UART_SERIALBUS: + case PARSEOP_UART_SERIALBUS_V2: Rnode = RsDoUartSerialBusDescriptor (Info); break; @@ -888,7 +890,7 @@ RsDoOneResourceDescriptor ( default: printf ("Unknown resource descriptor type [%s]\n", - Info->DescriptorTypeOp->Asl.ParseOpName); + Info->DescriptorTypeOp->Asl.ParseOpName); break; } @@ -904,7 +906,8 @@ RsDoOneResourceDescriptor ( if (Rnode) { Info->DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; - Info->DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; + Info->DescriptorTypeOp->Asl.Extra = + ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; } return (Rnode); diff --git a/sys/contrib/dev/acpica/compiler/aslresources.y b/sys/contrib/dev/acpica/compiler/aslresources.y new file mode 100644 index 0000000..074536b --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslresources.y @@ -0,0 +1,1248 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslresources.y - Bison/Yacc production rules for resources + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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. + */ + +') + +/******************************************************************************* + * + * ASL Parameter Keyword Terms + * + ******************************************************************************/ + +AccessAttribKeyword + : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} + | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} + | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} + | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} + | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} + | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} + | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} + | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + ; + +AccessTypeKeyword + : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} + | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} + | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} + | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} + | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} + | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} + ; + +AddressingModeKeyword + : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} + | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} + ; + +AddressKeyword + : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} + | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} + | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} + | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} + ; + +AddressSpaceKeyword + : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} + | RegionSpaceKeyword {} + ; + +BitsPerByteKeyword + : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} + | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} + | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} + | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} + | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} + ; + +ClockPhaseKeyword + : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} + | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} + ; + +ClockPolarityKeyword + : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} + | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} + ; + +DecodeKeyword + : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} + | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} + ; + +DevicePolarityKeyword + : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} + | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} + ; + +DMATypeKeyword + : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} + | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} + | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} + | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} + ; + +EndianKeyword + : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} + | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} + ; + +FlowControlKeyword + : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} + | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} + | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} + ; + +InterruptLevel + : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} + | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} + | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} + ; + +InterruptTypeKeyword + : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} + | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} + ; + +IODecodeKeyword + : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} + | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} + ; + +IoRestrictionKeyword + : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} + | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} + | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} + | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} + ; + +LockRuleKeyword + : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} + | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} + ; + +MatchOpKeyword + : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} + | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} + | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} + | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} + | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} + | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} + ; + +MaxKeyword + : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} + | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} + ; + +MemTypeKeyword + : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} + | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} + | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} + | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} + ; + +MinKeyword + : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} + | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} + ; + +ObjectTypeKeyword + : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} + | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} + | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} + | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} + | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} + | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} + | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} + | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} + | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} + | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} + | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} + | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} + | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} + | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} + | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} + ; + +ParityTypeKeyword + : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} + | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} + | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} + | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} + | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} + ; + +PinConfigByte + : PinConfigKeyword {$$ = $1;} + | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + +PinConfigKeyword + : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} + | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} + | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} + | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} + ; + +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);} + ; + +RangeTypeKeyword + : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} + | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} + | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} + ; + +RegionSpaceKeyword + : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} + | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} + | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} + | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} + | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} + | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} + | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} + | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} + | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} + | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} + | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} + | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} + ; + +ResourceTypeKeyword + : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} + ; + +SerializeRuleKeyword + : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} + | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} + ; + +ShareTypeKeyword + : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} + | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} + | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} + | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} + ; + +SlaveModeKeyword + : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} + | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} + ; + +StopBitsKeyword + : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} + | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} + | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} + | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} + ; + +TranslationKeyword + : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} + | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} + ; + +TypeKeyword + : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} + | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} + ; + +UpdateRuleKeyword + : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} + | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} + | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} + ; + +WireModeKeyword + : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} + | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} + ; + +XferSizeKeyword + : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} + | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} + | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} + | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} + | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} + ; + +XferTypeKeyword + : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} + | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} + | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} + ; + + +/******************************************************************************* + * + * ASL Resource Template Terms + * + ******************************************************************************/ + +/* + * Note: Create two default nodes to allow conversion to a Buffer AML opcode + * Also, insert the EndTag at the end of the template. + */ +ResourceTemplateTerm + : PARSEOP_RESOURCETEMPLATE '(' ')' + '{' + ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + $5, + TrCreateLeafNode (PARSEOP_ENDTAG));} + ; + +ResourceMacroList + : {$$ = NULL;} + | ResourceMacroList + ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} + ; + +ResourceMacroTerm + : DMATerm {} + | DWordIOTerm {} + | DWordMemoryTerm {} + | DWordSpaceTerm {} + | EndDependentFnTerm {} + | ExtendedIOTerm {} + | ExtendedMemoryTerm {} + | ExtendedSpaceTerm {} + | FixedDmaTerm {} + | FixedIOTerm {} + | GpioIntTerm {} + | GpioIoTerm {} + | I2cSerialBusTerm {} + | I2cSerialBusTermV2 {} + | InterruptTerm {} + | IOTerm {} + | IRQNoFlagsTerm {} + | IRQTerm {} + | Memory24Term {} + | Memory32FixedTerm {} + | Memory32Term {} + | QWordIOTerm {} + | QWordMemoryTerm {} + | QWordSpaceTerm {} + | RegisterTerm {} + | SpiSerialBusTerm {} + | SpiSerialBusTermV2 {} + | StartDependentFnNoPriTerm {} + | StartDependentFnTerm {} + | UartSerialBusTerm {} + | UartSerialBusTermV2 {} + | VendorLongTerm {} + | VendorShortTerm {} + | WordBusNumberTerm {} + | WordIOTerm {} + | WordSpaceTerm {} + ; + +DMATerm + : PARSEOP_DMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DMA);} + DMATypeKeyword + OptionalBusMasterKeyword + ',' XferTypeKeyword + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);} + | PARSEOP_DMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordIOTerm + : PARSEOP_DWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_DWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordMemoryTerm + : PARSEOP_DWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_DWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordSpaceTerm + : PARSEOP_DWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_DWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +EndDependentFnTerm + : PARSEOP_ENDDEPENDENTFN '(' + ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} + | PARSEOP_ENDDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedIOTerm + : PARSEOP_EXTENDEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} + | PARSEOP_EXTENDEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedMemoryTerm + : PARSEOP_EXTENDEDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} + | PARSEOP_EXTENDEDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedSpaceTerm + : PARSEOP_EXTENDEDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} + | PARSEOP_EXTENDEDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedDmaTerm + : PARSEOP_FIXEDDMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} + WordConstExpr /* 04: DMA RequestLines */ + ',' WordConstExpr /* 06: DMA Channels */ + OptionalXferSize /* 07: DMA TransferSize */ + OptionalNameString /* 08: DescriptorName */ + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);} + | PARSEOP_FIXEDDMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedIOTerm + : PARSEOP_FIXEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} + WordConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FIXEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIntTerm + : PARSEOP_GPIO_INT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} + InterruptTypeKeyword /* 04: InterruptType */ + ',' InterruptLevel /* 06: InterruptLevel */ + OptionalShareType /* 07: SharedType */ + ',' PinConfigByte /* 09: PinConfig */ + OptionalWordConstExpr /* 10: DebounceTimeout */ + ',' StringData /* 12: ResourceSource */ + OptionalByteConstExpr /* 13: ResourceSourceIndex */ + OptionalResourceType /* 14: ResourceType */ + OptionalNameString /* 15: DescriptorName */ + OptionalBuffer_Last /* 16: VendorData */ + ')' '{' + DWordConstExpr '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} + | PARSEOP_GPIO_INT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIoTerm + : PARSEOP_GPIO_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} + OptionalShareType_First /* 04: SharedType */ + ',' PinConfigByte /* 06: PinConfig */ + OptionalWordConstExpr /* 07: DebounceTimeout */ + OptionalWordConstExpr /* 08: DriveStrength */ + OptionalIoRestriction /* 09: IoRestriction */ + ',' StringData /* 11: ResourceSource */ + OptionalByteConstExpr /* 12: ResourceSourceIndex */ + OptionalResourceType /* 13: ResourceType */ + OptionalNameString /* 14: DescriptorName */ + OptionalBuffer_Last /* 15: VendorData */ + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} + | PARSEOP_GPIO_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +I2cSerialBusTerm + : PARSEOP_I2C_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} + WordConstExpr /* 04: SlaveAddress */ + OptionalSlaveMode /* 05: SlaveMode */ + ',' DWordConstExpr /* 07: ConnectionSpeed */ + OptionalAddressingMode /* 08: AddressingMode */ + ',' StringData /* 10: ResourceSource */ + OptionalByteConstExpr /* 11: ResourceSourceIndex */ + OptionalResourceType /* 12: ResourceType */ + OptionalNameString /* 13: DescriptorName */ + OptionalBuffer_Last /* 14: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,10,$4,$5,$7,$8,$10,$11,$12,$13, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$14);} + | PARSEOP_I2C_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +I2cSerialBusTermV2 + : PARSEOP_I2C_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS_V2);} + WordConstExpr /* 04: SlaveAddress */ + OptionalSlaveMode /* 05: SlaveMode */ + ',' DWordConstExpr /* 07: ConnectionSpeed */ + OptionalAddressingMode /* 08: AddressingMode */ + ',' StringData /* 10: ResourceSource */ + OptionalByteConstExpr /* 11: ResourceSourceIndex */ + OptionalResourceType /* 12: ResourceType */ + OptionalNameString /* 13: DescriptorName */ + OptionalShareType /* 14: Share */ + OptionalBuffer_Last /* 15: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,10,$4,$5,$7,$8,$10,$11,$12,$13, + $14,$15);} + | PARSEOP_I2C_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +InterruptTerm + : PARSEOP_INTERRUPT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} + OptionalResourceType_First + ',' InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);} + | PARSEOP_INTERRUPT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IOTerm + : PARSEOP_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IO);} + IODecodeKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' ByteConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQNoFlagsTerm + : PARSEOP_IRQNOFLAGS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_IRQNOFLAGS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQTerm + : PARSEOP_IRQ '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQ);} + InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);} + | PARSEOP_IRQ '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory24Term + : PARSEOP_MEMORY24 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY24);} + OptionalReadWriteKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY24 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32FixedTerm + : PARSEOP_MEMORY32FIXED '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);} + | PARSEOP_MEMORY32FIXED '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32Term + : PARSEOP_MEMORY32 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY32 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordIOTerm + : PARSEOP_QWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_QWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordMemoryTerm + : PARSEOP_QWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_QWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordSpaceTerm + : PARSEOP_QWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_QWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +RegisterTerm + : PARSEOP_REGISTER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_REGISTER);} + AddressSpaceKeyword + ',' ByteConstExpr + ',' ByteConstExpr + ',' QWordConstExpr + OptionalAccessSize + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);} + | PARSEOP_REGISTER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SpiSerialBusTerm + : PARSEOP_SPI_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} + WordConstExpr /* 04: DeviceSelection */ + OptionalDevicePolarity /* 05: DevicePolarity */ + OptionalWireMode /* 06: WireMode */ + ',' ByteConstExpr /* 08: DataBitLength */ + OptionalSlaveMode /* 09: SlaveMode */ + ',' DWordConstExpr /* 11: ConnectionSpeed */ + ',' ClockPolarityKeyword /* 13: ClockPolarity */ + ',' ClockPhaseKeyword /* 15: ClockPhase */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} + | PARSEOP_SPI_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SpiSerialBusTermV2 + : PARSEOP_SPI_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS_V2);} + WordConstExpr /* 04: DeviceSelection */ + OptionalDevicePolarity /* 05: DevicePolarity */ + OptionalWireMode /* 06: WireMode */ + ',' ByteConstExpr /* 08: DataBitLength */ + OptionalSlaveMode /* 09: SlaveMode */ + ',' DWordConstExpr /* 11: ConnectionSpeed */ + ',' ClockPolarityKeyword /* 13: ClockPolarity */ + ',' ClockPhaseKeyword /* 15: ClockPhase */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalShareType /* 21: Share */ + OptionalBuffer_Last /* 22: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, + $21,$22);} + | PARSEOP_SPI_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnNoPriTerm + : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,1,$6);} + | PARSEOP_STARTDEPENDENTFN_NOPRI '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnTerm + : PARSEOP_STARTDEPENDENTFN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} + ByteConstExpr + ',' ByteConstExpr + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);} + | PARSEOP_STARTDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UartSerialBusTerm + : PARSEOP_UART_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} + DWordConstExpr /* 04: ConnectionSpeed */ + OptionalBitsPerByte /* 05: BitsPerByte */ + OptionalStopBits /* 06: StopBits */ + ',' ByteConstExpr /* 08: LinesInUse */ + OptionalEndian /* 09: Endianess */ + OptionalParityType /* 10: Parity */ + OptionalFlowControl /* 11: FlowControl */ + ',' WordConstExpr /* 13: Rx BufferSize */ + ',' WordConstExpr /* 15: Tx BufferSize */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} + | PARSEOP_UART_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UartSerialBusTermV2 + : PARSEOP_UART_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS_V2);} + DWordConstExpr /* 04: ConnectionSpeed */ + OptionalBitsPerByte /* 05: BitsPerByte */ + OptionalStopBits /* 06: StopBits */ + ',' ByteConstExpr /* 08: LinesInUse */ + OptionalEndian /* 09: Endianess */ + OptionalParityType /* 10: Parity */ + OptionalFlowControl /* 11: FlowControl */ + ',' WordConstExpr /* 13: Rx BufferSize */ + ',' WordConstExpr /* 15: Tx BufferSize */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalShareType /* 21: Share */ + OptionalBuffer_Last /* 22: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, + $21,$22);} + | PARSEOP_UART_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorLongTerm + : PARSEOP_VENDORLONG '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_VENDORLONG '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorShortTerm + : PARSEOP_VENDORSHORT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_VENDORSHORT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordBusNumberTerm + : PARSEOP_WORDBUSNUMBER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} + | PARSEOP_WORDBUSNUMBER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordIOTerm + : PARSEOP_WORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_WORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordSpaceTerm + : PARSEOP_WORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_WORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Object References ***********************************************/ + +/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ + +NameString + : NameSeg {} + | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} + | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} + | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} + | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} + ; + +NameSeg + : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + + +/******************************************************************************* + * + * ASL Helper Terms + * + ******************************************************************************/ + +OptionalBusMasterKeyword + : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} + ; + +OptionalAccessAttribTerm + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + | ',' AccessAttribKeyword {$$ = $2;} + ; + +OptionalAccessSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalAddressingMode + : ',' {$$ = NULL;} + | ',' AddressingModeKeyword {$$ = $2;} + ; + +OptionalAddressRange + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' AddressKeyword {$$ = $2;} + ; + +OptionalBitsPerByte + : ',' {$$ = NULL;} + | ',' BitsPerByteKeyword {$$ = $2;} + ; + +OptionalBuffer_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' RawDataBufferTerm {$$ = $2;} + ; + +OptionalByteConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalDecodeType + : ',' {$$ = NULL;} + | ',' DecodeKeyword {$$ = $2;} + ; + +OptionalDevicePolarity + : ',' {$$ = NULL;} + | ',' DevicePolarityKeyword {$$ = $2;} + ; + +OptionalDWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' DWordConstExpr {$$ = $2;} + ; + +OptionalEndian + : ',' {$$ = NULL;} + | ',' EndianKeyword {$$ = $2;} + ; + +OptionalFlowControl + : ',' {$$ = NULL;} + | ',' FlowControlKeyword {$$ = $2;} + ; + +OptionalIoRestriction + : ',' {$$ = NULL;} + | ',' IoRestrictionKeyword {$$ = $2;} + ; + +OptionalListString + : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' TermArg {$$ = $2;} + ; + +OptionalMaxType + : ',' {$$ = NULL;} + | ',' MaxKeyword {$$ = $2;} + ; + +OptionalMemType + : ',' {$$ = NULL;} + | ',' MemTypeKeyword {$$ = $2;} + ; + +OptionalMinType + : ',' {$$ = NULL;} + | ',' MinKeyword {$$ = $2;} + ; + +OptionalNameString + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_First + : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} + | NameString {$$ = $1;} + ; + +OptionalObjectTypeKeyword + : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | ',' ObjectTypeKeyword {$$ = $2;} + ; + +OptionalParityType + : ',' {$$ = NULL;} + | ',' ParityTypeKeyword {$$ = $2;} + ; + +OptionalQWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' QWordConstExpr {$$ = $2;} + ; + +OptionalRangeType + : ',' {$$ = NULL;} + | ',' RangeTypeKeyword {$$ = $2;} + ; + +OptionalReadWriteKeyword + : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} + ; + +OptionalResourceType_First + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ResourceTypeKeyword {$$ = $1;} + ; + +OptionalResourceType + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' ResourceTypeKeyword {$$ = $2;} + ; + +OptionalSlaveMode + : ',' {$$ = NULL;} + | ',' SlaveModeKeyword {$$ = $2;} + ; + +OptionalShareType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ShareTypeKeyword {$$ = $2;} + ; + +OptionalShareType_First + : {$$ = NULL;} + | ShareTypeKeyword {$$ = $1;} + ; + +OptionalStopBits + : ',' {$$ = NULL;} + | ',' StopBitsKeyword {$$ = $2;} + ; + +OptionalStringData + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' StringData {$$ = $2;} + ; + +OptionalTranslationType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TranslationKeyword {$$ = $2;} + ; + +OptionalType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalWireMode + : ',' {$$ = NULL;} + | ',' WireModeKeyword {$$ = $2;} + ; + +OptionalWordConstExpr + : ',' {$$ = NULL;} + | ',' WordConstExpr {$$ = $2;} + ; + +OptionalXferSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' XferSizeKeyword {$$ = $2;} + ; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 4ac0635..dbe88a8 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,6 @@ RsDoEndTagDescriptor ( Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE; Descriptor->EndTag.Checksum = 0; - return (Rnode); } @@ -114,8 +113,8 @@ RsDoEndDependentDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); Descriptor = Rnode->Buffer; - Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | - ASL_RDESC_END_DEPEND_SIZE; + Descriptor->EndDpf.DescriptorType = + ACPI_RESOURCE_NAME_END_DEPENDENT | ASL_RDESC_END_DEPEND_SIZE; return (Rnode); } @@ -151,7 +150,7 @@ RsDoMemory24Descriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); Descriptor = Rnode->Buffer; - Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; + Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; Descriptor->Memory24.ResourceLength = 9; /* Process all child initialization nodes */ @@ -257,7 +256,7 @@ RsDoMemory32Descriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; + Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; Descriptor->Memory32.ResourceLength = 17; /* Process all child initialization nodes */ @@ -360,7 +359,7 @@ RsDoMemory32FixedDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; + Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; Descriptor->FixedMemory32.ResourceLength = 9; /* Process all child initialization nodes */ @@ -448,8 +447,8 @@ RsDoStartDependentDescriptor ( /* Descriptor has priority byte */ - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - (ASL_RDESC_ST_DEPEND_SIZE + 0x01); + Descriptor->StartDpf.DescriptorType = + ACPI_RESOURCE_NAME_START_DEPENDENT | (ASL_RDESC_ST_DEPEND_SIZE + 0x01); /* Process all child initialization nodes */ @@ -493,8 +492,8 @@ RsDoStartDependentDescriptor ( * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, - NextRnode); + CurrentByteOffset += RsLinkDescriptorChain ( + &PreviousRnode, NextRnode); break; } @@ -536,8 +535,8 @@ RsDoStartDependentNoPriDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); Descriptor = Rnode->Buffer; - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - ASL_RDESC_ST_DEPEND_SIZE; + Descriptor->StartDpf.DescriptorType = + ACPI_RESOURCE_NAME_START_DEPENDENT | ASL_RDESC_ST_DEPEND_SIZE; PreviousRnode = Rnode; /* Increment offset past StartDependentNoPri descriptor */ @@ -599,7 +598,7 @@ RsDoVendorSmallDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); Descriptor = Rnode->Buffer; - Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; + Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); /* Process all child initialization nodes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c index 36e2400..7d9d691 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,8 +88,8 @@ RsDoDmaDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); Descriptor = Rnode->Buffer; - Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | - ASL_RDESC_DMA_SIZE; + Descriptor->Dma.DescriptorType = + ACPI_RESOURCE_NAME_DMA | ASL_RDESC_DMA_SIZE; /* Process all child initialization nodes */ @@ -282,8 +282,8 @@ RsDoFixedIoDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | - ASL_RDESC_FIXED_IO_SIZE; + Descriptor->Io.DescriptorType = + ACPI_RESOURCE_NAME_FIXED_IO | ASL_RDESC_FIXED_IO_SIZE; /* Process all child initialization nodes */ @@ -365,8 +365,8 @@ RsDoIoDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | - ASL_RDESC_IO_SIZE; + Descriptor->Io.DescriptorType = + ACPI_RESOURCE_NAME_IO | ASL_RDESC_IO_SIZE; /* Process all child initialization nodes */ @@ -476,8 +476,8 @@ RsDoIrqDescriptor ( /* Length = 3 (with flag byte) */ Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - (ASL_RDESC_IRQ_SIZE + 0x01); + Descriptor->Irq.DescriptorType = + ACPI_RESOURCE_NAME_IRQ | (ASL_RDESC_IRQ_SIZE + 0x01); /* Process all child initialization nodes */ @@ -596,8 +596,8 @@ RsDoIrqNoFlagsDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - ASL_RDESC_IRQ_SIZE; + Descriptor->Irq.DescriptorType = + ACPI_RESOURCE_NAME_IRQ | ASL_RDESC_IRQ_SIZE; /* Process all child initialization nodes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index af93a9e..ba6fb8e 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,6 +147,7 @@ RsDoGeneralRegisterDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + return (Rnode); } @@ -213,7 +214,7 @@ RsDoInterruptDescriptor ( 1 + OptionIndex + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; + Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; /* * Initial descriptor length -- may be enlarged if there are @@ -223,7 +224,7 @@ RsDoInterruptDescriptor ( Descriptor->ExtendedIrq.InterruptCount = 0; Rover = ACPI_CAST_PTR (AML_RESOURCE, - (&(Descriptor->ExtendedIrq.Interrupts[0]))); + (&(Descriptor->ExtendedIrq.Interrupts[0]))); /* Process all child initialization nodes */ @@ -382,9 +383,10 @@ RsDoInterruptDescriptor ( (Descriptor->ExtendedIrq.ResourceLength + StringLength); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - - ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = + (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - + ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) + + OptionIndex + StringLength; return (Rnode); } @@ -431,7 +433,7 @@ RsDoVendorLargeDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i); Descriptor = Rnode->Buffer; - Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE; + Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE; Descriptor->VendorLarge.ResourceLength = (UINT16) i; /* Point to end-of-descriptor for vendor data */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c index 25cbed9..a23e01e 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoDwordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -325,7 +325,7 @@ RsDoDwordMemoryDescriptor ( Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -556,7 +556,7 @@ RsDoDwordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c index ddb7ea3..fc85635 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,14 +87,14 @@ RsDoExtendedIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); @@ -143,7 +143,7 @@ RsDoExtendedIoDescriptor ( RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY, CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); GranOp = InitializerOp; - break; + break; case 6: /* Address Min */ @@ -263,11 +263,11 @@ RsDoExtendedMemoryDescriptor ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); @@ -441,13 +441,13 @@ RsDoExtendedSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c index 16398e5..65d2257 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoQwordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -312,11 +312,11 @@ RsDoQwordMemoryDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -541,7 +541,7 @@ RsDoQwordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/compiler/aslrestype2s.c index 73680c2..3b72f90 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2s.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -313,17 +313,19 @@ RsDoGpioIntDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; - Descriptor->Gpio.ResourceLength = DescriptorSize; - Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; - Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; - Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; /* Build pointers to optional areas */ - InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + 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); @@ -336,11 +338,6 @@ RsDoGpioIntDescriptor ( Descriptor->Gpio.ResSourceOffset = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", - "GpioInt", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), - ResSourceLength, VendorLength, InterruptLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -397,7 +394,8 @@ RsDoGpioIntDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->Gpio.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -422,7 +420,7 @@ RsDoGpioIntDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -430,7 +428,7 @@ RsDoGpioIntDescriptor ( default: /* - * PINs come through here, repeatedly. Each PIN must be a DWORD. + * PINs come through here, repeatedly. Each PIN must be a WORD. * NOTE: there is no "length" field for this, so from ACPI spec: * The number of pins in the table can be calculated from: * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 @@ -459,7 +457,7 @@ RsDoGpioIntDescriptor ( /* Create a named field at the start of the list */ - RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN, CurrentByteOffset + Descriptor->Gpio.PinTableOffset); } break; @@ -468,7 +466,8 @@ RsDoGpioIntDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -524,13 +523,14 @@ RsDoGpioIoDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; - Descriptor->Gpio.ResourceLength = DescriptorSize; - Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; - Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; - Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; /* Build pointers to optional areas */ @@ -547,11 +547,6 @@ RsDoGpioIoDescriptor ( Descriptor->Gpio.ResSourceOffset = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", - "GpioIo", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), - ResSourceLength, VendorLength, InterruptLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -632,7 +627,7 @@ RsDoGpioIoDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -640,7 +635,7 @@ RsDoGpioIoDescriptor ( default: /* - * PINs come through here, repeatedly. Each PIN must be a DWORD. + * PINs come through here, repeatedly. Each PIN must be a WORD. * NOTE: there is no "length" field for this, so from ACPI spec: * The number of pins in the table can be calculated from: * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 @@ -669,7 +664,7 @@ RsDoGpioIoDescriptor ( /* Create a named field at the start of the list */ - RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN, CurrentByteOffset + Descriptor->Gpio.PinTableOffset); } break; @@ -678,7 +673,8 @@ RsDoGpioIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -727,27 +723,27 @@ RsDoI2cSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->I2cSerialBus.ResourceLength = DescriptorSize; Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; + Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION; - Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; + Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_I2C_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "I2cSerialBus", Descriptor->I2cSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_I2C_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->I2cSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -797,7 +793,8 @@ RsDoI2cSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->I2cSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->I2cSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -811,7 +808,18 @@ RsDoI2cSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 8: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 2); + break; + + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS)); @@ -874,27 +882,28 @@ RsDoSpiSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->SpiSerialBus.ResourceLength = DescriptorSize; Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; + Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION; - Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; + Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ - VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_SPI_SERIALBUS)); + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, + sizeof (AML_RESOURCE_SPI_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "SpiSerialBus", Descriptor->SpiSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_SPI_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->SpiSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -972,7 +981,8 @@ RsDoSpiSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->SpiSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->SpiSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -986,7 +996,18 @@ RsDoSpiSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 12: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 2); + break; + + case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS)); @@ -1049,27 +1070,27 @@ RsDoUartSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->UartSerialBus.ResourceLength = DescriptorSize; Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; + Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION; - Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; + Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "UartSerialBus", Descriptor->UartSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_UART_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->UartSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -1154,7 +1175,8 @@ RsDoUartSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->UartSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->UartSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -1178,7 +1200,18 @@ RsDoUartSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 13: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 2); + break; + + case 14: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS)); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c index a9f4771..f3b7757 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoWordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -312,11 +312,11 @@ RsDoWordBusNumberDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -517,10 +517,10 @@ RsDoWordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; /* * Initial descriptor length -- may be enlarged if there are diff --git a/sys/contrib/dev/acpica/compiler/aslrules.y b/sys/contrib/dev/acpica/compiler/aslrules.y index dbe0882..a5d8387 100644 --- a/sys/contrib/dev/acpica/compiler/aslrules.y +++ b/sys/contrib/dev/acpica/compiler/aslrules.y @@ -1,12 +1,12 @@ NoEcho(' /****************************************************************************** * - * Module Name: aslrules.y - Bison/Yacc production rules + * Module Name: aslrules.y - Main Bison/Yacc production rules * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,24 +46,19 @@ NoEcho(' /******************************************************************************* * - * Production rules start here + * ASL Root and Secondary Terms * ******************************************************************************/ /* - * ASL Names - * - * Root rule. Allow multiple #line directives before the definition block + * Root term. Allow multiple #line directives before the definition block * to handle output from preprocessors */ -ASLCode - : DefinitionBlockTerm +AslCode + : DefinitionBlockList {$<n>$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_ASL_CODE),1, $1);} | error {YYABORT; $$ = NULL;} ; -/* - * Blocks, Data, and Opcodes - */ /* * Note concerning support for "module-level code". @@ -79,9 +74,13 @@ ASLCode * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the * original use of {TermList} instead (see below.) This allows the use * of Type1 and Type2 opcodes at module level. + * + * 04/2016: The module-level code is now allowed in the following terms: + * DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm. + * The ObjectList term is obsolete and has been removed. */ DefinitionBlockTerm - : PARSEOP_DEFINITIONBLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);} + : PARSEOP_DEFINITION_BLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);} String ',' String ',' ByteConst ',' @@ -92,150 +91,167 @@ 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,TrCreateNullTarget ());} - - | 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,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), - TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - - | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - - | 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,TrCreateNullTarget (), - 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));} +DefinitionBlockList + : DefinitionBlockTerm + | DefinitionBlockTerm + DefinitionBlockList {$$ = TrLinkPeerNodes (2, $1,$2);} + ; - | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +SuperName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | Type6Opcode {} - | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +Target + : {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ + | ',' {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ + | ',' SuperName {$$ = TrSetNodeFlags ($2, 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));} +TermArg + : 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);} + | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} ; +/* + NOTE: Removed from TermArg due to reduce/reduce conflicts: + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} -/* ACPI 3.0 -- allow semicolons between terms */ +*/ + +MethodInvocationTerm + : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} + ArgList ')' {$$ = TrLinkChildNode ($1,$4);} + ; + +/* OptionalCount must appear before ByteList or an incorrect reduction will result */ + +OptionalCount + : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' TermArg {$$ = $2;} + ; + +VarPackageLengthTerm + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | TermArg {$$ = $1;} + ; + + +/******* List Terms **************************************************/ + +ArgList + : {$$ = NULL;} + | TermArg + | ArgList ',' /* Allows a trailing comma at list end */ + | ArgList ',' + TermArg {$$ = TrLinkPeerNode ($1,$3);} + ; + +ByteList + : {$$ = NULL;} + | ByteConstExpr + | ByteList ',' /* Allows a trailing comma at list end */ + | ByteList ',' + ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +DWordList + : {$$ = NULL;} + | DWordConstExpr + | DWordList ',' /* Allows a trailing comma at list end */ + | DWordList ',' + DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +FieldUnitList + : {$$ = NULL;} + | FieldUnit + | FieldUnitList ',' /* Allows a trailing comma at list end */ + | FieldUnitList ',' + FieldUnit {$$ = TrLinkPeerNode ($1,$3);} + ; + +FieldUnit + : FieldUnitEntry {} + | OffsetTerm {} + | AccessAsTerm {} + | ConnectionTerm {} + ; + +FieldUnitEntry + : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} + | NameSeg ',' + AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} + ; + +Object + : CompilerDirective {} + | NamedObject {} + | NameSpaceModifier {} + ; + +PackageList + : {$$ = NULL;} + | PackageElement + | PackageList ',' /* Allows a trailing comma at list end */ + | PackageList ',' + PackageElement {$$ = TrLinkPeerNode ($1,$3);} + ; + +PackageElement + : DataObject {} + | NameString {} + ; + + /* Rules for specifying the type of one method argument or return value */ + +ParameterTypePackage + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | ParameterTypePackage ',' + ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypePackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypePackage '}' {$$ = $2;} + ; + +OptionalParameterTypePackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + + /* Rules for specifying the types for method arguments */ + +ParameterTypesPackage + : ParameterTypePackageList {$$ = $1;} + | ParameterTypesPackage ',' + ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypesPackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypesPackage '}' {$$ = $2;} + ; + +OptionalParameterTypesPackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + + /* ACPI 3.0 -- allow semicolons between terms */ TermList : {$$ = NULL;} @@ -256,22 +272,44 @@ Term | error {$$ = AslDoError(); yyclearin;} ; -CompilerDirective - : IncludeTerm {} - | ExternalTerm {} - ; +/* + * Case-Default list; allow only one Default term and unlimited Case terms + */ +CaseDefaultTermList + : {$$ = NULL;} + | CaseTerm {} + | DefaultTerm {} + | CaseDefaultTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} + | CaseDefaultTermList + DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} + +/* Original - attempts to force zero or one default term within the switch */ -ObjectList +/* +CaseDefaultTermList : {$$ = NULL;} - | ObjectList Object {$$ = TrLinkPeerNode ($1,$2);} - | error {$$ = AslDoError(); yyclearin;} + | CaseTermList + DefaultTerm + CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} ; -Object - : CompilerDirective {} - | NamedObject {} - | NameSpaceModifier {} +CaseTermList + : {$$ = NULL;} + | CaseTerm {} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} ; +*/ + + +/******************************************************************************* + * + * ASL Data and Constant Terms + * + ******************************************************************************/ DataObject : BufferData {} @@ -303,6 +341,94 @@ StringData | String {} ; +ByteConst + : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + ; + +WordConst + : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + ; + +DWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + ; + +QWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + ; + +/* + * The NODE_COMPILE_TIME_CONST flag in the following constant expressions + * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes + * to simple integers. It is an error if these types of expressions cannot be + * reduced, since the AML grammar for ****ConstExpr requires a simple constant. + * Note: The required byte length of the constant is passed through to the + * constant folding code in the node AmlLength field. + */ +ByteConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + | ByteConst {} + ; + +WordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + | WordConst {} + ; + +DWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + | DWordConst {} + ; + +QWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + | QWordConst {} + ; + +ConstTerm + : ConstExprTerm {} + | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} + ; + +ConstExprTerm + : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} + | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} + | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} + | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} + | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} + | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} + | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} + ; + +Integer + : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} + ; + +String + : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + + +/******************************************************************************* + * + * ASL Opcode Terms + * + ******************************************************************************/ + +CompilerDirective + : IncludeTerm {} + | IncludeEndTerm {} + | ExternalTerm {} + ; + NamedObject : BankFieldTerm {} | CreateBitFieldTerm {} @@ -331,40 +457,17 @@ NameSpaceModifier | ScopeTerm {} ; -MethodInvocationTerm - : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} - ArgList ')' {$$ = TrLinkChildNode ($1,$4);} - ; - -ArgList - : {$$ = NULL;} - | TermArg - | ArgList ',' /* Allows a trailing comma at list end */ - | ArgList ',' - TermArg {$$ = TrLinkPeerNode ($1,$3);} - ; - -/* -Removed from TermArg due to reduce/reduce conflicts - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - -*/ - -TermArg - : 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);} - | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - ; +/* For ObjectType: SuperName except for MethodInvocationTerm */ -Target - : {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ - | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} +ObjectTypeName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | RefOfTerm {} + | DerefOfTerm {} + | IndexTerm {} +/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ ; RequiredTarget @@ -377,46 +480,6 @@ SimpleTarget | ArgTerm {} ; -/* Rules for specifying the type of one method argument or return value */ - -ParameterTypePackage - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | ParameterTypePackage ',' - ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypePackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypePackage '}' {$$ = $2;} - ; - -OptionalParameterTypePackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - -/* Rules for specifying the types for method arguments */ - -ParameterTypesPackage - : ParameterTypePackageList {$$ = $1;} - | ParameterTypesPackage ',' - ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypesPackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypesPackage '}' {$$ = $2;} - ; - -OptionalParameterTypesPackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - - /* Opcode types */ Type1Opcode @@ -424,7 +487,8 @@ Type1Opcode | BreakPointTerm {} | ContinueTerm {} | FatalTerm {} - | IfElseTerm {} + | ForTerm {} + | ElseIfTerm {} | LoadTerm {} | NoOpTerm {} | NotifyTerm {} @@ -457,7 +521,6 @@ Type2Opcode /* * Type 3/4/5 opcodes */ - Type2IntegerOpcode /* "Type3" opcodes */ : Expression {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} | AddTerm {} @@ -515,7 +578,6 @@ Type2BufferOrStringOpcode /* * A type 3 opcode evaluates to an Integer and cannot have a destination operand */ - Type3Opcode : EISAIDTerm {} ; @@ -530,7 +592,6 @@ Type4Opcode ; */ - Type5Opcode : ResourceTemplateTerm {} | UnicodeTerm {} @@ -542,34 +603,74 @@ Type6Opcode : RefOfTerm {} | DerefOfTerm {} | IndexTerm {} + | IndexExpTerm {} | MethodInvocationTerm {} ; -IncludeTerm - : PARSEOP_INCLUDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);} - String ')' {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);} - TermList - IncludeEndTerm {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);} + +/******************************************************************************* + * + * ASL Primary Terms + * + ******************************************************************************/ + +AccessAsTerm + : PARSEOP_ACCESSAS '(' + AccessTypeKeyword + OptionalAccessAttribTerm + ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} + | PARSEOP_ACCESSAS '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -IncludeEndTerm - : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);} +AcquireTerm + : PARSEOP_ACQUIRE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} + SuperName + ',' WordConstExpr + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$6);} + | PARSEOP_ACQUIRE '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -ExternalTerm - : PARSEOP_EXTERNAL '(' - NameString - OptionalObjectTypeKeyword - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} - | PARSEOP_EXTERNAL '(' +AddTerm + : PARSEOP_ADD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_ADD '(' error ')' {$$ = AslDoError(); yyclearin;} ; +AliasTerm + : PARSEOP_ALIAS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);} + NameString + NameStringItem + ')' {$$ = TrLinkChildren ($<n>3,2,$4, + TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} + | PARSEOP_ALIAS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; -/******* Named Objects *******************************************************/ +AndTerm + : PARSEOP_AND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_AND '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; +ArgTerm + : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} + | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} + | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} + | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} + | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} + | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} + | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} + ; BankFieldTerm : PARSEOP_BANKFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} @@ -585,41 +686,54 @@ BankFieldTerm error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; -FieldUnitList - : {$$ = NULL;} - | FieldUnit - | FieldUnitList ',' /* Allows a trailing comma at list end */ - | FieldUnitList ',' - FieldUnit {$$ = TrLinkPeerNode ($1,$3);} +BreakTerm + : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} ; -FieldUnit - : FieldUnitEntry {} - | OffsetTerm {} - | AccessAsTerm {} - | ConnectionTerm {} +BreakPointTerm + : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} ; -FieldUnitEntry - : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} - | NameSeg ',' - AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} +BufferTerm + : PARSEOP_BUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);} + OptionalBufferLength + ')' '{' + BufferTermData '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_BUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -OffsetTerm - : PARSEOP_OFFSET '(' - AmlPackageLengthTerm - ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} - | PARSEOP_OFFSET '(' +BufferTermData + : ByteList {} + | StringData {} + ; + +CaseTerm + : PARSEOP_CASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);} + DataObject + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_CASE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -AccessAsTerm - : PARSEOP_ACCESSAS '(' - AccessTypeKeyword - OptionalAccessAttribTerm - ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} - | PARSEOP_ACCESSAS '(' +ConcatTerm + : PARSEOP_CONCATENATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_CONCATENATE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ConcatResTerm + : PARSEOP_CONCATENATERESTEMPLATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_CONCATENATERESTEMPLATE '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -638,6 +752,28 @@ ConnectionTerm error ')' {$$ = AslDoError(); yyclearin;} ; +CondRefOfTerm + : PARSEOP_CONDREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} + SuperName + Target + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_CONDREFOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ContinueTerm + : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} + ; + +CopyObjectTerm + : PARSEOP_COPYOBJECT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} + TermArg + ',' SimpleTarget + ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} + | PARSEOP_COPYOBJECT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + CreateBitFieldTerm : PARSEOP_CREATEBITFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} TermArg @@ -710,204 +846,64 @@ DataRegionTerm error ')' {$$ = AslDoError(); yyclearin;} ; -DeviceTerm - : PARSEOP_DEVICE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_DEVICE '(' - error ')' {$$ = AslDoError(); yyclearin;} +DebugTerm + : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} ; -EventTerm - : PARSEOP_EVENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);} - NameString - ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} - | PARSEOP_EVENT '(' +DecTerm + : PARSEOP_DECREMENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DECREMENT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -FieldTerm - : PARSEOP_FIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);} - NameString - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);} - | PARSEOP_FIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} +DefaultTerm + : PARSEOP_DEFAULT '{' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);} + TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DEFAULT '{' + error '}' {$$ = AslDoError(); yyclearin;} ; -FunctionTerm - : PARSEOP_FUNCTION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} - NameString - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), - TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} - | PARSEOP_FUNCTION '(' +DerefOfTerm + : PARSEOP_DEREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DEREFOF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -IndexFieldTerm - : PARSEOP_INDEXFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} - NameString - NameStringItem - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);} - | PARSEOP_INDEXFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -MethodTerm - : PARSEOP_METHOD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} +DeviceTerm + : PARSEOP_DEVICE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);} NameString - OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} - OptionalSerializeRuleKeyword - OptionalByteConstExpr - OptionalParameterTypePackage - OptionalParameterTypesPackage ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} - | PARSEOP_METHOD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MutexTerm - : PARSEOP_MUTEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);} - NameString - ',' ByteConstExpr - ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_MUTEX '(' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_DEVICE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -OpRegionTerm - : PARSEOP_OPERATIONREGION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} - NameString - ',' OpRegionSpaceIdTerm - TermArgItem +DivideTerm + : PARSEOP_DIVIDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} - | PARSEOP_OPERATIONREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -OpRegionSpaceIdTerm - : RegionSpaceKeyword {} - | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PowerResTerm - : PARSEOP_POWERRESOURCE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} - NameString - ',' ByteConstExpr - ',' WordConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} - | PARSEOP_POWERRESOURCE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ProcessorTerm - : PARSEOP_PROCESSOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} - NameString - ',' ByteConstExpr - OptionalDWordConstExpr - OptionalByteConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} - | PARSEOP_PROCESSOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ThermalZoneTerm - : PARSEOP_THERMALZONE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_THERMALZONE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Namespace modifiers *************************************************/ - - -AliasTerm - : PARSEOP_ALIAS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);} - NameString - NameStringItem - ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} - | PARSEOP_ALIAS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NameTerm - : PARSEOP_NAME '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);} - NameString - ',' DataObject - ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_NAME '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ScopeTerm - : PARSEOP_SCOPE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_SCOPE '(' + Target + Target + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);} + | PARSEOP_DIVIDE '(' error ')' {$$ = AslDoError(); yyclearin;} ; - -/******* Type 1 opcodes *******************************************************/ - - -BreakTerm - : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} - ; - -BreakPointTerm - : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} - ; - -ContinueTerm - : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} - ; - -FatalTerm - : PARSEOP_FATAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);} - ByteConstExpr - ',' DWordConstExpr - TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} - | PARSEOP_FATAL '(' +EISAIDTerm + : PARSEOP_EISAID '(' + StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} + | PARSEOP_EISAID '(' error ')' {$$ = AslDoError(); yyclearin;} ; -IfElseTerm +ElseIfTerm : IfTerm ElseTerm {$$ = TrLinkPeerNode ($1,$2);} ; -IfTerm - : PARSEOP_IF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IF);} - TermArg - ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - - | PARSEOP_IF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - ElseTerm : {$$ = NULL;} | PARSEOP_ELSE '{' {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);} @@ -933,275 +929,133 @@ ElseTerm error {$$ = AslDoError(); yyclearin;} ; -LoadTerm - : PARSEOP_LOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);} +EventTerm + : PARSEOP_EVENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);} NameString - RequiredTarget - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_LOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NoOpTerm - : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} - ; - -NotifyTerm - : PARSEOP_NOTIFY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);} - SuperName - TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_NOTIFY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReleaseTerm - : PARSEOP_RELEASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RELEASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ResetTerm - : PARSEOP_RESET '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RESET '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReturnTerm - : PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);} - OptionalReturnArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} - | PARSEOP_RETURN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SignalTerm - : PARSEOP_SIGNAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_SIGNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SleepTerm - : PARSEOP_SLEEP '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_SLEEP '(' + ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} + | PARSEOP_EVENT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -StallTerm - : PARSEOP_STALL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_STALL '(' +ExternalTerm + : PARSEOP_EXTERNAL '(' + NameString + OptionalObjectTypeKeyword + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} + | PARSEOP_EXTERNAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; -SwitchTerm - : PARSEOP_SWITCH '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);} - TermArg - ')' '{' - CaseDefaultTermList '}' - {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_SWITCH '(' +FatalTerm + : PARSEOP_FATAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);} + ByteConstExpr + ',' DWordConstExpr + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FATAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; -/* - * Case-Default list; allow only one Default term and unlimited Case terms - */ - -CaseDefaultTermList - : {$$ = NULL;} - | CaseTerm {} - | DefaultTerm {} - | CaseDefaultTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - | CaseDefaultTermList - DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} - -/* Original - attempts to force zero or one default term within the switch */ - -/* -CaseDefaultTermList - : {$$ = NULL;} - | CaseTermList - DefaultTerm - CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -CaseTermList - : {$$ = NULL;} - | CaseTerm {} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; -*/ - -CaseTerm - : PARSEOP_CASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);} - DataObject +FieldTerm + : PARSEOP_FIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);} + NameString + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_CASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DefaultTerm - : PARSEOP_DEFAULT '{' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);} - TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DEFAULT '{' - error '}' {$$ = AslDoError(); yyclearin;} - ; - -UnloadTerm - : PARSEOP_UNLOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_UNLOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WhileTerm - : PARSEOP_WHILE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} - TermArg - ')' '{' TermList '}' - {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_WHILE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Type 2 opcodes *******************************************************/ - -AcquireTerm - : PARSEOP_ACQUIRE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} - SuperName - ',' WordConstExpr - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$6);} - | PARSEOP_ACQUIRE '(' - error ')' {$$ = AslDoError(); yyclearin;} + FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);} + | PARSEOP_FIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; -AddTerm - : PARSEOP_ADD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} +FindSetLeftBitTerm + : PARSEOP_FINDSETLEFTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} TermArg - TermArgItem Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_ADD '(' + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FINDSETLEFTBIT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -AndTerm - : PARSEOP_AND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} +FindSetRightBitTerm + : PARSEOP_FINDSETRIGHTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} TermArg - TermArgItem Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_AND '(' + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FINDSETRIGHTBIT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -ConcatTerm - : PARSEOP_CONCATENATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_CONCATENATE '(' - error ')' {$$ = AslDoError(); yyclearin;} + /* Convert a For() loop to a While() loop */ +ForTerm + : PARSEOP_FOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} + OptionalTermArg ',' {} + OptionalPredicate ',' + OptionalTermArg {$<n>$ = TrLinkPeerNode ($4,$<n>3); + TrSetParent ($9,$<n>3);} /* New parent is WHILE */ + ')' '{' TermList '}' {$<n>$ = TrLinkChildren ($<n>3,2,$7,$13);} + {$<n>$ = TrLinkPeerNode ($13,$9); + $$ = $<n>10;} ; -ConcatResTerm - : PARSEOP_CONCATENATERESTEMPLATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_CONCATENATERESTEMPLATE '(' - error ')' {$$ = AslDoError(); yyclearin;} +OptionalPredicate + : {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, 1);} + | TermArg {$$ = $1;} ; -CondRefOfTerm - : PARSEOP_CONDREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} - SuperName - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_CONDREFOF '(' +FprintfTerm + : PARSEOP_FPRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FPRINTF);} + TermArg ',' + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FPRINTF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -CopyObjectTerm - : PARSEOP_COPYOBJECT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} +FromBCDTerm + : PARSEOP_FROMBCD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);} TermArg - ',' SimpleTarget - ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_COPYOBJECT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DecTerm - : PARSEOP_DECREMENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DECREMENT '(' + Target + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FROMBCD '(' error ')' {$$ = AslDoError(); yyclearin;} ; -DerefOfTerm - : PARSEOP_DEREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DEREFOF '(' +FunctionTerm + : PARSEOP_FUNCTION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), + TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} + | PARSEOP_FUNCTION '(' error ')' {$$ = AslDoError(); yyclearin;} ; -DivideTerm - : PARSEOP_DIVIDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} +IfTerm + : PARSEOP_IF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IF);} TermArg - TermArgItem - Target - Target - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);} - | PARSEOP_DIVIDE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} -FindSetLeftBitTerm - : PARSEOP_FINDSETLEFTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FINDSETLEFTBIT '(' + | PARSEOP_IF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -FindSetRightBitTerm - : PARSEOP_FINDSETRIGHTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FINDSETRIGHTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} +IncludeTerm + : PARSEOP_INCLUDE '(' + String ')' {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3); + FlOpenIncludeFile ($3);} ; -FromBCDTerm - : PARSEOP_FROMBCD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FROMBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} +IncludeEndTerm + : PARSEOP_INCLUDE_END {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE_END); TrSetCurrentFilename ($$);} ; IncTerm @@ -1212,6 +1066,19 @@ IncTerm error ')' {$$ = AslDoError(); yyclearin;} ; +IndexFieldTerm + : PARSEOP_INDEXFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} + NameString + NameStringItem + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword + ')' '{' + FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);} + | PARSEOP_INDEXFIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + ; + IndexTerm : PARSEOP_INDEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEX);} TermArg @@ -1240,6 +1107,15 @@ LEqualTerm error ')' {$$ = AslDoError(); yyclearin;} ; +LGreaterEqualTerm + : PARSEOP_LGREATEREQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg + TermArgItem + ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} + | PARSEOP_LGREATEREQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + LGreaterTerm : PARSEOP_LGREATER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg @@ -1249,12 +1125,12 @@ LGreaterTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LGreaterEqualTerm - : PARSEOP_LGREATEREQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} +LLessEqualTerm + : PARSEOP_LLESSEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg TermArgItem ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LGREATEREQUAL '(' + | PARSEOP_LLESSEQUAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1267,12 +1143,12 @@ LLessTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LLessEqualTerm - : PARSEOP_LLESSEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} +LNotEqualTerm + : PARSEOP_LNOTEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} TermArg TermArgItem ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LLESSEQUAL '(' + | PARSEOP_LNOTEQUAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1284,15 +1160,6 @@ LNotTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LNotEqualTerm - : PARSEOP_LNOTEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} - TermArg - TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LNOTEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - LoadTableTerm : PARSEOP_LOADTABLE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} TermArg @@ -1306,6 +1173,26 @@ LoadTableTerm error ')' {$$ = AslDoError(); yyclearin;} ; +LoadTerm + : PARSEOP_LOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);} + NameString + RequiredTarget + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_LOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LocalTerm + : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} + | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} + | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} + | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} + | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} + | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} + | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} + | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} + ; + LOrTerm : PARSEOP_LOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} TermArg @@ -1328,6 +1215,20 @@ MatchTerm error ')' {$$ = AslDoError(); yyclearin;} ; +MethodTerm + : PARSEOP_METHOD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} + OptionalSerializeRuleKeyword + OptionalByteConstExpr + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} + | PARSEOP_METHOD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + MidTerm : PARSEOP_MID '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MID);} TermArg @@ -1359,6 +1260,24 @@ MultiplyTerm error ')' {$$ = AslDoError(); yyclearin;} ; +MutexTerm + : PARSEOP_MUTEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);} + NameString + ',' ByteConstExpr + ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_MUTEX '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NameTerm + : PARSEOP_NAME '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);} + NameString + ',' DataObject + ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_NAME '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + NAndTerm : PARSEOP_NAND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAND);} TermArg @@ -1369,6 +1288,10 @@ NAndTerm error ')' {$$ = AslDoError(); yyclearin;} ; +NoOpTerm + : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} + ; + NOrTerm : PARSEOP_NOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOR);} TermArg @@ -1379,6 +1302,15 @@ NOrTerm error ')' {$$ = AslDoError(); yyclearin;} ; +NotifyTerm + : PARSEOP_NOTIFY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);} + SuperName + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_NOTIFY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + NotTerm : PARSEOP_NOT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} TermArg @@ -1396,6 +1328,30 @@ ObjectTypeTerm error ')' {$$ = AslDoError(); yyclearin;} ; +OffsetTerm + : PARSEOP_OFFSET '(' + AmlPackageLengthTerm + ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} + | PARSEOP_OFFSET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionTerm + : PARSEOP_OPERATIONREGION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} + NameString + ',' OpRegionSpaceIdTerm + TermArgItem + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} + | PARSEOP_OPERATIONREGION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionSpaceIdTerm + : RegionSpaceKeyword {} + | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + OrTerm : PARSEOP_OR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} TermArg @@ -1406,6 +1362,63 @@ OrTerm error ')' {$$ = AslDoError(); yyclearin;} ; +PackageTerm + : PARSEOP_PACKAGE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} + VarPackageLengthTerm + ')' '{' + PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_PACKAGE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PowerResTerm + : PARSEOP_POWERRESOURCE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} + NameString + ',' ByteConstExpr + ',' WordConstExpr + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} + | PARSEOP_POWERRESOURCE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PrintfTerm + : PARSEOP_PRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PRINTF);} + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_PRINTF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PrintfArgList + : {$$ = NULL;} + | TermArg {$$ = $1;} + | PrintfArgList ',' + TermArg {$$ = TrLinkPeerNode ($1, $3);} + ; + +ProcessorTerm + : PARSEOP_PROCESSOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} + NameString + ',' ByteConstExpr + OptionalDWordConstExpr + OptionalByteConstExpr + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} + | PARSEOP_PROCESSOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +RawDataBufferTerm + : PARSEOP_DATABUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} + OptionalWordConst + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_DATABUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + /* * In RefOf, the node isn't really a target, but we can't keep track of it after * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) @@ -1418,6 +1431,40 @@ RefOfTerm error ')' {$$ = AslDoError(); yyclearin;} ; +ReleaseTerm + : PARSEOP_RELEASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RELEASE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ResetTerm + : PARSEOP_RESET '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RESET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ReturnTerm + : PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);} + OptionalReturnArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} + | PARSEOP_RETURN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ScopeTerm + : PARSEOP_SCOPE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);} + NameString + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_SCOPE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + ShiftLeftTerm : PARSEOP_SHIFTLEFT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} TermArg @@ -1438,6 +1485,14 @@ ShiftRightTerm error ')' {$$ = AslDoError(); yyclearin;} ; +SignalTerm + : PARSEOP_SIGNAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_SIGNAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + SizeOfTerm : PARSEOP_SIZEOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIZEOF);} SuperName @@ -1446,6 +1501,22 @@ SizeOfTerm error ')' {$$ = AslDoError(); yyclearin;} ; +SleepTerm + : PARSEOP_SLEEP '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_SLEEP '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StallTerm + : PARSEOP_STALL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_STALL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + StoreTerm : PARSEOP_STORE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STORE);} TermArg @@ -1464,6 +1535,24 @@ SubtractTerm | PARSEOP_SUBTRACT '(' error ')' {$$ = AslDoError(); yyclearin;} ; +SwitchTerm + : PARSEOP_SWITCH '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);} + TermArg + ')' '{' + CaseDefaultTermList '}' + {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_SWITCH '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ThermalZoneTerm + : PARSEOP_THERMALZONE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} + NameString + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_THERMALZONE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; TimerTerm : PARSEOP_TIMER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TIMER);} @@ -1518,35 +1607,12 @@ 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);} +ToPLDTerm + : PARSEOP_TOPLD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOPLD);} + PldKeywordList + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_TOPLD '(' + error ')' {$$ = AslDoError(); yyclearin;} ; PldKeywordList @@ -1564,39 +1630,6 @@ PldKeywordList 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);} @@ -1615,6 +1648,22 @@ ToUUIDTerm error ')' {$$ = AslDoError(); yyclearin;} ; +UnicodeTerm + : PARSEOP_UNICODE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);} + StringData + ')' {$$ = TrLinkChildren ($<n>3,2,0,$4);} + | PARSEOP_UNICODE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UnloadTerm + : PARSEOP_UNLOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_UNLOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + WaitTerm : PARSEOP_WAIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WAIT);} SuperName @@ -1634,1105 +1683,21 @@ XOrTerm error ')' {$$ = AslDoError(); yyclearin;} ; - -/******* Keywords *************************************************************/ - - -AccessAttribKeyword - : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} - | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} - | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} - | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} - | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} - | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} - | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} - | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - ; - -AccessTypeKeyword - : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} - | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} - | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} - | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} - | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} - | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} - ; - -AddressingModeKeyword - : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} - | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} - ; - -AddressKeyword - : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} - | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} - | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} - | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} - ; - -AddressSpaceKeyword - : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} - | RegionSpaceKeyword {} - ; - -BitsPerByteKeyword - : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} - | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} - | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} - | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} - | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} - ; - -ClockPhaseKeyword - : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} - | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} - ; - -ClockPolarityKeyword - : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} - | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} - ; - -DecodeKeyword - : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} - | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} - ; - -DevicePolarityKeyword - : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} - | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} - ; - -DMATypeKeyword - : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} - | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} - | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} - | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} - ; - -EndianKeyword - : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} - | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} - ; - -FlowControlKeyword - : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} - | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} - | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} - ; - -InterruptLevel - : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} - | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} - | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} - ; - -InterruptTypeKeyword - : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} - | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} - ; - -IODecodeKeyword - : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} - | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} - ; - -IoRestrictionKeyword - : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} - | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} - | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} - | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} - ; - -LockRuleKeyword - : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} - | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} - ; - -MatchOpKeyword - : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} - | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} - | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} - | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} - | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} - | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} - ; - -MaxKeyword - : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} - | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} - ; - -MemTypeKeyword - : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} - | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} - | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} - | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} - ; - -MinKeyword - : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} - | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} - ; - -ObjectTypeKeyword - : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} - | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} - | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} - | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} - | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} - | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} - | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} - | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} - | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} - | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} - | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} - | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} - | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} - | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} - | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} - ; - -ParityTypeKeyword - : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} - | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} - | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} - | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} - | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} - ; - -PinConfigByte - : PinConfigKeyword {$$ = $1;} - | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PinConfigKeyword - : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} - | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} - | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} - | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} - ; - -RangeTypeKeyword - : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} - | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} - | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} - ; - -RegionSpaceKeyword - : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} - | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} - | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} - | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} - | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} - | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} - | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} - | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} - | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} - | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} - | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} - | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} - ; - -ResourceTypeKeyword - : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} - ; - -SerializeRuleKeyword - : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} - | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} - ; - -ShareTypeKeyword - : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} - | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} - | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} - | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} - ; - -SlaveModeKeyword - : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} - | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} - ; - -StopBitsKeyword - : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} - | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} - | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} - | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} - ; - -TranslationKeyword - : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} - | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} - ; - -TypeKeyword - : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} - | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} - ; - -UpdateRuleKeyword - : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} - | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} - | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} - ; - -WireModeKeyword - : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} - | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} - ; - -XferSizeKeyword - : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} - | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} - | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} - | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} - | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} - ; - -XferTypeKeyword - : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} - | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} - | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} - ; - - -/******* Miscellaneous Types **************************************************/ - - -SuperName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | Type6Opcode {} - -/* For ObjectType: SuperName except for MethodInvocationTerm */ - -ObjectTypeName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - -/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ - ; - -ArgTerm - : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} - | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} - | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} - | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} - | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} - | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} - | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} - ; - -LocalTerm - : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} - | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} - | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} - | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} - | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} - | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} - | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} - | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} - ; - -DebugTerm - : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} - ; - - -ByteConst - : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - ; - -WordConst - : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - ; - -DWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - ; - -QWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - ; - -Integer - : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} - ; - -String - : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - -ConstTerm - : ConstExprTerm {} - | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} - ; - -ConstExprTerm - : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} - | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} - | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} - | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} - | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} - | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} - | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} - ; - -/* - * The NODE_COMPILE_TIME_CONST flag in the following constant expressions - * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes - * to simple integers. It is an error if these types of expressions cannot be - * reduced, since the AML grammar for ****ConstExpr requires a simple constant. - * Note: The required byte length of the constant is passed through to the - * constant folding code in the node AmlLength field. - */ -ByteConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - | ByteConst {} - ; - -WordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - | WordConst {} - ; - -DWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - | DWordConst {} - ; - -QWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - | QWordConst {} - ; - -/* OptionalCount must appear before ByteList or an incorrect reduction will result */ - -OptionalCount - : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' TermArg {$$ = $2;} - ; - -BufferTerm - : PARSEOP_BUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);} - OptionalTermArg - ')' '{' - BufferTermData '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_BUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -BufferTermData - : ByteList {} - | StringData {} - ; - -ByteList - : {$$ = NULL;} - | ByteConstExpr - | ByteList ',' /* Allows a trailing comma at list end */ - | ByteList ',' - ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -DataBufferTerm - : PARSEOP_DATABUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} - OptionalWordConst - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_DATABUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordList - : {$$ = NULL;} - | DWordConstExpr - | DWordList ',' /* Allows a trailing comma at list end */ - | DWordList ',' - DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageTerm - : PARSEOP_PACKAGE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} - VarPackageLengthTerm - ')' '{' - PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_PACKAGE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -PackageList - : {$$ = NULL;} - | PackageElement - | PackageList ',' /* Allows a trailing comma at list end */ - | PackageList ',' - PackageElement {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageElement - : DataObject {} - | NameString {} - ; - -VarPackageLengthTerm - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | TermArg {$$ = $1;} - ; - - -/******* Macros ***********************************************/ - - -EISAIDTerm - : PARSEOP_EISAID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} - | PARSEOP_EISAID '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UnicodeTerm - : PARSEOP_UNICODE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);} - StringData - ')' {$$ = TrLinkChildren ($<n>3,2,0,$4);} - | PARSEOP_UNICODE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Resources and Memory ***********************************************/ - - -/* - * Note: Create two default nodes to allow conversion to a Buffer AML opcode - * Also, insert the EndTag at the end of the template. - */ -ResourceTemplateTerm - : PARSEOP_RESOURCETEMPLATE '(' ')' - '{' - ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - $5, - TrCreateLeafNode (PARSEOP_ENDTAG));} - ; - -ResourceMacroList - : {$$ = NULL;} - | ResourceMacroList - ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -ResourceMacroTerm - : DMATerm {} - | DWordIOTerm {} - | DWordMemoryTerm {} - | DWordSpaceTerm {} - | EndDependentFnTerm {} - | ExtendedIOTerm {} - | ExtendedMemoryTerm {} - | ExtendedSpaceTerm {} - | FixedDmaTerm {} - | FixedIOTerm {} - | GpioIntTerm {} - | GpioIoTerm {} - | I2cSerialBusTerm {} - | InterruptTerm {} - | IOTerm {} - | IRQNoFlagsTerm {} - | IRQTerm {} - | Memory24Term {} - | Memory32FixedTerm {} - | Memory32Term {} - | QWordIOTerm {} - | QWordMemoryTerm {} - | QWordSpaceTerm {} - | RegisterTerm {} - | SpiSerialBusTerm {} - | StartDependentFnNoPriTerm {} - | StartDependentFnTerm {} - | UartSerialBusTerm {} - | VendorLongTerm {} - | VendorShortTerm {} - | WordBusNumberTerm {} - | WordIOTerm {} - | WordSpaceTerm {} - ; - -DMATerm - : PARSEOP_DMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DMA);} - DMATypeKeyword - OptionalBusMasterKeyword - ',' XferTypeKeyword - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);} - | PARSEOP_DMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordIOTerm - : PARSEOP_DWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_DWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordMemoryTerm - : PARSEOP_DWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_DWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordSpaceTerm - : PARSEOP_DWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_DWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -EndDependentFnTerm - : PARSEOP_ENDDEPENDENTFN '(' - ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} - | PARSEOP_ENDDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedIOTerm - : PARSEOP_EXTENDEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} - | PARSEOP_EXTENDEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedMemoryTerm - : PARSEOP_EXTENDEDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} - | PARSEOP_EXTENDEDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedSpaceTerm - : PARSEOP_EXTENDEDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} - | PARSEOP_EXTENDEDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedDmaTerm - : PARSEOP_FIXEDDMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} - WordConstExpr /* 04: DMA RequestLines */ - ',' WordConstExpr /* 06: DMA Channels */ - OptionalXferSize /* 07: DMA TransferSize */ - OptionalNameString /* 08: DescriptorName */ - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);} - | PARSEOP_FIXEDDMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedIOTerm - : PARSEOP_FIXEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} - WordConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} - | PARSEOP_FIXEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIntTerm - : PARSEOP_GPIO_INT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} - InterruptTypeKeyword /* 04: InterruptType */ - ',' InterruptLevel /* 06: InterruptLevel */ - OptionalShareType /* 07: SharedType */ - ',' PinConfigByte /* 09: PinConfig */ - OptionalWordConstExpr /* 10: DebounceTimeout */ - ',' StringData /* 12: ResourceSource */ - OptionalByteConstExpr /* 13: ResourceSourceIndex */ - OptionalResourceType /* 14: ResourceType */ - OptionalNameString /* 15: DescriptorName */ - OptionalBuffer_Last /* 16: VendorData */ - ')' '{' - DWordConstExpr '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} - | PARSEOP_GPIO_INT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIoTerm - : PARSEOP_GPIO_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} - OptionalShareType_First /* 04: SharedType */ - ',' PinConfigByte /* 06: PinConfig */ - OptionalWordConstExpr /* 07: DebounceTimeout */ - OptionalWordConstExpr /* 08: DriveStrength */ - OptionalIoRestriction /* 09: IoRestriction */ - ',' StringData /* 11: ResourceSource */ - OptionalByteConstExpr /* 12: ResourceSourceIndex */ - OptionalResourceType /* 13: ResourceType */ - OptionalNameString /* 14: DescriptorName */ - OptionalBuffer_Last /* 15: VendorData */ - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} - | PARSEOP_GPIO_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -I2cSerialBusTerm - : PARSEOP_I2C_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} - WordConstExpr /* 04: SlaveAddress */ - OptionalSlaveMode /* 05: SlaveMode */ - ',' DWordConstExpr /* 07: ConnectionSpeed */ - OptionalAddressingMode /* 08: AddressingMode */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);} - | PARSEOP_I2C_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -InterruptTerm - : PARSEOP_INTERRUPT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} - OptionalResourceType_First - ',' InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);} - | PARSEOP_INTERRUPT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IOTerm - : PARSEOP_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IO);} - IODecodeKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' ByteConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQNoFlagsTerm - : PARSEOP_IRQNOFLAGS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_IRQNOFLAGS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQTerm - : PARSEOP_IRQ '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQ);} - InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);} - | PARSEOP_IRQ '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory24Term - : PARSEOP_MEMORY24 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY24);} - OptionalReadWriteKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY24 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32FixedTerm - : PARSEOP_MEMORY32FIXED '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);} - | PARSEOP_MEMORY32FIXED '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32Term - : PARSEOP_MEMORY32 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY32 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordIOTerm - : PARSEOP_QWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_QWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordMemoryTerm - : PARSEOP_QWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_QWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordSpaceTerm - : PARSEOP_QWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_QWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -RegisterTerm - : PARSEOP_REGISTER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_REGISTER);} - AddressSpaceKeyword - ',' ByteConstExpr - ',' ByteConstExpr - ',' QWordConstExpr - OptionalAccessSize - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);} - | PARSEOP_REGISTER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SpiSerialBusTerm - : PARSEOP_SPI_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} - WordConstExpr /* 04: DeviceSelection */ - OptionalDevicePolarity /* 05: DevicePolarity */ - OptionalWireMode /* 06: WireMode */ - ',' ByteConstExpr /* 08: DataBitLength */ - OptionalSlaveMode /* 09: SlaveMode */ - ',' DWordConstExpr /* 11: ConnectionSpeed */ - ',' ClockPolarityKeyword /* 13: ClockPolarity */ - ',' ClockPhaseKeyword /* 15: ClockPhase */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_SPI_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnNoPriTerm - : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,1,$6);} - | PARSEOP_STARTDEPENDENTFN_NOPRI '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnTerm - : PARSEOP_STARTDEPENDENTFN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} - ByteConstExpr - ',' ByteConstExpr - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);} - | PARSEOP_STARTDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UartSerialBusTerm - : PARSEOP_UART_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} - DWordConstExpr /* 04: ConnectionSpeed */ - OptionalBitsPerByte /* 05: BitsPerByte */ - OptionalStopBits /* 06: StopBits */ - ',' ByteConstExpr /* 08: LinesInUse */ - OptionalEndian /* 09: Endianess */ - OptionalParityType /* 10: Parity */ - OptionalFlowControl /* 11: FlowControl */ - ',' WordConstExpr /* 13: Rx BufferSize */ - ',' WordConstExpr /* 15: Tx BufferSize */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_UART_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorLongTerm - : PARSEOP_VENDORLONG '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_VENDORLONG '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorShortTerm - : PARSEOP_VENDORSHORT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_VENDORSHORT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordBusNumberTerm - : PARSEOP_WORDBUSNUMBER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} - | PARSEOP_WORDBUSNUMBER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordIOTerm - : PARSEOP_WORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_WORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordSpaceTerm - : PARSEOP_WORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_WORDSPACE '(' +WhileTerm + : PARSEOP_WHILE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} + TermArg + ')' '{' TermList '}' + {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_WHILE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -/******* Object References ***********************************************/ - -/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ - -NameString - : NameSeg {} - | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} - | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} - | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} - | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} - ; - -NameSeg - : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - - -/******* Helper rules ****************************************************/ - +/******************************************************************************* + * + * ASL Helper Terms + * + ******************************************************************************/ AmlPackageLengthTerm : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);} @@ -2748,166 +1713,12 @@ TermArgItem | ',' error {$$ = AslDoError (); yyclearin;} ; -OptionalBusMasterKeyword - : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} - ; - -OptionalAccessAttribTerm - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - | ',' AccessAttribKeyword {$$ = $2;} - ; - -OptionalAccessSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalAddressingMode - : ',' {$$ = NULL;} - | ',' AddressingModeKeyword {$$ = $2;} - ; - -OptionalAddressRange - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' AddressKeyword {$$ = $2;} - ; - -OptionalBitsPerByte - : ',' {$$ = NULL;} - | ',' BitsPerByteKeyword {$$ = $2;} - ; - -OptionalBuffer_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DataBufferTerm {$$ = $2;} - ; - -OptionalByteConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalDecodeType - : ',' {$$ = NULL;} - | ',' DecodeKeyword {$$ = $2;} - ; - -OptionalDevicePolarity - : ',' {$$ = NULL;} - | ',' DevicePolarityKeyword {$$ = $2;} - ; - -OptionalDWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DWordConstExpr {$$ = $2;} - ; - -OptionalEndian - : ',' {$$ = NULL;} - | ',' EndianKeyword {$$ = $2;} - ; - -OptionalFlowControl - : ',' {$$ = NULL;} - | ',' FlowControlKeyword {$$ = $2;} - ; - -OptionalIoRestriction - : ',' {$$ = NULL;} - | ',' IoRestrictionKeyword {$$ = $2;} - ; - -OptionalListString - : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' TermArg {$$ = $2;} - ; - -OptionalMaxType - : ',' {$$ = NULL;} - | ',' MaxKeyword {$$ = $2;} - ; - -OptionalMemType - : ',' {$$ = NULL;} - | ',' MemTypeKeyword {$$ = $2;} - ; - -OptionalMinType - : ',' {$$ = NULL;} - | ',' MinKeyword {$$ = $2;} - ; - -OptionalNameString - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_First - : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} - | NameString {$$ = $1;} - ; - -OptionalObjectTypeKeyword - : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | ',' ObjectTypeKeyword {$$ = $2;} - ; - -OptionalParityType - : ',' {$$ = NULL;} - | ',' ParityTypeKeyword {$$ = $2;} - ; - -OptionalQWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' QWordConstExpr {$$ = $2;} - ; - -OptionalRangeType - : ',' {$$ = NULL;} - | ',' RangeTypeKeyword {$$ = $2;} - ; - -OptionalReadWriteKeyword - : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} - ; - OptionalReference : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ | ',' {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ | ',' TermArg {$$ = $2;} ; -OptionalResourceType_First - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ResourceTypeKeyword {$$ = $1;} - ; - -OptionalResourceType - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' ResourceTypeKeyword {$$ = $2;} - ; - OptionalReturnArg : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ | TermArg {$$ = $1;} @@ -2919,73 +1730,17 @@ OptionalSerializeRuleKeyword | ',' SerializeRuleKeyword {$$ = $2;} ; -OptionalSlaveMode - : ',' {$$ = NULL;} - | ',' SlaveModeKeyword {$$ = $2;} - ; - -OptionalShareType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ShareTypeKeyword {$$ = $2;} - ; - -OptionalShareType_First - : {$$ = NULL;} - | ShareTypeKeyword {$$ = $1;} - ; - -OptionalStopBits - : ',' {$$ = NULL;} - | ',' StopBitsKeyword {$$ = $2;} - ; - -OptionalStringData - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' StringData {$$ = $2;} - ; - OptionalTermArg - : {$$ = NULL;} + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} | TermArg {$$ = $1;} ; -OptionalType +OptionalBufferLength : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalTranslationType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TranslationKeyword {$$ = $2;} - ; - -OptionalWireMode - : ',' {$$ = NULL;} - | ',' WireModeKeyword {$$ = $2;} + | TermArg {$$ = $1;} ; OptionalWordConst : {$$ = NULL;} | WordConst {$$ = $1;} ; - -OptionalWordConstExpr - : ',' {$$ = NULL;} - | ',' WordConstExpr {$$ = $2;} - ; - -OptionalXferSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' XferSizeKeyword {$$ = $2;} - ; diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c index 85e2f88..cd3bb94 100644 --- a/sys/contrib/dev/acpica/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/compiler/aslstartup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -144,62 +144,63 @@ AslDetectSourceFileType ( ASL_FILE_INFO *Info) { char *FileChar; - UINT8 Type; + UINT8 Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */ ACPI_STATUS Status; - /* Check for a valid binary ACPI table */ + /* Check for 100% ASCII source file (comments are ignored) */ - Status = FlCheckForAcpiTable (Info->Handle); + Status = FlIsFileAsciiSource (Info->Filename, FALSE); if (ACPI_SUCCESS (Status)) { - Type = ASL_INPUT_TYPE_ACPI_TABLE; - goto Cleanup; - } + /* + * File contains ASCII source code. Determine if this is an ASL + * file or an ACPI data table file. + */ + while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) + { + /* Uppercase the buffer for caseless compare */ - /* Check for 100% ASCII source file (comments are ignored) */ + FileChar = Gbl_CurrentLineBuffer; + while (*FileChar) + { + *FileChar = (char) toupper ((int) *FileChar); + FileChar++; + } - Status = FlCheckForAscii (Info->Filename, TRUE); - if (ACPI_FAILURE (Status)) - { - printf ("Invalid characters in input file - %s\n", Info->Filename); + /* Presence of "DefinitionBlock" indicates actual ASL code */ - if (!Gbl_IgnoreErrors) - { - Type = ASL_INPUT_TYPE_BINARY; - goto Cleanup; + if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) + { + /* Appears to be an ASL file */ + + Type = ASL_INPUT_TYPE_ASCII_ASL; + goto Cleanup; + } } - } - /* - * File is ASCII. Determine if this is an ASL file or an ACPI data - * table file. - */ - while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) - { - /* Uppercase the buffer for caseless compare */ + /* Appears to be an ASCII data table source file */ - FileChar = Gbl_CurrentLineBuffer; - while (*FileChar) - { - *FileChar = (char) toupper ((int) *FileChar); - FileChar++; - } + Type = ASL_INPUT_TYPE_ASCII_DATA; + goto Cleanup; + } - /* Presence of "DefinitionBlock" indicates actual ASL code */ + /* We have some sort of binary table, check for valid ACPI table */ - if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) - { - /* Appears to be an ASL file */ + fseek (Info->Handle, 0, SEEK_SET); - Type = ASL_INPUT_TYPE_ASCII_ASL; - goto Cleanup; - } + Status = AcValidateTableHeader (Info->Handle, 0); + if (ACPI_SUCCESS (Status)) + { + fprintf (stderr, + "Binary file appears to be a valid ACPI table, disassembling\n"); + + Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; + goto Cleanup; } - /* Not an ASL source file, default to a data table source file */ + Type = ASL_INPUT_TYPE_BINARY; - Type = ASL_INPUT_TYPE_ASCII_DATA; Cleanup: @@ -246,9 +247,14 @@ AslDoDisassembly ( return (Status); } + /* Handle additional output files for disassembler */ + + Gbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; + Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); + /* This is where the disassembly happens */ - AcpiGbl_DbOpt_Disasm = TRUE; + AcpiGbl_DmOpt_Disasm = TRUE; Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix, &Gbl_Files[ASL_FILE_INPUT].Filename); @@ -261,13 +267,6 @@ AslDoDisassembly ( AcpiDmUnresolvedWarning (0); -#if 0 - /* TBD: Handle additional output files for disassembler */ - - Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); - NsDisplayNamespace (); -#endif - /* Shutdown compiler and ACPICA subsystem */ AeClearErrorLog (); @@ -359,6 +358,8 @@ AslDoOneFile ( return (AE_ERROR); } + Gbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT); + /* Determine input file type */ Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]); @@ -454,7 +455,7 @@ AslDoOneFile ( /* * Binary ACPI table was auto-detected, disassemble it */ - case ASL_INPUT_TYPE_ACPI_TABLE: + case ASL_INPUT_TYPE_BINARY_ACPI_TABLE: /* We have what appears to be an ACPI table, disassemble it */ diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index 2259255..2d8d21c 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,6 +64,13 @@ AcpiNsExecModuleCodeList ( } ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, @@ -120,6 +127,13 @@ AcpiDsStoreObjectToLocal ( } ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue) @@ -165,15 +179,6 @@ AcpiEvInitializeRegion ( return (AE_OK); } -void -AcpiExDoDebugObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - UINT32 Level, - UINT32 Index) -{ - return; -} - ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, @@ -216,6 +221,60 @@ AcpiExLoadOp ( return (AE_SUPPORT); } +void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + return; +} + +void +AcpiExStartTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStopTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStartTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStopTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) + +{ + return; +} + +void +AcpiExTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname) +{ + return; +} + ACPI_STATUS AcpiTbFindTable ( char *Signature, @@ -225,3 +284,45 @@ AcpiTbFindTable ( { return (AE_SUPPORT); } + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + return (AE_OK); +} + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l index b3149cf..deb9e9a 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/compiler/aslsupport.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,6 +113,7 @@ AslDoLineDirective ( char *Filename; UINT32 i; + Gbl_HasIncludeFiles = TRUE; /* Eat the entire line that contains the #line directive */ @@ -195,9 +196,13 @@ AslPopInputFileStack ( ASL_FILE_NODE *Fnode; + Gbl_PreviousIncludeFilename = Gbl_Files[ASL_FILE_INPUT].Filename; Fnode = Gbl_IncludeFileStack; DbgPrint (ASL_PARSE_OUTPUT, - "\nPop InputFile Stack, Fnode %p\n\n", Fnode); + "\nPop InputFile Stack, Fnode %p\n", Fnode); + + DbgPrint (ASL_PARSE_OUTPUT, + "Include: Closing \"%s\"\n\n", Gbl_Files[ASL_FILE_INPUT].Filename); if (!Fnode) { @@ -713,7 +718,7 @@ DoCharacter: * string and resume processing of the next character */ ConvertBuffer[i] = 0; - Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); + Digit = (UINT8) strtoul (ConvertBuffer, NULL, 8); /* Check for NULL or non-ascii character (ignore if so) */ @@ -749,7 +754,7 @@ DoCharacter: /* Up to two hex digits allowed */ - if (!ACPI_IS_XDIGIT (StringChar) || + if (!isxdigit (StringChar) || (i > 1)) { /* @@ -757,7 +762,7 @@ DoCharacter: * string and resume processing of the next character */ ConvertBuffer[i] = 0; - Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); + Digit = (UINT8) strtoul (ConvertBuffer, NULL, 16); /* Check for NULL or non-ascii character (ignore if so) */ @@ -830,7 +835,7 @@ CompletedString: return (FALSE); } - ACPI_STRCPY (CleanString, MsgBuffer); + strcpy (CleanString, MsgBuffer); AslCompilerlval.s = CleanString; return (TRUE); diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.y b/sys/contrib/dev/acpica/compiler/aslsupport.y index ba81b7d..cd2605b 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.y +++ b/sys/contrib/dev/acpica/compiler/aslsupport.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/asltokens.y b/sys/contrib/dev/acpica/compiler/asltokens.y index 511fa9b..429fa42 100644 --- a/sys/contrib/dev/acpica/compiler/asltokens.y +++ b/sys/contrib/dev/acpica/compiler/asltokens.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,7 +124,7 @@ NoEcho(' %token <i> PARSEOP_DECREMENT %token <i> PARSEOP_DEFAULT %token <i> PARSEOP_DEFAULT_ARG -%token <i> PARSEOP_DEFINITIONBLOCK +%token <i> PARSEOP_DEFINITION_BLOCK %token <i> PARSEOP_DEREFOF %token <i> PARSEOP_DEVICE %token <i> PARSEOP_DEVICEPOLARITY_HIGH @@ -166,6 +166,7 @@ NoEcho(' %token <i> PARSEOP_GPIO_INT %token <i> PARSEOP_GPIO_IO %token <i> PARSEOP_I2C_SERIALBUS +%token <i> PARSEOP_I2C_SERIALBUS_V2 %token <i> PARSEOP_IF %token <i> PARSEOP_INCLUDE %token <i> PARSEOP_INCLUDE_END @@ -323,6 +324,7 @@ NoEcho(' %token <i> PARSEOP_SLAVEMODE_DEVICEINIT %token <i> PARSEOP_SLEEP %token <i> PARSEOP_SPI_SERIALBUS +%token <i> PARSEOP_SPI_SERIALBUS_V2 %token <i> PARSEOP_STALL %token <i> PARSEOP_STARTDEPENDENTFN %token <i> PARSEOP_STARTDEPENDENTFN_NOPRI @@ -348,6 +350,7 @@ NoEcho(' %token <i> PARSEOP_TYPE_STATIC %token <i> PARSEOP_TYPE_TRANSLATION %token <i> PARSEOP_UART_SERIALBUS +%token <i> PARSEOP_UART_SERIALBUS_V2 %token <i> PARSEOP_UNICODE %token <i> PARSEOP_UNLOAD %token <i> PARSEOP_UPDATERULE_ONES @@ -452,12 +455,24 @@ NoEcho(' %left <i> PARSEOP_EXP_INCREMENT PARSEOP_EXP_DECREMENT +/* Brackets for Index() support */ + +%left <i> PARSEOP_EXP_INDEX_LEFT +%right <i> PARSEOP_EXP_INDEX_RIGHT + +/* Macros */ + %token <i> PARSEOP_PRINTF %token <i> PARSEOP_FPRINTF +%token <i> PARSEOP_FOR + /* Specific parentheses tokens are not used at this time */ /* PARSEOP_EXP_PAREN_OPEN */ /* PARSEOP_EXP_PAREN_CLOSE */ + +%token <i> PARSEOP_ASL_CODE + /* * Special functions. These should probably stay at the end of this * table. diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index c46801b..cc87390 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,7 +111,7 @@ TrAmlGetNextTempName ( char *TempName; - if (*TempCount >= (10+26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */ + if (*TempCount >= (10 + 26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */ { /* Too many temps */ @@ -129,6 +129,7 @@ TrAmlGetNextTempName ( { TempName[3] = (char) (*TempCount + ('A' - 10)); } + (*TempCount)++; /* First three characters are always "_T_" */ @@ -217,7 +218,7 @@ TrAmlSetSubtreeParent ( while (Next) { Next->Asl.Parent = Parent; - Next = Next->Asl.Next; + Next = Next->Asl.Next; } } @@ -242,13 +243,13 @@ TrAmlInsertPeer ( { NewPeer->Asl.Next = Op->Asl.Next; - Op->Asl.Next = NewPeer; + Op->Asl.Next = NewPeer; } /******************************************************************************* * - * FUNCTION: TrAmlTransformWalk + * FUNCTION: TrAmlTransformWalkBegin * * PARAMETERS: ASL_WALK_CALLBACK * @@ -260,7 +261,7 @@ TrAmlInsertPeer ( ******************************************************************************/ ACPI_STATUS -TrAmlTransformWalk ( +TrAmlTransformWalkBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) @@ -273,6 +274,38 @@ TrAmlTransformWalk ( /******************************************************************************* * + * FUNCTION: TrAmlTransformWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML + * operands. + * + ******************************************************************************/ + +ACPI_STATUS +TrAmlTransformWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + /* Save possible Externals list in the DefintionBlock Op */ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + Op->Asl.Value.Arg = Gbl_ExternalsListHead; + Gbl_ExternalsListHead = NULL; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: TrTransformSubtree * * PARAMETERS: Op - The parent parse node @@ -297,7 +330,7 @@ TrTransformSubtree ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: TrDoDefinitionBlock (Op); break; @@ -315,6 +348,15 @@ TrTransformSubtree ( Gbl_TempCount = 0; break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == TRUE) + { + ExDoExternal (Op); + } + + break; + default: /* Nothing to do here for other opcodes */ @@ -346,6 +388,10 @@ TrDoDefinitionBlock ( UINT32 i; + /* Reset external list when starting a definition block */ + + Gbl_ExternalsListHead = NULL; + Next = Op->Asl.Child; for (i = 0; i < 5; i++) { @@ -448,7 +494,7 @@ TrDoSwitch ( { /* Add an ELSE to complete the previous CASE */ - NewOp = TrCreateLeafNode (PARSEOP_ELSE); + NewOp = TrCreateLeafNode (PARSEOP_ELSE); NewOp->Asl.Parent = Conditional->Asl.Parent; TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent); @@ -458,9 +504,9 @@ TrDoSwitch ( CurrentParentNode = NewOp; } - CaseOp = Next; + CaseOp = Next; Conditional = CaseOp; - CaseBlock = CaseOp->Asl.Child->Asl.Next; + CaseBlock = CaseOp->Asl.Child->Asl.Next; Conditional->Asl.Child->Asl.Next = NULL; Predicate = CaseOp->Asl.Child; @@ -537,7 +583,7 @@ TrDoSwitch ( * CaseOp->Child->Peer is the beginning of the case block */ NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); NewOp->Asl.Next = Predicate; TrAmlInitLineNumbers (NewOp, Predicate); @@ -600,7 +646,7 @@ TrDoSwitch ( /* Unknown peer opcode */ AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%u)\n", - Next->Asl.ParseOpName, Next->Asl.ParseOpcode); + Next->Asl.ParseOpName, Next->Asl.ParseOpcode); } } @@ -645,7 +691,7 @@ TrDoSwitch ( Next = StartNode; while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) && - (Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK)) + (Next->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK)) { Next = Next->Asl.Parent; } @@ -668,7 +714,8 @@ TrDoSwitch ( */ if (Next->Asl.ParseOpcode != PARSEOP_SERIALIZERULE_SERIAL) { - AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, "Due to use of Switch operator"); + AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, + "Due to use of Switch operator"); Next->Asl.ParseOpcode = PARSEOP_SERIALIZERULE_SERIAL; } @@ -682,7 +729,7 @@ TrDoSwitch ( /* Create the NameSeg child for the Name node */ NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); TrAmlInitLineNumbers (NewOp2, NewOp); NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION; NewOp->Asl.Child = NewOp2; @@ -694,25 +741,25 @@ TrDoSwitch ( case ACPI_BTYPE_INTEGER: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO, - (UINT64) 0); + (UINT64) 0); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_STRING: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, - (UINT64) ACPI_TO_INTEGER ("")); + (UINT64) ACPI_TO_INTEGER ("")); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_BUFFER: (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER, - (UINT64) 0)); + (UINT64) 0)); Next = NewOp2->Asl.Next; TrAmlInitLineNumbers (Next, NewOp2); (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO, - (UINT64) 1)); + (UINT64) 1)); TrAmlInitLineNumbers (Next->Asl.Child, Next); BufferOp = TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (UINT64) 0); @@ -755,7 +802,7 @@ TrDoSwitch ( Predicate->Asl.Parent = StoreOp; NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); TrAmlInitLineNumbers (NewOp, StoreOp); NewOp->Asl.Parent = StoreOp; Predicate->Asl.Next = NewOp; diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index 68d8072..d2f128e 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,29 @@ TrGetNextNode ( /******************************************************************************* * + * FUNCTION: TrSetParent + * + * PARAMETERS: Op - To be set to new parent + * ParentOp - The parent + * + * RETURN: None, sets Op parent directly + * + * DESCRIPTION: Change the parent of a parse op. + * + ******************************************************************************/ + +void +TrSetParent ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *ParentOp) +{ + + Op->Asl.Parent = ParentOp; +} + + +/******************************************************************************* + * * FUNCTION: TrGetNextNode * * PARAMETERS: None @@ -157,10 +180,30 @@ TrReleaseNode ( /******************************************************************************* * + * FUNCTION: TrSetCurrentFilename + * + * PARAMETERS: Op - An existing parse node + * + * RETURN: None + * + * DESCRIPTION: Save the include file filename. Used for debug output only. + * + ******************************************************************************/ + +void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op) +{ + Op->Asl.Filename = Gbl_PreviousIncludeFilename; +} + + +/******************************************************************************* + * * FUNCTION: TrUpdateNode * * PARAMETERS: ParseOpcode - New opcode to be assigned to the node - * Op - An existing parse node + * Op - An existing parse node * * RETURN: The updated node * @@ -340,6 +383,11 @@ TrPrintNodeCompileFlags ( FlagName = "NODE_METHOD_TYPED"; break; + case NODE_COULD_NOT_REDUCE: + + FlagName = "NODE_COULD_NOT_REDUCE"; + break; + case NODE_COMPILE_TIME_CONST: FlagName = "NODE_COMPILE_TIME_CONST"; @@ -489,7 +537,7 @@ TrSetEndLineNumber ( return; } - Op->Asl.EndLine = Gbl_CurrentLineNumber; + Op->Asl.EndLine = Gbl_CurrentLineNumber; Op->Asl.EndLogicalLine = Gbl_LogicalLineNumber; } @@ -538,6 +586,7 @@ TrCreateAssignmentNode ( case PARSEOP_ADD: case PARSEOP_AND: case PARSEOP_DIVIDE: + case PARSEOP_INDEX: case PARSEOP_MOD: case PARSEOP_MULTIPLY: case PARSEOP_NOT: @@ -752,7 +801,8 @@ TrCreateConstantLeafNode ( } DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X \n", + "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p " + "Op %s Value %8.8X%8.8X \n", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode), ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); return (Op); @@ -859,7 +909,8 @@ TrCreateValuedLeafNode ( Op = TrAllocateNode (ParseOpcode); DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ", + "\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p " + "Op %s Value %8.8X%8.8X ", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode), ACPI_FORMAT_UINT64 (Value)); Op->Asl.Value.Integer = Value; @@ -945,15 +996,22 @@ TrCreateNode ( DbgPrint (ASL_PARSE_OUTPUT, "\nCreateNode Ln/Col %u/%u NewParent %p Child %u Op %s ", - Op->Asl.LineNumber, Op->Asl.Column, Op, NumChildren, UtGetOpName(ParseOpcode)); + Op->Asl.LineNumber, Op->Asl.Column, Op, + NumChildren, UtGetOpName(ParseOpcode)); /* Some extra debug output based on the parse opcode */ switch (ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ASL_CODE: + + Gbl_ParseTreeRoot = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: - RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1074,9 +1132,15 @@ TrLinkChildren ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ASL_CODE: + + Gbl_ParseTreeRoot = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: - RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1154,6 +1218,7 @@ TrLinkChildren ( Child = Child->Asl.Next; Child->Asl.Parent = Op; } + PrevChild = Child; } @@ -1375,7 +1440,7 @@ TrWalkParseTree ( ACPI_STATUS Status; - if (!RootNode) + if (!Gbl_ParseTreeRoot) { return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 4bd24da..411faed 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ #define NODE_METHOD_SOME_NO_RETVAL 0x00000200 #define NODE_RESULT_NOT_USED 0x00000400 #define NODE_METHOD_TYPED 0x00000800 -#define NODE_UNUSED_FLAG 0x00001000 +#define NODE_COULD_NOT_REDUCE 0x00001000 #define NODE_COMPILE_TIME_CONST 0x00002000 #define NODE_IS_TERM_ARG 0x00004000 #define NODE_WAS_ONES_OP 0x00008000 @@ -81,6 +81,7 @@ typedef struct asl_method_info { ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *CurrentOp; struct asl_method_info *Next; UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; UINT32 ValidReturnTypes; @@ -148,32 +149,57 @@ typedef struct asl_file_status /* * File types. Note: Any changes to this table must also be reflected * in the Gbl_Files array. + * + * Corresponding filename suffixes are in comments + * + * NOTE: Don't move the first 4 file types */ typedef enum { ASL_FILE_STDOUT = 0, ASL_FILE_STDERR, - ASL_FILE_INPUT, - ASL_FILE_AML_OUTPUT, /* Don't move these first 4 file types */ - ASL_FILE_SOURCE_OUTPUT, - ASL_FILE_PREPROCESSOR, - ASL_FILE_LISTING_OUTPUT, - ASL_FILE_HEX_OUTPUT, - ASL_FILE_NAMESPACE_OUTPUT, - ASL_FILE_DEBUG_OUTPUT, - ASL_FILE_ASM_SOURCE_OUTPUT, - ASL_FILE_C_SOURCE_OUTPUT, - ASL_FILE_ASM_INCLUDE_OUTPUT, - ASL_FILE_C_INCLUDE_OUTPUT, - ASL_FILE_C_OFFSET_OUTPUT, - ASL_FILE_MAP_OUTPUT + ASL_FILE_INPUT, /* .asl */ + ASL_FILE_AML_OUTPUT, /* .aml */ + ASL_FILE_SOURCE_OUTPUT, /* .src */ + ASL_FILE_PREPROCESSOR, /* .pre */ + ASL_FILE_PREPROCESSOR_USER, /* .i */ + ASL_FILE_LISTING_OUTPUT, /* .lst */ + ASL_FILE_HEX_OUTPUT, /* .hex */ + ASL_FILE_NAMESPACE_OUTPUT, /* .nsp */ + ASL_FILE_DEBUG_OUTPUT, /* .txt */ + ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */ + ASL_FILE_C_SOURCE_OUTPUT, /* .c */ + ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */ + ASL_FILE_C_INCLUDE_OUTPUT, /* .h */ + ASL_FILE_C_OFFSET_OUTPUT, /* .offset.h */ + ASL_FILE_MAP_OUTPUT, /* .map */ + ASL_FILE_XREF_OUTPUT /* .xrf */ } ASL_FILE_TYPES; -#define ASL_MAX_FILE_TYPE 15 +#define ASL_MAX_FILE_TYPE 17 #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +/* Name suffixes used to create filenames for output files */ + +#define FILE_SUFFIX_ASL_CODE "asl" +#define FILE_SUFFIX_AML_CODE "aml" +#define FILE_SUFFIX_SOURCE "src" +#define FILE_SUFFIX_PREPROCESSOR "pre" +#define FILE_SUFFIX_PREPROC_USER "i" +#define FILE_SUFFIX_LISTING "lst" +#define FILE_SUFFIX_HEX_DUMP "hex" +#define FILE_SUFFIX_NAMESPACE "nsp" +#define FILE_SUFFIX_DEBUG "txt" +#define FILE_SUFFIX_ASM_SOURCE "asm" +#define FILE_SUFFIX_C_SOURCE "c" +#define FILE_SUFFIX_ASM_INCLUDE "inc" +#define FILE_SUFFIX_C_INCLUDE "h" +#define FILE_SUFFIX_C_OFFSET "offset.h" +#define FILE_SUFFIX_MAP "map" +#define FILE_SUFFIX_XREF "xrf" + /* Cache block structure for ParseOps and Strings */ @@ -278,5 +304,36 @@ typedef struct acpi_serial_info } ACPI_SERIAL_INFO; +typedef struct asl_method_local +{ + ACPI_PARSE_OBJECT *Op; + UINT8 Flags; + +} ASL_METHOD_LOCAL; + +/* Values for Flags field above */ + +#define ASL_LOCAL_INITIALIZED (1) +#define ASL_LOCAL_REFERENCED (1<<1) +#define ASL_ARG_IS_LOCAL (1<<2) +#define ASL_ARG_INITIALIZED (1<<3) +#define ASL_ARG_REFERENCED (1<<4) + +/* Info used to track method counts for cross reference output file */ + +typedef struct asl_xref_info +{ + UINT32 ThisMethodInvocations; + UINT32 TotalPredefinedMethods; + UINT32 TotalUserMethods; + UINT32 TotalUnreferenceUserMethods; + UINT32 ThisObjectReferences; + UINT32 TotalObjects; + UINT32 TotalUnreferencedObjects; + ACPI_PARSE_OBJECT *MethodOp; + ACPI_PARSE_OBJECT *CurrentMethodOp; + +} ASL_XREF_INFO; + #endif /* __ASLTYPES_H */ diff --git a/sys/contrib/dev/acpica/compiler/asltypes.y b/sys/contrib/dev/acpica/compiler/asltypes.y index 650b856..1faecb4 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.y +++ b/sys/contrib/dev/acpica/compiler/asltypes.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,17 +51,17 @@ NoEcho(' *****************************************************************************/ %type <n> ArgList -%type <n> ASLCode +%type <n> AslCode %type <n> BufferData %type <n> BufferTermData %type <n> CompilerDirective %type <n> DataObject %type <n> DefinitionBlockTerm +%type <n> DefinitionBlockList %type <n> IntegerData %type <n> NamedObject %type <n> NameSpaceModifier %type <n> Object -%type <n> ObjectList %type <n> PackageData %type <n> ParameterTypePackage %type <n> ParameterTypePackageList @@ -136,7 +136,7 @@ NoEcho(' %type <n> DefaultTerm %type <n> ElseTerm %type <n> FatalTerm -%type <n> IfElseTerm +%type <n> ElseIfTerm %type <n> IfTerm %type <n> LoadTerm %type <n> NoOpTerm @@ -188,6 +188,7 @@ NoEcho(' %type <n> NotTerm %type <n> ObjectTypeTerm %type <n> OrTerm +%type <n> RawDataBufferTerm %type <n> RefOfTerm %type <n> ShiftLeftTerm %type <n> ShiftRightTerm @@ -293,11 +294,11 @@ NoEcho(' %type <n> PrintfArgList %type <n> PrintfTerm %type <n> FprintfTerm +%type <n> ForTerm /* Resource Descriptors */ %type <n> ConnectionTerm -%type <n> DataBufferTerm %type <n> DMATerm %type <n> DWordIOTerm %type <n> DWordMemoryTerm @@ -311,6 +312,7 @@ NoEcho(' %type <n> GpioIntTerm %type <n> GpioIoTerm %type <n> I2cSerialBusTerm +%type <n> I2cSerialBusTermV2 %type <n> InterruptTerm %type <n> IOTerm %type <n> IRQNoFlagsTerm @@ -325,9 +327,11 @@ NoEcho(' %type <n> QWordSpaceTerm %type <n> RegisterTerm %type <n> SpiSerialBusTerm +%type <n> SpiSerialBusTermV2 %type <n> StartDependentFnNoPriTerm %type <n> StartDependentFnTerm %type <n> UartSerialBusTerm +%type <n> UartSerialBusTermV2 %type <n> VendorLongTerm %type <n> VendorShortTerm %type <n> WordBusNumberTerm @@ -346,6 +350,7 @@ NoEcho(' %type <n> OptionalAddressRange %type <n> OptionalBitsPerByte %type <n> OptionalBuffer_Last +%type <n> OptionalBufferLength %type <n> OptionalByteConstExpr %type <n> OptionalCount %type <n> OptionalDecodeType @@ -365,6 +370,7 @@ NoEcho(' %type <n> OptionalParameterTypePackage %type <n> OptionalParameterTypesPackage %type <n> OptionalParityType +%type <n> OptionalPredicate %type <n> OptionalQWordConstExpr %type <n> OptionalRangeType %type <n> OptionalReference @@ -391,3 +397,4 @@ NoEcho(' */ %type <n> Expression %type <n> EqualsTerm +%type <n> IndexExpTerm diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index dadd6b1..b3dc354 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,8 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acapps.h> +#include <sys/stat.h> + #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslutils") @@ -67,6 +69,67 @@ UtAttachNameseg ( /******************************************************************************* * + * FUNCTION: UtIsBigEndianMachine + * + * 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 +UtIsBigEndianMachine ( + void) +{ + union { + UINT32 Integer; + UINT8 Bytes[4]; + } Overlay = {0xFF000000}; + + + return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ +} + + +/****************************************************************************** + * + * FUNCTION: UtQueryForOverwrite + * + * PARAMETERS: Pathname - Output filename + * + * RETURN: TRUE if file does not exist or overwrite is authorized + * + * DESCRIPTION: Query for file overwrite if it already exists. + * + ******************************************************************************/ + +BOOLEAN +UtQueryForOverwrite ( + char *Pathname) +{ + struct stat StatInfo; + + + if (!stat (Pathname, &StatInfo)) + { + fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ", + Pathname); + + if (getchar () != 'y') + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * * FUNCTION: UtDisplaySupportedTables * * PARAMETERS: None @@ -199,7 +262,6 @@ UtBeginEvent ( AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer (); AslGbl_Events[AslGbl_NextEvent].EventName = Name; AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; - return (AslGbl_NextEvent++); } @@ -234,63 +296,6 @@ UtEndEvent ( /******************************************************************************* * - * FUNCTION: UtConvertByteToHex - * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be - * stored - * - * RETURN: Ascii hex byte is stored in Buffer. - * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" - * - ******************************************************************************/ - -void -UtConvertByteToHex ( - UINT8 RawByte, - UINT8 *Buffer) -{ - - Buffer[0] = '0'; - Buffer[1] = 'x'; - - Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); - Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); -} - - -/******************************************************************************* - * - * FUNCTION: UtConvertByteToAsmHex - * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be - * stored - * - * RETURN: Ascii hex byte is stored in Buffer. - * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with '0', and a trailing 'h' is added. - * - ******************************************************************************/ - -void -UtConvertByteToAsmHex ( - UINT8 RawByte, - UINT8 *Buffer) -{ - - Buffer[0] = '0'; - Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); - Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); - Buffer[3] = 'h'; -} - - -/******************************************************************************* - * * FUNCTION: DbgPrint * * PARAMETERS: Type - Type of output @@ -333,43 +338,6 @@ DbgPrint ( /******************************************************************************* * - * FUNCTION: UtPrintFormattedName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * Level - Indentation level - * - * RETURN: None - * - * DESCRIPTION: Print the ascii name of the parse opcode. - * - ******************************************************************************/ - -#define TEXT_OFFSET 10 - -void -UtPrintFormattedName ( - UINT16 ParseOpcode, - UINT32 Level) -{ - - if (Level) - { - DbgPrint (ASL_TREE_OUTPUT, - "%*s", (3 * Level), " "); - } - DbgPrint (ASL_TREE_OUTPUT, - " %-20.20s", UtGetOpName (ParseOpcode)); - - if (Level < TEXT_OFFSET) - { - DbgPrint (ASL_TREE_OUTPUT, - "%*s", (TEXT_OFFSET - Level) * 3, " "); - } -} - - -/******************************************************************************* - * * FUNCTION: UtSetParseOpName * * PARAMETERS: Op - Parse op to be named. @@ -441,17 +409,22 @@ UtDisplaySummary ( "%-14s %s - %u lines, %u bytes, %u keywords\n", "ASL Input:", Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, - Gbl_InputByteCount, TotalKeywords); + Gbl_OriginalInputFileSize, TotalKeywords); /* AML summary */ if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) { - FlPrintFile (FileId, - "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n", - "AML Output:", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, - TotalNamedObjects, TotalExecutableOpcodes); + if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) + { + FlPrintFile (FileId, + "%-14s %s - %u bytes, %u named objects, " + "%u executable opcodes\n", + "AML Output:", + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_AML_OUTPUT), + TotalNamedObjects, TotalExecutableOpcodes); + } } } @@ -471,9 +444,9 @@ UtDisplaySummary ( continue; } - /* .I is a temp file unless specifically requested */ + /* .PRE is the preprocessor intermediate file */ - if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_PreprocessorOutputFlag)) + if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_KeepPreprocessorTempFile)) { continue; } @@ -803,6 +776,7 @@ UtPadNameWithUnderscores ( { *PaddedNameSeg = '_'; } + PaddedNameSeg++; } } @@ -932,7 +906,9 @@ UtDoConstant ( char ErrBuf[64]; - Status = UtStrtoul64 (String, 0, &Converted); + Status = AcpiUtStrtoul64 (String, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &Converted); + if (ACPI_FAILURE (Status)) { sprintf (ErrBuf, "%s %s\n", "Conversion error:", @@ -944,198 +920,62 @@ UtDoConstant ( } -/* TBD: use version in ACPICA main code base? */ +#ifdef _OBSOLETE_FUNCTIONS +/* Removed 01/2016 */ /******************************************************************************* * - * FUNCTION: UtStrtoul64 + * FUNCTION: UtConvertByteToHex * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte - * is returned - * Base - Radix of the string + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored * - * RETURN: Converted value + * RETURN: Ascii hex byte is stored in Buffer. * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * with "0x" * ******************************************************************************/ -ACPI_STATUS -UtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger) +void +UtConvertByteToHex ( + UINT8 RawByte, + UINT8 *Buffer) { - UINT32 Index; - UINT32 Sign; - UINT64 ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - - - *RetInteger = 0; - - switch (Base) - { - case 0: - case 8: - case 10: - case 16: - - break; - - default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); - } - /* Skip over any white space in the buffer: */ - - while (isspace ((int) *String) || *String == '\t') - { - ++String; - } - - /* - * The buffer may contain an optional plus or minus sign. - * If it does, then skip over it but remember what is was: - */ - if (*String == '-') - { - Sign = NEGATIVE; - ++String; - } - else if (*String == '+') - { - ++String; - Sign = POSITIVE; - } - else - { - Sign = POSITIVE; - } - - /* - * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: - */ - if (Base == 0) - { - if (*String == '0') - { - if (tolower ((int) *(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } - } - else - { - Base = 10; - } - } - - /* - * For octal and hexadecimal bases, skip over the leading - * 0 or 0x, if they are present. - */ - if (Base == 8 && *String == '0') - { - String++; - } - - if (Base == 16 && - *String == '0' && - tolower ((int) *(++String)) == 'x') - { - String++; - } - - /* Main loop: convert the string to an unsigned long */ - - while (*String) - { - if (isdigit ((int) *String)) - { - Index = ((UINT8) *String) - '0'; - } - else - { - Index = (UINT8) toupper ((int) *String); - if (isupper ((int) Index)) - { - Index = Index - 'A' + 10; - } - else - { - goto ErrorExit; - } - } - - if (Index >= Base) - { - goto ErrorExit; - } - - /* Check to see if value is out of range: */ - - if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / - (UINT64) Base)) - { - goto ErrorExit; - } - else - { - ReturnValue *= Base; - ReturnValue += Index; - } - - ++String; - } - - - /* If a minus sign was present, then "the conversion is negated": */ - - if (Sign == NEGATIVE) - { - ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; - } - - *RetInteger = ReturnValue; - return (Status); - - -ErrorExit: - switch (Base) - { - case 8: - - Status = AE_BAD_OCTAL_CONSTANT; - break; - - case 10: - - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: + Buffer[0] = '0'; + Buffer[1] = 'x'; - Status = AE_BAD_HEX_CONSTANT; - break; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); +} - default: - /* Base validated above */ +/******************************************************************************* + * + * FUNCTION: UtConvertByteToAsmHex + * + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored + * + * RETURN: Ascii hex byte is stored in Buffer. + * + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * with '0', and a trailing 'h' is added. + * + ******************************************************************************/ - break; - } +void +UtConvertByteToAsmHex ( + UINT8 RawByte, + UINT8 *Buffer) +{ - return (Status); + Buffer[0] = '0'; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); + Buffer[3] = 'h'; } +#endif /* OBSOLETE_FUNCTIONS */ diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c index 4e345e9..a26fdfa 100644 --- a/sys/contrib/dev/acpica/compiler/asluuid.c +++ b/sys/contrib/dev/acpica/compiler/asluuid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ ACPI_MODULE_NAME ("asluuid") -extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -69,7 +69,7 @@ AuValidateUuid ( UINT32 i; - if (!InString || (ACPI_STRLEN (InString) != UUID_STRING_LENGTH)) + if (!InString || (strlen (InString) != UUID_STRING_LENGTH)) { return (AE_BAD_PARAMETER); } @@ -90,11 +90,10 @@ AuValidateUuid ( return (AE_BAD_PARAMETER); } } - - /* All other positions must contain hex digits */ - else { + /* All other positions must contain hex digits */ + if (!isxdigit ((int) InString[i])) { return (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica/compiler/aslwalks.c b/sys/contrib/dev/acpica/compiler/aslwalks.c index c59895d..dbafaf6 100644 --- a/sys/contrib/dev/acpica/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/compiler/aslwalks.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,13 @@ ACPI_MODULE_NAME ("aslwalks") +/* Local prototypes */ + +static void +AnAnalyzeStoreOperator ( + ACPI_PARSE_OBJECT *Op); + + /******************************************************************************* * * FUNCTION: AnMethodTypingWalkEnd @@ -73,7 +80,7 @@ AnMethodTypingWalkEnd ( UINT32 Level, void *Context) { - UINT32 ThisNodeBtype; + UINT32 ThisOpBtype; switch (Op->Asl.ParseOpcode) @@ -88,18 +95,21 @@ AnMethodTypingWalkEnd ( if ((Op->Asl.Child) && (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) { - ThisNodeBtype = AnGetBtype (Op->Asl.Child); + ThisOpBtype = AnGetBtype (Op->Asl.Child); if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) && - (ThisNodeBtype == (ACPI_UINT32_MAX -1))) + (ThisOpBtype == (ACPI_UINT32_MAX -1))) { /* * The called method is untyped at this time (typically a * forward reference). * - * Check for a recursive method call first. + * Check for a recursive method call first. Note: the + * Child->Node will be null if the method has not been + * resolved. */ - if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op) + if (Op->Asl.Child->Asl.Node && + (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)) { /* We must type the method here */ @@ -107,7 +117,7 @@ AnMethodTypingWalkEnd ( ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); - ThisNodeBtype = AnGetBtype (Op->Asl.Child); + ThisOpBtype = AnGetBtype (Op->Asl.Child); } } @@ -115,7 +125,7 @@ AnMethodTypingWalkEnd ( if (Op->Asl.ParentMethod) { - Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype; + Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype; } } break; @@ -186,9 +196,9 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); } - ArgOp = Op->Asl.Child; + ArgOp = Op->Asl.Child; + OpcodeClass = OpInfo->Class; RuntimeArgTypes = OpInfo->RuntimeArgs; - OpcodeClass = OpInfo->Class; #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE /* @@ -247,6 +257,7 @@ AnOperandTypecheckWalkEnd ( { return (AE_OK); } + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype); } @@ -271,6 +282,70 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); } + /* + * Special handling for certain opcodes. + */ + switch (Op->Asl.AmlOpcode) + { + /* BankField has one TermArg */ + + case AML_BANK_FIELD_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; + break; + + /* Operation Region has 2 TermArgs */ + + case AML_REGION_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; + break; + + /* DataTableRegion has 3 TermArgs */ + + case AML_DATA_REGION_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + break; + + /* Buffers/Packages have a length that is a TermArg */ + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + /* If length is a constant, we are done */ + + if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) || + (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA)) + { + return (AE_OK); + } + break; + + /* Store can write any object to the Debug object */ + + case AML_STORE_OP: + /* + * If this is a Store() to the Debug object, we don't need + * to perform any further validation -- because a Store of + * any object to Debug is permitted and supported. + */ + if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP) + { + return (AE_OK); + } + break; + + default: + break; + } + switch (OpcodeClass) { case AML_CLASS_EXECUTE: @@ -278,15 +353,6 @@ AnOperandTypecheckWalkEnd ( case AML_CLASS_CONTROL: case AML_CLASS_RETURN_VALUE: - /* TBD: Change class or fix typechecking for these */ - - if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) || - (Op->Asl.AmlOpcode == AML_PACKAGE_OP) || - (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)) - { - break; - } - /* Reverse the runtime argument list */ RuntimeArgTypes2 = 0; @@ -297,8 +363,12 @@ AnOperandTypecheckWalkEnd ( INCREMENT_ARG_LIST (RuntimeArgTypes); } + /* Typecheck each argument */ + while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2))) { + /* Get the required type(s) for the argument */ + RequiredBtypes = AnMapArgTypeToBtype (ArgType); if (!ArgOp) @@ -308,6 +378,8 @@ AnOperandTypecheckWalkEnd ( AslAbort (); } + /* Get the actual type of the argument */ + ThisNodeBtype = AnGetBtype (ArgOp); if (ThisNodeBtype == ACPI_UINT32_MAX) { @@ -328,6 +400,10 @@ AnOperandTypecheckWalkEnd ( break; } + /* Fallthrough */ + + case ARGI_STORE_TARGET: + if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) { /* @@ -339,25 +415,22 @@ AnOperandTypecheckWalkEnd ( if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL); + AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, + ArgOp, NULL); } else { - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL); + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, + ArgOp, NULL); } - break; } - - if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF)) - { - break; - } - - ThisNodeBtype = RequiredBtypes; break; +#ifdef __FUTURE_IMPLEMENTATION +/* + * Possible future typechecking support + */ case ARGI_REFERENCE: /* References */ case ARGI_INTEGER_REF: case ARGI_OBJECT_REF: @@ -388,8 +461,8 @@ AnOperandTypecheckWalkEnd ( case PARSEOP_ARG5: case PARSEOP_ARG6: - /* Hard to analyze argument types, sow we won't */ - /* For now, just treat any arg as a typematch */ + /* Hard to analyze argument types, so we won't */ + /* for now. Just treat any arg as a typematch */ /* ThisNodeBtype = RequiredBtypes; */ break; @@ -400,10 +473,9 @@ AnOperandTypecheckWalkEnd ( default: break; - } break; - +#endif case ARGI_INTEGER: default: @@ -411,6 +483,8 @@ AnOperandTypecheckWalkEnd ( } + /* Check for a type mismatch (required versus actual) */ + CommonBtypes = ThisNodeBtype & RequiredBtypes; if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) @@ -438,9 +512,10 @@ AnOperandTypecheckWalkEnd ( AnFormatBtype (StringBuffer2, RequiredBtypes); sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); + StringBuffer, OpInfo->Name, StringBuffer2); - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, + ArgOp, MsgBuffer); } NextArgument: @@ -477,14 +552,15 @@ AnOtherSemanticAnalysisWalkBegin ( UINT32 Level, void *Context) { - ACPI_PARSE_OBJECT *ArgNode; - ACPI_PARSE_OBJECT *PrevArgNode = NULL; + ACPI_PARSE_OBJECT *ArgOp; + ACPI_PARSE_OBJECT *PrevArgOp = NULL; const ACPI_OPCODE_INFO *OpInfo; ACPI_NAMESPACE_NODE *Node; OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + /* * Determine if an execution class operator actually does something by * checking if it has a target and/or the function return value is used. @@ -497,30 +573,31 @@ AnOtherSemanticAnalysisWalkBegin ( if (OpInfo->Flags & AML_HAS_TARGET) { /* - * Find the target node, it is always the last child. If the traget + * Find the target node, it is always the last child. If the target * is not specified in the ASL, a default node of type Zero was * created by the parser. */ - ArgNode = Op->Asl.Child; - while (ArgNode->Asl.Next) + ArgOp = Op->Asl.Child; + while (ArgOp->Asl.Next) { - PrevArgNode = ArgNode; - ArgNode = ArgNode->Asl.Next; + PrevArgOp = ArgOp; + ArgOp = ArgOp->Asl.Next; } /* Divide() is the only weird case, it has two targets */ if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) { - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && - (PrevArgNode) && - (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) + if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) && + (PrevArgOp) && + (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO)) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } - else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) + + else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); @@ -555,6 +632,15 @@ AnOtherSemanticAnalysisWalkBegin ( */ switch (Op->Asl.ParseOpcode) { + case PARSEOP_STORE: + + if (Gbl_DoTypechecking) + { + AnAnalyzeStoreOperator (Op); + } + break; + + case PARSEOP_ACQUIRE: case PARSEOP_WAIT: /* @@ -566,16 +652,16 @@ AnOtherSemanticAnalysisWalkBegin ( /* First child is the namepath, 2nd child is timeout */ - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; + ArgOp = Op->Asl.Child; + ArgOp = ArgOp->Asl.Next; /* * Check for the WAIT_FOREVER case - defined by the ACPI spec to be * 0xFFFF or greater */ - if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || - (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && - (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) + if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) || + (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)) && + (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) { break; } @@ -586,7 +672,7 @@ AnOtherSemanticAnalysisWalkBegin ( */ if (!AnIsResultUsed (Op)) { - AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, + AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp, Op->Asl.ExternalName); } break; @@ -595,15 +681,15 @@ AnOtherSemanticAnalysisWalkBegin ( /* * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand */ - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; - ArgNode = ArgNode->Asl.Next; + ArgOp = Op->Asl.Child; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) || - ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) && - (ArgNode->Asl.Value.Integer == 0))) + if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) || + ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) && + (ArgOp->Asl.Value.Integer == 0))) { - AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL); + AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL); } break; @@ -612,24 +698,24 @@ AnOtherSemanticAnalysisWalkBegin ( * Ensure that the referenced operation region has the correct SPACE_ID. * From the grammar/parser, we know the parent is a FIELD definition. */ - ArgNode = Op->Asl.Parent; /* Field definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + ArgOp = Op->Asl.Parent; /* Field definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } - ArgNode = Node->Op; /* OpRegion definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ + ArgOp = Node->Op; /* OpRegion definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* * The Connection() operator is only valid for the following operation * region SpaceIds: GeneralPurposeIo and GenericSerialBus. */ - if ((ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && - (ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) + if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && + (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL); } @@ -640,46 +726,46 @@ AnOtherSemanticAnalysisWalkBegin ( * Ensure that fields for GeneralPurposeIo and GenericSerialBus * contain at least one Connection() operator */ - ArgNode = Op->Asl.Child; /* 1st child is the OpRegion Name */ - Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ + Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } - ArgNode = Node->Op; /* OpRegion definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ + ArgOp = Node->Op; /* OpRegion definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* We are only interested in GeneralPurposeIo and GenericSerialBus */ - if ((ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && - (ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) + if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && + (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { break; } - ArgNode = Op->Asl.Child; /* 1st child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* AccessType */ - ArgNode = ArgNode->Asl.Next; /* LockRule */ - ArgNode = ArgNode->Asl.Next; /* UpdateRule */ - ArgNode = ArgNode->Asl.Next; /* Start of FieldUnitList */ + ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* AccessType */ + ArgOp = ArgOp->Asl.Next; /* LockRule */ + ArgOp = ArgOp->Asl.Next; /* UpdateRule */ + ArgOp = ArgOp->Asl.Next; /* Start of FieldUnitList */ /* Walk the FieldUnitList */ - while (ArgNode) + while (ArgOp) { - if (ArgNode->Asl.ParseOpcode == PARSEOP_CONNECTION) + if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION) { break; } - else if (ArgNode->Asl.ParseOpcode == PARSEOP_NAMESEG) + else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG) { - AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgNode, NULL); + AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL); break; } - ArgNode = ArgNode->Asl.Next; + ArgOp = ArgOp->Asl.Next; } break; @@ -690,3 +776,202 @@ AnOtherSemanticAnalysisWalkBegin ( return (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AnAnalyzeStoreOperator + * + * PARAMETERS: Op - Store() operator + * + * RETURN: None + * + * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package + * objects where there are more restrictions than other data + * types. + * + ******************************************************************************/ + +static void +AnAnalyzeStoreOperator ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_NAMESPACE_NODE *SourceNode; + ACPI_NAMESPACE_NODE *TargetNode; + ACPI_PARSE_OBJECT *SourceOperandOp; + ACPI_PARSE_OBJECT *TargetOperandOp; + UINT32 SourceOperandBtype; + UINT32 TargetOperandBtype; + + + /* Extract the two operands for STORE */ + + SourceOperandOp = Op->Asl.Child; + TargetOperandOp = SourceOperandOp->Asl.Next; + + /* + * Ignore these Source operand opcodes, they cannot be typechecked, + * the actual result is unknown here. + */ + switch (SourceOperandOp->Asl.ParseOpcode) + { + /* For these, type of the returned value is unknown at compile time */ + + case PARSEOP_DEREFOF: + case PARSEOP_METHODCALL: + case PARSEOP_STORE: + case PARSEOP_COPYOBJECT: + + return; + + case PARSEOP_INDEX: + case PARSEOP_REFOF: + + if (!Gbl_EnableReferenceTypechecking) + { + return; + } + + /* + * These opcodes always return an object reference, and thus + * the result can only be stored to a Local, Arg, or Debug. + */ + if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP) + { + return; + } + + if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) || + (TargetOperandOp->Asl.AmlOpcode > AML_ARG6)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, + "Source [Reference], Target must be [Local/Arg/Debug]"); + } + return; + + default: + break; + } + + /* + * Ignore these Target operand opcodes, they cannot be typechecked + */ + switch (TargetOperandOp->Asl.ParseOpcode) + { + case PARSEOP_DEBUG: + case PARSEOP_DEREFOF: + case PARSEOP_REFOF: + case PARSEOP_INDEX: + + return; + + case PARSEOP_METHODCALL: + /* + * A target is not allowed to be a method call. + * It is not supported by the ACPICA interpreter, nor is it + * supported by the MS ASL compiler or the MS interpreter. + * Although legal syntax up until ACPI 6.1, support for this + * will be removed for ACPI 6.2 (02/2016) + */ + AslError (ASL_ERROR, ASL_MSG_SYNTAX, + TargetOperandOp, "Illegal method invocation as a target operand"); + return; + + default: + break; + } + + /* + * Ignore typecheck for External() operands of type "UnknownObj", + * we don't know the actual type (source or target). + */ + SourceNode = SourceOperandOp->Asl.Node; + if (SourceNode && + (SourceNode->Flags & ANOBJ_IS_EXTERNAL) && + (SourceNode->Type == ACPI_TYPE_ANY)) + { + return; + } + + TargetNode = TargetOperandOp->Asl.Node; + if (TargetNode && + (TargetNode->Flags & ANOBJ_IS_EXTERNAL) && + (TargetNode->Type == ACPI_TYPE_ANY)) + { + return; + } + + /* + * A NULL node with a namepath AML opcode indicates non-existent + * name. Just return, the error message is generated elsewhere. + */ + if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) || + (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP))) + { + return; + } + + /* + * Simple check for source same as target via NS node. + * -- Could be expanded to locals and args. + */ + if (SourceNode && TargetNode) + { + if (SourceNode == TargetNode) + { + AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM, + TargetOperandOp, "Source is the same as Target"); + return; + } + } + + /* Ignore typecheck if either source or target is a local or arg */ + + if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && + (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6)) + { + return; /* Cannot type a local/arg at compile time */ + } + + if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && + (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6)) + { + return; /* Cannot type a local/arg at compile time */ + } + + /* + * Package objects are a special case because they cannot by implicitly + * converted to/from anything. Check for these two illegal cases: + * + * Store (non-package, package) + * Store (package, non-package) + */ + SourceOperandBtype = AnGetBtype (SourceOperandOp); + TargetOperandBtype = AnGetBtype (TargetOperandOp); + + /* Check source first for (package, non-package) case */ + + if (SourceOperandBtype & ACPI_BTYPE_PACKAGE) + { + /* If Source is PACKAGE-->Target must be PACKAGE */ + + if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, + "Source is [Package], Target must be a package also"); + } + } + + /* Else check target for (non-package, package) case */ + + else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE) + { + /* If Target is PACKAGE, Source must be PACKAGE */ + + if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp, + "Target is [Package], Source must be a package also"); + } + } +} diff --git a/sys/contrib/dev/acpica/compiler/aslxref.c b/sys/contrib/dev/acpica/compiler/aslxref.c index cda7ccf..b09572e 100644 --- a/sys/contrib/dev/acpica/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/compiler/aslxref.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,6 +66,10 @@ XfNamespaceLocateEnd ( UINT32 Level, void *Context); +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + static BOOLEAN XfObjectExists ( char *Name); @@ -129,8 +133,6 @@ XfCrossReferenceNamespace ( ACPI_WALK_STATE *WalkState; - DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n"); - /* * Create a new walk state for use when looking up names * within the namespace (Passed as context to the callbacks) @@ -143,8 +145,8 @@ XfCrossReferenceNamespace ( /* Walk the entire parse tree */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, - XfNamespaceLocateEnd, WalkState); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); ACPI_FREE (WalkState); return (AE_OK); @@ -173,8 +175,8 @@ XfObjectExists ( /* Walk entire namespace from the supplied root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL, - Name, NULL); + ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL, + Name, NULL); if (Status == AE_CTRL_TRUE) { /* At least one instance of the name was found */ @@ -280,59 +282,16 @@ 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 + * PARAMETERS: Op - Parse 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. + * RETURN: Control method Op if found. NULL otherwise * - * NOTE: It would be better to have the parser set a flag in the Op if possible. + * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if + * the input Op is not within a control method. * ******************************************************************************/ @@ -340,120 +299,22 @@ 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; - } + ACPI_PARSE_OBJECT *NextOp; - /* Objects not in the same method? */ - if (MethodOp1 != MethodOp2) + NextOp = Op->Asl.Parent; + while (NextOp) { - /* - * 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)) + if (NextOp->Asl.AmlOpcode == AML_METHOD_OP) { - AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, - Op->Asl.ExternalName); + return (NextOp); } - } - /* - * 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); + NextOp = NextOp->Asl.Parent; } + return (NULL); /* No parent method found */ } -#endif - /******************************************************************************* * @@ -496,10 +357,67 @@ XfNamespaceLocateBegin ( UINT8 Message = 0; const ACPI_OPCODE_INFO *OpInfo; UINT32 Flags; + ASL_METHOD_LOCAL *MethodLocals = NULL; + ASL_METHOD_LOCAL *MethodArgs = NULL; + int RegisterNumber; + UINT32 i; ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op); + + if ((Op->Asl.AmlOpcode == AML_METHOD_OP) && Op->Asl.Node) + { + Node = Op->Asl.Node; + + /* Support for method LocalX/ArgX analysis */ + + if (!Node->MethodLocals) + { + /* Create local/arg info blocks */ + + MethodLocals = UtLocalCalloc ( + sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_LOCALS); + Node->MethodLocals = MethodLocals; + + MethodArgs = UtLocalCalloc ( + sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_ARGS); + Node->MethodArgs = MethodArgs; + + /* + * Get the method argument count + * First, get the name node + */ + NextOp = Op->Asl.Child; + + /* Get the NumArguments node */ + + NextOp = NextOp->Asl.Next; + Node->ArgCount = (UINT8) + (((UINT8) NextOp->Asl.Value.Integer) & 0x07); + + /* We will track all posible ArgXs */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + if (i < Node->ArgCount) + { + /* Real Args are always "initialized" */ + + MethodArgs[i].Flags = ASL_ARG_INITIALIZED; + } + else + { + /* Other ArgXs can be used as locals */ + + MethodArgs[i].Flags = ASL_ARG_IS_LOCAL; + } + + MethodArgs[i].Op = Op; + } + } + } + /* * If this node is the actual declaration of a name * [such as the XXXX name in "Method (XXXX)"], @@ -512,10 +430,88 @@ XfNamespaceLocateBegin ( return_ACPI_STATUS (AE_OK); } - /* We are only interested in opcodes that have an associated name */ - OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + /* Check method LocalX variables */ + + if (OpInfo->Type == AML_TYPE_LOCAL_VARIABLE) + { + /* Find parent method Op */ + + NextOp = XfGetParentMethod (Op); + if (!NextOp) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get method node */ + + Node = NextOp->Asl.Node; + + RegisterNumber = Op->Asl.AmlOpcode & 0x0007; /* 0x60 through 0x67 */ + MethodLocals = Node->MethodLocals; + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + /* Local is being initialized */ + + MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_INITIALIZED; + MethodLocals[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Mark this Local as referenced */ + + MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_REFERENCED; + MethodLocals[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Check method ArgX variables */ + + if (OpInfo->Type == AML_TYPE_METHOD_ARGUMENT) + { + /* Find parent method Op */ + + NextOp = XfGetParentMethod (Op); + if (!NextOp) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get method node */ + + Node = NextOp->Asl.Node; + + /* Get Arg # */ + + RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */ + MethodArgs = Node->MethodArgs; + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + /* Arg is being initialized */ + + MethodArgs[RegisterNumber].Flags |= ASL_ARG_INITIALIZED; + MethodArgs[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Mark this Arg as referenced */ + + MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED; + MethodArgs[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* + * After method ArgX and LocalX, we are only interested in opcodes + * that have an associated name + */ if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && @@ -577,6 +573,7 @@ XfNamespaceLocateBegin ( { NextOp = NextOp->Asl.Next; } + Path = NextOp->Asl.Value.String; } else @@ -598,7 +595,7 @@ XfNamespaceLocateBegin ( Gbl_NsLookupCount++; Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -780,7 +777,8 @@ XfNamespaceLocateBegin ( if (Message) { - sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s", + sprintf (MsgBuffer, + "Size mismatch, Tag: %u bit%s, Field: %u bit%s", TagBitLength, (TagBitLength > 1) ? "s" : "", FieldBitLength, (FieldBitLength > 1) ? "s" : ""); @@ -849,7 +847,7 @@ XfNamespaceLocateBegin ( if (Node->Type != ACPI_TYPE_METHOD) { sprintf (MsgBuffer, "%s is a %s", - Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); + Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); return_ACPI_STATUS (AE_OK); @@ -872,7 +870,7 @@ XfNamespaceLocateBegin ( UtSetParseOpName (Op); PassedArgs = 0; - NextOp = Op->Asl.Child; + NextOp = Op->Asl.Child; while (NextOp) { @@ -880,7 +878,8 @@ XfNamespaceLocateBegin ( NextOp = NextOp->Asl.Next; } - if (Node->Value != ASL_EXTERNAL_METHOD) + if (Node->Value != ASL_EXTERNAL_METHOD && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) { /* * Check the parsed arguments with the number expected by the @@ -978,7 +977,8 @@ XfNamespaceLocateBegin ( case ACPI_ADR_SPACE_CMOS: case ACPI_ADR_SPACE_GPIO: - if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE) + if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != + AML_FIELD_ACCESS_BYTE) { AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL); } @@ -988,7 +988,8 @@ XfNamespaceLocateBegin ( case ACPI_ADR_SPACE_IPMI: case ACPI_ADR_SPACE_GSBUS: - if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) + if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != + AML_FIELD_ACCESS_BUFFER) { AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL); } @@ -1016,10 +1017,10 @@ XfNamespaceLocateBegin ( if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child) { XfCheckFieldRange (Op, - Op->Asl.Parent->Asl.ExtraValue, - Op->Asl.ExtraValue, - (UINT32) Op->Asl.Child->Asl.Value.Integer, - Op->Asl.Child->Asl.ExtraValue); + Op->Asl.Parent->Asl.ExtraValue, + Op->Asl.ExtraValue, + (UINT32) Op->Asl.Child->Asl.Value.Integer, + Op->Asl.Child->Asl.ExtraValue); } } } @@ -1094,3 +1095,178 @@ XfNamespaceLocateEnd ( return_ACPI_STATUS (AE_OK); } + + +#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 diff --git a/sys/contrib/dev/acpica/compiler/aslxrefout.c b/sys/contrib/dev/acpica/compiler/aslxrefout.c new file mode 100644 index 0000000..7408ffe --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslxrefout.c @@ -0,0 +1,814 @@ +/****************************************************************************** + * + * Module Name: aslxrefout.c - support for optional cross-reference file + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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/acnamesp.h> +#include <contrib/dev/acpica/include/acparser.h> +#include <contrib/dev/acpica/include/amlcode.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslxrefout") + + +/* Local prototypes */ + +static ACPI_STATUS +OtXrefWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefAnalysisWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +static ACPI_STATUS +OtXrefAnalysisWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefAnalysisWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: OtPrintHeaders + * + * PARAMETERS: Message - Main header message + * + * RETURN: None + * + * DESCRIPTION: Emits the main header message along with field descriptions + * + ******************************************************************************/ + +void +OtPrintHeaders ( + char *Message) +{ + UINT32 Length; + + + Length = strlen (Message); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\n%s\n", Message); + while (Length) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, "-"); + Length--; + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nLineno %-40s Description\n", + "Full Pathname"); +} + + +/******************************************************************************* + * + * FUNCTION: OtCreateXrefFile + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION Main entry point for parts 2 and 3 of the cross-reference + * file. + * + ******************************************************************************/ + +void +OtCreateXrefFile ( + void) +{ + ASL_XREF_INFO XrefInfo; + + + /* Build cross-reference output file if requested */ + + if (!Gbl_CrossReferenceOutput) + { + return; + } + + memset (&XrefInfo, 0, sizeof (ASL_XREF_INFO)); + + /* Cross-reference output file, part 2 (Method invocations) */ + + OtPrintHeaders ("Part 2: Method Reference Map " + "(Invocations of each user-defined control method)"); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefWalkPart2, NULL, &XrefInfo); + + /* Cross-reference output file, part 3 (All other object refs) */ + + OtPrintHeaders ("Part 3: Full Object Reference Map " + "(Methods that reference each object in namespace"); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefWalkPart3, NULL, &XrefInfo); + + /* Cross-reference summary */ + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nObject Summary\n"); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal methods: %u\n", + XrefInfo.TotalPredefinedMethods + XrefInfo.TotalUserMethods); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total predefined methods: %u\n", + XrefInfo.TotalPredefinedMethods); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal user methods: %u\n", + XrefInfo.TotalUserMethods); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total unreferenced user methods %u\n", + XrefInfo.TotalUnreferenceUserMethods); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal defined objects: %u\n", + XrefInfo.TotalObjects); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total unreferenced objects: %u\n", + XrefInfo.TotalUnreferencedObjects); +} + + +/* + * Part 1 of the cross reference file. This part emits the namespace objects + * that are referenced by each control method in the namespace. + * + * Part 2 and 3 are below part 1. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart1 + * + * PARAMETERS: Op - Current parse Op + * Level - Current tree nesting level + * MethodInfo - Info block for the current method + * + * + * RETURN: None + * + * DESCRIPTION: Entry point for the creation of the method call reference map. + * For each control method in the namespace, all other methods + * that invoke the method are listed. Predefined names/methods + * that start with an underscore are ignored, because these are + * essentially external/public interfaces. + + * DESCRIPTION: Entry point for the creation of the object reference map. + * For each control method in the namespace, all objects that + * are referenced by the method are listed. + * + * Called during a normal namespace walk, once per namespace + * object. (MtMethodAnalysisWalkBegin) + * + ******************************************************************************/ + +void +OtXrefWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + ASL_METHOD_INFO *MethodInfo) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *FieldOp; + char *ParentPath; + UINT32 Length; + ACPI_STATUS Status; + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + + if (!MethodInfo || + (MethodInfo->Op->Asl.Child == Op) || + !Op->Asl.Node) + { + break; + } + + MethodInfo->CurrentOp = Op; + Node = Op->Asl.Node; + + /* Find all objects referenced by this method */ + + Status = TrWalkParseTree (MethodInfo->Op, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart1, NULL, MethodInfo); + + if (Status == AE_CTRL_TERMINATE) + { + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " %-40s %s", + ParentPath, AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); + + switch (Node->Type) + { + /* Handle externals */ + + case ACPI_TYPE_ANY: + case ACPI_TYPE_FIELD_UNIT: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " <External Object>"); + break; + + case ACPI_TYPE_INTEGER: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + break; + + case ACPI_TYPE_METHOD: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " Invocation (%u args)", + Node->ArgCount); + break; + + case ACPI_TYPE_BUFFER_FIELD: + + NextOp = Node->Op; /* Create Buffer Field Op */ + switch (NextOp->Asl.ParseOpcode) + { + case PARSEOP_CREATEBITFIELD: + Length = 1; + break; + + case PARSEOP_CREATEBYTEFIELD: + Length = 8; + break; + + case PARSEOP_CREATEWORDFIELD: + Length = 16; + break; + + case PARSEOP_CREATEDWORDFIELD: + Length = 32; + break; + + case PARSEOP_CREATEQWORDFIELD: + Length = 64; + break; + + default: + Length = 0; + break; + } + + NextOp = NextOp->Asl.Child; /* Buffer name */ + + if (!NextOp->Asl.ExternalName) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, " in Arg/Local"); + } + else + { + ParentPath = AcpiNsGetNormalizedPathname ( + NextOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Buffer %s", + Length, ParentPath); + ACPI_FREE (ParentPath); + } + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + NextOp = Node->Op; + FieldOp = NextOp->Asl.Parent; + NextOp = FieldOp->Asl.Child; + + ParentPath = AcpiNsGetNormalizedPathname ( + NextOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Region %s", + (UINT32) Node->Op->Asl.Child->Asl.Value.Integer, + ParentPath); + ACPI_FREE (ParentPath); + + if (FieldOp->Asl.ParseOpcode == PARSEOP_FIELD) + { + Node = NextOp->Asl.Node; /* Region node */ + NextOp = Node->Op; /* PARSEOP_REGION */ + NextOp = NextOp->Asl.Child; /* Region name */ + NextOp = NextOp->Asl.Next; + + /* Get region space/addr/len? */ + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%s)", + AcpiUtGetRegionName ((UINT8) + NextOp->Asl.Value.Integer)); + } + break; + + default: + break; + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n"); + } + break; + + case PARSEOP_METHOD: + + ParentPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration (%u args)\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Op->Asl.Node->Type), Op->Asl.Node->ArgCount); + + ACPI_FREE (ParentPath); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart1 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Secondary walk for cross-reference part 1. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_METHOD_INFO *MethodInfo = (ASL_METHOD_INFO *) Context; + ACPI_PARSE_OBJECT *Next; + + + /* Only interested in name string Ops -- ignore all others */ + + if ((Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + /* No node means a locally declared object -- ignore */ + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + /* When we encounter the source Op, we are done */ + + Next = MethodInfo->CurrentOp; + if (Next == Op) + { + return (AE_CTRL_TERMINATE); + } + + /* If we have a name match, this Op is a duplicate */ + + if ((Next->Asl.ParseOpcode == PARSEOP_NAMESEG) || + (Next->Asl.ParseOpcode == PARSEOP_NAMESTRING) || + (Next->Asl.ParseOpcode == PARSEOP_METHODCALL)) + { + if (!strcmp (Op->Asl.ExternalName, Next->Asl.ExternalName)) + { + return (AE_ALREADY_EXISTS); + } + } + + return (AE_OK); +} + + +/* + * Part 2 of the cross reference file. This part emits the names of each + * non-predefined method in the namespace (user methods), along with the + * names of each control method that references that method. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart2 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: For each control method in the namespace, we will re-walk the + * namespace to find each and every invocation of that control + * method. Brute force, but does not matter, even for large + * namespaces. Ignore predefined names (start with underscore). + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_NAMESPACE_NODE *Node; + char *ParentPath; + + + /* Looking for Method Declaration Ops only */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode != PARSEOP_METHOD)) + { + return (AE_OK); + } + + /* Ignore predefined names */ + + if (Op->Asl.Node->Name.Ascii[0] == '_') + { + XrefInfo->TotalPredefinedMethods++; + return (AE_OK); + } + + Node = Op->Asl.Node; + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration (%u args)\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Node->Type), Node->ArgCount); + + XrefInfo->TotalUserMethods++; + XrefInfo->ThisMethodInvocations = 0; + XrefInfo->MethodOp = Op; + + (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart2, NULL, XrefInfo); + + if (!XrefInfo->ThisMethodInvocations) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " Zero invocations of this method in this module\n"); + XrefInfo->TotalUnreferenceUserMethods++; + } + else + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " %u invocations of method %s in this module\n", + XrefInfo->ThisMethodInvocations, ParentPath); + } + + ACPI_FREE (ParentPath); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart2 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: For every Op that is a method invocation, emit a reference + * line if the Op is invoking the target method. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_PARSE_OBJECT *CallerOp; + char *CallerFullPathname; + + + /* Looking for MethodCall Ops only */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + /* If not a match to the target method, we are done */ + + if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node) + { + return (AE_CTRL_DEPTH); + } + + /* Find parent method to get method caller namepath */ + + CallerOp = Op->Asl.Parent; + while (CallerOp && + (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD)) + { + CallerOp = CallerOp->Asl.Parent; + } + + /* There is no parent method for External() statements */ + + if (!CallerOp) + { + return (AE_OK); + } + + CallerFullPathname = AcpiNsGetNormalizedPathname ( + CallerOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "[%5u] %-40s Invocation path: %s\n", + Op->Asl.LogicalLineNumber, CallerFullPathname, + Op->Asl.ExternalName); + + ACPI_FREE (CallerFullPathname); + XrefInfo->ThisMethodInvocations++; + return (AE_OK); +} + + +/* + * Part 3 of the cross reference file. This part emits the names of each + * non-predefined method in the namespace (user methods), along with the + * names of each control method that references that method. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart3 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Cross-reference part 3. references to objects other than + * control methods. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_NAMESPACE_NODE *Node; + char *ParentPath; + const ACPI_OPCODE_INFO *OpInfo; + + + /* Ignore method declarations */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode == PARSEOP_METHOD)) + { + return (AE_OK); + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + if (!(OpInfo->Class & AML_CLASS_NAMED_OBJECT)) + { + return (AE_OK); + } + + /* Only care about named object creation opcodes */ + + if ((Op->Asl.ParseOpcode != PARSEOP_NAME) && + (Op->Asl.ParseOpcode != PARSEOP_DEVICE) && + (Op->Asl.ParseOpcode != PARSEOP_MUTEX) && + (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION) && + (Op->Asl.ParseOpcode != PARSEOP_FIELD) && + (Op->Asl.ParseOpcode != PARSEOP_EVENT)) + { + return (AE_OK); + } + + /* Ignore predefined names */ + + if (Op->Asl.Node->Name.Ascii[0] == '_') + { + return (AE_OK); + } + + Node = Op->Asl.Node; + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); + + XrefInfo->MethodOp = Op; + XrefInfo->ThisObjectReferences = 0; + XrefInfo->TotalObjects = 0; + + (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart3, NULL, XrefInfo); + + if (!XrefInfo->ThisObjectReferences) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " Zero references to this object in this module\n"); + XrefInfo->TotalUnreferencedObjects++; + } + else + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " %u references to this object in this module\n", + XrefInfo->ThisObjectReferences, ParentPath); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart3 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Secondary walk for cross-reference part 3. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + char *CallerFullPathname = NULL; + ACPI_PARSE_OBJECT *CallerOp; + const char *Operator; + + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + XrefInfo->TotalObjects++; + + /* Ignore Op that actually defined the object */ + + if (Op == XrefInfo->MethodOp) + { + return (AE_OK); + } + + /* Only interested in Ops that reference the target node */ + + if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node) + { + return (AE_OK); + } + + /* Find parent "open scope" object to get method caller namepath */ + + CallerOp = Op->Asl.Parent; + while (CallerOp && + (CallerOp->Asl.ParseOpcode != PARSEOP_NAME) && + (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD) && + (CallerOp->Asl.ParseOpcode != PARSEOP_DEVICE) && + (CallerOp->Asl.ParseOpcode != PARSEOP_POWERRESOURCE) && + (CallerOp->Asl.ParseOpcode != PARSEOP_PROCESSOR) && + (CallerOp->Asl.ParseOpcode != PARSEOP_THERMALZONE)) + { + CallerOp = CallerOp->Asl.Parent; + } + + if (CallerOp == XrefInfo->CurrentMethodOp) + { + return (AE_OK); + } + + /* Null CallerOp means the caller is at the namespace root */ + + if (CallerOp) + { + CallerFullPathname = AcpiNsGetNormalizedPathname ( + CallerOp->Asl.Node, TRUE); + } + + /* There are some special cases for the oddball operators */ + + if (Op->Asl.ParseOpcode == PARSEOP_SCOPE) + { + Operator = "Scope"; + } + else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_ALIAS) + { + Operator = "Alias"; + } + else if (!CallerOp) + { + Operator = "ModLevel"; + } + else + { + Operator = AcpiUtGetTypeName (CallerOp->Asl.Node->Type); + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "[%5u] %-40s %-8s via path: %s, Operator: %s\n", + Op->Asl.LogicalLineNumber, + CallerFullPathname ? CallerFullPathname : "<root>", + Operator, + Op->Asl.ExternalName, + Op->Asl.Parent->Asl.ParseOpName); + + if (!CallerOp) + { + CallerOp = ACPI_TO_POINTER (0xFFFFFFFF); + } + + if (CallerFullPathname) + { + ACPI_FREE (CallerFullPathname); + } + + XrefInfo->CurrentMethodOp = CallerOp; + XrefInfo->ThisObjectReferences++; + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c index 20da143..56da8d3 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/compiler/dtcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -302,7 +302,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (strlen (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -345,7 +345,7 @@ DtCompileDataTable ( DtInsertCompilerIds (*FieldList); Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader, - &Gbl_RootTable, TRUE); + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -358,6 +358,8 @@ DtCompileDataTable ( TableData = AcpiDmGetTableData (Signature); if (!TableData || Gbl_CompileGeneric) { + /* Unknown table signature and/or force generic compile */ + DtCompileGeneric ((void **) FieldList, NULL, NULL); goto FinishHeader; } @@ -380,7 +382,7 @@ DtCompileDataTable ( Subtable = NULL; Status = DtCompileTable (FieldList, TableData->TableInfo, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -454,7 +456,7 @@ DtCompileTable ( /* Ignore optional subtable if name does not match */ if ((Info->Flags & DT_OPTIONAL) && - ACPI_STRCMP ((*Field)->Name, Info->Name)) + strcmp ((*Field)->Name, Info->Name)) { *RetSubtable = NULL; return (AE_OK); @@ -591,7 +593,7 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); - ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); + memcpy (Buffer, InlineSubtable->Buffer, FieldLength); LocalField = *Field; break; @@ -637,6 +639,57 @@ Error: /****************************************************************************** * + * FUNCTION: DtCompileTwoSubtables + * + * PARAMETERS: List - Current field list pointer + * TableInfo1 - Info table 1 + * TableInfo1 - Info table 2 + * + * RETURN: Status + * + * DESCRIPTION: Compile tables with a header and one or more same subtables. + * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + + + Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompilePadding * * PARAMETERS: Length - Padding field size diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h index 201b2db..ca7fb59 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -172,6 +172,12 @@ DtCompileTable ( BOOLEAN Required); ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2); + +ACPI_STATUS DtCompilePadding ( UINT32 Length, DT_SUBTABLE **RetSubtable); @@ -181,7 +187,13 @@ DtCompilePadding ( UINT32 DtGetNextLine ( - FILE *Handle); + FILE *Handle, + UINT32 Flags); + +/* Flags for DtGetNextLine */ + +#define DT_ALLOW_MULTILINE_QUOTES 0x01 + DT_FIELD * DtScanFile ( @@ -531,6 +543,10 @@ DtCompileStao ( void **PFieldList); ACPI_STATUS +DtCompileTcpa ( + void **PFieldList); + +ACPI_STATUS DtCompileUefi ( void **PFieldList); diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c index 90054c9..b9da670 100644 --- a/sys/contrib/dev/acpica/compiler/dtexpress.c +++ b/sys/contrib/dev/acpica/compiler/dtexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,6 +147,7 @@ DtDoOperator ( Gbl_CurrentField, NULL); return (0); } + Result = LeftValue / RightValue; break; @@ -158,6 +159,7 @@ DtDoOperator ( Gbl_CurrentField, NULL); return (0); } + Result = LeftValue % RightValue; break; @@ -413,10 +415,11 @@ DtLookupLabel ( LabelField = Gbl_LabelList; while (LabelField) { - if (!ACPI_STRCMP (Name, LabelField->Value)) + if (!strcmp (Name, LabelField->Value)) { return (LabelField); } + LabelField = LabelField->NextLabel; } diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c index 3b191ab..8448206 100644 --- a/sys/contrib/dev/acpica/compiler/dtfield.c +++ b/sys/contrib/dev/acpica/compiler/dtfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,6 +99,7 @@ DtCompileOneField ( { ACPI_STATUS Status; + switch (Type) { case DT_FIELD_TYPE_INTEGER: @@ -166,7 +167,7 @@ DtCompileString ( UINT32 Length; - Length = ACPI_STRLEN (Field->Value); + Length = strlen (Field->Value); /* Check if the string is too long for the field */ @@ -177,7 +178,7 @@ DtCompileString ( Length = ByteLength; } - ACPI_MEMCPY (Buffer, Field->Value, Length); + memcpy (Buffer, Field->Value, Length); } @@ -212,7 +213,7 @@ DtCompileUnicode ( AsciiString = Field->Value; UnicodeString = (UINT16 *) Buffer; - Count = ACPI_STRLEN (AsciiString) + 1; + Count = strlen (AsciiString) + 1; /* Convert to Unicode string (including null terminator) */ @@ -318,7 +319,7 @@ DtCompileInteger ( /* TBD: Should use a flag rather than compare "Reserved" */ - if (!ACPI_STRCMP (Field->Name, "Reserved")) + if (!strcmp (Field->Name, "Reserved")) { if (Flags & DT_NON_ZERO) { @@ -359,7 +360,7 @@ DtCompileInteger ( DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } - ACPI_MEMCPY (Buffer, &Value, ByteLength); + memcpy (Buffer, &Value, ByteLength); return; } @@ -391,7 +392,7 @@ DtNormalizeBuffer ( char c; - NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1); + NewBuffer = UtLocalCalloc (strlen (Buffer) + 1); TmpBuffer = NewBuffer; while ((c = *Buffer++)) diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c index 4b05bd0..d43b57e 100644 --- a/sys/contrib/dev/acpica/compiler/dtio.c +++ b/sys/contrib/dev/acpica/compiler/dtio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ DtDumpSubtableTree ( #define DT_MERGE_LINES 6 #define DT_ESCAPE_SEQUENCE 7 -static UINT32 Gbl_NextLineOffset; +static UINT32 Gbl_NextLineOffset; /****************************************************************************** @@ -129,7 +129,7 @@ DtTrim ( /* Skip lines that start with a space */ - if (!ACPI_STRCMP (String, " ")) + if (!strcmp (String, " ")) { ReturnString = UtStringCacheCalloc (1); return (ReturnString); @@ -138,7 +138,7 @@ DtTrim ( /* Setup pointers to start and end of input string */ Start = String; - End = String + ACPI_STRLEN (String) - 1; + End = String + strlen (String) - 1; /* Find first non-whitespace character */ @@ -180,9 +180,9 @@ DtTrim ( Length = ACPI_PTR_DIFF (End, Start) + 1; ReturnString = UtStringCacheCalloc (Length + 1); - if (ACPI_STRLEN (Start)) + if (strlen (Start)) { - ACPI_STRNCPY (ReturnString, Start, Length); + strncpy (ReturnString, Start, Length); } ReturnString[Length] = 0; @@ -313,7 +313,7 @@ DtParseLine ( Length = ACPI_PTR_DIFF (End, Start); TmpName = UtLocalCalloc (Length + 1); - ACPI_STRNCPY (TmpName, Start, Length); + strncpy (TmpName, Start, Length); Name = DtTrim (TmpName); ACPI_FREE (TmpName); @@ -354,13 +354,14 @@ DtParseLine ( End--; break; } + End++; } Length = ACPI_PTR_DIFF (End, Start); TmpValue = UtLocalCalloc (Length + 1); - ACPI_STRNCPY (TmpValue, Start, Length); + strncpy (TmpValue, Start, Length); Value = DtTrim (TmpValue); ACPI_FREE (TmpValue); @@ -406,7 +407,8 @@ DtParseLine ( UINT32 DtGetNextLine ( - FILE *Handle) + FILE *Handle, + UINT32 Flags) { BOOLEAN LineNotAllBlanks = FALSE; UINT32 State = DT_NORMAL_TEXT; @@ -415,7 +417,7 @@ DtGetNextLine ( int c; - ACPI_MEMSET (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); + memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); for (i = 0; ;) { /* @@ -550,9 +552,13 @@ DtGetNextLine ( case '\n': - AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n", - Gbl_CurrentLineNumber++); - State = DT_NORMAL_TEXT; + if (!(Flags & DT_ALLOW_MULTILINE_QUOTES)) + { + AcpiOsPrintf ( + "ERROR at line %u: Unterminated quoted string\n", + Gbl_CurrentLineNumber++); + State = DT_NORMAL_TEXT; + } break; default: /* Get next character */ @@ -746,12 +752,13 @@ DtScanFile ( /* Scan line-by-line */ - while ((Offset = DtGetNextLine (Handle)) != ASL_EOF) + while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF) { ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s", Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer)); - Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset); + Status = DtParseLine (Gbl_CurrentLineBuffer, + Gbl_CurrentLineNumber, Offset); if (Status == AE_NOT_FOUND) { break; @@ -897,7 +904,7 @@ DtDumpBuffer ( } BufChar = Buffer[(ACPI_SIZE) i + j]; - if (ACPI_IS_PRINT (BufChar)) + if (isprint (BufChar)) { FlPrintFile (FileId, "%c", BufChar); } @@ -942,6 +949,7 @@ DtDumpFieldList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nField List:\n" "LineNo ByteOff NameCol Column TableOff " "Flags %32s : %s\n\n", "Name", "Value"); + while (Field) { DbgPrint (ASL_DEBUG_OUTPUT, @@ -1088,6 +1096,7 @@ DtWriteFieldToListing ( FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n", strlen (Field->Value)); } + FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n"); /* Dump the hex data that will be output for this field */ diff --git a/sys/contrib/dev/acpica/compiler/dtparser.l b/sys/contrib/dev/acpica/compiler/dtparser.l index c6c29ae..9f62bed 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.l +++ b/sys/contrib/dev/acpica/compiler/dtparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, 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 0271d78..fe29e38 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.y +++ b/sys/contrib/dev/acpica/compiler/dtparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,13 @@ #define _COMPONENT DT_COMPILER ACPI_MODULE_NAME ("dtparser") +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#undef alloca +#define alloca AslLocalAllocate + int DtParserlex (void); int DtParserparse (void); void DtParsererror (char const *msg); @@ -162,15 +169,15 @@ Expression /* Default base for a non-prefixed integer is 16 */ - | EXPOP_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} - /* TBD: Decimal number with prefix (0d1234) - Not supported by UtStrtoul64 at this time */ + /* TBD: Decimal number with prefix (0d1234) - Not supported by strtoul64 at this time */ - | EXPOP_DECIMAL_NUMBER { UtStrtoul64 (DtParsertext, 10, &$$);} + | EXPOP_DECIMAL_NUMBER { AcpiUtStrtoul64 (DtParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c index 1152656..49ae8d5 100644 --- a/sys/contrib/dev/acpica/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,7 +80,7 @@ DtCreateSubtable ( String = UtStringCacheCalloc (Length); Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); - ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); + memcpy (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; Subtable->TotalLength = Length; @@ -379,6 +379,6 @@ DtSetSubtableLength ( return; } - ACPI_MEMCPY (Subtable->LengthField, &Subtable->TotalLength, + memcpy (Subtable->LengthField, &Subtable->TotalLength, Subtable->SizeOfLengthField); } diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c index bae80ad..dc55449 100644 --- a/sys/contrib/dev/acpica/compiler/dttable.c +++ b/sys/contrib/dev/acpica/compiler/dttable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ -/* Compile all complex data tables */ +/* Compile routines for the basic ACPI tables */ #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> @@ -50,123 +50,6 @@ ACPI_MODULE_NAME ("dttable") -/* TBD: merge these into dmtbinfo.c? */ - -static ACPI_DMTABLE_INFO TableInfoAsfAddress[] = -{ - {ACPI_DMT_BUFFER, 0, "Addresses", 0}, - {ACPI_DMT_EXIT, 0, NULL, 0} -}; - -static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] = -{ - {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0}, - {ACPI_DMT_EXIT, 0, NULL, 0} -}; - - -/* Local prototypes */ - -static ACPI_STATUS -DtCompileTwoSubtables ( - void **List, - ACPI_DMTABLE_INFO *TableInfo1, - ACPI_DMTABLE_INFO *TableInfo2); - - -/****************************************************************************** - * - * FUNCTION: DtCompileTwoSubtables - * - * PARAMETERS: List - Current field list pointer - * TableInfo1 - Info table 1 - * TableInfo1 - Info table 2 - * - * RETURN: Status - * - * DESCRIPTION: Compile tables with a header and one or more same subtables. - * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT - * - *****************************************************************************/ - -static ACPI_STATUS -DtCompileTwoSubtables ( - void **List, - ACPI_DMTABLE_INFO *TableInfo1, - ACPI_DMTABLE_INFO *TableInfo2) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - - - Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileFacs - * - * PARAMETERS: PFieldList - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile FACS. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileFacs ( - DT_FIELD **PFieldList) -{ - DT_SUBTABLE *Subtable; - UINT8 *ReservedBuffer; - ACPI_STATUS Status; - UINT32 ReservedSize; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, - &Gbl_RootTable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Large FACS reserved area at the end of the table */ - - ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); - ReservedBuffer = UtLocalCalloc (ReservedSize); - - DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); - - ACPI_FREE (ReservedBuffer); - DtInsertSubtable (Gbl_RootTable, Subtable); - return (AE_OK); -} - - /****************************************************************************** * * FUNCTION: DtCompileRsdp @@ -192,7 +75,7 @@ DtCompileRsdp ( /* Compile the "common" RSDP (ACPI 1.0) */ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1, - &Gbl_RootTable, TRUE); + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -206,7 +89,7 @@ DtCompileRsdp ( /* Compile the "extended" part of the RSDP as a subtable */ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -227,799 +110,6 @@ DtCompileRsdp ( /****************************************************************************** * - * FUNCTION: DtCompileAsf - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile ASF!. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileAsf ( - void **List) -{ - ACPI_ASF_INFO *AsfTable; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - ACPI_DMTABLE_INFO *DataInfoTable = NULL; - UINT32 DataCount = 0; - ACPI_STATUS Status; - UINT32 i; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer); - - switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ - { - case ACPI_ASF_TYPE_INFO: - - InfoTable = AcpiDmTableInfoAsf0; - break; - - case ACPI_ASF_TYPE_ALERT: - - InfoTable = AcpiDmTableInfoAsf1; - break; - - case ACPI_ASF_TYPE_CONTROL: - - InfoTable = AcpiDmTableInfoAsf2; - break; - - case ACPI_ASF_TYPE_BOOT: - - InfoTable = AcpiDmTableInfoAsf3; - break; - - case ACPI_ASF_TYPE_ADDRESS: - - InfoTable = AcpiDmTableInfoAsf4; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ - { - case ACPI_ASF_TYPE_INFO: - - DataInfoTable = NULL; - break; - - case ACPI_ASF_TYPE_ALERT: - - DataInfoTable = AcpiDmTableInfoAsf1a; - DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Alerts; - break; - - case ACPI_ASF_TYPE_CONTROL: - - DataInfoTable = AcpiDmTableInfoAsf2a; - DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Controls; - break; - - case ACPI_ASF_TYPE_BOOT: - - DataInfoTable = NULL; - break; - - case ACPI_ASF_TYPE_ADDRESS: - - DataInfoTable = TableInfoAsfAddress; - DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Devices; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); - return (AE_ERROR); - } - - if (DataInfoTable) - { - switch (AsfTable->Header.Type & 0x7F) - { - case ACPI_ASF_TYPE_ADDRESS: - - while (DataCount > 0) - { - Status = DtCompileTable (PFieldList, DataInfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - DataCount = DataCount - Subtable->Length; - } - break; - - default: - - for (i = 0; i < DataCount; i++) - { - Status = DtCompileTable (PFieldList, DataInfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - break; - } - } - - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileCpep - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile CPEP. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileCpep ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileCsrt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile CSRT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileCsrt ( - void **List) -{ - ACPI_STATUS Status = AE_OK; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT32 DescriptorCount; - UINT32 GroupLength; - - - /* Subtables (Resource Groups) */ - - ParentTable = DtPeekSubtable (); - while (*PFieldList) - { - /* Resource group subtable */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Compute the number of resource descriptors */ - - GroupLength = - (ACPI_CAST_PTR (ACPI_CSRT_GROUP, - Subtable->Buffer))->Length - - (ACPI_CAST_PTR (ACPI_CSRT_GROUP, - Subtable->Buffer))->SharedInfoLength - - sizeof (ACPI_CSRT_GROUP); - - DescriptorCount = (GroupLength / - sizeof (ACPI_CSRT_DESCRIPTOR)); - - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - - /* Shared info subtable (One per resource group) */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - - /* Sub-Subtables (Resource Descriptors) */ - - while (*PFieldList && DescriptorCount) - { - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - if (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - } - } - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - DescriptorCount--; - } - - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - } - - return (Status); -} - - -/****************************************************************************** - * - * 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 - * - * RETURN: Status - * - * DESCRIPTION: Compile DMAR. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileDmar ( - 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_DMAR_HEADER *DmarHeader; - ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope; - UINT32 DeviceScopeLength; - UINT32 PciPathLength; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - while (*PFieldList) - { - /* DMAR Header */ - - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); - - switch (DmarHeader->Type) - { - case ACPI_DMAR_TYPE_HARDWARE_UNIT: - - InfoTable = AcpiDmTableInfoDmar0; - break; - - case ACPI_DMAR_TYPE_RESERVED_MEMORY: - - InfoTable = AcpiDmTableInfoDmar1; - break; - - case ACPI_DMAR_TYPE_ROOT_ATS: - - InfoTable = AcpiDmTableInfoDmar2; - break; - - 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"); - return (AE_ERROR); - } - - /* DMAR Subtable */ - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* - * 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) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, - &Subtable, FALSE); - if (Status == AE_NOT_FOUND) - { - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer); - - /* Optional PCI Paths */ - - PciPathLength = DmarDeviceScope->Length - Subtable->Length; - while (PciPathLength) - { - Status = DtCompileTable (PFieldList, TableInfoDmarPciPath, - &Subtable, FALSE); - if (Status == AE_NOT_FOUND) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - PciPathLength -= Subtable->Length; - } - - DtPopSubtable (); - DeviceScopeLength -= DmarDeviceScope->Length; - } - - DtPopSubtable (); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileDrtm - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile DRTM. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileDrtm ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT32 Count; - /* ACPI_TABLE_DRTM *Drtm; */ - ACPI_DRTM_VTABLE_LIST *DrtmVtl; - ACPI_DRTM_RESOURCE_LIST *DrtmRl; - /* ACPI_DRTM_DPS_ID *DrtmDps; */ - - - ParentTable = DtPeekSubtable (); - - /* Compile DRTM header */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - /* - * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care - * should be taken to avoid accessing ACPI_TABLE_HADER fields. - */ -#if 0 - Drtm = ACPI_SUB_PTR (ACPI_TABLE_DRTM, - Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); -#endif - /* Compile VTL */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - DrtmVtl = ACPI_CAST_PTR (ACPI_DRTM_VTABLE_LIST, Subtable->Buffer); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - Count = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - DrtmVtl->ValidatedTableCount = Count; - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - /* Compile RL */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - DrtmRl = ACPI_CAST_PTR (ACPI_DRTM_RESOURCE_LIST, Subtable->Buffer); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - Count = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - DrtmRl->ResourceCount = Count; - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - /* Compile DPS */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - /* DrtmDps = ACPI_CAST_PTR (ACPI_DRTM_DPS_ID, Subtable->Buffer);*/ - - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileEinj - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile EINJ. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileEinj ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileErst - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile ERST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileErst ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoErst, AcpiDmTableInfoEinj0); - return (Status); -} - - -/****************************************************************************** - * * FUNCTION: DtCompileFadt * * PARAMETERS: List - Current field list pointer @@ -1043,7 +133,7 @@ DtCompileFadt ( Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1058,7 +148,7 @@ DtCompileFadt ( if (Revision == 2) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1069,7 +159,7 @@ DtCompileFadt ( else if (Revision >= 2) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1080,7 +170,7 @@ DtCompileFadt ( if (Revision >= 5) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1092,2362 +182,57 @@ DtCompileFadt ( if (Revision >= 6) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - } - - 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); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileFpdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile FPDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileFpdt ( - void **List) -{ - ACPI_STATUS Status; - ACPI_FPDT_HEADER *FpdtHeader; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFpdtHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); - - switch (FpdtHeader->Type) - { - case ACPI_FPDT_TYPE_BOOT: - - InfoTable = AcpiDmTableInfoFpdt0; - break; - - case ACPI_FPDT_TYPE_S3PERF: - - InfoTable = AcpiDmTableInfoFpdt1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT"); - return (AE_ERROR); - break; - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileHest - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile HEST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileHest ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_DMTABLE_INFO *InfoTable; - UINT16 Type; - UINT32 BankCount; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - /* Get subtable type */ - - SubtableStart = *PFieldList; - DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); - - switch (Type) - { - case ACPI_HEST_TYPE_IA32_CHECK: - - InfoTable = AcpiDmTableInfoHest0; - break; - - case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: - - InfoTable = AcpiDmTableInfoHest1; - break; - - case ACPI_HEST_TYPE_IA32_NMI: - - InfoTable = AcpiDmTableInfoHest2; - break; - - case ACPI_HEST_TYPE_AER_ROOT_PORT: - - InfoTable = AcpiDmTableInfoHest6; - break; - - case ACPI_HEST_TYPE_AER_ENDPOINT: - - InfoTable = AcpiDmTableInfoHest7; - break; - - case ACPI_HEST_TYPE_AER_BRIDGE: - - InfoTable = AcpiDmTableInfoHest8; - break; - - case ACPI_HEST_TYPE_GENERIC_ERROR: - - InfoTable = AcpiDmTableInfoHest9; - break; - - default: - - /* Cannot continue on unknown type */ - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - - /* - * Additional subtable data - IA32 Error Bank(s) - */ - BankCount = 0; - switch (Type) - { - case ACPI_HEST_TYPE_IA32_CHECK: - - BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, - Subtable->Buffer))->NumHardwareBanks; - break; - - case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: - - BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, - Subtable->Buffer))->NumHardwareBanks; - break; - - default: - - break; - } - - while (BankCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - BankCount--; - } - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileIort - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile IORT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileIort ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_TABLE_IORT *Iort; - ACPI_IORT_NODE *IortNode; - ACPI_IORT_ITS_GROUP *IortItsGroup; - ACPI_IORT_SMMU *IortSmmu; - UINT32 NodeNumber; - UINT32 NodeLength; - UINT32 IdMappingNumber; - UINT32 ItsNumber; - UINT32 ContextIrptNumber; - UINT32 PmuIrptNumber; - UINT32 PaddingLength; - - - ParentTable = DtPeekSubtable (); - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - /* - * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care - * should be taken to avoid accessing ACPI_TABLE_HADER fields. - */ - Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT, - Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); - - /* - * OptionalPadding - Variable-length data - * (Optional, size = OffsetToNodes - sizeof (ACPI_TABLE_IORT)) - * Optionally allows the generic data types to be used for filling - * this field. - */ - Iort->NodeOffset = sizeof (ACPI_TABLE_IORT); - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - Iort->NodeOffset += Subtable->Length; - } - else - { - Status = DtCompileGeneric (ACPI_CAST_PTR (void *, PFieldList), - AcpiDmTableInfoIortHdr[0].Name, &PaddingLength); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Iort->NodeOffset += PaddingLength; - } - - NodeNumber = 0; - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortNode = ACPI_CAST_PTR (ACPI_IORT_NODE, Subtable->Buffer); - NodeLength = ACPI_OFFSET (ACPI_IORT_NODE, NodeData); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - - switch (IortNode->Type) - { - case ACPI_IORT_NODE_ITS_GROUP: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortItsGroup = ACPI_CAST_PTR (ACPI_IORT_ITS_GROUP, Subtable->Buffer); - NodeLength += Subtable->Length; - - ItsNumber = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - ItsNumber++; - } - - IortItsGroup->ItsCount = ItsNumber; - break; - - case ACPI_IORT_NODE_NAMED_COMPONENT: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - - /* - * Padding - Variable-length data - * Optionally allows the offset of the ID mappings to be used - * for filling this field. - */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - } - else - { - if (NodeLength > IortNode->MappingOffset) - { - return (AE_BAD_DATA); - } - if (NodeLength < IortNode->MappingOffset) - { - Status = DtCompilePadding ( - IortNode->MappingOffset - NodeLength, - &Subtable); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength = IortNode->MappingOffset; - } - } - break; - - case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - break; - - case ACPI_IORT_NODE_SMMU: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortSmmu = ACPI_CAST_PTR (ACPI_IORT_SMMU, Subtable->Buffer); - NodeLength += Subtable->Length; - - /* Compile global interrupt array */ - - IortSmmu->GlobalInterruptOffset = NodeLength; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - - /* Compile context interrupt array */ - - ContextIrptNumber = 0; - IortSmmu->ContextInterruptOffset = NodeLength; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - ContextIrptNumber++; - } - IortSmmu->ContextInterruptCount = ContextIrptNumber; - - /* Compile PMU interrupt array */ - - PmuIrptNumber = 0; - IortSmmu->PmuInterruptOffset = NodeLength; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - PmuIrptNumber++; - } - IortSmmu->PmuInterruptCount = PmuIrptNumber; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); - return (AE_ERROR); - } - - /* Compile Array of ID mappings */ - - IortNode->MappingOffset = NodeLength; - IdMappingNumber = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortMap, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += sizeof (ACPI_IORT_ID_MAPPING); - IdMappingNumber++; - } - IortNode->MappingCount = IdMappingNumber; - - /* - * Node length can be determined by DT_LENGTH option - * IortNode->Length = NodeLength; - */ - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - NodeNumber++; - } - Iort->NodeCount = NodeNumber; - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileIvrs - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile IVRS. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileIvrs ( - 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_IVRS_HEADER *IvrsHeader; - UINT8 EntryType; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer); - - switch (IvrsHeader->Type) - { - case ACPI_IVRS_TYPE_HARDWARE: - - InfoTable = AcpiDmTableInfoIvrs0; - break; - - case ACPI_IVRS_TYPE_MEMORY1: - case ACPI_IVRS_TYPE_MEMORY2: - case ACPI_IVRS_TYPE_MEMORY3: - - InfoTable = AcpiDmTableInfoIvrs1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE) - { - while (*PFieldList && - !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type")) - { - SubtableStart = *PFieldList; - DtCompileInteger (&EntryType, *PFieldList, 1, 0); - - switch (EntryType) - { - /* 4-byte device entries */ - - case ACPI_IVRS_TYPE_PAD4: - case ACPI_IVRS_TYPE_ALL: - case ACPI_IVRS_TYPE_SELECT: - case ACPI_IVRS_TYPE_START: - case ACPI_IVRS_TYPE_END: - - InfoTable = AcpiDmTableInfoIvrs4; - break; - - /* 8-byte entries, type A */ - - case ACPI_IVRS_TYPE_ALIAS_SELECT: - case ACPI_IVRS_TYPE_ALIAS_START: - - InfoTable = AcpiDmTableInfoIvrs8a; - break; - - /* 8-byte entries, type B */ - - case ACPI_IVRS_TYPE_PAD8: - case ACPI_IVRS_TYPE_EXT_SELECT: - case ACPI_IVRS_TYPE_EXT_START: - - InfoTable = AcpiDmTableInfoIvrs8b; - break; - - /* 8-byte entries, type C */ - - case ACPI_IVRS_TYPE_SPECIAL: - - InfoTable = AcpiDmTableInfoIvrs8c; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, - "IVRS Device Entry"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - } - - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * 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; - - 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 - * - * RETURN: Status - * - * DESCRIPTION: Compile MADT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMadt ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *MadtHeader; - ACPI_DMTABLE_INFO *InfoTable; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (MadtHeader->Type) - { - case ACPI_MADT_TYPE_LOCAL_APIC: - - InfoTable = AcpiDmTableInfoMadt0; - break; - - case ACPI_MADT_TYPE_IO_APIC: - - InfoTable = AcpiDmTableInfoMadt1; - break; - - case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: - - InfoTable = AcpiDmTableInfoMadt2; - break; - - case ACPI_MADT_TYPE_NMI_SOURCE: - - InfoTable = AcpiDmTableInfoMadt3; - break; - - case ACPI_MADT_TYPE_LOCAL_APIC_NMI: - - InfoTable = AcpiDmTableInfoMadt4; - break; - - case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: - - InfoTable = AcpiDmTableInfoMadt5; - break; - - case ACPI_MADT_TYPE_IO_SAPIC: - - InfoTable = AcpiDmTableInfoMadt6; - break; - - case ACPI_MADT_TYPE_LOCAL_SAPIC: - - InfoTable = AcpiDmTableInfoMadt7; - break; - - case ACPI_MADT_TYPE_INTERRUPT_SOURCE: - - InfoTable = AcpiDmTableInfoMadt8; - break; - - case ACPI_MADT_TYPE_LOCAL_X2APIC: - - InfoTable = AcpiDmTableInfoMadt9; - break; - - case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: - - InfoTable = AcpiDmTableInfoMadt10; - break; - - case ACPI_MADT_TYPE_GENERIC_INTERRUPT: - - InfoTable = AcpiDmTableInfoMadt11; - break; - - case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: - - InfoTable = AcpiDmTableInfoMadt12; - break; - - case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: - - InfoTable = AcpiDmTableInfoMadt13; - break; - - case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: - - InfoTable = AcpiDmTableInfoMadt14; - break; - - case ACPI_MADT_TYPE_GENERIC_TRANSLATOR: - - InfoTable = AcpiDmTableInfoMadt15; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); - 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: DtCompileMcfg - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MCFG. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMcfg ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMpst - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MPST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMpst ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - ACPI_MPST_CHANNEL *MpstChannelInfo; - ACPI_MPST_POWER_NODE *MpstPowerNode; - ACPI_MPST_DATA_HDR *MpstDataHeader; - UINT16 SubtableCount; - UINT32 PowerStateCount; - UINT32 ComponentCount; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer); - SubtableCount = MpstChannelInfo->PowerNodeCount; - - while (*PFieldList && SubtableCount) - { - /* Subtable: Memory Power Node(s) */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer); - PowerStateCount = MpstPowerNode->NumPowerStates; - ComponentCount = MpstPowerNode->NumPhysicalComponents; - - ParentTable = DtPeekSubtable (); - - /* Sub-subtables - Memory Power State Structure(s) */ - - while (*PFieldList && PowerStateCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A, - &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } DtInsertSubtable (ParentTable, Subtable); - PowerStateCount--; - } - - /* Sub-subtables - Physical Component ID Structure(s) */ - - while (*PFieldList && ComponentCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - ComponentCount--; - } - - SubtableCount--; - DtPopSubtable (); - } - - /* Subtable: Count of Memory Power State Characteristic structures */ - - DtPopSubtable (); - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer); - SubtableCount = MpstDataHeader->CharacteristicsCount; - - ParentTable = DtPeekSubtable (); - - /* Subtable: Memory Power State Characteristics structure(s) */ - - while (*PFieldList && SubtableCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); } - - DtInsertSubtable (ParentTable, Subtable); - SubtableCount--; } - DtPopSubtable (); return (AE_OK); } /****************************************************************************** * - * FUNCTION: DtCompileMsct - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MSCT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMsct ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMtmr - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MTMR. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMtmr ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileNfit - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile NFIT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileNfit ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_NFIT_HEADER *NfitHeader; - ACPI_DMTABLE_INFO *InfoTable; - UINT32 Count; - ACPI_NFIT_INTERLEAVE *Interleave = NULL; - ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL; - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - /* Subtables */ - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer); - - switch (NfitHeader->Type) - { - case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: - - InfoTable = AcpiDmTableInfoNfit0; - break; - - case ACPI_NFIT_TYPE_MEMORY_MAP: - - InfoTable = AcpiDmTableInfoNfit1; - break; - - case ACPI_NFIT_TYPE_INTERLEAVE: - - Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer); - InfoTable = AcpiDmTableInfoNfit2; - break; - - case ACPI_NFIT_TYPE_SMBIOS: - - InfoTable = AcpiDmTableInfoNfit3; - break; - - case ACPI_NFIT_TYPE_CONTROL_REGION: - - InfoTable = AcpiDmTableInfoNfit4; - break; - - case ACPI_NFIT_TYPE_DATA_REGION: - - InfoTable = AcpiDmTableInfoNfit5; - break; - - case ACPI_NFIT_TYPE_FLUSH_ADDRESS: - - Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer); - InfoTable = AcpiDmTableInfoNfit6; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - - switch (NfitHeader->Type) - { - case ACPI_NFIT_TYPE_INTERLEAVE: - - Count = 0; - DtPushSubtable (Subtable); - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a, - &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - - Interleave->LineCount = Count; - DtPopSubtable (); - break; - - case ACPI_NFIT_TYPE_SMBIOS: - - if (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - } - } - break; - - case ACPI_NFIT_TYPE_FLUSH_ADDRESS: - - Count = 0; - DtPushSubtable (Subtable); - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a, - &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - - Hint->HintCount = (UINT16) Count; - DtPopSubtable (); - break; - - default: - break; - } - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * 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; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* Subtables */ - - 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 - * - * RETURN: Status - * - * DESCRIPTION: Compile PMTT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompilePmtt ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_PMTT_HEADER *PmttHeader; - ACPI_PMTT_CONTROLLER *PmttController; - UINT16 DomainCount; - UINT8 PrevType = ACPI_PMTT_TYPE_SOCKET; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer); - while (PrevType >= PmttHeader->Type) - { - DtPopSubtable (); - - if (PrevType == ACPI_PMTT_TYPE_SOCKET) - { - break; - } - PrevType--; - } - PrevType = PmttHeader->Type; - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - switch (PmttHeader->Type) - { - case ACPI_PMTT_TYPE_SOCKET: - - /* Subtable: Socket Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - break; - - case ACPI_PMTT_TYPE_CONTROLLER: - - /* Subtable: Memory Controller Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER, - (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER))); - DomainCount = PmttController->DomainCount; - - while (DomainCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - DomainCount--; - } - break; - - case ACPI_PMTT_TYPE_DIMM: - - /* Subtable: Physical Component Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT"); - return (AE_ERROR); - } - } - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileRsdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile RSDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileRsdt ( - void **List) -{ - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD *FieldList = *(DT_FIELD **) List; - UINT32 Address; - - - ParentTable = DtPeekSubtable (); - - while (FieldList) - { - DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); - - DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileS3pt + * FUNCTION: DtCompileFacs * * PARAMETERS: PFieldList - Current field list pointer * * RETURN: Status * - * DESCRIPTION: Compile S3PT (Pointed to by FPDT) + * DESCRIPTION: Compile FACS. * *****************************************************************************/ ACPI_STATUS -DtCompileS3pt ( +DtCompileFacs ( DT_FIELD **PFieldList) { - ACPI_STATUS Status; - ACPI_S3PT_HEADER *S3ptHeader; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - DT_FIELD *SubtableStart; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, - &Gbl_RootTable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtPushSubtable (Gbl_RootTable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - S3ptHeader = ACPI_CAST_PTR (ACPI_S3PT_HEADER, Subtable->Buffer); - - switch (S3ptHeader->Type) - { - case ACPI_S3PT_TYPE_RESUME: - - InfoTable = AcpiDmTableInfoS3pt0; - break; - - case ACPI_S3PT_TYPE_SUSPEND: - - InfoTable = AcpiDmTableInfoS3pt1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); - 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: DtCompileSlic - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SLIC. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSlic ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileSlit - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SLIT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSlit ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *FieldList; - UINT32 Localities; - UINT8 *LocalityBuffer; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); - LocalityBuffer = UtLocalCalloc (Localities); - - /* Compile each locality buffer */ - - FieldList = *PFieldList; - while (FieldList) - { - DtCompileBuffer (LocalityBuffer, - FieldList->Value, FieldList, Localities); - - DtCreateSubtable (LocalityBuffer, Localities, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - ACPI_FREE (LocalityBuffer); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileSrat - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SRAT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSrat ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *SratHeader; - ACPI_DMTABLE_INFO *InfoTable; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (SratHeader->Type) - { - case ACPI_SRAT_TYPE_CPU_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat0; - break; - - case ACPI_SRAT_TYPE_MEMORY_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat1; - break; - - case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat2; - break; - - case ACPI_SRAT_TYPE_GICC_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat3; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); - 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: DtCompileStao - * - * PARAMETERS: PFieldList - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile STAO. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileStao ( - void **List) -{ - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_STATUS Status; - - - /* Compile the main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* Compile each ASCII namestring as a subtable */ - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtGetGenericTableInfo - * - * PARAMETERS: Name - Generic type name - * - * RETURN: Info entry - * - * DESCRIPTION: Obtain table info for a generic name entry - * - *****************************************************************************/ - -ACPI_DMTABLE_INFO * -DtGetGenericTableInfo ( - char *Name) -{ - ACPI_DMTABLE_INFO *Info; - UINT32 i; - - - if (!Name) - { - return (NULL); - } - - /* Search info table for name match */ - - for (i = 0; ; i++) - { - Info = AcpiDmTableInfoGeneric[i]; - if (Info->Opcode == ACPI_DMT_EXIT) - { - Info = NULL; - break; - } - - /* Use caseless compare for generic keywords */ - - if (!AcpiUtStricmp (Name, Info->Name)) - { - break; - } - } - - return (Info); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileUefi - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile UEFI. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileUefi ( - void **List) -{ - ACPI_STATUS Status; DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT16 *DataOffset; - - - /* Compile the predefined portion of the UEFI table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DataOffset = (UINT16 *) (Subtable->Buffer + 16); - *DataOffset = sizeof (ACPI_TABLE_UEFI); - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* - * Compile the "generic" portion of the UEFI table. This - * part of the table is not predefined and any of the generic - * operators may be used. - */ - - DtCompileGeneric ((void **) PFieldList, NULL, NULL); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileVrtc - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile VRTC. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileVrtc ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileWdat - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile WDAT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileWdat ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileWpbt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile WPBT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileWpbt ( - void **List) -{ - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_TABLE_WPBT *Table; + UINT8 *ReservedBuffer; ACPI_STATUS Status; - UINT16 Length; - - - /* Compile the main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); + UINT32 ReservedSize; - /* Compile the argument list subtable */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, - &Subtable, TRUE); + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } - /* Extract the length of the Arguments buffer, insert into main table */ - - Length = (UINT16) Subtable->TotalLength; - Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); - Table->ArgumentsLength = Length; - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileXsdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile XSDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileXsdt ( - void **List) -{ - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD *FieldList = *(DT_FIELD **) List; - UINT64 Address; - - - ParentTable = DtPeekSubtable (); - - while (FieldList) - { - DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); - - DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileGeneric - * - * PARAMETERS: List - Current field list pointer - * Name - Field name to end generic compiling - * Length - Compiled table length to return - * - * RETURN: Status - * - * DESCRIPTION: Compile generic unknown table. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileGeneric ( - void **List, - char *Name, - UINT32 *Length) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - ACPI_DMTABLE_INFO *Info; - - - ParentTable = DtPeekSubtable (); - - /* - * Compile the "generic" portion of the table. This - * part of the table is not predefined and any of the generic - * operators may be used. - */ - - /* Find any and all labels in the entire generic portion */ - - DtDetectAllLabels (*PFieldList); - - /* Now we can actually compile the parse tree */ - - if (*Length) - { - *Length = 0; - } - while (*PFieldList) - { - if (Name && !ACPI_STRCMP ((*PFieldList)->Name, Name)) - { - break; - } - Info = DtGetGenericTableInfo ((*PFieldList)->Name); - if (!Info) - { - sprintf (MsgBuffer, "Generic data type \"%s\" not found", - (*PFieldList)->Name); - DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, - (*PFieldList), MsgBuffer); - - *PFieldList = (*PFieldList)->Next; - continue; - } + /* Large FACS reserved area at the end of the table */ - Status = DtCompileTable (PFieldList, Info, - &Subtable, TRUE); - if (ACPI_SUCCESS (Status)) - { - DtInsertSubtable (ParentTable, Subtable); - if (Length) - { - *Length += Subtable->Length; - } - } - else - { - *PFieldList = (*PFieldList)->Next; + ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); + ReservedBuffer = UtLocalCalloc (ReservedSize); - if (Status == AE_NOT_FOUND) - { - sprintf (MsgBuffer, "Generic data type \"%s\" not found", - (*PFieldList)->Name); - DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, - (*PFieldList), MsgBuffer); - } - } - } + DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); + ACPI_FREE (ReservedBuffer); + DtInsertSubtable (Gbl_RootTable, Subtable); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/dttable1.c b/sys/contrib/dev/acpica/compiler/dttable1.c new file mode 100644 index 0000000..673f256 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/dttable1.c @@ -0,0 +1,1684 @@ +/****************************************************************************** + * + * Module Name: dttable1.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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. + */ + +/* Compile all complex data tables, signatures starting with A-I */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttable1") + + +static ACPI_DMTABLE_INFO TableInfoAsfAddress[] = +{ + {ACPI_DMT_BUFFER, 0, "Addresses", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + +static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] = +{ + {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + + +/****************************************************************************** + * + * FUNCTION: DtCompileAsf + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ASF!. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileAsf ( + void **List) +{ + ACPI_ASF_INFO *AsfTable; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_DMTABLE_INFO *DataInfoTable = NULL; + UINT32 DataCount = 0; + ACPI_STATUS Status; + UINT32 i; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + + InfoTable = AcpiDmTableInfoAsf0; + break; + + case ACPI_ASF_TYPE_ALERT: + + InfoTable = AcpiDmTableInfoAsf1; + break; + + case ACPI_ASF_TYPE_CONTROL: + + InfoTable = AcpiDmTableInfoAsf2; + break; + + case ACPI_ASF_TYPE_BOOT: + + InfoTable = AcpiDmTableInfoAsf3; + break; + + case ACPI_ASF_TYPE_ADDRESS: + + InfoTable = AcpiDmTableInfoAsf4; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ALERT: + + DataInfoTable = AcpiDmTableInfoAsf1a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Alerts; + break; + + case ACPI_ASF_TYPE_CONTROL: + + DataInfoTable = AcpiDmTableInfoAsf2a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Controls; + break; + + case ACPI_ASF_TYPE_BOOT: + + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ADDRESS: + + DataInfoTable = TableInfoAsfAddress; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Devices; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + if (DataInfoTable) + { + switch (AsfTable->Header.Type & 0x7F) + { + case ACPI_ASF_TYPE_ADDRESS: + + while (DataCount > 0) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DataCount = DataCount - Subtable->Length; + } + break; + + default: + + for (i = 0; i < DataCount; i++) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + break; + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileCpep + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CPEP. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCpep ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileCsrt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CSRT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCsrt ( + void **List) +{ + ACPI_STATUS Status = AE_OK; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 DescriptorCount; + UINT32 GroupLength; + + + /* Subtables (Resource Groups) */ + + ParentTable = DtPeekSubtable (); + while (*PFieldList) + { + /* Resource group subtable */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Compute the number of resource descriptors */ + + GroupLength = + (ACPI_CAST_PTR (ACPI_CSRT_GROUP, + Subtable->Buffer))->Length - + (ACPI_CAST_PTR (ACPI_CSRT_GROUP, + Subtable->Buffer))->SharedInfoLength - + sizeof (ACPI_CSRT_GROUP); + + DescriptorCount = (GroupLength / + sizeof (ACPI_CSRT_DESCRIPTOR)); + + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + /* Shared info subtable (One per resource group) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* Sub-Subtables (Resource Descriptors) */ + + while (*PFieldList && DescriptorCount) + { + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + if (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + DescriptorCount--; + } + + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + } + + return (Status); +} + + +/****************************************************************************** + * + * 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 + * + * RETURN: Status + * + * DESCRIPTION: Compile DMAR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDmar ( + 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_DMAR_HEADER *DmarHeader; + ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope; + UINT32 DeviceScopeLength; + UINT32 PciPathLength; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + while (*PFieldList) + { + /* DMAR Header */ + + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); + + switch (DmarHeader->Type) + { + case ACPI_DMAR_TYPE_HARDWARE_UNIT: + + InfoTable = AcpiDmTableInfoDmar0; + break; + + case ACPI_DMAR_TYPE_RESERVED_MEMORY: + + InfoTable = AcpiDmTableInfoDmar1; + break; + + case ACPI_DMAR_TYPE_ROOT_ATS: + + InfoTable = AcpiDmTableInfoDmar2; + break; + + 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"); + return (AE_ERROR); + } + + /* DMAR Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * 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) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer); + + /* Optional PCI Paths */ + + PciPathLength = DmarDeviceScope->Length - Subtable->Length; + while (PciPathLength) + { + Status = DtCompileTable (PFieldList, TableInfoDmarPciPath, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + PciPathLength -= Subtable->Length; + } + + DtPopSubtable (); + DeviceScopeLength -= DmarDeviceScope->Length; + } + + DtPopSubtable (); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDrtm + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DRTM. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDrtm ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 Count; + /* ACPI_TABLE_DRTM *Drtm; */ + ACPI_DRTM_VTABLE_LIST *DrtmVtl; + ACPI_DRTM_RESOURCE_LIST *DrtmRl; + /* ACPI_DRTM_DPS_ID *DrtmDps; */ + + + ParentTable = DtPeekSubtable (); + + /* Compile DRTM header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + + /* + * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care + * should be taken to avoid accessing ACPI_TABLE_HADER fields. + */ +#if 0 + Drtm = ACPI_SUB_PTR (ACPI_TABLE_DRTM, + Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); +#endif + /* Compile VTL */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DrtmVtl = ACPI_CAST_PTR (ACPI_DRTM_VTABLE_LIST, Subtable->Buffer); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + Count = 0; + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (!Subtable) + { + break; + } + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + DrtmVtl->ValidatedTableCount = Count; + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + + /* Compile RL */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DrtmRl = ACPI_CAST_PTR (ACPI_DRTM_RESOURCE_LIST, Subtable->Buffer); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + Count = 0; + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + DrtmRl->ResourceCount = Count; + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + + /* Compile DPS */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + /* DrtmDps = ACPI_CAST_PTR (ACPI_DRTM_DPS_ID, Subtable->Buffer);*/ + + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileEinj + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile EINJ. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileEinj ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileErst + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ERST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileErst ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoErst, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * 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); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileFpdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile FPDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileFpdt ( + void **List) +{ + ACPI_STATUS Status; + ACPI_FPDT_HEADER *FpdtHeader; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFpdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); + + switch (FpdtHeader->Type) + { + case ACPI_FPDT_TYPE_BOOT: + + InfoTable = AcpiDmTableInfoFpdt0; + break; + + case ACPI_FPDT_TYPE_S3PERF: + + InfoTable = AcpiDmTableInfoFpdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT"); + return (AE_ERROR); + break; + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileHest + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile HEST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileHest ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + UINT16 Type; + UINT32 BankCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + /* Get subtable type */ + + SubtableStart = *PFieldList; + DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); + + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + + InfoTable = AcpiDmTableInfoHest0; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + + InfoTable = AcpiDmTableInfoHest1; + break; + + case ACPI_HEST_TYPE_IA32_NMI: + + InfoTable = AcpiDmTableInfoHest2; + break; + + case ACPI_HEST_TYPE_AER_ROOT_PORT: + + InfoTable = AcpiDmTableInfoHest6; + break; + + case ACPI_HEST_TYPE_AER_ENDPOINT: + + InfoTable = AcpiDmTableInfoHest7; + break; + + case ACPI_HEST_TYPE_AER_BRIDGE: + + InfoTable = AcpiDmTableInfoHest8; + break; + + case ACPI_HEST_TYPE_GENERIC_ERROR: + + InfoTable = AcpiDmTableInfoHest9; + break; + + default: + + /* Cannot continue on unknown type */ + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional subtable data - IA32 Error Bank(s) + */ + BankCount = 0; + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, + Subtable->Buffer))->NumHardwareBanks; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, + Subtable->Buffer))->NumHardwareBanks; + break; + + default: + + break; + } + + while (BankCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + BankCount--; + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileIort + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile IORT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileIort ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_TABLE_IORT *Iort; + ACPI_IORT_NODE *IortNode; + ACPI_IORT_ITS_GROUP *IortItsGroup; + ACPI_IORT_SMMU *IortSmmu; + UINT32 NodeNumber; + UINT32 NodeLength; + UINT32 IdMappingNumber; + UINT32 ItsNumber; + UINT32 ContextIrptNumber; + UINT32 PmuIrptNumber; + UINT32 PaddingLength; + + + ParentTable = DtPeekSubtable (); + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + + /* + * Using ACPI_SUB_PTR, We needn't define a separate structure. Care + * should be taken to avoid accessing ACPI_TABLE_HEADER fields. + */ + Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT, + Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); + + /* + * OptionalPadding - Variable-length data + * (Optional, size = OffsetToNodes - sizeof (ACPI_TABLE_IORT)) + * Optionally allows the generic data types to be used for filling + * this field. + */ + Iort->NodeOffset = sizeof (ACPI_TABLE_IORT); + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + Iort->NodeOffset += Subtable->Length; + } + else + { + Status = DtCompileGeneric (ACPI_CAST_PTR (void *, PFieldList), + AcpiDmTableInfoIortHdr[0].Name, &PaddingLength); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Iort->NodeOffset += PaddingLength; + } + + NodeNumber = 0; + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortNode = ACPI_CAST_PTR (ACPI_IORT_NODE, Subtable->Buffer); + NodeLength = ACPI_OFFSET (ACPI_IORT_NODE, NodeData); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + switch (IortNode->Type) + { + case ACPI_IORT_NODE_ITS_GROUP: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortItsGroup = ACPI_CAST_PTR (ACPI_IORT_ITS_GROUP, Subtable->Buffer); + NodeLength += Subtable->Length; + + ItsNumber = 0; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + ItsNumber++; + } + + IortItsGroup->ItsCount = ItsNumber; + break; + + case ACPI_IORT_NODE_NAMED_COMPONENT: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + + /* + * Padding - Variable-length data + * Optionally allows the offset of the ID mappings to be used + * for filling this field. + */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + } + else + { + if (NodeLength > IortNode->MappingOffset) + { + return (AE_BAD_DATA); + } + + if (NodeLength < IortNode->MappingOffset) + { + Status = DtCompilePadding ( + IortNode->MappingOffset - NodeLength, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength = IortNode->MappingOffset; + } + } + break; + + case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + + case ACPI_IORT_NODE_SMMU: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortSmmu = ACPI_CAST_PTR (ACPI_IORT_SMMU, Subtable->Buffer); + NodeLength += Subtable->Length; + + /* Compile global interrupt array */ + + IortSmmu->GlobalInterruptOffset = NodeLength; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + + /* Compile context interrupt array */ + + ContextIrptNumber = 0; + IortSmmu->ContextInterruptOffset = NodeLength; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + ContextIrptNumber++; + } + + IortSmmu->ContextInterruptCount = ContextIrptNumber; + + /* Compile PMU interrupt array */ + + PmuIrptNumber = 0; + IortSmmu->PmuInterruptOffset = NodeLength; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + PmuIrptNumber++; + } + + IortSmmu->PmuInterruptCount = PmuIrptNumber; + break; + + case ACPI_IORT_NODE_SMMU_V3: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort4, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); + return (AE_ERROR); + } + + /* Compile Array of ID mappings */ + + IortNode->MappingOffset = NodeLength; + IdMappingNumber = 0; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortMap, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += sizeof (ACPI_IORT_ID_MAPPING); + IdMappingNumber++; + } + + IortNode->MappingCount = IdMappingNumber; + + /* + * Node length can be determined by DT_LENGTH option + * IortNode->Length = NodeLength; + */ + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + NodeNumber++; + } + + Iort->NodeCount = NodeNumber; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileIvrs + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile IVRS. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileIvrs ( + 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_IVRS_HEADER *IvrsHeader; + UINT8 EntryType; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer); + + switch (IvrsHeader->Type) + { + case ACPI_IVRS_TYPE_HARDWARE: + + InfoTable = AcpiDmTableInfoIvrs0; + break; + + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + + InfoTable = AcpiDmTableInfoIvrs1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE) + { + while (*PFieldList && + !strcmp ((*PFieldList)->Name, "Entry Type")) + { + SubtableStart = *PFieldList; + DtCompileInteger (&EntryType, *PFieldList, 1, 0); + + switch (EntryType) + { + /* 4-byte device entries */ + + case ACPI_IVRS_TYPE_PAD4: + case ACPI_IVRS_TYPE_ALL: + case ACPI_IVRS_TYPE_SELECT: + case ACPI_IVRS_TYPE_START: + case ACPI_IVRS_TYPE_END: + + InfoTable = AcpiDmTableInfoIvrs4; + break; + + /* 8-byte entries, type A */ + + case ACPI_IVRS_TYPE_ALIAS_SELECT: + case ACPI_IVRS_TYPE_ALIAS_START: + + InfoTable = AcpiDmTableInfoIvrs8a; + break; + + /* 8-byte entries, type B */ + + case ACPI_IVRS_TYPE_PAD8: + case ACPI_IVRS_TYPE_EXT_SELECT: + case ACPI_IVRS_TYPE_EXT_START: + + InfoTable = AcpiDmTableInfoIvrs8b; + break; + + /* 8-byte entries, type C */ + + case ACPI_IVRS_TYPE_SPECIAL: + + InfoTable = AcpiDmTableInfoIvrs8c; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, + "IVRS Device Entry"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dttable2.c b/sys/contrib/dev/acpica/compiler/dttable2.c new file mode 100644 index 0000000..8297ba3 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/dttable2.c @@ -0,0 +1,1691 @@ +/****************************************************************************** + * + * Module Name: dttable2.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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. + */ + +/* Compile all complex data tables, signatures starting with L-Z */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttable2") + + +/****************************************************************************** + * + * 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; + + 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 + * + * RETURN: Status + * + * DESCRIPTION: Compile MADT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMadt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *MadtHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (MadtHeader->Type) + { + case ACPI_MADT_TYPE_LOCAL_APIC: + + InfoTable = AcpiDmTableInfoMadt0; + break; + + case ACPI_MADT_TYPE_IO_APIC: + + InfoTable = AcpiDmTableInfoMadt1; + break; + + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + + InfoTable = AcpiDmTableInfoMadt2; + break; + + case ACPI_MADT_TYPE_NMI_SOURCE: + + InfoTable = AcpiDmTableInfoMadt3; + break; + + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + + InfoTable = AcpiDmTableInfoMadt4; + break; + + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + + InfoTable = AcpiDmTableInfoMadt5; + break; + + case ACPI_MADT_TYPE_IO_SAPIC: + + InfoTable = AcpiDmTableInfoMadt6; + break; + + case ACPI_MADT_TYPE_LOCAL_SAPIC: + + InfoTable = AcpiDmTableInfoMadt7; + break; + + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: + + InfoTable = AcpiDmTableInfoMadt8; + break; + + case ACPI_MADT_TYPE_LOCAL_X2APIC: + + InfoTable = AcpiDmTableInfoMadt9; + break; + + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + + InfoTable = AcpiDmTableInfoMadt10; + break; + + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + + InfoTable = AcpiDmTableInfoMadt11; + break; + + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt12; + break; + + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + + case ACPI_MADT_TYPE_GENERIC_TRANSLATOR: + + InfoTable = AcpiDmTableInfoMadt15; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); + 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: DtCompileMcfg + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MCFG. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMcfg ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMpst + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MPST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMpst ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_MPST_CHANNEL *MpstChannelInfo; + ACPI_MPST_POWER_NODE *MpstPowerNode; + ACPI_MPST_DATA_HDR *MpstDataHeader; + UINT16 SubtableCount; + UINT32 PowerStateCount; + UINT32 ComponentCount; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer); + SubtableCount = MpstChannelInfo->PowerNodeCount; + + while (*PFieldList && SubtableCount) + { + /* Subtable: Memory Power Node(s) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer); + PowerStateCount = MpstPowerNode->NumPowerStates; + ComponentCount = MpstPowerNode->NumPhysicalComponents; + + ParentTable = DtPeekSubtable (); + + /* Sub-subtables - Memory Power State Structure(s) */ + + while (*PFieldList && PowerStateCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + PowerStateCount--; + } + + /* Sub-subtables - Physical Component ID Structure(s) */ + + while (*PFieldList && ComponentCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + ComponentCount--; + } + + SubtableCount--; + DtPopSubtable (); + } + + /* Subtable: Count of Memory Power State Characteristic structures */ + + DtPopSubtable (); + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer); + SubtableCount = MpstDataHeader->CharacteristicsCount; + + ParentTable = DtPeekSubtable (); + + /* Subtable: Memory Power State Characteristics structure(s) */ + + while (*PFieldList && SubtableCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + SubtableCount--; + } + + DtPopSubtable (); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMsct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MSCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMsct ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMtmr + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MTMR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMtmr ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileNfit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile NFIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileNfit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_NFIT_HEADER *NfitHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 Count; + ACPI_NFIT_INTERLEAVE *Interleave = NULL; + ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + /* Subtables */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer); + + switch (NfitHeader->Type) + { + case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: + + InfoTable = AcpiDmTableInfoNfit0; + break; + + case ACPI_NFIT_TYPE_MEMORY_MAP: + + InfoTable = AcpiDmTableInfoNfit1; + break; + + case ACPI_NFIT_TYPE_INTERLEAVE: + + Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer); + InfoTable = AcpiDmTableInfoNfit2; + break; + + case ACPI_NFIT_TYPE_SMBIOS: + + InfoTable = AcpiDmTableInfoNfit3; + break; + + case ACPI_NFIT_TYPE_CONTROL_REGION: + + InfoTable = AcpiDmTableInfoNfit4; + break; + + case ACPI_NFIT_TYPE_DATA_REGION: + + InfoTable = AcpiDmTableInfoNfit5; + break; + + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + + Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer); + InfoTable = AcpiDmTableInfoNfit6; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + + switch (NfitHeader->Type) + { + case ACPI_NFIT_TYPE_INTERLEAVE: + + Count = 0; + DtPushSubtable (Subtable); + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a, + &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + Interleave->LineCount = Count; + DtPopSubtable (); + break; + + case ACPI_NFIT_TYPE_SMBIOS: + + if (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + } + } + break; + + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + + Count = 0; + DtPushSubtable (Subtable); + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a, + &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + Hint->HintCount = (UINT16) Count; + DtPopSubtable (); + break; + + default: + break; + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * 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; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Subtables */ + + 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; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2: + + InfoTable = AcpiDmTableInfoPcct2; + 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 + * + * RETURN: Status + * + * DESCRIPTION: Compile PMTT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePmtt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_PMTT_HEADER *PmttHeader; + ACPI_PMTT_CONTROLLER *PmttController; + UINT16 DomainCount; + UINT8 PrevType = ACPI_PMTT_TYPE_SOCKET; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer); + while (PrevType >= PmttHeader->Type) + { + DtPopSubtable (); + + if (PrevType == ACPI_PMTT_TYPE_SOCKET) + { + break; + } + + PrevType--; + } + + PrevType = PmttHeader->Type; + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + switch (PmttHeader->Type) + { + case ACPI_PMTT_TYPE_SOCKET: + + /* Subtable: Socket Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + break; + + case ACPI_PMTT_TYPE_CONTROLLER: + + /* Subtable: Memory Controller Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER, + (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER))); + DomainCount = PmttController->DomainCount; + + while (DomainCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DomainCount--; + } + break; + + case ACPI_PMTT_TYPE_DIMM: + + /* Subtable: Physical Component Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT"); + return (AE_ERROR); + } + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileRsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile RSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileRsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT32 Address; + + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileS3pt + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile S3PT (Pointed to by FPDT) + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileS3pt ( + DT_FIELD **PFieldList) +{ + ACPI_STATUS Status; + ACPI_FPDT_HEADER *S3ptHeader; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + DT_FIELD *SubtableStart; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, + &Gbl_RootTable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtPushSubtable (Gbl_RootTable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); + + switch (S3ptHeader->Type) + { + case ACPI_S3PT_TYPE_RESUME: + + InfoTable = AcpiDmTableInfoS3pt0; + break; + + case ACPI_S3PT_TYPE_SUSPEND: + + InfoTable = AcpiDmTableInfoS3pt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); + 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: DtCompileSlic + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SLIC. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSlic ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSlit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SLIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSlit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *FieldList; + UINT32 Localities; + UINT8 *LocalityBuffer; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); + LocalityBuffer = UtLocalCalloc (Localities); + + /* Compile each locality buffer */ + + FieldList = *PFieldList; + while (FieldList) + { + DtCompileBuffer (LocalityBuffer, + FieldList->Value, FieldList, Localities); + + DtCreateSubtable (LocalityBuffer, Localities, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + ACPI_FREE (LocalityBuffer); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSrat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SRAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSrat ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *SratHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (SratHeader->Type) + { + case ACPI_SRAT_TYPE_CPU_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat0; + break; + + case ACPI_SRAT_TYPE_MEMORY_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat1; + break; + + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat2; + break; + + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); + 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: DtCompileStao + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile STAO. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileStao ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_STATUS Status; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Compile each ASCII namestring as a subtable */ + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileTcpa + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile TCPA. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileTcpa ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + ACPI_TABLE_TCPA_HDR *TcpaHeader; + DT_SUBTABLE *ParentTable; + ACPI_STATUS Status; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Examine the PlatformClass field to determine the table type. + * Either a client or server table. Only one. + */ + TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer); + + switch (TcpaHeader->PlatformClass) + { + case ACPI_TCPA_CLIENT_TABLE: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient, + &Subtable, TRUE); + break; + + case ACPI_TCPA_SERVER_TABLE: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer, + &Subtable, TRUE); + break; + + default: + + AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", + TcpaHeader->PlatformClass); + Status = AE_ERROR; + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetGenericTableInfo + * + * PARAMETERS: Name - Generic type name + * + * RETURN: Info entry + * + * DESCRIPTION: Obtain table info for a generic name entry + * + *****************************************************************************/ + +ACPI_DMTABLE_INFO * +DtGetGenericTableInfo ( + char *Name) +{ + ACPI_DMTABLE_INFO *Info; + UINT32 i; + + + if (!Name) + { + return (NULL); + } + + /* Search info table for name match */ + + for (i = 0; ; i++) + { + Info = AcpiDmTableInfoGeneric[i]; + if (Info->Opcode == ACPI_DMT_EXIT) + { + Info = NULL; + break; + } + + /* Use caseless compare for generic keywords */ + + if (!AcpiUtStricmp (Name, Info->Name)) + { + break; + } + } + + return (Info); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileUefi + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile UEFI. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileUefi ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT16 *DataOffset; + + + /* Compile the predefined portion of the UEFI table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DataOffset = (UINT16 *) (Subtable->Buffer + 16); + *DataOffset = sizeof (ACPI_TABLE_UEFI); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Compile the "generic" portion of the UEFI table. This + * part of the table is not predefined and any of the generic + * operators may be used. + */ + DtCompileGeneric ((void **) PFieldList, NULL, NULL); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileVrtc + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile VRTC. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileVrtc ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileWdat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile WDAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileWdat ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileWpbt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile WPBT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileWpbt ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_TABLE_WPBT *Table; + ACPI_STATUS Status; + UINT16 Length; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Compile the argument list subtable */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Extract the length of the Arguments buffer, insert into main table */ + + Length = (UINT16) Subtable->TotalLength; + Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); + Table->ArgumentsLength = Length; + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileXsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile XSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileXsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT64 Address; + + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileGeneric + * + * PARAMETERS: List - Current field list pointer + * Name - Field name to end generic compiling + * Length - Compiled table length to return + * + * RETURN: Status + * + * DESCRIPTION: Compile generic unknown table. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGeneric ( + void **List, + char *Name, + UINT32 *Length) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_DMTABLE_INFO *Info; + + + ParentTable = DtPeekSubtable (); + + /* + * Compile the "generic" portion of the table. This + * part of the table is not predefined and any of the generic + * operators may be used. + */ + + /* Find any and all labels in the entire generic portion */ + + DtDetectAllLabels (*PFieldList); + + /* Now we can actually compile the parse tree */ + + if (Length && *Length) + { + *Length = 0; + } + while (*PFieldList) + { + if (Name && !strcmp ((*PFieldList)->Name, Name)) + { + break; + } + + Info = DtGetGenericTableInfo ((*PFieldList)->Name); + if (!Info) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + + *PFieldList = (*PFieldList)->Next; + continue; + } + + Status = DtCompileTable (PFieldList, Info, + &Subtable, TRUE); + if (ACPI_SUCCESS (Status)) + { + DtInsertSubtable (ParentTable, Subtable); + if (Length) + { + *Length += Subtable->Length; + } + } + else + { + *PFieldList = (*PFieldList)->Next; + + if (Status == AE_NOT_FOUND) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + } + } + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c index 90b6b17..319ee29 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/compiler/dttemplate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,14 +57,27 @@ AcpiUtIsSpecialTable ( char *Signature); static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount); + +static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData); static ACPI_STATUS DtCreateAllTemplates ( void); +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance); + /******************************************************************************* * @@ -85,6 +98,7 @@ AcpiUtIsSpecialTable ( { if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT) || ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) || ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS) || ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME)) @@ -100,7 +114,7 @@ AcpiUtIsSpecialTable ( * * FUNCTION: DtCreateTemplates * - * PARAMETERS: Signature - ACPI table signature + * PARAMETERS: argv - Standard command line arguments * * RETURN: Status * @@ -110,32 +124,115 @@ AcpiUtIsSpecialTable ( ACPI_STATUS DtCreateTemplates ( - char *Signature) + char **argv) { - const ACPI_DMTABLE_DATA *TableData; - ACPI_STATUS Status; + char *Signature; + char *End; + unsigned long TableCount; + ACPI_STATUS Status = AE_OK; AslInitializeGlobals (); - /* Default (no signature) is DSDT */ + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Special cases for DSDT, ALL, and '*' + */ + + /* Default (no signature option) is DSDT */ - if (!Signature) + if (AcpiGbl_Optind < 3) { - Signature = "DSDT"; - goto GetTemplate; + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, 0); + goto Exit; } + AcpiGbl_Optind--; + Signature = argv[AcpiGbl_Optind]; AcpiUtStrupr (Signature); - if (!ACPI_STRCMP (Signature, "ALL") || - !ACPI_STRCMP (Signature, "*")) + + /* + * Multiple SSDT support (-T <ssdt count>) + */ + TableCount = strtoul (Signature, &End, 0); + if (Signature != End) + { + /* The count is used for table ID and method name - max is 254(+1) */ + + if (TableCount > 254) + { + fprintf (stderr, "%u SSDTs requested, maximum is 254\n", + (unsigned int) TableCount); + + Status = AE_LIMIT; + goto Exit; + } + + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, TableCount); + goto Exit; + } + + if (!strcmp (Signature, "ALL")) { /* Create all available/known templates */ Status = DtCreateAllTemplates (); - return (Status); + goto Exit; + } + + /* + * Normal case: Create template for each signature + */ + while (argv[AcpiGbl_Optind]) + { + Signature = argv[AcpiGbl_Optind]; + AcpiUtStrupr (Signature); + + Status = DtCreateOneTemplateFile (Signature, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + AcpiGbl_Optind++; } + +Exit: + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: DtCreateOneTemplateFile + * + * PARAMETERS: Signature - ACPI table signature + * + * RETURN: Status + * + * DESCRIPTION: Create one template file of the requested signature. + * + ******************************************************************************/ + +static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount) +{ + const ACPI_DMTABLE_DATA *TableData; + ACPI_STATUS Status; + + /* * Validate signature and get the template data: * 1) Signature must be 4 characters @@ -145,8 +242,8 @@ DtCreateTemplates ( if (strlen (Signature) != ACPI_NAME_SIZE) { fprintf (stderr, - "%s: Invalid ACPI table signature (length must be 4 characters)\n", - Signature); + "%s: Invalid ACPI table signature " + "(length must be 4 characters)\n", Signature); return (AE_ERROR); } @@ -163,7 +260,8 @@ DtCreateTemplates ( Signature = "FACP"; } -GetTemplate: + /* TableData will point to the template */ + TableData = AcpiDmGetTableData (Signature); if (TableData) { @@ -180,19 +278,7 @@ GetTemplate: return (AE_ERROR); } - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Status = DtCreateOneTemplate (Signature, TableData); - - - /* Shutdown ACPICA subsystem */ - - (void) AcpiTerminate (); - CmDeleteCaches (); + Status = DtCreateOneTemplate (Signature, TableCount, TableData); return (Status); } @@ -217,12 +303,6 @@ DtCreateAllTemplates ( ACPI_STATUS Status; - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - fprintf (stderr, "Creating all supported Template files\n"); /* Walk entire ACPI table data structure */ @@ -234,7 +314,7 @@ DtCreateAllTemplates ( if (TableData->Template) { Status = DtCreateOneTemplate (TableData->Signature, - TableData); + 0, TableData); if (ACPI_FAILURE (Status)) { return (Status); @@ -247,25 +327,31 @@ DtCreateAllTemplates ( * 1) DSDT/SSDT are AML tables, not data tables * 2) FACS and RSDP have non-standard headers */ - Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_DSDT, 0, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_SIG_SSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_OSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_FACS, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL); + Status = DtCreateOneTemplate (ACPI_RSDP_NAME, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); @@ -280,6 +366,7 @@ DtCreateAllTemplates ( * FUNCTION: DtCreateOneTemplate * * PARAMETERS: Signature - ACPI signature, NULL terminated. + * TableCount - Used for SSDTs in same file as DSDT * TableData - Entry in ACPI table data structure. * NULL if a special ACPI table. * @@ -292,12 +379,14 @@ DtCreateAllTemplates ( static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData) { char *DisasmFilename; FILE *File; ACPI_STATUS Status = AE_OK; - ACPI_SIZE Actual; + int Actual; + UINT32 i; /* New file will have a .asl suffix */ @@ -310,13 +399,17 @@ DtCreateOneTemplate ( return (AE_ERROR); } - /* Probably should prompt to overwrite the file */ - AcpiUtStrlwr (DisasmFilename); + if (!UtQueryForOverwrite (DisasmFilename)) + { + return (AE_ERROR); + } + File = fopen (DisasmFilename, "w+"); if (!File) { - fprintf (stderr, "Could not open output file %s\n", DisasmFilename); + fprintf (stderr, "Could not open output file %s\n", + DisasmFilename); return (AE_ERROR); } @@ -327,8 +420,16 @@ DtCreateOneTemplate ( AcpiOsPrintf ("/*\n"); AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * ")); - AcpiOsPrintf (" * Template for [%4.4s] ACPI Table\n", - Signature); + if (TableCount == 0) + { + AcpiOsPrintf (" * Template for [%4.4s] ACPI Table", + Signature); + } + else + { + AcpiOsPrintf (" * Template for [%4.4s] and %u [SSDT] ACPI Tables", + Signature, TableCount); + } /* Dump the actual ACPI table */ @@ -336,6 +437,8 @@ DtCreateOneTemplate ( { /* Normal case, tables that appear in AcpiDmTableData */ + AcpiOsPrintf (" (static data table)\n"); + if (Gbl_VerboseTemplates) { AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]" @@ -344,7 +447,7 @@ DtCreateOneTemplate ( else { AcpiOsPrintf (" * Format: [ByteLength]" - " FieldName : HexFieldValue\n */\n\n"); + " FieldName : HexFieldValue\n */\n"); } AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, @@ -352,32 +455,55 @@ DtCreateOneTemplate ( } else { - /* Special ACPI tables - DSDT, SSDT, FADT, RSDP */ + /* Special ACPI tables - DSDT, SSDT, OSDT, FACS, RSDP */ + + AcpiOsPrintf (" (AML byte code table)\n"); + AcpiOsPrintf (" */\n"); - AcpiOsPrintf (" */\n\n"); if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) { - Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File); - if (Actual != sizeof (TemplateDsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_DSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } + + /* Emit any requested SSDTs into the same file */ + + for (i = 1; i <= TableCount; i++) + { + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, i + 1); + if (Actual < 0) + { + Status = AE_ERROR; + goto Cleanup; + } + } } else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT)) { - Actual = fwrite (TemplateSsdt, 1, sizeof (TemplateSsdt) -1, File); - if (Actual != sizeof (TemplateSsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } } - else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */ + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT)) + { + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_OSDT, 1); + if (Actual < 0) + { + Status = AE_ERROR; + goto Cleanup; + } + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) { AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, TemplateFacs)); @@ -396,12 +522,72 @@ DtCreateOneTemplate ( } } - fprintf (stderr, - "Created ACPI table template for [%4.4s], written to \"%s\"\n", - Signature, DisasmFilename); + if (TableCount == 0) + { + fprintf (stderr, + "Created ACPI table template for [%4.4s], " + "written to \"%s\"\n", + Signature, DisasmFilename); + } + else + { + fprintf (stderr, + "Created ACPI table templates for [%4.4s] " + "and %u [SSDT], written to \"%s\"\n", + Signature, TableCount, DisasmFilename); + } Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); return (Status); } + + +/******************************************************************************* + * + * FUNCTION: DtEmitDefinitionBlock + * + * PARAMETERS: File - An open file for the block + * Filename - Filename for same, for error msg(s) + * Signature - ACPI signature for the block + * Instance - Used for multiple SSDTs in the same file + * + * RETURN: Status from fprintf + * + * DESCRIPTION: Emit the raw ASL for a complete Definition Block (DSDT or SSDT) + * + * Note: The AMLFileName parameter for DefinitionBlock is left as a NULL + * string. This allows the compiler to create the output AML filename from + * the input filename. + * + ******************************************************************************/ + +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance) +{ + int Status; + + + Status = fprintf (File, + "DefinitionBlock (\"\", \"%4.4s\", 2, \"Intel\", \"_%4.4s_%.2X\", 0x00000001)\n" + "{\n" + " Method (%2.2s%.2X)\n" + " {\n" + " }\n" + "}\n\n", + Signature, Signature, Instance, Signature, Instance); + + if (Status < 0) + { + fprintf (stderr, + "Could not write %4.4s to output file %s\n", + Signature, Filename); + } + + return (Status); +} diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h index 1b27b4e..23ef051 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/compiler/dttemplate.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,27 +45,6 @@ #define __DTTEMPLATE_H -/* Special templates for DSDT and SSDT (AML byte-code tables) */ - -const char TemplateDsdt[] = - "DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - -const char TemplateSsdt[] = - "DefinitionBlock (\"ssdt.aml\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - - /* Templates for ACPI data tables */ const unsigned char TemplateAsf[] = @@ -564,11 +543,11 @@ const unsigned char TemplateHpet[] = const unsigned char TemplateIort[] = { - 0x49,0x4F,0x52,0x54,0x0C,0x01,0x00,0x00, /* 00000000 "IORT...." */ - 0x00,0xBC,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x49,0x4F,0x52,0x54,0x48,0x01,0x00,0x00, /* 00000000 "IORTH..." */ + 0x00,0x02,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" */ - 0x10,0x04,0x15,0x20,0x04,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x12,0x02,0x16,0x20,0x05,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "4......." */ 0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00, /* 00000030 ".....,.." */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ @@ -597,7 +576,14 @@ const unsigned char TemplateIort[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */ - 0x00,0x00,0x00,0x00 /* 00000108 "...." */ + 0x00,0x00,0x00,0x00,0x04,0x3C,0x00,0x00, /* 00000108 ".....<.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "<......." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000128 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000140 "........" */ }; const unsigned char TemplateIvrs[] = @@ -858,28 +844,39 @@ const unsigned char TemplateMtmr[] = 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" */ + 0x50,0x43,0x43,0x54,0x06,0x01,0x00,0x00, /* 00000000 "PCCT...." */ + 0x01,0xE3,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" */ - 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ + 0x18,0x03,0x16,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 "........" */ + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ + 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ + 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ + 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ + 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ + 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ + 0x77,0x77,0x77,0x77,0x88,0x88,0x01,0x3E, /* 00000068 "wwww...>" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,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 "...." */ + 0x00,0x03,0x44,0x44,0x44,0x44,0x44,0x44, /* 00000088 "..DDDDDD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 00000090 "DDDDDDDD" */ + 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55, /* 00000098 "DDUUUUUU" */ + 0x55,0x55,0x66,0x66,0x66,0x66,0x77,0x77, /* 000000A0 "UUffffww" */ + 0x77,0x77,0x88,0x88,0x02,0x5A,0x01,0x00, /* 000000A8 "ww...Z.." */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x32,0x00,0x03, /* 000000C0 ".....2.." */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 000000C8 "DDDDDDDD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 000000D0 "DDDDDDDD" */ + 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* 000000D8 "UUUUUUUU" */ + 0x66,0x66,0x66,0x66,0x77,0x77,0x77,0x77, /* 000000E0 "ffffwwww" */ + 0x88,0x88,0x01,0x32,0x00,0x03,0x33,0x33, /* 000000E8 "...2..33" */ + 0x33,0x33,0x33,0x33,0x33,0x33,0x44,0x44, /* 000000F0 "333333DD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x55,0x55, /* 000000F8 "DDDDDDUU" */ + 0x55,0x55,0x55,0x55,0x55,0x55 /* 00000100 "UUUUUU" */ }; const unsigned char TemplatePmtt[] = @@ -1135,13 +1132,19 @@ const unsigned char TemplateStao[] = const unsigned char TemplateTcpa[] = { - 0x54,0x43,0x50,0x41,0x32,0x00,0x00,0x00, /* 00000000 "TCPA2..." */ - 0x01,0x67,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".gINTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x54,0x43,0x50,0x41,0x64,0x00,0x00,0x00, /* 00000000 "TCPAd..." */ + 0x02,0xFF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x80,0x31,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 ".1..INTL" */ - 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00 /* 00000030 ".." */ + 0x19,0x06,0x15,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x11,0x00,0xFF,0xEE,0xDD,0xCC,0xBB,0xAA, /* 00000030 "........" */ + 0x02,0x01,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x03, /* 00000040 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x03, /* 00000050 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x01,0x01,0x01,0x01 /* 00000060 "...." */ }; const unsigned char TemplateTpm2[] = diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c index 2d5b762..2f3fdcd 100644 --- a/sys/contrib/dev/acpica/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/compiler/dtutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -241,7 +241,7 @@ DtStrtoul64 ( while (*ThisChar) { - if (ACPI_IS_DIGIT (*ThisChar)) + if (isdigit ((int) *ThisChar)) { /* Convert ASCII 0-9 to Decimal value */ @@ -249,8 +249,8 @@ DtStrtoul64 ( } else /* Letter */ { - ThisDigit = (UINT32) ACPI_TOUPPER (*ThisChar); - if (!ACPI_IS_XDIGIT ((char) ThisDigit)) + ThisDigit = (UINT32) toupper ((int) *ThisChar); + if (!isxdigit ((int) ThisDigit)) { /* Not A-F */ @@ -568,7 +568,7 @@ DtGetFieldLength ( Value = DtGetFieldValue (Field); if (Value) { - ByteLength = ACPI_STRLEN (Value) + 1; + ByteLength = strlen (Value) + 1; } else { /* At this point, this is a fatal error */ @@ -633,7 +633,7 @@ DtGetFieldLength ( /* TBD: error if Value is NULL? (as below?) */ - ByteLength = (ACPI_STRLEN (Value) + 1) * sizeof(UINT16); + ByteLength = (strlen (Value) + 1) * sizeof(UINT16); break; default: diff --git a/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h index 9dc2bdb..50759b5 100644 --- a/sys/contrib/dev/acpica/compiler/preprocess.h +++ b/sys/contrib/dev/acpica/compiler/preprocess.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prexpress.c b/sys/contrib/dev/acpica/compiler/prexpress.c index 0f0d938..32e2b62 100644 --- a/sys/contrib/dev/acpica/compiler/prexpress.c +++ b/sys/contrib/dev/acpica/compiler/prexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +84,7 @@ PrUnTokenize ( { return; } + if (Buffer[Length] != '\n') { Buffer[strlen(Buffer)] = ' '; diff --git a/sys/contrib/dev/acpica/compiler/prmacros.c b/sys/contrib/dev/acpica/compiler/prmacros.c index 866d089..0849903 100644 --- a/sys/contrib/dev/acpica/compiler/prmacros.c +++ b/sys/contrib/dev/acpica/compiler/prmacros.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -387,7 +387,8 @@ PrAddMacro ( { UseCount = Args[i].UseCount; - Args[i].Offset[UseCount] = (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; + Args[i].Offset[UseCount] = + (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Macro Arg #%u: %s UseCount %u Offset %u \n", diff --git a/sys/contrib/dev/acpica/compiler/prparser.l b/sys/contrib/dev/acpica/compiler/prparser.l index 3150b69..18d78f7 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.l +++ b/sys/contrib/dev/acpica/compiler/prparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,14 +50,22 @@ #define STRING_SETUP strcpy (StringBuffer, PrParsertext);\ PrParserlval.str = StringBuffer -#define YY_NO_INPUT /* No file input, we use strings only */ - #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("prscanner") + + +/* Local prototypes */ + +static char +PrDoCommentType1 ( + void); + +static char +PrDoCommentType2 ( + void); %} %option noyywrap -%option nounput Number [0-9a-fA-F]+ HexNumber 0[xX][0-9a-fA-F]+ @@ -66,6 +74,8 @@ NewLine [\n] Identifier [a-zA-Z][0-9a-zA-Z]* %% +"/*" { if (!PrDoCommentType1 ()) {yyterminate ();} } +"//" { if (!PrDoCommentType2 ()) {yyterminate ();} } \( return (EXPOP_PAREN_OPEN); \) return (EXPOP_PAREN_CLOSE); @@ -151,3 +161,76 @@ PrTerminateLexer ( yy_delete_buffer (LexBuffer); } + + +/******************************************************************************** + * + * FUNCTION: PrDoCommentType1 + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a new legacy comment. Just toss it. + * + ******************************************************************************/ + +static char +PrDoCommentType1 ( + void) +{ + int c; + + +Loop: + while (((c = input ()) != '*') && (c != EOF)) + { + } + if (c == EOF) + { + return (FALSE); + } + + if (((c = input ()) != '/') && (c != EOF)) + { + unput (c); + goto Loop; + } + if (c == EOF) + { + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************** + * + * FUNCTION: PrDoCommentType2 + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a new "//" comment. Just toss it. + * + ******************************************************************************/ + +static char +PrDoCommentType2 ( + void) +{ + int c; + + + while (((c = input ()) != '\n') && (c != EOF)) + { + } + if (c == EOF) + { + return (FALSE); + } + + return (TRUE); +} diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y index 20d6e6a..749f7d5 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.y +++ b/sys/contrib/dev/acpica/compiler/prparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,13 @@ #define _COMPONENT ASL_PREPROCESSOR ACPI_MODULE_NAME ("prparser") +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#undef alloca +#define alloca AslLocalAllocate + int PrParserlex (void); int PrParserparse (void); void PrParsererror (char const *msg); @@ -175,11 +182,11 @@ Expression /* Default base for a non-prefixed integer is 10 */ - | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (PrParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (PrParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% @@ -206,8 +213,11 @@ void PrParsererror ( char const *Message) { + + sprintf (StringBuffer, "Preprocessor Parser : %s (near line %u)", + Message, Gbl_CurrentLineNumber); DtError (ASL_ERROR, ASL_MSG_SYNTAX, - NULL, (char *) Message); + NULL, (char *) StringBuffer); } diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c index 12d303c..c02280d 100644 --- a/sys/contrib/dev/acpica/compiler/prscan.c +++ b/sys/contrib/dev/acpica/compiler/prscan.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,14 @@ PrDoDirective ( char *DirectiveToken, char **Next); +static void +PrGetNextLineInit ( + void); + +static UINT32 +PrGetNextLine ( + FILE *Handle); + static int PrMatchDirective ( char *Directive); @@ -112,7 +120,6 @@ static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] = {"include", 0}, /* Argument is not standard format, so just use 0 here */ {"includebuffer", 0}, /* Argument is not standard format, so just use 0 here */ {"line", 1}, - {"loadbuffer", 0}, {"pragma", 1}, {"undef", 1}, {"warning", 1}, @@ -136,7 +143,7 @@ enum Gbl_DirectiveIndexes PR_DIRECTIVE_LINE, PR_DIRECTIVE_PRAGMA, PR_DIRECTIVE_UNDEF, - PR_DIRECTIVE_WARNING, + PR_DIRECTIVE_WARNING }; #define ASL_DIRECTIVE_NOT_FOUND -1 @@ -186,7 +193,7 @@ PrInitializeGlobals ( /* Init globals */ Gbl_InputFileList = NULL; - Gbl_CurrentLineNumber = 0; + Gbl_CurrentLineNumber = 1; Gbl_PreprocessorLineNumber = 1; Gbl_PreprocessorError = FALSE; @@ -271,7 +278,7 @@ PrDoPreprocess ( } while (MoreInputFiles); - /* Point compiler input to the new preprocessor output file (.i) */ + /* Point compiler input to the new preprocessor output file (.pre) */ FlCloseFile (ASL_FILE_INPUT); Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle; @@ -280,7 +287,10 @@ PrDoPreprocess ( /* Reset globals to allow compiler to run */ FlSeekFile (ASL_FILE_INPUT, 0); - Gbl_CurrentLineNumber = 1; + if (!Gbl_PreprocessOnly) + { + Gbl_CurrentLineNumber = 0; + } DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n"); } @@ -297,7 +307,8 @@ PrDoPreprocess ( * DESCRIPTION: Preprocess one entire file, line-by-line. * * Input: Raw user ASL from ASL_FILE_INPUT - * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR + * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR and + * (optionally) ASL_FILE_PREPROCESSOR_USER * ******************************************************************************/ @@ -305,7 +316,7 @@ static void PrPreprocessInputFile ( void) { - UINT32 Offset; + UINT32 Status; char *Token; char *ReplaceString; PR_DEFINE_INFO *DefineInfo; @@ -314,10 +325,20 @@ PrPreprocessInputFile ( int OffsetAdjust; - /* Scan line-by-line. Comments and blank lines are skipped by this function */ + PrGetNextLineInit (); + + /* Scan source line-by-line and process directives. Then write the .i file */ - while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) + while ((Status = PrGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) { + Gbl_CurrentLineNumber++; + Gbl_LogicalLineNumber++; + + if (Status == ASL_IGNORE_LINE) + { + goto WriteEntireLine; + } + /* Need a copy of the input line for strok() */ strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer); @@ -397,24 +418,13 @@ PrPreprocessInputFile ( Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); } - /* - * Emit a #line directive if necessary, to keep the line numbers in - * the (.i) file synchronized with the original source code file, so - * that the correct line number appears in any error messages - * generated by the actual compiler. - */ - if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1)) - { - FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n", - Gbl_CurrentLineNumber); - } - - Gbl_PreviousLineNumber = Gbl_CurrentLineNumber; Gbl_PreprocessorLineNumber++; + +WriteEntireLine: /* * Now we can write the possibly modified source line to the - * preprocessor (.i) file + * preprocessor file(s). */ FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, strlen (Gbl_CurrentLineBuffer)); @@ -467,6 +477,16 @@ PrDoDirective ( } /* + * Emit a line directive into the preprocessor file (.pre) after + * every matched directive. This is passed through to the compiler + * so that error/warning messages are kept in sync with the + * original source file. + */ + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\" // #%s\n", + Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename, + Gbl_DirectiveInfo[Directive].Name); + + /* * If we are currently ignoring this block and we encounter a #else or * #elif, we must ignore their blocks also if the parent block is also * being ignored. @@ -478,7 +498,8 @@ PrDoDirective ( case PR_DIRECTIVE_ELSE: case PR_DIRECTIVE_ELIF: - if (Gbl_DirectiveStack && Gbl_DirectiveStack->IgnoringThisCodeBlock) + if (Gbl_DirectiveStack && + Gbl_DirectiveStack->IgnoringThisCodeBlock) { PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name); return; @@ -653,8 +674,9 @@ PrDoDirective ( if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') { #ifndef MACROS_SUPPORTED - AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", - Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber); + AcpiOsPrintf ( + "%s ERROR - line %u: #define macros are not supported yet\n", + Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber); exit(1); #else PrAddMacro (Token, Next); @@ -671,11 +693,13 @@ PrDoDirective ( { Token2++; } + End = Token2; while (*End != '\n') { End++; } + *End = 0; } else @@ -691,7 +715,7 @@ PrDoDirective ( #endif DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID "New #define: %s->%s\n", - Gbl_CurrentLineNumber, Token, Token2); + Gbl_LogicalLineNumber, Token, Token2); PrAddDefine (Token, Token2, FALSE); } @@ -760,10 +784,7 @@ PrDoDirective ( "User #line invocation %s\n", Gbl_CurrentLineNumber, Token); - /* Update local line numbers */ - Gbl_CurrentLineNumber = (UINT32) Value; - Gbl_PreviousLineNumber = 0; /* Emit #line into the preprocessor file */ @@ -816,6 +837,9 @@ PrDoDirective ( PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE, THIS_TOKEN_OFFSET (Token)); + + Gbl_SourceLine = 0; + Gbl_NextError = Gbl_ErrorLog; break; default: @@ -839,6 +863,166 @@ SyntaxError: /******************************************************************************* * + * FUNCTION: PrGetNextLine, PrGetNextLineInit + * + * PARAMETERS: Handle - Open file handle for the source file + * + * RETURN: Status of the GetLine operation: + * AE_OK - Normal line, OK status + * ASL_IGNORE_LINE - Line is blank or part of a multi-line + * comment + * ASL_EOF - End-of-file reached + * + * DESCRIPTION: Get the next text line from the input file. Does not strip + * comments. + * + ******************************************************************************/ + +#define PR_NORMAL_TEXT 0 +#define PR_MULTI_LINE_COMMENT 1 +#define PR_SINGLE_LINE_COMMENT 2 +#define PR_QUOTED_STRING 3 + +static UINT8 AcpiGbl_LineScanState = PR_NORMAL_TEXT; + +static void +PrGetNextLineInit ( + void) +{ + AcpiGbl_LineScanState = 0; +} + +static UINT32 +PrGetNextLine ( + FILE *Handle) +{ + UINT32 i; + int c = 0; + int PreviousChar; + + + /* Always clear the global line buffer */ + + memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); + for (i = 0; ;) + { + /* + * If line is too long, expand the line buffers. Also increases + * Gbl_LineBufferSize. + */ + if (i >= Gbl_LineBufferSize) + { + UtExpandLineBuffers (); + } + + PreviousChar = c; + c = getc (Handle); + if (c == EOF) + { + /* + * On EOF: If there is anything in the line buffer, terminate + * it with a newline, and catch the EOF on the next call + * to this function. + */ + if (i > 0) + { + Gbl_CurrentLineBuffer[i] = '\n'; + return (AE_OK); + } + + return (ASL_EOF); + } + + /* Update state machine as necessary */ + + switch (AcpiGbl_LineScanState) + { + case PR_NORMAL_TEXT: + + /* Check for multi-line comment start */ + + if ((PreviousChar == '/') && (c == '*')) + { + AcpiGbl_LineScanState = PR_MULTI_LINE_COMMENT; + } + + /* Check for single-line comment start */ + + else if ((PreviousChar == '/') && (c == '/')) + { + AcpiGbl_LineScanState = PR_SINGLE_LINE_COMMENT; + } + + /* Check for quoted string start */ + + else if (PreviousChar == '"') + { + AcpiGbl_LineScanState = PR_QUOTED_STRING; + } + break; + + case PR_QUOTED_STRING: + + if (PreviousChar == '"') + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + } + break; + + case PR_MULTI_LINE_COMMENT: + + /* Check for multi-line comment end */ + + if ((PreviousChar == '*') && (c == '/')) + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + } + break; + + case PR_SINGLE_LINE_COMMENT: /* Just ignore text until EOL */ + default: + break; + } + + /* Always copy the character into line buffer */ + + Gbl_CurrentLineBuffer[i] = (char) c; + i++; + + /* Always exit on end-of-line */ + + if (c == '\n') + { + /* Handle multi-line comments */ + + if (AcpiGbl_LineScanState == PR_MULTI_LINE_COMMENT) + { + return (ASL_IGNORE_LINE); + } + + /* End of single-line comment */ + + if (AcpiGbl_LineScanState == PR_SINGLE_LINE_COMMENT) + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + return (AE_OK); + } + + /* Blank line */ + + if (i == 1) + { + return (ASL_IGNORE_LINE); + } + + return (AE_OK); + } + } +} + + +/******************************************************************************* + * * FUNCTION: PrMatchDirective * * PARAMETERS: Directive - Pointer to directive name token diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c index 7e880b1..c4c9dd6 100644 --- a/sys/contrib/dev/acpica/compiler/prutils.c +++ b/sys/contrib/dev/acpica/compiler/prutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,8 +122,10 @@ PrGetNextToken ( { *Next = NULL; } + return (TokenStart); } + Buffer++; } @@ -382,6 +384,8 @@ PrPushInputFileStack ( PR_FILE_NODE *Fnode; + Gbl_HasIncludeFiles = TRUE; + /* Save the current state in an Fnode */ Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE)); @@ -406,8 +410,7 @@ PrPushInputFileStack ( strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; - Gbl_PreviousLineNumber = 0; - Gbl_CurrentLineNumber = 0; + Gbl_CurrentLineNumber = 1; /* Emit a new #line directive for the include file */ @@ -460,12 +463,11 @@ PrPopInputFileStack ( Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File; Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; - Gbl_PreviousLineNumber = 0; /* Emit a new #line directive after the include file */ FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", - Gbl_CurrentLineNumber + 1, Fnode->Filename); + Gbl_CurrentLineNumber, Fnode->Filename); /* All done with this node */ |