diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2015-11-25 21:04:42 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2015-11-25 21:04:42 +0000 |
commit | b9098066cd6284319bca922f13e59517f774a103 (patch) | |
tree | f01fd6c9053cb01ed84c00cb42ee789adafceaf5 /source/compiler | |
parent | 1e24cf365bc9c8df179b145c90d52852724e54ee (diff) |
Notes
Diffstat (limited to 'source/compiler')
60 files changed, 4240 insertions, 3732 deletions
diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index 45c4431abb74d..fd717639c3902 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -139,8 +139,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 +190,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 +230,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; } } @@ -323,7 +322,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 +400,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); diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index 4b6fd4fe57cdc..ed546352b4e2b 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -78,7 +78,6 @@ AnMapArgTypeToBtype ( switch (ArgType) { - /* Simple types */ case ARGI_ANYTYPE: @@ -221,7 +220,6 @@ AnMapEtypeToBtype ( UINT32 Etype) { - if (Etype == ACPI_TYPE_ANY) { return (ACPI_BTYPE_OBJECTS_AND_REFS); @@ -328,7 +326,6 @@ AnFormatBtype ( *Buffer = 0; - if (Btype == 0) { strcat (Buffer, "NoReturnValue"); @@ -343,6 +340,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, AcpiUtGetTypeName (Type)); } @@ -355,6 +353,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Reference"); } @@ -366,6 +365,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Resource"); } @@ -409,7 +409,8 @@ AnGetBtype ( if (!Node) { 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\n", Op->Asl.ParseOpName, Op->Asl.LineNumber, Op->Asl.ExternalName); return (ACPI_UINT32_MAX); @@ -457,6 +458,7 @@ AnGetBtype ( return (ThisNodeBtype); } + /******************************************************************************* * * FUNCTION: AnMapObjTypeToBtype diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index dc8b7d51e626e..cb3a4a5c78318 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -168,28 +168,28 @@ CgAmlWriteWalk ( } DbgPrint (ASL_TREE_OUTPUT, - "%08X %04X %04X %01X %04X %04X %04X %04X " - "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %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, - /* 18 */ Op->Asl.EndLine, - /* 19 */ Op->Asl.LogicalLineNumber, - /* 20 */ Op->Asl.EndLogicalLine); + "%08X %04X %04X %01X %04X %04X %04X %04X " + "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %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, + /* 18 */ Op->Asl.EndLine, + /* 19 */ Op->Asl.LogicalLineNumber, + /* 20 */ Op->Asl.EndLogicalLine); /* Generate the AML for this node */ @@ -274,7 +274,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: @@ -357,8 +358,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); @@ -467,50 +470,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 */ - TableHeader.Checksum = (UINT8) (0 - Sum); + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + + ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum)); - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + 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; + + + /* Process all definition blocks */ + + Op = RootNode->Asl.Child; + while (Op) + { + CgUpdateHeader (Op); + Op = Op->Asl.Next; + } } @@ -586,7 +639,7 @@ CgWriteNode ( break; - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: CgWriteTableHeader (Op); break; diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index a45814e48f3c9..a564f8629c882 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -130,7 +130,8 @@ 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; } @@ -165,7 +166,7 @@ CmDoCompile ( LsDumpParseTree (); - OpcGetIntegerWidth (RootNode); + OpcGetIntegerWidth (RootNode->Asl.Child); UtEndEvent (Event); /* Pre-process parse tree for any operator transforms */ @@ -186,8 +187,8 @@ CmDoCompile ( /* * 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); @@ -263,7 +264,8 @@ CmDoCompile ( /* Namespace cross-reference */ - AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); + AslGbl_NamespaceEvent = UtBeginEvent ( + "Cross reference parse tree and Namespace"); Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { @@ -301,7 +303,8 @@ CmDoCompile ( /* 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"); + DbgPrint (ASL_DEBUG_OUTPUT, + "\nSemantic analysis - Operand type checking\n\n"); if (Gbl_DoTypechecking) { TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, @@ -590,8 +593,8 @@ CmDumpAllEvents ( { ASL_EVENT_INFO *Event; UINT32 Delta; - UINT32 USec; - UINT32 MSec; + UINT32 MicroSeconds; + UINT32 MilliSeconds; UINT32 i; @@ -611,23 +614,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); } } diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 37e99ae6eef7a..b9796a6c0d496 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -210,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); } diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 4f430d11d0487..2c0516a56a857 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -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, @@ -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/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 4db97a67358aa..676eaf16835e2 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -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); } @@ -269,7 +270,8 @@ FlPrintFile ( AslAbort (); } - if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag) + if ((FileId == ASL_FILE_PREPROCESSOR) && + Gbl_PreprocessorOutputFlag) { /* * Duplicate the output to the user preprocessor (.i) file, @@ -291,7 +293,6 @@ FlPrintFile ( AslAbort (); } } - } diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 1b738ccf15d88..3ef1be06cb6c3 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -56,7 +56,6 @@ FlOpenIncludeWithPrefix ( ACPI_PARSE_OBJECT *Op, char *Filename); - #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS FlParseInputPathname ( @@ -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); @@ -422,7 +422,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; @@ -435,7 +436,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; diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index 0b3ef8d166a9d..276b963a4ba98 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -100,7 +100,7 @@ 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. * ******************************************************************************/ @@ -206,7 +206,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 a downward walk of the parse subtree. * ******************************************************************************/ @@ -218,6 +219,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,21 +231,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) - { - DbgPrint (ASL_PARSE_OUTPUT, - "\nBuffer+Buffer->Buffer constant reduction is not supported yet"); - Status = AE_TYPE; - goto CleanupAndExit; - } - - /* * These opcodes do not appear in the OpcodeInfo table, but * they represent constants, so abort the constant walk now. */ @@ -256,11 +244,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) { @@ -272,13 +344,36 @@ 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"); @@ -294,6 +389,7 @@ OpcAmlCheckForConstant ( DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET"); } } + if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) { DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG"); diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c index a255daa1ed966..185845c9cad06 100644 --- a/source/compiler/aslhex.c +++ b/source/compiler/aslhex.c @@ -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/source/compiler/asllength.c b/source/compiler/asllength.c index 8e876c7b6b332..0399124fc6116 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -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: diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 34277459844e1..91ddcac43a23b 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -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); } @@ -316,7 +323,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 +369,46 @@ LsWriteNodeToListing ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: 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; @@ -540,31 +557,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/source/compiler/asllistsup.c b/source/compiler/asllistsup.c index 21ffb74f8d21d..c073c1f420f17 100644 --- a/source/compiler/asllistsup.c +++ b/source/compiler/asllistsup.c @@ -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/source/compiler/aslload.c b/source/compiler/aslload.c index 0f68e0c4f5b0d..8da8b806aa92e 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -196,12 +196,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 +265,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 +295,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 +343,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 +500,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 +509,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 +534,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 +598,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 +620,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 +640,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 +653,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,6 +687,17 @@ 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 @@ -818,8 +858,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 +872,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/source/compiler/aslmap.c b/source/compiler/aslmap.c index 53382045c4201..a69d5c0e41e57 100644 --- a/source/compiler/aslmap.c +++ b/source/compiler/aslmap.c @@ -479,6 +479,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/source/compiler/aslmapenter.c b/source/compiler/aslmapenter.c index 8ab3e6273241b..06a86235fab16 100644 --- a/source/compiler/aslmapenter.c +++ b/source/compiler/aslmapenter.c @@ -239,7 +239,7 @@ MpCreateGpioInfo ( /* Sort on source DeviceName first */ while (NextGpio && - (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) && - !strcmp (DeviceName, NextGpio->DeviceName)) + (NextGpio->PinNumber < PinNumber) && + !strcmp (DeviceName, NextGpio->DeviceName)) { PrevGpio = NextGpio; NextGpio = NextGpio->Next; diff --git a/source/compiler/aslmapoutput.c b/source/compiler/aslmapoutput.c index 07ed89a1eb59d..4d2e0e92f8ad1 100644 --- a/source/compiler/aslmapoutput.c +++ b/source/compiler/aslmapoutput.c @@ -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); } diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index bd693110e0a59..244e72ecb73d9 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -238,8 +238,9 @@ const char *AslCompilerMsgs [] = /* 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_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/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index d7e3dd06e8b68..440513f9a7e34 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -241,6 +241,8 @@ typedef enum 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/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index 40ed971e07122..bf3a683f8d940 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -101,7 +101,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 +186,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 +197,7 @@ MtMethodAnalysisWalkBegin ( { MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; ActualArgs++; } @@ -251,7 +254,8 @@ 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); } @@ -294,7 +298,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 +322,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); } @@ -418,7 +423,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; @@ -495,9 +501,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 +684,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/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c index e2dea6fff5f6b..4be3981da5aff 100644 --- a/source/compiler/aslnamesp.c +++ b/source/compiler/aslnamesp.c @@ -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)) @@ -417,6 +425,5 @@ NsDoOnePathname ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); ACPI_FREE (TargetPath.Pointer); - return (AE_OK); } diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index a7f14de6d3b81..29e9d795c7be7 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -260,7 +260,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 +330,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 +400,7 @@ OpcDoAccessAs ( { AttribOp->Asl.Value.Integer = 0; } + AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; @@ -486,21 +489,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 +567,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 +576,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); } @@ -1330,9 +1333,9 @@ OpcDoPld ( NewOp = TrAllocateNode (PARSEOP_INTEGER); - NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.AmlOpcode = AML_BYTE_OP; NewOp->Asl.Value.Integer = 20; - NewOp->Asl.Parent = Op; + NewOp->Asl.Parent = Op; Op->Asl.Child = NewOp; Op = NewOp; @@ -1340,10 +1343,10 @@ OpcDoPld ( /* 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; + 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; } @@ -1398,9 +1401,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; @@ -1408,10 +1411,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; } diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 913ac90a7abc2..cdef7fab53f21 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -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 */ @@ -1131,7 +1134,7 @@ OpnGenerateAmlOperands ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: OpnDoDefinitionBlock (Op); break; diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index e41e22f087b09..05af0bef34ed4 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -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); @@ -172,8 +172,8 @@ OptSearchToRoot ( 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); @@ -292,7 +292,7 @@ OptBuildShortestPath ( /* Determine how many prefix Carats are required */ NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - - NumCommonSegments; + NumCommonSegments; /* * Construct a new target string @@ -373,8 +373,8 @@ OptBuildShortestPath ( * path that has been created. */ Status = AcpiNsLookup (&ScopeInfo, 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 */ @@ -446,7 +446,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 +458,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 +474,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 */ @@ -633,6 +633,7 @@ OptOptimizeNamePath ( { NextOp = NextOp->Asl.Parent; } + if (NextOp && NextOp->Asl.Node) { CurrentNode = NextOp->Asl.Node; @@ -662,6 +663,7 @@ OptOptimizeNamePath ( 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) */ @@ -674,12 +676,13 @@ OptOptimizeNamePath ( 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 +708,7 @@ OptOptimizeNamePath ( * a reference. */ Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode, - TargetNode, AmlNameString, &NewPath); + TargetNode, AmlNameString, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -713,8 +716,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 +729,7 @@ OptOptimizeNamePath ( * NameSeg of the NamePath */ Status = OptSearchToRoot (Op, WalkState, CurrentNode, - TargetNode, &TargetPath, &NewPath); + TargetNode, &TargetPath, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -734,8 +737,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); } } diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index ef6ad8b5381c9..2473a8d142cbc 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -331,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); } diff --git a/source/compiler/aslpredef.c b/source/compiler/aslpredef.c index 268549cfaade1..7dd10b5fe60b8 100644 --- a/source/compiler/aslpredef.c +++ b/source/compiler/aslpredef.c @@ -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) @@ -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/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index eb621274f6203..ff80b57474c6d 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -238,6 +238,7 @@ ApCheckPackage ( ApCheckObjectType (Predefined->Info.Name, Op, Package->RetInfo3.TailObjectType, i); } + Op = Op->Asl.Next; } break; diff --git a/source/compiler/aslprune.c b/source/compiler/aslprune.c index 3cf47da4e9f08..a797d2ecc009c 100644 --- a/source/compiler/aslprune.c +++ b/source/compiler/aslprune.c @@ -63,6 +63,8 @@ PrPrintObjectAtLevel ( const char *ObjectName); +/* Structure used for the pruning parse tree walk */ + typedef struct acpi_prune_info { UINT32 PruneLevel; diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index 1b96a362d5544..895d69c18fcee 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -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; } @@ -888,7 +887,7 @@ RsDoOneResourceDescriptor ( default: printf ("Unknown resource descriptor type [%s]\n", - Info->DescriptorTypeOp->Asl.ParseOpName); + Info->DescriptorTypeOp->Asl.ParseOpName); break; } @@ -904,7 +903,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/source/compiler/aslrestype1.c b/source/compiler/aslrestype1.c index 92c8730f1e524..3f967ca453c23 100644 --- a/source/compiler/aslrestype1.c +++ b/source/compiler/aslrestype1.c @@ -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/source/compiler/aslrestype1i.c b/source/compiler/aslrestype1i.c index 7acdbbce1bec1..07fc146fc2ff5 100644 --- a/source/compiler/aslrestype1i.c +++ b/source/compiler/aslrestype1i.c @@ -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/source/compiler/aslrestype2.c b/source/compiler/aslrestype2.c index 45bbe232587e6..4a017956dd0a7 100644 --- a/source/compiler/aslrestype2.c +++ b/source/compiler/aslrestype2.c @@ -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/source/compiler/aslrestype2d.c b/source/compiler/aslrestype2d.c index c814f8c0e697e..caca601da96be 100644 --- a/source/compiler/aslrestype2d.c +++ b/source/compiler/aslrestype2d.c @@ -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/source/compiler/aslrestype2e.c b/source/compiler/aslrestype2e.c index 07b7255007a02..eec12479ec257 100644 --- a/source/compiler/aslrestype2e.c +++ b/source/compiler/aslrestype2e.c @@ -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)); @@ -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/source/compiler/aslrestype2q.c b/source/compiler/aslrestype2q.c index 6db3815218661..229daae625955 100644 --- a/source/compiler/aslrestype2q.c +++ b/source/compiler/aslrestype2q.c @@ -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/source/compiler/aslrestype2s.c b/source/compiler/aslrestype2s.c index 9fe03b7f2ec42..c7d545503a5a5 100644 --- a/source/compiler/aslrestype2s.c +++ b/source/compiler/aslrestype2s.c @@ -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); @@ -337,8 +339,10 @@ RsDoGpioIntDescriptor ( 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), + "%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 */ @@ -397,7 +401,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 +427,7 @@ RsDoGpioIntDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -468,7 +473,8 @@ RsDoGpioIntDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -524,13 +530,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 */ @@ -548,8 +555,10 @@ RsDoGpioIoDescriptor ( 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), + "%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 */ @@ -632,7 +641,7 @@ RsDoGpioIoDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -678,7 +687,8 @@ RsDoGpioIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -727,14 +737,15 @@ 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; /* Build pointers to optional areas */ @@ -743,7 +754,8 @@ RsDoI2cSerialBusDescriptor ( ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", + "%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); @@ -797,7 +809,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; @@ -874,23 +887,26 @@ 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; /* 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", + "%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); @@ -972,7 +988,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; @@ -1049,14 +1066,15 @@ 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; /* Build pointers to optional areas */ @@ -1065,7 +1083,8 @@ RsDoUartSerialBusDescriptor ( ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", + "%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); @@ -1154,7 +1173,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; diff --git a/source/compiler/aslrestype2w.c b/source/compiler/aslrestype2w.c index 3b4cc1038d19d..98257ad975231 100644 --- a/source/compiler/aslrestype2w.c +++ b/source/compiler/aslrestype2w.c @@ -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/source/compiler/aslrules.y b/source/compiler/aslrules.y index cac37c3ddcb0d..79accf4dd2e03 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -54,11 +54,12 @@ NoEcho(' * 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;} ; + /* * Note concerning support for "module-level code". * @@ -75,7 +76,7 @@ ASLCode * of Type1 and Type2 opcodes at module level. */ DefinitionBlockTerm - : PARSEOP_DEFINITIONBLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);} + : PARSEOP_DEFINITION_BLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);} String ',' String ',' ByteConst ',' @@ -86,6 +87,12 @@ DefinitionBlockTerm '{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} ; +DefinitionBlockList + : DefinitionBlockTerm + | DefinitionBlockTerm + DefinitionBlockList {$$ = TrLinkPeerNodes (2, $1,$2);} + ; + SuperName : NameString {} | ArgTerm {} diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index 26f607fbbe9c5..cd92033467911 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -270,3 +270,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/source/compiler/asltokens.y b/source/compiler/asltokens.y index d52bb500bff23..17ae28d05a130 100644 --- a/source/compiler/asltokens.y +++ b/source/compiler/asltokens.y @@ -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 @@ -464,6 +464,9 @@ NoEcho(' /* 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/source/compiler/asltransform.c b/source/compiler/asltransform.c index 709b7b09e68f2..b2a0f39b3af3e 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -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,7 +243,7 @@ TrAmlInsertPeer ( { NewPeer->Asl.Next = Op->Asl.Next; - Op->Asl.Next = NewPeer; + Op->Asl.Next = NewPeer; } @@ -297,7 +298,7 @@ TrTransformSubtree ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: TrDoDefinitionBlock (Op); break; @@ -448,7 +449,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 +459,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 +538,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 +601,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 +646,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 +669,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 +684,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 +696,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 +757,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/source/compiler/asltree.c b/source/compiler/asltree.c index 173886109c1ab..0d800654f6ca5 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -340,6 +340,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 +494,7 @@ TrSetEndLineNumber ( return; } - Op->Asl.EndLine = Gbl_CurrentLineNumber; + Op->Asl.EndLine = Gbl_CurrentLineNumber; Op->Asl.EndLogicalLine = Gbl_LogicalLineNumber; } @@ -753,7 +758,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); @@ -860,7 +866,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; @@ -946,15 +953,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: RootNode = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: + DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1075,9 +1089,15 @@ TrLinkChildren ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ASL_CODE: RootNode = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: + DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1155,6 +1175,7 @@ TrLinkChildren ( Child = Child->Asl.Next; Child->Asl.Parent = Op; } + PrevChild = Child; } diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 6205dbfb7a011..4211767eae2fd 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -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 diff --git a/source/compiler/asltypes.y b/source/compiler/asltypes.y index 2ed708f13d64e..7fa24a87a39ac 100644 --- a/source/compiler/asltypes.y +++ b/source/compiler/asltypes.y @@ -51,12 +51,13 @@ 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 diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 9ea4c19c48a09..47851bddad881 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -199,7 +199,6 @@ UtBeginEvent ( AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer (); AslGbl_Events[AslGbl_NextEvent].EventName = Name; AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; - return (AslGbl_NextEvent++); } @@ -806,6 +805,7 @@ UtPadNameWithUnderscores ( { *PaddedNameSeg = '_'; } + PaddedNameSeg++; } } @@ -1090,7 +1090,7 @@ stroul64 ( /* Check to see if value is out of range: */ if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / - (UINT64) Base)) + (UINT64) Base)) { goto ErrorExit; } diff --git a/source/compiler/asluuid.c b/source/compiler/asluuid.c index 86ca83a7fce78..ebb72c4f5fef4 100644 --- a/source/compiler/asluuid.c +++ b/source/compiler/asluuid.c @@ -47,7 +47,7 @@ ACPI_MODULE_NAME ("asluuid") -extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -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/source/compiler/aslxref.c b/source/compiler/aslxref.c index 6b65bb1699bf9..9a830e16058f4 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -148,7 +148,7 @@ XfCrossReferenceNamespace ( /* Walk the entire parse tree */ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, - XfNamespaceLocateEnd, WalkState); + XfNamespaceLocateEnd, WalkState); ACPI_FREE (WalkState); return (AE_OK); @@ -177,8 +177,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 */ @@ -575,6 +575,7 @@ XfNamespaceLocateBegin ( { NextOp = NextOp->Asl.Next; } + Path = NextOp->Asl.Value.String; } else @@ -596,7 +597,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) @@ -778,7 +779,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" : ""); @@ -847,7 +849,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); @@ -870,7 +872,7 @@ XfNamespaceLocateBegin ( UtSetParseOpName (Op); PassedArgs = 0; - NextOp = Op->Asl.Child; + NextOp = Op->Asl.Child; while (NextOp) { @@ -976,7 +978,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); } @@ -986,7 +989,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); } @@ -1014,10 +1018,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); } } } diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 58e749f5bc73c..a3f5ea799a6e8 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -345,7 +345,7 @@ DtCompileDataTable ( DtInsertCompilerIds (*FieldList); Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader, - &Gbl_RootTable, TRUE); + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -382,7 +382,7 @@ DtCompileDataTable ( Subtable = NULL; Status = DtCompileTable (FieldList, TableData->TableInfo, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -639,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/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index 55d7c1285225d..df7078d08f833 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -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); diff --git a/source/compiler/dtexpress.c b/source/compiler/dtexpress.c index 97d01151419aa..2ed63064e9b1f 100644 --- a/source/compiler/dtexpress.c +++ b/source/compiler/dtexpress.c @@ -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; @@ -417,6 +419,7 @@ DtLookupLabel ( { return (LabelField); } + LabelField = LabelField->NextLabel; } diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index f083f05ae3f5c..72abe40eeff08 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -99,6 +99,7 @@ DtCompileOneField ( { ACPI_STATUS Status; + switch (Type) { case DT_FIELD_TYPE_INTEGER: diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 41b46b525593c..25e60ba060d73 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -102,7 +102,7 @@ DtDumpSubtableTree ( #define DT_MERGE_LINES 6 #define DT_ESCAPE_SEQUENCE 7 -static UINT32 Gbl_NextLineOffset; +static UINT32 Gbl_NextLineOffset; /****************************************************************************** @@ -354,6 +354,7 @@ DtParseLine ( End--; break; } + End++; } @@ -553,7 +554,8 @@ DtGetNextLine ( if (!(Flags & DT_ALLOW_MULTILINE_QUOTES)) { - AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n", + AcpiOsPrintf ( + "ERROR at line %u: Unterminated quoted string\n", Gbl_CurrentLineNumber++); State = DT_NORMAL_TEXT; } @@ -755,7 +757,8 @@ DtScanFile ( 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; @@ -946,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, @@ -1092,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/source/compiler/dttable.c b/source/compiler/dttable.c index c5b2ef9f6f2e6..d482e8e51452a 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ -/* Compile all complex data tables */ +/* Compile routines for the basic ACPI tables */ #include "aslcompiler.h" #include "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,344 +182,13 @@ 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--; } } @@ -1439,2086 +198,41 @@ DtCompileHest ( /****************************************************************************** * - * 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 && - !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: 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; + 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) - { - *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; - } + /* 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/source/compiler/dttable1.c b/source/compiler/dttable1.c new file mode 100644 index 0000000000000..1c3b0f251104d --- /dev/null +++ b/source/compiler/dttable1.c @@ -0,0 +1,1671 @@ +/****************************************************************************** + * + * Module Name: dttable1.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +/* Compile all complex data tables, signatures starting with A-I */ + +#include "aslcompiler.h" +#include "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 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 && + !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/source/compiler/dttable2.c b/source/compiler/dttable2.c new file mode 100644 index 0000000000000..ec2a36f00d67c --- /dev/null +++ b/source/compiler/dttable2.c @@ -0,0 +1,1686 @@ +/****************************************************************************** + * + * Module Name: dttable2.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2015, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +/* Compile all complex data tables, signatures starting with L-Z */ + +#include "aslcompiler.h" +#include "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; + + 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_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: 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/source/compiler/dttemplate.c b/source/compiler/dttemplate.c index 3da0692bb0868..622e2011038f5 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -189,7 +189,6 @@ GetTemplate: Status = DtCreateOneTemplate (Signature, TableData); - /* Shutdown ACPICA subsystem */ (void) AcpiTerminate (); @@ -235,7 +234,7 @@ DtCreateAllTemplates ( if (TableData->Template) { Status = DtCreateOneTemplate (TableData->Signature, - TableData); + TableData); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/source/compiler/prexpress.c b/source/compiler/prexpress.c index b7af4121cdbda..ca18c358f54db 100644 --- a/source/compiler/prexpress.c +++ b/source/compiler/prexpress.c @@ -84,6 +84,7 @@ PrUnTokenize ( { return; } + if (Buffer[Length] != '\n') { Buffer[strlen(Buffer)] = ' '; diff --git a/source/compiler/prmacros.c b/source/compiler/prmacros.c index c2781138dfa66..89a553fedf0b3 100644 --- a/source/compiler/prmacros.c +++ b/source/compiler/prmacros.c @@ -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/source/compiler/prscan.c b/source/compiler/prscan.c index 27eb6be85318e..1ba58d14c6797 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -499,7 +499,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; @@ -674,7 +675,8 @@ PrDoDirective ( if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') { #ifndef MACROS_SUPPORTED - AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", + AcpiOsPrintf ( + "%s ERROR - line %u: #define macros are not supported yet\n", Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber); exit(1); #else @@ -692,11 +694,13 @@ PrDoDirective ( { Token2++; } + End = Token2; while (*End != '\n') { End++; } + *End = 0; } else @@ -999,6 +1003,7 @@ PrGetNextLine ( { return (ASL_BLANK_LINE); } + return (AE_OK); } } diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c index d967e5cb19b8c..c9e260c8511f4 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -122,8 +122,10 @@ PrGetNextToken ( { *Next = NULL; } + return (TokenStart); } + Buffer++; } |