From 7600ac2283596bd000a29b9347e95346d3b740d7 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Fri, 30 Sep 2016 19:46:13 +0000 Subject: [PATCH 001/115] Import ACPICA 20160930. --- changes.txt | 79 +++++++++++++++++ source/common/acfileio.c | 10 ++- source/compiler/aslmaputils.c | 6 ++ source/compiler/asloperands.c | 14 +++ source/compiler/asloptions.c | 7 ++ source/compiler/aslrules.y | 2 +- source/compiler/aslxref.c | 6 +- source/components/disassembler/dmbuffer.c | 68 +++++++++++++-- source/components/disassembler/dmcstyle.c | 91 ++++++++++++++++++++ source/components/disassembler/dmopcode.c | 66 +++++++++++++- source/components/disassembler/dmresrcl.c | 15 ++-- source/components/executer/exconfig.c | 24 +++++- source/components/parser/psxface.c | 12 +++ source/components/tables/tbdata.c | 7 +- source/components/tables/tbfind.c | 2 +- source/components/tables/tbxfload.c | 16 +++- source/components/utilities/utstrtoul64.c | 2 +- source/include/acconfig.h | 2 +- source/include/acglobal.h | 5 +- source/include/aclocal.h | 19 ++-- source/include/acpixf.h | 9 +- source/include/platform/acmacosx.h | 1 - source/os_specific/service_layers/osunixxf.c | 13 ++- source/tools/acpibin/abcompare.c | 7 +- source/tools/acpiexec/aemain.c | 2 +- source/tools/acpinames/anmain.c | 2 +- source/tools/acpisrc/asfile.c | 2 +- 27 files changed, 430 insertions(+), 59 deletions(-) diff --git a/changes.txt b/changes.txt index 3e87f12c3b5..49c88a49bbe 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,82 @@ +---------------------------------------- +30 September 2016. Summary of changes for version 20160930: + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression in the internal AcpiTbFindTable function where a non +AE_OK exception could inadvertently be returned even if the function did +not fail. This problem affects the following operators: + DataTableRegion + LoadTable + +Fixed a regression in the LoadTable operator where a load to any +namespace location other than the root no longer worked properly. + +Increased the maximum loop count value that will result in the +AE_AML_INFINITE_LOOP exception. This is a mechanism that is intended to +prevent infinite loops within the AML interpreter and thus the host OS +kernel. The value is increased from 0xFFFF to 0xFFFFF loops (65,535 to +1,048,575). + +Moved the AcpiGbl_MaxLoopIterations configuration variable to the public +acpixf.h file. This allows hosts to easily configure the maximum loop +count at runtime. + +Removed an illegal character in the strtoul64.c file. This character +caused errors with some C compilers. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 140.4K Code, 58.1K Data, 198.5K Total + Debug Version: 200.7K Code, 82.1K Data, 282.8K Total + Previous Release: + Non-Debug Version: 140.0K Code, 58.1K Data, 198.1K Total + Debug Version: 200.3K Code, 82.1K Data, 282.4K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Fixed a problem with the conversion of Else{If{ blocks into +the simpler ASL ElseIf keyword. During the conversion, a trailing If +block could be lost and missing from the disassembled output. + +iASL: Fixed a missing parser rule for the ObjectType operator. For ASL+, +the missing rule caused a parse error when using the Index operator as an +operand to ObjectType. This construct now compiles properly. Example: + ObjectType(PKG1[4]). + +iASL: Correctly handle unresolved symbols in the hardware map file (-lm +option). Previously, unresolved symbols could cause a protection fault. +Such symbols are now marked as unresolved in the map file. + +iASL: Implemented support to allow control method invocations as an +operand to the ASL DeRefOf operator. Example: + DeRefOf(MTH1(Local0)) + +Disassembler: Improved support for the ToPLD ASL macro. Detection of a +possible _PLD buffer now includes examination of both the normal buffer +length (16 or 20) as well as the surrounding AML package length. + +Disassembler: Fixed a problem with the decoding of complex expressions +within the Divide operator for ASL+. For the case where both the quotient +and remainder targets are specified, the entire statement cannot be +disassembled. Previously, the output incorrectly contained a mix of ASL- +and ASL+ operators. This mixed statement causes a syntax error when +compiled. Example: + Divide (Add (INT1, 6), 128, RSLT, QUOT) // was incorrectly +disassembled to: + Divide (INT1 + 6, 128, RSLT, QUOT) + +iASL/Tools: Added support to process AML and non-AML ACPI tables +consistently. For the disassembler and AcpiExec, allow all types of ACPI +tables (AML and data tables). For the iASL -e option, allow only AML +tables (DSDT/SSDT). + ---------------------------------------- 31 August 2016. Summary of changes for version 20160831: diff --git a/source/common/acfileio.c b/source/common/acfileio.c index c2ae8550dfa..409e16f0684 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -262,12 +262,14 @@ AcGetOneTableFromFile ( return (Status); } + if (GetOnlyAmlTables) { - /* Table must be an AML table (DSDT/SSDT) or FADT */ - - if (!ACPI_COMPARE_NAME (TableHeader.Signature, ACPI_SIG_FADT) && - !AcpiUtIsAmlTable (&TableHeader)) + /* + * Table must be an AML table (DSDT/SSDT). + * Used for iASL -e option only. + */ + if (!AcpiUtIsAmlTable (&TableHeader)) { fprintf (stderr, " %s: Table [%4.4s] is not an AML table - ignoring\n", diff --git a/source/compiler/aslmaputils.c b/source/compiler/aslmaputils.c index ebdab7daa74..1ba70405076 100644 --- a/source/compiler/aslmaputils.c +++ b/source/compiler/aslmaputils.c @@ -80,6 +80,12 @@ MpGetHidFromParseTree ( Op = HidNode->Op; + if (!Op) + { + /* Object is not resolved, probably an External */ + + return ("Unresolved Symbol - referenced but not defined in this table"); + } switch (Op->Asl.ParseOpcode) { diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 3f84114282d..1b8eb8735a9 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -351,6 +351,20 @@ OpnDoFieldCommon ( NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; CurrentBitOffset += NewBitOffset; + if ((NewBitOffset == 0) && + (Next->Asl.ParseOpcode == PARSEOP_RESERVED_BYTES)) + { + /* + * Unnamed field with a bit length of zero. We can + * safely just ignore this. However, we will not ignore + * a named field of zero length, we don't want to just + * toss out a name. + */ + Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + break; + } + /* Save the current AccessAs value for error checking later */ switch (AccessType) diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index b9d4e3c4070..4f1294596b7 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -561,6 +561,13 @@ AslDoOptions ( Gbl_CompileTimesFlag = TRUE; break; + case 'd': + + /* Disable disassembler code optimizations */ + + AcpiGbl_DoDisassemblerOptimizations = FALSE; + break; + case 'e': /* iASL: Disable External opcode generation */ diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index a7a41e2ed1b..2cb972f8056 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -530,7 +530,7 @@ ObjectTypeName | RefOfTerm {} | DerefOfTerm {} | IndexTerm {} - + | IndexExpTerm {} /* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ ; diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index a2cb6b33240..b8c7835bb6d 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -826,16 +826,18 @@ XfNamespaceLocateBegin ( /* * A reference to a method within one of these opcodes is not an * invocation of the method, it is simply a reference to the method. + * + * September 2016: Removed DeRefOf from this list */ if ((Op->Asl.Parent) && - ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) || - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) || + ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)|| (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) { return_ACPI_STATUS (AE_OK); } + /* * There are two types of method invocation: * 1) Invocation with arguments -- the parser recognizes this diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index 79c37e2e3ea..42920500ba2 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -529,7 +529,8 @@ AcpiDmIsStringBuffer ( * * PARAMETERS: Op - Buffer Object to be examined * - * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise + * RETURN: TRUE if buffer appears to contain data produced via the + * ToPLD macro, FALSE otherwise * * DESCRIPTION: Determine if a buffer Op contains a _PLD structure * @@ -541,12 +542,60 @@ AcpiDmIsPldBuffer ( { ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *SizeOp; + ACPI_PARSE_OBJECT *ByteListOp; ACPI_PARSE_OBJECT *ParentOp; + UINT64 BufferSize; + UINT64 InitializerSize; - /* Buffer size is the buffer argument */ - + /* + * Get the BufferSize argument - Buffer(BufferSize) + * If the buffer was generated by the ToPld macro, it must + * be a BYTE constant. + */ SizeOp = Op->Common.Value.Arg; + if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) + { + return (FALSE); + } + + /* Check the declared BufferSize, two possibilities */ + + BufferSize = SizeOp->Common.Value.Integer; + if ((BufferSize != ACPI_PLD_REV1_BUFFER_SIZE) && + (BufferSize != ACPI_PLD_REV2_BUFFER_SIZE)) + { + return (FALSE); + } + + /* + * Check the initializer list length. This is the actual + * number of bytes in the buffer as counted by the AML parser. + * The declared BufferSize can be larger than the actual length. + * However, for the ToPLD macro, the BufferSize will be the same + * as the initializer list length. + */ + ByteListOp = SizeOp->Common.Next; + if (!ByteListOp) + { + return (FALSE); /* Zero-length buffer case */ + } + + InitializerSize = ByteListOp->Common.Value.Integer; + if ((InitializerSize != ACPI_PLD_REV1_BUFFER_SIZE) && + (InitializerSize != ACPI_PLD_REV2_BUFFER_SIZE)) + { + return (FALSE); + } + + /* Final size check */ + + if (BufferSize != InitializerSize) + { + return (FALSE); + } + + /* Now examine the buffer parent */ ParentOp = Op->Common.Parent; if (!ParentOp) @@ -571,8 +620,17 @@ AcpiDmIsPldBuffer ( return (FALSE); } - /* Check for proper form: Name(_PLD, Package() {Buffer() {}}) */ - + /* + * Check for proper form: Name(_PLD, Package() {ToPLD()}) + * + * Note: All other forms such as + * Return (Package() {ToPLD()}) + * Local0 = ToPLD() + * etc. are not converted back to the ToPLD macro, because + * there is really no deterministic way to disassemble the buffer + * back to the ToPLD macro, other than trying to find the "_PLD" + * name + */ if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP) { ParentOp = ParentOp->Common.Parent; diff --git a/source/components/disassembler/dmcstyle.c b/source/components/disassembler/dmcstyle.c index 2f61dea2084..939168f2425 100644 --- a/source/components/disassembler/dmcstyle.c +++ b/source/components/disassembler/dmcstyle.c @@ -98,6 +98,9 @@ AcpiDmCheckForSymbolicOpcode ( ACPI_PARSE_OBJECT *Child1; ACPI_PARSE_OBJECT *Child2; ACPI_PARSE_OBJECT *Target; + ACPI_PARSE_OBJECT *GrandChild1; + ACPI_PARSE_OBJECT *GrandChild2; + ACPI_PARSE_OBJECT *GrandTarget = NULL; /* Exit immediately if ASL+ not enabled */ @@ -107,6 +110,14 @@ AcpiDmCheckForSymbolicOpcode ( return (FALSE); } + /* Check for a non-ASL+ statement, propagate the flag */ + + if (Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY) + { + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (FALSE); + } + /* Get the first operand */ Child1 = AcpiPsGetArg (Op, 0); @@ -323,6 +334,7 @@ AcpiDmCheckForSymbolicOpcode ( if (AcpiDmIsValidTarget (Target)) { Child1->Common.OperatorSymbol = NULL; + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; return (FALSE); } @@ -339,6 +351,13 @@ AcpiDmCheckForSymbolicOpcode ( if (!AcpiDmIsValidTarget (Target)) { + if (Op->Common.Parent->Common.AmlOpcode == AML_STORE_OP) + { + Op->Common.DisasmFlags = 0; + Child1->Common.OperatorSymbol = NULL; + return (FALSE); + } + /* Not a valid target (placeholder only, from parser) */ break; } @@ -478,6 +497,69 @@ AcpiDmCheckForSymbolicOpcode ( /* * Target is the 2nd operand. * We know the target is valid, it is not optional. + * + * The following block implements "Ignore conversion if a store + * is followed by a math/bit operator that has no target". Used + * only for the ASL test suite. + */ + if (!AcpiGbl_DoDisassemblerOptimizations) + { + switch (Child1->Common.AmlOpcode) + { + /* This operator has two operands and two targets */ + + case AML_DIVIDE_OP: + + GrandChild1 = Child1->Common.Value.Arg; + GrandChild2 = GrandChild1->Common.Next; + GrandTarget = GrandChild2->Common.Next; + + if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget)) + { + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (FALSE); + } + GrandTarget = GrandTarget->Common.Next; + break; + + case AML_ADD_OP: + case AML_SUBTRACT_OP: + case AML_MULTIPLY_OP: + case AML_MOD_OP: + case AML_SHIFT_LEFT_OP: + case AML_SHIFT_RIGHT_OP: + case AML_BIT_AND_OP: + case AML_BIT_OR_OP: + case AML_BIT_XOR_OP: + case AML_INDEX_OP: + + /* These operators have two operands and a target */ + + GrandChild1 = Child1->Common.Value.Arg; + GrandChild2 = GrandChild1->Common.Next; + GrandTarget = GrandChild2->Common.Next; + break; + + case AML_BIT_NOT_OP: + + /* This operator has one operand and a target */ + + GrandChild1 = Child1->Common.Value.Arg; + GrandTarget = GrandChild1->Common.Next; + break; + + default: + break; + } + + if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget)) + { + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (FALSE); + } + } + + /* * In the parse tree, simply swap the target with the * source so that the target is processed first. */ @@ -563,6 +645,7 @@ AcpiDmCloseOperator ( { BOOLEAN IsCStyleOp = FALSE; + /* Always emit paren if ASL+ disassembly disabled */ if (!AcpiGbl_CstyleDisassembly) @@ -571,6 +654,14 @@ AcpiDmCloseOperator ( return; } + /* Check for a non-ASL+ statement */ + + if (Op->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY) + { + AcpiOsPrintf (")"); + return; + } + /* Check if we need to add an additional closing paren */ switch (Op->Common.AmlOpcode) diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 7ca171cbbbe..35fa5945bc1 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -64,6 +64,10 @@ static void AcpiDmConvertToElseIf ( ACPI_PARSE_OBJECT *Op); +static void +AcpiDmPromoteSubtree ( + ACPI_PARSE_OBJECT *StartOp); + /******************************************************************************* * @@ -1067,16 +1071,26 @@ AcpiDmConvertToElseIf ( * be the only blocks under the original Else. */ IfOp = OriginalElseOp->Common.Value.Arg; + if (!IfOp || (IfOp->Common.AmlOpcode != AML_IF_OP) || (IfOp->Asl.Next && (IfOp->Asl.Next->Common.AmlOpcode != AML_ELSE_OP))) { - /* Not an Else..If sequence, cannot convert to ElseIf */ + /* Not a proper Else..If sequence, cannot convert to ElseIf */ AcpiOsPrintf ("%s", "Else"); return; } + /* Cannot have anything following the If...Else block */ + + ElseOp = IfOp->Common.Next; + if (ElseOp && ElseOp->Common.Next) + { + AcpiOsPrintf ("%s", "Else"); + return; + } + /* Emit ElseIf, mark the IF as now an ELSEIF */ AcpiOsPrintf ("%s", "ElseIf"); @@ -1100,7 +1114,10 @@ AcpiDmConvertToElseIf ( /* If an ELSE matches the IF, promote it also */ ElseOp->Common.Parent = OriginalElseOp->Common.Parent; - ElseOp->Common.Next = OriginalElseOp->Common.Next; + + /* Promote the entire block under the ElseIf (All Next OPs) */ + + AcpiDmPromoteSubtree (OriginalElseOp); } else { @@ -1122,3 +1139,48 @@ AcpiDmConvertToElseIf ( OriginalElseOp->Common.Next = IfOp; } + + +/******************************************************************************* + * + * FUNCTION: AcpiDmPromoteSubtree + * + * PARAMETERS: StartOpOp - Original parent of the entire subtree + * + * RETURN: None + * + * DESCRIPTION: Promote an entire parse subtree up one level. + * + ******************************************************************************/ + +static void +AcpiDmPromoteSubtree ( + ACPI_PARSE_OBJECT *StartOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *ParentOp; + + + /* New parent for subtree elements */ + + ParentOp = StartOp->Common.Parent; + + /* First child starts the subtree */ + + Op = StartOp->Common.Value.Arg; + + /* Walk the top-level elements of the subtree */ + + while (Op) + { + Op->Common.Parent = ParentOp; + if (!Op->Common.Next) + { + /* Last Op in list, update its next field */ + + Op->Common.Next = StartOp->Common.Next; + break; + } + Op = Op->Common.Next; + } +} diff --git a/source/components/disassembler/dmresrcl.c b/source/components/disassembler/dmresrcl.c index 52fd3356b8d..b845a728636 100644 --- a/source/components/disassembler/dmresrcl.c +++ b/source/components/disassembler/dmresrcl.c @@ -443,16 +443,17 @@ AcpiDmIoFlags2 ( UINT8 SpecificFlags) { + /* _TTP */ + AcpiOsPrintf (", %s", AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 4)]); - /* TRS is only used if TTP is TypeTranslation */ - - if (SpecificFlags & 0x10) - { - AcpiOsPrintf (", %s", - AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]); - } + /* + * TRS is only used if TTP is TypeTranslation. However, the disassembler + * always emits exactly what is in the AML. + */ + AcpiOsPrintf (", %s", + AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]); } diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 7e2f6996cf3..c17beab9961 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -581,11 +581,18 @@ AcpiExUnloadTable ( TableIndex = TableDesc->Reference.Value; + /* + * Release the interpreter lock so that the table lock won't have + * strict order requirement against it. + */ + AcpiExExitInterpreter (); + /* Ensure the table is still loaded */ if (!AcpiTbIsTableLoaded (TableIndex)) { - return_ACPI_STATUS (AE_NOT_EXIST); + Status = AE_NOT_EXIST; + goto LockAndExit; } /* Invoke table handler if present */ @@ -605,16 +612,25 @@ AcpiExUnloadTable ( Status = AcpiTbDeleteNamespaceByOwner (TableIndex); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto LockAndExit; } (void) AcpiTbReleaseOwnerId (TableIndex); AcpiTbSetTableLoadedFlag (TableIndex, FALSE); +LockAndExit: + + /* Re-acquire the interpreter lock */ + + AcpiExEnterInterpreter (); + /* * Invalidate the handle. We do this because the handle may be stored * in a named object and may not be actually deleted until much later. */ - DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; - return_ACPI_STATUS (AE_OK); + if (ACPI_SUCCESS (Status)) + { + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; + } + return_ACPI_STATUS (Status); } diff --git a/source/components/parser/psxface.c b/source/components/parser/psxface.c index c85f0e939f3..58c1ce82f11 100644 --- a/source/components/parser/psxface.c +++ b/source/components/parser/psxface.c @@ -334,6 +334,18 @@ AcpiPsExecuteTable ( WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; } + /* Info->Node is the default location to load the table */ + + if (Info->Node && Info->Node != AcpiGbl_RootNode) + { + Status = AcpiDsScopeStackPush ( + Info->Node, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + /* * Parse the AML, WalkState will be deleted by ParseAml */ diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c index 11164e2316d..81b3abcfdd7 100644 --- a/source/components/tables/tbdata.c +++ b/source/components/tables/tbdata.c @@ -681,18 +681,13 @@ AcpiTbDeleteNamespaceByOwner ( * lock may block, and also since the execution of a namespace walk * must be allowed to use the interpreter. */ - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); - - AcpiNsDeleteNamespaceByOwner (OwnerId); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - + AcpiNsDeleteNamespaceByOwner (OwnerId); AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); - - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); return_ACPI_STATUS (Status); } diff --git a/source/components/tables/tbfind.c b/source/components/tables/tbfind.c index 663e85285ea..563358cbbc9 100644 --- a/source/components/tables/tbfind.c +++ b/source/components/tables/tbfind.c @@ -156,5 +156,5 @@ AcpiTbFindTable ( UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS (Status); } diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c index bebfc119f3f..43fe397fde5 100644 --- a/source/components/tables/tbxfload.c +++ b/source/components/tables/tbxfload.c @@ -262,7 +262,7 @@ AcpiTbLoadNamespace ( if (!TablesFailed) { ACPI_INFO (( - "%u ACPI AML tables successfully acquired and loaded\n", + "%u ACPI AML tables successfully acquired and loaded", TablesLoaded)); } else @@ -276,6 +276,11 @@ AcpiTbLoadNamespace ( Status = AE_CTRL_TERMINATE; } +#ifdef ACPI_APPLICATION + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\n")); +#endif + + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); @@ -423,9 +428,9 @@ AcpiUnloadParentTable ( return_ACPI_STATUS (AE_TYPE); } - /* Must acquire the interpreter lock during this operation */ + /* Must acquire the table lock during this operation */ - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -456,9 +461,11 @@ AcpiUnloadParentTable ( /* Ensure the table is actually loaded */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (!AcpiTbIsTableLoaded (i)) { Status = AE_NOT_EXIST; + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); break; } @@ -485,10 +492,11 @@ AcpiUnloadParentTable ( Status = AcpiTbReleaseOwnerId (i); AcpiTbSetTableLoadedFlag (i, FALSE); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); break; } - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } diff --git a/source/components/utilities/utstrtoul64.c b/source/components/utilities/utstrtoul64.c index 96cf112a479..f7558773681 100644 --- a/source/components/utilities/utstrtoul64.c +++ b/source/components/utilities/utstrtoul64.c @@ -85,7 +85,7 @@ AcpiUtStrtoulBase16 ( * The integer is initialized to the value zero. * The ASCII string is interpreted as a hexadecimal constant. * - * 1) A “0x” prefix is not allowed. However, ACPICA allows this for + * 1) A "0x" prefix is not allowed. However, ACPICA allows this for * compatibility with previous ACPICA. (NO ERROR) * * 2) Terminates when the size of an integer is reached (32 or 64 bits). diff --git a/source/include/acconfig.h b/source/include/acconfig.h index fb9727138ec..d6324911e8a 100644 --- a/source/include/acconfig.h +++ b/source/include/acconfig.h @@ -148,7 +148,7 @@ /* Maximum number of While() loops before abort */ -#define ACPI_MAX_LOOP_COUNT 0xFFFF +#define ACPI_MAX_LOOP_COUNT 0x000FFFFF /****************************************************************************** diff --git a/source/include/acglobal.h b/source/include/acglobal.h index fc7a7a213fd..1d5c17e6377 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -245,10 +245,6 @@ ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); -/* Maximum number of While() loop iterations before forced abort */ - -ACPI_GLOBAL (UINT16, AcpiGbl_MaxLoopIterations); - /* Control method single step flag */ ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); @@ -322,6 +318,7 @@ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_CstyleDisassembly, TRUE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ForceAmlDisassembly, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Verbose, TRUE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmEmitExternalOpcodes, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DoDisassemblerOptimizations, TRUE); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Disasm); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Listing); diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 9820a89a92f..f41160953b1 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -917,7 +917,7 @@ typedef union acpi_parse_value ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ UINT8 ArgListLength; /* Number of elements in the arg list */\ ACPI_DISASM_ONLY_MEMBERS (\ - UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT16 DisasmFlags; /* Used during AML disassembly */\ UINT8 DisasmOpcode; /* Subtype used for disassembly */\ char *OperatorSymbol;/* Used for C-style operator name strings */\ char AmlOpName[16]) /* Op name (debug only) */ @@ -1037,14 +1037,15 @@ typedef struct acpi_parse_state /* Parse object DisasmFlags */ -#define ACPI_PARSEOP_IGNORE 0x01 -#define ACPI_PARSEOP_PARAMETER_LIST 0x02 -#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 -#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x08 -#define ACPI_PARSEOP_CLOSING_PAREN 0x10 -#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x20 -#define ACPI_PARSEOP_ASSIGNMENT 0x40 -#define ACPI_PARSEOP_ELSEIF 0x80 +#define ACPI_PARSEOP_IGNORE 0x0001 +#define ACPI_PARSEOP_PARAMETER_LIST 0x0002 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x0004 +#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x0008 +#define ACPI_PARSEOP_CLOSING_PAREN 0x0010 +#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x0020 +#define ACPI_PARSEOP_ASSIGNMENT 0x0040 +#define ACPI_PARSEOP_ELSEIF 0x0080 +#define ACPI_PARSEOP_LEGACY_ASL_ONLY 0x0100 /***************************************************************************** diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 17bab19baad..b2655e96fd9 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160831 +#define ACPI_CA_VERSION 0x20160930 #include "acconfig.h" #include "actypes.h" @@ -260,6 +260,13 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_OsiData, 0); */ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ReducedHardware, FALSE); +/* + * Maximum number of While() loop iterations before forced method abort. + * This mechanism is intended to prevent infinite loops during interpreter + * execution within a host kernel. + */ +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_MaxLoopIterations, ACPI_MAX_LOOP_COUNT); + /* * This mechanism is used to trace a specified AML method. The method is * traced each time it is executed. diff --git a/source/include/platform/acmacosx.h b/source/include/platform/acmacosx.h index 5d2ba41e825..a16262a816a 100644 --- a/source/include/platform/acmacosx.h +++ b/source/include/platform/acmacosx.h @@ -47,7 +47,6 @@ #include "aclinux.h" #ifdef __APPLE__ -#define sem_destroy sem_close #define ACPI_USE_ALTERNATE_TIMEOUT #endif /* __APPLE__ */ diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index 643b02e86a5..3837b8e99d1 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -754,8 +754,12 @@ AcpiOsCreateSemaphore ( #ifdef __APPLE__ { - char *SemaphoreName = tmpnam (NULL); + static int SemaphoreCount = 0; + char SemaphoreName[32]; + snprintf (SemaphoreName, sizeof (SemaphoreName), "acpi_sem_%d", + SemaphoreCount++); + printf ("%s\n", SemaphoreName); Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); if (!Sem) { @@ -807,10 +811,17 @@ AcpiOsDeleteSemaphore ( return (AE_BAD_PARAMETER); } +#ifdef __APPLE__ + if (sem_close (Sem) == -1) + { + return (AE_BAD_PARAMETER); + } +#else if (sem_destroy (Sem) == -1) { return (AE_BAD_PARAMETER); } +#endif return (AE_OK); } diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index b997a5cdae4..e21e29d852f 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -433,7 +433,7 @@ AbCompareAmlFiles ( { if (Char1 != Char2) { - printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n", + printf ("Error - Byte mismatch at offset %8.4X: 0x%2.2X 0x%2.2X\n", Offset, Char1, Char2); Mismatches++; if (Mismatches > 100) @@ -471,7 +471,10 @@ AbCompareAmlFiles ( } printf ("%u Mismatches found\n", Mismatches); - Status = 0; + if (Mismatches == 0) + { + Status = 0; + } Exit2: fclose (File2); diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index d4bf335a980..826d60df136 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -542,7 +542,7 @@ main ( /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], - ACPI_GET_ONLY_AML_TABLES, &ListHead); + ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { ExitCode = -1; diff --git a/source/tools/acpinames/anmain.c b/source/tools/acpinames/anmain.c index 6e48bfdd68e..46a69ac1b1f 100644 --- a/source/tools/acpinames/anmain.c +++ b/source/tools/acpinames/anmain.c @@ -176,7 +176,7 @@ main ( /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], - ACPI_GET_ONLY_AML_TABLES, &ListHead); + ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { return (-1); diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index b8f0501d6c4..570b27c4b81 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -321,7 +321,7 @@ AsConvertFile ( ConditionalTable = ConversionTable->SourceConditionalTable; StructTable = ConversionTable->SourceStructTable; SpecialMacroTable = ConversionTable->SourceSpecialMacroTable; - break; + break; case FILE_TYPE_HEADER: From b48502fe1a0fe681f5ae605f67954585d6507a09 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Wed, 2 Nov 2016 17:33:22 +0000 Subject: [PATCH 002/115] 5752 dump_nvlist() is not aware of boolean array illumos/illumos-gate@ee3c499ad1e4fc884a11b2bc6490787b788bf84a https://github.com/illumos/illumos-gate/commit/ee3c499ad1e4fc884a11b2bc6490787b788bf84a https://www.illumos.org/issues/5752 dump_nvlist() is not aware of the boolean array value type: bad config type 24 for "foobar" Reviewed by: Dan Kimmel Reviewed by: Matthew Ahrens Reviewed by: Will Andrews Approved by: Robert Mustacchi Author: Andriy Gapon --- lib/libnvpair/libnvpair.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/libnvpair/libnvpair.c b/lib/libnvpair/libnvpair.c index 0415568e9de..d4d20000280 100644 --- a/lib/libnvpair/libnvpair.c +++ b/lib/libnvpair/libnvpair.c @@ -794,6 +794,7 @@ dump_nvlist(nvlist_t *list, int indent) { nvpair_t *elem = NULL; boolean_t bool_value; + boolean_t *bool_array_value; nvlist_t *nvlist_value; nvlist_t **nvlist_array_value; uint_t i, count; @@ -854,6 +855,16 @@ dump_nvlist(nvlist_t *list, int indent) NVP(elem, string, char *, char *, "'%s'"); break; + case DATA_TYPE_BOOLEAN_ARRAY: + (void) nvpair_value_boolean_array(elem, + &bool_array_value, &count); + for (i = 0; i < count; i++) { + (void) printf("%*s%s[%d]: %s\n", indent, "", + nvpair_name(elem), i, + bool_array_value[i] ? "true" : "false"); + } + break; + case DATA_TYPE_BYTE_ARRAY: NVPA(elem, byte_array, uchar_t, int, "%u"); break; From 3033242f0e72cba7aed30cf8654537afc909011d Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Wed, 2 Nov 2016 17:34:33 +0000 Subject: [PATCH 003/115] 5778 nvpair_type_is_array() does not recognize DATA_TYPE_INT8_ARRAY illumos/illumos-gate@bf4d553b8a4685dc5ba4549cc9ba6d94e9306a81 https://github.com/illumos/illumos-gate/commit/bf4d553b8a4685dc5ba4549cc9ba6d94e9306a81 https://www.illumos.org/issues/5778 DATA_TYPE_INT8_ARRAY is missing from the array check in nvpair_type_is_array() Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Approved by: Dan McDonald Author: Andriy Gapon --- common/nvpair/nvpair.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/nvpair/nvpair.c b/common/nvpair/nvpair.c index 9b5d5133480..691de5d61b6 100644 --- a/common/nvpair/nvpair.c +++ b/common/nvpair/nvpair.c @@ -1230,6 +1230,7 @@ nvpair_type_is_array(nvpair_t *nvp) data_type_t type = NVP_TYPE(nvp); if ((type == DATA_TYPE_BYTE_ARRAY) || + (type == DATA_TYPE_INT8_ARRAY) || (type == DATA_TYPE_UINT8_ARRAY) || (type == DATA_TYPE_INT16_ARRAY) || (type == DATA_TYPE_UINT16_ARRAY) || From a56e3c255d5c5dfa4dd3a2fda4705a1607a6b7f3 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Thu, 17 Nov 2016 18:06:08 +0000 Subject: [PATCH 004/115] Import ACPICA 20161117. --- changes.txt | 79 ++ source/common/acfileio.c | 24 +- source/common/dmtbdump.c | 194 ++-- source/common/dmtbinfo.c | 28 +- source/compiler/aslbtypes.c | 1 - source/compiler/aslcompiler.l | 16 +- source/compiler/aslcstyle.y | 42 +- source/compiler/aslexternal.c | 15 + source/compiler/aslkeywords.y | 15 +- source/compiler/aslopcodes.c | 10 +- source/compiler/aslprimaries.y | 1021 ++++++++++++--------- source/compiler/aslresources.y | 365 +++++--- source/compiler/aslrestype2.c | 5 + source/compiler/aslrules.y | 161 ++-- source/compiler/aslstubs.c | 3 +- source/compiler/asltokens.y | 3 + source/compiler/asltypes.y | 7 +- source/compiler/aslwalks.c | 13 +- source/compiler/dttable.c | 76 +- source/components/disassembler/dmbuffer.c | 27 +- source/components/disassembler/dmcstyle.c | 352 ++++--- source/components/disassembler/dmresrc.c | 30 +- source/components/dispatcher/dsinit.c | 10 +- source/components/dispatcher/dsmethod.c | 50 +- source/components/dispatcher/dsopcode.c | 2 +- source/components/dispatcher/dswload2.c | 17 +- source/components/events/evrgnini.c | 57 +- source/components/executer/exconfig.c | 40 +- source/components/executer/exconvrt.c | 1 - source/components/executer/exresop.c | 1 - source/components/namespace/nsload.c | 2 + source/components/namespace/nsnames.c | 52 ++ source/components/namespace/nsxfname.c | 42 +- source/components/parser/psargs.c | 75 +- source/components/parser/psloop.c | 3 + source/components/parser/psobject.c | 8 +- source/components/parser/pstree.c | 10 +- source/components/tables/tbdata.c | 102 +- source/components/tables/tbfadt.c | 23 +- source/components/tables/tbutils.c | 96 ++ source/components/tables/tbxface.c | 137 ++- source/components/tables/tbxfload.c | 35 +- source/components/utilities/utdecode.c | 54 ++ source/components/utilities/utresrc.c | 19 +- source/include/acdisasm.h | 5 +- source/include/acevents.h | 3 +- source/include/acnamesp.h | 5 + source/include/acopcode.h | 22 +- source/include/acpixf.h | 7 +- source/include/actables.h | 14 +- source/include/actbl.h | 165 ++-- source/include/acutils.h | 4 + source/include/amlcode.h | 22 +- source/tools/acpibin/abcompare.c | 9 +- source/tools/acpibin/abmain.c | 17 +- source/tools/acpibin/acpibin.h | 2 + source/tools/acpinames/anstubs.c | 3 +- source/tools/acpixtract/acpixtract.c | 6 +- source/tools/acpixtract/axutils.c | 6 +- 59 files changed, 2226 insertions(+), 1387 deletions(-) diff --git a/changes.txt b/changes.txt index 49c88a49bbe..52bc749dfe5 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,82 @@ +---------------------------------------- +17 November 2016. Summary of changes for version 20161117: + + +1) ACPICA kernel-resident subsystem: + +Table Manager: Fixed a regression introduced in 20160729, "FADT support +cleanup". This was an attempt to remove all references in the source to +the FADT version 2, which never was a legal version number. It was +skipped because it was an early version of 64-bit support that was +eventually abandoned for the current 64-bit support. + +Interpreter: Fixed a problem where runtime implicit conversion was +incorrectly disabled for the ASL operators below. This brings the +behavior into compliance with the ACPI specification: + FromBCD + ToBCD + ToDecimalString + ToHexString + ToInteger + ToBuffer + +Table Manager: Added a new public interface, AcpiPutTable, used to +release and free an ACPI table returned by AcpiGetTable and related +interfaces. Lv Zheng. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 140.5K Code, 58.5K Data, 198.9K Total + Debug Version: 201.3K Code, 82.7K Data, 284.0K Total + Previous Release: + Non-Debug Version: 140.4K Code, 58.1K Data, 198.5K Total + Debug Version: 200.7K Code, 82.1K Data, 282.8K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Fixed a regression for disassembly of Resource Template. +Detection of templates in the AML stream missed some types of templates. + +iASL: Fixed a problem where an Access Size error was returned for the PCC +address space when the AccessSize of the GAS register is greater than a +DWORD. Hoan Tran. + +iASL: Implemented several grammar changes for the operators below. These +changes are slated for the next version of the ACPI specification: + RefOf - Disallow method invocation as an operand + CondRefOf - Disallow method invocation as an operand + DerefOf - Disallow operands that use the result from operators +that + do not return a reference (Changed TermArg to +SuperName). + +iASL: Control method invocations are now allowed for Target operands, as +per the ACPI specification. Removed error for using a control method +invocation as a Target operand. + +Disassembler: Improved detection of Resource Templates, Unicode, and +Strings within Buffer objects. These subtypes do not contain a specific +opcode to indicate the originating ASL code, and they must be detected by +other means within the disassembler. + +iASL: Implemented an optimization improvement for 32-bit ACPI tables +(DSDT/SSDT). For the 32-bit case only, compute the optimum integer opcode +only after 64-bit to 32-bit truncation. A truncation warning message is +still emitted, however. + +AcpiXtract: Implemented handling for both types of line terminators (LF +or CR/LF) so that it can accept AcpiDump output files from any system. +Peter Wu. + +AcpiBin: Added two new options for comparing AML files: + -a: compare and display ALL mismatches + -o: start compare at this offset into the second file + ---------------------------------------- 30 September 2016. Summary of changes for version 20160930: diff --git a/source/common/acfileio.c b/source/common/acfileio.c index 409e16f0684..ffa23a64e25 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -112,7 +112,7 @@ AcGetAllTablesFromFile ( if (FileSize == ACPI_UINT32_MAX) { Status = AE_ERROR; - goto ErrorExit; + goto Exit; } fprintf (stderr, @@ -124,7 +124,7 @@ AcGetAllTablesFromFile ( if (FileSize < sizeof (ACPI_TABLE_HEADER)) { Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } /* Check for an non-binary file */ @@ -134,7 +134,8 @@ AcGetAllTablesFromFile ( fprintf (stderr, " %s: File does not appear to contain a valid AML table\n", Filename); - return (AE_TYPE); + Status = AE_TYPE; + goto Exit; } /* Read all tables within the file */ @@ -153,23 +154,31 @@ AcGetAllTablesFromFile ( } else if (Status == AE_TYPE) { - return (AE_OK); + Status = AE_OK; + goto Exit; } else if (ACPI_FAILURE (Status)) { - goto ErrorExit; + goto Exit; } /* Print table header for iASL/disassembler only */ #ifdef ACPI_ASL_COMPILER - AcpiTbPrintTableHeader (0, Table); + AcpiTbPrintTableHeader (0, Table); #endif /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC)); + if (!TableDesc) + { + AcpiOsFree (Table); + Status = AE_NO_MEMORY; + goto Exit; + } + TableDesc->Table = Table; TableDesc->Next = NULL; @@ -204,7 +213,7 @@ AcGetAllTablesFromFile ( *ReturnListHead = ListHead; } -ErrorExit: +Exit: fclose(File); return (Status); } @@ -262,7 +271,6 @@ AcGetOneTableFromFile ( return (Status); } - if (GetOnlyAmlTables) { /* diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index 4ef670d0ce9..789256c12d3 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -52,31 +52,12 @@ ACPI_MODULE_NAME ("dmtbdump") -/* Table of revision-dependent FADT sizes */ +/* Local prototypes */ -static const UINT32 FadtRevisionLength [ACPI_FADT_MAX_VERSION + 1] = -{ - 0, /* 0 - illegal */ - ACPI_FADT_V1_SIZE, /* 1 - ACPI 1.0 */ - 0, /* 2 - illegal */ - ACPI_FADT_V3_SIZE, /* 3 - ACPI 2.0 */ - ACPI_FADT_V4_SIZE, /* 4 - ACPI 3.0 and ACPI 4.0 */ - ACPI_FADT_V5_SIZE, /* 5 - ACPI 5.0 */ - ACPI_FADT_V6_SIZE /* 6 - ACPI 6.0 */ -}; - -/* Table of revision-dependent FADT info tables */ - -ACPI_DMTABLE_INFO *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1] = -{ - NULL, /* 0 - illegal */ - AcpiDmTableInfoFadt1, /* 1 - ACPI 1.0 */ - NULL, /* 2 - illegal */ - AcpiDmTableInfoFadt3, /* 3 - ACPI 2.0 */ - AcpiDmTableInfoFadt4, /* 4 - ACPI 3.0 and ACPI 4.0 */ - AcpiDmTableInfoFadt5, /* 5 - ACPI 5.0 */ - AcpiDmTableInfoFadt6 /* 6 - ACPI 6.0 */ -}; +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length); /******************************************************************************* @@ -366,11 +347,6 @@ AcpiDmDumpXsdt ( * * DESCRIPTION: Format the contents of a FADT * - * Check the FADT revision against the expected table length for - * that revision. Issue a warning if the length is not what was - * expected. This seems to be such a common BIOS bug that the - * FADT revision has been rendered virtually meaningless. - * * NOTE: We cannot depend on the FADT version to indicate the actual * contents of the FADT because of BIOS bugs. The table length * is the only reliable indicator. @@ -382,72 +358,142 @@ AcpiDmDumpFadt ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - UINT8 FadtRevision; - UINT32 ExpectedLength; - UINT32 i; - FadtRevision = Table->Revision; + /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */ - /* FADT revision/length validation */ - - if ((FadtRevision == 0) || - (FadtRevision == 2)) + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt1); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ( - "// ACPI Warning: Invalid or unsupported FADT revision: %u\n", - FadtRevision); return; } - if (FadtRevision > ACPI_FADT_MAX_VERSION) - { - AcpiOsPrintf ("// ACPI Warning: Revision %u is not fully supported, " - "disassembling known fields (up to revision %u)\n\n", - FadtRevision, ACPI_FADT_MAX_VERSION); - } - else - { - ExpectedLength = FadtRevisionLength[FadtRevision]; - if (Table->Length != ExpectedLength) - { - AcpiOsPrintf ( - "// ACPI Warning: Input FADT revision %X does not match " - "expected length: found 0x%X expected 0x%X\n", - FadtRevision, Table->Length, ExpectedLength); - } - } + /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */ - /* - * Dump the input table on a per-version basis, but is actually - * based upon the length of the table. Table length must - * be larger than the required length of the previous version. - */ - for (i = 1; i <= ACPI_FADT_MAX_VERSION; i++) + if ((Table->Length > ACPI_FADT_V1_SIZE) && + (Table->Length <= ACPI_FADT_V2_SIZE)) { - if (!FadtRevisionLength[i]) /* Skip any empty slots */ - { - continue; - } - - /* Dump the fields specific to FADT revision[i] */ - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, - FadtRevisionInfo[i]); + AcpiDmTableInfoFadt2); + if (ACPI_FAILURE (Status)) + { + return; + } + } + + /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */ + + else if (Table->Length > ACPI_FADT_V2_SIZE) + { + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt3); if (ACPI_FAILURE (Status)) { return; } - if (Table->Length <= FadtRevisionLength[i]) + /* Check for FADT revision 5 fields and up (ACPI 5.0+) */ + + if (Table->Length > ACPI_FADT_V3_SIZE) { - break; /* End of table */ + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt5); + if (ACPI_FAILURE (Status)) + { + return; + } + } + + /* Check for FADT revision 6 fields and up (ACPI 6.0+) */ + + if (Table->Length > ACPI_FADT_V3_SIZE) + { + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt6); + if (ACPI_FAILURE (Status)) + { + return; + } } } - /* Build a local FADT to test some FADT values */ + /* Validate various fields in the FADT, including length */ AcpiTbCreateLocalFadt (Table, Table->Length); + + /* Validate FADT length against the revision */ + + AcpiDmValidateFadtLength (Table->Revision, Table->Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmValidateFadtLength + * + * PARAMETERS: Revision - FADT revision (Header->Revision) + * Length - FADT length (Header->Length + * + * RETURN: None + * + * DESCRIPTION: Check the FADT revision against the expected table length for + * that revision. Issue a warning if the length is not what was + * expected. This seems to be such a common BIOS bug that the + * FADT revision has been rendered virtually meaningless. + * + ******************************************************************************/ + +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length) +{ + UINT32 ExpectedLength; + + + switch (Revision) + { + case 0: + + AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n"); + return; + + case 1: + + ExpectedLength = ACPI_FADT_V1_SIZE; + break; + + case 2: + + ExpectedLength = ACPI_FADT_V2_SIZE; + break; + + case 3: + case 4: + + ExpectedLength = ACPI_FADT_V3_SIZE; + break; + + case 5: + + ExpectedLength = ACPI_FADT_V5_SIZE; + break; + + default: + + return; + } + + if (Length == ExpectedLength) + { + return; + } + + AcpiOsPrintf ( + "\n// ACPI Warning: FADT revision %X does not match length: " + "found %X expected %X\n", + Revision, Length, ExpectedLength); } diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index e0a6070f06a..1cc37ef31df 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -400,7 +400,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = * ******************************************************************************/ -/* FADT version 1 (ACPI 1.0) */ +/* ACPI 1.0 FADT (Version 1) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = { @@ -486,7 +486,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = ACPI_DMT_TERMINATOR }; -/* FADT version 3 (ACPI 2.0) */ +/* ACPI 1.0 MS Extensions (FADT version 2) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = +{ + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { @@ -510,23 +521,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = ACPI_DMT_TERMINATOR }; -/* FADT version 4 (ACPI 3.0 and ACPI 4.0) */ - -ACPI_DMTABLE_INFO AcpiDmTableInfoFadt4[] = -{ - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepControl), "Sleep Control Register", 0}, - ACPI_DMT_TERMINATOR -}; - -/* FADT version 5 (ACPI 5.0) */ +/* ACPI 5.0 Extensions (FADT version 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[] = { + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepControl), "Sleep Control Register", 0}, {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepStatus), "Sleep Status Register", 0}, ACPI_DMT_TERMINATOR }; -/* FADT version 6 (ACPI 6.0) */ +/* ACPI 6.0 Extensions (FADT version 6) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[] = { diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index c956516f8ba..10ec3d49b34 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -151,7 +151,6 @@ AnMapArgTypeToBtype ( return (ACPI_BTYPE_DATA | ACPI_BTYPE_DEBUG_OBJECT | ACPI_BTYPE_REFERENCE_OBJECT); - case ARGI_FIXED_TARGET: case ARGI_SIMPLE_TARGET: return (ACPI_BTYPE_OBJECTS_AND_REFS); diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 15c9dae0d11..228db8b90d6 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -156,8 +156,14 @@ NamePathTail [.]{NameSeg} "^=" { count (3); return (PARSEOP_EXP_XOR_EQ); } "|=" { count (3); return (PARSEOP_EXP_OR_EQ); } -"[" { count (3); return(PARSEOP_EXP_INDEX_LEFT); } -"]" { count (0); return(PARSEOP_EXP_INDEX_RIGHT); } +"[" { count (3); return (PARSEOP_EXP_INDEX_LEFT); } +"]" { count (0); return (PARSEOP_EXP_INDEX_RIGHT); } +"(" { count (0); return (PARSEOP_OPEN_PAREN); } +")" { count (0); return (PARSEOP_CLOSE_PAREN); } + +"{" { count (0); return ('{'); } +"}" { count (0); return ('}'); } +"," { count (0); return (','); } /* @@ -691,12 +697,6 @@ NamePathTail [.]{NameSeg} "__PATH__" { count (0); return (PARSEOP___PATH__); } -"{" { count (0); return('{'); } -"}" { count (0); return('}'); } -"," { count (0); return(','); } -"(" { count (0); return('('); } -")" { count (0); return(')'); } - {NameSeg} { char *s; count (0); s=UtStringCacheCalloc (ACPI_NAME_SIZE + 1); diff --git a/source/compiler/aslcstyle.y b/source/compiler/aslcstyle.y index fc7d5933df1..d4034a5f2e4 100644 --- a/source/compiler/aslcstyle.y +++ b/source/compiler/aslcstyle.y @@ -149,21 +149,30 @@ Expression /* Parentheses */ - | '(' TermArg ')' { $$ = $2;} + | PARSEOP_OPEN_PAREN + Expression + PARSEOP_CLOSE_PAREN {$$ = $2;} /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ - | SuperName PARSEOP_EXP_INDEX_LEFT - TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX); - TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} + | IndexExpTerm ; - /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */ - + /* + * Index term -- "BUF1[5] = " or " = BUF1[5] on either the left side + * of an equals (target) or the right side (source) + * Currently used in these terms: + * Expression + * ObjectTypeSource + * DerefOfSource + * Type6Opcode + */ IndexExpTerm - : SuperName PARSEOP_EXP_INDEX_LEFT - TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX); + : SuperName + PARSEOP_EXP_INDEX_LEFT + TermArg + PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX); TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} ; @@ -177,11 +186,26 @@ IndexExpTerm EqualsTerm + /* Allow parens anywhere */ + + : PARSEOP_OPEN_PAREN + EqualsTerm + PARSEOP_CLOSE_PAREN {$$ = $2;} + /* Simple Store() operation */ - : SuperName PARSEOP_EXP_EQUALS + | SuperName + PARSEOP_EXP_EQUALS TermArg {$$ = TrCreateAssignmentNode ($1, $3);} + /* Chained equals: (a=RefOf)=b, a=b=c=d etc. */ + + | PARSEOP_OPEN_PAREN + EqualsTerm + PARSEOP_CLOSE_PAREN + PARSEOP_EXP_EQUALS + TermArg {$$ = TrCreateAssignmentNode ($2, $5);} + /* Compound assignments -- Add (operand, operand, target) */ | TermArg PARSEOP_EXP_ADD_EQ {$$ = TrCreateLeafNode (PARSEOP_ADD);} diff --git a/source/compiler/aslexternal.c b/source/compiler/aslexternal.c index a814efddd54..8e76aa7236c 100644 --- a/source/compiler/aslexternal.c +++ b/source/compiler/aslexternal.c @@ -325,6 +325,7 @@ ExMoveExternals ( ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *Prev; ACPI_PARSE_OBJECT *Next; + char *ExternalName; ACPI_OBJECT_TYPE ObjType; UINT32 i; @@ -345,6 +346,12 @@ ExMoveExternals ( */ ExternalOp = NextOp->Asl.Child; + /* Get/set the fully qualified name */ + + ExternalName = AcpiNsGetNormalizedPathname (ExternalOp->Asl.Node, TRUE); + ExternalOp->Asl.ExternalName = ExternalName; + ExternalOp->Asl.Namepath = ExternalName; + /* Set line numbers (for listings, etc.) */ ExternalOp->Asl.LineNumber = 0; @@ -354,6 +361,14 @@ ExMoveExternals ( Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; + if (Next->Asl.ParseOpcode == PARSEOP_NAMESEG) + { + Next->Asl.ParseOpcode = PARSEOP_NAMESTRING; + } + Next->Asl.ExternalName = ExternalName; + UtInternalizeName (ExternalName, &Next->Asl.Value.String); + Next->Asl.AmlLength = strlen (Next->Asl.Value.String); + Next = Next->Asl.Next; Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; diff --git a/source/compiler/aslkeywords.y b/source/compiler/aslkeywords.y index 51af1c684a3..c908ae401c5 100644 --- a/source/compiler/aslkeywords.y +++ b/source/compiler/aslkeywords.y @@ -58,15 +58,18 @@ AccessAttribKeyword | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} - | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} + | PARSEOP_ACCESSATTRIB_MULTIBYTE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_BYTES + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_PROCESS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} ; AccessTypeKeyword diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index de9ffe1baf0..c981f07c4d7 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -289,7 +289,7 @@ OpcSetOptimalIntegerSize ( Op->Asl.AmlOpcode = AML_DWORD_OP; return (4); } - else + else /* 64-bit integer */ { if (AcpiGbl_IntegerByteWidth == 4) { @@ -299,8 +299,12 @@ OpcSetOptimalIntegerSize ( if (!Gbl_IgnoreErrors) { /* Truncate the integer to 32-bit */ - Op->Asl.AmlOpcode = AML_DWORD_OP; - return (4); + + Op->Asl.Value.Integer &= ACPI_UINT32_MAX; + + /* Now set the optimal integer size */ + + return (OpcSetOptimalIntegerSize (Op)); } } diff --git a/source/compiler/aslprimaries.y b/source/compiler/aslprimaries.y index 742213ab623..b52bbcdc671 100644 --- a/source/compiler/aslprimaries.y +++ b/source/compiler/aslprimaries.y @@ -52,51 +52,61 @@ NoEcho(' ******************************************************************************/ AccessAsTerm - : PARSEOP_ACCESSAS '(' + : PARSEOP_ACCESSAS + PARSEOP_OPEN_PAREN AccessTypeKeyword OptionalAccessAttribTerm - ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} - | PARSEOP_ACCESSAS '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} + | PARSEOP_ACCESSAS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; AcquireTerm - : PARSEOP_ACQUIRE '(' {$$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} + : PARSEOP_ACQUIRE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} SuperName ',' WordConstExpr - ')' {$$ = TrLinkChildren ($3,2,$4,$6);} - | PARSEOP_ACQUIRE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$6);} + | PARSEOP_ACQUIRE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; AddTerm - : PARSEOP_ADD '(' {$$ = TrCreateLeafNode (PARSEOP_ADD);} + : PARSEOP_ADD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ADD);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_ADD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_ADD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; AliasTerm - : PARSEOP_ALIAS '(' {$$ = TrCreateLeafNode (PARSEOP_ALIAS);} + : PARSEOP_ALIAS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ALIAS);} NameString NameStringItem - ')' {$$ = TrLinkChildren ($3,2,$4, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4, TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} - | PARSEOP_ALIAS '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_ALIAS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; AndTerm - : PARSEOP_AND '(' {$$ = TrCreateLeafNode (PARSEOP_AND);} + : PARSEOP_AND + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_AND);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_AND '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_AND + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ArgTerm @@ -110,18 +120,21 @@ ArgTerm ; BankFieldTerm - : PARSEOP_BANKFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} + : PARSEOP_BANKFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} NameString NameStringItem TermArgItem ',' AccessTypeKeyword ',' LockRuleKeyword ',' UpdateRuleKeyword - ')' '{' + PARSEOP_CLOSE_PAREN '{' FieldUnitList '}' {$$ = TrLinkChildren ($3,7, $4,$5,$6,$8,$10,$12,$15);} - | PARSEOP_BANKFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + | PARSEOP_BANKFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN + '{' error '}' {$$ = AslDoError(); yyclearin;} ; BreakTerm @@ -144,58 +157,69 @@ BufferTermData ; CaseTerm - : PARSEOP_CASE '(' {$$ = TrCreateLeafNode (PARSEOP_CASE);} + : PARSEOP_CASE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CASE);} DataObject - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_CASE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CASE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ConcatTerm - : PARSEOP_CONCATENATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} + : PARSEOP_CONCATENATE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_CONCATENATE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ConcatResTerm - : PARSEOP_CONCATENATERESTEMPLATE '(' {$$ = TrCreateLeafNode ( - PARSEOP_CONCATENATERESTEMPLATE);} + : PARSEOP_CONCATENATERESTEMPLATE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode ( + PARSEOP_CONCATENATERESTEMPLATE);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATERESTEMPLATE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_CONCATENATERESTEMPLATE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} + ; + +CondRefOfTerm + : PARSEOP_CONDREFOF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} + CondRefOfSource + Target + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_CONDREFOF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ConnectionTerm - : PARSEOP_CONNECTION '(' + : PARSEOP_CONNECTION + PARSEOP_OPEN_PAREN NameString - ')' {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);} - | PARSEOP_CONNECTION '(' {$$ = TrCreateLeafNode (PARSEOP_CONNECTION);} + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);} + | PARSEOP_CONNECTION + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CONNECTION);} ResourceMacroTerm - ')' {$$ = TrLinkChildren ($3, 1, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3, 1, TrLinkChildren ( TrCreateLeafNode (PARSEOP_RESOURCETEMPLATE), 3, TrCreateLeafNode (PARSEOP_DEFAULT_ARG), TrCreateLeafNode (PARSEOP_DEFAULT_ARG), $4));} - | PARSEOP_CONNECTION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CondRefOfTerm - : PARSEOP_CONDREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} - SuperName - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_CONDREFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CONNECTION + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ContinueTerm @@ -203,92 +227,108 @@ ContinueTerm ; CopyObjectTerm - : PARSEOP_COPYOBJECT '(' {$$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} + : PARSEOP_COPYOBJECT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} TermArg - ',' SimpleTarget - ')' {$$ = TrLinkChildren ($3,2,$4, + ',' SimpleName + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4, TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_COPYOBJECT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_COPYOBJECT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateBitFieldTerm - : PARSEOP_CREATEBITFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} + : PARSEOP_CREATEBITFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} TermArg TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5, TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBITFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEBITFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateByteFieldTerm - : PARSEOP_CREATEBYTEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);} + : PARSEOP_CREATEBYTEFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);} TermArg TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5, TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBYTEFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEBYTEFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateDWordFieldTerm - : PARSEOP_CREATEDWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);} + : PARSEOP_CREATEDWORDFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);} TermArg TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5, TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEDWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEDWORDFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateFieldTerm - : PARSEOP_CREATEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);} + : PARSEOP_CREATEFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);} TermArg TermArgItem TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4,$4,$5,$6, TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateQWordFieldTerm - : PARSEOP_CREATEQWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);} + : PARSEOP_CREATEQWORDFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);} TermArg TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5, TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEQWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEQWORDFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; CreateWordFieldTerm - : PARSEOP_CREATEWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);} + : PARSEOP_CREATEWORDFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);} TermArg TermArgItem NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5, TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_CREATEWORDFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DataRegionTerm - : PARSEOP_DATATABLEREGION '(' {$$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);} + : PARSEOP_DATATABLEREGION + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);} NameString TermArgItem TermArgItem TermArgItem - ')' {$$ = TrLinkChildren ($3,4, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);} - | PARSEOP_DATATABLEREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DATATABLEREGION + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DebugTerm @@ -296,11 +336,13 @@ DebugTerm ; DecTerm - : PARSEOP_DECREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + : PARSEOP_DECREMENT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DECREMENT);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_DECREMENT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_DECREMENT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DefaultTerm @@ -311,39 +353,48 @@ DefaultTerm ; DerefOfTerm - : PARSEOP_DEREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_DEREFOF);} - TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_DEREFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} + : PARSEOP_DEREFOF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DEREFOF);} + DerefOfSource + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_DEREFOF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DeviceTerm - : PARSEOP_DEVICE '(' {$$ = TrCreateLeafNode (PARSEOP_DEVICE);} + : PARSEOP_DEVICE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DEVICE);} NameString - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,2, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_DEVICE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DEVICE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DivideTerm - : PARSEOP_DIVIDE '(' {$$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + : PARSEOP_DIVIDE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DIVIDE);} TermArg TermArgItem Target Target - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_DIVIDE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} + | PARSEOP_DIVIDE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; EISAIDTerm - : PARSEOP_EISAID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} - | PARSEOP_EISAID '(' - error ')' {$$ = AslDoError(); yyclearin;} + : PARSEOP_EISAID + PARSEOP_OPEN_PAREN + StringData + PARSEOP_CLOSE_PAREN {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} + | PARSEOP_EISAID + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ElseIfTerm @@ -361,88 +412,105 @@ ElseTerm | PARSEOP_ELSE error {$$ = AslDoError(); yyclearin;} - | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} + | PARSEOP_ELSEIF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_ELSE);} TermArg {$$ = TrCreateLeafNode (PARSEOP_IF);} - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {TrLinkChildren ($5,2,$4,$8);} ElseTerm {TrLinkPeerNode ($5,$11);} {$$ = TrLinkChildren ($3,1,$5);} - | PARSEOP_ELSEIF '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_ELSEIF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} | PARSEOP_ELSEIF error {$$ = AslDoError(); yyclearin;} ; EventTerm - : PARSEOP_EVENT '(' {$$ = TrCreateLeafNode (PARSEOP_EVENT);} + : PARSEOP_EVENT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_EVENT);} NameString - ')' {$$ = TrLinkChildren ($3,1, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} - | PARSEOP_EVENT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_EVENT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ExternalTerm - : PARSEOP_EXTERNAL '(' + : PARSEOP_EXTERNAL + PARSEOP_OPEN_PAREN NameString OptionalObjectTypeKeyword OptionalParameterTypePackage OptionalParameterTypesPackage - ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} - | PARSEOP_EXTERNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} + | PARSEOP_EXTERNAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FatalTerm - : PARSEOP_FATAL '(' {$$ = TrCreateLeafNode (PARSEOP_FATAL);} + : PARSEOP_FATAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FATAL);} ByteConstExpr ',' DWordConstExpr TermArgItem - ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} - | PARSEOP_FATAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$6,$7);} + | PARSEOP_FATAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FieldTerm - : PARSEOP_FIELD '(' {$$ = TrCreateLeafNode (PARSEOP_FIELD);} + : PARSEOP_FIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FIELD);} NameString ',' AccessTypeKeyword ',' LockRuleKeyword ',' UpdateRuleKeyword - ')' '{' + PARSEOP_CLOSE_PAREN '{' FieldUnitList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$8,$10,$13);} - | PARSEOP_FIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + | PARSEOP_FIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN + '{' error '}' {$$ = AslDoError(); yyclearin;} ; FindSetLeftBitTerm - : PARSEOP_FINDSETLEFTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} + : PARSEOP_FINDSETLEFTBIT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETLEFTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FINDSETLEFTBIT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FindSetRightBitTerm - : PARSEOP_FINDSETRIGHTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} + : PARSEOP_FINDSETRIGHTBIT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETRIGHTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FINDSETRIGHTBIT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; /* Convert a For() loop to a While() loop */ ForTerm - : PARSEOP_FOR '(' {$$ = TrCreateLeafNode (PARSEOP_WHILE);} + : PARSEOP_FOR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WHILE);} OptionalTermArg ',' {} OptionalPredicate ',' OptionalTermArg {$$ = TrLinkPeerNode ($4,$3); - TrSetParent ($9,$3);} /* New parent is WHILE */ - ')' '{' TermList '}' {$$ = TrLinkChildren ($3,2,$7,$13);} + TrSetParent ($9,$3);} /* New parent is WHILE */ + PARSEOP_CLOSE_PAREN + '{' TermList '}' {$$ = TrLinkChildren ($3,2,$7,$13);} {$$ = TrLinkPeerNode ($13,$9); $$ = $10;} ; @@ -453,52 +521,62 @@ OptionalPredicate ; FprintfTerm - : PARSEOP_FPRINTF '(' {$$ = TrCreateLeafNode (PARSEOP_FPRINTF);} + : PARSEOP_FPRINTF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FPRINTF);} TermArg ',' StringData PrintfArgList - ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} - | PARSEOP_FPRINTF '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$6,$7);} + | PARSEOP_FPRINTF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FromBCDTerm - : PARSEOP_FROMBCD '(' {$$ = TrCreateLeafNode (PARSEOP_FROMBCD);} + : PARSEOP_FROMBCD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FROMBCD);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FROMBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FROMBCD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FunctionTerm - : PARSEOP_FUNCTION '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} + : PARSEOP_FUNCTION + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_METHOD);} NameString OptionalParameterTypePackage OptionalParameterTypesPackage - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,7, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} - | PARSEOP_FUNCTION '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_FUNCTION + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IfTerm - : PARSEOP_IF '(' {$$ = TrCreateLeafNode (PARSEOP_IF);} + : PARSEOP_IF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_IF);} TermArg - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_IF '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_IF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IncludeTerm - : PARSEOP_INCLUDE '(' - String ')' {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3); + : PARSEOP_INCLUDE + PARSEOP_OPEN_PAREN + String + PARSEOP_CLOSE_PAREN {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3); FlOpenIncludeFile ($3);} ; @@ -508,130 +586,157 @@ IncludeEndTerm ; IncTerm - : PARSEOP_INCREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_INCREMENT);} + : PARSEOP_INCREMENT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_INCREMENT);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_INCREMENT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_INCREMENT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IndexFieldTerm - : PARSEOP_INDEXFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} + : PARSEOP_INDEXFIELD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} NameString NameStringItem ',' AccessTypeKeyword ',' LockRuleKeyword ',' UpdateRuleKeyword - ')' '{' + PARSEOP_CLOSE_PAREN '{' FieldUnitList '}' {$$ = TrLinkChildren ($3,6,$4,$5,$7,$9,$11,$14);} - | PARSEOP_INDEXFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + | PARSEOP_INDEXFIELD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN + '{' error '}' {$$ = AslDoError(); yyclearin;} ; IndexTerm - : PARSEOP_INDEX '(' {$$ = TrCreateLeafNode (PARSEOP_INDEX);} + : PARSEOP_INDEX + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_INDEX);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_INDEX '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_INDEX + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LAndTerm - : PARSEOP_LAND '(' {$$ = TrCreateLeafNode (PARSEOP_LAND);} + : PARSEOP_LAND + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LAND);} TermArg TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LAND '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LAND + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LEqualTerm - : PARSEOP_LEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + : PARSEOP_LEQUAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} TermArg TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LEQUAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LGreaterEqualTerm - : PARSEOP_LGREATEREQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} + : PARSEOP_LGREATEREQUAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LLESS);} TermArg TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LGREATEREQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_LGREATEREQUAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LGreaterTerm - : PARSEOP_LGREATER '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} + : PARSEOP_LGREATER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LGREATER '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LGREATER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LLessEqualTerm - : PARSEOP_LLESSEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} + : PARSEOP_LLESSEQUAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LLESSEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_LLESSEQUAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LLessTerm - : PARSEOP_LLESS '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} + : PARSEOP_LLESS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LLESS);} TermArg TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LLESS '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LLESS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LNotEqualTerm - : PARSEOP_LNOTEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + : PARSEOP_LNOTEQUAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} TermArg TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LNOTEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_LNOTEQUAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LNotTerm - : PARSEOP_LNOT '(' {$$ = TrCreateLeafNode (PARSEOP_LNOT);} + : PARSEOP_LNOT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LNOT);} TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_LNOT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_LNOT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LoadTableTerm - : PARSEOP_LOADTABLE '(' {$$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} + : PARSEOP_LOADTABLE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} TermArg TermArgItem TermArgItem OptionalListString OptionalListString OptionalReference - ')' {$$ = TrLinkChildren ($3,6,$4,$5,$6,$7,$8,$9);} - | PARSEOP_LOADTABLE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$5,$6,$7,$8,$9);} + | PARSEOP_LOADTABLE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LoadTerm - : PARSEOP_LOAD '(' {$$ = TrCreateLeafNode (PARSEOP_LOAD);} + : PARSEOP_LOAD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LOAD);} NameString RequiredTarget - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LOAD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; LocalTerm @@ -646,102 +751,120 @@ LocalTerm ; LOrTerm - : PARSEOP_LOR '(' {$$ = TrCreateLeafNode (PARSEOP_LOR);} + : PARSEOP_LOR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_LOR);} TermArg TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LOR '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LOR + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; MatchTerm - : PARSEOP_MATCH '(' {$$ = TrCreateLeafNode (PARSEOP_MATCH);} + : PARSEOP_MATCH + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MATCH);} TermArg ',' MatchOpKeyword TermArgItem ',' MatchOpKeyword TermArgItem TermArgItem - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$7,$9,$10,$11);} - | PARSEOP_MATCH '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$6,$7,$9,$10,$11);} + | PARSEOP_MATCH + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; MethodTerm - : PARSEOP_METHOD '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} + : PARSEOP_METHOD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_METHOD);} NameString OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} OptionalSerializeRuleKeyword OptionalByteConstExpr OptionalParameterTypePackage OptionalParameterTypesPackage - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,7, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), $5,$7,$8,$9,$10,$13);} - | PARSEOP_METHOD '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_METHOD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; MidTerm - : PARSEOP_MID '(' {$$ = TrCreateLeafNode (PARSEOP_MID);} + : PARSEOP_MID + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MID);} TermArg TermArgItem TermArgItem Target - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_MID '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} + | PARSEOP_MID + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ModTerm - : PARSEOP_MOD '(' {$$ = TrCreateLeafNode (PARSEOP_MOD);} + : PARSEOP_MOD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MOD);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_MOD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_MOD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; MultiplyTerm - : PARSEOP_MULTIPLY '(' {$$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + : PARSEOP_MULTIPLY + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_MULTIPLY '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_MULTIPLY + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; MutexTerm - : PARSEOP_MUTEX '(' {$$ = TrCreateLeafNode (PARSEOP_MUTEX);} + : PARSEOP_MUTEX + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MUTEX);} NameString ',' ByteConstExpr - ')' {$$ = TrLinkChildren ($3,2, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_MUTEX '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_MUTEX + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; NameTerm - : PARSEOP_NAME '(' {$$ = TrCreateLeafNode (PARSEOP_NAME);} + : PARSEOP_NAME + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_NAME);} NameString ',' DataObject - ')' {$$ = TrLinkChildren ($3,2, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_NAME '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_NAME + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; NAndTerm - : PARSEOP_NAND '(' {$$ = TrCreateLeafNode (PARSEOP_NAND);} + : PARSEOP_NAND + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_NAND);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_NAND '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_NAND + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; NoOpTerm @@ -749,60 +872,72 @@ NoOpTerm ; NOrTerm - : PARSEOP_NOR '(' {$$ = TrCreateLeafNode (PARSEOP_NOR);} + : PARSEOP_NOR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_NOR);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_NOR '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_NOR + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; NotifyTerm - : PARSEOP_NOTIFY '(' {$$ = TrCreateLeafNode (PARSEOP_NOTIFY);} + : PARSEOP_NOTIFY + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_NOTIFY);} SuperName TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_NOTIFY '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_NOTIFY + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; NotTerm - : PARSEOP_NOT '(' {$$ = TrCreateLeafNode (PARSEOP_NOT);} + : PARSEOP_NOT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_NOT);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_NOT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_NOT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ObjectTypeTerm - : PARSEOP_OBJECTTYPE '(' {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);} - ObjectTypeName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_OBJECTTYPE '(' - error ')' {$$ = AslDoError(); yyclearin;} + : PARSEOP_OBJECTTYPE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);} + ObjectTypeSource + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_OBJECTTYPE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; OffsetTerm - : PARSEOP_OFFSET '(' + : PARSEOP_OFFSET + PARSEOP_OPEN_PAREN AmlPackageLengthTerm - ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} - | PARSEOP_OFFSET '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} + | PARSEOP_OFFSET + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; OpRegionTerm - : PARSEOP_OPERATIONREGION '(' {$$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} + : PARSEOP_OPERATIONREGION + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} NameString ',' OpRegionSpaceIdTerm TermArgItem TermArgItem - ')' {$$ = TrLinkChildren ($3,4, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), $6,$7,$8);} - | PARSEOP_OPERATIONREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_OPERATIONREGION + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; OpRegionSpaceIdTerm @@ -811,13 +946,15 @@ OpRegionSpaceIdTerm ; OrTerm - : PARSEOP_OR '(' {$$ = TrCreateLeafNode (PARSEOP_OR);} + : PARSEOP_OR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_OR);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_OR '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_OR + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; PackageTerm @@ -826,25 +963,29 @@ PackageTerm '{' PackageList '}' {$$ = TrLinkChildren ($2,2,$3,$5);} PowerResTerm - : PARSEOP_POWERRESOURCE '(' {$$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} + : PARSEOP_POWERRESOURCE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} NameString ',' ByteConstExpr ',' WordConstExpr - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,4, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), $6,$8,$11);} - | PARSEOP_POWERRESOURCE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_POWERRESOURCE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; PrintfTerm - : PARSEOP_PRINTF '(' {$$ = TrCreateLeafNode (PARSEOP_PRINTF);} + : PARSEOP_PRINTF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_PRINTF);} StringData PrintfArgList - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_PRINTF '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_PRINTF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; PrintfArgList @@ -855,26 +996,30 @@ PrintfArgList ; ProcessorTerm - : PARSEOP_PROCESSOR '(' {$$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} + : PARSEOP_PROCESSOR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} NameString ',' ByteConstExpr OptionalDWordConstExpr OptionalByteConstExpr - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,5, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), $6,$7,$8,$11);} - | PARSEOP_PROCESSOR '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_PROCESSOR + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; RawDataBufferTerm - : PARSEOP_DATABUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} + : PARSEOP_DATABUFFER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} OptionalWordConst - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_DATABUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DATABUFFER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; /* @@ -882,204 +1027,247 @@ RawDataBufferTerm * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) */ RefOfTerm - : PARSEOP_REFOF '(' {$$ = TrCreateLeafNode (PARSEOP_REFOF);} - SuperName - ')' {$$ = TrLinkChildren ($3,1, + : PARSEOP_REFOF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_REFOF);} + RefOfSource + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1, TrSetNodeFlags ($4, NODE_IS_TARGET));} - | PARSEOP_REFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_REFOF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ReleaseTerm - : PARSEOP_RELEASE '(' {$$ = TrCreateLeafNode (PARSEOP_RELEASE);} + : PARSEOP_RELEASE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_RELEASE);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_RELEASE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_RELEASE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ResetTerm - : PARSEOP_RESET '(' {$$ = TrCreateLeafNode (PARSEOP_RESET);} + : PARSEOP_RESET + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_RESET);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_RESET '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_RESET + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ReturnTerm - : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);} + : PARSEOP_RETURN + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_RETURN);} OptionalReturnArg - ')' {$$ = TrLinkChildren ($3,1,$4);} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} | PARSEOP_RETURN {$$ = TrLinkChildren ( TrCreateLeafNode (PARSEOP_RETURN),1, TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} - | PARSEOP_RETURN '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_RETURN + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ScopeTerm - : PARSEOP_SCOPE '(' {$$ = TrCreateLeafNode (PARSEOP_SCOPE);} + : PARSEOP_SCOPE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SCOPE);} NameString - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,2, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_SCOPE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_SCOPE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ShiftLeftTerm - : PARSEOP_SHIFTLEFT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + : PARSEOP_SHIFTLEFT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTLEFT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SHIFTLEFT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ShiftRightTerm - : PARSEOP_SHIFTRIGHT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + : PARSEOP_SHIFTRIGHT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTRIGHT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SHIFTRIGHT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SignalTerm - : PARSEOP_SIGNAL '(' {$$ = TrCreateLeafNode (PARSEOP_SIGNAL);} + : PARSEOP_SIGNAL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SIGNAL);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SIGNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SIGNAL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SizeOfTerm - : PARSEOP_SIZEOF '(' {$$ = TrCreateLeafNode (PARSEOP_SIZEOF);} + : PARSEOP_SIZEOF + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SIZEOF);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SIZEOF '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SIZEOF + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SleepTerm - : PARSEOP_SLEEP '(' {$$ = TrCreateLeafNode (PARSEOP_SLEEP);} + : PARSEOP_SLEEP + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SLEEP);} TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SLEEP '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SLEEP + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; StallTerm - : PARSEOP_STALL '(' {$$ = TrCreateLeafNode (PARSEOP_STALL);} + : PARSEOP_STALL + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_STALL);} TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_STALL '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_STALL + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; StoreTerm - : PARSEOP_STORE '(' {$$ = TrCreateLeafNode (PARSEOP_STORE);} + : PARSEOP_STORE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_STORE);} TermArg ',' SuperName - ')' {$$ = TrLinkChildren ($3,2,$4, - TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_STORE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4, + TrSetNodeFlags ($6, NODE_IS_TARGET));} + | PARSEOP_STORE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SubtractTerm - : PARSEOP_SUBTRACT '(' {$$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + : PARSEOP_SUBTRACT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SUBTRACT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SUBTRACT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SwitchTerm - : PARSEOP_SWITCH '(' {$$ = TrCreateLeafNode (PARSEOP_SWITCH);} + : PARSEOP_SWITCH + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SWITCH);} TermArg - ')' '{' - CaseDefaultTermList '}' - {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_SWITCH '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN '{' + CaseDefaultTermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_SWITCH + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ThermalZoneTerm - : PARSEOP_THERMALZONE '(' {$$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} + : PARSEOP_THERMALZONE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} NameString - ')' '{' + PARSEOP_CLOSE_PAREN '{' TermList '}' {$$ = TrLinkChildren ($3,2, TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_THERMALZONE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_THERMALZONE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; TimerTerm - : PARSEOP_TIMER '(' {$$ = TrCreateLeafNode (PARSEOP_TIMER);} - ')' {$$ = TrLinkChildren ($3,0);} + : PARSEOP_TIMER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TIMER);} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,0);} | PARSEOP_TIMER {$$ = TrLinkChildren ( TrCreateLeafNode (PARSEOP_TIMER),0);} - | PARSEOP_TIMER '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_TIMER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToBCDTerm - : PARSEOP_TOBCD '(' {$$ = TrCreateLeafNode (PARSEOP_TOBCD);} + : PARSEOP_TOBCD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOBCD);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOBCD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToBufferTerm - : PARSEOP_TOBUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_TOBUFFER);} + : PARSEOP_TOBUFFER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOBUFFER);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOBUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOBUFFER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToDecimalStringTerm - : PARSEOP_TODECIMALSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);} + : PARSEOP_TODECIMALSTRING + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TODECIMALSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TODECIMALSTRING + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToHexStringTerm - : PARSEOP_TOHEXSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);} + : PARSEOP_TOHEXSTRING + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOHEXSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOHEXSTRING + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToIntegerTerm - : PARSEOP_TOINTEGER '(' {$$ = TrCreateLeafNode (PARSEOP_TOINTEGER);} + : PARSEOP_TOINTEGER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOINTEGER);} TermArg Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOINTEGER '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOINTEGER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToPLDTerm - : PARSEOP_TOPLD '(' {$$ = TrCreateLeafNode (PARSEOP_TOPLD);} + : PARSEOP_TOPLD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOPLD);} PldKeywordList - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_TOPLD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_TOPLD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; PldKeywordList @@ -1099,62 +1287,77 @@ PldKeywordList ToStringTerm - : PARSEOP_TOSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOSTRING);} + : PARSEOP_TOSTRING + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_TOSTRING);} TermArg OptionalCount Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_TOSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_TOSTRING + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ToUUIDTerm - : PARSEOP_TOUUID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);} - | PARSEOP_TOUUID '(' - error ')' {$$ = AslDoError(); yyclearin;} + : PARSEOP_TOUUID + PARSEOP_OPEN_PAREN + StringData + PARSEOP_CLOSE_PAREN {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);} + | PARSEOP_TOUUID + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; UnicodeTerm - : PARSEOP_UNICODE '(' {$$ = TrCreateLeafNode (PARSEOP_UNICODE);} + : PARSEOP_UNICODE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_UNICODE);} StringData - ')' {$$ = TrLinkChildren ($3,2,0,$4);} - | PARSEOP_UNICODE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,0,$4);} + | PARSEOP_UNICODE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; UnloadTerm - : PARSEOP_UNLOAD '(' {$$ = TrCreateLeafNode (PARSEOP_UNLOAD);} + : PARSEOP_UNLOAD + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_UNLOAD);} SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_UNLOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_UNLOAD + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; WaitTerm - : PARSEOP_WAIT '(' {$$ = TrCreateLeafNode (PARSEOP_WAIT);} + : PARSEOP_WAIT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WAIT);} SuperName TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_WAIT '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_WAIT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; XOrTerm - : PARSEOP_XOR '(' {$$ = TrCreateLeafNode (PARSEOP_XOR);} + : PARSEOP_XOR + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_XOR);} TermArg TermArgItem Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_XOR '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_XOR + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; WhileTerm - : PARSEOP_WHILE '(' {$$ = TrCreateLeafNode (PARSEOP_WHILE);} + : PARSEOP_WHILE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WHILE);} TermArg - ')' '{' TermList '}' - {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_WHILE '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN + '{' TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_WHILE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; diff --git a/source/compiler/aslresources.y b/source/compiler/aslresources.y index 92d58a9257d..34ce47574bc 100644 --- a/source/compiler/aslresources.y +++ b/source/compiler/aslresources.y @@ -56,7 +56,8 @@ NoEcho(' * Also, insert the EndTag at the end of the template. */ ResourceTemplateTerm - : PARSEOP_RESOURCETEMPLATE OptionalParentheses + : PARSEOP_RESOURCETEMPLATE + OptionalParentheses '{' ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, TrCreateLeafNode (PARSEOP_DEFAULT_ARG), @@ -67,7 +68,8 @@ ResourceTemplateTerm OptionalParentheses : {$$ = NULL;} - | '(' ')' {$$ = NULL;} + | PARSEOP_OPEN_PAREN + PARSEOP_CLOSE_PAREN {$$ = NULL;} ; ResourceMacroList @@ -116,19 +118,22 @@ ResourceMacroTerm ; DMATerm - : PARSEOP_DMA '(' {$$ = TrCreateLeafNode (PARSEOP_DMA);} + : PARSEOP_DMA + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DMA);} DMATypeKeyword OptionalBusMasterKeyword ',' XferTypeKeyword OptionalNameString_Last - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$5,$7,$8,$11);} - | PARSEOP_DMA '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DMA + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DWordIOTerm - : PARSEOP_DWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDIO);} + : PARSEOP_DWORDIO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DWORDIO);} OptionalResourceType_First OptionalMinType OptionalMaxType @@ -144,14 +149,16 @@ DWordIOTerm OptionalNameString OptionalType OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_DWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DWORDIO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DWordMemoryTerm - : PARSEOP_DWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} + : PARSEOP_DWORDMEMORY + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} OptionalResourceType_First OptionalDecodeType OptionalMinType @@ -168,14 +175,16 @@ DWordMemoryTerm OptionalNameString OptionalAddressRange OptionalType_Last - ')' {$$ = TrLinkChildren ($3,16, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,16, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_DWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DWORDMEMORY + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; DWordSpaceTerm - : PARSEOP_DWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} + : PARSEOP_DWORDSPACE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} OptionalResourceType OptionalDecodeType @@ -190,21 +199,25 @@ DWordSpaceTerm OptionalByteConstExpr OptionalStringData OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_DWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DWORDSPACE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; EndDependentFnTerm - : PARSEOP_ENDDEPENDENTFN '(' - ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} - | PARSEOP_ENDDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} + : PARSEOP_ENDDEPENDENTFN + PARSEOP_OPEN_PAREN + PARSEOP_CLOSE_PAREN {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} + | PARSEOP_ENDDEPENDENTFN + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ExtendedIOTerm - : PARSEOP_EXTENDEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} + : PARSEOP_EXTENDEDIO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} OptionalResourceType_First OptionalMinType OptionalMaxType @@ -219,14 +232,16 @@ ExtendedIOTerm OptionalNameString OptionalType OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} - | PARSEOP_EXTENDEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_EXTENDEDIO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ExtendedMemoryTerm - : PARSEOP_EXTENDEDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} + : PARSEOP_EXTENDEDMEMORY + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} OptionalResourceType_First OptionalDecodeType OptionalMinType @@ -242,14 +257,15 @@ ExtendedMemoryTerm OptionalNameString OptionalAddressRange OptionalType_Last - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} - | PARSEOP_EXTENDEDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_EXTENDEDMEMORY + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; ExtendedSpaceTerm - : PARSEOP_EXTENDEDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} + : PARSEOP_EXTENDEDSPACE PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} OptionalResourceType OptionalDecodeType @@ -263,35 +279,41 @@ ExtendedSpaceTerm ',' QWordConstExpr OptionalQWordConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,13, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,13, $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} - | PARSEOP_EXTENDEDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_EXTENDEDSPACE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FixedDmaTerm - : PARSEOP_FIXEDDMA '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} + : PARSEOP_FIXEDDMA + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} WordConstExpr /* 04: DMA RequestLines */ ',' WordConstExpr /* 06: DMA Channels */ OptionalXferSize /* 07: DMA TransferSize */ OptionalNameString /* 08: DescriptorName */ - ')' {$$ = TrLinkChildren ($3,4,$4,$6,$7,$8);} - | PARSEOP_FIXEDDMA '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4,$4,$6,$7,$8);} + | PARSEOP_FIXEDDMA + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; FixedIOTerm - : PARSEOP_FIXEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} + : PARSEOP_FIXEDIO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} WordConstExpr ',' ByteConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} - | PARSEOP_FIXEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,3,$4,$6,$7);} + | PARSEOP_FIXEDIO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; GpioIntTerm - : PARSEOP_GPIO_INT '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} + : PARSEOP_GPIO_INT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} InterruptTypeKeyword /* 04: InterruptType */ ',' InterruptLevel /* 06: InterruptLevel */ OptionalShareType /* 07: SharedType */ @@ -302,15 +324,17 @@ GpioIntTerm OptionalResourceType /* 14: ResourceType */ OptionalNameString /* 15: DescriptorName */ OptionalBuffer_Last /* 16: VendorData */ - ')' '{' + PARSEOP_CLOSE_PAREN '{' DWordConstExpr '}' {$$ = TrLinkChildren ($3,11, $4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} - | PARSEOP_GPIO_INT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_GPIO_INT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; GpioIoTerm - : PARSEOP_GPIO_IO '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} + : PARSEOP_GPIO_IO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} OptionalShareType_First /* 04: SharedType */ ',' PinConfigByte /* 06: PinConfig */ OptionalWordConstExpr /* 07: DebounceTimeout */ @@ -321,15 +345,17 @@ GpioIoTerm OptionalResourceType /* 13: ResourceType */ OptionalNameString /* 14: DescriptorName */ OptionalBuffer_Last /* 15: VendorData */ - ')' '{' + PARSEOP_CLOSE_PAREN '{' DWordList '}' {$$ = TrLinkChildren ($3,11, $4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} - | PARSEOP_GPIO_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_GPIO_IO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; I2cSerialBusTerm - : PARSEOP_I2C_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} + : PARSEOP_I2C_SERIALBUS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} WordConstExpr /* 04: SlaveAddress */ OptionalSlaveMode /* 05: SlaveMode */ ',' DWordConstExpr /* 07: ConnectionSpeed */ @@ -339,15 +365,17 @@ I2cSerialBusTerm OptionalResourceType /* 12: ResourceType */ OptionalNameString /* 13: DescriptorName */ OptionalBuffer_Last /* 14: VendorData */ - ')' {$$ = TrLinkChildren ($3,10, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,10, $4,$5,$7,$8,$10,$11,$12,$13, TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$14);} - | PARSEOP_I2C_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_I2C_SERIALBUS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; I2cSerialBusTermV2 - : PARSEOP_I2C_SERIALBUS_V2 '(' {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS_V2);} + : PARSEOP_I2C_SERIALBUS_V2 + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS_V2);} WordConstExpr /* 04: SlaveAddress */ OptionalSlaveMode /* 05: SlaveMode */ ',' DWordConstExpr /* 07: ConnectionSpeed */ @@ -358,14 +386,16 @@ I2cSerialBusTermV2 OptionalNameString /* 13: DescriptorName */ OptionalShareType /* 14: Share */ OptionalBuffer_Last /* 15: VendorData */ - ')' {$$ = TrLinkChildren ($3,10, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,10, $4,$5,$7,$8,$10,$11,$12,$13,$14,$15);} - | PARSEOP_I2C_SERIALBUS_V2 '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_I2C_SERIALBUS_V2 + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; InterruptTerm - : PARSEOP_INTERRUPT '(' {$$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} + : PARSEOP_INTERRUPT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} OptionalResourceType_First ',' InterruptTypeKeyword ',' InterruptLevel @@ -373,86 +403,100 @@ InterruptTerm OptionalByteConstExpr OptionalStringData OptionalNameString_Last - ')' '{' + PARSEOP_CLOSE_PAREN '{' DWordList '}' {$$ = TrLinkChildren ($3,8, $4,$6,$8,$9,$10,$11,$12,$15);} - | PARSEOP_INTERRUPT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_INTERRUPT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IOTerm - : PARSEOP_IO '(' {$$ = TrCreateLeafNode (PARSEOP_IO);} + : PARSEOP_IO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_IO);} IODecodeKeyword ',' WordConstExpr ',' WordConstExpr ',' ByteConstExpr ',' ByteConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_IO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IRQNoFlagsTerm - : PARSEOP_IRQNOFLAGS '(' {$$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} + : PARSEOP_IRQNOFLAGS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} OptionalNameString_First - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_IRQNOFLAGS '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_IRQNOFLAGS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; IRQTerm - : PARSEOP_IRQ '(' {$$ = TrCreateLeafNode (PARSEOP_IRQ);} + : PARSEOP_IRQ + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_IRQ);} InterruptTypeKeyword ',' InterruptLevel OptionalShareType OptionalNameString_Last - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$7,$8,$11);} - | PARSEOP_IRQ '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_IRQ + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; Memory24Term - : PARSEOP_MEMORY24 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);} + : PARSEOP_MEMORY24 + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);} OptionalReadWriteKeyword ',' WordConstExpr ',' WordConstExpr ',' WordConstExpr ',' WordConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY24 '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY24 + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; Memory32FixedTerm - : PARSEOP_MEMORY32FIXED '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} + : PARSEOP_MEMORY32FIXED + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} OptionalReadWriteKeyword ',' DWordConstExpr ',' DWordConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,4,$4,$6,$8,$9);} - | PARSEOP_MEMORY32FIXED '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,4,$4,$6,$8,$9);} + | PARSEOP_MEMORY32FIXED + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; Memory32Term - : PARSEOP_MEMORY32 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);} + : PARSEOP_MEMORY32 + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);} OptionalReadWriteKeyword ',' DWordConstExpr ',' DWordConstExpr ',' DWordConstExpr ',' DWordConstExpr OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY32 '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY32 + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; QWordIOTerm - : PARSEOP_QWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDIO);} + : PARSEOP_QWORDIO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_QWORDIO);} OptionalResourceType_First OptionalMinType OptionalMaxType @@ -468,14 +512,16 @@ QWordIOTerm OptionalNameString OptionalType OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_QWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_QWORDIO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; QWordMemoryTerm - : PARSEOP_QWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} + : PARSEOP_QWORDMEMORY + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} OptionalResourceType_First OptionalDecodeType OptionalMinType @@ -492,14 +538,16 @@ QWordMemoryTerm OptionalNameString OptionalAddressRange OptionalType_Last - ')' {$$ = TrLinkChildren ($3,16, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,16, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_QWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_QWORDMEMORY + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; QWordSpaceTerm - : PARSEOP_QWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} + : PARSEOP_QWORDSPACE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} OptionalResourceType OptionalDecodeType @@ -514,27 +562,31 @@ QWordSpaceTerm OptionalByteConstExpr OptionalStringData OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_QWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_QWORDSPACE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; RegisterTerm - : PARSEOP_REGISTER '(' {$$ = TrCreateLeafNode (PARSEOP_REGISTER);} + : PARSEOP_REGISTER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_REGISTER);} AddressSpaceKeyword ',' ByteConstExpr ',' ByteConstExpr ',' QWordConstExpr OptionalAccessSize OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$11,$12);} - | PARSEOP_REGISTER '(' - error ')' {$$ = AslDoError(); yyclearin;} + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$11,$12);} + | PARSEOP_REGISTER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SpiSerialBusTerm - : PARSEOP_SPI_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} + : PARSEOP_SPI_SERIALBUS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} WordConstExpr /* 04: DeviceSelection */ OptionalDevicePolarity /* 05: DevicePolarity */ OptionalWireMode /* 06: WireMode */ @@ -548,15 +600,17 @@ SpiSerialBusTerm OptionalResourceType /* 19: ResourceType */ OptionalNameString /* 20: DescriptorName */ OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} - | PARSEOP_SPI_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_SPI_SERIALBUS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; SpiSerialBusTermV2 - : PARSEOP_SPI_SERIALBUS_V2 '(' {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS_V2);} + : PARSEOP_SPI_SERIALBUS_V2 + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS_V2);} WordConstExpr /* 04: DeviceSelection */ OptionalDevicePolarity /* 05: DevicePolarity */ OptionalWireMode /* 06: WireMode */ @@ -571,32 +625,38 @@ SpiSerialBusTermV2 OptionalNameString /* 20: DescriptorName */ OptionalShareType /* 21: Share */ OptionalBuffer_Last /* 22: VendorData */ - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21,$22);} - | PARSEOP_SPI_SERIALBUS_V2 '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_SPI_SERIALBUS_V2 + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; StartDependentFnNoPriTerm - : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} - ')' '{' + : PARSEOP_STARTDEPENDENTFN_NOPRI + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} + PARSEOP_CLOSE_PAREN '{' ResourceMacroList '}' {$$ = TrLinkChildren ($3,1,$6);} - | PARSEOP_STARTDEPENDENTFN_NOPRI '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_STARTDEPENDENTFN_NOPRI + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; StartDependentFnTerm - : PARSEOP_STARTDEPENDENTFN '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} + : PARSEOP_STARTDEPENDENTFN + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} ByteConstExpr ',' ByteConstExpr - ')' '{' + PARSEOP_CLOSE_PAREN '{' ResourceMacroList '}' {$$ = TrLinkChildren ($3,3,$4,$6,$9);} - | PARSEOP_STARTDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_STARTDEPENDENTFN + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; UartSerialBusTerm - : PARSEOP_UART_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} + : PARSEOP_UART_SERIALBUS + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} DWordConstExpr /* 04: ConnectionSpeed */ OptionalBitsPerByte /* 05: BitsPerByte */ OptionalStopBits /* 06: StopBits */ @@ -611,15 +671,17 @@ UartSerialBusTerm OptionalResourceType /* 19: ResourceType */ OptionalNameString /* 20: DescriptorName */ OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} - | PARSEOP_UART_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_UART_SERIALBUS + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; UartSerialBusTermV2 - : PARSEOP_UART_SERIALBUS_V2 '(' {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS_V2);} + : PARSEOP_UART_SERIALBUS_V2 + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS_V2);} DWordConstExpr /* 04: ConnectionSpeed */ OptionalBitsPerByte /* 05: BitsPerByte */ OptionalStopBits /* 06: StopBits */ @@ -635,32 +697,38 @@ UartSerialBusTermV2 OptionalNameString /* 20: DescriptorName */ OptionalShareType /* 21: Share */ OptionalBuffer_Last /* 22: VendorData */ - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21,$22);} - | PARSEOP_UART_SERIALBUS_V2 '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_UART_SERIALBUS_V2 + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; VendorLongTerm - : PARSEOP_VENDORLONG '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} + : PARSEOP_VENDORLONG + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} OptionalNameString_First - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_VENDORLONG '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_VENDORLONG + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; VendorShortTerm - : PARSEOP_VENDORSHORT '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} + : PARSEOP_VENDORSHORT + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} OptionalNameString_First - ')' '{' + PARSEOP_CLOSE_PAREN '{' ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_VENDORSHORT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_VENDORSHORT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; WordBusNumberTerm - : PARSEOP_WORDBUSNUMBER '(' {$$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} + : PARSEOP_WORDBUSNUMBER + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} OptionalResourceType_First OptionalMinType OptionalMaxType @@ -673,14 +741,16 @@ WordBusNumberTerm OptionalByteConstExpr OptionalStringData OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,12, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,12, $4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} - | PARSEOP_WORDBUSNUMBER '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_WORDBUSNUMBER + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; WordIOTerm - : PARSEOP_WORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_WORDIO);} + : PARSEOP_WORDIO + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WORDIO);} OptionalResourceType_First OptionalMinType OptionalMaxType @@ -696,14 +766,16 @@ WordIOTerm OptionalNameString OptionalType OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,15, $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_WORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_WORDIO + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; WordSpaceTerm - : PARSEOP_WORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} + : PARSEOP_WORDSPACE + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} OptionalResourceType OptionalDecodeType @@ -718,8 +790,9 @@ WordSpaceTerm OptionalByteConstExpr OptionalStringData OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14, + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildren ($3,14, $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_WORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_WORDSPACE + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; diff --git a/source/compiler/aslrestype2.c b/source/compiler/aslrestype2.c index b75c1184eb1..bc130e530be 100644 --- a/source/compiler/aslrestype2.c +++ b/source/compiler/aslrestype2.c @@ -127,6 +127,11 @@ RsDoGeneralRegisterDescriptor ( RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE, CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); + if (Descriptor->GenericReg.AddressSpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) + { + break; + } + if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD) { AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE, diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index 2cb972f8056..112f041878b 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -81,14 +81,15 @@ AslCode * The ObjectList term is obsolete and has been removed. */ DefinitionBlockTerm - : PARSEOP_DEFINITION_BLOCK '(' {$$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);} + : PARSEOP_DEFINITION_BLOCK + PARSEOP_OPEN_PAREN {$$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);} String ',' String ',' ByteConst ',' String ',' String ',' DWordConst - ')' {TrSetEndLineNumber ($3);} + PARSEOP_CLOSE_PAREN {TrSetEndLineNumber ($3);} '{' TermList '}' {$$ = TrLinkChildren ($3,7, $4,$6,$8,$10,$12,$14,$18);} ; @@ -99,6 +100,9 @@ DefinitionBlockList DefinitionBlockList {$$ = TrLinkPeerNodes (2, $1,$2);} ; + +/******* Basic ASCII identifiers **************************************************/ + /* Allow IO, DMA, IRQ Resource macro and FOR macro names to also be used as identifiers */ NameString @@ -112,20 +116,31 @@ NameString /* NameSeg : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) - TrNormalizeNameSeg ($1));} + TrNormalizeNameSeg ($1));} ; */ NameSeg : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (ACPI_NATIVE_INT) AslCompilerlval.s);} + (ACPI_NATIVE_INT) AslCompilerlval.s);} ; +/******* Fundamental argument/statement types ***********************************/ + +Term + : Object {} + | Type1Opcode {} + | Type2Opcode {} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type2BufferOpcode {} + | Type2BufferOrStringOpcode {} + | error {$$ = AslDoError(); yyclearin;} + ; + SuperName - : NameString {} - | ArgTerm {} - | LocalTerm {} + : SimpleName {} | DebugTerm {} | Type6Opcode {} ; @@ -136,14 +151,19 @@ Target | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} ; +RequiredTarget + : ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} + ; + TermArg - : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + : SimpleName {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - - +/* + | PARSEOP_OPEN_PAREN + TermArg + PARSEOP_CLOSE_PAREN {} +*/ ; /* @@ -156,8 +176,10 @@ TermArg */ MethodInvocationTerm - : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} - ArgList ')' {$$ = TrLinkChildNode ($1,$4);} + : NameString + PARSEOP_OPEN_PAREN {TrUpdateNode (PARSEOP_METHODCALL, $1);} + ArgList + PARSEOP_CLOSE_PAREN {$$ = TrLinkChildNode ($1,$4);} ; /* OptionalCount must appear before ByteList or an incorrect reduction will result */ @@ -176,23 +198,44 @@ OptionalDataCount /* Legacy ASL */ : {$$ = NULL;} - | '(' TermArg ')' {$$ = $2;} - | '(' ')' {$$ = NULL;} + | PARSEOP_OPEN_PAREN + TermArg + PARSEOP_CLOSE_PAREN {$$ = $2;} + | PARSEOP_OPEN_PAREN + PARSEOP_CLOSE_PAREN {$$ = NULL;} /* C-style (ASL+) -- adds equals term */ | PARSEOP_EXP_EQUALS {$$ = NULL;} - | '(' TermArg ')' + | PARSEOP_OPEN_PAREN + TermArg + PARSEOP_CLOSE_PAREN PARSEOP_EXP_EQUALS {$$ = $2;} - | '(' ')' String + | PARSEOP_OPEN_PAREN + PARSEOP_CLOSE_PAREN + String PARSEOP_EXP_EQUALS {$$ = NULL;} ; /******* List Terms **************************************************/ + /* ACPI 3.0 -- allow semicolons between terms */ + +TermList + : {$$ = NULL;} + | TermList Term {$$ = TrLinkPeerNode ( + TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} + | TermList Term ';' {$$ = TrLinkPeerNode ( + TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} + | TermList ';' Term {$$ = TrLinkPeerNode ( + TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} + | TermList ';' Term ';' {$$ = TrLinkPeerNode ( + TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} + ; + ArgList : {$$ = NULL;} | TermArg @@ -299,38 +342,13 @@ OptionalParameterTypesPackage TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} ; - /* ACPI 3.0 -- allow semicolons between terms */ - -TermList - : {$$ = NULL;} - | TermList Term {$$ = TrLinkPeerNode ( - TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} - | TermList Term ';' {$$ = TrLinkPeerNode ( - TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} - | TermList ';' Term {$$ = TrLinkPeerNode ( - TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} - | TermList ';' Term ';' {$$ = TrLinkPeerNode ( - TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} - ; - -Term - : Object {} - | Type1Opcode {} - | Type2Opcode {} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Type2BufferOpcode {} - | Type2BufferOrStringOpcode {} - | error {$$ = AslDoError(); yyclearin;} - ; - /* * Case-Default list; allow only one Default term and unlimited Case terms */ CaseDefaultTermList : {$$ = NULL;} - | CaseTerm {} - | DefaultTerm {} + | CaseTerm {} + | DefaultTerm {} | CaseDefaultTermList CaseTerm {$$ = TrLinkPeerNode ($1,$2);} | CaseDefaultTermList @@ -520,32 +538,59 @@ NameSpaceModifier | ScopeTerm {} ; -/* For ObjectType: SuperName except for MethodInvocationTerm */ - -ObjectTypeName +SimpleName : NameString {} - | ArgTerm {} | LocalTerm {} + | ArgTerm {} + ; + +/* For ObjectType(), SuperName except for MethodInvocationTerm */ + +ObjectTypeSource + : SimpleName {} | DebugTerm {} | RefOfTerm {} | DerefOfTerm {} | IndexTerm {} | IndexExpTerm {} -/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ ; -RequiredTarget - : ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} +/* For DeRefOf(), SuperName except for DerefOf and Debug */ + +DerefOfSource + : SimpleName {} + | RefOfTerm {} + | DerefOfTerm {} + | IndexTerm {} + | IndexExpTerm {} + | StoreTerm {} + | EqualsTerm {} + | MethodInvocationTerm {} ; -SimpleTarget - : NameString {} - | LocalTerm {} - | ArgTerm {} +/* For RefOf(), SuperName except for RefOf and MethodInvocationTerm */ + +RefOfSource + : SimpleName {} + | DebugTerm {} + | DerefOfTerm {} + | IndexTerm {} + | IndexExpTerm {} ; -/* Opcode types */ +/* For CondRefOf(), SuperName except for RefOf and MethodInvocationTerm */ +CondRefOfSource + : SimpleName {} + | DebugTerm {} + | DerefOfTerm {} + | IndexTerm {} + | IndexExpTerm {} + ; + +/* + * Opcode types, as defined in the ACPI specification + */ Type1Opcode : BreakTerm {} | BreakPointTerm {} diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index b88513ffb52..c472e073968 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -188,8 +188,7 @@ AcpiEvReleaseGlobalLock ( ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) + ACPI_OPERAND_OBJECT *RegionObj) { return (AE_OK); } diff --git a/source/compiler/asltokens.y b/source/compiler/asltokens.y index ff1dd42535c..61213db0b66 100644 --- a/source/compiler/asltokens.y +++ b/source/compiler/asltokens.y @@ -465,6 +465,9 @@ NoEcho(' %left PARSEOP_EXP_INCREMENT PARSEOP_EXP_DECREMENT +%left PARSEOP_OPEN_PAREN + PARSEOP_CLOSE_PAREN + /* Brackets for Index() support */ %left PARSEOP_EXP_INDEX_LEFT diff --git a/source/compiler/asltypes.y b/source/compiler/asltypes.y index 1152a422d79..d463997bf6b 100644 --- a/source/compiler/asltypes.y +++ b/source/compiler/asltypes.y @@ -68,7 +68,7 @@ NoEcho(' %type ParameterTypesPackage %type ParameterTypesPackageList %type RequiredTarget -%type SimpleTarget +%type SimpleName %type StringData %type Target %type Term @@ -252,7 +252,10 @@ NoEcho(' /* Types */ %type SuperName -%type ObjectTypeName +%type ObjectTypeSource +%type DerefOfSource +%type RefOfSource +%type CondRefOfSource %type ArgTerm %type LocalTerm %type DebugTerm diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 357b92d0b38..9fbc582b6ab 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -862,21 +862,10 @@ AnAnalyzeStoreOperator ( case PARSEOP_DEREFOF: case PARSEOP_REFOF: case PARSEOP_INDEX: + case PARSEOP_STORE: return; - case PARSEOP_METHODCALL: - /* - * A target is not allowed to be a method call. - * It is not supported by the ACPICA interpreter, nor is it - * supported by the MS ASL compiler or the MS interpreter. - * Although legal syntax up until ACPI 6.1, support for this - * will be removed for ACPI 6.2 (02/2016) - */ - AslError (ASL_ERROR, ASL_MSG_SYNTAX, - TargetOperandOp, "Illegal method invocation as a target operand"); - return; - default: break; } diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index c1011f82313..7b33e4d2302 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -129,12 +129,9 @@ DtCompileFadt ( DT_SUBTABLE *ParentTable; DT_FIELD **PFieldList = (DT_FIELD **) List; ACPI_TABLE_HEADER *Table; - UINT8 FadtRevision; - UINT32 i; + UINT8 Revision; - /* Minimum table is the FADT version 1 (ACPI 1.0) */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, &Subtable, TRUE); if (ACPI_FAILURE (Status)) @@ -146,41 +143,11 @@ DtCompileFadt ( DtInsertSubtable (ParentTable, Subtable); Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); - FadtRevision = Table->Revision; + Revision = Table->Revision; - /* Revision 0 and 2 are illegal */ - - if ((FadtRevision == 0) || - (FadtRevision == 2)) + if (Revision == 2) { - DtError (ASL_ERROR, 0, NULL, - "Invalid value for FADT revision"); - - return (AE_BAD_VALUE); - } - - /* Revision out of supported range? */ - - if (FadtRevision > ACPI_FADT_MAX_VERSION) - { - DtError (ASL_ERROR, 0, NULL, - "Unknown or unsupported value for FADT revision"); - - return (AE_BAD_VALUE); - } - - /* Compile individual sub-parts of the FADT, per-revision */ - - for (i = 3; i <= ACPI_FADT_MAX_VERSION; i++) - { - if (i > FadtRevision) - { - break; - } - - /* Compile the fields specific to this FADT revision */ - - Status = DtCompileTable (PFieldList, FadtRevisionInfo[i], + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, &Subtable, TRUE); if (ACPI_FAILURE (Status)) { @@ -189,6 +156,41 @@ DtCompileFadt ( DtInsertSubtable (ParentTable, Subtable); } + else if (Revision >= 2) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + if (Revision >= 5) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + if (Revision >= 6) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + } return (AE_OK); } diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index 42920500ba2..7e2b6f90a71 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -439,12 +439,16 @@ AcpiDmIsUnicodeBuffer ( return (FALSE); } - /* For each word, 1st byte must be ascii (1-0x7F), 2nd byte must be zero */ - + /* + * For each word, 1st byte must be printable ascii, and the + * 2nd byte must be zero. This does not allow for escape + * sequences, but it is the most secure way to detect a + * unicode string. + */ for (i = 0; i < (ByteCount - 2); i += 2) { if ((ByteData[i] == 0) || - (ByteData[i] > 0x7F) || + !(isprint (ByteData[i])) || (ByteData[(ACPI_SIZE) i + 1] != 0)) { return (FALSE); @@ -507,12 +511,27 @@ AcpiDmIsStringBuffer ( return (FALSE); } + /* + * Check for a possible standalone resource EndTag, ignore it + * here. However, this sequence is also the string "Y", but + * this seems rare enough to be acceptable. + */ + if ((ByteCount == 2) && (ByteData[0] == 0x79)) + { + return (FALSE); + } + + /* Check all bytes for ASCII */ + for (i = 0; i < (ByteCount - 1); i++) { - /* TBD: allow some escapes (non-ascii chars). + /* + * TBD: allow some escapes (non-ascii chars). * they will be handled in the string output routine */ + /* Not a string if not printable ascii */ + if (!isprint (ByteData[i])) { return (FALSE); diff --git a/source/components/disassembler/dmcstyle.c b/source/components/disassembler/dmcstyle.c index 939168f2425..f5e9560a907 100644 --- a/source/components/disassembler/dmcstyle.c +++ b/source/components/disassembler/dmcstyle.c @@ -73,6 +73,11 @@ AcpiDmIsTargetAnOperand ( ACPI_PARSE_OBJECT *Operand, BOOLEAN TopLevel); +static BOOLEAN +AcpiDmIsOptimizationIgnored ( + ACPI_PARSE_OBJECT *StoreOp, + ACPI_PARSE_OBJECT *StoreArgument); + /******************************************************************************* * @@ -95,12 +100,10 @@ AcpiDmCheckForSymbolicOpcode ( ACPI_OP_WALK_INFO *Info) { char *OperatorSymbol = NULL; - ACPI_PARSE_OBJECT *Child1; - ACPI_PARSE_OBJECT *Child2; + ACPI_PARSE_OBJECT *Argument1; + ACPI_PARSE_OBJECT *Argument2; ACPI_PARSE_OBJECT *Target; - ACPI_PARSE_OBJECT *GrandChild1; - ACPI_PARSE_OBJECT *GrandChild2; - ACPI_PARSE_OBJECT *GrandTarget = NULL; + ACPI_PARSE_OBJECT *Target2; /* Exit immediately if ASL+ not enabled */ @@ -110,25 +113,17 @@ AcpiDmCheckForSymbolicOpcode ( return (FALSE); } - /* Check for a non-ASL+ statement, propagate the flag */ - - if (Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY) - { - Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; - return (FALSE); - } - /* Get the first operand */ - Child1 = AcpiPsGetArg (Op, 0); - if (!Child1) + Argument1 = AcpiPsGetArg (Op, 0); + if (!Argument1) { return (FALSE); } /* Get the second operand */ - Child2 = Child1->Common.Next; + Argument2 = Argument1->Common.Next; /* Setup the operator string for this opcode */ @@ -202,7 +197,7 @@ AcpiDmCheckForSymbolicOpcode ( * LNotEqual, LLessEqual, and LGreaterEqual. There are * no actual AML opcodes for these operators. */ - switch (Child1->Common.AmlOpcode) + switch (Argument1->Common.AmlOpcode) { case AML_LEQUAL_OP: OperatorSymbol = " != "; @@ -224,19 +219,18 @@ AcpiDmCheckForSymbolicOpcode ( return (TRUE); } - Child1->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX; + Argument1->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX; Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX; - Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; /* Save symbol string in the next child (not peer) */ - Child2 = AcpiPsGetArg (Child1, 0); - if (!Child2) + Argument2 = AcpiPsGetArg (Argument1, 0); + if (!Argument2) { return (FALSE); } - Child2->Common.OperatorSymbol = OperatorSymbol; + Argument2->Common.OperatorSymbol = OperatorSymbol; return (TRUE); case AML_INDEX_OP: @@ -246,10 +240,10 @@ AcpiDmCheckForSymbolicOpcode ( * the symbolic operators for Index(). It doesn't make sense to * use Index() with a constant anyway. */ - if ((Child1->Common.AmlOpcode == AML_STRING_OP) || - (Child1->Common.AmlOpcode == AML_BUFFER_OP) || - (Child1->Common.AmlOpcode == AML_PACKAGE_OP) || - (Child1->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + if ((Argument1->Common.AmlOpcode == AML_STRING_OP) || + (Argument1->Common.AmlOpcode == AML_BUFFER_OP) || + (Argument1->Common.AmlOpcode == AML_PACKAGE_OP) || + (Argument1->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { Op->Common.DisasmFlags |= ACPI_PARSEOP_CLOSING_PAREN; return (FALSE); @@ -257,8 +251,8 @@ AcpiDmCheckForSymbolicOpcode ( /* Index operator is [] */ - Child1->Common.OperatorSymbol = " ["; - Child2->Common.OperatorSymbol = "]"; + Argument1->Common.OperatorSymbol = " ["; + Argument2->Common.OperatorSymbol = "]"; break; /* Unary operators */ @@ -280,7 +274,7 @@ AcpiDmCheckForSymbolicOpcode ( return (FALSE); } - if (Child1->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX) + if (Argument1->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX) { return (TRUE); } @@ -291,9 +285,9 @@ AcpiDmCheckForSymbolicOpcode ( * deferring symbol output until after the first operand has been * emitted. */ - if (!Child1->Common.OperatorSymbol) + if (!Argument1->Common.OperatorSymbol) { - Child1->Common.OperatorSymbol = OperatorSymbol; + Argument1->Common.OperatorSymbol = OperatorSymbol; } /* @@ -323,23 +317,58 @@ AcpiDmCheckForSymbolicOpcode ( /* Target is 3rd operand */ - Target = Child2->Common.Next; + Target = Argument2->Common.Next; if (Op->Common.AmlOpcode == AML_DIVIDE_OP) { + Target2 = Target->Common.Next; + /* * Divide has an extra target operand (Remainder). - * If this extra target is specified, it cannot be converted - * to a C-style operator + * Default behavior is to simply ignore ASL+ conversion + * if the remainder target (modulo) is specified. */ - if (AcpiDmIsValidTarget (Target)) + if (!AcpiGbl_DoDisassemblerOptimizations) { - Child1->Common.OperatorSymbol = NULL; - Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; - return (FALSE); - } + if (AcpiDmIsValidTarget (Target)) + { + Argument1->Common.OperatorSymbol = NULL; + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (FALSE); + } - Target->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; - Target = Target->Common.Next; + Target->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + Target = Target2; + } + else + { + /* + * Divide has an extra target operand (Remainder). + * If both targets are specified, it cannot be converted + * to a C-style operator. + */ + if (AcpiDmIsValidTarget (Target) && + AcpiDmIsValidTarget (Target2)) + { + Argument1->Common.OperatorSymbol = NULL; + Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (FALSE); + } + + if (AcpiDmIsValidTarget (Target)) /* Only first Target is valid (remainder) */ + { + /* Convert the Divide to Modulo */ + + Op->Common.AmlOpcode = AML_MOD_OP; + + Argument1->Common.OperatorSymbol = " % "; + Target2->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + } + else /* Only second Target (quotient) is valid */ + { + Target->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + Target = Target2; + } + } } /* Parser should ensure there is at least a placeholder target */ @@ -351,13 +380,6 @@ AcpiDmCheckForSymbolicOpcode ( if (!AcpiDmIsValidTarget (Target)) { - if (Op->Common.Parent->Common.AmlOpcode == AML_STORE_OP) - { - Op->Common.DisasmFlags = 0; - Child1->Common.OperatorSymbol = NULL; - return (FALSE); - } - /* Not a valid target (placeholder only, from parser) */ break; } @@ -390,8 +412,8 @@ AcpiDmCheckForSymbolicOpcode ( * Add (B, A, A) --> A += B * Add (B, C, A) --> A = (B + C) */ - if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) || - (AcpiDmIsTargetAnOperand (Target, Child2, TRUE))) + if ((AcpiDmIsTargetAnOperand (Target, Argument1, TRUE)) || + (AcpiDmIsTargetAnOperand (Target, Argument2, TRUE))) { Target->Common.OperatorSymbol = AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode); @@ -399,7 +421,7 @@ AcpiDmCheckForSymbolicOpcode ( /* Convert operator to compound assignment */ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; - Child1->Common.OperatorSymbol = NULL; + Argument1->Common.OperatorSymbol = NULL; return (TRUE); } break; @@ -419,7 +441,7 @@ AcpiDmCheckForSymbolicOpcode ( * Subtract (A, B, A) --> A -= B * Subtract (B, A, A) --> A = (B - A) */ - if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE))) + if ((AcpiDmIsTargetAnOperand (Target, Argument1, TRUE))) { Target->Common.OperatorSymbol = AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode); @@ -427,7 +449,7 @@ AcpiDmCheckForSymbolicOpcode ( /* Convert operator to compound assignment */ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; - Child1->Common.OperatorSymbol = NULL; + Argument1->Common.OperatorSymbol = NULL; return (TRUE); } break; @@ -481,7 +503,7 @@ AcpiDmCheckForSymbolicOpcode ( /* Target is optional, 3rd operand */ - Target = Child2->Common.Next; + Target = Argument2->Common.Next; if (AcpiDmIsValidTarget (Target)) { AcpiDmPromoteTarget (Op, Target); @@ -495,75 +517,23 @@ AcpiDmCheckForSymbolicOpcode ( case AML_STORE_OP: /* - * Target is the 2nd operand. - * We know the target is valid, it is not optional. + * For Store, the Target is the 2nd operand. We know the target + * is valid, because it is not optional. * - * The following block implements "Ignore conversion if a store - * is followed by a math/bit operator that has no target". Used - * only for the ASL test suite. + * Ignore any optimizations/folding if flag is set. + * Used for iASL/disassembler test suite only. */ - if (!AcpiGbl_DoDisassemblerOptimizations) + if (AcpiDmIsOptimizationIgnored (Op, Argument1)) { - switch (Child1->Common.AmlOpcode) - { - /* This operator has two operands and two targets */ - - case AML_DIVIDE_OP: - - GrandChild1 = Child1->Common.Value.Arg; - GrandChild2 = GrandChild1->Common.Next; - GrandTarget = GrandChild2->Common.Next; - - if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget)) - { - Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; - return (FALSE); - } - GrandTarget = GrandTarget->Common.Next; - break; - - case AML_ADD_OP: - case AML_SUBTRACT_OP: - case AML_MULTIPLY_OP: - case AML_MOD_OP: - case AML_SHIFT_LEFT_OP: - case AML_SHIFT_RIGHT_OP: - case AML_BIT_AND_OP: - case AML_BIT_OR_OP: - case AML_BIT_XOR_OP: - case AML_INDEX_OP: - - /* These operators have two operands and a target */ - - GrandChild1 = Child1->Common.Value.Arg; - GrandChild2 = GrandChild1->Common.Next; - GrandTarget = GrandChild2->Common.Next; - break; - - case AML_BIT_NOT_OP: - - /* This operator has one operand and a target */ - - GrandChild1 = Child1->Common.Value.Arg; - GrandTarget = GrandChild1->Common.Next; - break; - - default: - break; - } - - if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget)) - { - Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; - return (FALSE); - } + return (FALSE); } /* + * Perform conversion. * In the parse tree, simply swap the target with the * source so that the target is processed first. */ - Target = Child1->Common.Next; + Target = Argument1->Common.Next; if (!Target) { return (FALSE); @@ -580,7 +550,7 @@ AcpiDmCheckForSymbolicOpcode ( /* Target is optional, 2nd operand */ - Target = Child1->Common.Next; + Target = Argument1->Common.Next; if (!Target) { return (FALSE); @@ -605,19 +575,6 @@ AcpiDmCheckForSymbolicOpcode ( break; } - /* - * Nodes marked with ACPI_PARSEOP_PARAMLIST don't need a parens - * output here. We also need to check the parent to see if this op - * is part of a compound test (!=, >=, <=). - */ - if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) || - ((Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && - (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX))) - { - /* Do Nothing. Paren already generated */ - return (TRUE); - } - /* All other operators, emit an open paren */ AcpiOsPrintf ("("); @@ -625,6 +582,125 @@ AcpiDmCheckForSymbolicOpcode ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmIsOptimizationIgnored + * + * PARAMETERS: StoreOp - Store operator parse object + * StoreArgument - Target associate with the Op + * + * RETURN: TRUE if this Store operator should not be converted/removed. + * + * DESCRIPTION: The following function implements "Do not optimize if a + * store is immediately followed by a math/bit operator that + * has no target". + * + * Function is ignored if DoDisassemblerOptimizations is TRUE. + * This is the default, ignore this function. + * + * Disables these types of optimizations, and simply emits + * legacy ASL code: + * Store (Add (INT1, 4), INT2) --> Add (INT1, 4, INT2) + * --> INT2 = INT1 + 4 + * + * Store (Not (INT1), INT2) --> Not (INT1, INT2) + * --> INT2 = ~INT1 + * + * Used only for the ASL test suite. For the test suite, we + * don't want to perform some optimizations to ensure binary + * compatibility with the generation of the legacy ASL->AML. + * In other words, for all test modules we want exactly: + * (ASL+ -> AML) == (ASL- -> AML) + * + ******************************************************************************/ + +static BOOLEAN +AcpiDmIsOptimizationIgnored ( + ACPI_PARSE_OBJECT *StoreOp, + ACPI_PARSE_OBJECT *StoreArgument) +{ + ACPI_PARSE_OBJECT *Argument1; + ACPI_PARSE_OBJECT *Argument2; + ACPI_PARSE_OBJECT *Target; + + + /* No optimizations/folding for the typical case */ + + if (AcpiGbl_DoDisassemblerOptimizations) + { + return (FALSE); + } + + /* + * Only a small subset of ASL/AML operators can be optimized. + * Can only optimize/fold if there is no target (or targets) + * specified for the operator. And of course, the operator + * is surrrounded by a Store() operator. + */ + switch (StoreArgument->Common.AmlOpcode) + { + case AML_ADD_OP: + case AML_SUBTRACT_OP: + case AML_MULTIPLY_OP: + case AML_MOD_OP: + case AML_SHIFT_LEFT_OP: + case AML_SHIFT_RIGHT_OP: + case AML_BIT_AND_OP: + case AML_BIT_OR_OP: + case AML_BIT_XOR_OP: + case AML_INDEX_OP: + + /* These operators have two arguments and one target */ + + Argument1 = StoreArgument->Common.Value.Arg; + Argument2 = Argument1->Common.Next; + Target = Argument2->Common.Next; + + if (!AcpiDmIsValidTarget (Target)) + { + StoreOp->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (TRUE); + } + break; + + case AML_DIVIDE_OP: + + /* This operator has two arguments and two targets */ + + Argument1 = StoreArgument->Common.Value.Arg; + Argument2 = Argument1->Common.Next; + Target = Argument2->Common.Next; + + if (!AcpiDmIsValidTarget (Target) || + !AcpiDmIsValidTarget (Target->Common.Next)) + { + StoreOp->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (TRUE); + } + break; + + case AML_BIT_NOT_OP: + + /* This operator has one operand and one target */ + + Argument1 = StoreArgument->Common.Value.Arg; + Target = Argument1->Common.Next; + + if (!AcpiDmIsValidTarget (Target)) + { + StoreOp->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY; + return (TRUE); + } + break; + + default: + break; + } + + return (FALSE); +} + + /******************************************************************************* * * FUNCTION: AcpiDmCloseOperator @@ -643,8 +719,6 @@ void AcpiDmCloseOperator ( ACPI_PARSE_OBJECT *Op) { - BOOLEAN IsCStyleOp = FALSE; - /* Always emit paren if ASL+ disassembly disabled */ @@ -654,8 +728,6 @@ AcpiDmCloseOperator ( return; } - /* Check for a non-ASL+ statement */ - if (Op->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY) { AcpiOsPrintf (")"); @@ -695,8 +767,6 @@ AcpiDmCloseOperator ( { AcpiOsPrintf (")"); } - - IsCStyleOp = TRUE; break; case AML_INDEX_OP: @@ -724,21 +794,7 @@ AcpiDmCloseOperator ( break; } - /* - * Nodes marked with ACPI_PARSEOP_PARAMLIST don't need a parens - * output here. We also need to check the parent to see if this op - * is part of a compound test (!=, >=, <=). - */ - if (IsCStyleOp && - ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) || - ((Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && - (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX)))) - { - return; - } - AcpiOsPrintf (")"); - return; } diff --git a/source/components/disassembler/dmresrc.c b/source/components/disassembler/dmresrc.c index a486f1d8920..ee4a55fcfaa 100644 --- a/source/components/disassembler/dmresrc.c +++ b/source/components/disassembler/dmresrc.c @@ -392,7 +392,8 @@ AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *NextOp; UINT8 *Aml; UINT8 *EndAml; - ACPI_SIZE Length; + UINT32 BufferLength; + UINT32 DeclaredBufferLength; /* This op must be a buffer */ @@ -402,8 +403,10 @@ AcpiDmIsResourceTemplate ( return (AE_TYPE); } - /* Get the ByteData list and length */ - + /* + * Get the declared length of the buffer. + * This is the nn in "Buffer (nn)" + */ NextOp = Op->Common.Value.Arg; if (!NextOp) { @@ -411,6 +414,10 @@ AcpiDmIsResourceTemplate ( return (AE_TYPE); } + DeclaredBufferLength = NextOp->Common.Value.Size; + + /* Get the length of the raw initialization byte list */ + NextOp = NextOp->Common.Next; if (!NextOp) { @@ -418,11 +425,22 @@ AcpiDmIsResourceTemplate ( } Aml = NextOp->Named.Data; - Length = (ACPI_SIZE) NextOp->Common.Value.Integer; + BufferLength = NextOp->Common.Value.Size; + + /* + * Not a template if declared buffer length != actual length of the + * intialization byte list. Because the resource macros will create + * a buffer of the exact required length (buffer length will be equal + * to the actual length). + */ + if (DeclaredBufferLength != BufferLength) + { + return (AE_TYPE); + } /* Walk the byte list, abort on any invalid descriptor type or length */ - Status = AcpiUtWalkAmlResources (WalkState, Aml, Length, + Status = AcpiUtWalkAmlResources (WalkState, Aml, BufferLength, NULL, ACPI_CAST_INDIRECT_PTR (void, &EndAml)); if (ACPI_FAILURE (Status)) { @@ -435,7 +453,7 @@ AcpiDmIsResourceTemplate ( * of a ResourceTemplate, the buffer must not have any extra data after * the EndTag.) */ - if ((Aml + Length - sizeof (AML_RESOURCE_END_TAG)) != EndAml) + if ((Aml + BufferLength - sizeof (AML_RESOURCE_END_TAG)) != EndAml) { return (AE_AML_NO_RESOURCE_END_TAG); } diff --git a/source/components/dispatcher/dsinit.c b/source/components/dispatcher/dsinit.c index 74e974da031..67c8d61c028 100644 --- a/source/components/dispatcher/dsinit.c +++ b/source/components/dispatcher/dsinit.c @@ -46,6 +46,7 @@ #include "acdispat.h" #include "acnamesp.h" #include "actables.h" +#include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") @@ -231,23 +232,16 @@ AcpiDsInitializeObjects ( /* Walk entire namespace from the supplied root */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* * We don't use AcpiWalkNamespace since we do not want to acquire * the namespace reader lock. */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + ACPI_NS_WALK_NO_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) diff --git a/source/components/dispatcher/dsmethod.c b/source/components/dispatcher/dsmethod.c index 4c4ff227012..92bdb2fc80f 100644 --- a/source/components/dispatcher/dsmethod.c +++ b/source/components/dispatcher/dsmethod.c @@ -107,15 +107,12 @@ AcpiDsAutoSerializeMethod ( "Method auto-serialization parse [%4.4s] %p\n", AcpiUtGetNodeName (Node), Node)); - AcpiExEnterInterpreter (); - /* Create/Init a root op for the method parse tree */ Op = AcpiPsAllocOp (AML_METHOD_OP, ObjDesc->Method.AmlStart); if (!Op) { - Status = AE_NO_MEMORY; - goto Unlock; + return_ACPI_STATUS (AE_NO_MEMORY); } AcpiPsSetName (Op, Node->Name.Integer); @@ -127,8 +124,7 @@ AcpiDsAutoSerializeMethod ( if (!WalkState) { AcpiPsFreeOp (Op); - Status = AE_NO_MEMORY; - goto Unlock; + return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiDsInitAmlWalk (WalkState, Op, Node, @@ -147,8 +143,6 @@ AcpiDsAutoSerializeMethod ( Status = AcpiPsParseAml (WalkState); AcpiPsDeleteParseTree (Op); -Unlock: - AcpiExExitInterpreter (); return_ACPI_STATUS (Status); } @@ -783,26 +777,6 @@ AcpiDsTerminateControlMethod ( AcpiDsMethodDataDeleteAll (WalkState); - /* - * If method is serialized, release the mutex and restore the - * current sync level for this thread - */ - if (MethodDesc->Method.Mutex) - { - /* Acquisition Depth handles recursive calls */ - - MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; - if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) - { - WalkState->Thread->CurrentSyncLevel = - MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; - - AcpiOsReleaseMutex ( - MethodDesc->Method.Mutex->Mutex.OsMutex); - MethodDesc->Method.Mutex->Mutex.ThreadId = 0; - } - } - /* * Delete any namespace objects created anywhere within the * namespace by the execution of this method. Unless: @@ -836,6 +810,26 @@ AcpiDsTerminateControlMethod ( ~ACPI_METHOD_MODIFIED_NAMESPACE; } } + + /* + * If method is serialized, release the mutex and restore the + * current sync level for this thread + */ + if (MethodDesc->Method.Mutex) + { + /* Acquisition Depth handles recursive calls */ + + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) + { + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; + + AcpiOsReleaseMutex ( + MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; + } + } } /* Decrement the thread count on the method */ diff --git a/source/components/dispatcher/dsopcode.c b/source/components/dispatcher/dsopcode.c index 1c6b3425709..5cd9107d866 100644 --- a/source/components/dispatcher/dsopcode.c +++ b/source/components/dispatcher/dsopcode.c @@ -90,7 +90,7 @@ AcpiDsInitializeRegion ( /* Namespace is NOT locked */ - Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + Status = AcpiEvInitializeRegion (ObjDesc); return (Status); } diff --git a/source/components/dispatcher/dswload2.c b/source/components/dispatcher/dswload2.c index ae076e2587c..c0e4ad47e89 100644 --- a/source/components/dispatcher/dswload2.c +++ b/source/components/dispatcher/dswload2.c @@ -626,23 +626,8 @@ AcpiDsLoad2EndOp ( } } - AcpiExExitInterpreter (); Status = AcpiEvInitializeRegion ( - AcpiNsGetAttachedObject (Node), FALSE); - AcpiExEnterInterpreter (); - - if (ACPI_FAILURE (Status)) - { - /* - * If AE_NOT_EXIST is returned, it is not fatal - * because many regions get created before a handler - * is installed for said region. - */ - if (AE_NOT_EXIST == Status) - { - Status = AE_OK; - } - } + AcpiNsGetAttachedObject (Node)); break; case AML_NAME_OP: diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c index 51e3ce99aa7..171602a59c2 100644 --- a/source/components/events/evrgnini.c +++ b/source/components/events/evrgnini.c @@ -45,6 +45,7 @@ #include "accommon.h" #include "acevents.h" #include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evrgnini") @@ -537,7 +538,6 @@ AcpiEvDefaultRegionSetup ( * FUNCTION: AcpiEvInitializeRegion * * PARAMETERS: RegionObj - Region we are initializing - * AcpiNsLocked - Is namespace locked? * * RETURN: Status * @@ -555,21 +555,33 @@ AcpiEvDefaultRegionSetup ( * MUTEX: Interpreter should be unlocked, because we may run the _REG * method for this region. * + * NOTE: Possible incompliance: + * There is a behavior conflict in automatic _REG execution: + * 1. When the interpreter is evaluating a method, we can only + * automatically run _REG for the following case: + * Method(_REG, 2) {} + * OperationRegion (OPR1, 0x80, 0x1000010, 0x4) + * 2. When the interpreter is loading a table, we can also + * automatically run _REG for the following case: + * OperationRegion (OPR1, 0x80, 0x1000010, 0x4) + * Method(_REG, 2) {} + * Though this may not be compliant to the de-facto standard, the + * logic is kept in order not to trigger regressions. And keeping + * this logic should be taken care by the caller of this function. + * ******************************************************************************/ ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) + ACPI_OPERAND_OBJECT *RegionObj) { ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_ADR_SPACE_TYPE SpaceId; ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); + ACPI_FUNCTION_TRACE (EvInitializeRegion); if (!RegionObj) @@ -641,33 +653,15 @@ AcpiEvInitializeRegion ( "Found handler %p for region %p in obj %p\n", HandlerObj, RegionObj, ObjDesc)); - Status = AcpiEvAttachRegion (HandlerObj, RegionObj, - AcpiNsLocked); + (void) AcpiEvAttachRegion (HandlerObj, RegionObj, FALSE); /* * Tell all users that this region is usable by * running the _REG method */ - if (AcpiNsLocked) - { - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); - - if (AcpiNsLocked) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - + AcpiExExitInterpreter (); + (void) AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); + AcpiExEnterInterpreter (); return_ACPI_STATUS (AE_OK); } } @@ -677,11 +671,14 @@ AcpiEvInitializeRegion ( Node = Node->Parent; } - /* If we get here, there is no handler for this region */ - + /* + * If we get here, there is no handler for this region. This is not + * fatal because many regions get created before a handler is installed + * for said region. + */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "No handler for RegionType %s(%X) (RegionObj %p)\n", AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS (AE_OK); } diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index c17beab9961..f49b0a9fa9b 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -480,7 +480,7 @@ AcpiExLoadOp ( ACPI_INFO (("Dynamic OEM Table Load:")); AcpiExExitInterpreter (); - Status = AcpiTbInstallAndLoadTable (Table, ACPI_PTR_TO_PHYSADDR (Table), + Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table), ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, &TableIndex); AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) @@ -545,7 +545,6 @@ AcpiExUnloadTable ( ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; UINT32 TableIndex; - ACPI_TABLE_HEADER *Table; ACPI_FUNCTION_TRACE (ExUnloadTable); @@ -586,42 +585,7 @@ AcpiExUnloadTable ( * strict order requirement against it. */ AcpiExExitInterpreter (); - - /* Ensure the table is still loaded */ - - if (!AcpiTbIsTableLoaded (TableIndex)) - { - Status = AE_NOT_EXIST; - goto LockAndExit; - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - Status = AcpiGetTableByIndex (TableIndex, &Table); - if (ACPI_SUCCESS (Status)) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, - AcpiGbl_TableHandlerContext); - } - } - - /* Delete the portion of the namespace owned by this table */ - - Status = AcpiTbDeleteNamespaceByOwner (TableIndex); - if (ACPI_FAILURE (Status)) - { - goto LockAndExit; - } - - (void) AcpiTbReleaseOwnerId (TableIndex); - AcpiTbSetTableLoadedFlag (TableIndex, FALSE); - -LockAndExit: - - /* Re-acquire the interpreter lock */ - + Status = AcpiTbUnloadTable (TableIndex); AcpiExEnterInterpreter (); /* diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c index 5e0f5499aa4..ddbcc46b5b9 100644 --- a/source/components/executer/exconvrt.c +++ b/source/components/executer/exconvrt.c @@ -645,7 +645,6 @@ AcpiExConvertToTargetType ( switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) { case ARGI_SIMPLE_TARGET: - case ARGI_FIXED_TARGET: case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ switch (DestinationType) diff --git a/source/components/executer/exresop.c b/source/components/executer/exresop.c index d4352e297c1..bf1edd42145 100644 --- a/source/components/executer/exresop.c +++ b/source/components/executer/exresop.c @@ -321,7 +321,6 @@ AcpiExResolveOperands ( case ARGI_OBJECT_REF: case ARGI_DEVICE_REF: case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ case ARGI_STORE_TARGET: diff --git a/source/components/namespace/nsload.c b/source/components/namespace/nsload.c index 6e11d6b7062..d7dbf8955fa 100644 --- a/source/components/namespace/nsload.c +++ b/source/components/namespace/nsload.c @@ -154,7 +154,9 @@ Unlock: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Begin Table Object Initialization\n")); + AcpiExEnterInterpreter (); Status = AcpiDsInitializeObjects (TableIndex, Node); + AcpiExExitInterpreter (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); diff --git a/source/components/namespace/nsnames.c b/source/components/namespace/nsnames.c index 95f8c8db970..8af12f19727 100644 --- a/source/components/namespace/nsnames.c +++ b/source/components/namespace/nsnames.c @@ -108,6 +108,58 @@ AcpiNsGetPathnameLength ( } +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToName + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * Buffer - Where the name is returned + * + * RETURN: Status, Buffer is filled with name if status is AE_OK + * + * DESCRIPTION: Build and return a full namespace name + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToName ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + const char *NodeName; + + + ACPI_FUNCTION_TRACE_PTR (NsHandleToName, TargetHandle); + + + Node = AcpiNsValidateHandle (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + NodeName = AcpiUtGetNodeName (Node); + ACPI_MOVE_NAME (Buffer->Pointer, NodeName); + ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%4.4s\n", (char *) Buffer->Pointer)); + return_ACPI_STATUS (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiNsHandleToPathname diff --git a/source/components/namespace/nsxfname.c b/source/components/namespace/nsxfname.c index cfd6937f497..1621ba985da 100644 --- a/source/components/namespace/nsxfname.c +++ b/source/components/namespace/nsxfname.c @@ -176,8 +176,6 @@ AcpiGetName ( ACPI_BUFFER *Buffer) { ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - const char *NodeName; /* Parameter validation */ @@ -193,16 +191,6 @@ AcpiGetName ( return (Status); } - if (NameType == ACPI_FULL_PATHNAME || - NameType == ACPI_FULL_PATHNAME_NO_TRAILING) - { - /* Get the full pathname (From the namespace root) */ - - Status = AcpiNsHandleToPathname (Handle, Buffer, - NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); - return (Status); - } - /* * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node @@ -213,31 +201,21 @@ AcpiGetName ( return (Status); } - Node = AcpiNsValidateHandle (Handle); - if (!Node) + if (NameType == ACPI_FULL_PATHNAME || + NameType == ACPI_FULL_PATHNAME_NO_TRAILING) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, Buffer, + NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); } - - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); - if (ACPI_FAILURE (Status)) + else { - goto UnlockAndExit; + /* Get the single name */ + + Status = AcpiNsHandleToName (Handle, Buffer); } - /* Just copy the ACPI name from the Node and zero terminate it */ - - NodeName = AcpiUtGetNodeName (Node); - ACPI_MOVE_NAME (Buffer->Pointer, NodeName); - ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; - Status = AE_OK; - - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } diff --git a/source/components/parser/psargs.c b/source/components/parser/psargs.c index a4745c3adc1..5cc328612e1 100644 --- a/source/components/parser/psargs.c +++ b/source/components/parser/psargs.c @@ -298,23 +298,12 @@ AcpiPsGetNextNamepath ( PossibleMethodCall && (Node->Type == ACPI_TYPE_METHOD)) { - if (WalkState->Opcode == AML_UNLOAD_OP) - { - /* - * AcpiPsGetNextNamestring has increased the AML pointer, - * so we need to restore the saved AML pointer for method call. - */ - WalkState->ParserState.Aml = Start; - WalkState->ArgCount = 1; - AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); - return_ACPI_STATUS (AE_OK); - } - /* This name is actually a control method invocation */ MethodDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); + "Control Method invocation %4.4s - %p Desc %p Path=%p\n", + Node->Name.Ascii, Node, MethodDesc, Path)); NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start); if (!NameOp) @@ -771,6 +760,10 @@ AcpiPsGetNextArg ( ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Expected argument type ARGP: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + switch (ArgType) { case ARGP_BYTEDATA: @@ -854,11 +847,13 @@ AcpiPsGetNextArg ( } break; - case ARGP_TARGET: - case ARGP_SUPERNAME: case ARGP_SIMPLENAME: case ARGP_NAME_OR_REF: + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** SimpleName/NameOrRef: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + Subop = AcpiPsPeekOpcode (ParserState); if (Subop == 0 || AcpiPsIsLeadingChar (Subop) || @@ -873,28 +868,37 @@ AcpiPsGetNextArg ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* To support SuperName arg of Unload */ + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_NOT_METHOD_CALL); + } + else + { + /* Single complex argument, nothing returned */ - if (WalkState->Opcode == AML_UNLOAD_OP) - { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, - Arg, ACPI_POSSIBLE_METHOD_CALL); + WalkState->ArgCount = 1; + } + break; - /* - * If the SuperName argument is a method call, we have - * already restored the AML pointer, just free this Arg - */ - if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) - { - AcpiPsFreeOp (Arg); - Arg = NULL; - } - } - else + case ARGP_TARGET: + case ARGP_SUPERNAME: + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Target/Supername: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0) + { + /* NULL target (zero). Convert to a NULL namepath */ + + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml); + if (!Arg) { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, - Arg, ACPI_NOT_METHOD_CALL); + return_ACPI_STATUS (AE_NO_MEMORY); } + + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_POSSIBLE_METHOD_CALL); } else { @@ -907,6 +911,11 @@ AcpiPsGetNextArg ( case ARGP_DATAOBJ: case ARGP_TERMARG: + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** TermArg/DataObj: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; diff --git a/source/components/parser/psloop.c b/source/components/parser/psloop.c index e0839fd7d82..5056cd1de7f 100644 --- a/source/components/parser/psloop.c +++ b/source/components/parser/psloop.c @@ -104,6 +104,9 @@ AcpiPsGetArguments ( ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Get arguments for opcode [%s]\n", Op->Common.AmlOpName)); + switch (Op->Common.AmlOpcode) { case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ diff --git a/source/components/parser/psobject.c b/source/components/parser/psobject.c index 7edc39e2b7a..d027f6d9892 100644 --- a/source/components/parser/psobject.c +++ b/source/components/parser/psobject.c @@ -373,7 +373,13 @@ AcpiPsCreateOp ( Op->Common.Flags |= ACPI_PARSEOP_TARGET; } } - else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + + /* + * Special case for both Increment() and Decrement(), where + * the lone argument is both a source and a target. + */ + else if ((ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) || + (ParentScope->Common.AmlOpcode == AML_DECREMENT_OP)) { Op->Common.Flags |= ACPI_PARSEOP_TARGET; } diff --git a/source/components/parser/pstree.c b/source/components/parser/pstree.c index 729856982b6..0d6ab6373b6 100644 --- a/source/components/parser/pstree.c +++ b/source/components/parser/pstree.c @@ -142,12 +142,12 @@ AcpiPsAppendArg ( const ACPI_OPCODE_INFO *OpInfo; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE ("PsAppendArg"); if (!Op) { - return; + return_VOID; } /* Get the info structure for this opcode */ @@ -159,7 +159,7 @@ AcpiPsAppendArg ( ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X", Op->Common.AmlOpcode)); - return; + return_VOID; } /* Check if this opcode requires argument sub-objects */ @@ -168,7 +168,7 @@ AcpiPsAppendArg ( { /* Has no linked argument objects */ - return; + return_VOID; } /* Append the argument to the linked argument list */ @@ -200,6 +200,8 @@ AcpiPsAppendArg ( Op->Common.ArgListLength++; } + + return_VOID; } diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c index 81b3abcfdd7..95b5b2672cd 100644 --- a/source/components/tables/tbdata.c +++ b/source/components/tables/tbdata.c @@ -937,9 +937,9 @@ AcpiTbLoadTable ( * * FUNCTION: AcpiTbInstallAndLoadTable * - * PARAMETERS: Table - Pointer to the table - * Address - Physical address of the table + * PARAMETERS: Address - Physical address of the table * Flags - Allocation flags of the table + * Override - Whether override should be performed * TableIndex - Where table index is returned * * RETURN: Status @@ -950,7 +950,6 @@ AcpiTbLoadTable ( ACPI_STATUS AcpiTbInstallAndLoadTable ( - ACPI_TABLE_HEADER *Table, ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, BOOLEAN Override, @@ -958,10 +957,9 @@ AcpiTbInstallAndLoadTable ( { ACPI_STATUS Status; UINT32 i; - ACPI_OWNER_ID OwnerId; - ACPI_FUNCTION_TRACE (AcpiLoadTable); + ACPI_FUNCTION_TRACE (TbInstallAndLoadTable); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); @@ -975,44 +973,8 @@ AcpiTbInstallAndLoadTable ( goto UnlockAndExit; } - /* - * Note: Now table is "INSTALLED", it must be validated before - * using. - */ - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - Status = AcpiNsLoadTable (i, AcpiGbl_RootNode); - - /* Execute any module-level code that was found in the table */ - - if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) - { - AcpiNsExecModuleCodeList (); - } - - /* - * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is - * responsible for discovering any new wake GPEs by running _PRW methods - * that may have been loaded by this table. - */ - Status = AcpiTbGetOwnerId (i, &OwnerId); - if (ACPI_SUCCESS (Status)) - { - AcpiEvUpdateGpes (OwnerId); - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); - } + Status = AcpiTbLoadTable (i, AcpiGbl_RootNode); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); UnlockAndExit: @@ -1020,3 +982,59 @@ UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiTbUnloadTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbUnloadTable ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE (TbUnloadTable); + + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, + AcpiGbl_TableHandlerContext); + } + } + + /* Delete the portion of the namespace owned by this table */ + + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + return_ACPI_STATUS (Status); +} diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index b75b52d9d0b..1d327dc3113 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -341,6 +341,8 @@ AcpiTbParseFadt ( { UINT32 Length; ACPI_TABLE_HEADER *Table; + ACPI_TABLE_DESC *FadtDesc; + ACPI_STATUS Status; /* @@ -350,14 +352,13 @@ AcpiTbParseFadt ( * Get a local copy of the FADT and convert it to a common format * Map entire FADT, assumed to be smaller than one page. */ - Length = AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Length; - - Table = AcpiOsMapMemory ( - AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Address, Length); - if (!Table) + FadtDesc = &AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex]; + Status = AcpiTbGetTable (FadtDesc, &Table); + if (ACPI_FAILURE (Status)) { return; } + Length = FadtDesc->Length; /* * Validate the FADT checksum before we copy the table. Ignore @@ -371,7 +372,7 @@ AcpiTbParseFadt ( /* All done with the real FADT, unmap it */ - AcpiOsUnmapMemory (Table, Length); + AcpiTbPutTable (FadtDesc); /* Obtain the DSDT and FACS tables via their addresses within the FADT */ @@ -522,19 +523,17 @@ AcpiTbConvertFadt ( /* - * For ACPI 1.0 FADTs (revision 1), ensure that reserved fields which + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which * should be zero are indeed zero. This will workaround BIOSs that * inadvertently place values in these fields. * * The ACPI 1.0 reserved fields that will be zeroed are the bytes located * at offset 45, 55, 95, and the word located at offset 109, 110. * - * Note: The FADT revision value is unreliable because of BIOS errors. - * The table length is instead used as the final word on the version. - * - * Note: FADT revision 3 is the ACPI 2.0 version of the FADT. + * Note: The FADT revision value is unreliable. Only the length can be + * trusted. */ - if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V3_SIZE) + if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE) { AcpiGbl_FADT.PreferredProfile = 0; AcpiGbl_FADT.PstateControl = 0; diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c index 85b9c3e4c56..6fc30a69fa3 100644 --- a/source/components/tables/tbutils.c +++ b/source/components/tables/tbutils.c @@ -411,3 +411,99 @@ NextTable: AcpiOsUnmapMemory (Table, Length); return_ACPI_STATUS (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTable + * + * PARAMETERS: TableDesc - Table descriptor + * OutTable - Where the pointer to the table is returned + * + * RETURN: Status and pointer to the requested table + * + * DESCRIPTION: Increase a reference to a table descriptor and return the + * validated table pointer. + * If the table descriptor is an entry of the root table list, + * this API must be invoked with ACPI_MTX_TABLES acquired. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **OutTable) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiTbGetTable); + + + if (TableDesc->ValidationCount == 0) + { + /* Table need to be "VALIDATED" */ + + Status = AcpiTbValidateTable (TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + TableDesc->ValidationCount++; + if (TableDesc->ValidationCount == 0) + { + ACPI_ERROR ((AE_INFO, + "Table %p, Validation count is zero after increment\n", + TableDesc)); + TableDesc->ValidationCount--; + return_ACPI_STATUS (AE_LIMIT); + } + + *OutTable = TableDesc->Pointer; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbPutTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: None + * + * DESCRIPTION: Decrease a reference to a table descriptor and release the + * validated table pointer if no references. + * If the table descriptor is an entry of the root table list, + * this API must be invoked with ACPI_MTX_TABLES acquired. + * + ******************************************************************************/ + +void +AcpiTbPutTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + ACPI_FUNCTION_TRACE (AcpiTbPutTable); + + + if (TableDesc->ValidationCount == 0) + { + ACPI_WARNING ((AE_INFO, + "Table %p, Validation count is zero before decrement\n", + TableDesc)); + return_VOID; + } + TableDesc->ValidationCount--; + + if (TableDesc->ValidationCount == 0) + { + /* Table need to be "INVALIDATED" */ + + AcpiTbInvalidateTable (TableDesc); + } + + return_VOID; +} diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c index 4c8c065cf37..9346933cf52 100644 --- a/source/components/tables/tbxface.c +++ b/source/components/tables/tbxface.c @@ -184,6 +184,7 @@ AcpiReallocateRootTable ( void) { ACPI_STATUS Status; + UINT32 i; ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); @@ -198,6 +199,22 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (AE_SUPPORT); } + /* + * Ensure OS early boot logic, which is required by some hosts. If the + * table state is reported to be wrong, developers should fix the + * issue by invoking AcpiPutTable() for the reported table during the + * early stage. + */ + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) + { + if (AcpiGbl_RootTableList.Tables[i].Pointer) + { + ACPI_ERROR ((AE_INFO, + "Table [%4.4s] is not invalidated during early boot stage", + AcpiGbl_RootTableList.Tables[i].Signature.Ascii)); + } + } + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; Status = AcpiTbResizeRootTableList (); @@ -307,6 +324,11 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) * * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the * RSDT/XSDT. + * Note that an early stage AcpiGetTable() call must be paired + * with an early stage AcpiPutTable() call. otherwise the table + * pointer mapped by the early stage mapping implementation may be + * erroneously unmapped by the late stage unmapping implementation + * in an AcpiPutTable() invoked during the late stage. * ******************************************************************************/ @@ -318,7 +340,8 @@ AcpiGetTable ( { UINT32 i; UINT32 j; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_NOT_FOUND; + ACPI_TABLE_DESC *TableDesc; /* Parameter validation */ @@ -328,12 +351,22 @@ AcpiGetTable ( return (AE_BAD_PARAMETER); } + /* + * Note that the following line is required by some OSPMs, they only + * check if the returned table is NULL instead of the returned status + * to determined if this function is succeeded. + */ + *OutTable = NULL; + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + /* Walk the root table list */ for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { - if (!ACPI_COMPARE_NAME ( - &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) + TableDesc = &AcpiGbl_RootTableList.Tables[i]; + + if (!ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) { continue; } @@ -343,27 +376,74 @@ AcpiGetTable ( continue; } - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_SUCCESS (Status)) - { - *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; - } - - return (Status); + Status = AcpiTbGetTable (TableDesc, OutTable); + break; } - return (AE_NOT_FOUND); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (Status); } ACPI_EXPORT_SYMBOL (AcpiGetTable) +/******************************************************************************* + * + * FUNCTION: AcpiPutTable + * + * PARAMETERS: Table - The pointer to the table + * + * RETURN: None + * + * DESCRIPTION: Release a table returned by AcpiGetTable() and its clones. + * Note that it is not safe if this function was invoked after an + * uninstallation happened to the original table descriptor. + * Currently there is no OSPMs' requirement to handle such + * situations. + * + ******************************************************************************/ + +void +AcpiPutTable ( + ACPI_TABLE_HEADER *Table) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + + + ACPI_FUNCTION_TRACE (AcpiPutTable); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Walk the root table list */ + + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) + { + TableDesc = &AcpiGbl_RootTableList.Tables[i]; + + if (TableDesc->Pointer != Table) + { + continue; + } + + AcpiTbPutTable (TableDesc); + break; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_VOID; +} + +ACPI_EXPORT_SYMBOL (AcpiPutTable) + + /******************************************************************************* * * FUNCTION: AcpiGetTableByIndex * * PARAMETERS: TableIndex - Table index - * Table - Where the pointer to the table is returned + * OutTable - Where the pointer to the table is returned * * RETURN: Status and pointer to the requested table * @@ -375,7 +455,7 @@ ACPI_EXPORT_SYMBOL (AcpiGetTable) ACPI_STATUS AcpiGetTableByIndex ( UINT32 TableIndex, - ACPI_TABLE_HEADER **Table) + ACPI_TABLE_HEADER **OutTable) { ACPI_STATUS Status; @@ -385,37 +465,34 @@ AcpiGetTableByIndex ( /* Parameter validation */ - if (!Table) + if (!OutTable) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* + * Note that the following line is required by some OSPMs, they only + * check if the returned table is NULL instead of the returned status + * to determined if this function is succeeded. + */ + *OutTable = NULL; + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); /* Validate index */ if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_BAD_PARAMETER); + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) - { - /* Table is not mapped, map it */ + Status = AcpiTbGetTable ( + &AcpiGbl_RootTableList.Tables[TableIndex], OutTable); - Status = AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[TableIndex]); - if (ACPI_FAILURE (Status)) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); - } - } - - *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; +UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c index 43fe397fde5..30c6534a569 100644 --- a/source/components/tables/tbxfload.c +++ b/source/components/tables/tbxfload.c @@ -372,7 +372,7 @@ AcpiLoadTable ( /* Install the table and load it into the namespace */ ACPI_INFO (("Host-directed Dynamic ACPI Table Load:")); - Status = AcpiTbInstallAndLoadTable (Table, ACPI_PTR_TO_PHYSADDR (Table), + Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table), ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, &TableIndex); return_ACPI_STATUS (Status); } @@ -459,39 +459,8 @@ AcpiUnloadParentTable ( break; } - /* Ensure the table is actually loaded */ - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - if (!AcpiTbIsTableLoaded (i)) - { - Status = AE_NOT_EXIST; - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - break; - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, - AcpiGbl_RootTableList.Tables[i].Pointer, - AcpiGbl_TableHandlerContext); - } - - /* - * Delete all namespace objects owned by this table. Note that - * these objects can appear anywhere in the namespace by virtue - * of the AML "Scope" operator. Thus, we need to track ownership - * by an ID, not simply a position within the hierarchy. - */ - Status = AcpiTbDeleteNamespaceByOwner (i); - if (ACPI_FAILURE (Status)) - { - break; - } - - Status = AcpiTbReleaseOwnerId (i); - AcpiTbSetTableLoadedFlag (i, FALSE); + Status = AcpiTbUnloadTable (i); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); break; } diff --git a/source/components/utilities/utdecode.c b/source/components/utilities/utdecode.c index 5c8f2cec805..45adf14c6d9 100644 --- a/source/components/utilities/utdecode.c +++ b/source/components/utilities/utdecode.c @@ -44,6 +44,7 @@ #include "acpi.h" #include "accommon.h" #include "acnamesp.h" +#include "amlcode.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdecode") @@ -604,6 +605,59 @@ AcpiUtGetNotifyName ( return ("Hardware-Specific"); } + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetArgumentTypeName + * + * PARAMETERS: ArgType - an ARGP_* parser argument type + * + * RETURN: Decoded ARGP_* type + * + * DESCRIPTION: Decode an ARGP_* parser type, as defined in the amlcode.h file, + * and used in the acopcode.h file. For example, ARGP_TERMARG. + * Used for debug only. + * + ******************************************************************************/ + +static const char *AcpiGbl_ArgumentType[20] = +{ + /* 00 */ "Unknown ARGP", + /* 01 */ "ByteData", + /* 02 */ "ByteList", + /* 03 */ "CharList", + /* 04 */ "DataObject", + /* 05 */ "DataObjectList", + /* 06 */ "DWordData", + /* 07 */ "FieldList", + /* 08 */ "Name", + /* 09 */ "NameString", + /* 0A */ "ObjectList", + /* 0B */ "PackageLength", + /* 0C */ "SuperName", + /* 0D */ "Target", + /* 0E */ "TermArg", + /* 0F */ "TermList", + /* 10 */ "WordData", + /* 11 */ "QWordData", + /* 12 */ "SimpleName", + /* 13 */ "NameOrRef" +}; + +const char * +AcpiUtGetArgumentTypeName ( + UINT32 ArgType) +{ + + if (ArgType > ARGP_MAX) + { + return ("Unknown ARGP"); + } + + return (AcpiGbl_ArgumentType[ArgType]); +} + #endif diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c index 8efae429777..8c44a1cab8f 100644 --- a/source/components/utilities/utresrc.c +++ b/source/components/utilities/utresrc.c @@ -468,9 +468,11 @@ AcpiUtWalkAmlResources ( ACPI_FUNCTION_TRACE (UtWalkAmlResources); - /* The absolute minimum resource template is one EndTag descriptor */ - - if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) + /* + * The absolute minimum resource template is one EndTag descriptor. + * However, we will treat a lone EndTag as just a simple buffer. + */ + if (AmlLength <= sizeof (AML_RESOURCE_END_TAG)) { return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); } @@ -503,8 +505,8 @@ AcpiUtWalkAmlResources ( if (UserFunction) { - Status = UserFunction ( - Aml, Length, Offset, ResourceIndex, Context); + Status = UserFunction (Aml, Length, Offset, + ResourceIndex, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -531,6 +533,13 @@ AcpiUtWalkAmlResources ( *Context = Aml; } + /* Check if buffer is defined to be longer than the resource length */ + + if (AmlLength > (Offset + Length)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + /* Normal exit */ return_ACPI_STATUS (AE_OK); diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index d60be8fd0b4..719ff859bc3 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -280,8 +280,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt[]; @@ -425,9 +425,6 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2]; -extern ACPI_DMTABLE_INFO *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1]; - - /* * dmtable and ahtable */ diff --git a/source/include/acevents.h b/source/include/acevents.h index 14f2b7925b8..a2ea52042e4 100644 --- a/source/include/acevents.h +++ b/source/include/acevents.h @@ -336,8 +336,7 @@ AcpiEvDefaultRegionSetup ( ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked); + ACPI_OPERAND_OBJECT *RegionObj); /* diff --git a/source/include/acnamesp.h b/source/include/acnamesp.h index 440ff5b940e..09b319cc87c 100644 --- a/source/include/acnamesp.h +++ b/source/include/acnamesp.h @@ -384,6 +384,11 @@ char * AcpiNsNameOfCurrentScope ( ACPI_WALK_STATE *WalkState); +ACPI_STATUS +AcpiNsHandleToName ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer); + ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, diff --git a/source/include/acopcode.h b/source/include/acopcode.h index a278d4a154a..e5c35255ca5 100644 --- a/source/include/acopcode.h +++ b/source/include/acopcode.h @@ -93,7 +93,7 @@ #define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) #define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_NAME_OR_REF,ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SIMPLENAME, ARGP_TARGET) #define ARGP_CONNECTFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONTINUE_OP ARG_NONE #define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) @@ -106,7 +106,7 @@ #define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) #define ARGP_DEBUG_OP ARG_NONE #define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) #define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) #define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) @@ -153,14 +153,14 @@ #define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_NOOP_OP ARG_NONE #define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_OBJECT_TYPE_OP ARGP_LIST1 (ARGP_NAME_OR_REF) +#define ARGP_OBJECT_TYPE_OP ARGP_LIST1 (ARGP_SIMPLENAME) #define ARGP_ONE_OP ARG_NONE #define ARGP_ONES_OP ARG_NONE #define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) #define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) #define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) #define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_NAME_OR_REF) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SIMPLENAME) #define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) #define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) @@ -251,7 +251,7 @@ #define ARGI_FIELD_OP ARGI_INVALID_OPCODE #define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_IF_OP ARGI_INVALID_OPCODE #define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) #define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE @@ -315,12 +315,12 @@ #define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE #define ARGI_TIMER_OP ARG_NONE -#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) #define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) diff --git a/source/include/acpixf.h b/source/include/acpixf.h index b2655e96fd9..f5f86d4fb25 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160930 +#define ACPI_CA_VERSION 0x20161117 #include "acconfig.h" #include "actypes.h" @@ -582,6 +582,11 @@ AcpiGetTable ( UINT32 Instance, ACPI_TABLE_HEADER **OutTable)) +ACPI_EXTERNAL_RETURN_VOID ( +void +AcpiPutTable ( + ACPI_TABLE_HEADER *Table)) + ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetTableByIndex ( diff --git a/source/include/actables.h b/source/include/actables.h index 3325f19e2d1..3269728a7fd 100644 --- a/source/include/actables.h +++ b/source/include/actables.h @@ -185,12 +185,15 @@ AcpiTbLoadTable ( ACPI_STATUS AcpiTbInstallAndLoadTable ( - ACPI_TABLE_HEADER *Table, ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, BOOLEAN Override, UINT32 *TableIndex); +ACPI_STATUS +AcpiTbUnloadTable ( + UINT32 TableIndex); + void AcpiTbTerminate ( void); @@ -253,6 +256,15 @@ ACPI_STATUS AcpiTbParseRootTable ( ACPI_PHYSICAL_ADDRESS RsdpAddress); +ACPI_STATUS +AcpiTbGetTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **OutTable); + +void +AcpiTbPutTable ( + ACPI_TABLE_DESC *TableDesc); + /* * tbxfload diff --git a/source/include/actbl.h b/source/include/actbl.h index b5c76c9c1b0..93e1a51fb0f 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -256,72 +256,62 @@ typedef struct acpi_table_facs typedef struct acpi_table_fadt { - ACPI_TABLE_HEADER Header; /* [V1] Common ACPI table header */ - UINT32 Facs; /* [V1] 32-bit physical address of FACS */ - UINT32 Dsdt; /* [V1] 32-bit physical address of DSDT */ - UINT8 Model; /* [V1] System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ - UINT8 PreferredProfile; /* [V1] Conveys preferred power management profile to OSPM. */ - UINT16 SciInterrupt; /* [V1] System vector of SCI interrupt */ - UINT32 SmiCommand; /* [V1] 32-bit Port address of SMI command port */ - UINT8 AcpiEnable; /* [V1] Value to write to SMI_CMD to enable ACPI */ - UINT8 AcpiDisable; /* [V1] Value to write to SMI_CMD to disable ACPI */ - UINT8 S4BiosRequest; /* [V1] Value to write to SMI_CMD to enter S4BIOS state */ - UINT8 PstateControl; /* [V1] Processor performance state control*/ - UINT32 Pm1aEventBlock; /* [V1] 32-bit port address of Power Mgt 1a Event Reg Blk */ - UINT32 Pm1bEventBlock; /* [V1] 32-bit port address of Power Mgt 1b Event Reg Blk */ - UINT32 Pm1aControlBlock; /* [V1] 32-bit port address of Power Mgt 1a Control Reg Blk */ - UINT32 Pm1bControlBlock; /* [V1] 32-bit port address of Power Mgt 1b Control Reg Blk */ - UINT32 Pm2ControlBlock; /* [V1] 32-bit port address of Power Mgt 2 Control Reg Blk */ - UINT32 PmTimerBlock; /* [V1] 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 Gpe0Block; /* [V1] 32-bit port address of General Purpose Event 0 Reg Blk */ - UINT32 Gpe1Block; /* [V1] 32-bit port address of General Purpose Event 1 Reg Blk */ - UINT8 Pm1EventLength; /* [V1] Byte Length of ports at Pm1xEventBlock */ - UINT8 Pm1ControlLength; /* [V1] Byte Length of ports at Pm1xControlBlock */ - UINT8 Pm2ControlLength; /* [V1] Byte Length of ports at Pm2ControlBlock */ - UINT8 PmTimerLength; /* [V1] Byte Length of ports at PmTimerBlock */ - UINT8 Gpe0BlockLength; /* [V1] Byte Length of ports at Gpe0Block */ - UINT8 Gpe1BlockLength; /* [V1] Byte Length of ports at Gpe1Block */ - UINT8 Gpe1Base; /* [V1] Offset in GPE number space where GPE1 events start */ - UINT8 CstControl; /* [V1] Support for the _CST object and C-States change notification */ - UINT16 C2Latency; /* [V1] Worst case HW latency to enter/exit C2 state */ - UINT16 C3Latency; /* [V1] Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* [V1] Processor memory cache line width, in bytes */ - UINT16 FlushStride; /* [V1] Number of flush strides that need to be read */ - UINT8 DutyOffset; /* [V1] Processor duty cycle index in processor P_CNT reg */ - UINT8 DutyWidth; /* [V1] Processor duty cycle value bit width in P_CNT register */ - UINT8 DayAlarm; /* [V1] Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonthAlarm; /* [V1] Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* [V1] Index to century in RTC CMOS RAM */ - UINT16 BootFlags; /* [V3] IA-PC Boot Architecture Flags (see below for individual flags) */ - UINT8 Reserved; /* [V1] Reserved, must be zero */ - UINT32 Flags; /* [V1] Miscellaneous flag bits (see below for individual flags) */ - /* End of Version 1 FADT fields (ACPI 1.0) */ - - ACPI_GENERIC_ADDRESS ResetRegister; /* [V3] 64-bit address of the Reset register */ - UINT8 ResetValue; /* [V3] Value to write to the ResetRegister port to reset the system */ - UINT16 ArmBootFlags; /* [V5] ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ - UINT8 MinorRevision; /* [V5] FADT Minor Revision (ACPI 5.1) */ - UINT64 XFacs; /* [V3] 64-bit physical address of FACS */ - UINT64 XDsdt; /* [V3] 64-bit physical address of DSDT */ - ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* [V3] 64-bit Extended Power Mgt 1a Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* [V3] 64-bit Extended Power Mgt 1b Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* [V3] 64-bit Extended Power Mgt 1a Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* [V3] 64-bit Extended Power Mgt 1b Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* [V3] 64-bit Extended Power Mgt 2 Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPmTimerBlock; /* [V3] 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe0Block; /* [V3] 64-bit Extended General Purpose Event 0 Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe1Block; /* [V3] 64-bit Extended General Purpose Event 1 Reg Blk address */ - /* End of Version 3 FADT fields (ACPI 2.0) */ - - ACPI_GENERIC_ADDRESS SleepControl; /* [V4] 64-bit Sleep Control register (ACPI 5.0) */ - /* End of Version 4 FADT fields (ACPI 3.0 and ACPI 4.0) (Field was originally reserved in ACPI 3.0) */ - - ACPI_GENERIC_ADDRESS SleepStatus; /* [V5] 64-bit Sleep Status register (ACPI 5.0) */ - /* End of Version 5 FADT fields (ACPI 5.0) */ - - UINT64 HypervisorId; /* [V6] Hypervisor Vendor ID (ACPI 6.0) */ - /* End of Version 6 FADT fields (ACPI 6.0) */ - + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to SMI_CMD to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to SMI_CMD to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI_CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C-States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + ACPI_GENERIC_ADDRESS SleepControl; /* 64-bit Sleep Control register (ACPI 5.0) */ + ACPI_GENERIC_ADDRESS SleepStatus; /* 64-bit Sleep Status register (ACPI 5.0) */ + UINT64 HypervisorId; /* Hypervisor Vendor ID (ACPI 6.0) */ } ACPI_TABLE_FADT; @@ -337,8 +327,8 @@ typedef struct acpi_table_fadt /* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ -#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5] PSCI 0.2+ is implemented */ -#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5] HVC must be used instead of SMC as the PSCI conduit */ +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ /* Masks for FADT flags */ @@ -415,6 +405,7 @@ typedef struct acpi_table_desc ACPI_NAME_UNION Signature; ACPI_OWNER_ID OwnerId; UINT8 Flags; + UINT16 ValidationCount; } ACPI_TABLE_DESC; @@ -445,34 +436,20 @@ typedef struct acpi_table_desc * match the expected length. In other words, the length of the * FADT is the bottom line as to what the version really is. * - * NOTE: There is no officialy released V2 of the FADT. This - * version was used only for prototyping and testing during the - * 32-bit to 64-bit transition. V3 was the first official 64-bit - * version of the FADT. - * - * Update this list of defines when a new version of the FADT is - * added to the ACPI specification. Note that the FADT version is - * only incremented when new fields are appended to the existing - * version. Therefore, the FADT version is competely independent - * from the version of the ACPI specification where it is - * defined. - * - * For reference, the various FADT lengths are as follows: - * FADT V1 size: 0x074 ACPI 1.0 - * FADT V3 size: 0x0F4 ACPI 2.0 - * FADT V4 size: 0x100 ACPI 3.0 and ACPI 4.0 - * FADT V5 size: 0x10C ACPI 5.0 - * FADT V6 size: 0x114 ACPI 6.0 + * For reference, the values below are as follows: + * FADT V1 size: 0x074 + * FADT V2 size: 0x084 + * FADT V3 size: 0x0F4 + * FADT V4 size: 0x0F4 + * FADT V5 size: 0x10C + * FADT V6 size: 0x114 */ -#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) /* ACPI 1.0 */ -#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) /* ACPI 2.0 */ -#define ACPI_FADT_V4_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepStatus)) /* ACPI 3.0 and ACPI 4.0 */ -#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) /* ACPI 5.0 */ -#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) /* ACPI 6.0 */ +#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) +#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) +#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) +#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) -/* Update these when new FADT versions are added */ - -#define ACPI_FADT_MAX_VERSION 6 #define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" #endif /* __ACTBL_H__ */ diff --git a/source/include/acutils.h b/source/include/acutils.h index bdd6f9b55d2..ac135ebb8b1 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -283,6 +283,10 @@ const char * AcpiUtGetEventName ( UINT32 EventId); +const char * +AcpiUtGetArgumentTypeName ( + UINT32 ArgType); + char AcpiUtHexToAsciiChar ( UINT64 Integer, diff --git a/source/include/amlcode.h b/source/include/amlcode.h index a432c2b7de7..640029b4428 100644 --- a/source/include/amlcode.h +++ b/source/include/amlcode.h @@ -243,6 +243,7 @@ #define ARGP_QWORDDATA 0x11 #define ARGP_SIMPLENAME 0x12 /* NameString | LocalTerm | ArgTerm */ #define ARGP_NAME_OR_REF 0x13 /* For ObjectType only */ +#define ARGP_MAX 0x13 /* * Resolved argument types for the AML Interpreter @@ -279,9 +280,24 @@ #define ARGI_DEVICE_REF 0x0D #define ARGI_REFERENCE 0x0E #define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ -#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ -#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ -#define ARGI_STORE_TARGET 0x12 /* Target for store is TARGETREF + package objects */ +#define ARGI_SIMPLE_TARGET 0x10 /* Name, Local, Arg -- no implicit conversion */ +#define ARGI_STORE_TARGET 0x11 /* Target for store is TARGETREF + package objects */ +/* + * #define ARGI_FIXED_TARGET 0x10 Target, no implicit conversion + * + * Removed 10/2016. ARGI_FIXED_TARGET was used for these operators: + * FromBCD + * ToBCD + * ToDecimalString + * ToHexString + * ToInteger + * ToBuffer + * The purpose of this type was to disable "implicit result conversion", + * but this was incorrect per the ACPI spec and other ACPI implementations. + * These operators now have the target operand defined as a normal + * ARGI_TARGETREF. + */ + /* Multiple/complex types */ diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index e21e29d852f..3d99c602ba4 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -414,6 +414,7 @@ AbCompareAmlFiles ( { /* Display header information */ + printf ("Comparing %s to %s\n", File1Path, File2Path); AbPrintHeadersInfo (&Header1, &Header2); } @@ -425,6 +426,12 @@ AbCompareAmlFiles ( /* Do the byte-by-byte compare */ + printf ("Compare offset: %u\n", AbGbl_CompareOffset); + if (AbGbl_CompareOffset) + { + fseek (File2, AbGbl_CompareOffset, SEEK_CUR); + } + Actual1 = fread (&Char1, 1, 1, File1); Actual2 = fread (&Char2, 1, 1, File2); Offset = sizeof (ACPI_TABLE_HEADER); @@ -436,7 +443,7 @@ AbCompareAmlFiles ( printf ("Error - Byte mismatch at offset %8.4X: 0x%2.2X 0x%2.2X\n", Offset, Char1, Char2); Mismatches++; - if (Mismatches > 100) + if ((Mismatches > 100) && (!AbGbl_DisplayAllMiscompares)) { printf ("100 Mismatches: Too many mismatches\n"); goto Exit2; diff --git a/source/tools/acpibin/abmain.c b/source/tools/acpibin/abmain.c index 5334bc002a3..ccc355c56c5 100644 --- a/source/tools/acpibin/abmain.c +++ b/source/tools/acpibin/abmain.c @@ -52,7 +52,7 @@ AbDisplayUsage ( #define AB_UTILITY_NAME "ACPI Binary Table Dump Utility" -#define AB_SUPPORTED_OPTIONS "c:d:h:s:tv" +#define AB_SUPPORTED_OPTIONS "a:c:d:h:o:s:tv" /****************************************************************************** @@ -75,9 +75,11 @@ AbDisplayUsage ( ACPI_USAGE_HEADER ("acpibin [options]"); - ACPI_OPTION ("-c ", "Compare two binary AML files"); + ACPI_OPTION ("-a ", "Compare two binary AML files, dump all mismatches"); + ACPI_OPTION ("-c ", "Compare two binary AML files, dump first 100 mismatches"); ACPI_OPTION ("-d ", "Dump AML binary to text file"); ACPI_OPTION ("-e ", "Extract binary AML table from acpidump file"); + ACPI_OPTION ("-o ", "Start comparison at this offset into second file"); ACPI_OPTION ("-h ", "Display table header for binary AML file"); ACPI_OPTION ("-s ", "Update checksum for binary AML file"); ACPI_OPTION ("-t", "Terse mode"); @@ -120,6 +122,12 @@ main ( while ((j = AcpiGetopt (argc, argv, AB_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { + case 'a': /* Compare Files, display all differences */ + + AbGbl_DisplayAllMiscompares = TRUE; + + /* Fallthrough */ + case 'c': /* Compare Files */ if (argc < 4) @@ -153,6 +161,11 @@ main ( AbDisplayHeader (AcpiGbl_Optarg); return (0); + case 'o': + + AbGbl_CompareOffset = atoi (AcpiGbl_Optarg); + continue; + case 's': /* Compute/update checksum */ if (argc < 3) diff --git a/source/tools/acpibin/acpibin.h b/source/tools/acpibin/acpibin.h index 679f1a5538b..dd5940f8c1f 100644 --- a/source/tools/acpibin/acpibin.h +++ b/source/tools/acpibin/acpibin.h @@ -63,6 +63,8 @@ /* Globals */ EXTERN BOOLEAN INIT_GLOBAL (Gbl_TerseMode, FALSE); +EXTERN BOOLEAN INIT_GLOBAL (AbGbl_DisplayAllMiscompares, FALSE); +EXTERN UINT32 INIT_GLOBAL (AbGbl_CompareOffset, 0); /* Prototypes */ diff --git a/source/tools/acpinames/anstubs.c b/source/tools/acpinames/anstubs.c index 78984ce0115..ab4df3cc77f 100644 --- a/source/tools/acpinames/anstubs.c +++ b/source/tools/acpinames/anstubs.c @@ -112,8 +112,7 @@ AcpiEvInitializeOpRegions ( ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) + ACPI_OPERAND_OBJECT *RegionObj) { return (AE_OK); } diff --git a/source/tools/acpixtract/acpixtract.c b/source/tools/acpixtract/acpixtract.c index 1573ceeff06..01c748cdb7b 100644 --- a/source/tools/acpixtract/acpixtract.c +++ b/source/tools/acpixtract/acpixtract.c @@ -87,7 +87,7 @@ AxExtractTables ( /* Open input in text mode, output is in binary mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); @@ -286,7 +286,7 @@ AxExtractToMultiAmlFile ( /* Open the input file in text mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); @@ -417,7 +417,7 @@ AxListTables ( /* Open input in text mode, output is in binary mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); diff --git a/source/tools/acpixtract/axutils.c b/source/tools/acpixtract/axutils.c index 6af8cdc29a3..68e51daa2dd 100644 --- a/source/tools/acpixtract/axutils.c +++ b/source/tools/acpixtract/axutils.c @@ -100,9 +100,9 @@ AxIsEmptyLine ( Buffer++; } - /* If end-of-line, this line is empty */ + /* Line is empty when a Unix or DOS-style line terminator is found. */ - if (*Buffer == '\n') + if ((*Buffer == '\r') || (*Buffer == '\n')) { return (1); } @@ -262,7 +262,7 @@ AxCountTableInstances ( unsigned int Instances = 0; - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); From 49a8bad7d6fbbbe518e7bd62c904703fb8f29682 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sat, 19 Nov 2016 23:58:50 +0000 Subject: [PATCH 005/115] Modify umount so that it does not do an Unmount RPC for NFSv4 mounts and uses TCP for the Unmount RPC if the mount is over TCP. Without this patch, umount does an Unmount RPC over UDP for all NFS mounts. Suggested by: cperciva Reviewed by: cperciva MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8503 --- sbin/umount/umount.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c index 20b78043de1..e6ece316e82 100644 --- a/sbin/umount/umount.c +++ b/sbin/umount/umount.c @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -323,6 +324,9 @@ umountfs(struct statfs *sfs) CLIENT *clp; char *nfsdirname, *orignfsdirname; char *hostp, *delimp; + char buf[1024]; + struct nfscl_dumpmntopts dumpmntopts; + const char *proto_ptr = NULL; ai = NULL; do_rpc = 0; @@ -361,8 +365,24 @@ umountfs(struct statfs *sfs) * mount from mntfromname that is still mounted. */ if (getmntentry(sfs->f_mntfromname, NULL, NULL, - CHECKUNIQUE) != NULL) + CHECKUNIQUE) != NULL) { do_rpc = 1; + proto_ptr = "udp"; + /* + * Try and find out whether this NFS mount is NFSv4 and + * what protocol is being used. If this fails, the + * default is NFSv2,3 and use UDP for the Unmount RPC. + */ + dumpmntopts.ndmnt_fname = sfs->f_mntonname; + dumpmntopts.ndmnt_buf = buf; + dumpmntopts.ndmnt_blen = sizeof(buf); + if (nfssvc(NFSSVC_DUMPMNTOPTS, &dumpmntopts) >= 0) { + if (strstr(buf, "nfsv4,") != NULL) + do_rpc = 0; + else if (strstr(buf, ",tcp,") != NULL) + proto_ptr = "tcp"; + } + } } if (!namematch(ai)) { @@ -400,7 +420,7 @@ umountfs(struct statfs *sfs) * has been unmounted. */ if (ai != NULL && !(fflag & MNT_FORCE) && do_rpc) { - clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS3, "udp"); + clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS3, proto_ptr); if (clp == NULL) { warnx("%s: %s", hostp, clnt_spcreateerror("MOUNTPROG")); From 0f2bb99d438be582ee5e336e5c417c99a86ddc06 Mon Sep 17 00:00:00 2001 From: Alexander Kabaev Date: Sun, 20 Nov 2016 01:59:22 +0000 Subject: [PATCH 006/115] Use ofw_gpiobus instead of plain gpiobus for CI20 Requesed by: mmel --- sys/mips/ingenic/jz4780_gpio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/mips/ingenic/jz4780_gpio.c b/sys/mips/ingenic/jz4780_gpio.c index aa45e31c3bb..fe1de7ccb91 100644 --- a/sys/mips/ingenic/jz4780_gpio.c +++ b/sys/mips/ingenic/jz4780_gpio.c @@ -786,6 +786,13 @@ jz4780_gpio_intr(void *arg) return (FILTER_HANDLED); } +static phandle_t +jz4780_gpio_bus_get_node(device_t bus, device_t dev) +{ + + return (ofw_bus_get_node(bus)); +} + static device_method_t jz4780_gpio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, jz4780_gpio_probe), @@ -815,6 +822,9 @@ static device_method_t jz4780_gpio_methods[] = { DEVMETHOD(pic_post_ithread, jz4780_gpio_pic_post_ithread), DEVMETHOD(pic_pre_ithread, jz4780_gpio_pic_pre_ithread), + /* ofw_bus interface */ + DEVMETHOD(ofw_bus_get_node, jz4780_gpio_bus_get_node), + DEVMETHOD_END }; From 4026b447908ec41deae2e5c9cdd62eef3072daa4 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Sun, 20 Nov 2016 06:10:12 +0000 Subject: [PATCH 007/115] Fix buildworld for powerpc. vmpage requires struct pmap to exist and contain a pm_stats field. As of r308817, either AIM or BOOKE is required to be set in order to get their respective pmap structs. Rather than expose them both, or try to unify them unnecessarily, add a third option which contains only a pm_stats field, and change the two existing pmap structures to place the common fields at the beginning of the struct. This actually fixes the stats collection by libkvm on AIM hardware, because before it was accessing a possibly different offset, which would cause it to read garbage. Bump __FreeBSD_version to denote this ABI change, so that ports which depend on libkvm can be rebuilt. --- UPDATING | 5 +++++ lib/libmemstat/memstat_uma.c | 3 --- sys/powerpc/include/pmap.h | 20 +++++++++++++++----- tools/tools/umastat/umastat.c | 4 ---- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/UPDATING b/UPDATING index 3240f5f5c56..30e9968351c 100644 --- a/UPDATING +++ b/UPDATING @@ -51,6 +51,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: ****************************** SPECIAL WARNING: ****************************** +20161119: + The layout of the pmap structure has changed for powerpc to put the pmap + statistics at the front for all CPU variations. libkvm(3) and all tools + that link against it need to be recompiled. + 20161030: isl(4) and cyapa(4) drivers now require a new driver, chromebook_platform(4), to work properly on Chromebook-class hardware. diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 8e89585300b..e54f25672d6 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -30,9 +30,6 @@ #include #include -#include -#include - #include #include diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h index c6611233960..dfb33bfd853 100644 --- a/sys/powerpc/include/pmap.h +++ b/sys/powerpc/include/pmap.h @@ -74,6 +74,9 @@ #include #include +struct pmap; +typedef struct pmap *pmap_t; + #if defined(AIM) #if !defined(NPMAPS) @@ -81,8 +84,6 @@ #endif /* !defined(NPMAPS) */ struct slbtnode; -struct pmap; -typedef struct pmap *pmap_t; struct pvo_entry { LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */ @@ -131,6 +132,7 @@ RB_PROTOTYPE(pvo_tree, pvo_entry, pvo_plink, pvo_vaddr_compare); #define PVO_VSID(pvo) ((pvo)->pvo_vpn >> 16) struct pmap { + struct pmap_statistics pm_stats; struct mtx pm_mtx; #ifdef __powerpc64__ @@ -143,7 +145,6 @@ struct pmap { cpuset_t pm_active; struct pmap *pmap_phys; - struct pmap_statistics pm_stats; struct pvo_tree pmap_pvo; }; @@ -182,10 +183,10 @@ void slb_free_user_cache(struct slb **); #elif defined(BOOKE) struct pmap { + struct pmap_statistics pm_stats; /* pmap statistics */ struct mtx pm_mtx; /* pmap mutex */ tlbtid_t pm_tid[MAXCPU]; /* TID to identify this pmap entries in TLB */ cpuset_t pm_active; /* active on cpus */ - struct pmap_statistics pm_stats; /* pmap statistics */ /* Page table directory, array of pointers to page tables. */ pte_t *pm_pdir[PDIR_NENTRIES]; @@ -193,7 +194,6 @@ struct pmap { /* List of allocated ptbl bufs (ptbl kva regions). */ TAILQ_HEAD(, ptbl_buf) pm_ptbl_list; }; -typedef struct pmap *pmap_t; struct pv_entry { pmap_t pv_pmap; @@ -210,6 +210,16 @@ struct md_page { #define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) +#else +/* + * Common pmap members between AIM and BOOKE. + * libkvm needs pm_stats at the same location between both, as it doesn't define + * AIM nor BOOKE, and is expected to work across all. + */ +struct pmap { + struct pmap_statistics pm_stats; /* pmap statistics */ + struct mtx pm_mtx; /* pmap mutex */ +}; #endif /* AIM */ extern struct pmap kernel_pmap_store; diff --git a/tools/tools/umastat/umastat.c b/tools/tools/umastat/umastat.c index 77bc590f420..941351267ff 100644 --- a/tools/tools/umastat/umastat.c +++ b/tools/tools/umastat/umastat.c @@ -28,10 +28,6 @@ #include -#define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ -#include -#include - #include #include From 69f690335bc96742eef6333cc3d74495bd2a8644 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Sun, 20 Nov 2016 06:11:30 +0000 Subject: [PATCH 008/115] Actually bump __FreeBSD_version --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 7586fa97cf6..e057b26a7a7 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200014 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200015 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From 4e0bab8df7e90f467b38570dfe66844b4e2f8299 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 20 Nov 2016 10:01:21 +0000 Subject: [PATCH 009/115] Attempt package build even if dependencies seems to be missing --- tools/tools/sysbuild/sysbuild.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/tools/sysbuild/sysbuild.sh b/tools/tools/sysbuild/sysbuild.sh index a12308802f5..8053ea50ca8 100644 --- a/tools/tools/sysbuild/sysbuild.sh +++ b/tools/tools/sysbuild/sysbuild.sh @@ -273,8 +273,7 @@ ports_build() ( miss=`(cd $p ; make missing ${PORTS_OPTS}) || true` if [ "x${miss}" != "x" ] ; then - log_it "MISSING for $p:" $miss - continue + log_it "NB: MISSING for $p:" $miss fi log_it "build $pn ($p)" From 17055fcda7a839a3dd5ff459e9a54e9e8dc87676 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Sun, 20 Nov 2016 14:00:50 +0000 Subject: [PATCH 010/115] fix unsafe modification of zfs_vnodeops when DIAGNOSTIC is enabled The idea was to avoid a false assertion in zfs_lock, but it was implemented very dangerously and incorrectly. Reported by: pho Tested by: pho MFC after: 1 week --- .../opensolaris/uts/common/fs/zfs/zfs_vnops.c | 15 +++++++++------ .../opensolaris/uts/common/fs/zfs/zfs_znode.c | 7 ------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index d176706f777..c538176ed96 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -5963,6 +5963,10 @@ zfs_vptocnp(struct vop_vptocnp_args *ap) } #ifdef DIAGNOSTIC +#define CHECK_LOR ((flags & LK_NOWAIT) == 0 && vp->v_mount != NULL && \ + (vp->v_iflag & VI_DOOMED) == 0 && vp->v_data != NULL && \ + (zp->z_pflags & ZFS_XATTR) == 0) + static int zfs_lock(ap) struct vop_lock1_args /* { @@ -5979,22 +5983,21 @@ zfs_lock(ap) int err; vp = ap->a_vp; + zp = vp->v_data; flags = ap->a_flags; - if ((flags & LK_INTERLOCK) == 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && - (zp->z_pflags & ZFS_XATTR) == 0) { + if ((flags & LK_INTERLOCK) == 0 && CHECK_LOR) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } err = vop_stdlock(ap); - if ((flags & LK_INTERLOCK) != 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && - (zp->z_pflags & ZFS_XATTR) == 0) { + if ((flags & LK_INTERLOCK) != 0 && CHECK_LOR) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } return (err); } + +#undef CHECK_LOR #endif struct vop_vector zfs_vnodeops; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c index 224e829d711..1ad0d834642 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c @@ -727,14 +727,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, /* * Acquire vnode lock before making it available to the world. */ -#ifdef DIAGNOSTIC - vop_lock1_t *orig_lock = vp->v_op->vop_lock1; - vp->v_op->vop_lock1 = vop_stdlock; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - vp->v_op->vop_lock1 = orig_lock; -#else - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); -#endif VN_LOCK_AREC(vp); if (vp->v_type != VFIFO) VN_LOCK_ASHARE(vp); From dac458e0d6d560fa0ce9943792b94f0db6e44788 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Sun, 20 Nov 2016 18:20:28 +0000 Subject: [PATCH 011/115] Enable the use of spigen on FDT platform MFC after: 2 weeks --- sys/dev/spibus/spigen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/dev/spibus/spigen.c b/sys/dev/spibus/spigen.c index 9012761073b..debcf451c32 100644 --- a/sys/dev/spibus/spigen.c +++ b/sys/dev/spibus/spigen.c @@ -25,6 +25,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_platform.h" + #include #include #include @@ -65,6 +67,17 @@ struct spigen_softc { int sc_debug; }; +#ifdef FDT +static void +spigen_identify(driver_t *driver, device_t parent) +{ + if (device_find_child(parent, "spigen", -1) != NULL) + return; + if (BUS_ADD_CHILD(parent, 0, "spigen", -1) == NULL) + device_printf(parent, "add child failed\n"); +} +#endif + static int spigen_probe(device_t dev) { @@ -387,6 +400,9 @@ static devclass_t spigen_devclass; static device_method_t spigen_methods[] = { /* Device interface */ +#ifdef FDT + DEVMETHOD(device_identify, spigen_identify), +#endif DEVMETHOD(device_probe, spigen_probe), DEVMETHOD(device_attach, spigen_attach), DEVMETHOD(device_detach, spigen_detach), From 481b6d6f3776a9ee559c1855d0c25f39a26ae8b3 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 20 Nov 2016 18:21:05 +0000 Subject: [PATCH 012/115] rc.subr: $(ps -p $$ -o jid=) is always 0, so do not fork ps for it. The JID keyword writes 0 for a process also in the host system or in the same jail. --- etc/rc.subr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.subr b/etc/rc.subr index 7eaa13a9401..57154604028 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -49,7 +49,7 @@ PROTECT="/usr/bin/protect" ID="/usr/bin/id" IDCMD="if [ -x $ID ]; then $ID -un; fi" PS="/bin/ps -ww" -JID=`$PS -p $$ -o jid=` +JID=0 # # functions From 44b5cf6ff450e7094d645c6757c02618b12cae29 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Sun, 20 Nov 2016 18:21:42 +0000 Subject: [PATCH 013/115] Add spigen to the ARMv6 GENERIC kernel --- sys/arm/conf/GENERIC | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/arm/conf/GENERIC b/sys/arm/conf/GENERIC index 93a9b802e82..6ecaf008f4b 100644 --- a/sys/arm/conf/GENERIC +++ b/sys/arm/conf/GENERIC @@ -150,6 +150,7 @@ device aw_cir # SPI device spibus +device spigen device bcm2835_spi device ti_spi From 06ae3ba328fccb90c65f6de0f69f608904ad9596 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sun, 20 Nov 2016 18:38:32 +0000 Subject: [PATCH 014/115] [bytgpio] Fix USB disconnect event after listsing pins on gpioc2 - Do not set input flag when reading value from GPIO pin, it is not required and for gpioc2(S5 bank) setting both input and output flags leads to some kind of electric interference (curren drop?) that causes USB devices to disconnect - Check pad configuration when attaching device and provide IN/OUT capabilities only for pads that are configured as GPIO. Do not let user code to configure or change value of non-GPIO pads. There is no information for NC bank in intel's datasheet so for now function check is ignored for pins in it Reported by: Frank H. MFC after: 3 days --- sys/dev/gpio/bytgpio.c | 283 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 250 insertions(+), 33 deletions(-) diff --git a/sys/dev/gpio/bytgpio.c b/sys/dev/gpio/bytgpio.c index 93a291eb04e..76f29922fe1 100644 --- a/sys/dev/gpio/bytgpio.c +++ b/sys/dev/gpio/bytgpio.c @@ -60,6 +60,16 @@ __FBSDID("$FreeBSD$"); #define BYTGPIO_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) #define BYTGPIO_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED) +struct pinmap_info { + int reg; + int pad_func; +}; + +/* Ignore function check, no info is available at the moment */ +#define PADCONF_FUNC_ANY -1 + +#define GPIO_PIN_MAP(r, f) { .reg = (r), .pad_func = (f) } + struct bytgpio_softc { ACPI_HANDLE sc_handle; device_t sc_dev; @@ -69,44 +79,211 @@ struct bytgpio_softc { struct resource *sc_mem_res; int sc_npins; const char* sc_bank_prefix; - const int *sc_pinpad_map; + const struct pinmap_info *sc_pinpad_map; + /* List of current functions for pads shared by GPIO */ + int *sc_pad_funcs; }; static int bytgpio_probe(device_t dev); static int bytgpio_attach(device_t dev); -#define SCORE_UID 1 -#define SCORE_BANK_PREFIX "GPIO_S0_SC" -const int bytgpio_score_pins[] = { - 85, 89, 93, 96, 99, 102, 98, 101, 34, 37, 36, 38, 39, 35, 40, - 84, 62, 61, 64, 59, 54, 56, 60, 55, 63, 57, 51, 50, 53, 47, - 52, 49, 48, 43, 46, 41, 45, 42, 58, 44, 95, 105, 70, 68, 67, - 66, 69, 71, 65, 72, 86, 90, 88, 92, 103, 77, 79, 83, 78, 81, - 80, 82, 13, 12, 15, 14, 17, 18, 19, 16, 2, 1, 0, 4, 6, 7, 9, - 8, 33, 32, 31, 30, 29, 27, 25, 28, 26, 23, 21, 20, 24, 22, 5, - 3, 10, 11, 106, 87, 91, 104, 97, 100 +#define SCORE_UID 1 +#define SCORE_BANK_PREFIX "GPIO_S0_SC" +const struct pinmap_info bytgpio_score_pins[] = { + GPIO_PIN_MAP(85, 0), + GPIO_PIN_MAP(89, 0), + GPIO_PIN_MAP(93, 0), + GPIO_PIN_MAP(96, 0), + GPIO_PIN_MAP(99, 0), + GPIO_PIN_MAP(102, 0), + GPIO_PIN_MAP(98, 0), + GPIO_PIN_MAP(101, 0), + GPIO_PIN_MAP(34, 0), + GPIO_PIN_MAP(37, 0), + GPIO_PIN_MAP(36, 0), + GPIO_PIN_MAP(38, 0), + GPIO_PIN_MAP(39, 0), + GPIO_PIN_MAP(35, 0), + GPIO_PIN_MAP(40, 0), + GPIO_PIN_MAP(84, 0), + GPIO_PIN_MAP(62, 0), + GPIO_PIN_MAP(61, 0), + GPIO_PIN_MAP(64, 0), + GPIO_PIN_MAP(59, 0), + GPIO_PIN_MAP(54, 0), + GPIO_PIN_MAP(56, 0), + GPIO_PIN_MAP(60, 0), + GPIO_PIN_MAP(55, 0), + GPIO_PIN_MAP(63, 0), + GPIO_PIN_MAP(57, 0), + GPIO_PIN_MAP(51, 0), + GPIO_PIN_MAP(50, 0), + GPIO_PIN_MAP(53, 0), + GPIO_PIN_MAP(47, 0), + GPIO_PIN_MAP(52, 0), + GPIO_PIN_MAP(49, 0), + GPIO_PIN_MAP(48, 0), + GPIO_PIN_MAP(43, 0), + GPIO_PIN_MAP(46, 0), + GPIO_PIN_MAP(41, 0), + GPIO_PIN_MAP(45, 0), + GPIO_PIN_MAP(42, 0), + GPIO_PIN_MAP(58, 0), + GPIO_PIN_MAP(44, 0), + GPIO_PIN_MAP(95, 0), + GPIO_PIN_MAP(105, 0), + GPIO_PIN_MAP(70, 0), + GPIO_PIN_MAP(68, 0), + GPIO_PIN_MAP(67, 0), + GPIO_PIN_MAP(66, 0), + GPIO_PIN_MAP(69, 0), + GPIO_PIN_MAP(71, 0), + GPIO_PIN_MAP(65, 0), + GPIO_PIN_MAP(72, 0), + GPIO_PIN_MAP(86, 0), + GPIO_PIN_MAP(90, 0), + GPIO_PIN_MAP(88, 0), + GPIO_PIN_MAP(92, 0), + GPIO_PIN_MAP(103, 0), + GPIO_PIN_MAP(77, 0), + GPIO_PIN_MAP(79, 0), + GPIO_PIN_MAP(83, 0), + GPIO_PIN_MAP(78, 0), + GPIO_PIN_MAP(81, 0), + GPIO_PIN_MAP(80, 0), + GPIO_PIN_MAP(82, 0), + GPIO_PIN_MAP(13, 0), + GPIO_PIN_MAP(12, 0), + GPIO_PIN_MAP(15, 0), + GPIO_PIN_MAP(14, 0), + GPIO_PIN_MAP(17, 0), + GPIO_PIN_MAP(18, 0), + GPIO_PIN_MAP(19, 0), + GPIO_PIN_MAP(16, 0), + GPIO_PIN_MAP(2, 0), + GPIO_PIN_MAP(1, 0), + GPIO_PIN_MAP(0, 0), + GPIO_PIN_MAP(4, 0), + GPIO_PIN_MAP(6, 0), + GPIO_PIN_MAP(7, 0), + GPIO_PIN_MAP(9, 0), + GPIO_PIN_MAP(8, 0), + GPIO_PIN_MAP(33, 0), + GPIO_PIN_MAP(32, 0), + GPIO_PIN_MAP(31, 0), + GPIO_PIN_MAP(30, 0), + GPIO_PIN_MAP(29, 0), + GPIO_PIN_MAP(27, 0), + GPIO_PIN_MAP(25, 0), + GPIO_PIN_MAP(28, 0), + GPIO_PIN_MAP(26, 0), + GPIO_PIN_MAP(23, 0), + GPIO_PIN_MAP(21, 0), + GPIO_PIN_MAP(20, 0), + GPIO_PIN_MAP(24, 0), + GPIO_PIN_MAP(22, 0), + GPIO_PIN_MAP(5, 1), + GPIO_PIN_MAP(3, 1), + GPIO_PIN_MAP(10, 0), + GPIO_PIN_MAP(11, 0), + GPIO_PIN_MAP(106, 0), + GPIO_PIN_MAP(87, 0), + GPIO_PIN_MAP(91, 0), + GPIO_PIN_MAP(104, 0), + GPIO_PIN_MAP(97, 0), + GPIO_PIN_MAP(100, 0) }; -#define SCORE_PINS nitems(bytgpio_score_pins) -#define NCORE_UID 2 -#define NCORE_BANK_PREFIX "GPIO_S0_NC" -const int bytgpio_ncore_pins[] = { - 19, 18, 17, 20, 21, 22, 24, 25, 23, 16, 14, 15, 12, 26, 27, - 1, 4, 8, 11, 0, 3, 6, 10, 13, 2, 5, 9, 7 +#define SCORE_PINS nitems(bytgpio_score_pins) + +#define NCORE_UID 2 +#define NCORE_BANK_PREFIX "GPIO_S0_NC" +const struct pinmap_info bytgpio_ncore_pins[] = { + GPIO_PIN_MAP(19, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(18, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(17, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(20, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(21, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(22, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(24, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(25, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(23, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(16, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(14, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(15, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(12, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(26, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(27, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(1, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(4, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(8, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(11, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(0, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(3, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(6, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(10, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(13, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(2, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(5, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(9, PADCONF_FUNC_ANY), + GPIO_PIN_MAP(7, PADCONF_FUNC_ANY) }; #define NCORE_PINS nitems(bytgpio_ncore_pins) -#define SUS_UID 3 -#define SUS_BANK_PREFIX "GPIO_S5_" -const int bytgpio_sus_pins[] = { - 29, 33, 30, 31, 32, 34, 36, 35, 38, 37, 18, 7, 11, 20, 17, 1, - 8, 10, 19, 12, 0, 2, 23, 39, 28, 27, 22, 21, 24, 25, 26, 51, - 56, 54, 49, 55, 48, 57, 50, 58, 52, 53, 59, 40 +#define SUS_UID 3 +#define SUS_BANK_PREFIX "GPIO_S5_" +const struct pinmap_info bytgpio_sus_pins[] = { + GPIO_PIN_MAP(29, 0), + GPIO_PIN_MAP(33, 0), + GPIO_PIN_MAP(30, 0), + GPIO_PIN_MAP(31, 0), + GPIO_PIN_MAP(32, 0), + GPIO_PIN_MAP(34, 0), + GPIO_PIN_MAP(36, 0), + GPIO_PIN_MAP(35, 0), + GPIO_PIN_MAP(38, 0), + GPIO_PIN_MAP(37, 0), + GPIO_PIN_MAP(18, 0), + GPIO_PIN_MAP(7, 1), + GPIO_PIN_MAP(11, 1), + GPIO_PIN_MAP(20, 1), + GPIO_PIN_MAP(17, 1), + GPIO_PIN_MAP(1, 1), + GPIO_PIN_MAP(8, 1), + GPIO_PIN_MAP(10, 1), + GPIO_PIN_MAP(19, 1), + GPIO_PIN_MAP(12, 1), + GPIO_PIN_MAP(0, 1), + GPIO_PIN_MAP(2, 1), + GPIO_PIN_MAP(23, 0), + GPIO_PIN_MAP(39, 0), + GPIO_PIN_MAP(28, 0), + GPIO_PIN_MAP(27, 0), + GPIO_PIN_MAP(22, 0), + GPIO_PIN_MAP(21, 0), + GPIO_PIN_MAP(24, 0), + GPIO_PIN_MAP(25, 0), + GPIO_PIN_MAP(26, 0), + GPIO_PIN_MAP(51, 0), + GPIO_PIN_MAP(56, 0), + GPIO_PIN_MAP(54, 0), + GPIO_PIN_MAP(49, 0), + GPIO_PIN_MAP(55, 0), + GPIO_PIN_MAP(48, 0), + GPIO_PIN_MAP(57, 0), + GPIO_PIN_MAP(50, 0), + GPIO_PIN_MAP(58, 0), + GPIO_PIN_MAP(52, 0), + GPIO_PIN_MAP(53, 0), + GPIO_PIN_MAP(59, 0), + GPIO_PIN_MAP(40, 0) }; + #define SUS_PINS nitems(bytgpio_sus_pins) -#define BYGPIO_PIN_REGISTER(sc, pin, reg) ((sc)->sc_pinpad_map[(pin)] * 16 + (reg)) +#define BYGPIO_PIN_REGISTER(sc, pin, r) ((sc)->sc_pinpad_map[(pin)].reg * 16 + (r)) #define BYTGPIO_PCONF0 0x0000 +#define BYTGPIO_PCONF0_FUNC_MASK 7 #define BYTGPIO_PAD_VAL 0x0008 #define BYTGPIO_PAD_VAL_LEVEL (1 << 0) #define BYTGPIO_PAD_VAL_I_OUTPUT_ENABLED (1 << 1) @@ -158,6 +335,19 @@ bytgpio_valid_pin(struct bytgpio_softc *sc, int pin) return (0); } +/* + * Returns true if pad configured to be used as GPIO + */ +static bool +bytgpio_pad_is_gpio(struct bytgpio_softc *sc, int pin) +{ + if ((sc->sc_pinpad_map[pin].pad_func == PADCONF_FUNC_ANY) || + (sc->sc_pad_funcs[pin] == sc->sc_pinpad_map[pin].pad_func)) + return (true); + else + return (false); +} + static int bytgpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) { @@ -167,7 +357,9 @@ bytgpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); - *caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + *caps = 0; + if (bytgpio_pad_is_gpio(sc, pin)) + *caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; return (0); } @@ -182,11 +374,14 @@ bytgpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); + *flags = 0; + if (!bytgpio_pad_is_gpio(sc, pin)) + return (0); + /* Get the current pin state */ BYTGPIO_LOCK(sc); reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); val = bytgpio_read_4(sc, reg); - *flags = 0; if ((val & BYTGPIO_PAD_VAL_I_OUTPUT_ENABLED) == 0) *flags |= GPIO_PIN_OUTPUT; /* @@ -211,7 +406,10 @@ bytgpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); - allowed = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + if (bytgpio_pad_is_gpio(sc, pin)) + allowed = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + else + allowed = 0; /* * Only directtion flag allowed @@ -266,6 +464,9 @@ bytgpio_pin_set(device_t dev, uint32_t pin, unsigned int value) if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); + if (!bytgpio_pad_is_gpio(sc, pin)) + return (EINVAL); + BYTGPIO_LOCK(sc); reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); val = bytgpio_read_4(sc, reg); @@ -288,15 +489,16 @@ bytgpio_pin_get(device_t dev, uint32_t pin, unsigned int *value) sc = device_get_softc(dev); if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); + /* + * Report non-GPIO pads as pin LOW + */ + if (!bytgpio_pad_is_gpio(sc, pin)) { + *value = GPIO_PIN_LOW; + return (0); + } BYTGPIO_LOCK(sc); reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); - /* - * Enable input to read current value - */ - val = bytgpio_read_4(sc, reg); - val = val & ~BYTGPIO_PAD_VAL_I_INPUT_ENABLED; - bytgpio_write_4(sc, reg, val); /* * And read actual value */ @@ -320,6 +522,9 @@ bytgpio_pin_toggle(device_t dev, uint32_t pin) if (bytgpio_valid_pin(sc, pin) != 0) return (EINVAL); + if (!bytgpio_pad_is_gpio(sc, pin)) + return (EINVAL); + /* Toggle the pin */ BYTGPIO_LOCK(sc); reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); @@ -350,6 +555,8 @@ bytgpio_attach(device_t dev) struct bytgpio_softc *sc; ACPI_STATUS status; int uid; + int pin; + uint32_t reg, val; sc = device_get_softc(dev); sc->sc_dev = dev; @@ -378,8 +585,12 @@ bytgpio_attach(device_t dev) break; default: device_printf(dev, "invalid _UID value: %d\n", uid); + goto error; } + sc->sc_pad_funcs = malloc(sizeof(int)*sc->sc_npins, M_DEVBUF, + M_WAITOK | M_ZERO); + sc->sc_mem_rid = 0; sc->sc_mem_res = bus_alloc_resource_any(sc->sc_dev, SYS_RES_MEMORY, &sc->sc_mem_rid, RF_ACTIVE); @@ -390,6 +601,12 @@ bytgpio_attach(device_t dev) BYTGPIO_LOCK_INIT(sc); + for (pin = 0; pin < sc->sc_npins; pin++) { + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PCONF0); + val = bytgpio_read_4(sc, reg); + sc->sc_pad_funcs[pin] = val & BYTGPIO_PCONF0_FUNC_MASK; + } + sc->sc_busdev = gpiobus_attach_bus(dev); if (sc->sc_busdev == NULL) { BYTGPIO_LOCK_DESTROY(sc); From 08036373dcfd3ad34cb9903f4a222c0aa33add4f Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sun, 20 Nov 2016 18:56:04 +0000 Subject: [PATCH 015/115] [FDT] Remove empty wrapper for upstream am335x-evm.dts Remove empty wrapper for sys/gnu version of am335x-evm.dts located in sys/boot/fdt, with current include paths priority it's recursive #include and current build system can find file in sys/gnu when generating dtb Reported by: Jared McNeill --- sys/boot/fdt/dts/arm/am335x-evm.dts | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 sys/boot/fdt/dts/arm/am335x-evm.dts diff --git a/sys/boot/fdt/dts/arm/am335x-evm.dts b/sys/boot/fdt/dts/arm/am335x-evm.dts deleted file mode 100644 index 3e1c4c0caad..00000000000 --- a/sys/boot/fdt/dts/arm/am335x-evm.dts +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * Copyright (c) 2015 Oleksandr Tymoshenko - * 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. - * - * $FreeBSD$ - */ - -#include "am335x-evm.dts" From a7fc4a032bad3dc9939603218fd54979e81bfecb Mon Sep 17 00:00:00 2001 From: Jared McNeill Date: Sun, 20 Nov 2016 19:36:17 +0000 Subject: [PATCH 016/115] Add dtsi for FreeBSD-specific Allwinner H3 nodes. --- sys/boot/fdt/dts/arm/h3.dtsi | 179 +++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 sys/boot/fdt/dts/arm/h3.dtsi diff --git a/sys/boot/fdt/dts/arm/h3.dtsi b/sys/boot/fdt/dts/arm/h3.dtsi new file mode 100644 index 00000000000..9038fc33959 --- /dev/null +++ b/sys/boot/fdt/dts/arm/h3.dtsi @@ -0,0 +1,179 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * $FreeBSD$ + */ + +#include + +/ { + cpus { + cpu0: cpu@0 { + clocks = <&cpu>; + clock-latency = <2000000>; + }; + }; + + clocks { + pll2: clk@01c20008 { + #clock-cells = <1>; + compatible = "allwinner,sun8i-h3-pll2-clk"; + reg = <0x01c20008 0x4>; + clocks = <&osc24M>; + clock-output-names = "pll2-1x", "pll2-2x", + "pll2-4x", "pll2-8x"; + }; + + ths_clk: clk@1c20074 { + #clock-cells = <0>; + compatible = "allwinner,sun8i-h3-ths-clk"; + reg = <0x01c20074 0x4>; + clocks = <&osc24M>; + clock-output-names = "ths"; + }; + + codec_clk: clk@01c20140 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-codec-clk"; + reg = <0x01c20140 0x4>; + clocks = <&pll2 SUN4I_A10_PLL2_1X>; + clock-output-names = "codec"; + }; + }; + + soc { + emac: ethernet@1c30000 { + compatible = "allwinner,sun8i-h3-emac"; + reg = <0x01c30000 0x104>, <0x01c00030 0x4>; + reg-names = "emac", "syscon"; + interrupts = ; + resets = <&ahb_rst 17>; + reset-names = "ahb"; + clocks = <&bus_gates 17>; + clock-names = "ahb"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c0: i2c@1c2ac00 { + compatible = "allwinner,sun6i-a31-i2c"; + reg = <0x01c2ac00 0x400>; + interrupts = ; + clocks = <&bus_gates 96>; + resets = <&apb2_rst 0>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c1: i2c@1c2b000 { + compatible = "allwinner,sun6i-a31-i2c"; + reg = <0x01c2b000 0x400>; + interrupts = ; + clocks = <&bus_gates 97>; + resets = <&apb2_rst 1>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c2: i2c@1c2b400 { + compatible = "allwinner,sun6i-a31-i2c"; + reg = <0x01c2b400 0x400>; + interrupts = ; + clocks = <&bus_gates 98>; + resets = <&apb2_rst 2>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + }; + + r_i2c: i2c@1f02400 { + compatible = "allwinner,sun6i-a31-i2c"; + reg = <0x01f02400 0x400>; + interrupts = ; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + }; + + sid: eeprom@1c14000 { + compatible = "allwinner,sun8i-a83t-sid"; + reg = <0x01c14000 0x400>; + }; + + rtp: rtp@1c25000 { + compatible = "allwinner,sun8i-h3-ts"; + reg = <0x01c25000 0x400>; + interrupts = ; + clocks = <&bus_gates 72>, <&ths_clk>; + clock-names = "ahb", "ths"; + resets = <&apb1_rst 8>; + #thermal-sensor-cells = <0>; + }; + + dma: dma-controller@01c02000 { + compatible = "allwinner,sun8i-h3-dma"; + reg = <0x01c02000 0x1000>; + interrupts = ; + clocks = <&bus_gates 6>; + clock-names = "ahb"; + resets = <&ahb_rst 6>; + reset-names = "ahb"; + #dma-cells = <1>; + }; + + codec: codec@01c22c00 { + compatible = "allwinner,sun8i-h3-codec"; + reg = <0x01c22c00 0x100>, <0x01f015c0 0x4>; + reg-names = "codec", "pr"; + interrupts = ; + clocks = <&bus_gates 64>, <&codec_clk>; + clock-names = "ahb", "codec"; + resets = <&ahb_rst 128>; + reset-names = "ahb"; + dmas = <&dma 15>, <&dma 15>; + dma-names = "rx", "tx"; + status = "disabled"; + }; + + }; +}; + +&pll1 { + compatible = "allwinner,sun8i-h3-pll1-clk"; +}; + +&pio { + emac_pins_rgmii_a: emac_rgmii@0 { + allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", + "PD7", "PD8", "PD9", "PD10", "PD12", "PD13", + "PD15", "PD16", "PD17"; + allwinner,function = "emac"; + allwinner,drive = ; + allwinner,pull = ; + }; +}; From e73fb284af6de70d31718234951752e7c11ddc1c Mon Sep 17 00:00:00 2001 From: Jared McNeill Date: Sun, 20 Nov 2016 19:38:05 +0000 Subject: [PATCH 017/115] Add dts for FriendlyARM NanoPi NEO. --- sys/boot/fdt/dts/arm/nanopi-neo.dts | 73 +++++++++++ sys/boot/fdt/dts/arm/sun8i-h3-nanopi-neo.dts | 128 +++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 sys/boot/fdt/dts/arm/nanopi-neo.dts create mode 100644 sys/boot/fdt/dts/arm/sun8i-h3-nanopi-neo.dts diff --git a/sys/boot/fdt/dts/arm/nanopi-neo.dts b/sys/boot/fdt/dts/arm/nanopi-neo.dts new file mode 100644 index 00000000000..ccd2836ab48 --- /dev/null +++ b/sys/boot/fdt/dts/arm/nanopi-neo.dts @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * $FreeBSD$ + */ + +#include "sun8i-h3-nanopi-neo.dts" +#include "h3.dtsi" + +/ { + vdd_cpu: reg_cpux_vset { + compatible = "regulator-gpio"; + + regulator-name = "cpux-supply"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1300000>; + regulator-boot-on; + + gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* GPIOL6 */ + states = <1300000 0x1 + 1100000 0x0>; + + enable-active-high; + }; +}; + +&r_i2c { + status = "okay"; +}; + +&emac { + phy = <&phy1>; + phy-mode = "mii"; + allwinner,use-internal-phy; + allwinner,leds-active-low; + status = "okay"; + + phy1: ethernet-phy@1 { + reg = <1>; + }; +}; + +&cpu0 { + cpu-supply = <&vdd_cpu>; + operating-points = < + /* kHz uV */ + 1008000 1300000 + 816000 1100000 + 480000 1100000 + >; +}; diff --git a/sys/boot/fdt/dts/arm/sun8i-h3-nanopi-neo.dts b/sys/boot/fdt/dts/arm/sun8i-h3-nanopi-neo.dts new file mode 100644 index 00000000000..7ea454faae8 --- /dev/null +++ b/sys/boot/fdt/dts/arm/sun8i-h3-nanopi-neo.dts @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2016 James Pettigrew + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Or, alternatively, + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * $FreeBSD$ + */ + +/dts-v1/; +#include "sun8i-h3.dtsi" +#include "sunxi-common-regulators.dtsi" + +#include +#include +#include + +/ { + model = "FriendlyARM NanoPi NEO"; + compatible = "friendlyarm,nanopi-neo", "allwinner,sun8i-h3"; + + aliases { + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&leds_opc>, <&leds_r_opc>; + + pwr_led { + label = "nanopi:green:pwr"; + gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + status_led { + label = "nanopi:blue:status"; + gpios = <&pio 0 10 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&ehci3 { + status = "okay"; +}; + +&mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>; + vmmc-supply = <®_vcc3v3>; + bus-width = <4>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ + cd-inverted; + status = "okay"; +}; + +&ohci3 { + status = "okay"; +}; + +&pio { + leds_opc: led_pins@0 { + allwinner,pins = "PA10"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; +}; + +&r_pio { + leds_r_opc: led_pins@0 { + allwinner,pins = "PL10"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; +}; + +&uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins_a>; + status = "okay"; +}; + +&usbphy { + /* USB VBUS is always on */ + status = "okay"; +}; From 5cba9041d01f126c463fa707c0c9699153407a1e Mon Sep 17 00:00:00 2001 From: Jared McNeill Date: Sun, 20 Nov 2016 19:38:46 +0000 Subject: [PATCH 018/115] Add dts for Xunlong Orange Pi Plus 2E. --- sys/boot/fdt/dts/arm/orangepi-plus-2e.dts | 121 ++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 sys/boot/fdt/dts/arm/orangepi-plus-2e.dts diff --git a/sys/boot/fdt/dts/arm/orangepi-plus-2e.dts b/sys/boot/fdt/dts/arm/orangepi-plus-2e.dts new file mode 100644 index 00000000000..24dd844d2a4 --- /dev/null +++ b/sys/boot/fdt/dts/arm/orangepi-plus-2e.dts @@ -0,0 +1,121 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * $FreeBSD$ + */ + +#include "sun8i-h3-orangepi-plus.dts" +#include "h3.dtsi" + +/ { + model = "Xunlong Orange Pi Plus 2E"; + compatible = "xunlong,orangepi-plus-2e", "allwinner,sun8i-h3"; + + reg_gmac_3v3: gmac-3v3 { + compatible = "regulator-fixed"; + pinctrl-names = "default"; + pinctrl-0 = <&emac_phy_reset_pin>; + regulator-name = "gmac-3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + startup-delay-us = <100000>; + enable-active-high; + gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; + }; +}; + +&pio { + emac_phy_reset_pin: emac_phy_reset_pin@0 { + allwinner,pins = "PD6"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; + + codec_pa_pin: codec_pa_pin@0 { + allwinner,pins = "PA16"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; +}; + +&emac { + pinctrl-names = "default"; + pinctrl-0 = <&emac_pins_rgmii_a>; + phy-supply = <®_gmac_3v3>; + phy-mode = "rgmii"; + phy = <&phy1>; + + allwinner,leds-active-low; + status = "okay"; + + phy1: ethernet-phy@1 { + reg = <1>; + }; +}; + +&ehci2 { + status = "okay"; +}; + +&i2c0 { + status = "okay"; +}; + +&r_i2c { + status = "okay"; + + vdd_cpu: regulator@65 { + compatible = "silergy,sy8106a"; + reg = <0x65>; + + regulator-name = "vdd-cpu"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1400000>; + regulator-ramp-delay = <200>; + regulator-boot-on; + regulator-always-on; + }; +}; + +&codec { + pinctrl-names = "default"; + pinctrl-0 = <&codec_pa_pin>; + allwinner,pa-gpios = <&pio 0 16 GPIO_ACTIVE_HIGH>; /* PA16 */ + status = "okay"; +}; + +&cpu0 { + cpu-supply = <&vdd_cpu>; + operating-points = < + /* kHz uV */ + 1296000 1340000 + 1200000 1320000 + 1008000 1200000 + 816000 1100000 + 648000 1040000 + >; +}; From a9332a788e13ae17938cad5c5aae4f43a74290b4 Mon Sep 17 00:00:00 2001 From: Jared McNeill Date: Sun, 20 Nov 2016 19:39:55 +0000 Subject: [PATCH 019/115] Build and install nanopi-neo.dts and orangepi-plus-2e.dts --- sys/modules/dtb/allwinner/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/modules/dtb/allwinner/Makefile b/sys/modules/dtb/allwinner/Makefile index cdf34c8620a..cc2db41d75f 100644 --- a/sys/modules/dtb/allwinner/Makefile +++ b/sys/modules/dtb/allwinner/Makefile @@ -5,8 +5,10 @@ DTS= \ bananapim2.dts \ cubieboard.dts \ cubieboard2.dts \ + nanopi-neo.dts \ olimex-a20-som-evb.dts \ olinuxino-lime.dts \ + orangepi-plus-2e.dts \ pcduino3.dts \ sinovoip-bpi-m3.dts \ sun5i-a13-olinuxino.dts \ From 81f91de9f776f91e2eee6815d452c520f892ced3 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Sun, 20 Nov 2016 20:13:22 +0000 Subject: [PATCH 020/115] Fix error reporting from wcstof() When wcstof() skipped initial space and then parsing failed, it set endptr to the first non-space character. Fix it to correctly report failure by setting endptr to the beginning of the input string. The fix is from theraven@, who fixed this bug in wcstod() and wcstold() in r227753. While I'm here: Move assignments out of declarations in wcstod() and wcstold(). This is against my personal preference, but it is our agreed style(9). Set endptr correctly on malloc() failure in all three functions. Remove an incorrect comment: This is pointer arithmetic, so the code was not actually making that assumption. wcstold() advanced the wcp pointer beyond leading whitespace and then reset it back to the beginning of the string. Do not reset it. This seems to have no functional effect, since strtold_l() also skips leading whitespace. I'm making the change to keep this function consistent with wcstof() and wcstod(), and because the C11 spec prescribes the use of iswspace() to skip leading space. Reported by: libc++ unit test for std::stof(std::wstring) MFC after: 8 days Sponsored by: Dell EMC --- lib/libc/locale/wcstod.c | 13 ++++++++----- lib/libc/locale/wcstof.c | 20 +++++++++++++++----- lib/libc/locale/wcstold.c | 13 ++++++++----- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lib/libc/locale/wcstod.c b/lib/libc/locale/wcstod.c index 8bc46a7c3ad..c6ae1417c1d 100644 --- a/lib/libc/locale/wcstod.c +++ b/lib/libc/locale/wcstod.c @@ -54,11 +54,13 @@ wcstod_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, mbstate_t mbs; double val; char *buf, *end; - const wchar_t *wcp = nptr; + const wchar_t *wcp; size_t len; - size_t spaces = 0; + size_t spaces; FIX_LOCALE(locale); + wcp = nptr; + spaces = 0; while (iswspace_l(*wcp, locale)) { wcp++; spaces++; @@ -80,8 +82,11 @@ wcstod_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, *endptr = (wchar_t *)nptr; return (0.0); } - if ((buf = malloc(len + 1)) == NULL) + if ((buf = malloc(len + 1)) == NULL) { + if (endptr != NULL) + *endptr = (wchar_t *)nptr; return (0.0); + } mbs = initial; wcsrtombs_l(buf, &wcp, len + 1, &mbs, locale); @@ -95,13 +100,11 @@ wcstod_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, * corresponding position in the wide char string. */ if (endptr != NULL) { - /* XXX Assume each wide char is one byte. */ *endptr = (wchar_t *)nptr + (end - buf); if (buf != end) *endptr += spaces; } - free(buf); return (val); diff --git a/lib/libc/locale/wcstof.c b/lib/libc/locale/wcstof.c index 93a5af83818..99ce0fe4af2 100644 --- a/lib/libc/locale/wcstof.c +++ b/lib/libc/locale/wcstof.c @@ -50,27 +50,37 @@ wcstof_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, char *buf, *end; const wchar_t *wcp; size_t len; + size_t spaces; FIX_LOCALE(locale); - while (iswspace_l(*nptr, locale)) - nptr++; - wcp = nptr; + spaces = 0; + while (iswspace_l(*wcp, locale)) { + wcp++; + spaces++; + } + mbs = initial; if ((len = wcsrtombs_l(NULL, &wcp, 0, &mbs, locale)) == (size_t)-1) { if (endptr != NULL) *endptr = (wchar_t *)nptr; return (0.0); } - if ((buf = malloc(len + 1)) == NULL) + if ((buf = malloc(len + 1)) == NULL) { + if (endptr != NULL) + *endptr = (wchar_t *)nptr; return (0.0); + } mbs = initial; wcsrtombs_l(buf, &wcp, len + 1, &mbs, locale); val = strtof_l(buf, &end, locale); - if (endptr != NULL) + if (endptr != NULL) { *endptr = (wchar_t *)nptr + (end - buf); + if (buf != end) + *endptr += spaces; + } free(buf); diff --git a/lib/libc/locale/wcstold.c b/lib/libc/locale/wcstold.c index fcfd48f12d0..89c92d95d4f 100644 --- a/lib/libc/locale/wcstold.c +++ b/lib/libc/locale/wcstold.c @@ -48,32 +48,35 @@ wcstold_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, mbstate_t mbs; long double val; char *buf, *end; - const wchar_t *wcp = nptr; + const wchar_t *wcp; size_t len; - size_t spaces = 0; + size_t spaces; FIX_LOCALE(locale); + wcp = nptr; + spaces = 0; while (iswspace_l(*wcp, locale)) { wcp++; spaces++; } - wcp = nptr; mbs = initial; if ((len = wcsrtombs_l(NULL, &wcp, 0, &mbs, locale)) == (size_t)-1) { if (endptr != NULL) *endptr = (wchar_t *)nptr; return (0.0); } - if ((buf = malloc(len + 1)) == NULL) + if ((buf = malloc(len + 1)) == NULL) { + if (endptr != NULL) + *endptr = (wchar_t *)nptr; return (0.0); + } mbs = initial; wcsrtombs_l(buf, &wcp, len + 1, &mbs, locale); val = strtold_l(buf, &end, locale); if (endptr != NULL) { - /* XXX Assume each wide char is one byte. */ *endptr = (wchar_t *)nptr + (end - buf); if (buf != end) *endptr += spaces; From dc13fee60ccc20b858903030f82f3a1ed1fb1666 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:00:51 +0000 Subject: [PATCH 021/115] hyperv/hn: Implement RNDIS multi-packet message support. Currently, it is only applied to packet sent through chimney sending buffers. Not enabled by default yet. This one gives 20%~30% performance boost for non-TSO usage in both bit/packet rate tests and nginx performance test. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8560 --- sys/dev/hyperv/netvsc/hn_rndis.c | 8 +- sys/dev/hyperv/netvsc/if_hn.c | 584 ++++++++++++++++++++++++++++--- sys/dev/hyperv/netvsc/if_hnvar.h | 25 ++ 3 files changed, 557 insertions(+), 60 deletions(-) diff --git a/sys/dev/hyperv/netvsc/hn_rndis.c b/sys/dev/hyperv/netvsc/hn_rndis.c index 08314a25e29..e308e791825 100644 --- a/sys/dev/hyperv/netvsc/hn_rndis.c +++ b/sys/dev/hyperv/netvsc/hn_rndis.c @@ -838,11 +838,15 @@ hn_rndis_init(struct hn_softc *sc) error = EIO; goto done; } + sc->hn_rndis_agg_size = comp->rm_pktmaxsz; + sc->hn_rndis_agg_pkts = comp->rm_pktmaxcnt; + sc->hn_rndis_agg_align = 1U << comp->rm_align; + if (bootverbose) { if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u, " "align %u\n", comp->rm_ver_major, comp->rm_ver_minor, - comp->rm_pktmaxsz, comp->rm_pktmaxcnt, - 1U << comp->rm_align); + sc->hn_rndis_agg_size, sc->hn_rndis_agg_pkts, + sc->hn_rndis_agg_align); } error = 0; done: diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index e9f530af8b1..d4962285d87 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -159,10 +159,22 @@ __FBSDID("$FreeBSD$"); #define HN_CSUM_IP6_HWASSIST(sc) \ ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) +#define HN_PKTSIZE_MIN(align) \ + roundup2(ETHER_MIN_LEN + ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN + \ + HN_RNDIS_PKT_LEN, (align)) +#define HN_PKTSIZE(m, align) \ + roundup2((m)->m_pkthdr.len + HN_RNDIS_PKT_LEN, (align)) + struct hn_txdesc { #ifndef HN_USE_TXDESC_BUFRING SLIST_ENTRY(hn_txdesc) link; #endif + STAILQ_ENTRY(hn_txdesc) agg_link; + + /* Aggregated txdescs, in sending order. */ + STAILQ_HEAD(, hn_txdesc) agg_list; + + /* The oldest packet, if transmission aggregation happens. */ struct mbuf *m; struct hn_tx_ring *txr; int refs; @@ -180,6 +192,7 @@ struct hn_txdesc { #define HN_TXD_FLAG_ONLIST 0x0001 #define HN_TXD_FLAG_DMAMAP 0x0002 +#define HN_TXD_FLAG_ONAGG 0x0004 struct hn_rxinfo { uint32_t vlan_info; @@ -259,6 +272,10 @@ static int hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_size_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *); static void hn_init_locked(struct hn_softc *); @@ -306,7 +323,7 @@ static int hn_create_tx_data(struct hn_softc *, int); static void hn_fixup_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); -static int hn_encap(struct hn_tx_ring *, +static int hn_encap(struct ifnet *, struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_txpkt(struct ifnet *, struct hn_tx_ring *, struct hn_txdesc *); @@ -315,6 +332,10 @@ static void hn_set_tso_maxsize(struct hn_softc *, int, int); static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_resume_tx(struct hn_softc *, int); +static void hn_set_txagg(struct hn_softc *); +static void *hn_try_txagg(struct ifnet *, + struct hn_tx_ring *, struct hn_txdesc *, + int); static int hn_get_txswq_depth(const struct hn_tx_ring *); static void hn_txpkt_done(struct hn_nvs_sendctx *, struct hn_softc *, struct vmbus_channel *, @@ -430,6 +451,16 @@ SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); #endif +/* Packet transmission aggregation size limit */ +static int hn_tx_agg_size = -1; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_size, CTLFLAG_RDTUN, + &hn_tx_agg_size, 0, "Packet transmission aggregation size limit"); + +/* Packet transmission aggregation count limit */ +static int hn_tx_agg_pkts = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_pkts, CTLFLAG_RDTUN, + &hn_tx_agg_pkts, 0, "Packet transmission aggregation packet limit"); + static u_int hn_cpu_index; /* next CPU for channel */ static struct taskqueue *hn_tx_taskq; /* shared TX taskqueue */ @@ -658,6 +689,84 @@ hn_set_rxfilter(struct hn_softc *sc) return (error); } +static void +hn_set_txagg(struct hn_softc *sc) +{ + uint32_t size, pkts; + int i; + + /* + * Setup aggregation size. + */ + if (sc->hn_agg_size < 0) + size = UINT32_MAX; + else + size = sc->hn_agg_size; + + if (sc->hn_rndis_agg_size < size) + size = sc->hn_rndis_agg_size; + + if (size <= 2 * HN_PKTSIZE_MIN(sc->hn_rndis_agg_align)) { + /* Disable */ + size = 0; + pkts = 0; + goto done; + } + + /* NOTE: Type of the per TX ring setting is 'int'. */ + if (size > INT_MAX) + size = INT_MAX; + + /* NOTE: We only aggregate packets using chimney sending buffers. */ + if (size > (uint32_t)sc->hn_chim_szmax) + size = sc->hn_chim_szmax; + + /* + * Setup aggregation packet count. + */ + if (sc->hn_agg_pkts < 0) + pkts = UINT32_MAX; + else + pkts = sc->hn_agg_pkts; + + if (sc->hn_rndis_agg_pkts < pkts) + pkts = sc->hn_rndis_agg_pkts; + + if (pkts <= 1) { + /* Disable */ + size = 0; + pkts = 0; + goto done; + } + + /* NOTE: Type of the per TX ring setting is 'short'. */ + if (pkts > SHRT_MAX) + pkts = SHRT_MAX; + +done: + /* NOTE: Type of the per TX ring setting is 'short'. */ + if (sc->hn_rndis_agg_align > SHRT_MAX) { + /* Disable */ + size = 0; + pkts = 0; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "TX agg size %u, pkts %u, align %u\n", + size, pkts, sc->hn_rndis_agg_align); + } + + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_agg_szmax = size; + txr->hn_agg_pktmax = pkts; + txr->hn_agg_align = sc->hn_rndis_agg_align; + mtx_unlock(&txr->hn_tx_lock); + } +} + static int hn_get_txswq_depth(const struct hn_tx_ring *txr) { @@ -784,6 +893,12 @@ hn_attach(device_t dev) sc->hn_prichan = vmbus_get_channel(dev); HN_LOCK_INIT(sc); + /* + * Initialize these tunables once. + */ + sc->hn_agg_size = hn_tx_agg_size; + sc->hn_agg_pkts = hn_tx_agg_pkts; + /* * Setup taskqueue for transmission. */ @@ -939,6 +1054,24 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_ind", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_ind_sysctl, "IU", "RSS indirect table"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_size", + CTLFLAG_RD, &sc->hn_rndis_agg_size, 0, + "RNDIS offered packet transmission aggregation size limit"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_pkts", + CTLFLAG_RD, &sc->hn_rndis_agg_pkts, 0, + "RNDIS offered packet transmission aggregation count limit"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_align", + CTLFLAG_RD, &sc->hn_rndis_agg_align, 0, + "RNDIS packet transmission aggregation alignment"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_size", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_size_sysctl, "I", + "Packet transmission aggregation size, 0 -- disable, -1 -- auto"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_pkts", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_pkts_sysctl, "I", + "Packet transmission aggregation packets, " + "0 -- disable, -1 -- auto"); /* * Setup the ifmedia, which has been initialized earlier. @@ -1189,16 +1322,45 @@ hn_txdesc_put(struct hn_tx_ring *txr, struct hn_txdesc *txd) KASSERT((txd->flags & HN_TXD_FLAG_ONLIST) == 0, ("put an onlist txd %#x", txd->flags)); + KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("put an onagg txd %#x", txd->flags)); KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs)); if (atomic_fetchadd_int(&txd->refs, -1) != 1) return 0; + if (!STAILQ_EMPTY(&txd->agg_list)) { + struct hn_txdesc *tmp_txd; + + while ((tmp_txd = STAILQ_FIRST(&txd->agg_list)) != NULL) { + int freed; + + KASSERT(STAILQ_EMPTY(&tmp_txd->agg_list), + ("resursive aggregation on aggregated txdesc")); + KASSERT((tmp_txd->flags & HN_TXD_FLAG_ONAGG), + ("not aggregated txdesc")); + KASSERT((tmp_txd->flags & HN_TXD_FLAG_DMAMAP) == 0, + ("aggregated txdesc uses dmamap")); + KASSERT(tmp_txd->chim_index == HN_NVS_CHIM_IDX_INVALID, + ("aggregated txdesc consumes " + "chimney sending buffer")); + KASSERT(tmp_txd->chim_size == 0, + ("aggregated txdesc has non-zero " + "chimney sending size")); + + STAILQ_REMOVE_HEAD(&txd->agg_list, agg_link); + tmp_txd->flags &= ~HN_TXD_FLAG_ONAGG; + freed = hn_txdesc_put(txr, tmp_txd); + KASSERT(freed, ("failed to free aggregated txdesc")); + } + } + if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("chim txd uses dmamap")); hn_chim_free(txr->hn_sc, txd->chim_index); txd->chim_index = HN_NVS_CHIM_IDX_INVALID; + txd->chim_size = 0; } else if (txd->flags & HN_TXD_FLAG_DMAMAP) { bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap, BUS_DMASYNC_POSTWRITE); @@ -1253,8 +1415,11 @@ hn_txdesc_get(struct hn_tx_ring *txr) atomic_subtract_int(&txr->hn_txdesc_avail, 1); #endif KASSERT(txd->m == NULL && txd->refs == 0 && + STAILQ_EMPTY(&txd->agg_list) && txd->chim_index == HN_NVS_CHIM_IDX_INVALID && + txd->chim_size == 0 && (txd->flags & HN_TXD_FLAG_ONLIST) && + (txd->flags & HN_TXD_FLAG_ONAGG) == 0 && (txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("invalid txd")); txd->flags &= ~HN_TXD_FLAG_ONLIST; txd->refs = 1; @@ -1271,6 +1436,22 @@ hn_txdesc_hold(struct hn_txdesc *txd) atomic_add_int(&txd->refs, 1); } +static __inline void +hn_txdesc_agg(struct hn_txdesc *agg_txd, struct hn_txdesc *txd) +{ + + KASSERT((agg_txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("recursive aggregation on aggregating txdesc")); + + KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("already aggregated")); + KASSERT(STAILQ_EMPTY(&txd->agg_list), + ("recursive aggregation on to-be-aggregated txdesc")); + + txd->flags |= HN_TXD_FLAG_ONAGG; + STAILQ_INSERT_TAIL(&agg_txd->agg_list, txd, agg_link); +} + static bool hn_tx_ring_pending(struct hn_tx_ring *txr) { @@ -1382,12 +1563,123 @@ hn_rndis_pktinfo_append(struct rndis_packet_msg *pkt, size_t pktsize, return (pi->rm_data); } +static __inline int +hn_flush_txagg(struct ifnet *ifp, struct hn_tx_ring *txr) +{ + struct hn_txdesc *txd; + struct mbuf *m; + int error, pkts; + + txd = txr->hn_agg_txd; + KASSERT(txd != NULL, ("no aggregate txdesc")); + + /* + * Since hn_txpkt() will reset this temporary stat, save + * it now, so that oerrors can be updated properly, if + * hn_txpkt() ever fails. + */ + pkts = txr->hn_stat_pkts; + + /* + * Since txd's mbuf will _not_ be freed upon hn_txpkt() + * failure, save it for later freeing, if hn_txpkt() ever + * fails. + */ + m = txd->m; + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m is not. */ + m_freem(m); + + txr->hn_flush_failed++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, pkts); + } + + /* Reset all aggregation states. */ + txr->hn_agg_txd = NULL; + txr->hn_agg_szleft = 0; + txr->hn_agg_pktleft = 0; + txr->hn_agg_prevpkt = NULL; + + return (error); +} + +static void * +hn_try_txagg(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, + int pktsize) +{ + void *chim; + + if (txr->hn_agg_txd != NULL) { + if (txr->hn_agg_pktleft >= 1 && txr->hn_agg_szleft > pktsize) { + struct hn_txdesc *agg_txd = txr->hn_agg_txd; + struct rndis_packet_msg *pkt = txr->hn_agg_prevpkt; + int olen; + + /* + * Update the previous RNDIS packet's total length, + * it can be increased due to the mandatory alignment + * padding for this RNDIS packet. And update the + * aggregating txdesc's chimney sending buffer size + * accordingly. + * + * XXX + * Zero-out the padding, as required by the RNDIS spec. + */ + olen = pkt->rm_len; + pkt->rm_len = roundup2(olen, txr->hn_agg_align); + agg_txd->chim_size += pkt->rm_len - olen; + + /* Link this txdesc to the parent. */ + hn_txdesc_agg(agg_txd, txd); + + chim = (uint8_t *)pkt + pkt->rm_len; + /* Save the current packet for later fixup. */ + txr->hn_agg_prevpkt = chim; + + txr->hn_agg_pktleft--; + txr->hn_agg_szleft -= pktsize; + if (txr->hn_agg_szleft <= + HN_PKTSIZE_MIN(txr->hn_agg_align)) { + /* + * Probably can't aggregate more packets, + * flush this aggregating txdesc proactively. + */ + txr->hn_agg_pktleft = 0; + } + /* Done! */ + return (chim); + } + hn_flush_txagg(ifp, txr); + } + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); + + txr->hn_tx_chimney_tried++; + txd->chim_index = hn_chim_alloc(txr->hn_sc); + if (txd->chim_index == HN_NVS_CHIM_IDX_INVALID) + return (NULL); + txr->hn_tx_chimney++; + + chim = txr->hn_sc->hn_chim + + (txd->chim_index * txr->hn_sc->hn_chim_szmax); + + if (txr->hn_agg_pktmax > 1 && + txr->hn_agg_szmax > pktsize + HN_PKTSIZE_MIN(txr->hn_agg_align)) { + txr->hn_agg_txd = txd; + txr->hn_agg_pktleft = txr->hn_agg_pktmax - 1; + txr->hn_agg_szleft = txr->hn_agg_szmax - pktsize; + txr->hn_agg_prevpkt = chim; + } + return (chim); +} + /* * NOTE: * If this function fails, then both txd and m_head0 will be freed. */ static int -hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) +hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, + struct mbuf **m_head0) { bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; @@ -1395,33 +1687,30 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) struct rndis_packet_msg *pkt; uint32_t *pi_data; void *chim = NULL; - int pktlen; + int pkt_hlen, pkt_size; pkt = txd->rndis_pkt; - if (m_head->m_pkthdr.len + HN_RNDIS_PKT_LEN < txr->hn_chim_size) { - /* - * This packet is small enough to fit into a chimney sending - * buffer. Try allocating one chimney sending buffer now. - */ - txr->hn_tx_chimney_tried++; - txd->chim_index = hn_chim_alloc(txr->hn_sc); - if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { - chim = txr->hn_sc->hn_chim + - (txd->chim_index * txr->hn_sc->hn_chim_szmax); - /* - * Directly fill the chimney sending buffer w/ the - * RNDIS packet message. - */ + pkt_size = HN_PKTSIZE(m_head, txr->hn_agg_align); + if (pkt_size < txr->hn_chim_size) { + chim = hn_try_txagg(ifp, txr, txd, pkt_size); + if (chim != NULL) pkt = chim; - } + } else { + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); } pkt->rm_type = REMOTE_NDIS_PACKET_MSG; pkt->rm_len = sizeof(*pkt) + m_head->m_pkthdr.len; pkt->rm_dataoffset = sizeof(*pkt); pkt->rm_datalen = m_head->m_pkthdr.len; + pkt->rm_oobdataoffset = 0; + pkt->rm_oobdatalen = 0; + pkt->rm_oobdataelements = 0; pkt->rm_pktinfooffset = sizeof(*pkt); pkt->rm_pktinfolen = 0; + pkt->rm_vchandle = 0; + pkt->rm_reserved = 0; if (txr->hn_tx_flags & HN_TX_FLAG_HASHVAL) { /* @@ -1482,7 +1771,7 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } - pktlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; + pkt_hlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; /* Convert RNDIS packet message offsets */ pkt->rm_dataoffset = hn_rndis_pktmsg_offset(pkt->rm_dataoffset); pkt->rm_pktinfooffset = hn_rndis_pktmsg_offset(pkt->rm_pktinfooffset); @@ -1491,25 +1780,36 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) * Fast path: Chimney sending. */ if (chim != NULL) { - KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID, - ("chimney buffer is not used")); - KASSERT(pkt == chim, ("RNDIS pkt not in chimney buffer")); + struct hn_txdesc *tgt_txd = txd; + + if (txr->hn_agg_txd != NULL) { + tgt_txd = txr->hn_agg_txd; +#ifdef INVARIANTS + *m_head0 = NULL; +#endif + } + + KASSERT(pkt == chim, + ("RNDIS pkt not in chimney sending buffer")); + KASSERT(tgt_txd->chim_index != HN_NVS_CHIM_IDX_INVALID, + ("chimney sending buffer is not used")); + tgt_txd->chim_size += pkt->rm_len; m_copydata(m_head, 0, m_head->m_pkthdr.len, - ((uint8_t *)chim) + pktlen); + ((uint8_t *)chim) + pkt_hlen); - txd->chim_size = pkt->rm_len; txr->hn_gpa_cnt = 0; - txr->hn_tx_chimney++; txr->hn_sendpkt = hn_txpkt_chim; goto done; } + + KASSERT(txr->hn_agg_txd == NULL, ("aggregating sglist txdesc")); KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, ("chimney buffer is used")); KASSERT(pkt == txd->rndis_pkt, ("RNDIS pkt not in txdesc")); error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs); - if (error) { + if (__predict_false(error)) { int freed; /* @@ -1523,7 +1823,7 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) ("fail to free txd upon txdma error")); txr->hn_txdma_failed++; - if_inc_counter(txr->hn_sc->hn_ifp, IFCOUNTER_OERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return error; } *m_head0 = m_head; @@ -1534,7 +1834,7 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) /* send packet with page buffer */ txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr); txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK; - txr->hn_gpa[0].gpa_len = pktlen; + txr->hn_gpa[0].gpa_len = pkt_hlen; /* * Fill the page buffers with mbuf info after the page @@ -1557,6 +1857,12 @@ done: /* Set the completion routine */ hn_nvs_sendctx_init(&txd->send_ctx, hn_txpkt_done, txd); + /* Update temporary stats for later use. */ + txr->hn_stat_pkts++; + txr->hn_stat_size += m_head->m_pkthdr.len; + if (m_head->m_flags & M_MCAST) + txr->hn_stat_mcasts++; + return 0; } @@ -1572,23 +1878,34 @@ hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) again: /* - * Make sure that txd is not freed before ETHER_BPF_MTAP. + * Make sure that this txd and any aggregated txds are not freed + * before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); error = txr->hn_sendpkt(txr, txd); if (!error) { - ETHER_BPF_MTAP(ifp, txd->m); - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if (bpf_peers_present(ifp->if_bpf)) { + const struct hn_txdesc *tmp_txd; + + ETHER_BPF_MTAP(ifp, txd->m); + STAILQ_FOREACH(tmp_txd, &txd->agg_list, agg_link) + ETHER_BPF_MTAP(ifp, tmp_txd->m); + } + + if_inc_counter(ifp, IFCOUNTER_OPACKETS, txr->hn_stat_pkts); #ifdef HN_IFSTART_SUPPORT if (!hn_use_if_start) #endif { if_inc_counter(ifp, IFCOUNTER_OBYTES, - txd->m->m_pkthdr.len); - if (txd->m->m_flags & M_MCAST) - if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); + txr->hn_stat_size); + if (txr->hn_stat_mcasts != 0) { + if_inc_counter(ifp, IFCOUNTER_OMCASTS, + txr->hn_stat_mcasts); + } } - txr->hn_pkts++; + txr->hn_pkts += txr->hn_stat_pkts; + txr->hn_sends++; } hn_txdesc_put(txr, txd); @@ -1628,7 +1945,13 @@ again: txr->hn_send_failed++; } - return error; + + /* Reset temporary stats, after this sending is done. */ + txr->hn_stat_size = 0; + txr->hn_stat_pkts = 0; + txr->hn_stat_mcasts = 0; + + return (error); } /* @@ -2411,6 +2734,64 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS) return 0; } +static int +hn_txagg_size_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error, size; + + size = sc->hn_agg_size; + error = sysctl_handle_int(oidp, &size, 0, req); + if (error || req->newptr == NULL) + return (error); + + HN_LOCK(sc); + sc->hn_agg_size = size; + hn_set_txagg(sc); + HN_UNLOCK(sc); + + return (0); +} + +static int +hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error, pkts; + + pkts = sc->hn_agg_pkts; + error = sysctl_handle_int(oidp, &pkts, 0, req); + if (error || req->newptr == NULL) + return (error); + + HN_LOCK(sc); + sc->hn_agg_pkts = pkts; + hn_set_txagg(sc); + HN_UNLOCK(sc); + + return (0); +} + +static int +hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int pkts; + + pkts = sc->hn_tx_ring[0].hn_agg_pktmax; + return (sysctl_handle_int(oidp, &pkts, 0, req)); +} + +static int +hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int align; + + align = sc->hn_tx_ring[0].hn_agg_align; + return (sysctl_handle_int(oidp, &align, 0, req)); +} + static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) { @@ -2954,6 +3335,7 @@ hn_tx_ring_create(struct hn_softc *sc, int id) txd->txr = txr; txd->chim_index = HN_NVS_CHIM_IDX_INVALID; + STAILQ_INIT(&txd->agg_list); /* * Allocate and load RNDIS packet message. @@ -3037,6 +3419,8 @@ hn_tx_ring_create(struct hn_softc *sc, int id) SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "packets", CTLFLAG_RW, &txr->hn_pkts, "# of packets transmitted"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "sends", + CTLFLAG_RW, &txr->hn_sends, "# of sends"); } } @@ -3151,6 +3535,11 @@ hn_create_tx_data(struct hn_softc *sc, int ring_cnt) CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_tx_ring, hn_txdma_failed), hn_tx_stat_ulong_sysctl, "LU", "# of TX DMA failure"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_flush_failed", + CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, + __offsetof(struct hn_tx_ring, hn_flush_failed), + hn_tx_stat_ulong_sysctl, "LU", + "# of packet transmission aggregation flush failure"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tx_collapsed", CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_tx_ring, hn_tx_collapsed), @@ -3187,6 +3576,17 @@ hn_create_tx_data(struct hn_softc *sc, int ring_cnt) CTLFLAG_RD, &sc->hn_tx_ring_cnt, 0, "# created TX rings"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_inuse", CTLFLAG_RD, &sc->hn_tx_ring_inuse, 0, "# used TX rings"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "agg_szmax", + CTLFLAG_RD, &sc->hn_tx_ring[0].hn_agg_szmax, 0, + "Applied packet transmission aggregation size"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_pktmax", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_pktmax_sysctl, "I", + "Applied packet transmission aggregation packets"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_align", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_align_sysctl, "I", + "Applied packet transmission aggregation alignment"); return 0; } @@ -3306,18 +3706,20 @@ hn_start_locked(struct hn_tx_ring *txr, int len) { struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; + int sched = 0; KASSERT(hn_use_if_start, ("hn_start_locked is called, when if_start is disabled")); KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); mtx_assert(&txr->hn_tx_lock, MA_OWNED); + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); if (__predict_false(txr->hn_suspended)) - return 0; + return (0); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) - return 0; + return (0); while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { struct hn_txdesc *txd; @@ -3335,7 +3737,8 @@ hn_start_locked(struct hn_tx_ring *txr, int len) * following up packets) to tx taskqueue. */ IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - return 1; + sched = 1; + break; } #if defined(INET6) || defined(INET) @@ -3356,21 +3759,50 @@ hn_start_locked(struct hn_tx_ring *txr, int len) break; } - error = hn_encap(txr, txd, &m_head); + error = hn_encap(ifp, txr, txd, &m_head); if (error) { /* Both txd and m_head are freed */ + KASSERT(txr->hn_agg_txd == NULL, + ("encap failed w/ pending aggregating txdesc")); continue; } - error = hn_txpkt(ifp, txr, txd); - if (__predict_false(error)) { - /* txd is freed, but m_head is not */ - IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - break; + if (txr->hn_agg_pktleft == 0) { + if (txr->hn_agg_txd != NULL) { + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + error = hn_flush_txagg(ifp, txr); + if (__predict_false(error)) { + atomic_set_int(&ifp->if_drv_flags, + IFF_DRV_OACTIVE); + break; + } + } else { + KASSERT(m_head != NULL, ("mbuf was freed")); + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); + atomic_set_int(&ifp->if_drv_flags, + IFF_DRV_OACTIVE); + break; + } + } } +#ifdef INVARIANTS + else { + KASSERT(txr->hn_agg_txd != NULL, + ("no aggregating txdesc")); + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + } +#endif } - return 0; + + /* Flush pending aggerated transmission. */ + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); + return (sched); } static void @@ -3447,18 +3879,20 @@ hn_xmit(struct hn_tx_ring *txr, int len) struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; struct mbuf *m_head; + int sched = 0; mtx_assert(&txr->hn_tx_lock, MA_OWNED); #ifdef HN_IFSTART_SUPPORT KASSERT(hn_use_if_start == 0, ("hn_xmit is called, when if_start is enabled")); #endif + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); if (__predict_false(txr->hn_suspended)) - return 0; + return (0); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || txr->hn_oactive) - return 0; + return (0); while ((m_head = drbr_peek(ifp, txr->hn_mbuf_br)) != NULL) { struct hn_txdesc *txd; @@ -3471,7 +3905,8 @@ hn_xmit(struct hn_tx_ring *txr, int len) * following up packets) to tx taskqueue. */ drbr_putback(ifp, txr->hn_mbuf_br, m_head); - return 1; + sched = 1; + break; } txd = hn_txdesc_get(txr); @@ -3482,25 +3917,53 @@ hn_xmit(struct hn_tx_ring *txr, int len) break; } - error = hn_encap(txr, txd, &m_head); + error = hn_encap(ifp, txr, txd, &m_head); if (error) { /* Both txd and m_head are freed; discard */ + KASSERT(txr->hn_agg_txd == NULL, + ("encap failed w/ pending aggregating txdesc")); drbr_advance(ifp, txr->hn_mbuf_br); continue; } - error = hn_txpkt(ifp, txr, txd); - if (__predict_false(error)) { - /* txd is freed, but m_head is not */ - drbr_putback(ifp, txr->hn_mbuf_br, m_head); - txr->hn_oactive = 1; - break; + if (txr->hn_agg_pktleft == 0) { + if (txr->hn_agg_txd != NULL) { + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + error = hn_flush_txagg(ifp, txr); + if (__predict_false(error)) { + txr->hn_oactive = 1; + break; + } + } else { + KASSERT(m_head != NULL, ("mbuf was freed")); + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + drbr_putback(ifp, txr->hn_mbuf_br, + m_head); + txr->hn_oactive = 1; + break; + } + } } +#ifdef INVARIANTS + else { + KASSERT(txr->hn_agg_txd != NULL, + ("no aggregating txdesc")); + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + } +#endif /* Sent */ drbr_advance(ifp, txr->hn_mbuf_br); } - return 0; + + /* Flush pending aggerated transmission. */ + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); + return (sched); } static int @@ -3978,6 +4441,11 @@ back: if (error) return (error); + /* + * Fixup transmission aggregation setup. + */ + hn_set_txagg(sc); + sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; return (0); } diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index ea47be85848..acb924dd568 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -125,6 +125,22 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + /* Applied packet transmission aggregation limits. */ + int hn_agg_szmax; + short hn_agg_pktmax; + short hn_agg_align; + + /* Packet transmission aggregation states. */ + struct hn_txdesc *hn_agg_txd; + int hn_agg_szleft; + short hn_agg_pktleft; + struct rndis_packet_msg *hn_agg_prevpkt; + + /* Temporary stats for each sends. */ + int hn_stat_size; + short hn_stat_pkts; + short hn_stat_mcasts; + int (*hn_sendpkt)(struct hn_tx_ring *, struct hn_txdesc *); int hn_suspended; int hn_gpa_cnt; @@ -137,6 +153,8 @@ struct hn_tx_ring { u_long hn_tx_chimney_tried; u_long hn_tx_chimney; u_long hn_pkts; + u_long hn_sends; + u_long hn_flush_failed; /* Rarely used stuffs */ struct hn_txdesc *hn_txdesc; @@ -180,6 +198,10 @@ struct hn_softc { uint32_t hn_nvs_ver; uint32_t hn_rx_filter; + /* Packet transmission aggregation user settings. */ + int hn_agg_size; + int hn_agg_pkts; + struct taskqueue *hn_mgmt_taskq; struct taskqueue *hn_mgmt_taskq0; struct task hn_link_task; @@ -200,6 +222,9 @@ struct hn_softc { uint32_t hn_ndis_ver; int hn_ndis_tso_szmax; int hn_ndis_tso_sgmin; + uint32_t hn_rndis_agg_size; + uint32_t hn_rndis_agg_pkts; + uint32_t hn_rndis_agg_align; int hn_rss_ind_size; uint32_t hn_rss_hash; /* NDIS_HASH_ */ From 8f3bf5f97b6e6dda2b5d4a45926405ff5d506142 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:09:43 +0000 Subject: [PATCH 022/115] hyperv/vmbus: Support transction result busy-wait. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8488 --- sys/dev/hyperv/include/vmbus_xact.h | 2 ++ sys/dev/hyperv/vmbus/vmbus_xact.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sys/dev/hyperv/include/vmbus_xact.h b/sys/dev/hyperv/include/vmbus_xact.h index c2919aa8c1f..bfe4b88e920 100644 --- a/sys/dev/hyperv/include/vmbus_xact.h +++ b/sys/dev/hyperv/include/vmbus_xact.h @@ -51,6 +51,8 @@ void vmbus_xact_activate(struct vmbus_xact *xact); void vmbus_xact_deactivate(struct vmbus_xact *xact); const void *vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len); +const void *vmbus_xact_busywait(struct vmbus_xact *xact, + size_t *resp_len); void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen); void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, diff --git a/sys/dev/hyperv/vmbus/vmbus_xact.c b/sys/dev/hyperv/vmbus/vmbus_xact.c index 642c165bc29..2f9c2ea713b 100644 --- a/sys/dev/hyperv/vmbus/vmbus_xact.c +++ b/sys/dev/hyperv/vmbus/vmbus_xact.c @@ -69,6 +69,8 @@ static struct vmbus_xact *vmbus_xact_alloc(struct vmbus_xact_ctx *, static void vmbus_xact_free(struct vmbus_xact *); static struct vmbus_xact *vmbus_xact_get1(struct vmbus_xact_ctx *, uint32_t); +const void *vmbus_xact_wait1(struct vmbus_xact *, size_t *, + bool); static struct vmbus_xact * vmbus_xact_alloc(struct vmbus_xact_ctx *ctx, bus_dma_tag_t parent_dtag) @@ -249,7 +251,8 @@ vmbus_xact_deactivate(struct vmbus_xact *xact) } const void * -vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) +vmbus_xact_wait1(struct vmbus_xact *xact, size_t *resp_len, + bool can_sleep) { struct vmbus_xact_ctx *ctx = xact->x_ctx; const void *resp; @@ -258,8 +261,14 @@ vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) KASSERT(ctx->xc_active == xact, ("xact mismatch")); while (xact->x_resp == NULL) { - mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0, - "wxact", 0); + if (can_sleep) { + mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0, + "wxact", 0); + } else { + mtx_unlock(&ctx->xc_active_lock); + DELAY(1000); + mtx_lock(&ctx->xc_active_lock); + } } ctx->xc_active = NULL; @@ -271,6 +280,20 @@ vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) return (resp); } +const void * +vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) +{ + + return (vmbus_xact_wait1(xact, resp_len, true /* can sleep */)); +} + +const void * +vmbus_xact_busywait(struct vmbus_xact *xact, size_t *resp_len) +{ + + return (vmbus_xact_wait1(xact, resp_len, false /* can't sleep */)); +} + static void vmbus_xact_save_resp(struct vmbus_xact *xact, const void *data, size_t dlen) { From fdc4f478ed88489f86e72a479843d43a51d684a6 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:21:15 +0000 Subject: [PATCH 023/115] hyperv/hn: Fix WITNESS warnings And re-enable SIOCADDMULTI/SIOCDELMULTI, after WITNESS warning is fixed. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8489 --- sys/dev/hyperv/netvsc/hn_nvs.c | 5 +++- sys/dev/hyperv/netvsc/hn_rndis.c | 5 +++- sys/dev/hyperv/netvsc/if_hn.c | 46 ++++++++++++++++---------------- sys/dev/hyperv/netvsc/if_hnvar.h | 14 ++++++++++ 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/sys/dev/hyperv/netvsc/hn_nvs.c b/sys/dev/hyperv/netvsc/hn_nvs.c index 0d8c75cbc07..37f0cee3cab 100644 --- a/sys/dev/hyperv/netvsc/hn_nvs.c +++ b/sys/dev/hyperv/netvsc/hn_nvs.c @@ -109,7 +109,10 @@ hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, vmbus_xact_deactivate(xact); return (NULL); } - hdr = vmbus_xact_wait(xact, &resplen); + if (HN_CAN_SLEEP(sc)) + hdr = vmbus_xact_wait(xact, &resplen); + else + hdr = vmbus_xact_busywait(xact, &resplen); /* * Check this NVS response message. diff --git a/sys/dev/hyperv/netvsc/hn_rndis.c b/sys/dev/hyperv/netvsc/hn_rndis.c index e308e791825..1c140f9be4d 100644 --- a/sys/dev/hyperv/netvsc/hn_rndis.c +++ b/sys/dev/hyperv/netvsc/hn_rndis.c @@ -232,7 +232,10 @@ hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); return (NULL); } - return (vmbus_xact_wait(xact, comp_len)); + if (HN_CAN_SLEEP(sc)) + return (vmbus_xact_wait(xact, comp_len)); + else + return (vmbus_xact_busywait(xact, comp_len)); } static const void * diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index d4962285d87..be5aafabd7b 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -149,7 +149,11 @@ __FBSDID("$FreeBSD$"); sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) #define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) #define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) -#define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) +#define HN_LOCK(sc) \ +do { \ + while (sx_try_xlock(&(sc)->hn_lock) == 0) \ + DELAY(1000); \ +} while (0) #define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) #define HN_CSUM_IP_MASK (CSUM_IP | CSUM_IP_TCP | CSUM_IP_UDP) @@ -667,18 +671,10 @@ hn_set_rxfilter(struct hn_softc *sc) filter = NDIS_PACKET_TYPE_DIRECTED; if (ifp->if_flags & IFF_BROADCAST) filter |= NDIS_PACKET_TYPE_BROADCAST; -#ifdef notyet - /* - * See the comment in SIOCADDMULTI/SIOCDELMULTI. - */ /* TODO: support multicast list */ if ((ifp->if_flags & IFF_ALLMULTI) || !TAILQ_EMPTY(&ifp->if_multiaddrs)) filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; -#else - /* Always enable ALLMULTI */ - filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; -#endif } if (sc->hn_rx_filter != filter) { @@ -2338,10 +2334,18 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Caller meight hold mutex, e.g. + * bpf; use busy-wait for the RNDIS + * reply. + */ + HN_NO_SLEEPING(sc); hn_set_rxfilter(sc); - else + HN_SLEEPING_OK(sc); + } else { hn_init_locked(sc); + } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) hn_stop(sc); @@ -2402,27 +2406,23 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCADDMULTI: case SIOCDELMULTI: -#ifdef notyet - /* - * XXX - * Multicast uses mutex, while RNDIS RX filter setting - * sleeps. We workaround this by always enabling - * ALLMULTI. ALLMULTI would actually always be on, even - * if we supported the SIOCADDMULTI/SIOCDELMULTI, since - * we don't support multicast address list configuration - * for this driver. - */ HN_LOCK(sc); if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { HN_UNLOCK(sc); break; } - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Multicast uses mutex; use busy-wait for + * the RNDIS reply. + */ + HN_NO_SLEEPING(sc); hn_set_rxfilter(sc); + HN_SLEEPING_OK(sc); + } HN_UNLOCK(sc); -#endif break; case SIOCSIFMEDIA: diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index acb924dd568..9b27d17ec02 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -236,6 +236,20 @@ struct hn_softc { #define HN_FLAG_HAS_RSSKEY 0x0004 #define HN_FLAG_HAS_RSSIND 0x0008 #define HN_FLAG_SYNTH_ATTACHED 0x0010 +#define HN_FLAG_NO_SLEEPING 0x0020 + +#define HN_NO_SLEEPING(sc) \ +do { \ + (sc)->hn_flags |= HN_FLAG_NO_SLEEPING; \ +} while (0) + +#define HN_SLEEPING_OK(sc) \ +do { \ + (sc)->hn_flags &= ~HN_FLAG_NO_SLEEPING; \ +} while (0) + +#define HN_CAN_SLEEP(sc) \ + (((sc)->hn_flags & HN_FLAG_NO_SLEEPING) == 0) #define HN_CAP_VLAN 0x0001 #define HN_CAP_MTU 0x0002 From 7960e6ba99d5edacb94b87b4f60be4b0eecd3e5f Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:41:08 +0000 Subject: [PATCH 024/115] hyperv/hn: Allow enabling IPv6 TX checksum offloading and IPv6 TSO. They are still disabled by default. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8490 --- sys/dev/hyperv/netvsc/hn_rndis.c | 2 -- sys/dev/hyperv/netvsc/if_hn.c | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/dev/hyperv/netvsc/hn_rndis.c b/sys/dev/hyperv/netvsc/hn_rndis.c index 1c140f9be4d..fa749d31bb9 100644 --- a/sys/dev/hyperv/netvsc/hn_rndis.c +++ b/sys/dev/hyperv/netvsc/hn_rndis.c @@ -602,7 +602,6 @@ hn_rndis_conf_offload(struct hn_softc *sc, int mtu) if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == HN_NDIS_LSOV2_CAP_IP6) { -#ifdef notyet caps |= HN_CAP_TSO6; params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; @@ -610,7 +609,6 @@ hn_rndis_conf_offload(struct hn_softc *sc, int mtu) tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; -#endif } sc->hn_ndis_tso_szmax = 0; sc->hn_ndis_tso_sgmin = 0; diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index be5aafabd7b..a5bb790d4d7 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -1127,6 +1127,13 @@ hn_attach(device_t dev) /* Enable all available capabilities by default. */ ifp->if_capenable = ifp->if_capabilities; + /* + * Disable IPv6 TSO and TXCSUM by default, they still can + * be enabled through SIOCSIFCAP. + */ + ifp->if_capenable &= ~(IFCAP_TXCSUM_IPV6 | IFCAP_TSO6); + ifp->if_hwassist &= ~(HN_CSUM_IP6_MASK | CSUM_IP6_TSO); + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; @@ -3646,12 +3653,10 @@ hn_fixup_tx_data(struct hn_softc *sc) csum_assist |= CSUM_IP_TCP; if (sc->hn_caps & HN_CAP_UDP4CS) csum_assist |= CSUM_IP_UDP; -#ifdef notyet if (sc->hn_caps & HN_CAP_TCP6CS) csum_assist |= CSUM_IP6_TCP; if (sc->hn_caps & HN_CAP_UDP6CS) csum_assist |= CSUM_IP6_UDP; -#endif for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_csum_assist = csum_assist; From a7ba764844c1718886ec37907f9a5da78a9f5676 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:54:31 +0000 Subject: [PATCH 025/115] hyperv/hn: Don't abuse hn_{tx,rx}_ring_inuse. Just in case, the # of TX/RX rings is changed upon synthetic parts re-attach. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8520 --- sys/dev/hyperv/netvsc/if_hn.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index a5bb790d4d7..d56657a62a7 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -504,7 +504,7 @@ hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) { int i; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; } #endif @@ -2554,7 +2554,7 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS) */ --ackcnt; HN_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt; HN_UNLOCK(sc); return 0; @@ -2578,7 +2578,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS) return error; HN_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; if (on) @@ -2646,7 +2646,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS) uint64_t stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; stat += *((uint64_t *)((uint8_t *)rxr + ofs)); } @@ -2656,7 +2656,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS) return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; *((uint64_t *)((uint8_t *)rxr + ofs)) = 0; } @@ -2674,7 +2674,7 @@ hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) u_long stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; stat += *((u_long *)((uint8_t *)rxr + ofs)); } @@ -2684,7 +2684,7 @@ hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; *((u_long *)((uint8_t *)rxr + ofs)) = 0; } @@ -2700,7 +2700,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) u_long stat; stat = 0; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; stat += *((u_long *)((uint8_t *)txr + ofs)); } @@ -2710,7 +2710,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; *((u_long *)((uint8_t *)txr + ofs)) = 0; } @@ -2732,7 +2732,7 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS) return error; HN_LOCK(sc); - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; *((int *)((uint8_t *)txr + ofs)) = conf; } @@ -3603,7 +3603,7 @@ hn_set_chim_size(struct hn_softc *sc, int chim_size) { int i; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_chim_size = chim_size; } From f55d404d45fccb19615e3d1fc14eebb864f1b578 Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Mon, 21 Nov 2016 09:23:42 +0000 Subject: [PATCH 026/115] Update struct r12a_rom. Reviewed by: avos --- sys/dev/rtwn/rtl8812a/r12a_rom_image.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/dev/rtwn/rtl8812a/r12a_rom_image.h b/sys/dev/rtwn/rtl8812a/r12a_rom_image.h index 2349ea5ed1a..1f992e1e8dd 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_rom_image.h +++ b/sys/dev/rtwn/rtl8812a/r12a_rom_image.h @@ -114,17 +114,18 @@ struct r12a_rom { uint16_t pid_12a; uint8_t reserved5[3]; uint8_t macaddr_12a[IEEE80211_ADDR_LEN]; - uint8_t reserved6[35]; + uint8_t reserved6[2]; + uint8_t string_12a[8]; /* "Realtek " */ + uint8_t reserved7[25]; uint16_t vid_21a; uint16_t pid_21a; - uint8_t reserved7[3]; + uint8_t reserved8[3]; uint8_t macaddr_21a[IEEE80211_ADDR_LEN]; - uint8_t reserved8[2]; - /* XXX check on RTL8812AU. */ - uint8_t string[8]; /* "Realtek " */ uint8_t reserved9[2]; + uint8_t string_21a[8]; /* "Realtek " */ + uint8_t reserved10[2]; uint8_t string_ven[23]; /* XXX variable length? */ - uint8_t reserved10[208]; + uint8_t reserved11[208]; } __packed; _Static_assert(sizeof(struct r12a_rom) == R12A_EFUSE_MAP_LEN, From d6699d292b1bbb62118c5316fcec666fa186276d Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 11:18:00 +0000 Subject: [PATCH 027/115] Add accelerated AES with using the ARMv8 crypto instructions. This is based on the AES-NI code, and modified as needed for use on ARMv8. When loaded the driver will check the appropriate field in the id_aa64isar0_el1 register to see if AES is supported, and if so the probe function will signal the driver should attach. With this I have seen up to 2000Mb/s from the cryptotest test with a single thread on a ThunderX Pass 2.0. Reviewed by: imp Obtained from: ABT Systems Ltd MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8297 --- share/man/man4/Makefile | 5 + share/man/man4/armv8crypto.4 | 83 ++++ sys/conf/files.arm64 | 6 + sys/crypto/armv8/armv8_crypto.c | 565 +++++++++++++++++++++++++++ sys/crypto/armv8/armv8_crypto.h | 55 +++ sys/crypto/armv8/armv8_crypto_wrap.c | 128 ++++++ sys/modules/Makefile | 2 + sys/modules/armv8crypto/Makefile | 20 + 8 files changed, 864 insertions(+) create mode 100644 share/man/man4/armv8crypto.4 create mode 100644 sys/crypto/armv8/armv8_crypto.c create mode 100644 sys/crypto/armv8/armv8_crypto.h create mode 100644 sys/crypto/armv8/armv8_crypto_wrap.c create mode 100644 sys/modules/armv8crypto/Makefile diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 98697541983..a5ec0b0d57a 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -53,6 +53,7 @@ MAN= aac.4 \ ${_aout.4} \ ${_apic.4} \ arcmsr.4 \ + ${_armv8crypto.4} \ ${_asmc.4} \ ata.4 \ ath.4 \ @@ -746,6 +747,10 @@ MLINKS+=xe.4 if_xe.4 MLINKS+=xl.4 if_xl.4 MLINKS+=zyd.4 if_zyd.4 +.if ${MACHINE_CPUARCH} == "aarch64" +_armv8crypto.4= armv8crypto.4 +.endif + .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" _acpi_asus.4= acpi_asus.4 _acpi_asus_wmi.4= acpi_asus_wmi.4 diff --git a/share/man/man4/armv8crypto.4 b/share/man/man4/armv8crypto.4 new file mode 100644 index 00000000000..0ae364d7b1c --- /dev/null +++ b/share/man/man4/armv8crypto.4 @@ -0,0 +1,83 @@ +.\" Copyright (c) 2016 The FreeBSD Foundation +.\" All rights reserved. +.\" +.\" This software was developed by Andrew Turner under +.\" sponsorship from the FreeBSD Foundation. +.\" +.\" 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. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd October 20, 2016 +.Dt ARMV8CRYPTO 4 +.Os +.Sh NAME +.Nm armv8crypto +.Nd "driver for the AES accelerator on ARM CPUs" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device crypto" +.Cd "device armv8crypto" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +armv8crypto_load="YES" +.Ed +.Sh DESCRIPTION +Starting with the ARMv8 architecture ARM Limited has added optional +cryptography instructions to accelerate AES, SHA-1, SHA-2, and +finite field arithmetic. +.Pp +The processor capability is reported as AES in the Instruction Set +Attributes 0 line at boot. +The +.Nm +driver does not attach on systems that lack the required CPU capability. +.Pp +The +.Nm +driver registers itself to accelerate AES operations for +.Xr crypto 4 . +.Sh SEE ALSO +.Xr crypt 3 , +.Xr crypto 4 , +.Xr intro 4 , +.Xr ipsec 4 , +.Xr random 4 , +.Xr crypto 9 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 11.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Andrew Turner Aq Mt andrew@FreeBSD.org . diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 879515185c7..3f9a955d0a0 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -136,6 +136,12 @@ contrib/vchiq/interface/vchiq_arm/vchiq_shim.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_util.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +crypto/armv8/armv8_crypto.c optional armv8crypto +armv8_crypto_wrap.o optional armv8crypto \ + dependency "$S/crypto/armv8/armv8_crypto_wrap.c" \ + compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc:N-mgeneral-regs-only} ${WERROR} ${NO_WCAST_QUAL} ${PROF} -march=armv8a+crypto ${.IMPSRC}" \ + no-implicit-rule \ + clean "armv8_crypto_wrap.o" crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/acpica/acpi_if.m optional acpi diff --git a/sys/crypto/armv8/armv8_crypto.c b/sys/crypto/armv8/armv8_crypto.c new file mode 100644 index 00000000000..52cb8fcc218 --- /dev/null +++ b/sys/crypto/armv8/armv8_crypto.c @@ -0,0 +1,565 @@ +/*- + * Copyright (c) 2005-2008 Pawel Jakub Dawidek + * Copyright (c) 2010 Konstantin Belousov + * Copyright (c) 2014,2016 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by John-Mark Gurney + * under sponsorship of the FreeBSD Foundation and + * Rubicon Communications, LLC (Netgate). + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + */ + +/* + * This is based on the aesni code. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +struct armv8_crypto_softc { + int dieing; + int32_t cid; + uint32_t sid; + TAILQ_HEAD(armv8_crypto_sessions_head, armv8_crypto_session) sessions; + struct rwlock lock; +}; + +static struct mtx *ctx_mtx; +static struct fpu_kern_ctx **ctx_vfp; + +#define AQUIRE_CTX(i, ctx) \ + do { \ + (i) = PCPU_GET(cpuid); \ + mtx_lock(&ctx_mtx[(i)]); \ + (ctx) = ctx_vfp[(i)]; \ + } while (0) +#define RELEASE_CTX(i, ctx) \ + do { \ + mtx_unlock(&ctx_mtx[(i)]); \ + (i) = -1; \ + (ctx) = NULL; \ + } while (0) + +static void armv8_crypto_freesession_locked(struct armv8_crypto_softc *, + struct armv8_crypto_session *); +static int armv8_crypto_cipher_process(struct armv8_crypto_session *, + struct cryptodesc *, struct cryptop *); + +MALLOC_DEFINE(M_ARMV8_CRYPTO, "armv8_crypto", "ARMv8 Crypto Data"); + +static void +armv8_crypto_identify(driver_t *drv, device_t parent) +{ + + /* NB: order 10 is so we get attached after h/w devices */ + if (device_find_child(parent, "armv8crypto", -1) == NULL && + BUS_ADD_CHILD(parent, 10, "armv8crypto", -1) == 0) + panic("ARMv8 crypto: could not attach"); +} + +static int +armv8_crypto_probe(device_t dev) +{ + uint64_t reg; + int ret = ENXIO; + + reg = READ_SPECIALREG(id_aa64isar0_el1); + + switch (ID_AA64ISAR0_AES(reg)) { + case ID_AA64ISAR0_AES_BASE: + case ID_AA64ISAR0_AES_PMULL: + ret = 0; + break; + } + + device_set_desc_copy(dev, "AES-CBC"); + + /* TODO: Check more fields as we support more features */ + + return (ret); +} + +static int +armv8_crypto_attach(device_t dev) +{ + struct armv8_crypto_softc *sc; + int i; + + sc = device_get_softc(dev); + TAILQ_INIT(&sc->sessions); + sc->dieing = 0; + sc->sid = 1; + + sc->cid = crypto_get_driverid(dev, CRYPTOCAP_F_HARDWARE | + CRYPTOCAP_F_SYNC); + if (sc->cid < 0) { + device_printf(dev, "Could not get crypto driver id.\n"); + return (ENOMEM); + } + + rw_init(&sc->lock, "armv8crypto"); + + ctx_mtx = malloc(sizeof(*ctx_mtx) * (mp_maxid + 1), M_ARMV8_CRYPTO, + M_WAITOK|M_ZERO); + ctx_vfp = malloc(sizeof(*ctx_vfp) * (mp_maxid + 1), M_ARMV8_CRYPTO, + M_WAITOK|M_ZERO); + + CPU_FOREACH(i) { + ctx_vfp[i] = fpu_kern_alloc_ctx(0); + mtx_init(&ctx_mtx[i], "armv8cryptoctx", NULL, MTX_DEF|MTX_NEW); + } + + crypto_register(sc->cid, CRYPTO_AES_CBC, 0, 0); + + return (0); +} + +static int +armv8_crypto_detach(device_t dev) +{ + struct armv8_crypto_softc *sc; + struct armv8_crypto_session *ses; + int i; + + sc = device_get_softc(dev); + + rw_wlock(&sc->lock); + TAILQ_FOREACH(ses, &sc->sessions, next) { + if (ses->used) { + rw_wunlock(&sc->lock); + device_printf(dev, + "Cannot detach, sessions still active.\n"); + return (EBUSY); + } + } + sc->dieing = 1; + while ((ses = TAILQ_FIRST(&sc->sessions)) != NULL) { + TAILQ_REMOVE(&sc->sessions, ses, next); + free(ses, M_ARMV8_CRYPTO); + } + rw_wunlock(&sc->lock); + crypto_unregister_all(sc->cid); + + rw_destroy(&sc->lock); + + CPU_FOREACH(i) { + if (ctx_vfp[i] != NULL) { + mtx_destroy(&ctx_mtx[i]); + fpu_kern_free_ctx(ctx_vfp[i]); + } + ctx_vfp[i] = NULL; + } + free(ctx_mtx, M_ARMV8_CRYPTO); + ctx_mtx = NULL; + free(ctx_vfp, M_ARMV8_CRYPTO); + ctx_vfp = NULL; + + return (0); +} + +static int +armv8_crypto_cipher_setup(struct armv8_crypto_session *ses, + struct cryptoini *encini) +{ + int i; + + switch (ses->algo) { + case CRYPTO_AES_CBC: + switch (encini->cri_klen) { + case 128: + ses->rounds = AES128_ROUNDS; + break; + case 192: + ses->rounds = AES192_ROUNDS; + break; + case 256: + ses->rounds = AES256_ROUNDS; + break; + default: + CRYPTDEB("invalid CBC/ICM/GCM key length"); + return (EINVAL); + } + break; + default: + return (EINVAL); + } + + rijndaelKeySetupEnc(ses->enc_schedule, encini->cri_key, + encini->cri_klen); + rijndaelKeySetupDec(ses->dec_schedule, encini->cri_key, + encini->cri_klen); + for (i = 0; i < nitems(ses->enc_schedule); i++) { + ses->enc_schedule[i] = bswap32(ses->enc_schedule[i]); + ses->dec_schedule[i] = bswap32(ses->dec_schedule[i]); + } + + return (0); +} + +static int +armv8_crypto_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri) +{ + struct armv8_crypto_softc *sc; + struct armv8_crypto_session *ses; + struct cryptoini *encini; + int error; + + if (sidp == NULL || cri == NULL) { + CRYPTDEB("no sidp or cri"); + return (EINVAL); + } + + sc = device_get_softc(dev); + if (sc->dieing) + return (EINVAL); + + ses = NULL; + encini = NULL; + for (; cri != NULL; cri = cri->cri_next) { + switch (cri->cri_alg) { + case CRYPTO_AES_CBC: + if (encini != NULL) { + CRYPTDEB("encini already set"); + return (EINVAL); + } + encini = cri; + break; + default: + CRYPTDEB("unhandled algorithm"); + return (EINVAL); + } + } + if (encini == NULL) { + CRYPTDEB("no cipher"); + return (EINVAL); + } + + rw_wlock(&sc->lock); + if (sc->dieing) { + rw_wunlock(&sc->lock); + return (EINVAL); + } + + /* + * Free sessions goes first, so if first session is used, we need to + * allocate one. + */ + ses = TAILQ_FIRST(&sc->sessions); + if (ses == NULL || ses->used) { + ses = malloc(sizeof(*ses), M_ARMV8_CRYPTO, M_NOWAIT | M_ZERO); + if (ses == NULL) { + rw_wunlock(&sc->lock); + return (ENOMEM); + } + ses->id = sc->sid++; + } else { + TAILQ_REMOVE(&sc->sessions, ses, next); + } + ses->used = 1; + TAILQ_INSERT_TAIL(&sc->sessions, ses, next); + rw_wunlock(&sc->lock); + ses->algo = encini->cri_alg; + + error = armv8_crypto_cipher_setup(ses, encini); + if (error != 0) { + CRYPTDEB("setup failed"); + rw_wlock(&sc->lock); + armv8_crypto_freesession_locked(sc, ses); + rw_wunlock(&sc->lock); + return (error); + } + + *sidp = ses->id; + return (0); +} + +static void +armv8_crypto_freesession_locked(struct armv8_crypto_softc *sc, + struct armv8_crypto_session *ses) +{ + uint32_t sid; + + rw_assert(&sc->lock, RA_WLOCKED); + + sid = ses->id; + TAILQ_REMOVE(&sc->sessions, ses, next); + *ses = (struct armv8_crypto_session){}; + ses->id = sid; + TAILQ_INSERT_HEAD(&sc->sessions, ses, next); +} + +static int +armv8_crypto_freesession(device_t dev, uint64_t tid) +{ + struct armv8_crypto_softc *sc; + struct armv8_crypto_session *ses; + uint32_t sid; + + sc = device_get_softc(dev); + sid = ((uint32_t)tid) & 0xffffffff; + rw_wlock(&sc->lock); + TAILQ_FOREACH_REVERSE(ses, &sc->sessions, armv8_crypto_sessions_head, + next) { + if (ses->id == sid) + break; + } + if (ses == NULL) { + rw_wunlock(&sc->lock); + return (EINVAL); + } + armv8_crypto_freesession_locked(sc, ses); + rw_wunlock(&sc->lock); + + return (0); +} + +static int +armv8_crypto_process(device_t dev, struct cryptop *crp, int hint __unused) +{ + struct armv8_crypto_softc *sc = device_get_softc(dev); + struct cryptodesc *crd, *enccrd; + struct armv8_crypto_session *ses; + int error; + + error = 0; + enccrd = NULL; + + /* Sanity check. */ + if (crp == NULL) + return (EINVAL); + + if (crp->crp_callback == NULL || crp->crp_desc == NULL) { + error = EINVAL; + goto out; + } + + for (crd = crp->crp_desc; crd != NULL; crd = crd->crd_next) { + switch (crd->crd_alg) { + case CRYPTO_AES_CBC: + if (enccrd != NULL) { + error = EINVAL; + goto out; + } + enccrd = crd; + break; + default: + error = EINVAL; + goto out; + } + } + + if (enccrd == NULL) { + error = EINVAL; + goto out; + } + + /* We can only handle full blocks for now */ + if ((enccrd->crd_len % AES_BLOCK_LEN) != 0) { + error = EINVAL; + goto out; + } + + rw_rlock(&sc->lock); + TAILQ_FOREACH_REVERSE(ses, &sc->sessions, armv8_crypto_sessions_head, + next) { + if (ses->id == (crp->crp_sid & 0xffffffff)) + break; + } + rw_runlock(&sc->lock); + if (ses == NULL) { + error = EINVAL; + goto out; + } + + error = armv8_crypto_cipher_process(ses, enccrd, crp); + +out: + crp->crp_etype = error; + crypto_done(crp); + return (error); +} + +static uint8_t * +armv8_crypto_cipher_alloc(struct cryptodesc *enccrd, struct cryptop *crp, + int *allocated) +{ + struct mbuf *m; + struct uio *uio; + struct iovec *iov; + uint8_t *addr; + + if (crp->crp_flags & CRYPTO_F_IMBUF) { + m = (struct mbuf *)crp->crp_buf; + if (m->m_next != NULL) + goto alloc; + addr = mtod(m, uint8_t *); + } else if (crp->crp_flags & CRYPTO_F_IOV) { + uio = (struct uio *)crp->crp_buf; + if (uio->uio_iovcnt != 1) + goto alloc; + iov = uio->uio_iov; + addr = (uint8_t *)iov->iov_base; + } else + addr = (uint8_t *)crp->crp_buf; + *allocated = 0; + addr += enccrd->crd_skip; + return (addr); + +alloc: + addr = malloc(enccrd->crd_len, M_ARMV8_CRYPTO, M_NOWAIT); + if (addr != NULL) { + *allocated = 1; + crypto_copydata(crp->crp_flags, crp->crp_buf, enccrd->crd_skip, + enccrd->crd_len, addr); + } else + *allocated = 0; + return (addr); +} + +static int +armv8_crypto_cipher_process(struct armv8_crypto_session *ses, + struct cryptodesc *enccrd, struct cryptop *crp) +{ + struct fpu_kern_ctx *ctx; + uint8_t *buf; + uint8_t iv[AES_BLOCK_LEN]; + int allocated, error, i; + int encflag, ivlen; + int kt; + + encflag = (enccrd->crd_flags & CRD_F_ENCRYPT) == CRD_F_ENCRYPT; + + buf = armv8_crypto_cipher_alloc(enccrd, crp, &allocated); + if (buf == NULL) + return (ENOMEM); + + error = 0; + + kt = is_fpu_kern_thread(0); + if (!kt) { + AQUIRE_CTX(i, ctx); + error = fpu_kern_enter(curthread, ctx, + FPU_KERN_NORMAL | FPU_KERN_KTHR); + if (error != 0) + goto out; + } + + if ((enccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) { + panic("CRD_F_KEY_EXPLICIT"); + } + + switch (enccrd->crd_alg) { + case CRYPTO_AES_CBC: + ivlen = AES_BLOCK_LEN; + break; + } + + /* Setup iv */ + if (encflag) { + if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0) + bcopy(enccrd->crd_iv, iv, ivlen); + else + arc4rand(iv, ivlen, 0); + + if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) + crypto_copyback(crp->crp_flags, crp->crp_buf, + enccrd->crd_inject, ivlen, iv); + } else { + if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0) + bcopy(enccrd->crd_iv, iv, ivlen); + else + crypto_copydata(crp->crp_flags, crp->crp_buf, + enccrd->crd_inject, ivlen, iv); + } + + /* Do work */ + switch (ses->algo) { + case CRYPTO_AES_CBC: + if (encflag) + armv8_aes_encrypt_cbc(ses->rounds, ses->enc_schedule, + enccrd->crd_len, buf, buf, iv); + else + armv8_aes_decrypt_cbc(ses->rounds, ses->dec_schedule, + enccrd->crd_len, buf, iv); + break; + } + + if (allocated) + crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip, + enccrd->crd_len, buf); + + if (!kt) { + fpu_kern_leave(curthread, ctx); +out: + RELEASE_CTX(i, ctx); + } + if (allocated) { + bzero(buf, enccrd->crd_len); + free(buf, M_ARMV8_CRYPTO); + } + return (error); +} + +static device_method_t armv8_crypto_methods[] = { + DEVMETHOD(device_identify, armv8_crypto_identify), + DEVMETHOD(device_probe, armv8_crypto_probe), + DEVMETHOD(device_attach, armv8_crypto_attach), + DEVMETHOD(device_detach, armv8_crypto_detach), + + DEVMETHOD(cryptodev_newsession, armv8_crypto_newsession), + DEVMETHOD(cryptodev_freesession, armv8_crypto_freesession), + DEVMETHOD(cryptodev_process, armv8_crypto_process), + + DEVMETHOD_END, +}; + +static DEFINE_CLASS_0(armv8crypto, armv8_crypto_driver, armv8_crypto_methods, + sizeof(struct armv8_crypto_softc)); +static devclass_t armv8_crypto_devclass; + +DRIVER_MODULE(armv8crypto, nexus, armv8_crypto_driver, armv8_crypto_devclass, + 0, 0); diff --git a/sys/crypto/armv8/armv8_crypto.h b/sys/crypto/armv8/armv8_crypto.h new file mode 100644 index 00000000000..32a2b210718 --- /dev/null +++ b/sys/crypto/armv8/armv8_crypto.h @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARMV8_CRYPTO_H_ +#define _ARMV8_CRYPTO_H_ + +#define AES128_ROUNDS 10 +#define AES192_ROUNDS 12 +#define AES256_ROUNDS 14 +#define AES_SCHED_LEN ((AES256_ROUNDS + 1) * AES_BLOCK_LEN) + +struct armv8_crypto_session { + uint32_t enc_schedule[AES_SCHED_LEN/4]; + uint32_t dec_schedule[AES_SCHED_LEN/4]; + int algo; + int rounds; + int used; + uint32_t id; + TAILQ_ENTRY(armv8_crypto_session) next; +}; + +void armv8_aes_encrypt_cbc(int, const void *, size_t, const uint8_t *, + uint8_t *, const uint8_t[static AES_BLOCK_LEN]); +void armv8_aes_decrypt_cbc(int, const void *, size_t, uint8_t *, + const uint8_t[static AES_BLOCK_LEN]); + +#endif /* _ARMV8_CRYPTO_H_ */ diff --git a/sys/crypto/armv8/armv8_crypto_wrap.c b/sys/crypto/armv8/armv8_crypto_wrap.c new file mode 100644 index 00000000000..643b2be2cb1 --- /dev/null +++ b/sys/crypto/armv8/armv8_crypto_wrap.c @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + */ + +/* + * This code is built with floating-point enabled. Make sure to have entered + * into floating-point context before calling any of these functions. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include + +#include + +static uint8x16_t +armv8_aes_enc(int rounds, const uint8x16_t *keysched, const uint8x16_t from) +{ + uint8x16_t tmp; + int i; + + tmp = from; + for (i = 0; i < rounds - 1; i += 2) { + tmp = vaeseq_u8(tmp, keysched[i]); + tmp = vaesmcq_u8(tmp); + tmp = vaeseq_u8(tmp, keysched[i + 1]); + tmp = vaesmcq_u8(tmp); + } + + tmp = vaeseq_u8(tmp, keysched[rounds - 1]); + tmp = vaesmcq_u8(tmp); + tmp = vaeseq_u8(tmp, keysched[rounds]); + tmp = veorq_u8(tmp, keysched[rounds + 1]); + + return (tmp); +} + +static uint8x16_t +armv8_aes_dec(int rounds, const uint8x16_t *keysched, const uint8x16_t from) +{ + uint8x16_t tmp; + int i; + + tmp = from; + for (i = 0; i < rounds - 1; i += 2) { + tmp = vaesdq_u8(tmp, keysched[i]); + tmp = vaesimcq_u8(tmp); + tmp = vaesdq_u8(tmp, keysched[i+1]); + tmp = vaesimcq_u8(tmp); + } + + tmp = vaesdq_u8(tmp, keysched[rounds - 1]); + tmp = vaesimcq_u8(tmp); + tmp = vaesdq_u8(tmp, keysched[rounds]); + tmp = veorq_u8(tmp, keysched[rounds + 1]); + + return (tmp); +} + +void +armv8_aes_encrypt_cbc(int rounds, const void *key_schedule, size_t len, + const uint8_t *from, uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN]) +{ + uint8x16_t tot, ivreg, tmp; + size_t i; + + len /= AES_BLOCK_LEN; + ivreg = vld1q_u8(iv); + for (i = 0; i < len; i++) { + tmp = vld1q_u8(from); + tot = armv8_aes_enc(rounds - 1, key_schedule, + veorq_u8(tmp, ivreg)); + ivreg = tot; + vst1q_u8(to, tot); + from += AES_BLOCK_LEN; + to += AES_BLOCK_LEN; + } +} + +void +armv8_aes_decrypt_cbc(int rounds, const void *key_schedule, size_t len, + uint8_t *buf, const uint8_t iv[static AES_BLOCK_LEN]) +{ + uint8x16_t ivreg, nextiv, tmp; + size_t i; + + len /= AES_BLOCK_LEN; + ivreg = vld1q_u8(iv); + for (i = 0; i < len; i++) { + nextiv = vld1q_u8(buf); + tmp = armv8_aes_dec(rounds - 1, key_schedule, nextiv); + vst1q_u8(buf, veorq_u8(tmp, ivreg)); + ivreg = nextiv; + buf += AES_BLOCK_LEN; + } +} diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 602f3da52b3..1718547d9fb 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -42,6 +42,7 @@ SUBDIR= \ ${_apm} \ ${_arcmsr} \ ${_arcnet} \ + ${_armv8crypto} \ ${_asmc} \ ata \ ath \ @@ -539,6 +540,7 @@ _cxgb= cxgb .endif .if ${MACHINE_CPUARCH} == "aarch64" +_armv8crypto= armv8crypto _em= em _igb= igb .endif diff --git a/sys/modules/armv8crypto/Makefile b/sys/modules/armv8crypto/Makefile new file mode 100644 index 00000000000..179d639d0e7 --- /dev/null +++ b/sys/modules/armv8crypto/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../crypto/armv8 + +KMOD= armv8crypto +SRCS= armv8_crypto.c +SRCS+= device_if.h bus_if.h opt_bus.h cryptodev_if.h + +OBJS+= armv8_crypto_wrap.o + +# Remove -nostdinc so we can get the intrinsics. +armv8_crypto_wrap.o: armv8_crypto_wrap.c + ${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc:N-mgeneral-regs-only} \ + ${WERROR} ${PROF} \ + -march=armv8a+crypto ${.IMPSRC} + ${CTFCONVERT_CMD} + +armv8_crypto_wrap.o: armv8_crypto.h + +.include From 0812ab314153800fe9cef48541c8ab8db2d01653 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 11:27:14 +0000 Subject: [PATCH 028/115] Add an arm64 specific uart cpu driver. As arm64 may use ACPI to find the uart we need to handle both it and FDT, and as such we need to have an architecture specific driver. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7796 --- sys/conf/files.arm64 | 2 +- sys/dev/uart/uart_cpu_arm64.c | 117 ++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 sys/dev/uart/uart_cpu_arm64.c diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 3f9a955d0a0..fa59c97edc7 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -157,7 +157,7 @@ dev/ofw/ofwpci.c optional fdt pci dev/pci/pci_host_generic.c optional pci fdt dev/psci/psci.c optional psci dev/psci/psci_arm64.S optional psci -dev/uart/uart_cpu_fdt.c optional uart fdt +dev/uart/uart_cpu_arm64.c optional uart dev/uart/uart_dev_pl011.c optional uart pl011 dev/usb/controller/dwc_otg_hisi.c optional dwcotg fdt soc_hisi_hi6220 dev/usb/controller/generic_ehci.c optional ehci acpi diff --git a/sys/dev/uart/uart_cpu_arm64.c b/sys/dev/uart/uart_cpu_arm64.c new file mode 100644 index 00000000000..36193414bf1 --- /dev/null +++ b/sys/dev/uart/uart_cpu_arm64.c @@ -0,0 +1,117 @@ +/*- + * Copyright (c) 2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under sponsorship from + * the FreeBSD Foundation. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + */ + +#include "opt_acpi.h" +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#ifdef FDT +#include +#include +#include +#include +#endif + +/* + * UART console routines. + */ +bus_space_tag_t uart_bus_space_io; +bus_space_tag_t uart_bus_space_mem; + +int +uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) +{ + + if (pmap_kextract(b1->bsh) == 0) + return (0); + if (pmap_kextract(b2->bsh) == 0) + return (0); + return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0); +} + +int +uart_cpu_getdev(int devtype, struct uart_devinfo *di) +{ + struct uart_class *class; + bus_space_handle_t bsh; + bus_space_tag_t bst; + u_int rclk, shift; + int br, err; + + /* Allow overriding the FDT using the environment. */ + class = &uart_ns8250_class; + err = uart_getenv(devtype, di, class); + if (err == 0) + return (0); + + if (devtype != UART_DEV_CONSOLE) + return (ENXIO); + + err = ENXIO; +#ifdef FDT + err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, &shift); +#endif + if (err != 0) + return (err); + + /* + * Finalize configuration. + */ + di->bas.chan = 0; + di->bas.regshft = shift; + di->baudrate = br; + di->bas.rclk = rclk; + di->ops = uart_getops(class); + di->databits = 8; + di->stopbits = 1; + di->parity = UART_PARITY_NONE; + di->bas.bst = bst; + di->bas.bsh = bsh; + uart_bus_space_mem = di->bas.bst; + uart_bus_space_io = NULL; + + return (0); +} From 250b1bf3c56d49318cba89f1a3eb2f6892824dde Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Mon, 21 Nov 2016 12:00:31 +0000 Subject: [PATCH 029/115] Disable superpages reservations as we don't have implemented them yet. Requested by: Alan Cox Sponsored by: DARPA, AFRL --- sys/riscv/include/vmparam.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h index 7ecd884f9da..faa3c1efa51 100644 --- a/sys/riscv/include/vmparam.h +++ b/sys/riscv/include/vmparam.h @@ -105,10 +105,10 @@ #define VM_NFREEORDER 12 /* - * Enable superpage reservations: 1 level. + * Disable superpage reservations. */ #ifndef VM_NRESERVLEVEL -#define VM_NRESERVLEVEL 1 +#define VM_NRESERVLEVEL 0 #endif /* From d27078f990785b7c64acc8a497cf7dffe24c74ab Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 21 Nov 2016 14:13:57 +0000 Subject: [PATCH 030/115] Adjust r308689 to make rtld compilable with either in-tree or (hopefully) stock gcc 4.2.1 on i386 and other arches. In particular: - Do not use %ebx in the asm constraints on i386, since rtld is compiled with -fPIC and gcc cannot handle GOT-base register reload (clang and newer gcc can). - Avoid direct use of [static N] construct in the function declaration/definion. In-tree gcc was patched to support this, but stock 4.2.1 cannot handle the feature. Requested by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/aarch64/reloc.c | 2 +- libexec/rtld-elf/amd64/reloc.c | 2 +- libexec/rtld-elf/arm/reloc.c | 2 +- libexec/rtld-elf/i386/reloc.c | 22 +++++++++++++++++----- libexec/rtld-elf/mips/reloc.c | 2 +- libexec/rtld-elf/powerpc/reloc.c | 2 +- libexec/rtld-elf/powerpc64/reloc.c | 2 +- libexec/rtld-elf/riscv/reloc.c | 2 +- libexec/rtld-elf/rtld.h | 2 +- libexec/rtld-elf/sparc64/reloc.c | 2 +- 10 files changed, 26 insertions(+), 14 deletions(-) diff --git a/libexec/rtld-elf/aarch64/reloc.c b/libexec/rtld-elf/aarch64/reloc.c index cff813ac805..3f9de07db29 100644 --- a/libexec/rtld-elf/aarch64/reloc.c +++ b/libexec/rtld-elf/aarch64/reloc.c @@ -300,7 +300,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj, } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 43e3ce969c5..10b933205c4 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -454,7 +454,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate) uint32_t cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2; void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { u_int p[4], cpu_high; diff --git a/libexec/rtld-elf/arm/reloc.c b/libexec/rtld-elf/arm/reloc.c index 94a9bf0e021..1b022c5a9d6 100644 --- a/libexec/rtld-elf/arm/reloc.c +++ b/libexec/rtld-elf/arm/reloc.c @@ -480,7 +480,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj, } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 8a405fbccb6..42efcf7a030 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -407,8 +406,21 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate) uint32_t cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2; +static void +rtld_cpuid_count(int idx, int cnt, u_int *p) +{ + + __asm __volatile( + " pushl %%ebx\n" + " cpuid\n" + " movl %%ebx,%1\n" + " popl %%ebx\n" + : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3]) + : "0" (idx), "2" (cnt)); +} + void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { u_int p[4], cpu_high; int cpuid_supported; @@ -432,13 +444,13 @@ ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) if (!cpuid_supported) return; - do_cpuid(1, p); + rtld_cpuid_count(1, 0, p); cpu_feature = p[3]; cpu_feature2 = p[2]; - do_cpuid(0, p); + rtld_cpuid_count(0, 0, p); cpu_high = p[0]; if (cpu_high >= 7) { - cpuid_count(7, 0, p); + rtld_cpuid_count(7, 0, p); cpu_stdext_feature = p[1]; cpu_stdext_feature2 = p[2]; } diff --git a/libexec/rtld-elf/mips/reloc.c b/libexec/rtld-elf/mips/reloc.c index 4f3d5c450d1..fef1d71a18b 100644 --- a/libexec/rtld-elf/mips/reloc.c +++ b/libexec/rtld-elf/mips/reloc.c @@ -618,7 +618,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj, } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index e76da987f21..dea564b0dc4 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -620,7 +620,7 @@ init_pltgot(Obj_Entry *obj) } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/powerpc64/reloc.c b/libexec/rtld-elf/powerpc64/reloc.c index 6a09185b73a..e6198f0de85 100644 --- a/libexec/rtld-elf/powerpc64/reloc.c +++ b/libexec/rtld-elf/powerpc64/reloc.c @@ -524,7 +524,7 @@ init_pltgot(Obj_Entry *obj) } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/riscv/reloc.c b/libexec/rtld-elf/riscv/reloc.c index 5da0bd17566..71259cd629c 100644 --- a/libexec/rtld-elf/riscv/reloc.c +++ b/libexec/rtld-elf/riscv/reloc.c @@ -367,7 +367,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 99b56c12959..afdf83a51fe 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -367,7 +367,7 @@ void dump_Elf_Rela(Obj_Entry *, const Elf_Rela *, u_long); unsigned long elf_hash(const char *); const Elf_Sym *find_symdef(unsigned long, const Obj_Entry *, const Obj_Entry **, int, SymCache *, struct Struct_RtldLockState *); -void ifunc_init(Elf_Auxinfo[static AT_COUNT]); +void ifunc_init(Elf_Auxinfo[__min_size(AT_COUNT)]); void init_pltgot(Obj_Entry *); void lockdflt_init(void); void digest_notes(Obj_Entry *, Elf_Addr, Elf_Addr); diff --git a/libexec/rtld-elf/sparc64/reloc.c b/libexec/rtld-elf/sparc64/reloc.c index 981eea502b8..197c66c8627 100644 --- a/libexec/rtld-elf/sparc64/reloc.c +++ b/libexec/rtld-elf/sparc64/reloc.c @@ -787,7 +787,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj, } void -ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused) +ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused) { } From cb3c7e7f93be3ea8f175778308abc342ac0fb35c Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 21 Nov 2016 14:43:31 +0000 Subject: [PATCH 031/115] Add Intel Atom Cherryview SOC HSUART support PR: 207910 Submitted by: johannes@brilliantservice.co.jp MFC after: 1 week --- sys/dev/uart/uart_bus_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index 41662226f27..2203c3f2d66 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -128,6 +128,10 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 }, { 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x1e3d, 0xffff, 0, "Intel Panther Point KT Controller", 0x10 }, +{ 0x8086, 0x228a, 0xffff, 0, "Intel Cherryview SIO HSUART#1", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x228c, 0xffff, 0, "Intel Cherryview SIO HSUART#2", 0x10, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x2a07, 0xffff, 0, "Intel AMT - PM965/GM965 KT Controller", 0x10 }, { 0x8086, 0x2a47, 0xffff, 0, "Mobile 4 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, From 38079cf5724208a0fd682e1c0c1598e8e5974fef Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Mon, 21 Nov 2016 15:35:56 +0000 Subject: [PATCH 032/115] Move FDT option to the main SoC file and mark boards config as NO_UNIVERSE. Pointed out by: andrew Sponsored by: DARPA, AFRL --- sys/mips/conf/CANNA | 3 ++- sys/mips/conf/CI20 | 4 ++-- sys/mips/conf/JZ4780 | 5 +++++ sys/mips/conf/X1000 | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/mips/conf/CANNA b/sys/mips/conf/CANNA index 0d6f81b52c3..b5117f8beda 100644 --- a/sys/mips/conf/CANNA +++ b/sys/mips/conf/CANNA @@ -2,10 +2,11 @@ # # $FreeBSD$ +#NO_UNIVERSE + include "X1000" ident CANNA -options FDT options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=ingenic/canna.dts diff --git a/sys/mips/conf/CI20 b/sys/mips/conf/CI20 index 9d1940d85e8..fef340c15d7 100644 --- a/sys/mips/conf/CI20 +++ b/sys/mips/conf/CI20 @@ -2,10 +2,11 @@ # # $FreeBSD$ +#NO_UNIVERSE + include "JZ4780" ident CI20 -options FDT options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=ingenic/ci20.dts @@ -27,5 +28,4 @@ options ROOTDEVNAME=\"ufs:mmcsd0\" makeoptions TRAMPLOADADDR=0x88000000 #options VERBOSE_SYSINIT -device dme options PRINTF_BUFR_SIZE=256 diff --git a/sys/mips/conf/JZ4780 b/sys/mips/conf/JZ4780 index 2b7335af226..53986b2b9ba 100644 --- a/sys/mips/conf/JZ4780 +++ b/sys/mips/conf/JZ4780 @@ -78,6 +78,8 @@ device da device mmc device mmcsd +device dme + # USB support options USB_DEBUG # enable debug msgs options USB_HOST_ALIGN=128 # L2 cache line size @@ -90,3 +92,6 @@ device uhid # "Human Interface Devices" #device ulpt # Printer device umass # Disks/Mass storage - Requires scbus and da device ums # Mouse + +# FDT support +options FDT diff --git a/sys/mips/conf/X1000 b/sys/mips/conf/X1000 index 8659f1112e4..035a540f73c 100644 --- a/sys/mips/conf/X1000 +++ b/sys/mips/conf/X1000 @@ -87,3 +87,6 @@ device mmcsd #device ulpt # Printer #device umass # Disks/Mass storage - Requires scbus and da #device ums # Mouse + +# FDT support +options FDT From fbe94797ea59224457adfbc56de7cb50ca1b3f84 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Mon, 21 Nov 2016 15:42:54 +0000 Subject: [PATCH 033/115] Add PDMA controller registers. Obtained from: X1000 IoT Application Processor Programming Manual Sponsored by: DARPA, AFRL --- sys/mips/ingenic/jz4780_pdma.h | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sys/mips/ingenic/jz4780_pdma.h diff --git a/sys/mips/ingenic/jz4780_pdma.h b/sys/mips/ingenic/jz4780_pdma.h new file mode 100644 index 00000000000..8edb9d93c39 --- /dev/null +++ b/sys/mips/ingenic/jz4780_pdma.h @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * $FreeBSD$ + */ + +/* DMA Channel Registers */ +#define PDMA_DSA(n) (0x00 + 0x20 * n) /* Channel n Source Address */ +#define PDMA_DTA(n) (0x04 + 0x20 * n) /* Channel n Target Address */ +#define PDMA_DTC(n) (0x08 + 0x20 * n) /* Channel n Transfer Count */ +#define PDMA_DRT(n) (0x0C + 0x20 * n) /* Channel n Request Source */ +#define PDMA_DCS(n) (0x10 + 0x20 * n) /* Channel n Control/Status */ +#define PDMA_DCM(n) (0x14 + 0x20 * n) /* Channel n Command */ +#define PDMA_DDA(n) (0x18 + 0x20 * n) /* Channel n Descriptor Address */ +#define PDMA_DSD(n) (0x1C + 0x20 * n) /* Channel n Stride Difference */ + +/* Global Control Registers */ +#define PDMA_DMAC 0x1000 /* DMA Control */ +#define PDMA_DIRQP 0x1004 /* DMA Interrupt Pending */ +#define PDMA_DDB 0x1008 /* DMA Doorbell */ +#define PDMA_DDS 0x100C /* DMA Doorbell Set */ +#define PDMA_DIP 0x1010 /* Descriptor Interrupt Pending */ +#define PDMA_DIC 0x1014 /* Descriptor Interrupt Clear */ +#define PDMA_DMACP 0x101C /* DMA Channel Programmable */ +#define PDMA_DSIRQP 0x1020 /* Channel soft IRQ to MCU */ +#define PDMA_DSIRQM 0x1024 /* Channel soft IRQ mask */ +#define PDMA_DCIRQP 0x1028 /* Channel IRQ to MCU */ +#define PDMA_DCIRQM 0x102C /* Channel IRQ to MCU mask */ +#define PDMA_DMCS 0x1030 /* MCU Control and Status */ +#define PDMA_DMNMB 0x1034 /* MCU Normal Mailbox */ +#define PDMA_DMSMB 0x1038 /* MCU Security Mailbox */ +#define PDMA_DMINT 0x103C /* MCU Interrupt */ + +struct pdma_hwdesc { + uint32_t dcm; /* DMA Channel Command */ + uint32_t dsa; /* DMA Source Address */ + uint32_t dta; /* DMA Target Address */ + uint32_t dtc; /* DMA Transfer Counter */ + uint32_t sd; /* Stride Address */ + uint32_t drt; /* DMA Request Type */ + uint32_t reserved[2]; +}; From f94f8e62ab96dabeda86cc03cb6a011e52398a0d Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 18:24:05 +0000 Subject: [PATCH 034/115] To allow for an ACPI attachment to the generic PCIe driver split off the FDT attachment to a new file. A separate ACPI attachment will then be added to allow arm64 servers with ACPI to use it over FDT. This should also help with merging this with the ofwpci driver, with further work needed to remove restrictions this driver places on resource allocation. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7319 --- sys/arm/annapurna/alpine/alpine_pci.c | 3 +- sys/arm64/cavium/thunder_pcie_common.c | 3 + sys/arm64/cavium/thunder_pcie_fdt.c | 9 +- sys/conf/files.arm | 3 +- sys/conf/files.arm64 | 5 +- sys/dev/pci/pci_host_generic.c | 639 ++---------------------- sys/dev/pci/pci_host_generic.h | 17 +- sys/dev/pci/pci_host_generic_fdt.c | 641 +++++++++++++++++++++++++ sys/dev/pci/pci_host_generic_fdt.h | 49 ++ 9 files changed, 745 insertions(+), 624 deletions(-) create mode 100644 sys/dev/pci/pci_host_generic_fdt.c create mode 100644 sys/dev/pci/pci_host_generic_fdt.h diff --git a/sys/arm/annapurna/alpine/alpine_pci.c b/sys/arm/annapurna/alpine/alpine_pci.c index 4d507260579..043ae19e0cb 100644 --- a/sys/arm/annapurna/alpine/alpine_pci.c +++ b/sys/arm/annapurna/alpine/alpine_pci.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -79,7 +80,7 @@ static device_method_t al_pcib_methods[] = { }; DEFINE_CLASS_1(pcib, al_pcib_driver, al_pcib_methods, - sizeof(struct generic_pcie_softc), generic_pcie_driver); + sizeof(struct generic_pcie_fdt_softc), generic_pcie_fdt_driver); static devclass_t anpa_pcib_devclass; diff --git a/sys/arm64/cavium/thunder_pcie_common.c b/sys/arm64/cavium/thunder_pcie_common.c index a852222f868..b9244648a80 100644 --- a/sys/arm64/cavium/thunder_pcie_common.c +++ b/sys/arm64/cavium/thunder_pcie_common.c @@ -58,6 +58,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef FDT +#include +#endif #include "thunder_pcie_common.h" diff --git a/sys/arm64/cavium/thunder_pcie_fdt.c b/sys/arm64/cavium/thunder_pcie_fdt.c index e55e6ed9794..58b334e75e3 100644 --- a/sys/arm64/cavium/thunder_pcie_fdt.c +++ b/sys/arm64/cavium/thunder_pcie_fdt.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "thunder_pcie_common.h" @@ -80,7 +81,7 @@ static device_method_t thunder_pcie_fdt_methods[] = { }; DEFINE_CLASS_1(pcib, thunder_pcie_fdt_driver, thunder_pcie_fdt_methods, - sizeof(struct generic_pcie_softc), generic_pcie_driver); + sizeof(struct generic_pcie_fdt_softc), generic_pcie_fdt_driver); static devclass_t thunder_pcie_fdt_devclass; @@ -115,11 +116,11 @@ thunder_pcie_fdt_probe(device_t dev) static int thunder_pcie_fdt_attach(device_t dev) { - struct generic_pcie_softc *sc; + struct generic_pcie_fdt_softc *sc; sc = device_get_softc(dev); - thunder_pcie_identify_ecam(dev, &sc->ecam); - sc->coherent = 1; + thunder_pcie_identify_ecam(dev, &sc->base.ecam); + sc->base.coherent = 1; return (pci_host_generic_attach(dev)); } diff --git a/sys/conf/files.arm b/sys/conf/files.arm index c4c0f0aa477..e5207ba0735 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -124,7 +124,8 @@ dev/hwpmc/hwpmc_arm.c optional hwpmc dev/hwpmc/hwpmc_armv7.c optional hwpmc armv6 dev/iicbus/twsi/twsi.c optional twsi dev/ofw/ofwpci.c optional fdt pci -dev/pci/pci_host_generic.c optional pci_host_generic pci fdt +dev/pci/pci_host_generic.c optional pci_host_generic pci +dev/pci/pci_host_generic_fdt.c optional pci_host_generic pci fdt dev/psci/psci.c optional psci dev/psci/psci_arm.S optional psci dev/syscons/scgfbrndr.c optional sc diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index fa59c97edc7..cc1daacd224 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -154,8 +154,9 @@ dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc fdt soc_hisi_hi6220 dev/ofw/ofw_cpu.c optional fdt dev/ofw/ofwpci.c optional fdt pci -dev/pci/pci_host_generic.c optional pci fdt -dev/psci/psci.c optional psci +dev/pci/pci_host_generic.c optional pci +dev/pci/pci_host_generic_fdt.c optional pci fdt +dev/psci/psci.c optional psci fdt dev/psci/psci_arm64.S optional psci dev/uart/uart_cpu_arm64.c optional uart dev/uart/uart_dev_pl011.c optional uart pl011 diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index ed26b08ed8e..54b5dbd9dff 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -43,26 +43,14 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include -#if defined(INTRNG) -#include -#endif - -#include -#include -#include -#include #include #include #include #include -#include #include #include -#include #include "pcib_if.h" @@ -81,24 +69,8 @@ __FBSDID("$FreeBSD$"); (((func) & PCIE_FUNC_MASK) << PCIE_FUNC_SHIFT) | \ ((reg) & PCIE_REG_MASK)) -#define PCI_IO_WINDOW_OFFSET 0x1000 - -#define SPACE_CODE_SHIFT 24 -#define SPACE_CODE_MASK 0x3 -#define SPACE_CODE_IO_SPACE 0x1 -#define PROPS_CELL_SIZE 1 -#define PCI_ADDR_CELL_SIZE 2 - -/* OFW bus interface */ -struct generic_pcie_ofw_devinfo { - struct ofw_bus_devinfo di_dinfo; - struct resource_list di_rl; -}; - /* Forward prototypes */ -static int generic_pcie_probe(device_t dev); -static int parse_pci_mem_ranges(struct generic_pcie_softc *sc); static uint32_t generic_pcie_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes); static void generic_pcie_write_config(device_t dev, u_int bus, u_int slot, @@ -108,87 +80,17 @@ static int generic_pcie_read_ivar(device_t dev, device_t child, int index, uintptr_t *result); static int generic_pcie_write_ivar(device_t dev, device_t child, int index, uintptr_t value); -static struct resource *generic_pcie_alloc_resource_ofw(device_t, device_t, - int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static struct resource *generic_pcie_alloc_resource_pcie(device_t dev, - device_t child, int type, int *rid, rman_res_t start, rman_res_t end, - rman_res_t count, u_int flags); -static int generic_pcie_release_resource(device_t dev, device_t child, - int type, int rid, struct resource *res); -static int generic_pcie_release_resource_ofw(device_t, device_t, int, int, - struct resource *); -static int generic_pcie_release_resource_pcie(device_t, device_t, int, int, - struct resource *); -static int generic_pcie_ofw_bus_attach(device_t); -static const struct ofw_bus_devinfo *generic_pcie_ofw_get_devinfo(device_t, - device_t); - -static __inline void -get_addr_size_cells(phandle_t node, pcell_t *addr_cells, pcell_t *size_cells) -{ - - *addr_cells = 2; - /* Find address cells if present */ - OF_getencprop(node, "#address-cells", addr_cells, sizeof(*addr_cells)); - - *size_cells = 2; - /* Find size cells if present */ - OF_getencprop(node, "#size-cells", size_cells, sizeof(*size_cells)); -} - -static int -generic_pcie_probe(device_t dev) -{ - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (ofw_bus_is_compatible(dev, "pci-host-ecam-generic")) { - device_set_desc(dev, "Generic PCI host controller"); - return (BUS_PROBE_GENERIC); - } - if (ofw_bus_is_compatible(dev, "arm,gem5_pcie")) { - device_set_desc(dev, "GEM5 PCIe host controller"); - return (BUS_PROBE_DEFAULT); - } - - return (ENXIO); -} int -pci_host_generic_attach(device_t dev) +pci_host_generic_core_attach(device_t dev) { - struct generic_pcie_softc *sc; - uint64_t phys_base; - uint64_t pci_base; - uint64_t size; - phandle_t node; + struct generic_pcie_core_softc *sc; int error; - int tuple; int rid; sc = device_get_softc(dev); sc->dev = dev; - /* Retrieve 'ranges' property from FDT */ - if (bootverbose) - device_printf(dev, "parsing FDT for ECAM%d:\n", - sc->ecam); - if (parse_pci_mem_ranges(sc)) - return (ENXIO); - - /* Attach OFW bus */ - if (generic_pcie_ofw_bus_attach(dev) != 0) - return (ENXIO); - - node = ofw_bus_get_node(dev); - if (sc->coherent == 0) { - sc->coherent = OF_hasprop(node, "dma-coherent"); - } - if (bootverbose) - device_printf(dev, "Bus is%s cache-coherent\n", - sc->coherent ? "" : " not"); - /* Create the parent DMA tag to pass down the coherent flag */ error = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ 1, 0, /* alignment, bounds */ @@ -232,111 +134,6 @@ pci_host_generic_attach(device_t dev) return (error); } - for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) { - phys_base = sc->ranges[tuple].phys_base; - pci_base = sc->ranges[tuple].pci_base; - size = sc->ranges[tuple].size; - if (phys_base == 0 || size == 0) - continue; /* empty range element */ - if (sc->ranges[tuple].flags & FLAG_MEM) { - error = rman_manage_region(&sc->mem_rman, - phys_base, phys_base + size - 1); - } else if (sc->ranges[tuple].flags & FLAG_IO) { - error = rman_manage_region(&sc->io_rman, - pci_base + PCI_IO_WINDOW_OFFSET, - pci_base + PCI_IO_WINDOW_OFFSET + size - 1); - } else - continue; - if (error) { - device_printf(dev, "rman_manage_region() failed." - "error = %d\n", error); - rman_fini(&sc->mem_rman); - return (error); - } - } - - ofw_bus_setup_iinfo(node, &sc->pci_iinfo, sizeof(cell_t)); - - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); -} - -static int -parse_pci_mem_ranges(struct generic_pcie_softc *sc) -{ - pcell_t pci_addr_cells, parent_addr_cells; - pcell_t attributes, size_cells; - cell_t *base_ranges; - int nbase_ranges; - phandle_t node; - int i, j, k; - int tuple; - - node = ofw_bus_get_node(sc->dev); - - OF_getencprop(node, "#address-cells", &pci_addr_cells, - sizeof(pci_addr_cells)); - OF_getencprop(node, "#size-cells", &size_cells, - sizeof(size_cells)); - OF_getencprop(OF_parent(node), "#address-cells", &parent_addr_cells, - sizeof(parent_addr_cells)); - - if (parent_addr_cells > 2 || pci_addr_cells != 3 || size_cells > 2) { - device_printf(sc->dev, - "Unexpected number of address or size cells in FDT\n"); - return (ENXIO); - } - - nbase_ranges = OF_getproplen(node, "ranges"); - sc->nranges = nbase_ranges / sizeof(cell_t) / - (parent_addr_cells + pci_addr_cells + size_cells); - base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK); - OF_getencprop(node, "ranges", base_ranges, nbase_ranges); - - for (i = 0, j = 0; i < sc->nranges; i++) { - attributes = (base_ranges[j++] >> SPACE_CODE_SHIFT) & \ - SPACE_CODE_MASK; - if (attributes == SPACE_CODE_IO_SPACE) { - sc->ranges[i].flags |= FLAG_IO; - } else { - sc->ranges[i].flags |= FLAG_MEM; - } - - sc->ranges[i].pci_base = 0; - for (k = 0; k < (pci_addr_cells - 1); k++) { - sc->ranges[i].pci_base <<= 32; - sc->ranges[i].pci_base |= base_ranges[j++]; - } - sc->ranges[i].phys_base = 0; - for (k = 0; k < parent_addr_cells; k++) { - sc->ranges[i].phys_base <<= 32; - sc->ranges[i].phys_base |= base_ranges[j++]; - } - sc->ranges[i].size = 0; - for (k = 0; k < size_cells; k++) { - sc->ranges[i].size <<= 32; - sc->ranges[i].size |= base_ranges[j++]; - } - } - - for (; i < MAX_RANGES_TUPLES; i++) { - /* zero-fill remaining tuples to mark empty elements in array */ - sc->ranges[i].pci_base = 0; - sc->ranges[i].phys_base = 0; - sc->ranges[i].size = 0; - } - - if (bootverbose) { - for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) { - device_printf(sc->dev, - "\tPCI addr: 0x%jx, CPU addr: 0x%jx, Size: 0x%jx\n", - sc->ranges[tuple].pci_base, - sc->ranges[tuple].phys_base, - sc->ranges[tuple].size); - } - } - - free(base_ranges, M_DEVBUF); return (0); } @@ -344,7 +141,7 @@ static uint32_t generic_pcie_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; bus_space_handle_t h; bus_space_tag_t t; uint64_t offset; @@ -381,7 +178,7 @@ static void generic_pcie_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int bytes) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; bus_space_handle_t h; bus_space_tag_t t; uint64_t offset; @@ -419,42 +216,11 @@ generic_pcie_maxslots(device_t dev) return (31); /* max slots per bus acc. to standard */ } -static int -generic_pcie_route_interrupt(device_t bus, device_t dev, int pin) -{ - struct generic_pcie_softc *sc; - struct ofw_pci_register reg; - uint32_t pintr, mintr[2]; - phandle_t iparent; - int intrcells; - - sc = device_get_softc(bus); - pintr = pin; - - bzero(®, sizeof(reg)); - reg.phys_hi = (pci_get_bus(dev) << OFW_PCI_PHYS_HI_BUSSHIFT) | - (pci_get_slot(dev) << OFW_PCI_PHYS_HI_DEVICESHIFT) | - (pci_get_function(dev) << OFW_PCI_PHYS_HI_FUNCTIONSHIFT); - - intrcells = ofw_bus_lookup_imap(ofw_bus_get_node(dev), - &sc->pci_iinfo, ®, sizeof(reg), &pintr, sizeof(pintr), - mintr, sizeof(mintr), &iparent); - if (intrcells) { - pintr = ofw_bus_map_intr(dev, iparent, intrcells, mintr); - return (pintr); - } - - device_printf(bus, "could not route pin %d for device %d.%d\n", - pin, pci_get_slot(dev), pci_get_function(dev)); - return (PCI_INVALID_IRQ); -} - - static int generic_pcie_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; int secondary_bus; sc = device_get_softc(dev); @@ -486,7 +252,7 @@ generic_pcie_write_ivar(device_t dev, device_t child, int index, } static struct rman * -generic_pcie_rman(struct generic_pcie_softc *sc, int type) +generic_pcie_rman(struct generic_pcie_core_softc *sc, int type) { switch (type) { @@ -501,15 +267,21 @@ generic_pcie_rman(struct generic_pcie_softc *sc, int type) return (NULL); } -static int -generic_pcie_release_resource_pcie(device_t dev, device_t child, int type, +int +pci_host_generic_core_release_resource(device_t dev, device_t child, int type, int rid, struct resource *res) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; struct rman *rm; sc = device_get_softc(dev); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) { + return (pci_domain_release_bus(sc->ecam, child, rid, res)); + } +#endif + rm = generic_pcie_rman(sc, type); if (rm != NULL) { KASSERT(rman_is_region_manager(res, rm), ("rman mismatch")); @@ -519,62 +291,23 @@ generic_pcie_release_resource_pcie(device_t dev, device_t child, int type, return (bus_generic_release_resource(dev, child, type, rid, res)); } -static int -generic_pcie_release_resource(device_t dev, device_t child, int type, - int rid, struct resource *res) -{ -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - struct generic_pcie_softc *sc; - - if (type == PCI_RES_BUS) { - sc = device_get_softc(dev); - return (pci_domain_release_bus(sc->ecam, child, rid, res)); - } -#endif - /* For PCIe devices that do not have FDT nodes, use PCIB method */ - if ((int)ofw_bus_get_node(child) <= 0) { - return (generic_pcie_release_resource_pcie(dev, - child, type, rid, res)); - } - - /* For other devices use OFW method */ - return (generic_pcie_release_resource_ofw(dev, - child, type, rid, res)); -} - struct resource * -pci_host_generic_alloc_resource(device_t dev, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) +pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type, + int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - struct generic_pcie_softc *sc; - - if (type == PCI_RES_BUS) { - sc = device_get_softc(dev); - return (pci_domain_alloc_bus(sc->ecam, child, rid, start, end, - count, flags)); - } -#endif - /* For PCIe devices that do not have FDT nodes, use PCIB method */ - if ((int)ofw_bus_get_node(child) <= 0) - return (generic_pcie_alloc_resource_pcie(dev, child, type, rid, - start, end, count, flags)); - - /* For other devices use OFW method */ - return (generic_pcie_alloc_resource_ofw(dev, child, type, rid, - start, end, count, flags)); -} - -static struct resource * -generic_pcie_alloc_resource_pcie(device_t dev, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; struct resource *res; struct rman *rm; sc = device_get_softc(dev); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) { + return (pci_domain_alloc_bus(sc->ecam, child, rid, start, end, + count, flags)); + } +#endif + rm = generic_pcie_rman(sc, type); if (rm == NULL) return (BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, @@ -612,7 +345,7 @@ static int generic_pcie_adjust_resource(device_t dev, device_t child, int type, struct resource *res, rman_res_t start, rman_res_t end) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; struct rman *rm; sc = device_get_softc(dev); @@ -628,194 +361,22 @@ generic_pcie_adjust_resource(device_t dev, device_t child, int type, return (bus_generic_adjust_resource(dev, child, type, res, start, end)); } -static int -generic_pcie_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct generic_pcie_softc *sc; - uint64_t phys_base; - uint64_t pci_base; - uint64_t size; - int found; - int res; - int i; - - sc = device_get_softc(dev); - - if ((res = rman_activate_resource(r)) != 0) - return (res); - - switch(type) { - case SYS_RES_IOPORT: - found = 0; - for (i = 0; i < MAX_RANGES_TUPLES; i++) { - pci_base = sc->ranges[i].pci_base; - phys_base = sc->ranges[i].phys_base; - size = sc->ranges[i].size; - - if ((rid > pci_base) && (rid < (pci_base + size))) { - found = 1; - break; - } - } - if (found) { - rman_set_start(r, rman_get_start(r) + phys_base); - rman_set_end(r, rman_get_end(r) + phys_base); - BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, - type, rid, r); - } else { - device_printf(dev, "Failed to activate IOPORT resource\n"); - res = 0; - } - break; - case SYS_RES_MEMORY: - BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r); - break; - default: - break; - } - - return (res); -} - -static int -generic_pcie_deactivate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct generic_pcie_softc *sc; - vm_offset_t vaddr; - int res; - - sc = device_get_softc(dev); - - if ((res = rman_deactivate_resource(r)) != 0) - return (res); - - switch(type) { - case SYS_RES_IOPORT: - case SYS_RES_MEMORY: - vaddr = (vm_offset_t)rman_get_virtual(r); - pmap_unmapdev(vaddr, rman_get_size(r)); - break; - default: - break; - } - - return (res); -} - static bus_dma_tag_t generic_pcie_get_dma_tag(device_t dev, device_t child) { - struct generic_pcie_softc *sc; + struct generic_pcie_core_softc *sc; sc = device_get_softc(dev); return (sc->dmat); } -static int -generic_pcie_alloc_msi(device_t pci, device_t child, int count, int maxcount, - int *irqs) -{ -#if defined(INTRNG) - phandle_t msi_parent; - - ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, - NULL); - return (intr_alloc_msi(pci, child, msi_parent, count, maxcount, - irqs)); -#else - return (ENXIO); -#endif -} - -static int -generic_pcie_release_msi(device_t pci, device_t child, int count, int *irqs) -{ -#if defined(INTRNG) - phandle_t msi_parent; - - ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, - NULL); - return (intr_release_msi(pci, child, msi_parent, count, irqs)); -#else - return (ENXIO); -#endif -} - -static int -generic_pcie_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, - uint32_t *data) -{ -#if defined(INTRNG) - phandle_t msi_parent; - - ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, - NULL); - return (intr_map_msi(pci, child, msi_parent, irq, addr, data)); -#else - return (ENXIO); -#endif -} - -static int -generic_pcie_alloc_msix(device_t pci, device_t child, int *irq) -{ -#if defined(INTRNG) - phandle_t msi_parent; - - ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, - NULL); - return (intr_alloc_msix(pci, child, msi_parent, irq)); -#else - return (ENXIO); -#endif -} - -static int -generic_pcie_release_msix(device_t pci, device_t child, int irq) -{ -#if defined(INTRNG) - phandle_t msi_parent; - - ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, - NULL); - return (intr_release_msix(pci, child, msi_parent, irq)); -#else - return (ENXIO); -#endif -} - -int -generic_pcie_get_id(device_t pci, device_t child, enum pci_id_type type, - uintptr_t *id) -{ - phandle_t node; - uint32_t rid; - uint16_t pci_rid; - - if (type != PCI_ID_MSI) - return (pcib_get_id(pci, child, type, id)); - - node = ofw_bus_get_node(pci); - pci_rid = pci_get_rid(child); - - ofw_bus_msimap(node, pci_rid, NULL, &rid); - *id = rid; - - return (0); -} - static device_method_t generic_pcie_methods[] = { - DEVMETHOD(device_probe, generic_pcie_probe), - DEVMETHOD(device_attach, pci_host_generic_attach), + DEVMETHOD(device_attach, pci_host_generic_core_attach), DEVMETHOD(bus_read_ivar, generic_pcie_read_ivar), DEVMETHOD(bus_write_ivar, generic_pcie_write_ivar), - DEVMETHOD(bus_alloc_resource, pci_host_generic_alloc_resource), + DEVMETHOD(bus_alloc_resource, pci_host_generic_core_alloc_resource), DEVMETHOD(bus_adjust_resource, generic_pcie_adjust_resource), - DEVMETHOD(bus_release_resource, generic_pcie_release_resource), - DEVMETHOD(bus_activate_resource, generic_pcie_activate_resource), - DEVMETHOD(bus_deactivate_resource, generic_pcie_deactivate_resource), + DEVMETHOD(bus_release_resource, pci_host_generic_core_release_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), @@ -823,147 +384,11 @@ static device_method_t generic_pcie_methods[] = { /* pcib interface */ DEVMETHOD(pcib_maxslots, generic_pcie_maxslots), - DEVMETHOD(pcib_route_interrupt, generic_pcie_route_interrupt), DEVMETHOD(pcib_read_config, generic_pcie_read_config), DEVMETHOD(pcib_write_config, generic_pcie_write_config), - DEVMETHOD(pcib_alloc_msi, generic_pcie_alloc_msi), - DEVMETHOD(pcib_release_msi, generic_pcie_release_msi), - DEVMETHOD(pcib_alloc_msix, generic_pcie_alloc_msix), - DEVMETHOD(pcib_release_msix, generic_pcie_release_msix), - DEVMETHOD(pcib_map_msi, generic_pcie_map_msi), - DEVMETHOD(pcib_get_id, generic_pcie_get_id), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, generic_pcie_ofw_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), DEVMETHOD_END }; -static const struct ofw_bus_devinfo * -generic_pcie_ofw_get_devinfo(device_t bus __unused, device_t child) -{ - struct generic_pcie_ofw_devinfo *di; - - di = device_get_ivars(child); - return (&di->di_dinfo); -} - -static struct resource * -generic_pcie_alloc_resource_ofw(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct generic_pcie_softc *sc; - struct generic_pcie_ofw_devinfo *di; - struct resource_list_entry *rle; - int i; - - sc = device_get_softc(bus); - - if (RMAN_IS_DEFAULT_RANGE(start, end)) { - if ((di = device_get_ivars(child)) == NULL) - return (NULL); - if (type == SYS_RES_IOPORT) - type = SYS_RES_MEMORY; - - /* Find defaults for this rid */ - rle = resource_list_find(&di->di_rl, type, *rid); - if (rle == NULL) - return (NULL); - - start = rle->start; - end = rle->end; - count = rle->count; - } - - if (type == SYS_RES_MEMORY) { - /* Remap through ranges property */ - for (i = 0; i < MAX_RANGES_TUPLES; i++) { - if (start >= sc->ranges[i].phys_base && end < - sc->ranges[i].pci_base + sc->ranges[i].size) { - start -= sc->ranges[i].phys_base; - start += sc->ranges[i].pci_base; - end -= sc->ranges[i].phys_base; - end += sc->ranges[i].pci_base; - break; - } - } - - if (i == MAX_RANGES_TUPLES) { - device_printf(bus, "Could not map resource " - "%#jx-%#jx\n", start, end); - return (NULL); - } - } - - return (bus_generic_alloc_resource(bus, child, type, rid, start, end, - count, flags)); -} - -static int -generic_pcie_release_resource_ofw(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - return (bus_generic_release_resource(bus, child, type, rid, res)); -} - -/* Helper functions */ - -static int -generic_pcie_ofw_bus_attach(device_t dev) -{ - struct generic_pcie_ofw_devinfo *di; - device_t child; - phandle_t parent, node; - pcell_t addr_cells, size_cells; - - parent = ofw_bus_get_node(dev); - if (parent > 0) { - get_addr_size_cells(parent, &addr_cells, &size_cells); - /* Iterate through all bus subordinates */ - for (node = OF_child(parent); node > 0; node = OF_peer(node)) { - - /* Allocate and populate devinfo. */ - di = malloc(sizeof(*di), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&di->di_dinfo, node) != 0) { - free(di, M_DEVBUF); - continue; - } - - /* Initialize and populate resource list. */ - resource_list_init(&di->di_rl); - ofw_bus_reg_to_rl(dev, node, addr_cells, size_cells, - &di->di_rl); - ofw_bus_intr_to_rl(dev, node, &di->di_rl, NULL); - - /* Add newbus device for this FDT node */ - child = device_add_child(dev, NULL, -1); - if (child == NULL) { - resource_list_free(&di->di_rl); - ofw_bus_gen_destroy_devinfo(&di->di_dinfo); - free(di, M_DEVBUF); - continue; - } - - device_set_ivars(child, di); - } - } - - return (0); -} - -DEFINE_CLASS_0(pcib, generic_pcie_driver, - generic_pcie_methods, sizeof(struct generic_pcie_softc)); - -devclass_t generic_pcie_devclass; - -DRIVER_MODULE(pcib, simplebus, generic_pcie_driver, - generic_pcie_devclass, 0, 0); -DRIVER_MODULE(pcib, ofwbus, generic_pcie_driver, - generic_pcie_devclass, 0, 0); - +DEFINE_CLASS_0(pcib, generic_pcie_core_driver, + generic_pcie_methods, sizeof(struct generic_pcie_core_softc)); diff --git a/sys/dev/pci/pci_host_generic.h b/sys/dev/pci/pci_host_generic.h index adb5934c9cc..2d8a7dac2be 100644 --- a/sys/dev/pci/pci_host_generic.h +++ b/sys/dev/pci/pci_host_generic.h @@ -48,7 +48,7 @@ struct pcie_range { #define FLAG_MEM (1 << 1) }; -struct generic_pcie_softc { +struct generic_pcie_core_softc { struct pcie_range ranges[MAX_RANGES_TUPLES]; int nranges; int coherent; @@ -62,17 +62,16 @@ struct generic_pcie_softc { device_t dev; bus_space_handle_t ioh; bus_dma_tag_t dmat; -#ifdef FDT - struct ofw_bus_iinfo pci_iinfo; -#endif }; -extern devclass_t generic_pcie_devclass; -DECLARE_CLASS(generic_pcie_driver); +DECLARE_CLASS(generic_pcie_core_driver); -struct resource *pci_host_generic_alloc_resource(device_t, +struct resource *pci_host_generic_core_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -int pci_host_generic_attach(device_t); -int generic_pcie_get_id(device_t, device_t, enum pci_id_type, uintptr_t *); +int pci_host_generic_core_attach(device_t); +struct resource *pci_host_generic_core_alloc_resource(device_t, device_t, int, + int *, rman_res_t, rman_res_t, rman_res_t, u_int); +int pci_host_generic_core_release_resource(device_t, device_t, int, int, + struct resource *); #endif /* __PCI_HOST_GENERIC_H_ */ diff --git a/sys/dev/pci/pci_host_generic_fdt.c b/sys/dev/pci/pci_host_generic_fdt.c new file mode 100644 index 00000000000..e0566d20c9c --- /dev/null +++ b/sys/dev/pci/pci_host_generic_fdt.c @@ -0,0 +1,641 @@ +/*- + * Copyright (c) 2015 Ruslan Bukin + * Copyright (c) 2014,2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * the sponsorship of the FreeBSD Foundation. + * + * This software was developed by Semihalf under + * the sponsorship of the FreeBSD Foundation. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + */ + +/* Generic ECAM PCIe driver FDT attachment */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_platform.h" + +#include +#include +#include +#include +#include +#include +#include + +#if defined(INTRNG) +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "pcib_if.h" + +#define PCI_IO_WINDOW_OFFSET 0x1000 + +#define SPACE_CODE_SHIFT 24 +#define SPACE_CODE_MASK 0x3 +#define SPACE_CODE_IO_SPACE 0x1 +#define PROPS_CELL_SIZE 1 +#define PCI_ADDR_CELL_SIZE 2 + +/* OFW bus interface */ +struct generic_pcie_ofw_devinfo { + struct ofw_bus_devinfo di_dinfo; + struct resource_list di_rl; +}; + +/* Forward prototypes */ + +static int generic_pcie_fdt_probe(device_t dev); +static int parse_pci_mem_ranges(device_t, struct generic_pcie_core_softc *); +static int generic_pcie_fdt_release_resource(device_t dev, device_t child, + int type, int rid, struct resource *res); +static int generic_pcie_ofw_bus_attach(device_t); +static const struct ofw_bus_devinfo *generic_pcie_ofw_get_devinfo(device_t, + device_t); + +static __inline void +get_addr_size_cells(phandle_t node, pcell_t *addr_cells, pcell_t *size_cells) +{ + + *addr_cells = 2; + /* Find address cells if present */ + OF_getencprop(node, "#address-cells", addr_cells, sizeof(*addr_cells)); + + *size_cells = 2; + /* Find size cells if present */ + OF_getencprop(node, "#size-cells", size_cells, sizeof(*size_cells)); +} + +static int +generic_pcie_fdt_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_is_compatible(dev, "pci-host-ecam-generic")) { + device_set_desc(dev, "Generic PCI host controller"); + return (BUS_PROBE_GENERIC); + } + if (ofw_bus_is_compatible(dev, "arm,gem5_pcie")) { + device_set_desc(dev, "GEM5 PCIe host controller"); + return (BUS_PROBE_DEFAULT); + } + + return (ENXIO); +} + +int +pci_host_generic_attach(device_t dev) +{ + struct generic_pcie_fdt_softc *sc; + uint64_t phys_base; + uint64_t pci_base; + uint64_t size; + phandle_t node; + int error; + int tuple; + + sc = device_get_softc(dev); + + /* Retrieve 'ranges' property from FDT */ + if (bootverbose) + device_printf(dev, "parsing FDT for ECAM%d:\n", sc->base.ecam); + if (parse_pci_mem_ranges(dev, &sc->base)) + return (ENXIO); + + /* Attach OFW bus */ + if (generic_pcie_ofw_bus_attach(dev) != 0) + return (ENXIO); + + node = ofw_bus_get_node(dev); + if (sc->base.coherent == 0) { + sc->base.coherent = OF_hasprop(node, "dma-coherent"); + } + if (bootverbose) + device_printf(dev, "Bus is%s cache-coherent\n", + sc->base.coherent ? "" : " not"); + + error = pci_host_generic_attach(dev); + if (error != 0) + return (error); + + for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) { + phys_base = sc->base.ranges[tuple].phys_base; + pci_base = sc->base.ranges[tuple].pci_base; + size = sc->base.ranges[tuple].size; + if (phys_base == 0 || size == 0) + continue; /* empty range element */ + if (sc->base.ranges[tuple].flags & FLAG_MEM) { + error = rman_manage_region(&sc->base.mem_rman, + phys_base, phys_base + size - 1); + } else if (sc->base.ranges[tuple].flags & FLAG_IO) { + error = rman_manage_region(&sc->base.io_rman, + pci_base + PCI_IO_WINDOW_OFFSET, + pci_base + PCI_IO_WINDOW_OFFSET + size - 1); + } else + continue; + if (error) { + device_printf(dev, "rman_manage_region() failed." + "error = %d\n", error); + rman_fini(&sc->base.mem_rman); + return (error); + } + } + + ofw_bus_setup_iinfo(node, &sc->pci_iinfo, sizeof(cell_t)); + + device_add_child(dev, "pci", -1); + return (bus_generic_attach(dev)); +} + +static int +parse_pci_mem_ranges(device_t dev, struct generic_pcie_core_softc *sc) +{ + pcell_t pci_addr_cells, parent_addr_cells; + pcell_t attributes, size_cells; + cell_t *base_ranges; + int nbase_ranges; + phandle_t node; + int i, j, k; + int tuple; + + node = ofw_bus_get_node(dev); + + OF_getencprop(node, "#address-cells", &pci_addr_cells, + sizeof(pci_addr_cells)); + OF_getencprop(node, "#size-cells", &size_cells, + sizeof(size_cells)); + OF_getencprop(OF_parent(node), "#address-cells", &parent_addr_cells, + sizeof(parent_addr_cells)); + + if (parent_addr_cells > 2 || pci_addr_cells != 3 || size_cells > 2) { + device_printf(dev, + "Unexpected number of address or size cells in FDT\n"); + return (ENXIO); + } + + nbase_ranges = OF_getproplen(node, "ranges"); + sc->nranges = nbase_ranges / sizeof(cell_t) / + (parent_addr_cells + pci_addr_cells + size_cells); + base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK); + OF_getencprop(node, "ranges", base_ranges, nbase_ranges); + + for (i = 0, j = 0; i < sc->nranges; i++) { + attributes = (base_ranges[j++] >> SPACE_CODE_SHIFT) & \ + SPACE_CODE_MASK; + if (attributes == SPACE_CODE_IO_SPACE) { + sc->ranges[i].flags |= FLAG_IO; + } else { + sc->ranges[i].flags |= FLAG_MEM; + } + + sc->ranges[i].pci_base = 0; + for (k = 0; k < (pci_addr_cells - 1); k++) { + sc->ranges[i].pci_base <<= 32; + sc->ranges[i].pci_base |= base_ranges[j++]; + } + sc->ranges[i].phys_base = 0; + for (k = 0; k < parent_addr_cells; k++) { + sc->ranges[i].phys_base <<= 32; + sc->ranges[i].phys_base |= base_ranges[j++]; + } + sc->ranges[i].size = 0; + for (k = 0; k < size_cells; k++) { + sc->ranges[i].size <<= 32; + sc->ranges[i].size |= base_ranges[j++]; + } + } + + for (; i < MAX_RANGES_TUPLES; i++) { + /* zero-fill remaining tuples to mark empty elements in array */ + sc->ranges[i].pci_base = 0; + sc->ranges[i].phys_base = 0; + sc->ranges[i].size = 0; + } + + if (bootverbose) { + for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) { + device_printf(dev, + "\tPCI addr: 0x%jx, CPU addr: 0x%jx, Size: 0x%jx\n", + sc->ranges[tuple].pci_base, + sc->ranges[tuple].phys_base, + sc->ranges[tuple].size); + } + } + + free(base_ranges, M_DEVBUF); + return (0); +} + +static int +generic_pcie_fdt_route_interrupt(device_t bus, device_t dev, int pin) +{ + struct generic_pcie_fdt_softc *sc; + struct ofw_pci_register reg; + uint32_t pintr, mintr[2]; + phandle_t iparent; + int intrcells; + + sc = device_get_softc(bus); + pintr = pin; + + bzero(®, sizeof(reg)); + reg.phys_hi = (pci_get_bus(dev) << OFW_PCI_PHYS_HI_BUSSHIFT) | + (pci_get_slot(dev) << OFW_PCI_PHYS_HI_DEVICESHIFT) | + (pci_get_function(dev) << OFW_PCI_PHYS_HI_FUNCTIONSHIFT); + + intrcells = ofw_bus_lookup_imap(ofw_bus_get_node(dev), + &sc->pci_iinfo, ®, sizeof(reg), &pintr, sizeof(pintr), + mintr, sizeof(mintr), &iparent); + if (intrcells) { + pintr = ofw_bus_map_intr(dev, iparent, intrcells, mintr); + return (pintr); + } + + device_printf(bus, "could not route pin %d for device %d.%d\n", + pin, pci_get_slot(dev), pci_get_function(dev)); + return (PCI_INVALID_IRQ); +} + +static int +generic_pcie_fdt_release_resource(device_t dev, device_t child, int type, + int rid, struct resource *res) +{ + +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) { + return (pci_host_generic_core_release_resource(dev, child, type, + rid, res)); + } +#endif + + /* For PCIe devices that do not have FDT nodes, use PCIB method */ + if ((int)ofw_bus_get_node(child) <= 0) { + return (pci_host_generic_core_release_resource(dev, child, type, + rid, res)); + } + + /* For other devices use OFW method */ + return (bus_generic_release_resource(dev, child, type, rid, res)); +} + +struct resource * +pci_host_generic_alloc_resource(device_t dev, device_t child, int type, + int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) +{ + struct generic_pcie_fdt_softc *sc; + struct generic_pcie_ofw_devinfo *di; + struct resource_list_entry *rle; + int i; + +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) { + return (pci_host_generic_alloc_resource(dev, child, type, rid, + start, end, count, flags)); + } +#endif + + /* For PCIe devices that do not have FDT nodes, use PCIB method */ + if ((int)ofw_bus_get_node(child) <= 0) + return (pci_host_generic_alloc_resource(dev, child, type, rid, + start, end, count, flags)); + + /* For other devices use OFW method */ + sc = device_get_softc(dev); + + if (RMAN_IS_DEFAULT_RANGE(start, end)) { + if ((di = device_get_ivars(child)) == NULL) + return (NULL); + if (type == SYS_RES_IOPORT) + type = SYS_RES_MEMORY; + + /* Find defaults for this rid */ + rle = resource_list_find(&di->di_rl, type, *rid); + if (rle == NULL) + return (NULL); + + start = rle->start; + end = rle->end; + count = rle->count; + } + + if (type == SYS_RES_MEMORY) { + /* Remap through ranges property */ + for (i = 0; i < MAX_RANGES_TUPLES; i++) { + if (start >= sc->base.ranges[i].phys_base && + end < (sc->base.ranges[i].pci_base + + sc->base.ranges[i].size)) { + start -= sc->base.ranges[i].phys_base; + start += sc->base.ranges[i].pci_base; + end -= sc->base.ranges[i].phys_base; + end += sc->base.ranges[i].pci_base; + break; + } + } + + if (i == MAX_RANGES_TUPLES) { + device_printf(dev, "Could not map resource " + "%#jx-%#jx\n", start, end); + return (NULL); + } + } + + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static int +generic_pcie_fdt_activate_resource(device_t dev, device_t child, int type, + int rid, struct resource *r) +{ + struct generic_pcie_fdt_softc *sc; + uint64_t phys_base; + uint64_t pci_base; + uint64_t size; + int found; + int res; + int i; + + sc = device_get_softc(dev); + + if ((res = rman_activate_resource(r)) != 0) + return (res); + + switch(type) { + case SYS_RES_IOPORT: + found = 0; + for (i = 0; i < MAX_RANGES_TUPLES; i++) { + pci_base = sc->base.ranges[i].pci_base; + phys_base = sc->base.ranges[i].phys_base; + size = sc->base.ranges[i].size; + + if ((rid > pci_base) && (rid < (pci_base + size))) { + found = 1; + break; + } + } + if (found) { + rman_set_start(r, rman_get_start(r) + phys_base); + rman_set_end(r, rman_get_end(r) + phys_base); + res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), + child, type, rid, r); + } else { + device_printf(dev, + "Failed to activate IOPORT resource\n"); + res = 0; + } + break; + case SYS_RES_MEMORY: + res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, + type, rid, r); + break; + default: + break; + } + + return (res); +} + +static int +generic_pcie_fdt_deactivate_resource(device_t dev, device_t child, int type, + int rid, struct resource *r) +{ + int res; + + if ((res = rman_deactivate_resource(r)) != 0) + return (res); + + switch(type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + res = BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), child, + type, rid, r); + break; + default: + break; + } + + return (res); +} + +static int +generic_pcie_fdt_alloc_msi(device_t pci, device_t child, int count, + int maxcount, int *irqs) +{ +#if defined(INTRNG) + phandle_t msi_parent; + + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_alloc_msi(pci, child, msi_parent, count, maxcount, + irqs)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_fdt_release_msi(device_t pci, device_t child, int count, int *irqs) +{ +#if defined(INTRNG) + phandle_t msi_parent; + + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_release_msi(pci, child, msi_parent, count, irqs)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_fdt_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, + uint32_t *data) +{ +#if defined(INTRNG) + phandle_t msi_parent; + + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_map_msi(pci, child, msi_parent, irq, addr, data)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_fdt_alloc_msix(device_t pci, device_t child, int *irq) +{ +#if defined(INTRNG) + phandle_t msi_parent; + + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_alloc_msix(pci, child, msi_parent, irq)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_fdt_release_msix(device_t pci, device_t child, int irq) +{ +#if defined(INTRNG) + phandle_t msi_parent; + + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_release_msix(pci, child, msi_parent, irq)); +#else + return (ENXIO); +#endif +} + +int +generic_pcie_get_id(device_t pci, device_t child, enum pci_id_type type, + uintptr_t *id) +{ + phandle_t node; + uint32_t rid; + uint16_t pci_rid; + + if (type != PCI_ID_MSI) + return (pcib_get_id(pci, child, type, id)); + + node = ofw_bus_get_node(pci); + pci_rid = pci_get_rid(child); + + ofw_bus_msimap(node, pci_rid, NULL, &rid); + *id = rid; + + return (0); +} + +static const struct ofw_bus_devinfo * +generic_pcie_ofw_get_devinfo(device_t bus __unused, device_t child) +{ + struct generic_pcie_ofw_devinfo *di; + + di = device_get_ivars(child); + return (&di->di_dinfo); +} + +/* Helper functions */ + +static int +generic_pcie_ofw_bus_attach(device_t dev) +{ + struct generic_pcie_ofw_devinfo *di; + device_t child; + phandle_t parent, node; + pcell_t addr_cells, size_cells; + + parent = ofw_bus_get_node(dev); + if (parent > 0) { + get_addr_size_cells(parent, &addr_cells, &size_cells); + /* Iterate through all bus subordinates */ + for (node = OF_child(parent); node > 0; node = OF_peer(node)) { + + /* Allocate and populate devinfo. */ + di = malloc(sizeof(*di), M_DEVBUF, M_WAITOK | M_ZERO); + if (ofw_bus_gen_setup_devinfo(&di->di_dinfo, node) != 0) { + free(di, M_DEVBUF); + continue; + } + + /* Initialize and populate resource list. */ + resource_list_init(&di->di_rl); + ofw_bus_reg_to_rl(dev, node, addr_cells, size_cells, + &di->di_rl); + ofw_bus_intr_to_rl(dev, node, &di->di_rl, NULL); + + /* Add newbus device for this FDT node */ + child = device_add_child(dev, NULL, -1); + if (child == NULL) { + resource_list_free(&di->di_rl); + ofw_bus_gen_destroy_devinfo(&di->di_dinfo); + free(di, M_DEVBUF); + continue; + } + + device_set_ivars(child, di); + } + } + + return (0); +} + +static device_method_t generic_pcie_fdt_methods[] = { + DEVMETHOD(device_probe, generic_pcie_fdt_probe), + DEVMETHOD(device_attach, pci_host_generic_attach), + DEVMETHOD(bus_alloc_resource, pci_host_generic_alloc_resource), + DEVMETHOD(bus_release_resource, generic_pcie_fdt_release_resource), + DEVMETHOD(bus_activate_resource, generic_pcie_fdt_activate_resource), + DEVMETHOD(bus_deactivate_resource,generic_pcie_fdt_deactivate_resource), + + /* pcib interface */ + DEVMETHOD(pcib_route_interrupt, generic_pcie_fdt_route_interrupt), + DEVMETHOD(pcib_alloc_msi, generic_pcie_fdt_alloc_msi), + DEVMETHOD(pcib_release_msi, generic_pcie_fdt_release_msi), + DEVMETHOD(pcib_alloc_msix, generic_pcie_fdt_alloc_msix), + DEVMETHOD(pcib_release_msix, generic_pcie_fdt_release_msix), + DEVMETHOD(pcib_map_msi, generic_pcie_fdt_map_msi), + DEVMETHOD(pcib_get_id, generic_pcie_get_id), + + /* ofw_bus interface */ + DEVMETHOD(ofw_bus_get_devinfo, generic_pcie_ofw_get_devinfo), + DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), + DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), + DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), + DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), + DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), + + DEVMETHOD_END +}; + +DEFINE_CLASS_1(pcib, generic_pcie_fdt_driver, generic_pcie_fdt_methods, + sizeof(struct generic_pcie_fdt_softc), generic_pcie_core_driver); + +static devclass_t generic_pcie_fdt_devclass; + +DRIVER_MODULE(pcib, simplebus, generic_pcie_fdt_driver, + generic_pcie_fdt_devclass, 0, 0); +DRIVER_MODULE(pcib, ofwbus, generic_pcie_fdt_driver, generic_pcie_fdt_devclass, + 0, 0); diff --git a/sys/dev/pci/pci_host_generic_fdt.h b/sys/dev/pci/pci_host_generic_fdt.h new file mode 100644 index 00000000000..fba3ddcd7f8 --- /dev/null +++ b/sys/dev/pci/pci_host_generic_fdt.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Ruslan Bukin + * Copyright (c) 2015 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Semihalf. + * + * 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. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. + * + * + * $FreeBSD$ + * + */ + +#ifndef __PCI_HOST_GENERIC_FDT_H_ +#define __PCI_HOST_GENERIC_FDT_H_ + +struct generic_pcie_fdt_softc { + struct generic_pcie_core_softc base; + struct ofw_bus_iinfo pci_iinfo; +}; + +DECLARE_CLASS(generic_pcie_fdt_driver); + +struct resource *pci_host_generic_alloc_resource(device_t, + device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); +int pci_host_generic_attach(device_t); +int generic_pcie_get_id(device_t, device_t, enum pci_id_type, uintptr_t *); + +#endif /* __PCI_HOST_GENERIC_FDT_H_ */ From 32e7ac1e5ef831d84df05f2e1750fed56867aab5 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 18:50:45 +0000 Subject: [PATCH 035/115] Mark the Allwinner drivers as FDT only. These are mobile and embedded parts so are unlikely to use ACPI. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/conf/files.arm64 | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index cc1daacd224..e9cf04c162d 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -11,33 +11,33 @@ cloudabi64_vdso_blob.o optional compat_cloudabi64 \ no-implicit-rule \ clean "cloudabi64_vdso_blob.o" # -arm/allwinner/a10_ehci.c optional ehci aw_ehci -arm/allwinner/a10_gpio.c optional gpio aw_gpio -arm/allwinner/a10_mmc.c optional mmc aw_mmc -arm/allwinner/a64/a64_padconf.c optional soc_allwinner_a64 -arm/allwinner/a64/a64_r_padconf.c optional soc_allwinner_a64 -arm/allwinner/aw_ccu.c optional aw_ccu -arm/allwinner/aw_nmi.c optional aw_nmi \ +arm/allwinner/a10_ehci.c optional ehci aw_ehci fdt +arm/allwinner/a10_gpio.c optional gpio aw_gpio fdt +arm/allwinner/a10_mmc.c optional mmc aw_mmc fdt +arm/allwinner/a64/a64_padconf.c optional soc_allwinner_a64 fdt +arm/allwinner/a64/a64_r_padconf.c optional soc_allwinner_a64 fdt +arm/allwinner/aw_ccu.c optional aw_ccu fdt +arm/allwinner/aw_nmi.c optional aw_nmi fdt \ compile-with "${NORMAL_C} -I$S/gnu/dts/include" -arm/allwinner/aw_reset.c optional aw_ccu -arm/allwinner/aw_rsb.c optional aw_rsb -arm/allwinner/aw_rtc.c optional aw_rtc -arm/allwinner/aw_sid.c optional aw_sid -arm/allwinner/aw_thermal.c optional aw_thermal -arm/allwinner/aw_usbphy.c optional ehci aw_usbphy -arm/allwinner/aw_wdog.c optional aw_wdog -arm/allwinner/axp81x.c optional axp81x -arm/allwinner/clk/aw_ahbclk.c optional aw_ccu -arm/allwinner/clk/aw_apbclk.c optional aw_ccu -arm/allwinner/clk/aw_axiclk.c optional aw_ccu -arm/allwinner/clk/aw_cpuclk.c optional aw_ccu -arm/allwinner/clk/aw_gate.c optional aw_ccu -arm/allwinner/clk/aw_modclk.c optional aw_ccu -arm/allwinner/clk/aw_pll.c optional aw_ccu \ +arm/allwinner/aw_reset.c optional aw_ccu fdt +arm/allwinner/aw_rsb.c optional aw_rsb fdt +arm/allwinner/aw_rtc.c optional aw_rtc fdt +arm/allwinner/aw_sid.c optional aw_sid fdt +arm/allwinner/aw_thermal.c optional aw_thermal fdt +arm/allwinner/aw_usbphy.c optional ehci aw_usbphy fdt +arm/allwinner/aw_wdog.c optional aw_wdog fdt +arm/allwinner/axp81x.c optional axp81x fdt +arm/allwinner/clk/aw_ahbclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_apbclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_axiclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_cpuclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_gate.c optional aw_ccu fdt +arm/allwinner/clk/aw_modclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_pll.c optional aw_ccu fdt \ compile-with "${NORMAL_C} -I$S/gnu/dts/include" -arm/allwinner/clk/aw_thsclk.c optional aw_ccu -arm/allwinner/clk/aw_usbclk.c optional aw_ccu -arm/allwinner/if_awg.c optional awg +arm/allwinner/clk/aw_thsclk.c optional aw_ccu fdt +arm/allwinner/clk/aw_usbclk.c optional aw_ccu fdt +arm/allwinner/if_awg.c optional awg fdt arm/annapurna/alpine/alpine_ccu.c optional al_ccu fdt arm/annapurna/alpine/alpine_nb_service.c optional al_nb_service fdt arm/annapurna/alpine/alpine_pci.c optional al_pci fdt From 824f05d68fc09afb715b83167906e781e02c3c91 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 19:03:51 +0000 Subject: [PATCH 036/115] Mark extres as FDT only. Much of this assumes FDT and fails to build without it. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/conf/files | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 07bbfb8c41c..fbae55c11e2 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1601,23 +1601,23 @@ dev/ex/if_ex.c optional ex dev/ex/if_ex_isa.c optional ex isa dev/ex/if_ex_pccard.c optional ex pccard dev/exca/exca.c optional cbb -dev/extres/clk/clk.c optional ext_resources clk -dev/extres/clk/clkdev_if.m optional ext_resources clk -dev/extres/clk/clknode_if.m optional ext_resources clk +dev/extres/clk/clk.c optional ext_resources clk fdt +dev/extres/clk/clkdev_if.m optional ext_resources clk fdt +dev/extres/clk/clknode_if.m optional ext_resources clk fdt dev/extres/clk/clk_bus.c optional ext_resources clk fdt -dev/extres/clk/clk_div.c optional ext_resources clk -dev/extres/clk/clk_fixed.c optional ext_resources clk -dev/extres/clk/clk_gate.c optional ext_resources clk -dev/extres/clk/clk_mux.c optional ext_resources clk -dev/extres/phy/phy.c optional ext_resources phy -dev/extres/phy/phy_if.m optional ext_resources phy -dev/extres/hwreset/hwreset.c optional ext_resources hwreset -dev/extres/hwreset/hwreset_if.m optional ext_resources hwreset -dev/extres/regulator/regdev_if.m optional ext_resources regulator -dev/extres/regulator/regnode_if.m optional ext_resources regulator -dev/extres/regulator/regulator.c optional ext_resources regulator +dev/extres/clk/clk_div.c optional ext_resources clk fdt +dev/extres/clk/clk_fixed.c optional ext_resources clk fdt +dev/extres/clk/clk_gate.c optional ext_resources clk fdt +dev/extres/clk/clk_mux.c optional ext_resources clk fdt +dev/extres/phy/phy.c optional ext_resources phy fdt +dev/extres/phy/phy_if.m optional ext_resources phy fdt +dev/extres/hwreset/hwreset.c optional ext_resources hwreset fdt +dev/extres/hwreset/hwreset_if.m optional ext_resources hwreset fdt +dev/extres/regulator/regdev_if.m optional ext_resources regulator fdt +dev/extres/regulator/regnode_if.m optional ext_resources regulator fdt +dev/extres/regulator/regulator.c optional ext_resources regulator fdt dev/extres/regulator/regulator_bus.c optional ext_resources regulator fdt -dev/extres/regulator/regulator_fixed.c optional ext_resources regulator +dev/extres/regulator/regulator_fixed.c optional ext_resources regulator fdt dev/fatm/if_fatm.c optional fatm pci dev/fb/fbd.c optional fbd | vt dev/fb/fb_if.m standard From da8695d40852824faba759e8cda9c5cf74393b78 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 19:13:33 +0000 Subject: [PATCH 037/115] Mark uart_dev_snps.c as FDT only, it doesn't have and ACPI bindings. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/conf/files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/files b/sys/conf/files index fbae55c11e2..a2ece3f4320 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2947,7 +2947,7 @@ dev/uart/uart_dev_pl011.c optional uart pl011 dev/uart/uart_dev_quicc.c optional uart quicc dev/uart/uart_dev_sab82532.c optional uart uart_sab82532 dev/uart/uart_dev_sab82532.c optional uart scc -dev/uart/uart_dev_snps.c optional uart uart_snps +dev/uart/uart_dev_snps.c optional uart uart_snps fdt dev/uart/uart_dev_z8530.c optional uart uart_z8530 dev/uart/uart_dev_z8530.c optional uart scc dev/uart/uart_if.m optional uart From e45c936f460ed5f635ba0fca87114220017e693b Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 19:14:46 +0000 Subject: [PATCH 038/115] Mark virtio_mmio as FDT only, it lacks an ACPI attachment. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/conf/files | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index a2ece3f4320..d7d664422ff 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3149,8 +3149,8 @@ dev/virtio/virtqueue.c optional virtio dev/virtio/virtio_bus_if.m optional virtio dev/virtio/virtio_if.m optional virtio dev/virtio/pci/virtio_pci.c optional virtio_pci -dev/virtio/mmio/virtio_mmio.c optional virtio_mmio -dev/virtio/mmio/virtio_mmio_if.m optional virtio_mmio +dev/virtio/mmio/virtio_mmio.c optional virtio_mmio fdt +dev/virtio/mmio/virtio_mmio_if.m optional virtio_mmio fdt dev/virtio/network/if_vtnet.c optional vtnet dev/virtio/block/virtio_blk.c optional virtio_blk dev/virtio/balloon/virtio_balloon.c optional virtio_balloon From b15317c43192e806f2db7d725dcec84aff9c30d8 Mon Sep 17 00:00:00 2001 From: Michael Zhilin Date: Mon, 21 Nov 2016 19:26:22 +0000 Subject: [PATCH 039/115] [etherswitch] add ukswitch hint that is phy offset at mdio register This patch allows to specify PHY register offset for ukswitch. For instance, switch MAICREL KS8995XA connected via MDIO to SoC, but PHY register starts at 1. So hint for this case is: hint.ukswitch.0.phyoffset=1 No change/effect if hint is not set. Submitted by: Hiroki Mori Reviewed by: adrian, mizhka Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D8584 --- sys/dev/etherswitch/ukswitch/ukswitch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c index 876aa9da226..5d8c95eabb8 100644 --- a/sys/dev/etherswitch/ukswitch/ukswitch.c +++ b/sys/dev/etherswitch/ukswitch/ukswitch.c @@ -67,6 +67,7 @@ struct ukswitch_softc { int media; /* cpu port media */ int cpuport; /* which PHY is connected to the CPU */ int phymask; /* PHYs we manage */ + int phyoffset; /* PHYs register offset */ int numports; /* number of ports */ int ifpport[MII_NPHY]; int *portphy; @@ -133,7 +134,7 @@ ukswitch_attach_phys(struct ukswitch_softc *sc) M_WAITOK | M_ZERO); err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port], ukswitch_ifmedia_upd, ukswitch_ifmedia_sts, \ - BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); + BMSR_DEFCAPMASK, phy + sc->phyoffset, MII_OFFSET_ANY, 0); DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n", device_get_nameunit(*sc->miibus[port]), sc->ifp[port]->if_xname); @@ -166,6 +167,7 @@ ukswitch_attach(device_t dev) /* XXX Defaults */ sc->numports = 6; sc->phymask = 0x0f; + sc->phyoffset = 0; sc->cpuport = -1; sc->media = 100; @@ -173,6 +175,8 @@ ukswitch_attach(device_t dev) "numports", &sc->numports); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "phymask", &sc->phymask); + (void) resource_int_value(device_get_name(dev), device_get_unit(dev), + "phyoffset", &sc->phyoffset); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "cpuport", &sc->cpuport); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), From eba1a249dfc6ca98f5d10d9a56a53e3995cef1fc Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 19:26:58 +0000 Subject: [PATCH 040/115] Add support to find the arm64 serial using the ACPI tables. This uses the Serial Port Console Redirection Table to find the device to use. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/arm64/acpica/acpi_machdep.c | 18 +++++++ sys/arm64/include/acpica_machdep.h | 7 +++ sys/dev/uart/uart_cpu_acpi.h | 1 + sys/dev/uart/uart_cpu_arm64.c | 84 +++++++++++++++++++++++++++++- sys/dev/uart/uart_dev_pl011.c | 13 +++-- 5 files changed, 117 insertions(+), 6 deletions(-) diff --git a/sys/arm64/acpica/acpi_machdep.c b/sys/arm64/acpica/acpi_machdep.c index da07cfcb060..28216a86b38 100644 --- a/sys/arm64/acpica/acpi_machdep.c +++ b/sys/arm64/acpica/acpi_machdep.c @@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$"); #include +extern struct bus_space memmap_bus; + int acpi_machdep_init(device_t dev) { @@ -215,3 +217,19 @@ acpi_find_table(const char *sig) return (addr); } + +int +acpi_map_addr(struct acpi_generic_address *addr, bus_space_tag_t *tag, + bus_space_handle_t *handle, bus_size_t size) +{ + bus_addr_t phys; + + /* Check if the device is Memory mapped */ + if (addr->SpaceId != 0) + return (ENXIO); + + phys = addr->Address; + *tag = &memmap_bus; + + return (bus_space_map(*tag, phys, size, 0, handle)); +} diff --git a/sys/arm64/include/acpica_machdep.h b/sys/arm64/include/acpica_machdep.h index 9a3434a2bba..282c79f5eae 100644 --- a/sys/arm64/include/acpica_machdep.h +++ b/sys/arm64/include/acpica_machdep.h @@ -39,6 +39,8 @@ #ifdef _KERNEL +#include + /* Only use the reduced hardware model */ #define ACPI_REDUCED_HARDWARE 1 @@ -50,6 +52,11 @@ void *acpi_map_table(vm_paddr_t pa, const char *sig); void acpi_unmap_table(void *table); vm_paddr_t acpi_find_table(const char *sig); +struct acpi_generic_address; + +int acpi_map_addr(struct acpi_generic_address *, bus_space_tag_t *, + bus_space_handle_t *, bus_size_t); + #endif /* _KERNEL */ #endif /* __ACPICA_MACHDEP_H__ */ diff --git a/sys/dev/uart/uart_cpu_acpi.h b/sys/dev/uart/uart_cpu_acpi.h index afdd93da99b..30cfa4e1938 100644 --- a/sys/dev/uart/uart_cpu_acpi.h +++ b/sys/dev/uart/uart_cpu_acpi.h @@ -40,6 +40,7 @@ struct uart_class; struct acpi_uart_compat_data { const char *hid; struct uart_class *clas; + uint16_t port_subtype; }; /* diff --git a/sys/dev/uart/uart_cpu_arm64.c b/sys/dev/uart/uart_cpu_arm64.c index 36193414bf1..ce620e973b2 100644 --- a/sys/dev/uart/uart_cpu_arm64.c +++ b/sys/dev/uart/uart_cpu_arm64.c @@ -48,6 +48,12 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef DEV_ACPI +#include +#include +#include +#endif + #ifdef FDT #include #include @@ -72,6 +78,76 @@ uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0); } +#ifdef DEV_ACPI +static struct acpi_uart_compat_data * +uart_cpu_acpi_scan(uint8_t interface_type) +{ + struct acpi_uart_compat_data **cd; + + SET_FOREACH(cd, uart_acpi_class_and_device_set) { + if ((*cd)->port_subtype == interface_type) + return (*cd); + } + + SET_FOREACH(cd, uart_acpi_class_set) { + if ((*cd)->port_subtype == interface_type) + return (*cd); + } + + return (NULL); +} + +static int +uart_cpu_acpi_probe(struct uart_class **classp, bus_space_tag_t *bst, + bus_space_handle_t *bsh, int *baud, u_int *rclk, u_int *shiftp) +{ + struct acpi_uart_compat_data *cd; + ACPI_TABLE_SPCR *spcr; + vm_paddr_t spcr_physaddr; + int err; + + err = ENXIO; + spcr_physaddr = acpi_find_table(ACPI_SIG_SPCR); + if (spcr_physaddr == 0) + return (ENXIO); + + spcr = acpi_map_table(spcr_physaddr, ACPI_SIG_SPCR); + + cd = uart_cpu_acpi_scan(spcr->InterfaceType); + if (cd == NULL) + goto out; + + switch(spcr->BaudRate) { + case 3: + *baud = 9600; + break; + case 4: + *baud = 19200; + break; + case 6: + *baud = 57600; + break; + case 7: + *baud = 115200; + break; + default: + goto out; + } + + err = acpi_map_addr(&spcr->SerialPort, bst, bsh, PAGE_SIZE); + if (err != 0) + goto out; + + *classp = cd->clas; + *rclk = 0; + *shiftp = 2; + +out: + acpi_unmap_table(spcr); + return (err); +} +#endif + int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { @@ -91,8 +167,14 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) return (ENXIO); err = ENXIO; +#ifdef DEV_ACPI + err = uart_cpu_acpi_probe(&class, &bst, &bsh, &br, &rclk, &shift); +#endif #ifdef FDT - err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, &shift); + if (err != 0) { + err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, + &shift); + } #endif if (err != 0) return (err); diff --git a/sys/dev/uart/uart_dev_pl011.c b/sys/dev/uart/uart_dev_pl011.c index 8604477097a..49f22b33e6b 100644 --- a/sys/dev/uart/uart_dev_pl011.c +++ b/sys/dev/uart/uart_dev_pl011.c @@ -38,15 +38,18 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef DEV_ACPI -#include -#endif #ifdef FDT #include #endif #include #include "uart_if.h" +#ifdef DEV_ACPI +#include +#include +#include +#endif + #include /* PL011 UART registers and masks*/ @@ -296,8 +299,8 @@ UART_FDT_CLASS_AND_DEVICE(compat_data); #ifdef DEV_ACPI static struct acpi_uart_compat_data acpi_compat_data[] = { - {"ARMH0011", &uart_pl011_class}, - {NULL, NULL}, + {"ARMH0011", &uart_pl011_class, ACPI_DBG2_ARM_PL011}, + {NULL, NULL, 0}, }; UART_ACPI_CLASS_AND_DEVICE(acpi_compat_data); #endif From ef022bb1de6a2ef7e63f06b4135e6af43610d734 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 21 Nov 2016 19:38:57 +0000 Subject: [PATCH 041/115] Include the missing accommon.h from the ACPI uart code. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/dev/uart/uart_cpu_arm64.c | 1 + sys/dev/uart/uart_dev_pl011.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/dev/uart/uart_cpu_arm64.c b/sys/dev/uart/uart_cpu_arm64.c index ce620e973b2..0121866da34 100644 --- a/sys/dev/uart/uart_cpu_arm64.c +++ b/sys/dev/uart/uart_cpu_arm64.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #ifdef DEV_ACPI #include +#include #include #include #endif diff --git a/sys/dev/uart/uart_dev_pl011.c b/sys/dev/uart/uart_dev_pl011.c index 49f22b33e6b..9eb9ea8175b 100644 --- a/sys/dev/uart/uart_dev_pl011.c +++ b/sys/dev/uart/uart_dev_pl011.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #ifdef DEV_ACPI #include #include +#include #include #endif From fd9805111709be75f94d685fdbd6b1cc9735aeb0 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Mon, 21 Nov 2016 19:43:01 +0000 Subject: [PATCH 042/115] [bytgpio] prepare bytgpio(4) for modularization - Add detach method - module should depend on gpiobus, not gpio --- sys/dev/gpio/bytgpio.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sys/dev/gpio/bytgpio.c b/sys/dev/gpio/bytgpio.c index 76f29922fe1..2da58defffc 100644 --- a/sys/dev/gpio/bytgpio.c +++ b/sys/dev/gpio/bytgpio.c @@ -86,6 +86,7 @@ struct bytgpio_softc { static int bytgpio_probe(device_t dev); static int bytgpio_attach(device_t dev); +static int bytgpio_detach(device_t dev); #define SCORE_UID 1 #define SCORE_BANK_PREFIX "GPIO_S0_SC" @@ -567,6 +568,8 @@ bytgpio_attach(device_t dev) return (ENXIO); } + BYTGPIO_LOCK_INIT(sc); + switch (uid) { case SCORE_UID: sc->sc_npins = SCORE_PINS; @@ -599,8 +602,6 @@ bytgpio_attach(device_t dev) goto error; } - BYTGPIO_LOCK_INIT(sc); - for (pin = 0; pin < sc->sc_npins; pin++) { reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PCONF0); val = bytgpio_read_4(sc, reg); @@ -618,13 +619,39 @@ bytgpio_attach(device_t dev) return (0); error: + BYTGPIO_LOCK_DESTROY(sc); + return (ENXIO); } + +static int +bytgpio_detach(device_t dev) +{ + struct bytgpio_softc *sc; + + sc = device_get_softc(dev); + + if (sc->sc_busdev) + gpiobus_detach_bus(dev); + + BYTGPIO_LOCK_DESTROY(sc); + + if (sc->sc_pad_funcs) + free(sc->sc_pad_funcs, M_DEVBUF); + + if (sc->sc_mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, + sc->sc_mem_rid, sc->sc_mem_res); + + return (0); +} + static device_method_t bytgpio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bytgpio_probe), DEVMETHOD(device_attach, bytgpio_attach), + DEVMETHOD(device_detach, bytgpio_detach), /* GPIO protocol */ DEVMETHOD(gpio_get_bus, bytgpio_get_bus), @@ -649,4 +676,4 @@ static driver_t bytgpio_driver = { static devclass_t bytgpio_devclass; DRIVER_MODULE(bytgpio, acpi, bytgpio_driver, bytgpio_devclass, 0, 0); MODULE_DEPEND(bytgpio, acpi, 1, 1, 1); -MODULE_DEPEND(bytgpio, gpio, 1, 1, 1); +MODULE_DEPEND(bytgpio, gpiobus, 1, 1, 1); From 119bea9ff57e6dc3339655230e2a6fd70fe246c0 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Mon, 21 Nov 2016 19:46:10 +0000 Subject: [PATCH 043/115] [bytgpio] Add bytgpio(4) man page with general description of the driver MFC after: 3 days --- share/man/man4/Makefile | 2 ++ share/man/man4/bytgpio.4 | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 share/man/man4/bytgpio.4 diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index a5ec0b0d57a..2fee068cc90 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -86,6 +86,7 @@ MAN= aac.4 \ bt.4 \ bwi.4 \ bwn.4 \ + ${_bytgpio.4} \ capsicum.4 \ cardbus.4 \ carp.4 \ @@ -774,6 +775,7 @@ _amdsmb.4= amdsmb.4 _amdtemp.4= amdtemp.4 _asmc.4= asmc.4 _bxe.4= bxe.4 +_bytgpio.4= bytgpio.4 _coretemp.4= coretemp.4 _cpuctl.4= cpuctl.4 _dpms.4= dpms.4 diff --git a/share/man/man4/bytgpio.4 b/share/man/man4/bytgpio.4 new file mode 100644 index 00000000000..50609535f2a --- /dev/null +++ b/share/man/man4/bytgpio.4 @@ -0,0 +1,55 @@ +.\" Copyright (c) 2016 +.\" Oleksandr Tymoshenko . 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. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 20, 2016 +.Dt BYTGPIO 4 +.Os +.Sh NAME +.Nm bytgpio +.Nd Intel Bay Trail SoC GPIO controller +.Sh SYNOPSIS +.Cd "device gpio" +.Cd "device bytgpio" +.Sh DESCRIPTION +The +.Nm +is a driver for GPIO controller that can be found in Intel's Bay Trail SoC family. +.Pp +Bay Trail SoC has three banks of GPIO pins exposed to userland as /dev/gpiocN, +where N is 0, 1, and 2. Pins in each bank are pre-named to match names +on boards schematics: GPIO_S0_SCnn, GPIO_S0_NCnn, and GPIO_S5_nn. +.Sh SEE ALSO +.Xr gpio 3 , +.Xr gpio 4 , +.Xr gpioctl 8 +.Sh HISTORY +The +.Nm +manual page first appeared in +.Fx 12.0 . +.Sh AUTHORS +This driver and man page was written by +.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org . From 5370c80e0e6aa7aaaf53e62ec4010cee92440a8f Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Mon, 21 Nov 2016 19:47:37 +0000 Subject: [PATCH 044/115] [bytgpio] Add module for bytgpio(4) MFC after: 3 days --- sys/modules/Makefile | 2 ++ sys/modules/bytgpio/Makefile | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 sys/modules/bytgpio/Makefile diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 1718547d9fb..30e85396187 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -63,6 +63,7 @@ SUBDIR= \ bwi \ bwn \ bwn_pci \ + ${_bytgpio} \ cam \ ${_canbepm} \ ${_canbus} \ @@ -551,6 +552,7 @@ _an= an _aout= aout _bktr= bktr _bxe= bxe +_bytgpio= bytgpio _cardbus= cardbus _cbb= cbb _cpuctl= cpuctl diff --git a/sys/modules/bytgpio/Makefile b/sys/modules/bytgpio/Makefile new file mode 100644 index 00000000000..d1e54e7402b --- /dev/null +++ b/sys/modules/bytgpio/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/gpio +KMOD= bytgpio +SRCS= bytgpio.c +SRCS+= device_if.h bus_if.h gpio_if.h + +.include From 2806b2933b5961e59fd97523fd22b6b9797b9680 Mon Sep 17 00:00:00 2001 From: Hiren Panchasara Date: Mon, 21 Nov 2016 20:53:11 +0000 Subject: [PATCH 045/115] For RTT calculations mid-session, we explicitly ignore ACKs with tsecr of 0 as many borken middle-boxes tend to do that. But during 3whs, in syncache_expand(), we don't do that which causes us to send a RST to such a client. Relax this constraint by only using tsecr to compare against timestamp that we sent when it is not 0. As a result, we'd now accept the final ACK of 3whs with tsecr of 0. Reviewed by: jtl, gnn Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D8552 --- sys/netinet/tcp_syncache.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 6dc02ef8593..1458f44025a 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1069,10 +1069,17 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, } /* - * If timestamps were negotiated the reflected timestamp - * must be equal to what we actually sent in the SYN|ACK. + * If timestamps were negotiated, the reflected timestamp + * must be equal to what we actually sent in the SYN|ACK + * except in the case of 0. Some boxes are known for sending + * broken timestamp replies during the 3whs (and potentially + * during the connection also). + * + * Accept the final ACK of 3whs with reflected timestamp of 0 + * instead of sending a RST and deleting the syncache entry. */ - if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts) { + if ((to->to_flags & TOF_TS) && to->to_tsecr && + to->to_tsecr != sc->sc_ts) { if ((s = tcp_log_addrs(inc, th, NULL, NULL))) log(LOG_DEBUG, "%s; %s: TSECR %u != TS %u, " "segment rejected\n", From 005cecb30a3025f69750936f26e37b10412f45bb Mon Sep 17 00:00:00 2001 From: Hiren Panchasara Date: Mon, 21 Nov 2016 21:07:43 +0000 Subject: [PATCH 046/115] r308942 broke kernel build. Add acpi_if.h to module makefile to fix it. Submitted by: peter --- sys/modules/bytgpio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/modules/bytgpio/Makefile b/sys/modules/bytgpio/Makefile index d1e54e7402b..db06e4af9af 100644 --- a/sys/modules/bytgpio/Makefile +++ b/sys/modules/bytgpio/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/gpio KMOD= bytgpio SRCS= bytgpio.c -SRCS+= device_if.h bus_if.h gpio_if.h +SRCS+= acpi_if.h device_if.h bus_if.h gpio_if.h .include From 9fc3c7f733e93a624a5a4ffb8793b8ee0ef96d0d Mon Sep 17 00:00:00 2001 From: Glen Barber Date: Mon, 21 Nov 2016 23:29:28 +0000 Subject: [PATCH 047/115] Set the 'vital' flag on the runtime and jail packages. The default pkg(8) from pkg.freebsd.org requires libjail.so, so mark the jail package as vital along with the runtime package to avoid errors when libjail.so is removed. This is a no-op for systems with WITHOUT_JAIL in src.conf(5) and pkg(8) built from the Ports Collection. In order to make this work without marking packages such as the jail-lib32, for example, the jail.ucl file needed to be split out into separate files similarly to the runtime-*.ucl files. Glanced at by: brd MFC after: 5 days Sponsored by: The FreeBSD Foundation --- release/packages/Makefile.package | 7 ++++++ release/packages/generate-ucl.sh | 6 ++++++ release/packages/jail-debug.ucl | 24 +++++++++++++++++++++ release/packages/jail-development.ucl | 24 +++++++++++++++++++++ release/packages/jail-lib32-debug.ucl | 24 +++++++++++++++++++++ release/packages/jail-lib32-development.ucl | 24 +++++++++++++++++++++ release/packages/jail-lib32-profile.ucl | 24 +++++++++++++++++++++ release/packages/jail-lib32.ucl | 24 +++++++++++++++++++++ release/packages/jail-profile.ucl | 24 +++++++++++++++++++++ release/packages/jail.ucl | 1 + release/packages/runtime.ucl | 2 +- 11 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 release/packages/jail-debug.ucl create mode 100644 release/packages/jail-development.ucl create mode 100644 release/packages/jail-lib32-debug.ucl create mode 100644 release/packages/jail-lib32-development.ucl create mode 100644 release/packages/jail-lib32-profile.ucl create mode 100644 release/packages/jail-lib32.ucl create mode 100644 release/packages/jail-profile.ucl diff --git a/release/packages/Makefile.package b/release/packages/Makefile.package index 40faed84ea0..c027141f4a7 100644 --- a/release/packages/Makefile.package +++ b/release/packages/Makefile.package @@ -40,6 +40,13 @@ hast_COMMENT= Highly Available Storage daemon hast_DESC= Highly Available Storage daemon jail_COMMENT= Jail Utilities jail_DESC= Jail Utilities +jail-debug_DESCR= Debugging Symbols +jail-development_DESCR=Development Files +jail-profile_DESCR= Profiling Libraries +jail-lib32_DESCR= 32-bit Libraries +jail-lib32-debug_DESCR=32-bit Debugging Symbols +jail-lib32-development_DESCR=32-bit Development Files +jail-lib32-profile_DESCR=32-bit Profiling Libraries kernel_COMMENT= FreeBSD Kernel kernel_DESC= FreeBSD Kernel manuals_COMMENT= Manual Pages diff --git a/release/packages/generate-ucl.sh b/release/packages/generate-ucl.sh index 9a963f00125..5d7e7f6fb11 100755 --- a/release/packages/generate-ucl.sh +++ b/release/packages/generate-ucl.sh @@ -48,6 +48,12 @@ main() { pkgdeps="runtime" _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" ;; + jail_*) + outname="${origname}" + uclfile="${outname##*}${uclfile}" + pkgdeps="runtime" + _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" + ;; *_lib32_development) outname="${outname%%_lib32_development}" _descr="32-bit Libraries, Development Files" diff --git a/release/packages/jail-debug.ucl b/release/packages/jail-debug.ucl new file mode 100644 index 00000000000..753c26bc502 --- /dev/null +++ b/release/packages/jail-debug.ucl @@ -0,0 +1,24 @@ +# +# $FreeBSD$ +# + +name = "FreeBSD-%PKGNAME%" +origin = "base" +version = "%VERSION%" +comment = "%COMMENT%" +categories = [ base ] +maintainer = "re@FreeBSD.org" +www = "https://www.FreeBSD.org" +prefix = "/" +licenselogic = "single" +licenses = [ BSD2CLAUSE ] +desc = < Date: Tue, 22 Nov 2016 00:41:24 +0000 Subject: [PATCH 048/115] Audit 'fd' and 'cmd' arguments to fcntl(2), and when generating BSM, always audit the file-descriptor number and vnode information for all fnctl(2) commands, not just locking-related ones. This was likely an oversight in the original adaptation of this code from XNU. MFC after: 3 days Sponsored by: DARPA, AFRL --- sys/kern/kern_descrip.c | 2 ++ sys/security/audit/audit_bsm.c | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 3312b8876df..78cc6824ae4 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -495,6 +495,8 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) p = td->td_proc; fdp = p->p_fd; + AUDIT_ARG_FD(cmd); + AUDIT_ARG_CMD(cmd); switch (cmd) { case F_DUPFD: tmp = arg; diff --git a/sys/security/audit/audit_bsm.c b/sys/security/audit/audit_bsm.c index b4b1c67a3ae..62f4d8527b6 100644 --- a/sys/security/audit/audit_bsm.c +++ b/sys/security/audit/audit_bsm.c @@ -979,10 +979,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau) au_fcntl_cmd_to_bsm(ar->ar_arg_cmd)); kau_write(rec, tok); } - if (ar->ar_arg_cmd == F_GETLK || ar->ar_arg_cmd == F_SETLK || - ar->ar_arg_cmd == F_SETLKW) { - FD_VNODE1_TOKENS; - } + FD_VNODE1_TOKENS; break; case AUE_FCHFLAGS: From 5d8cce1764ccc4605a595bdfdabe7c3f23efdb61 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 22 Nov 2016 01:02:59 +0000 Subject: [PATCH 049/115] Initialize 'ticks' earlier in boot after 'hz' is set. This avoids the time-warp after kthreads have started running and the required fixup to td_slptick and td_blktick in the EARLY_AP_STARTUP case. Now, 'ticks' is initialized before any kthreads are created or any context switches are performed. Tested by: gavin MFC after: 2 weeks Sponsored by: Netflix --- sys/kern/kern_clock.c | 38 -------------------------------------- sys/kern/subr_param.c | 6 ++++++ 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 0f85e7d995e..e6c925bbc0c 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -393,10 +393,6 @@ static void initclocks(dummy) void *dummy; { -#ifdef EARLY_AP_STARTUP - struct proc *p; - struct thread *td; -#endif register int i; /* @@ -415,40 +411,6 @@ initclocks(dummy) psratio = profhz / i; #ifdef SW_WATCHDOG EVENTHANDLER_REGISTER(watchdog_list, watchdog_config, NULL, 0); -#endif - /* - * Arrange for ticks to wrap 10 minutes after boot to help catch - * sign problems sooner. - */ - ticks = INT_MAX - (hz * 10 * 60); - -#ifdef EARLY_AP_STARTUP - /* - * Fixup the tick counts in any blocked or sleeping threads to - * account for the jump above. - */ - sx_slock(&allproc_lock); - FOREACH_PROC_IN_SYSTEM(p) { - PROC_LOCK(p); - if (p->p_state == PRS_NEW) { - PROC_UNLOCK(p); - continue; - } - FOREACH_THREAD_IN_PROC(p, td) { - thread_lock(td); - if (TD_ON_LOCK(td)) { - MPASS(td->td_blktick == 0); - td->td_blktick = ticks; - } - if (TD_ON_SLEEPQ(td)) { - MPASS(td->td_slptick == 0); - td->td_slptick = ticks; - } - thread_unlock(td); - } - PROC_UNLOCK(p); - } - sx_sunlock(&allproc_lock); #endif } diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index d8ba53edd0d..3bfbb43779a 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -171,6 +171,12 @@ init_param1(void) tick_sbt = SBT_1S / hz; tick_bt = sbttobt(tick_sbt); + /* + * Arrange for ticks to wrap 10 minutes after boot to help catch + * sign problems sooner. + */ + ticks = INT_MAX - (hz * 10 * 60); + #ifdef VM_SWZONE_SIZE_MAX maxswzone = VM_SWZONE_SIZE_MAX; #endif From 869897d2e5c17fa5f3474a9be1d29a41de8510ec Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 22 Nov 2016 01:22:54 +0000 Subject: [PATCH 050/115] [net80211] flesh out more IBSS 11n support * Pepper comments around which describe what state(s) we're in when faking up 11n nodes. * By default don't fake it up as 11n until we properly negotiate the 11n capabilities using probe request/response frames. * Send a probe request with our HT information, as the 802.11-2012 spec suggests. * Reassociate with the driver if we've been promoted. This is done because although learning a peer via beacons can learn 11n state, learning peers via hearing probe frames and broadcast frames does not. Thus, sometimes you end up with an 11n peer in the peer table and sometimes you don't. Note that the probe request/response exchange may not actually succeed. Ideally we'd put the peer into some blocking state until we've exchanged probe request/reponse to learn capabilities, or we timeout and just stay non-11n. This is more an experiment to get 11n IBSS nodes actually discovering each other and be able to transmit. There are other issues that creep up which I'll attempt to address in future commits. Tested: * AR9380 NICs in 11n mode. Reviewed by: avos Differential Revision: https://reviews.freebsd.org/D8365 --- sys/net80211/ieee80211_adhoc.c | 37 +++++++++++++++++- sys/net80211/ieee80211_node.c | 71 +++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 4 deletions(-) diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c index f32892651e4..435a584c92f 100644 --- a/sys/net80211/ieee80211_adhoc.c +++ b/sys/net80211/ieee80211_adhoc.c @@ -427,8 +427,12 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, goto err; } /* - * Fake up a node for this newly - * discovered member of the IBSS. + * Fake up a node for this newly discovered member + * of the IBSS. + * + * Note: This doesn't "upgrade" the node to 11n; + * that will happen after a probe request/response + * exchange. */ ni = ieee80211_fakeup_adhoc_node(vap, wh->i_addr2); if (ni == NULL) { @@ -773,12 +777,35 @@ adhoc_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, ni = ieee80211_add_neighbor(vap, wh, &scan); else ni = NULL; + + /* + * Send a probe request so we announce 11n + * capabilities. + */ + ieee80211_send_probereq(ni, /* node */ + vap->iv_myaddr, /* SA */ + ni->ni_macaddr, /* DA */ + vap->iv_bss->ni_bssid, /* BSSID */ + vap->iv_bss->ni_essid, + vap->iv_bss->ni_esslen); /* SSID */ + } else if (ni->ni_capinfo == 0) { /* * Update faked node created on transmit. * Note this also updates the tsf. */ ieee80211_init_neighbor(ni, wh, &scan); + + /* + * Send a probe request so we announce 11n + * capabilities. + */ + ieee80211_send_probereq(ni, /* node */ + vap->iv_myaddr, /* SA */ + ni->ni_macaddr, /* DA */ + vap->iv_bss->ni_bssid, /* BSSID */ + vap->iv_bss->ni_essid, + vap->iv_bss->ni_esslen); /* SSID */ } else { /* * Record tsf for potential resync. @@ -889,6 +916,12 @@ adhoc_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, */ ieee80211_send_proberesp(vap, wh->i_addr2, is11bclient(rates, xrates) ? IEEE80211_SEND_LEGACY_11B : 0); + + /* + * Note: we don't benefit from stashing the probe request + * IEs away to use for IBSS negotiation, because we + * typically don't get all of the IEs. + */ break; case IEEE80211_FC0_SUBTYPE_ACTION: diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 05746ad9561..2d1c03f806f 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -324,10 +324,11 @@ ieee80211_create_ibss(struct ieee80211vap* vap, struct ieee80211_channel *chan) struct ieee80211_node *ni; IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, - "%s: creating %s on channel %u%c\n", __func__, + "%s: creating %s on channel %u%c flags 0x%08x\n", __func__, ieee80211_opmode_name[vap->iv_opmode], ieee80211_chan2ieee(ic, chan), - ieee80211_channel_type_char(chan)); + ieee80211_channel_type_char(chan), + chan->ic_flags); ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); if (ni == NULL) { @@ -408,6 +409,14 @@ ieee80211_create_ibss(struct ieee80211vap* vap, struct ieee80211_channel *chan) } } + /* XXX TODO: other bits and pieces - eg fast-frames? */ + + /* If we're an 11n channel then initialise the 11n bits */ + if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) { + /* XXX what else? */ + ieee80211_ht_node_init(ni); + } + (void) ieee80211_sta_join1(ieee80211_ref_node(ni)); } @@ -1549,6 +1558,9 @@ ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, * so we can do interesting things (e.g. use * WME to disable ACK's). */ + /* + * XXX TODO: 11n? + */ if (vap->iv_flags & IEEE80211_F_WME) ni->ni_flags |= IEEE80211_NODE_QOS; #ifdef IEEE80211_SUPPORT_SUPERG @@ -1558,8 +1570,44 @@ ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, } ieee80211_node_setuptxparms(ni); ieee80211_ratectl_node_init(ni); + + /* + * XXX TODO: 11n? At least 20MHz, at least A-MPDU RX, + * not A-MPDU TX; not 11n rates, etc. We'll cycle + * that after we hear that we can indeed do 11n + * (either by a beacon frame or by a probe response.) + */ + + /* + * This is the first time we see the node. + */ if (ic->ic_newassoc != NULL) ic->ic_newassoc(ni, 1); + + /* + * Kick off a probe request to the given node; + * we will then use the probe response to update + * 11n/etc configuration state. + * + * XXX TODO: this isn't guaranteed, and until we get + * a probe response, we won't be able to actually + * do anything 802.11n related to the node. + * So if this does indeed work, maybe we should hold + * off on sending responses until we get the probe + * response, or just default to some sensible subset + * of 802.11n behaviour (eg always allow aggregation + * negotiation TO us, but not FROM us, etc) so we + * aren't entirely busted. + */ + if (vap->iv_opmode == IEEE80211_M_IBSS) { + ieee80211_send_probereq(ni, /* node */ + vap->iv_myaddr, /* SA */ + ni->ni_macaddr, /* DA */ + vap->iv_bss->ni_bssid, /* BSSID */ + vap->iv_bss->ni_essid, + vap->iv_bss->ni_esslen); /* SSID */ + } + /* XXX not right for 802.1x/WPA */ ieee80211_node_authorize(ni); } @@ -1632,6 +1680,21 @@ ieee80211_init_neighbor(struct ieee80211_node *ni, ni->ni_ies.htinfo_ie); ieee80211_node_setuptxparms(ni); ieee80211_ratectl_node_init(ni); + + /* Reassociate; we're now 11n */ + /* + * XXX TODO: this is the wrong thing to do - + * we're calling it with isnew=1 so the ath(4) + * driver reinitialises the rate tables. + * This "mostly" works for ath(4), but it won't + * be right for firmware devices which allocate + * node states. + * + * So, do we just create a new node and delete + * the old one? Or? + */ + if (ni->ni_ic->ic_newassoc) + ni->ni_ic->ic_newassoc(ni, 1); } } @@ -1809,6 +1872,10 @@ ieee80211_find_txnode(struct ieee80211vap *vap, * caller to be consistent with * ieee80211_find_node_locked. */ + /* + * XXX TODO: this doesn't fake up 11n state; we need + * to find another way to get it upgraded. + */ ni = ieee80211_fakeup_adhoc_node(vap, macaddr); if (ni != NULL) (void) ieee80211_ref_node(ni); From 3d12d1f14fb4f87d2d4ff4a01515f46edfe2d9f5 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 22 Nov 2016 02:02:13 +0000 Subject: [PATCH 051/115] [net80211] Remove extra \n. --- sys/net80211/ieee80211_ht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c index 7f8d191644a..74e265ec9dc 100644 --- a/sys/net80211/ieee80211_ht.c +++ b/sys/net80211/ieee80211_ht.c @@ -592,7 +592,7 @@ ieee80211_ampdu_rx_start_ext(struct ieee80211_node *ni, int tid, int seq, int ba rap->rxa_flags |= IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND; IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_11N, ni, - "%s: tid=%d, start=%d, wnd=%d, flags=0x%08x\n", + "%s: tid=%d, start=%d, wnd=%d, flags=0x%08x", __func__, tid, seq, From c969f82d85927c071cdde529d7c61661ad11b5b0 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 22 Nov 2016 02:42:00 +0000 Subject: [PATCH 052/115] [ath] obey the peer A-MPDU density and max-size. * Obey the peer A-MPDU density if it's larger than the currently configured one. * Pay attention to the peer A-MPDU max-size and don't assume we can transmit a full A-MPDU (64k!) if the peer announces smaller values. Relnotes: ath(4): Fix A-MPDU transmit; obey A-MPDU density and max size. --- sys/dev/ath/if_ath_tx_ht.c | 63 ++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/sys/dev/ath/if_ath_tx_ht.c b/sys/dev/ath/if_ath_tx_ht.c index d6ca6e2cc83..d4b0961f4d9 100644 --- a/sys/dev/ath/if_ath_tx_ht.c +++ b/sys/dev/ath/if_ath_tx_ht.c @@ -319,8 +319,8 @@ ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf) * and we're not doing positioning, enable STBC. */ if (ic->ic_htcaps & IEEE80211_HTCAP_TXSTBC && - ni->ni_vap->iv_flags_ht & IEEE80211_FHT_STBC_TX && - ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM && + (ni->ni_vap->iv_flags_ht & IEEE80211_FHT_STBC_TX) && + (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC) && (sc->sc_cur_txchainmask > 1) && (HT_RC_2_STREAMS(rate) == 1) && (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) { @@ -404,24 +404,40 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, uint16_t pktlen) { +#define MS(_v, _f) (((_v) & _f) >> _f##_S) const HAL_RATE_TABLE *rt = sc->sc_currates; struct ieee80211_node *ni = first_bf->bf_node; struct ieee80211vap *vap = ni->ni_vap; int ndelim, mindelim = 0; - int mpdudensity; /* in 1/100'th of a microsecond */ + int mpdudensity; /* in 1/100'th of a microsecond */ + int peer_mpdudensity; /* net80211 value */ uint8_t rc, rix, flags; int width, half_gi; uint32_t nsymbits, nsymbols; uint16_t minlen; /* - * vap->iv_ampdu_density is a value, rather than the actual - * density. + * Get the advertised density from the node. */ - if (vap->iv_ampdu_density > IEEE80211_HTCAP_MPDUDENSITY_16) + peer_mpdudensity = MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + + /* + * vap->iv_ampdu_density is a net80211 value, rather than the actual + * density. Larger values are longer A-MPDU density spacing values, + * and we want to obey larger configured / negotiated density values + * per station if we get it. + */ + if (vap->iv_ampdu_density > peer_mpdudensity) + peer_mpdudensity = vap->iv_ampdu_density; + + /* + * Convert the A-MPDU density net80211 value to a 1/100 microsecond + * value for subsequent calculations. + */ + if (peer_mpdudensity > IEEE80211_HTCAP_MPDUDENSITY_16) mpdudensity = 1600; /* maximum density */ else - mpdudensity = ieee80211_mpdudensity_map[vap->iv_ampdu_density]; + mpdudensity = ieee80211_mpdudensity_map[peer_mpdudensity]; /* Select standard number of delimiters based on frame length */ ndelim = ATH_AGGR_GET_NDELIM(pktlen); @@ -509,22 +525,49 @@ ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, __func__, pktlen, minlen, rix, rc, width, half_gi, ndelim); return ndelim; +#undef MS } /* * Fetch the aggregation limit. * * It's the lowest of the four rate series 4ms frame length. + * + * Also take into account the hardware specific limits (8KiB on AR5416) + * and per-peer limits in non-STA mode. */ static int -ath_get_aggr_limit(struct ath_softc *sc, struct ath_buf *bf) +ath_get_aggr_limit(struct ath_softc *sc, struct ieee80211_node *ni, + struct ath_buf *bf) { +#define MS(_v, _f) (((_v) & _f) >> _f##_S) int amin = ATH_AGGR_MAXSIZE; int i; + /* Extract out the maximum configured driver A-MPDU limit */ if (sc->sc_aggr_limit > 0 && sc->sc_aggr_limit < ATH_AGGR_MAXSIZE) amin = sc->sc_aggr_limit; + /* + * Check the HTCAP field for the maximum size the node has + * negotiated. If it's smaller than what we have, cap it there. + */ + switch (MS(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU)) { + case IEEE80211_HTCAP_MAXRXAMPDU_16K: + amin = MIN(amin, 16384); + break; + case IEEE80211_HTCAP_MAXRXAMPDU_32K: + amin = MIN(amin, 32768); + break; + case IEEE80211_HTCAP_MAXRXAMPDU_64K: + amin = MIN(amin, 65536); + break; + case IEEE80211_HTCAP_MAXRXAMPDU_8K: + default: + amin = MIN(amin, 8192); + break; + } + for (i = 0; i < ATH_RC_NUM; i++) { if (bf->bf_state.bfs_rc[i].tries == 0) continue; @@ -535,6 +578,7 @@ ath_get_aggr_limit(struct ath_softc *sc, struct ath_buf *bf) __func__, amin); return amin; +#undef MS } /* @@ -787,7 +831,8 @@ ath_tx_form_aggr(struct ath_softc *sc, struct ath_node *an, * set the aggregation limit based on the * rate control decision that has been made. */ - aggr_limit = ath_get_aggr_limit(sc, bf_first); + aggr_limit = ath_get_aggr_limit(sc, &an->an_node, + bf_first); } /* Set this early just so things don't get confused */ From 74a54be9a43af7469a005e893a656774dc3c85dd Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 22 Nov 2016 02:51:06 +0000 Subject: [PATCH 053/115] [net80211] store references to VHT and related IEs. This just stores pointers to the IE; it doesn't yet parse anything. Note: it blows out the size of ieee80211_node, so this will require ye olde kernel/modules recompile. --- sys/net80211/ieee80211_node.c | 19 +++++++++++++++++++ sys/net80211/ieee80211_node.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 2d1c03f806f..c08051f6827 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -896,6 +896,10 @@ ieee80211_sta_join(struct ieee80211vap *vap, struct ieee80211_channel *chan, if (ni->ni_ies.tdma_ie != NULL) ieee80211_parse_tdma(ni, ni->ni_ies.tdma_ie); #endif + + /* XXX parse VHT IEs */ + /* XXX parse BSSLOAD IE */ + /* XXX parse APCHANREP IE */ } vap->iv_dtim_period = se->se_dtimperiod; @@ -1055,6 +1059,21 @@ ieee80211_ies_expand(struct ieee80211_ies *ies) ies->meshid_ie = ie; break; #endif + case IEEE80211_ELEMID_VHT_CAP: + ies->vhtcap_ie = ie; + break; + case IEEE80211_ELEMID_VHT_OPMODE: + ies->vhtopmode_ie = ie; + break; + case IEEE80211_ELEMID_VHT_PWR_ENV: + ies->vhtpwrenv_ie = ie; + break; + case IEEE80211_ELEMID_BSSLOAD: + ies->bssload_ie = ie; + break; + case IEEE80211_ELEMID_APCHANREP: + ies->apchanrep_ie = ie; + break; } ielen -= 2 + ie[1]; ie += 2 + ie[1]; diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 7bbf9761c97..699247d658e 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -83,6 +83,11 @@ struct ieee80211_ies { uint8_t *htinfo_ie; /* captured HTINFO ie */ uint8_t *tdma_ie; /* captured TDMA ie */ uint8_t *meshid_ie; /* captured MESH ID ie */ + uint8_t *vhtcap_ie; /* captured VHTCAP ie */ + uint8_t *vhtopmode_ie; /* captured VHTOPMODE ie */ + uint8_t *vhtpwrenv_ie; /* captured VHTPWRENV ie */ + uint8_t *apchanrep_ie; /* captured APCHANREP ie */ + uint8_t *bssload_ie; /* captured BSSLOAD ie */ uint8_t *spare[4]; /* NB: these must be the last members of this structure */ uint8_t *data; /* frame data > 802.11 header */ From 01b922f62c559f5778a983c365d390371956a214 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Tue, 22 Nov 2016 06:28:26 +0000 Subject: [PATCH 054/115] Vendor import of ntp-4.2.8p9. --- ChangeLog | 71 +- CommitLog | 1896 ++++++++++++- NEWS | 307 ++ configure | 20 +- html/drivers/driver40-ja.html | 4 +- html/drivers/driver40.html | 4 +- html/miscopt.html | 6 +- include/Makefile.am | 1 + include/Makefile.in | 1 + include/libssl_compat.h | 100 + include/ntp.h | 10 +- include/ntp_intres.h | 6 + include/ntpd.h | 1 + lib/isc/netaddr.c | 1 - libntp/Makefile.am | 1 + libntp/Makefile.in | 67 +- libntp/a_md5encrypt.c | 62 +- libntp/audio.c | 6 +- libntp/libssl_compat.c | 335 +++ libntp/ntp_calendar.c | 85 +- libntp/ntp_intres.c | 62 +- libntp/ssl_init.c | 11 +- libntp/work_fork.c | 18 +- libparse/clk_hopf6021.c | 68 +- ntpd/complete.conf.in | 2 +- ntpd/invoke-ntp.conf.texi | 17 +- ntpd/invoke-ntp.keys.texi | 2 +- ntpd/invoke-ntpd.texi | 4 +- ntpd/keyword-gen-utd | 2 +- ntpd/keyword-gen.c | 1 + ntpd/ntp.conf.5man | 39 +- ntpd/ntp.conf.5mdoc | 23 +- ntpd/ntp.conf.def | 19 + ntpd/ntp.conf.html | 110 +- ntpd/ntp.conf.man.in | 39 +- ntpd/ntp.conf.mdoc.in | 23 +- ntpd/ntp.keys.5man | 4 +- ntpd/ntp.keys.5mdoc | 4 +- ntpd/ntp.keys.html | 2 +- ntpd/ntp.keys.man.in | 4 +- ntpd/ntp.keys.mdoc.in | 4 +- ntpd/ntp_config.c | 36 +- ntpd/ntp_control.c | 156 +- ntpd/ntp_crypto.c | 345 ++- ntpd/ntp_keyword.h | 2126 +++++++------- ntpd/ntp_loopfilter.c | 11 +- ntpd/ntp_parser.c | 2513 +++++++++-------- ntpd/ntp_parser.h | 744 ++--- ntpd/ntp_parser.y | 4 +- ntpd/ntp_peer.c | 114 +- ntpd/ntp_proto.c | 153 +- ntpd/ntp_refclock.c | 62 +- ntpd/ntpd-opts.c | 14 +- ntpd/ntpd-opts.h | 6 +- ntpd/ntpd.1ntpdman | 6 +- ntpd/ntpd.1ntpdmdoc | 4 +- ntpd/ntpd.html | 4 +- ntpd/ntpd.man.in | 6 +- ntpd/ntpd.mdoc.in | 4 +- ntpd/refclock_gpsdjson.c | 2 +- ntpd/refclock_jjy.c | 8 +- ntpd/refclock_jupiter.c | 67 +- ntpdc/invoke-ntpdc.texi | 4 +- ntpdc/ntpdc-opts.c | 14 +- ntpdc/ntpdc-opts.h | 6 +- ntpdc/ntpdc.1ntpdcman | 6 +- ntpdc/ntpdc.1ntpdcmdoc | 4 +- ntpdc/ntpdc.html | 4 +- ntpdc/ntpdc.man.in | 6 +- ntpdc/ntpdc.mdoc.in | 4 +- ntpq/invoke-ntpq.texi | 4 +- ntpq/ntpq-opts.c | 14 +- ntpq/ntpq-opts.h | 6 +- ntpq/ntpq.1ntpqman | 6 +- ntpq/ntpq.1ntpqmdoc | 4 +- ntpq/ntpq.c | 9 +- ntpq/ntpq.html | 4 +- ntpq/ntpq.man.in | 6 +- ntpq/ntpq.mdoc.in | 4 +- ntpsnmpd/invoke-ntpsnmpd.texi | 4 +- ntpsnmpd/ntpsnmpd-opts.c | 14 +- ntpsnmpd/ntpsnmpd-opts.h | 6 +- ntpsnmpd/ntpsnmpd.1ntpsnmpdman | 6 +- ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc | 4 +- ntpsnmpd/ntpsnmpd.html | 2 +- ntpsnmpd/ntpsnmpd.man.in | 6 +- ntpsnmpd/ntpsnmpd.mdoc.in | 4 +- packageinfo.sh | 2 +- ports/winnt/include/ntp_iocompletionport.h | 2 +- ports/winnt/include/ntp_iocpltypes.h | 46 +- ports/winnt/include/termios.h | 3 + ports/winnt/libntp/termios.c | 311 +- ports/winnt/ntpd/ntp_iocompletionport.c | 732 +++-- ports/winnt/ntpd/ntp_iocpltypes.c | 130 +- ports/winnt/vs2005/libntp.vcproj | 8 + ports/winnt/vs2008/libntp/libntp.vcproj | 12 + ports/winnt/vs2013/libntp/libntp.vcxproj | 5 +- .../vs2013/libntp/libntp.vcxproj.filters | 19 +- ports/winnt/vs2015/libntp/libntp.vcxproj | 3 + .../vs2015/libntp/libntp.vcxproj.filters | 9 + ports/winnt/vs2015/ntp.sln | 6 +- scripts/build/genAuthors.in | 12 +- .../calc_tickadj.1calc_tickadjman | 6 +- .../calc_tickadj.1calc_tickadjmdoc | 4 +- scripts/calc_tickadj/calc_tickadj.html | 2 +- scripts/calc_tickadj/calc_tickadj.man.in | 6 +- scripts/calc_tickadj/calc_tickadj.mdoc.in | 4 +- scripts/calc_tickadj/invoke-calc_tickadj.texi | 2 +- scripts/invoke-plot_summary.texi | 4 +- scripts/invoke-summary.texi | 4 +- scripts/ntp-wait/invoke-ntp-wait.texi | 4 +- scripts/ntp-wait/ntp-wait-opts | 4 +- scripts/ntp-wait/ntp-wait.1ntp-waitman | 6 +- scripts/ntp-wait/ntp-wait.1ntp-waitmdoc | 4 +- scripts/ntp-wait/ntp-wait.html | 4 +- scripts/ntp-wait/ntp-wait.man.in | 6 +- scripts/ntp-wait/ntp-wait.mdoc.in | 4 +- scripts/ntpsweep/invoke-ntpsweep.texi | 4 +- scripts/ntpsweep/ntpsweep-opts | 4 +- scripts/ntpsweep/ntpsweep.1ntpsweepman | 6 +- scripts/ntpsweep/ntpsweep.1ntpsweepmdoc | 4 +- scripts/ntpsweep/ntpsweep.html | 4 +- scripts/ntpsweep/ntpsweep.man.in | 6 +- scripts/ntpsweep/ntpsweep.mdoc.in | 4 +- scripts/ntptrace/invoke-ntptrace.texi | 4 +- scripts/ntptrace/ntptrace-opts | 4 +- scripts/ntptrace/ntptrace.1ntptraceman | 6 +- scripts/ntptrace/ntptrace.1ntptracemdoc | 4 +- scripts/ntptrace/ntptrace.html | 4 +- scripts/ntptrace/ntptrace.man.in | 6 +- scripts/ntptrace/ntptrace.mdoc.in | 4 +- scripts/plot_summary-opts | 4 +- scripts/plot_summary.1plot_summaryman | 6 +- scripts/plot_summary.1plot_summarymdoc | 4 +- scripts/plot_summary.html | 4 +- scripts/plot_summary.man.in | 6 +- scripts/plot_summary.mdoc.in | 4 +- scripts/summary-opts | 4 +- scripts/summary.1summaryman | 6 +- scripts/summary.1summarymdoc | 4 +- scripts/summary.html | 4 +- scripts/summary.man.in | 6 +- scripts/summary.mdoc.in | 4 +- scripts/update-leap/invoke-update-leap.texi | 2 +- scripts/update-leap/update-leap-opts | 4 +- .../update-leap/update-leap.1update-leapman | 6 +- .../update-leap/update-leap.1update-leapmdoc | 4 +- scripts/update-leap/update-leap.html | 2 +- scripts/update-leap/update-leap.in | 7 +- scripts/update-leap/update-leap.man.in | 6 +- scripts/update-leap/update-leap.mdoc.in | 4 +- sntp/configure | 20 +- sntp/crypto.c | 18 +- sntp/include/version.def | 2 +- sntp/include/version.texi | 6 +- sntp/invoke-sntp.texi | 4 +- sntp/m4/version.m4 | 2 +- sntp/sntp-opts.c | 14 +- sntp/sntp-opts.h | 6 +- sntp/sntp.1sntpman | 6 +- sntp/sntp.1sntpmdoc | 4 +- sntp/sntp.html | 4 +- sntp/sntp.man.in | 6 +- sntp/sntp.mdoc.in | 4 +- sntp/tests/packetProcessing.c | 196 +- sntp/tests/run-packetProcessing.c | 36 +- sntp/unity/Makefile.am | 2 + sntp/unity/Makefile.in | 37 +- sntp/unity/ulib_setup.c | 14 + sntp/unity/ulib_teardown.c | 13 + sntp/unity/unity_fixture.c | 4 - sntp/version.c | 2 +- tests/libntp/a_md5encrypt.c | 4 +- tests/libntp/calendar.c | 127 + tests/libntp/run-calendar.c | 35 +- tests/libntp/sfptostr.c | 6 +- tests/ntpd/Makefile.am | 1 - tests/ntpd/Makefile.in | 18 +- util/invoke-ntp-keygen.texi | 4 +- util/ntp-keygen-opts.c | 14 +- util/ntp-keygen-opts.h | 6 +- util/ntp-keygen.1ntp-keygenman | 6 +- util/ntp-keygen.1ntp-keygenmdoc | 4 +- util/ntp-keygen.c | 367 ++- util/ntp-keygen.html | 4 +- util/ntp-keygen.man.in | 6 +- util/ntp-keygen.mdoc.in | 4 +- 187 files changed, 8151 insertions(+), 4352 deletions(-) create mode 100644 include/libssl_compat.h create mode 100644 libntp/libssl_compat.c create mode 100644 sntp/unity/ulib_setup.c create mode 100644 sntp/unity/ulib_teardown.c diff --git a/ChangeLog b/ChangeLog index 0805467dc6b..0cb8c4fb477 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,72 @@ +--- +(4.2.8p9) 2016/11/21 Released by Harlan Stenn +(4.2.8p9) 2016/MM/DD Released by Harlan Stenn + +* [Sec 3119] Trap crash +* [Sec 3118] Mode 6 information disclosure and DDoS vector + - TRAP config via mode 6 packet requires AUTH now. +* [Sec 3114] Broadcast Mode Replay Prevention DoS + - applied patches by Matthew Van Gundy. + - with bcpollbstep, tweaks and cleanup by stenn@ntp.org +* [Sec 3113] Broadcast Mode Poll Interval Enforcement DoS + - applied fix as suggested by Matthew Van Gundy +* [Sec 3110] Windows: ntpd DoS by oversized UDP packet + - fixed error handling for truncated UDP packets. +* [Sec 3102] Zero origin issues. HStenn. +* [Sec 3082] null pointer dereference in _IO_str_init_static_internal() + - more hardening to read_mru_list(). perlinger@ntp.org +* [Sec 3072] Attack on interface selection + - implemented Miroslav Lichvars suggestion + to skip interface updates based on incoming packets +* [Bug 3142] bug in netmask prefix length detection +* [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org +* [Bug 3129] Unknown hosts can put resolver thread into a hard loop + - moved retry decision where it belongs. +* [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order + using the loopback-ppsapi-provider.dll +* [Bug 3116] unit tests for NTP time stamp expansion. +* [Bug 3100] ntpq can't retrieve daemon_version + - fixed extended sysvar lookup (bug introduced with bug 3008 fix) +* [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx to source + - added shim layer for SSL API calls with issues (both directions) +* [Bug 3089] Serial Parser does not work anymore for hopfser like device + - simplified / refactored hex-decoding in driver. +* [Bug 3084] update-leap mis-parses the leapfile name. HStenn. +* [Bug 3068] Linker warnings when building on Solaris. perlinger@ntp.org + - applied patch thanks to Andrew Stormont +* [Bug 3067] Root distance calculation needs improvement. HStenn. +* [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org + - PPS-HACK works again. +* [Bug 3059] Potential buffer overrun from oversized hash + - applied patch by Brian Utterback +* [Bug 3053] ntp_loopfilter.c frequency calc precedence error. Sarah White. +* [Bug 3050] Fix for bug #2960 causes [...] spurious error message. + + - patches by Reinhard Max and Havard Eidnes +* [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + - Patch provided by Kuramatsu. +* [Bug 3021] unity_fixture.c needs pragma weak + - removed unnecessary & harmful decls of 'setUp()' & 'tearDown()' +* [Bug 3019] Windows: ERROR_HOST_UNREACHABLE block packet processing. + DMayer and JPerlinger. +* [Bug 2998] sntp/tests/packetProcessing.c broken without openssl. JPerlinger +* [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY. HStenn. +* [Bug 2959] refclock_jupiter: gps week correction + - fixed GPS week expansion to work based on build date. Special thanks + to Craig Leres for initial patch and testing. +* [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd' + - fixed Makefile.am +* [Bug 2689] ATOM driver processes last PPS pulse at startup, + even if it is very old + - make sure PPS source is alive before processing samples + - improve stability close to the 500ms phase jump (phase gate) +* Fix typos in include/ntp.h. +* Shim X509_get_signature_nid() if needed. +* git author attribution cleanup +* bk ignore file cleanup +* remove locks in Windows IO, use rpc-like thread synchronisation instead + --- (4.2.8p8) 2016/06/02 Released by Harlan Stenn @@ -19,7 +88,7 @@ * Fix typo in ntp-wait and plot_summary. HStenn. * Make sure we have an "author" file for git imports. HStenn. * Update the sntp problem tests for MacOS. HStenn. - + --- (4.2.8p7) 2016/04/26 Released by Harlan Stenn diff --git a/CommitLog b/CommitLog index 45777550d71..1c4c87f9069 100644 --- a/CommitLog +++ b/CommitLog @@ -1,3 +1,1866 @@ +ChangeSet@1.3720, 2016-11-21 08:08:21-05:00, stenn@deacon.udel.edu + NTP_4_2_8P9 + TAG: NTP_4_2_8P9 + + ChangeLog@1.1852 +1 -0 + NTP_4_2_8P9 + + ntpd/invoke-ntp.conf.texi@1.203 +1 -1 + NTP_4_2_8P9 + + ntpd/invoke-ntp.keys.texi@1.192 +1 -1 + NTP_4_2_8P9 + + ntpd/invoke-ntpd.texi@1.508 +2 -2 + NTP_4_2_8P9 + + ntpd/ntp.conf.5man@1.237 +3 -3 + NTP_4_2_8P9 + + ntpd/ntp.conf.5mdoc@1.237 +2 -2 + NTP_4_2_8P9 + + ntpd/ntp.conf.html@1.187 +157 -154 + NTP_4_2_8P9 + + ntpd/ntp.conf.man.in@1.237 +3 -3 + NTP_4_2_8P9 + + ntpd/ntp.conf.mdoc.in@1.237 +2 -2 + NTP_4_2_8P9 + + ntpd/ntp.keys.5man@1.226 +2 -2 + NTP_4_2_8P9 + + ntpd/ntp.keys.5mdoc@1.226 +3 -3 + NTP_4_2_8P9 + + ntpd/ntp.keys.html@1.188 +21 -33 + NTP_4_2_8P9 + + ntpd/ntp.keys.man.in@1.226 +2 -2 + NTP_4_2_8P9 + + ntpd/ntp.keys.mdoc.in@1.226 +3 -3 + NTP_4_2_8P9 + + ntpd/ntpd-opts.c@1.530 +245 -245 + NTP_4_2_8P9 + + ntpd/ntpd-opts.h@1.529 +3 -3 + NTP_4_2_8P9 + + ntpd/ntpd.1ntpdman@1.337 +3 -3 + NTP_4_2_8P9 + + ntpd/ntpd.1ntpdmdoc@1.337 +2 -2 + NTP_4_2_8P9 + + ntpd/ntpd.html@1.181 +142 -186 + NTP_4_2_8P9 + + ntpd/ntpd.man.in@1.337 +3 -3 + NTP_4_2_8P9 + + ntpd/ntpd.mdoc.in@1.337 +2 -2 + NTP_4_2_8P9 + + ntpdc/invoke-ntpdc.texi@1.505 +2 -2 + NTP_4_2_8P9 + + ntpdc/ntpdc-opts.c@1.523 +106 -106 + NTP_4_2_8P9 + + ntpdc/ntpdc-opts.h@1.522 +3 -3 + NTP_4_2_8P9 + + ntpdc/ntpdc.1ntpdcman@1.336 +3 -3 + NTP_4_2_8P9 + + ntpdc/ntpdc.1ntpdcmdoc@1.336 +2 -2 + NTP_4_2_8P9 + + ntpdc/ntpdc.html@1.349 +75 -95 + NTP_4_2_8P9 + + ntpdc/ntpdc.man.in@1.336 +3 -3 + NTP_4_2_8P9 + + ntpdc/ntpdc.mdoc.in@1.336 +2 -2 + NTP_4_2_8P9 + + ntpq/invoke-ntpq.texi@1.513 +2 -2 + NTP_4_2_8P9 + + ntpq/ntpq-opts.c@1.530 +113 -113 + NTP_4_2_8P9 + + ntpq/ntpq-opts.h@1.528 +3 -3 + NTP_4_2_8P9 + + ntpq/ntpq.1ntpqman@1.341 +3 -3 + NTP_4_2_8P9 + + ntpq/ntpq.1ntpqmdoc@1.341 +2 -2 + NTP_4_2_8P9 + + ntpq/ntpq.html@1.178 +136 -160 + NTP_4_2_8P9 + + ntpq/ntpq.man.in@1.341 +3 -3 + NTP_4_2_8P9 + + ntpq/ntpq.mdoc.in@1.341 +2 -2 + NTP_4_2_8P9 + + ntpsnmpd/invoke-ntpsnmpd.texi@1.507 +2 -2 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd-opts.c@1.525 +67 -67 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd-opts.h@1.524 +3 -3 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.336 +3 -3 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.336 +2 -2 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd.html@1.176 +10 -14 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd.man.in@1.336 +3 -3 + NTP_4_2_8P9 + + ntpsnmpd/ntpsnmpd.mdoc.in@1.336 +2 -2 + NTP_4_2_8P9 + + packageinfo.sh@1.532 +2 -2 + NTP_4_2_8P9 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.97 +3 -3 + NTP_4_2_8P9 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.98 +2 -2 + NTP_4_2_8P9 + + scripts/calc_tickadj/calc_tickadj.html@1.99 +30 -42 + NTP_4_2_8P9 + + scripts/calc_tickadj/calc_tickadj.man.in@1.96 +3 -3 + NTP_4_2_8P9 + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.98 +2 -2 + NTP_4_2_8P9 + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.101 +1 -1 + NTP_4_2_8P9 + + scripts/invoke-plot_summary.texi@1.119 +2 -2 + NTP_4_2_8P9 + + scripts/invoke-summary.texi@1.118 +2 -2 + NTP_4_2_8P9 + + scripts/ntp-wait/invoke-ntp-wait.texi@1.328 +2 -2 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait-opts@1.64 +2 -2 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.325 +3 -3 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.326 +2 -2 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait.html@1.345 +41 -59 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait.man.in@1.325 +3 -3 + NTP_4_2_8P9 + + scripts/ntp-wait/ntp-wait.mdoc.in@1.326 +2 -2 + NTP_4_2_8P9 + + scripts/ntpsweep/invoke-ntpsweep.texi@1.116 +2 -2 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep-opts@1.66 +2 -2 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.104 +3 -3 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.104 +2 -2 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep.html@1.117 +46 -57 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep.man.in@1.104 +3 -3 + NTP_4_2_8P9 + + scripts/ntpsweep/ntpsweep.mdoc.in@1.105 +2 -2 + NTP_4_2_8P9 + + scripts/ntptrace/invoke-ntptrace.texi@1.117 +2 -2 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace-opts@1.66 +2 -2 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace.1ntptraceman@1.104 +3 -3 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.105 +2 -2 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace.html@1.118 +38 -47 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace.man.in@1.104 +3 -3 + NTP_4_2_8P9 + + scripts/ntptrace/ntptrace.mdoc.in@1.106 +2 -2 + NTP_4_2_8P9 + + scripts/plot_summary-opts@1.67 +2 -2 + NTP_4_2_8P9 + + scripts/plot_summary.1plot_summaryman@1.117 +3 -3 + NTP_4_2_8P9 + + scripts/plot_summary.1plot_summarymdoc@1.117 +2 -2 + NTP_4_2_8P9 + + scripts/plot_summary.html@1.120 +40 -58 + NTP_4_2_8P9 + + scripts/plot_summary.man.in@1.117 +3 -3 + NTP_4_2_8P9 + + scripts/plot_summary.mdoc.in@1.117 +2 -2 + NTP_4_2_8P9 + + scripts/summary-opts@1.66 +2 -2 + NTP_4_2_8P9 + + scripts/summary.1summaryman@1.116 +3 -3 + NTP_4_2_8P9 + + scripts/summary.1summarymdoc@1.116 +2 -2 + NTP_4_2_8P9 + + scripts/summary.html@1.119 +37 -49 + NTP_4_2_8P9 + + scripts/summary.man.in@1.116 +3 -3 + NTP_4_2_8P9 + + scripts/summary.mdoc.in@1.116 +2 -2 + NTP_4_2_8P9 + + scripts/update-leap/invoke-update-leap.texi@1.17 +1 -1 + NTP_4_2_8P9 + + scripts/update-leap/update-leap-opts@1.17 +2 -2 + NTP_4_2_8P9 + + scripts/update-leap/update-leap.1update-leapman@1.17 +3 -3 + NTP_4_2_8P9 + + scripts/update-leap/update-leap.1update-leapmdoc@1.17 +2 -2 + NTP_4_2_8P9 + + scripts/update-leap/update-leap.html@1.17 +48 -72 + NTP_4_2_8P9 + + scripts/update-leap/update-leap.man.in@1.17 +3 -3 + NTP_4_2_8P9 + + scripts/update-leap/update-leap.mdoc.in@1.17 +2 -2 + NTP_4_2_8P9 + + sntp/invoke-sntp.texi@1.505 +2 -2 + NTP_4_2_8P9 + + sntp/sntp-opts.c@1.524 +158 -158 + NTP_4_2_8P9 + + sntp/sntp-opts.h@1.522 +3 -3 + NTP_4_2_8P9 + + sntp/sntp.1sntpman@1.340 +3 -3 + NTP_4_2_8P9 + + sntp/sntp.1sntpmdoc@1.340 +2 -2 + NTP_4_2_8P9 + + sntp/sntp.html@1.520 +111 -135 + NTP_4_2_8P9 + + sntp/sntp.man.in@1.340 +3 -3 + NTP_4_2_8P9 + + sntp/sntp.mdoc.in@1.340 +2 -2 + NTP_4_2_8P9 + + util/invoke-ntp-keygen.texi@1.508 +2 -2 + NTP_4_2_8P9 + + util/ntp-keygen-opts.c@1.526 +172 -172 + NTP_4_2_8P9 + + util/ntp-keygen-opts.h@1.524 +3 -3 + NTP_4_2_8P9 + + util/ntp-keygen.1ntp-keygenman@1.336 +3 -3 + NTP_4_2_8P9 + + util/ntp-keygen.1ntp-keygenmdoc@1.336 +2 -2 + NTP_4_2_8P9 + + util/ntp-keygen.html@1.182 +157 -216 + NTP_4_2_8P9 + + util/ntp-keygen.man.in@1.336 +3 -3 + NTP_4_2_8P9 + + util/ntp-keygen.mdoc.in@1.336 +2 -2 + NTP_4_2_8P9 + +ChangeSet@1.3719, 2016-11-21 07:07:04-05:00, stenn@deacon.udel.edu + ntp-4.2.8p9 + + packageinfo.sh@1.531 +1 -1 + ntp-4.2.8p9 + +ChangeSet@1.3718, 2016-11-21 03:47:58+00:00, stenn@psp-deb1.ntp.org + NEWS updates, final p9 testing + + NEWS@1.203 +25 -17 + NEWS updates, final p9 testing + + packageinfo.sh@1.530 +2 -2 + NEWS updates, final p9 testing + +ChangeSet@1.3717, 2016-11-18 10:33:02+00:00, stenn@psp-deb1.ntp.org + NEWS update for 3142 + + NEWS@1.202 +2 -1 + NEWS update for 3142 + +ChangeSet@1.3686.23.1, 2016-11-18 08:55:13+01:00, perlinger@ntp.org + [Bug 3142] bug in netmask prefix length detection + + ChangeLog@1.1834.23.1 +3 -0 + [Bug 3142] bug in netmask prefix length detection + + lib/isc/netaddr.c@1.15 +0 -1 + [Bug 3142] bug in netmask prefix length detection + +ChangeSet@1.3715, 2016-11-16 21:25:49-08:00, harlan@fb-x86-a.pfcs.com + NEWS file update + + NEWS@1.201 +7 -22 + NEWS file update + +ChangeSet@1.3707.1.1, 2016-11-13 21:59:31-08:00, harlan@fb-x86-a.pfcs.com + cleanup + + NEWS@1.197.1.1 +201 -77 + cleanup + +ChangeSet@1.3713, 2016-11-13 21:56:18-08:00, harlan@hms-mbp11.pfcs.com + cleanip + + ChangeLog@1.1850 +2 -0 + cleanip + +ChangeSet@1.3712, 2016-11-13 02:43:02+00:00, stenn@psp-deb1.ntp.org + NEWS updates + + NEWS@1.199 +17 -0 + NEWS updates + +ChangeSet@1.3710, 2016-11-13 02:30:31+00:00, stenn@psp-deb1.ntp.org + NEWS cleanup + + NEWS@1.198 +2 -0 + NEWS cleanup + +ChangeSet@1.3707, 2016-11-12 17:36:54-08:00, harlan@fb-x86-a.pfcs.com + NEWS cleanup + + NEWS@1.197 +41 -6 + NEWS cleanup + +ChangeSet@1.3706, 2016-11-12 16:55:59-08:00, harlan@fb-x86-a.pfcs.com + [Bug 3067] Root distance calculation needs improvement. HStenn + + ChangeLog@1.1846.1.2 +1 -0 + [Bug 3067] Root distance calculation needs improvement. HStenn + + NEWS@1.196 +1 -0 + [Bug 3067] Root distance calculation needs improvement. HStenn + + ntpd/ntp_proto.c@1.396 +16 -11 + [Bug 3067] Root distance calculation needs improvement. HStenn + +ChangeSet@1.3705, 2016-11-12 15:57:34-08:00, harlan@fb-x86-a.pfcs.com + [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org + + ChangeLog@1.1846.1.1 +1 -0 + [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org + + NEWS@1.195 +1 -0 + [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org + + ntpd/refclock_gpsdjson.c@1.25 +1 -1 + [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org + +ChangeSet@1.3686.22.1, 2016-11-12 05:54:39+01:00, perlinger@ntp.org + [Bug 3129] Unknown hosts can put resolver thread into a hard loop + + ChangeLog@1.1834.22.1 +4 -0 + [Bug 3129] Unknown hosts can put resolver thread into a hard loop + + include/ntp_intres.h@1.2 +6 -0 + [Bug 3129] Unknown hosts can put resolver thread into a hard loop + - add flags and prototype for 'getaddrinfo_sometime_ex()' + + libntp/ntp_intres.c@1.101 +48 -14 + [Bug 3129] Unknown hosts can put resolver thread into a hard loop + - implement 'getaddrinfo_sometime_ex()', support ignoring all errors + + ntpd/ntp_config.c@1.338.1.1 +11 -10 + [Bug 3129] Unknown hosts can put resolver thread into a hard loop + - move decison about igoring DNS errors to resolver code + +ChangeSet@1.3703.1.2, 2016-11-09 12:32:07+00:00, stenn@psp-deb1.ntp.org + [Bug 3114] bcpollbstep, tweaks and cleanup + + ChangeLog@1.1848 +1 -1 + [Bug 3114] bcpollbstep, tweaks and cleanup + + html/miscopt.html@1.87 +4 -2 + [Bug 3114] bcpollbstep, tweaks and cleanup + + include/ntp.h@1.223 +1 -0 + [Bug 3114] bcpollbstep, tweaks and cleanup + + include/ntpd.h@1.194 +1 -0 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/complete.conf.in@1.32 +1 -1 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/invoke-ntp.conf.texi@1.202 +16 -1 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/keyword-gen-utd@1.29 +1 -1 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/keyword-gen.c@1.35 +1 -0 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp.conf.5man@1.236 +29 -8 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp.conf.5mdoc@1.236 +21 -2 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp.conf.def@1.25 +19 -0 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp.conf.man.in@1.236 +29 -8 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp.conf.mdoc.in@1.236 +21 -2 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_config.c@1.339 +15 -0 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_keyword.h@1.31 +1068 -1058 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_parser.c@1.103 +1196 -1193 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_parser.h@1.67 +373 -371 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_parser.y@1.93 +3 -1 + [Bug 3114] bcpollbstep, tweaks and cleanup + + ntpd/ntp_proto.c@1.394.1.2 +43 -26 + [Bug 3114] bcpollbstep, tweaks and cleanup + +ChangeSet@1.3703, 2016-11-09 06:06:04+00:00, stenn@psp-deb1.ntp.org + typo + + ChangeLog@1.1846 +1 -1 + typo + +ChangeSet@1.3686.21.1, 2016-11-08 20:01:41+01:00, perlinger@ntp.org + [Bug 3089] Serial Parser does not work anymore for hopfser like device + + ChangeLog@1.1834.21.1 +4 -0 + [Bug 3089] Serial Parser does not work anymore for hopfser like device + + libparse/clk_hopf6021.c@1.13 +43 -25 + [Bug 3089] Serial Parser does not work anymore for hopfser like device + - simplified / refactored hex-decoding in driver. + +ChangeSet@1.3698.2.1, 2016-11-03 17:02:24-07:00, harlan@max.pfcs.com + Added leap smear/root dispersion comment + + ntpd/ntp_proto.c@1.393.1.1 +4 -0 + Added leap smear/root dispersion comment + +ChangeSet@1.3699.1.2, 2016-10-31 10:56:33+00:00, stenn@psp-deb1.ntp.org + Add bug 3125 to the NEWS file + + NEWS@1.194 +2 -0 + Add bug 3125 to the NEWS file + +ChangeSet@1.3701, 2016-10-24 07:37:25+02:00, perlinger@ntp.org + [winio2 - unlocked] + - the great lock removal + - the great renaming + + ChangeLog@1.1844 +1 -0 + [winio2 - unlocked] notes on changes + + ntpd/ntp_refclock.c@1.123 +1 -1 + [winio2 - unlocked] + - whitespace at EOL + + ports/winnt/include/ntp_iocpltypes.h@1.3 +21 -24 + [winio2 - unlocked] + - eliminate critical section, simplify API + - the great renaming + + ports/winnt/ntpd/ntp_iocompletionport.c@1.77 +331 -209 + [winio2 - unlocked] + - the great lock removal + - handle context objects are only manipulated by IOCPL thread + - closing handles is done by main thread after informing IOCPL thread (RPC-style) + - the great renaming + - restructured UNIX line mode emulation + + ports/winnt/ntpd/ntp_iocpltypes.c@1.3 +31 -95 + [winio2 - unlocked] + - eliminate critical section, simplify API + - the great renaming + + +ChangeSet@1.3698.1.7, 2016-10-23 05:18:04+00:00, stenn@psp-deb1.ntp.org + ntp-4.2.8p9-PRE + + ntpd/invoke-ntp.conf.texi@1.201 +1 -1 + ntp-4.2.8p9-PRE + + ntpd/invoke-ntp.keys.texi@1.191 +1 -1 + ntp-4.2.8p9-PRE + + ntpd/invoke-ntpd.texi@1.507 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntp.conf.5man@1.235 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntp.conf.5mdoc@1.235 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntp.conf.html@1.186 +104 -91 + ntp-4.2.8p9-PRE + + ntpd/ntp.conf.man.in@1.235 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntp.conf.mdoc.in@1.235 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntp.keys.5man@1.225 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntp.keys.5mdoc@1.225 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntp.keys.html@1.187 +29 -17 + ntp-4.2.8p9-PRE + + ntpd/ntp.keys.man.in@1.225 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntp.keys.mdoc.in@1.225 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntpd-opts.c@1.529 +245 -245 + ntp-4.2.8p9-PRE + + ntpd/ntpd-opts.h@1.528 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntpd.1ntpdman@1.336 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntpd.1ntpdmdoc@1.336 +2 -2 + ntp-4.2.8p9-PRE + + ntpd/ntpd.html@1.180 +146 -102 + ntp-4.2.8p9-PRE + + ntpd/ntpd.man.in@1.336 +3 -3 + ntp-4.2.8p9-PRE + + ntpd/ntpd.mdoc.in@1.336 +2 -2 + ntp-4.2.8p9-PRE + + ntpdc/invoke-ntpdc.texi@1.504 +2 -2 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc-opts.c@1.522 +106 -106 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc-opts.h@1.521 +3 -3 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc.1ntpdcman@1.335 +3 -3 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc.1ntpdcmdoc@1.335 +2 -2 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc.html@1.348 +77 -57 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc.man.in@1.335 +3 -3 + ntp-4.2.8p9-PRE + + ntpdc/ntpdc.mdoc.in@1.335 +2 -2 + ntp-4.2.8p9-PRE + + ntpq/invoke-ntpq.texi@1.512 +2 -2 + ntp-4.2.8p9-PRE + + ntpq/ntpq-opts.c@1.529 +113 -113 + ntp-4.2.8p9-PRE + + ntpq/ntpq-opts.h@1.527 +3 -3 + ntp-4.2.8p9-PRE + + ntpq/ntpq.1ntpqman@1.340 +3 -3 + ntp-4.2.8p9-PRE + + ntpq/ntpq.1ntpqmdoc@1.340 +2 -2 + ntp-4.2.8p9-PRE + + ntpq/ntpq.html@1.177 +129 -105 + ntp-4.2.8p9-PRE + + ntpq/ntpq.man.in@1.340 +3 -3 + ntp-4.2.8p9-PRE + + ntpq/ntpq.mdoc.in@1.340 +2 -2 + ntp-4.2.8p9-PRE + + ntpsnmpd/invoke-ntpsnmpd.texi@1.506 +2 -2 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd-opts.c@1.524 +67 -67 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd-opts.h@1.523 +3 -3 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.335 +3 -3 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.335 +2 -2 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd.html@1.175 +14 -10 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd.man.in@1.335 +3 -3 + ntp-4.2.8p9-PRE + + ntpsnmpd/ntpsnmpd.mdoc.in@1.335 +2 -2 + ntp-4.2.8p9-PRE + + packageinfo.sh@1.529 +2 -2 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.96 +3 -3 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.97 +2 -2 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/calc_tickadj.html@1.98 +34 -22 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/calc_tickadj.man.in@1.95 +3 -3 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.97 +2 -2 + ntp-4.2.8p9-PRE + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.100 +1 -1 + ntp-4.2.8p9-PRE + + scripts/invoke-plot_summary.texi@1.118 +2 -2 + ntp-4.2.8p9-PRE + + scripts/invoke-summary.texi@1.117 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/invoke-ntp-wait.texi@1.327 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait-opts@1.63 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.324 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.325 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait.html@1.344 +49 -31 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait.man.in@1.324 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntp-wait/ntp-wait.mdoc.in@1.325 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/invoke-ntpsweep.texi@1.115 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep-opts@1.65 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.103 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.103 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep.html@1.116 +44 -33 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep.man.in@1.103 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntpsweep/ntpsweep.mdoc.in@1.104 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntptrace/invoke-ntptrace.texi@1.116 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace-opts@1.65 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace.1ntptraceman@1.103 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.104 +2 -2 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace.html@1.117 +36 -27 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace.man.in@1.103 +3 -3 + ntp-4.2.8p9-PRE + + scripts/ntptrace/ntptrace.mdoc.in@1.105 +2 -2 + ntp-4.2.8p9-PRE + + scripts/plot_summary-opts@1.66 +2 -2 + ntp-4.2.8p9-PRE + + scripts/plot_summary.1plot_summaryman@1.116 +3 -3 + ntp-4.2.8p9-PRE + + scripts/plot_summary.1plot_summarymdoc@1.116 +2 -2 + ntp-4.2.8p9-PRE + + scripts/plot_summary.html@1.119 +47 -29 + ntp-4.2.8p9-PRE + + scripts/plot_summary.man.in@1.116 +3 -3 + ntp-4.2.8p9-PRE + + scripts/plot_summary.mdoc.in@1.116 +2 -2 + ntp-4.2.8p9-PRE + + scripts/summary-opts@1.65 +2 -2 + ntp-4.2.8p9-PRE + + scripts/summary.1summaryman@1.115 +3 -3 + ntp-4.2.8p9-PRE + + scripts/summary.1summarymdoc@1.115 +2 -2 + ntp-4.2.8p9-PRE + + scripts/summary.html@1.118 +39 -27 + ntp-4.2.8p9-PRE + + scripts/summary.man.in@1.115 +3 -3 + ntp-4.2.8p9-PRE + + scripts/summary.mdoc.in@1.115 +2 -2 + ntp-4.2.8p9-PRE + + scripts/update-leap/invoke-update-leap.texi@1.16 +1 -1 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap-opts@1.16 +2 -2 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap.1update-leapman@1.16 +3 -3 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap.1update-leapmdoc@1.16 +2 -2 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap.html@1.16 +59 -35 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap.man.in@1.16 +3 -3 + ntp-4.2.8p9-PRE + + scripts/update-leap/update-leap.mdoc.in@1.16 +2 -2 + ntp-4.2.8p9-PRE + + sntp/invoke-sntp.texi@1.504 +2 -2 + ntp-4.2.8p9-PRE + + sntp/sntp-opts.c@1.523 +158 -158 + ntp-4.2.8p9-PRE + + sntp/sntp-opts.h@1.521 +3 -3 + ntp-4.2.8p9-PRE + + sntp/sntp.1sntpman@1.339 +3 -3 + ntp-4.2.8p9-PRE + + sntp/sntp.1sntpmdoc@1.339 +2 -2 + ntp-4.2.8p9-PRE + + sntp/sntp.html@1.519 +109 -85 + ntp-4.2.8p9-PRE + + sntp/sntp.man.in@1.339 +3 -3 + ntp-4.2.8p9-PRE + + sntp/sntp.mdoc.in@1.339 +2 -2 + ntp-4.2.8p9-PRE + + util/invoke-ntp-keygen.texi@1.507 +2 -2 + ntp-4.2.8p9-PRE + + util/ntp-keygen-opts.c@1.525 +172 -172 + ntp-4.2.8p9-PRE + + util/ntp-keygen-opts.h@1.523 +3 -3 + ntp-4.2.8p9-PRE + + util/ntp-keygen.1ntp-keygenman@1.335 +3 -3 + ntp-4.2.8p9-PRE + + util/ntp-keygen.1ntp-keygenmdoc@1.335 +2 -2 + ntp-4.2.8p9-PRE + + util/ntp-keygen.html@1.181 +183 -124 + ntp-4.2.8p9-PRE + + util/ntp-keygen.man.in@1.335 +3 -3 + ntp-4.2.8p9-PRE + + util/ntp-keygen.mdoc.in@1.335 +2 -2 + ntp-4.2.8p9-PRE + +ChangeSet@1.3688.4.1, 2016-10-20 19:28:06+00:00, stenn@psp-deb1.ntp.org + cleanup + + ChangeLog@1.1836.4.1 +1 -0 + cleanup + +ChangeSet@1.3686.20.1, 2016-10-20 20:13:40+02:00, perlinger@ntp.org + [Sec 3114] Broadcast Mode Replay Prevention DoS + + ChangeLog@1.1834.20.1 +4 -0 + [Sec 3114] Broadcast Mode Replay Prevention DoS + + ntpd/ntp_proto.c@1.392.2.1 +39 -6 + [Sec 3114] Broadcast Mode Replay Prevention DoS + - applied patches by Matthew Van Gundy, with some rework. + +ChangeSet@1.3686.19.1, 2016-10-20 09:21:04+02:00, perlinger@ntp.org + [Sec 3113] Broadcast Mode Poll Interval Enforcement DoS + + ChangeLog@1.1834.19.1 +4 -0 + [Sec 3113] Broadcast Mode Poll Interval Enforcement DoS + + + include/ntp.h@1.220.1.1 +1 -1 + [Sec 3113] Broadcast Mode Poll Interval Enforcement DoS + + ntpd/ntp_proto.c@1.392.1.1 +12 -3 + [Sec 3113] Broadcast Mode Poll Interval Enforcement DoS + - applied fix as suggested by Matthew Van Gundy + +ChangeSet@1.3698.1.5, 2016-10-13 01:26:54-07:00, harlan@max.pfcs.com + typo + + ChangeLog@1.1841.1.3 +1 -1 + typo + +ChangeSet@1.3698.1.4, 2016-10-13 01:24:48-07:00, harlan@max.pfcs.com + [Bug 3102] Zero origin issues + + ChangeLog@1.1841.1.2 +1 -0 + [Bug 3102] Zero origin issues + + ntpd/ntp_proto.c@1.393 +28 -3 + [Bug 3102] Zero origin issues + +ChangeSet@1.3698.1.3, 2016-10-11 01:33:28-07:00, harlan@max.pfcs.com + Distribute libssl_compat.h + + include/Makefile.am@1.55 +1 -0 + Distribute libssl_compat.h + +ChangeSet@1.3698.1.2, 2016-10-10 22:34:55-07:00, harlan@max.pfcs.com + bug 3102 tests + + tests/bug-3102/README-3102.txt@1.1 +43 -0 + BitKeeper file tests/bug-3102/README-3102.txt + + tests/bug-3102/README-3102.txt@1.0 +0 -0 + + tests/bug-3102/zeroorg.py@1.1 +24 -0 + BitKeeper file tests/bug-3102/zeroorg.py + + tests/bug-3102/zeroorg.py@1.0 +0 -0 + +ChangeSet@1.3688.3.2, 2016-10-10 01:46:05-07:00, harlan@max.pfcs.com + Fix typos in include/ntp.h + + ChangeLog@1.1836.3.1 +1 -0 + Fix typos in include/ntp.h + + include/ntp.h@1.221 +3 -4 + Fix typos in include/ntp.h + +ChangeSet@1.3699, 2016-10-04 08:36:17+02:00, perlinger@ntp.org + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + + ChangeLog@1.1842 +2 -0 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + + ports/winnt/include/ntp_iocompletionport.h@1.23 +1 -1 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + - minor type renaming + + ports/winnt/include/termios.h@1.18 +3 -0 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + - manage device context for IOCPL together with comport + + ports/winnt/libntp/termios.c@1.34 +191 -120 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + - manage device context for IOCPL together with comport + + ports/winnt/ntpd/ntp_iocompletionport.c@1.76 +91 -98 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + - manage device context for IOCPL together with comport + - integrate Danny Mayers changes for docket error handling + + ports/winnt/ntpd/ntp_iocpltypes.c@1.2 +2 -2 + [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order using the loopback-ppsapi-provider.dll + - fix wrong instance initialisation + +ChangeSet@1.3698, 2016-10-01 10:52:11+00:00, stenn@psp-deb1.ntp.org + Update NEWS for 3119 + + NEWS@1.193 +17 -0 + Update NEWS for 3119 + +ChangeSet@1.3696, 2016-10-01 10:43:24+00:00, stenn@psp-deb1.ntp.org + Update NEWS for 3118 + + NEWS@1.192 +17 -0 + Update NEWS for 3118 + +ChangeSet@1.3694, 2016-10-01 10:29:06+00:00, stenn@psp-deb1.ntp.org + Update NEWS for 3110 + + NEWS@1.191 +17 -0 + Update NEWS for 3110 + +ChangeSet@1.3688.3.1, 2016-10-01 11:36:55+02:00, perlinger@ntp.org + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project files + + ports/winnt/vs2005/libntp.vcproj@1.26 +8 -0 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + + ports/winnt/vs2008/libntp/libntp.vcproj@1.57 +12 -0 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + + ports/winnt/vs2013/libntp/libntp.vcxproj@1.12 +4 -1 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + + ports/winnt/vs2013/libntp/libntp.vcxproj.filters@1.10 +14 -5 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + + ports/winnt/vs2015/libntp/libntp.vcxproj@1.2 +3 -0 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + + ports/winnt/vs2015/libntp/libntp.vcxproj.filters@1.2 +9 -0 + [Bug 3095] Compatibility with openssl 1.1 + - add new sources to project + +ChangeSet@1.3691, 2016-10-01 09:18:25+00:00, stenn@psp-deb1.ntp.org + Update NEWS for 3082 + + NEWS@1.190 +17 -0 + Update NEWS for 3082 + +ChangeSet@1.3688.1.33, 2016-10-01 08:32:28+00:00, stenn@psp-deb1.ntp.org + [Bug 3072] tweaks + + NEWS@1.189 +16 -1 + [Bug 3072] tweaks + + ntpd/ntp_peer.c@1.160 +6 -1 + [Bug 3072] tweaks + +ChangeSet@1.3688.1.31, 2016-09-29 20:53:30+00:00, perlinger@ntp.org + created 'X509_get_signature_nid()' shim for OpenSSL < v1.1.0 + fixed unit test for sntp/packetProcessing to work with or without AUTOKEY flag + + include/libssl_compat.h@1.2 +8 -1 + created 'X509_get_signature_nid()' shim for OpenSSL < v1.1.0 + + libntp/libssl_compat.c@1.2 +9 -1 + created 'X509_get_signature_nid()' shim for OpenSSL < v1.1.0 + + libntp/ssl_init.c@1.21 +0 -11 + moved 'X509_get_signature_nid()' for OpenSSL < v1.1.0 to 'libssl_compat.{c,h}' + + sntp/tests/packetProcessing.c@1.12 +0 -13 + fixed unit test to work with or without AUTOKEY flag + +ChangeSet@1.3688.1.30, 2016-09-29 12:03:17+00:00, stenn@psp-deb1.ntp.org + NEWS update + + NEWS@1.188 +2 -0 + NEWS update + +ChangeSet@1.3688.2.1, 2016-09-29 11:59:03+00:00, stenn@psp-deb1.ntp.org + X509_get_signature_nid() shim tweak + + ChangeLog@1.1836.2.1, stenn@stenn.ntp.org +1 -0 + Shim X509_get_signature_nid() if needed + + NEWS@1.187, stenn@stenn.ntp.org +1 -0 + Shim X509_get_signature_nid() if needed + + libntp/ssl_init.c@1.17.1.3 +1 -1 + X509_get_signature_nid() shim tweak + + libntp/ssl_init.c@1.17.1.2, stenn@stenn.ntp.org +12 -0 + Shim X509_get_signature_nid() if needed + +ChangeSet@1.3688.1.27, 2016-09-28 11:28:56+00:00, stenn@psp-deb1.ntp.org + NEWS + + NEWS@1.186 +1 -0 + NEWS + +ChangeSet@1.3688.1.25, 2016-09-28 11:24:36+00:00, stenn@psp-deb1.ntp.org + NEWS + + NEWS@1.185 +2 -0 + NEWS + +ChangeSet@1.3688.1.23, 2016-09-28 11:17:22+00:00, stenn@psp-deb1.ntp.org + Updated ChangeLog and NEWS + + ChangeLog@1.1836.1.19 +2 -2 + Updated ChangeLog and NEWS + + NEWS@1.184 +2 -0 + Updated ChangeLog and NEWS + +ChangeSet@1.3688.1.21, 2016-09-28 11:12:28+00:00, stenn@psp-deb1.ntp.org + NEWS + + NEWS@1.183 +2 -0 + NEWS + +ChangeSet@1.3688.1.19, 2016-09-28 11:01:29+00:00, stenn@psp-deb1.ntp.org + NEWS + + NEWS@1.182 +3 -0 + NEWS + +ChangeSet@1.3688.1.17, 2016-09-28 10:54:12+00:00, stenn@psp-deb1.ntp.org + Update ChangeLog and NEWS + + NEWS@1.181 +3 -0 + Update ChangeLog and NEWS + +ChangeSet@1.3688.1.15, 2016-09-28 10:45:21+00:00, stenn@psp-deb1.ntp.org + Update ChangeLog and NEWS + + ChangeLog@1.1836.1.14 +2 -2 + Update ChangeLog and NEWS + + NEWS@1.180 +2 -0 + Update ChangeLog and NEWS + +ChangeSet@1.3688.1.13, 2016-09-28 10:37:17+00:00, stenn@psp-deb1.ntp.org + NEWS updates + + NEWS@1.179 +4 -0 + NEWS updates + +ChangeSet@1.3688.1.11, 2016-09-28 10:25:01+00:00, stenn@psp-deb1.ntp.org + Update ChangeLog and NEWS + + ChangeLog@1.1836.1.11 +1 -1 + Update ChangeLog and NEWS + + NEWS@1.178 +1 -0 + Update ChangeLog and NEWS + +ChangeSet@1.3688.1.8, 2016-09-28 08:17:16+00:00, stenn@psp-deb1.ntp.org + Update ChangeLog and NEWS + + ChangeLog@1.1836.1.8 +2 -4 + Update ChangeLog and NEWS + + NEWS@1.177 +3 -0 + Update ChangeLog and NEWS + +ChangeSet@1.3688.1.6, 2016-09-28 08:10:35+00:00, stenn@psp-deb1.ntp.org + Update ChangeLog and NEWS + + ChangeLog@1.1836.1.6 +4 -6 + Update ChangeLog and NEWS + + NEWS@1.176 +4 -0 + Update ChangeLog and NEWS + +ChangeSet@1.3688.1.4, 2016-09-28 07:59:31+00:00, stenn@psp-deb1.ntp.org + ChangeLog and NEWS cleanup + + ChangeLog@1.1836.1.4 +2 -4 + ChangeLog and NEWS cleanup + + NEWS@1.175 +20 -0 + ChangeLog and NEWS cleanup + +ChangeSet@1.3686.9.2, 2016-09-26 08:24:48+02:00, perlinger@ntp.org + [Bug 3021] unity_fixture.c needs pragma weak + - add library implementation of empty setUp()/tearDown() + + sntp/unity/Makefile.am@1.10 +2 -0 + [Bug 3021] unity_fixture.c needs pragma weak + - add library implementation of empty setUp()/tearDown() + + sntp/unity/ulib_setup.c@1.1 +14 -0 + [Bug 3021] unity_fixture.c needs pragma weak + - add library implementation of empty setUp()/tearDown() + + sntp/unity/ulib_setup.c@1.0 +0 -0 + + sntp/unity/ulib_teardown.c@1.1 +13 -0 + [Bug 3021] unity_fixture.c needs pragma weak + - add library implementation of empty setUp()/tearDown() + + sntp/unity/ulib_teardown.c@1.0 +0 -0 + +ChangeSet@1.3686.18.1, 2016-09-25 10:58:43+02:00, perlinger@ntp.org + [Bug 2689] ATOM driver processes last PPS pulse at startup, even if it is very old + - make sure PPS source is alive before processing samples + - improve stability close to the 500ms phase jump by a 400ms phase gate + + ChangeLog@1.1834.18.1 +6 -0 + [Bug 2689] ATOM driver processes last PPS pulse at startup, even if it is very old + + ntpd/ntp_refclock.c@1.122 +50 -10 + [Bug 2689] ATOM driver processes last PPS pulse at startup, even if it is very old + - make sure PPS source is alive before processing samples + - improve stability close to the 500ms phase jump by a 400ms phase gate + +ChangeSet@1.3686.17.1, 2016-09-24 20:38:17+02:00, perlinger@ntp.org + [Sec 3118] Mode 6 information disclosure and DDoS vector + + ChangeLog@1.1834.17.1 +4 -0 + [Sec 3118] Mode 6 information disclosure and DDoS vector + + ntpd/ntp_control.c@1.209.5.1 +3 -3 + [Sec 3118] Mode 6 information disclosure and DDoS vector + - TRAP config via mode 6 packet requires AUTH now + - writing the clock status should require AUTH, too. + +ChangeSet@1.3686.16.1, 2016-09-23 20:00:55+02:00, perlinger@ntp.org + [Sec 3119] Trap crash + + ChangeLog@1.1834.16.1 +3 -0 + [Sec 3119] Trap crash + + ntpd/ntp_control.c@1.209.4.1 +19 -4 + [Sec 3119] Trap crash + - bail out if we hit a Peer Event without a peer. + +ChangeSet@1.3686.15.1, 2016-09-22 20:42:39+02:00, perlinger@ntp.org + [Bug 3116] unit tests for NTP time stamp expansion + + ChangeLog@1.1834.15.1 +3 -0 + [Bug 3116] unit tests for NTP time stamp expansion + + libntp/ntp_calendar.c@1.18 +56 -29 + [Bug 3116] unit tests for NTP time stamp expansion + - added back unsigned spec to constant to avoid confusion + and explained why there was no problem at all + + tests/libntp/calendar.c@1.13 +127 -0 + [Bug 3116] unit tests for NTP time stamp expansion + - added test cases for NTP time stamp expansion + + tests/libntp/run-calendar.c@1.12 +20 -15 + [Bug 3116] unit tests for NTP time stamp expansion + - update generated file + +ChangeSet@1.3688.1.2, 2016-09-16 08:26:08+00:00, stenn@psp-deb1.ntp.org + [Bug 3053] ntp_loopfilter.c frequency calc precedence error. Sarah White. + + ChangeLog@1.1836.1.2 +1 -0 + [Bug 3053] ntp_loopfilter.c frequency calc precedence error. Sarah White. + + ntpd/ntp_loopfilter.c@1.189 +6 -5 + [Bug 3053] ntp_loopfilter.c frequency calc precedence error. Sarah White. + +ChangeSet@1.3688.1.1, 2016-09-16 08:21:45+00:00, stenn@psp-deb1.ntp.org + cleanup + + ChangeLog@1.1836.1.1 +1 -0 + cleanup + +ChangeSet@1.3686.14.1, 2016-09-15 19:29:17+02:00, perlinger@ntp.org + [Bug 2959] refclock_jupiter: gps week correction + + ChangeLog@1.1834.14.1 +5 -0 + [Bug 2959] refclock_jupiter: gps week correction + + ntpd/refclock_jupiter.c@1.30 +66 -1 + [Bug 2959] refclock_jupiter: gps week correction + - fixed GPS week expansion to work based on build date. Special thanks to Craig Leres + for initial patch and testing. + +ChangeSet@1.3686.13.1, 2016-09-13 07:26:06+02:00, perlinger@ntp.org + [Bug 3072] Attack on interface selection + + ChangeLog@1.1834.13.1 +6 -1 + [Bug 3072] Attack on interface selection + + ntpd/ntp_peer.c@1.159 +61 -50 + [Bug 3072] Attack on interface selection + - implemented Miroslav Lichvars suggestion to skip interface updates + based on incoming packets + +ChangeSet@1.3686.12.1, 2016-09-10 17:22:27+02:00, perlinger@ntp.org + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx to source + - added shim layer for new SSL API calls + + ChangeLog@1.1834.12.1 +5 -0 + [Bug 3095] Compatibility with openssl 1.1 + + include/libssl_compat.h@1.1 +93 -0 + [Bug 3095] Compatibility with openssl 1.1 + shim layer for OpenSSL v1.1 API compatibility + + include/libssl_compat.h@1.0 +0 -0 + + libntp/Makefile.am@1.78.1.1 +1 -0 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + libntp/a_md5encrypt.c@1.36.1.1 +26 -28 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + libntp/libssl_compat.c@1.1 +327 -0 + [Bug 3095] Compatibility with openssl 1.1 + shim layer for OpenSSL v1.1 API compatibility + + libntp/libssl_compat.c@1.0 +0 -0 + + libntp/ssl_init.c@1.17.1.1 +7 -3 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpd/ntp_control.c@1.209.3.1 +13 -10 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpd/ntp_crypto.c@1.186.1.1 +207 -138 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpq/ntpq.c@1.170.1.1 +6 -3 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + sntp/crypto.c@1.21.1.1 +11 -7 + [Bug 3095] Compatibility with openssl 1.1 + - switched to new OpenSSL API + + util/ntp-keygen.c@1.107.1.1 +217 -150 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + - replaced use of deprecated functions + +ChangeSet@1.3686.11.1, 2016-09-09 18:34:03+02:00, jnperlin@nemesis.localnet + [Sec 3110] Windows: ntpd DoS by oversized UDP packet + + BitKeeper/etc/ignore@1.91.2.1 +2 -0 + add more studio specific garbage + + ChangeLog@1.1834.11.1 +4 -0 + [Sec 3110] Windows: ntpd DoS by oversized UDP packet + + ports/winnt/include/ntp_iocpltypes.h@1.2 +1 -0 + [Sec 3110] Windows: ntpd DoS by oversized UDP packet + - add 'ioFlags' to context; should be persistent during overlapped IO + + ports/winnt/ntpd/ntp_iocompletionport.c@1.73.1.1 +48 -9 + [Sec 3110] Windows: ntpd DoS by oversized UDP packet + - fixed error handling for truncated UDP packets + - sidekick: fixed handling of spurious ERROR_HOST_UNREACHABLE errors + - sidekick: fixed error message formatting for WaitForMultipleObjects() errors + + ports/winnt/vs2015/ntp.sln@1.2 +3 -3 + [Sec 3110] Windows: ntpd DoS by oversized UDP packet + - sidekick: set version of solution to match VS2015 + +ChangeSet@1.3686.10.1, 2016-09-04 21:10:56+02:00, perlinger@ntp.org + [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd' + + ChangeLog@1.1834.10.1 +4 -0 + [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd' + + tests/ntpd/Makefile.am@1.29 +0 -1 + [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd' + - removed source file that is included from t-ntp_signed.c + +ChangeSet@1.3686.9.1, 2016-09-04 19:19:34+02:00, perlinger@ntp.org + [Bug 3021] unity_fixture.c needs pragma weak + + ChangeLog@1.1834.9.1 +4 -0 + [Bug 3021] unity_fixture.c needs pragma weak + + sntp/unity/unity_fixture.c@1.2 +0 -4 + [Bug 3021] unity_fixture.c needs pragma weak + - removed unnecessary & harmful decls of 'setUp()' & 'tearDown()' + (no need to declare & implement locally unreferenced functions) + +ChangeSet@1.3686.8.1, 2016-09-04 17:37:34+02:00, perlinger@ntp.org + [Bug 3050] Fix for bug #2960 causes sntp to print a spurious error message + + ChangeLog@1.1834.8.1 +5 -0 + [Bug 3050] Fix for bug #2960 causes sntp to print a spurious error message + + libntp/work_fork.c@1.17 +13 -5 + [Bug 3050] Fix for bug #2960 causes sntp to print a spurious error message + - applied patches by Reinhard Max and Havard Eidnes . + Reinhard fought the cause, Harvard the symptom -- having both should put an end to this issue. + +ChangeSet@1.3686.7.2, 2016-09-04 11:20:00+02:00, perlinger@ntp.org + [Bug 3059] Potential buffer overrun from oversized hash + + ChangeLog@1.1834.7.2 +2 -0 + [Bug 3059] Potential buffer overrun from oversized hash + + libntp/a_md5encrypt.c@1.38 +7 -1 + [Bug 3059] Potential buffer overrun from oversized hash + - applied patch by Brian Utterback + +ChangeSet@1.3686.7.1, 2016-09-04 08:48:03+02:00, perlinger@ntp.org + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx to source + - added shim layer for SSL API calls with issues (both directions) + + ChangeLog@1.1834.7.1 +5 -0 + [Bug 3095] Compatibility with openssl 1.1 + + include/libssl_compat.h@1.1 +127 -0 + [Bug 3095] Compatibility with openssl 1.1 + shim layer for OpenSSL v1.1 API compatibility + + include/libssl_compat.h@1.0 +0 -0 + + libntp/Makefile.am@1.79 +1 -0 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + libntp/a_md5encrypt.c@1.37 +26 -28 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + - added shim layer for SSL API calls with issues (both directions) + + libntp/libssl_compat.c@1.1 +452 -0 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx to source + - added shim layer for SSL API calls with issues (both directions) + + libntp/libssl_compat.c@1.0 +0 -0 + + libntp/ssl_init.c@1.18 +7 -3 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpd/ntp_control.c@1.209.2.1 +13 -10 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpd/ntp_crypto.c@1.187 +207 -138 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + ntpq/ntpq.c@1.171 +6 -3 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + + sntp/crypto.c@1.22 +11 -7 + [Bug 3095] Compatibility with openssl 1.1 + - switched to new OpenSSL API + + util/ntp-keygen.c@1.108 +147 -131 + [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx + +ChangeSet@1.3686.6.1, 2016-08-21 09:29:00+02:00, perlinger@ntp.org + [Bug 3100] ntpq can't retrieve daemon_version + (extended sysvar lookup bug, introduced with fix for bug 3008) + + ChangeLog@1.1834.6.1 +4 -0 + [Bug 3100] ntpq can't retrieve daemon_version + + ntpd/ntp_control.c@1.209.1.1 +10 -4 + [Bug 3100] ntpq can't retrieve daemon_version + - extended sysvar lookup broken with fix for bug3008: extended sysvar text is "=", + name compare has to match if the name match stops at NUL or '='. Bug introduced with bug 3008 fix. + +ChangeSet@1.3686.5.1, 2016-08-01 09:09:19+02:00, perlinger@ntp.org + [Bug 3068] Linker warnings when building on Solaris. + - applied patch thanks to Andrew Stormont + + ChangeLog@1.1834.5.1 +2 -0 + [Bug 3068] Linker warnings when building on Solaris. + + libntp/audio.c@1.37 +3 -3 + [Bug 3068] Linker warnings when building on Solaris. + - applied patch thanks to Andrew Stormont + +ChangeSet@1.3686.4.1, 2016-07-26 08:56:44+02:00, perlinger@ntp.org + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + + ChangeLog@1.1834.4.1 +1 -0 + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + + sntp/tests/packetProcessing.c@1.9.1.1 +107 -89 + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + - make sure the tests compile when configured using --without-crypto --disable-autokey + - ensure the there is no buffer overrun when AUTOKEY is disabled + + sntp/tests/run-packetProcessing.c@1.11 +18 -18 + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + - automatic testrunner update + + tests/libntp/a_md5encrypt.c@1.15 +1 -3 + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + - side kick: avoid extra memset by using 'emalloc_zero()' + + tests/libntp/sfptostr.c@1.6 +3 -3 + [Bug 2998] sntp/tests/packetProcessing.c broken without openssl + - side kick: avoid warnings about left shift of negative integer + +ChangeSet@1.3686.3.1, 2016-07-23 09:20:53+02:00, perlinger@ntp.org + [Bug 3066] NMEA clock ignores pps. + (side kick: ignore msbuild 10 user settings file) + + BitKeeper/etc/ignore@1.91.1.1 +1 -0 + ignore msbuild 10 user setting + + ChangeLog@1.1834.3.1 +4 -0 + [Bug 3066] NMEA clock ignores pps. (actually, the PPS HACK stopped to work for all serial devices) + + ports/winnt/ntpd/ntp_iocompletionport.c@1.74 +20 -2 + [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org + - PPS-HACK works again; now controllable (explicitely) by the env var PPSAPI_HACK=true/yes/1 (anything else is NO) + - if PPSAPI_HACK is not set, a non-empty PPSAPI_DLLS list disables the PPS hack + +ChangeSet@1.3686.2.2, 2016-07-06 01:53:32-07:00, harlan@max.pfcs.com + [Bug 3084] update-leap mis-parses the leapfile name + + ChangeLog@1.1834.2.2 +1 -0 + [Bug 3084] update-leap mis-parses the leapfile name + + scripts/update-leap/update-leap.in@1.3 +5 -2 + [Bug 3084] update-leap mis-parses the leapfile name + +ChangeSet@1.3686.2.1, 2016-07-06 01:47:02-07:00, harlan@max.pfcs.com + [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY + + ChangeLog@1.1834.2.1 +4 -0 + [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY + + sntp/tests/packetProcessing.c@1.10 +5 -3 + [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY + +ChangeSet@1.3686.1.1, 2016-07-05 23:15:20+02:00, perlinger@ntp.org + [Sec 3075] Core Dump. Added missing paramter validation in read_mru_list(). + [Sec 3082] (title too long -- Variation of [Sec 3075].) + - more hardening to read_mru_list(). + + ChangeLog@1.1834.1.1 +7 -1 + [Sec 3075] Core Dump. Added missing paramter validation in read_mru_list() + [Sec 3082] (title too long -- Variation of [Sec 3075].) + - more hardening to read_mru_list(). + + ntpd/ntp_control.c@1.210 +57 -33 + [Sec 3075] Core Dump. Added missing paramter validation in read_mru_list(). + [Sec 3082] (title too long -- Variation of [Sec 3075].) + - more hardening to read_mru_list(). + +ChangeSet@1.3688, 2016-06-14 05:57:34+00:00, stenn@psp-deb1.ntp.org + bk ignore file cleanup + + BitKeeper/etc/ignore@1.92 +17 -13 + bk ignore file cleanup + + ChangeLog@1.1836 +1 -0 + bk ignore file cleanup + +ChangeSet@1.3687, 2016-06-14 05:56:12+00:00, stenn@psp-deb1.ntp.org + git author attribution cleanup + + BitKeeper/etc/Authors/a115350.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/a115350.txt + + BitKeeper/etc/Authors/a115350.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/abe.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/abe.txt + + BitKeeper/etc/Authors/abe.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/amidamaru.txt@1.1 +2 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/amidamaru.txt + + BitKeeper/etc/Authors/amidamaru.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/bkorb.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/bkorb.txt + + BitKeeper/etc/Authors/bkorb.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/blk.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/blk.txt + + BitKeeper/etc/Authors/blk.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/blu.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/blu.txt + + BitKeeper/etc/Authors/blu.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/bruckman.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/bruckman.txt + + BitKeeper/etc/Authors/bruckman.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/burnicki.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/burnicki.txt + + BitKeeper/etc/Authors/burnicki.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/claas.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/claas.txt + + BitKeeper/etc/Authors/claas.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/clemens.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/clemens.txt + + BitKeeper/etc/Authors/clemens.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/cov-build.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/cov-build.txt + + BitKeeper/etc/Authors/cov-build.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/cprice.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/cprice.txt + + BitKeeper/etc/Authors/cprice.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/davehart.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/davehart.txt + + BitKeeper/etc/Authors/davehart.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/dietrich.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/dietrich.txt + + BitKeeper/etc/Authors/dietrich.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/dunlop.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/dunlop.txt + + BitKeeper/etc/Authors/dunlop.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/fernandoph.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/fernandoph.txt + + BitKeeper/etc/Authors/fernandoph.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/fredb.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/fredb.txt + + BitKeeper/etc/Authors/fredb.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/gerstung.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/gerstung.txt + + BitKeeper/etc/Authors/gerstung.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/ginsbach.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/ginsbach.txt + + BitKeeper/etc/Authors/ginsbach.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/gnu.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/gnu.txt + + BitKeeper/etc/Authors/gnu.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/gopal.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/gopal.txt + + BitKeeper/etc/Authors/gopal.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/gunturu.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/gunturu.txt + + BitKeeper/etc/Authors/gunturu.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/harlan.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/harlan.txt + + BitKeeper/etc/Authors/harlan.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/harlanst.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/harlanst.txt + + BitKeeper/etc/Authors/harlanst.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/hart.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/hart.txt + + BitKeeper/etc/Authors/hart.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/hilbrecht.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/hilbrecht.txt + + BitKeeper/etc/Authors/hilbrecht.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/hstenn.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/hstenn.txt + + BitKeeper/etc/Authors/hstenn.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/jhay.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/jhay.txt + + BitKeeper/etc/Authors/jhay.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/jnperlin.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/jnperlin.txt + + BitKeeper/etc/Authors/jnperlin.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/kamboj.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/kamboj.txt + + BitKeeper/etc/Authors/kamboj.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/kardel.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/kardel.txt + + BitKeeper/etc/Authors/kardel.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/karlsson.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/karlsson.txt + + BitKeeper/etc/Authors/karlsson.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/kuehn.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/kuehn.txt + + BitKeeper/etc/Authors/kuehn.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/linus.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/linus.txt + + BitKeeper/etc/Authors/linus.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/loki.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/loki.txt + + BitKeeper/etc/Authors/loki.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/martin.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/martin.txt + + BitKeeper/etc/Authors/martin.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/matthias.andree.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/matthias.andree.txt + + BitKeeper/etc/Authors/matthias.andree.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/mayer.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/mayer.txt + + BitKeeper/etc/Authors/mayer.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/mbrett.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/mbrett.txt + + BitKeeper/etc/Authors/mbrett.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/murray.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/murray.txt + + BitKeeper/etc/Authors/murray.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/neal.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/neal.txt + + BitKeeper/etc/Authors/neal.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/paul.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/paul.txt + + BitKeeper/etc/Authors/paul.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/peda.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/peda.txt + + BitKeeper/etc/Authors/peda.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/perlinger.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/perlinger.txt + + BitKeeper/etc/Authors/perlinger.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/phk.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/phk.txt + + BitKeeper/etc/Authors/phk.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/rayvt.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/rayvt.txt + + BitKeeper/etc/Authors/rayvt.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/rick.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/rick.txt + + BitKeeper/etc/Authors/rick.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/ro.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/ro.txt + + BitKeeper/etc/Authors/ro.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/root.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/root.txt + + BitKeeper/etc/Authors/root.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/skamboj.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/skamboj.txt + + BitKeeper/etc/Authors/skamboj.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/stenn.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/stenn.txt + + BitKeeper/etc/Authors/stenn.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/tflendrich.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/tflendrich.txt + + BitKeeper/etc/Authors/tflendrich.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/tomek.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/tomek.txt + + BitKeeper/etc/Authors/tomek.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/utterback.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/utterback.txt + + BitKeeper/etc/Authors/utterback.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/venu.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/venu.txt + + BitKeeper/etc/Authors/venu.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/viperus.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/viperus.txt + + BitKeeper/etc/Authors/viperus.txt@1.0 +0 -0 + + BitKeeper/etc/Authors/wink.txt@1.1 +1 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/Authors/wink.txt + + BitKeeper/etc/Authors/wink.txt@1.0 +0 -0 + + BitKeeper/etc/authors.txt@1.1 +58 -0 + BitKeeper file /home/stenn/ntp-stable-p8/BitKeeper/etc/authors.txt + + BitKeeper/etc/authors.txt@1.0 +0 -0 + + ChangeLog@1.1835 +3 -0 + git author attribution cleanup + + scripts/build/genAuthors.in@1.2 +7 -5 + git author attribution cleanup + ChangeSet@1.3686, 2016-06-02 07:40:06-04:00, stenn@deacon.udel.edu NTP_4_2_8P8 TAG: NTP_4_2_8P8 @@ -386,13 +2249,13 @@ ChangeSet@1.3680, 2016-05-24 12:05:06+00:00, stenn@psp-deb1.ntp.org ntpd/ntp_proto.c@1.391 +39 -24 [Sec 3044] Spoofed server packets are partially processed. HStenn. -ChangeSet@1.3669.3.2, 2016-05-24 02:58:00-07:00, harlan@hms-mbp11.pfcs.com +ChangeSet@1.3669.4.2, 2016-05-24 02:58:00-07:00, harlan@hms-mbp11.pfcs.com Make sure we have an "author" file for git imports. HStenn. - ChangeLog@1.1820.3.3 +1 -0 + ChangeLog@1.1820.4.3 +1 -0 Update the problem tests for MacOS for sntp. HStenn. - ChangeLog@1.1820.3.2 +1 -0 + ChangeLog@1.1820.4.2 +1 -0 Make sure we have an "author" file for git imports. HStenn. configure.ac@1.606 +1 -0 @@ -420,10 +2283,10 @@ ChangeSet@1.3669.3.2, 2016-05-24 02:58:00-07:00, harlan@hms-mbp11.pfcs.com sntp/tests/Makefile.am@1.67 +8 -2 Update the problem tests for MacOS for sntp. HStenn. -ChangeSet@1.3669.3.1, 2016-05-24 02:25:46-07:00, harlan@hms-mbp11.pfcs.com +ChangeSet@1.3669.4.1, 2016-05-24 02:25:46-07:00, harlan@hms-mbp11.pfcs.com [Sec 3042] Broadcast Interleave. HStenn. - ChangeLog@1.1820.3.1 +4 -0 + ChangeLog@1.1820.4.1 +4 -0 [Sec 3042] Broadcast Interleave. HStenn. ntpd/ntp_proto.c@1.386.1.1 +69 -14 @@ -506,6 +2369,13 @@ ChangeSet@1.3671.1.2, 2016-05-17 04:25:50+00:00, stenn@psp-deb1.ntp.org ChangeLog@1.1822.1.2 +1 -0 [Bug 3052] Add a .gitignore file. Edmund Wong. +ChangeSet@1.3669.3.2, 2016-05-10 12:11:43+00:00, abe@psp-deb1.ntp.org + refclock_jjy.c: + [Bug 3047] Correct typo in the comment line. + + ntpd/refclock_jjy.c@1.32 +1 -1 + [Bug 3047] Correct typo in the comment line. + ChangeSet@1.3675, 2016-05-08 11:59:28+02:00, perlinger@ntp.org [Sec 3043] Autokey association reset. perlinger@ntp.org (fixes [Sec 3044] and [Sec 3045], too) @@ -517,6 +2387,22 @@ ChangeSet@1.3675, 2016-05-08 11:59:28+02:00, perlinger@ntp.org [Sec 3043] Autokey association reset. perlinger@ntp.org (fixes [Sec 3044] and [Sec 3045], too) +ChangeSet@1.3669.3.1, 2016-05-08 07:34:11+00:00, abe@psp-deb1.ntp.org + driver40.html, refclock_jjy.c, driver40-ja.html, ChangeLog: + [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + + ChangeLog@1.1820.3.1 +2 -0 + [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + + html/drivers/driver40-ja.html@1.5 +2 -2 + [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + + html/drivers/driver40.html@1.20 +2 -2 + [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + + ntpd/refclock_jjy.c@1.31 +7 -3 + [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + ChangeSet@1.3674, 2016-05-06 11:05:44+00:00, stenn@psp-deb1.ntp.org [Sec 3046] CRYPTO_NAK crash diff --git a/NEWS b/NEWS index fd2551cf4de..6445ed4cab2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,310 @@ +--- +NTP 4.2.8p9 (Harlan Stenn , 2016/11/21) + +Focus: Security, Bug fixes, enhancements. + +Severity: HIGH + +In addition to bug fixes and enhancements, this release fixes the +following 1 high- (Windows only), 2 medium-, 2 medium-/low, and +5 low-severity vulnerabilities, and provides 28 other non-security +fixes and improvements: + +* Trap crash + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3119 / CVE-2016-9311 / VU#633847 + Affects: ntp-4.0.90 (21 July 1999), possibly earlier, up to but not + including 4.2.8p9, and ntp-4.3.0 up to but not including ntp-4.3.94. + CVSS2: MED 4.9 (AV:N/AC:H/Au:N/C:N/I:N/A:C) + CVSS3: MED 4.4 CVSS:3.0/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H + Summary: + ntpd does not enable trap service by default. If trap service + has been explicitly enabled, an attacker can send a specially + crafted packet to cause a null pointer dereference that will + crash ntpd, resulting in a denial of service. + Mitigation: + Implement BCP-38. + Use "restrict default noquery ..." in your ntp.conf file. Only + allow mode 6 queries from trusted networks and hosts. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Matthew Van Gundy of Cisco. + +* Mode 6 information disclosure and DDoS vector + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3118 / CVE-2016-9310 / VU#633847 + Affects: ntp-4.0.90 (21 July 1999), possibly earlier, up to but not + including 4.2.8p9, and ntp-4.3.0 up to but not including ntp-4.3.94. + CVSS2: MED 6.4 (AV:A/AC:L/Au:N/C:N/I:N/A:P) + CVSS3: MED 6.5 CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L + Summary: + An exploitable configuration modification vulnerability exists + in the control mode (mode 6) functionality of ntpd. If, against + long-standing BCP recommendations, "restrict default noquery ..." + is not specified, a specially crafted control mode packet can set + ntpd traps, providing information disclosure and DDoS + amplification, and unset ntpd traps, disabling legitimate + monitoring. A remote, unauthenticated, network attacker can + trigger this vulnerability. + Mitigation: + Implement BCP-38. + Use "restrict default noquery ..." in your ntp.conf file. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Matthew Van Gundy of Cisco. + +* Broadcast Mode Replay Prevention DoS + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3114 / CVE-2016-7427 / VU#633847 + Affects: ntp-4.2.8p6, up to but not including ntp-4.2.8p9, and + ntp-4.3.90 up to, but not including ntp-4.3.94. + CVSS2: LOW 3.3 (AV:A/AC:L/Au:N/C:N/I:N/A:P) + CVSS3: MED 4.3 CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L + Summary: + The broadcast mode of NTP is expected to only be used in a + trusted network. If the broadcast network is accessible to an + attacker, a potentially exploitable denial of service + vulnerability in ntpd's broadcast mode replay prevention + functionality can be abused. An attacker with access to the NTP + broadcast domain can periodically inject specially crafted + broadcast mode NTP packets into the broadcast domain which, + while being logged by ntpd, can cause ntpd to reject broadcast + mode packets from legitimate NTP broadcast servers. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Matthew Van Gundy of Cisco. + +* Broadcast Mode Poll Interval Enforcement DoS + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3113 / CVE-2016-7428 / VU#633847 + Affects: ntp-4.2.8p6, up to but not including ntp-4.2.8p9, and + ntp-4.3.90 up to, but not including ntp-4.3.94 + CVSS2: LOW 3.3 (AV:A/AC:L/Au:N/C:N/I:N/A:P) + CVSS3: MED 4.3 CVSS:3.0/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L + Summary: + The broadcast mode of NTP is expected to only be used in a + trusted network. If the broadcast network is accessible to an + attacker, a potentially exploitable denial of service + vulnerability in ntpd's broadcast mode poll interval enforcement + functionality can be abused. To limit abuse, ntpd restricts the + rate at which each broadcast association will process incoming + packets. ntpd will reject broadcast mode packets that arrive + before the poll interval specified in the preceding broadcast + packet expires. An attacker with access to the NTP broadcast + domain can send specially crafted broadcast mode NTP packets to + the broadcast domain which, while being logged by ntpd, will + cause ntpd to reject broadcast mode packets from legitimate NTP + broadcast servers. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Matthew Van Gundy of Cisco. + +* Windows: ntpd DoS by oversized UDP packet + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3110 / CVE-2016-9312 / VU#633847 + Affects Windows only: ntp-4.?.?, up to but not including ntp-4.2.8p9, + and ntp-4.3.0 up to, but not including ntp-4.3.94. + CVSS2: HIGH 7.8 (AV:N/AC:L/Au:N/C:N/I:N/A:C) + CVSS3: HIGH 7.5 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H + Summary: + If a vulnerable instance of ntpd on Windows receives a crafted + malicious packet that is "too big", ntpd will stop working. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Robert Pajak of ABB. + +* 0rigin (zero origin) issues + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3102 / CVE-2016-7431 / VU#633847 + Affects: ntp-4.2.8p8, and ntp-4.3.93. + CVSS2: MED 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N) + CVSS3: MED 5.3 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N + Summary: + Zero Origin timestamp problems were fixed by Bug 2945 in + ntp-4.2.8p6. However, subsequent timestamp validation checks + introduced a regression in the handling of some Zero origin + timestamp checks. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Sharon Goldberg and Aanchal + Malhotra of Boston University. + +* read_mru_list() does inadequate incoming packet checks + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3082 / CVE-2016-7434 / VU#633847 + Affects: ntp-4.2.7p22, up to but not including ntp-4.2.8p9, and + ntp-4.3.0 up to, but not including ntp-4.3.94. + CVSS2: LOW 3.8 (AV:L/AC:H/Au:S/C:N/I:N/A:C) + CVSS3: LOW 3.8 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H + Summary: + If ntpd is configured to allow mrulist query requests from a + server that sends a crafted malicious packet, ntpd will crash + on receipt of that crafted malicious mrulist query packet. + Mitigation: + Only allow mrulist query packets from trusted hosts. + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Magnus Stubman. + +* Attack on interface selection + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3072 / CVE-2016-7429 / VU#633847 + Affects: ntp-4.2.7p385, up to but not including ntp-4.2.8p9, and + ntp-4.3.0 up to, but not including ntp-4.3.94 + CVSS2: LOW 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P) + CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L + Summary: + When ntpd receives a server response on a socket that corresponds + to a different interface than was used for the request, the peer + structure is updated to use the interface for new requests. If + ntpd is running on a host with multiple interfaces in separate + networks and the operating system doesn't check source address in + received packets (e.g. rp_filter on Linux is set to 0), an + attacker that knows the address of the source can send a packet + with spoofed source address which will cause ntpd to select wrong + interface for the source and prevent it from sending new requests + until the list of interfaces is refreshed, which happens on + routing changes or every 5 minutes by default. If the attack is + repeated often enough (once per second), ntpd will not be able to + synchronize with the source. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + If you are going to configure your OS to disable source address + checks, also configure your firewall configuration to control + what interfaces can receive packets from what networks. + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. + +* Client rate limiting and server responses + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3071 / CVE-2016-7426 / VU#633847 + Affects: ntp-4.2.5p203, up to but not including ntp-4.2.8p9, and + ntp-4.3.0 up to, but not including ntp-4.3.94 + CVSS2: LOW 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P) + CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L + Summary: + When ntpd is configured with rate limiting for all associations + (restrict default limited in ntp.conf), the limits are applied + also to responses received from its configured sources. An + attacker who knows the sources (e.g., from an IPv4 refid in + server response) and knows the system is (mis)configured in this + way can periodically send packets with spoofed source address to + keep the rate limiting activated and prevent ntpd from accepting + valid responses from its sources. + + While this blanket rate limiting can be useful to prevent + brute-force attacks on the origin timestamp, it allows this DoS + attack. Similarly, it allows the attacker to prevent mobilization + of ephemeral associations. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. + +* Fix for bug 2085 broke initial sync calculations + Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016 + References: Sec 3067 / CVE-2016-7433 / VU#633847 + Affects: ntp-4.2.7p385, up to but not including ntp-4.2.8p9, and + ntp-4.3.0 up to, but not including ntp-4.3.94. But the + root-distance calculation in general is incorrect in all versions + of ntp-4 until this release. + CVSS2: LOW 1.2 (AV:L/AC:H/Au:N/C:N/I:N/A:P) + CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:L + Summary: + Bug 2085 described a condition where the root delay was included + twice, causing the jitter value to be higher than expected. Due + to a misinterpretation of a small-print variable in The Book, the + fix for this problem was incorrect, resulting in a root distance + that did not include the peer dispersion. The calculations and + formulae have been reviewed and reconciled, and the code has been + updated accordingly. + Mitigation: + Upgrade to 4.2.8p9, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + Properly monitor your ntpd instances, and auto-restart ntpd + (without -g) if it stops running. + Credit: This weakness was discovered independently by Brian Utterback of + Oracle, and Sharon Goldberg and Aanchal Malhotra of Boston University. + +Other fixes: + +* [Bug 3142] bug in netmask prefix length detection +* [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org +* [Bug 3129] Unknown hosts can put resolver thread into a hard loop + - moved retry decision where it belongs. +* [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order + using the loopback-ppsapi-provider.dll +* [Bug 3116] unit tests for NTP time stamp expansion. +* [Bug 3100] ntpq can't retrieve daemon_version + - fixed extended sysvar lookup (bug introduced with bug 3008 fix) +* [Bug 3095] Compatibility with openssl 1.1 + - applied patches by Kurt Roeckx to source + - added shim layer for SSL API calls with issues (both directions) +* [Bug 3089] Serial Parser does not work anymore for hopfser like device + - simplified / refactored hex-decoding in driver. +* [Bug 3084] update-leap mis-parses the leapfile name. HStenn. +* [Bug 3068] Linker warnings when building on Solaris. perlinger@ntp.org + - applied patch thanks to Andrew Stormont +* [Bug 3067] Root distance calculation needs improvement. HStenn +* [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org + - PPS-HACK works again. +* [Bug 3059] Potential buffer overrun from oversized hash + - applied patch by Brian Utterback +* [Bug 3053] ntp_loopfilter.c frequency calc precedence error. Sarah White. +* [Bug 3050] Fix for bug #2960 causes [...] spurious error message. + + - patches by Reinhard Max and Havard Eidnes +* [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org + - Patch provided by Kuramatsu. +* [Bug 3021] unity_fixture.c needs pragma weak + - removed unnecessary & harmful decls of 'setUp()' & 'tearDown()' +* [Bug 3019] Windows: ERROR_HOST_UNREACHABLE block packet processing. DMayer +* [Bug 2998] sntp/tests/packetProcessing.c broken without openssl. JPerlinger +* [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY. HStenn. +* [Bug 2959] refclock_jupiter: gps week correction + - fixed GPS week expansion to work based on build date. Special thanks + to Craig Leres for initial patch and testing. +* [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd' + - fixed Makefile.am +* [Bug 2689] ATOM driver processes last PPS pulse at startup, + even if it is very old + - make sure PPS source is alive before processing samples + - improve stability close to the 500ms phase jump (phase gate) +* Fix typos in include/ntp.h. +* Shim X509_get_signature_nid() if needed +* git author attribution cleanup +* bk ignore file cleanup +* remove locks in Windows IO, use rpc-like thread synchronisation instead + --- NTP 4.2.8p8 (Harlan Stenn , 2016/06/02) diff --git a/configure b/configure index c38e7eb5e8f..91131cdb87c 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ntp 4.2.8p8. +# Generated by GNU Autoconf 2.69 for ntp 4.2.8p9. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ntp' PACKAGE_TARNAME='ntp' -PACKAGE_VERSION='4.2.8p8' -PACKAGE_STRING='ntp 4.2.8p8' +PACKAGE_VERSION='4.2.8p9' +PACKAGE_STRING='ntp 4.2.8p9' PACKAGE_BUGREPORT='http://bugs.ntp.org./' PACKAGE_URL='http://www.ntp.org./' @@ -1618,7 +1618,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ntp 4.2.8p8 to adapt to many kinds of systems. +\`configure' configures ntp 4.2.8p9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1688,7 +1688,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ntp 4.2.8p8:";; + short | recursive ) echo "Configuration of ntp 4.2.8p9:";; esac cat <<\_ACEOF @@ -1924,7 +1924,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ntp configure 4.2.8p8 +ntp configure 4.2.8p9 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2754,7 +2754,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ntp $as_me 4.2.8p8, which was +It was created by ntp $as_me 4.2.8p9, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3755,7 +3755,7 @@ fi # Define the identity of the package. PACKAGE='ntp' - VERSION='4.2.8p8' + VERSION='4.2.8p9' cat >>confdefs.h <<_ACEOF @@ -38003,7 +38003,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ntp $as_me 4.2.8p8, which was +This file was extended by ntp $as_me 4.2.8p9, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -38070,7 +38070,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ntp config.status 4.2.8p8 +ntp config.status 4.2.8p9 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/html/drivers/driver40-ja.html b/html/drivers/driver40-ja.html index 8b67e9009d4..d84c3ce107d 100644 --- a/html/drivers/driver40-ja.html +++ b/html/drivers/driver40-ja.html @@ -16,7 +16,7 @@

JJY Receivers

Last update: - 15-May-2015 00:00 + 08-May-2016 00:00 UTC          ENGLISH(英語)   JAPANESE(日本語)


Synopsis

@@ -137,7 +137,7 @@ {ENQ}1J{ETX}  -->  - {STX}JYYMMDD HHMMSSS{ETX} + {STX}JYYMMDDWHHMMSSS{ETX}
diff --git a/html/drivers/driver40.html b/html/drivers/driver40.html index 356429e499e..3b5f00f1506 100644 --- a/html/drivers/driver40.html +++ b/html/drivers/driver40.html @@ -16,7 +16,7 @@

JJY Receivers

Last update: - 15-May-2015 00:00 + 08-May-2016 00:00 UTC          ENGLISH   JAPANESE


Synopsis

@@ -136,7 +136,7 @@ {ENQ}1J{ETX}  -->  - {STX}JYYMMDD HHMMSSS{ETX} + {STX}JYYMMDDWHHMMSSS{ETX}
diff --git a/html/miscopt.html b/html/miscopt.html index bf4cfbfdb5a..6e03963326e 100644 --- a/html/miscopt.html +++ b/html/miscopt.html @@ -11,7 +11,7 @@ giffrom Pogo, Walt Kelly

We have three, now looking for more.

Last update: - 17-May-2016 06:26 + 9-Nov-2016 12:26 UTC


Related Links

@@ -145,10 +145,12 @@
Specifies the stepout threshold in seconds. The default without this command is 300 s. Since this option also affects the training and startup intervals, it should not be set less than the default. Further details are on the Clock State Machine page.
-
tos [beacon beacon | ceiling ceiling | cohort {0 | 1} | floor floor | maxclock maxclock | maxdist maxdist | minclock minclock | mindist mindist | minsane minsane | orphan stratum | orphanwait delay]
+
tos [bcpollbstep poll-gate | beacon beacon | ceiling ceiling | cohort {0 | 1} | floor floor | maxclock maxclock | maxdist maxdist | minclock minclock | mindist mindist | minsane minsane | orphan stratum | orphanwait delay]
This command alters certain system variables used by the the clock selection and clustering algorithms. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs. It can be used to select the quality and quantity of peers used to synchronize the system clock and is most useful in dynamic server discovery schemes. The options are as follows:
+
bcpollbstep poll-gate
+
This option will cause the client to delay believing backward time steps from a broadcast server for bcpollbstep poll intervals. NTP Broadcast networks are expected to be trusted, and if the server's time gets stepped backwards then it's desireable that the clients follow this change as soon as possible. However, in spite of various protections built-in to the broadcast protocol, it is possible that an attacker could perform a carefully-constructed replay attack and cause clients to erroneously step their clocks backward. If the risk of a successful broadcast replay attack is greater than the risk of the clients being out of sync in the event that there is a backward step on the broadcast time servers, this option may be used to cause the clients to delay beliveving backward time steps until poll-gate consecutive polls have been received. The default is 0, which means the client will accept these steps upon receipt. Any value from 0 to 4 can be specified.
beacon beacon
The manycast server sends packets at intervals of 64 s if less than maxclock servers are available. Otherwise, it sends packets at the beacon interval in seconds. The default is 3600 s. See the Automatic Server Discovery page for further details.
ceiling ceiling
diff --git a/include/Makefile.am b/include/Makefile.am index 521ac146c77..749a0c83905 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,6 +16,7 @@ noinst_HEADERS = \ intreswork.h \ iosignal.h \ l_stdlib.h \ + libssl_compat.h \ lib_strbuf.h \ libntp.h \ mbg_gps166.h \ diff --git a/include/Makefile.in b/include/Makefile.in index ef92804d14f..acd3bb5f803 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -501,6 +501,7 @@ noinst_HEADERS = \ intreswork.h \ iosignal.h \ l_stdlib.h \ + libssl_compat.h \ lib_strbuf.h \ libntp.h \ mbg_gps166.h \ diff --git a/include/libssl_compat.h b/include/libssl_compat.h new file mode 100644 index 00000000000..a8938a1517c --- /dev/null +++ b/include/libssl_compat.h @@ -0,0 +1,100 @@ +/* + * libssl_compat.h -- OpenSSL v1.1 compatibility shims + * + * --------------------------------------------------------------------- + * + * Written by Juergen Perlinger for the NTP project + * + * Based on an idea by Kurt Roeckx + * + * --------------------------------------------------------------------- + * This is a clean room implementation of shim functions that have + * counterparts in the OpenSSL v1.1 API but not in earlier versions. + * + * If the OpenSSL version used for compilation needs the shims (that is, + * does not provide the new functions) the names of these functions are + * redirected to our shims. + * --------------------------------------------------------------------- + */ + +#ifndef NTP_LIBSSL_COMPAT_H +#define NTP_LIBSSL_COMPAT_H + +#include "openssl/evp.h" +#include "openssl/dsa.h" +#include "openssl/rsa.h" + +/* ----------------------------------------------------------------- */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +/* ----------------------------------------------------------------- */ + +# include +# include + +/* shim the new-style API on an old-style OpenSSL */ + +extern BN_GENCB* sslshimBN_GENCB_new(void); +extern void sslshimBN_GENCB_free(BN_GENCB*); + +extern EVP_MD_CTX* sslshim_EVP_MD_CTX_new(void); +extern void sslshim_EVP_MD_CTX_free(EVP_MD_CTX *ctx); + +extern int sslshim_EVP_PKEY_id(const EVP_PKEY * pkey); +extern int sslshim_EVP_PKEY_base_id(const EVP_PKEY * pkey); +extern RSA* sslshim_EVP_PKEY_get0_RSA(EVP_PKEY * pkey); +extern DSA* sslshim_EVP_PKEY_get0_DSA(EVP_PKEY * pkey); + +extern void sslshim_RSA_get0_key(const RSA *prsa, const BIGNUM **pn, + const BIGNUM **pe, const BIGNUM **pd); +extern int sslshim_RSA_set0_key(RSA *prsa, BIGNUM *n, + BIGNUM *e, BIGNUM *d); +extern void sslshim_RSA_get0_factors(const RSA *prsa, const BIGNUM **pp, + const BIGNUM **pq); +extern int sslshim_RSA_set0_factors(RSA *prsar, BIGNUM *p, BIGNUM *q); +extern int sslshim_RSA_set0_crt_params(RSA *prsa, BIGNUM *dmp1, + BIGNUM *dmq1, BIGNUM *iqmp); + +extern void sslshim_DSA_SIG_get0(const DSA_SIG *psig, const BIGNUM **pr, + const BIGNUM **ps); +extern int sslshim_DSA_SIG_set0(DSA_SIG *psig, BIGNUM *r, BIGNUM *s); +extern void sslshim_DSA_get0_pqg(const DSA *pdsa, const BIGNUM **pp, + const BIGNUM **pq, const BIGNUM **pg); +extern int sslshim_DSA_set0_pqg(DSA *pdsa, BIGNUM *p, BIGNUM *q, BIGNUM *g); +extern void sslshim_DSA_get0_key(const DSA *pdsa, const BIGNUM **ppub_key, + const BIGNUM **ppriv_key); +extern int sslshim_DSA_set0_key(DSA *pdsa, BIGNUM *pub_key, + BIGNUM *priv_key); + +extern int sslshim_X509_get_signature_nid(const X509 *x); + +#define BN_GENCB_new sslshimBN_GENCB_new +#define BN_GENCB_free sslshimBN_GENCB_free + +#define EVP_MD_CTX_new sslshim_EVP_MD_CTX_new +#define EVP_MD_CTX_free sslshim_EVP_MD_CTX_free + +#define EVP_PKEY_id sslshim_EVP_PKEY_id +#define EVP_PKEY_base_id sslshim_EVP_PKEY_base_id +#define EVP_PKEY_get0_RSA sslshim_EVP_PKEY_get0_RSA +#define EVP_PKEY_get0_DSA sslshim_EVP_PKEY_get0_DSA + +#define RSA_get0_key sslshim_RSA_get0_key +#define RSA_set0_key sslshim_RSA_set0_key +#define RSA_get0_factors sslshim_RSA_get0_factors +#define RSA_set0_factors sslshim_RSA_set0_factors +#define RSA_set0_crt_params sslshim_RSA_set0_crt_params + +#define DSA_SIG_get0 sslshim_DSA_SIG_get0 +#define DSA_SIG_set0 sslshim_DSA_SIG_set0 +#define DSA_get0_pqg sslshim_DSA_get0_pqg +#define DSA_set0_pqg sslshim_DSA_set0_pqg +#define DSA_get0_key sslshim_DSA_get0_key +#define DSA_set0_key sslshim_DSA_set0_key + +#define X509_get_signature_nid sslshim_X509_get_signature_nid + +/* ----------------------------------------------------------------- */ +#endif /* OPENSSL_VERSION_NUMBER < v1.1.0 */ +/* ----------------------------------------------------------------- */ + +#endif /* NTP_LIBSSL_COMPAT_H */ diff --git a/include/ntp.h b/include/ntp.h index 84c30d9feea..323135da4a8 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -391,7 +391,7 @@ struct peer { * Statistic counters */ u_long timereset; /* time stat counters were reset */ - u_long timelastrec; /* last packet received time */ + u_long timelastrec; /* last packet received time, incl. trash */ u_long timereceived; /* last (clean) packet received time */ u_long timereachable; /* last reachable/unreachable time */ @@ -419,8 +419,7 @@ struct peer { * MODE_BROADCAST and MODE_BCLIENT appear in the transition * function. MODE_CONTROL and MODE_PRIVATE can appear in packets, * but those never survive to the transition function. - * is a -/ */ + */ #define MODE_UNSPEC 0 /* unspecified (old version) */ #define MODE_ACTIVE 1 /* symmetric active mode */ #define MODE_PASSIVE 2 /* symmetric passive mode */ @@ -433,7 +432,7 @@ struct peer { #define MODE_CONTROL 6 /* control mode */ #define MODE_PRIVATE 7 /* private mode */ /* - * This is a madeup mode for broadcast client. + * This is a made-up mode for broadcast client. */ #define MODE_BCLIENT 6 /* broadcast client mode */ @@ -724,6 +723,7 @@ struct pkt { #define PROTO_UECRYPTONAK 30 #define PROTO_UEDIGEST 31 #define PROTO_PCEDIGEST 32 +#define PROTO_BCPOLLBSTEP 33 /* * Configuration items for the loop filter @@ -731,7 +731,7 @@ struct pkt { #define LOOP_DRIFTINIT 1 /* iniitialize frequency */ #define LOOP_KERN_CLEAR 2 /* set initial frequency offset */ #define LOOP_MAX 3 /* set both step offsets */ -#define LOOP_MAX_BACK 4 /* set bacward-step offset */ +#define LOOP_MAX_BACK 4 /* set backward-step offset */ #define LOOP_MAX_FWD 5 /* set forward-step offset */ #define LOOP_PANIC 6 /* set panic offseet */ #define LOOP_PHI 7 /* set dispersion rate */ diff --git a/include/ntp_intres.h b/include/ntp_intres.h index 1b6bd66e0b1..11091300760 100644 --- a/include/ntp_intres.h +++ b/include/ntp_intres.h @@ -9,6 +9,9 @@ #ifdef WORKER #define INITIAL_DNS_RETRY 2 /* seconds between queries */ +/* flags for extended addrinfo version */ +#define GAIR_F_IGNDNSERR 0x0001 /* ignore DNS errors */ + /* * you call getaddrinfo_sometime(name, service, &hints, retry, callback_func, context); * later (*callback_func)(rescode, gai_errno, context, name, service, hints, ai_result) is called. @@ -19,6 +22,9 @@ typedef void (*gai_sometime_callback) extern int getaddrinfo_sometime(const char *, const char *, const struct addrinfo *, int, gai_sometime_callback, void *); +extern int getaddrinfo_sometime_ex(const char *, const char *, + const struct addrinfo *, int, + gai_sometime_callback, void *, u_int); /* * In gai_sometime_callback routines, the resulting addrinfo list is * only available until the callback returns. To hold on to the list diff --git a/include/ntpd.h b/include/ntpd.h index 362068c765e..1f33bf456b2 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -483,6 +483,7 @@ extern int sys_bclient; /* we set our time to broadcasts */ extern double sys_bdelay; /* broadcast client default delay */ extern int sys_authenticate; /* requre authentication for config */ extern l_fp sys_authdelay; /* authentication delay */ +extern u_char sys_bcpollbstep; /* broadcast poll backstep gate */ extern u_long sys_epoch; /* last clock update time */ extern keyid_t sys_private; /* private value for session seed */ extern int sys_manycastserver; /* respond to manycast client pkts */ diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 9710466281c..01f90804349 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -280,7 +280,6 @@ isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp) { for (; i < ipbytes; i++) { if (p[i] != 0) return (ISC_R_MASKNONCONTIG); - i++; } *lenp = nbytes * 8 + nbits; return (ISC_R_SUCCESS); diff --git a/libntp/Makefile.am b/libntp/Makefile.am index 26a4709e8b5..874739a1884 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -73,6 +73,7 @@ libntp_a_SRCS = \ iosignal.c \ is_ip_address.c \ lib_strbuf.c \ + libssl_compat.c \ machines.c \ mktime.c \ modetoa.c \ diff --git a/libntp/Makefile.in b/libntp/Makefile.in index 4c0fb4dbdd9..8dfa04c6801 100644 --- a/libntp/Makefile.in +++ b/libntp/Makefile.in @@ -150,15 +150,15 @@ am__libntp_a_SOURCES_DIST = systime.c a_md5encrypt.c adjtime.c \ calyearstart.c clocktime.c clocktypes.c decodenetnum.c \ dofptoa.c dolfptoa.c emalloc.c findconfig.c getopt.c \ hextoint.c hextolfp.c humandate.c icom.c iosignal.c \ - is_ip_address.c lib_strbuf.c machines.c mktime.c modetoa.c \ - mstolfp.c msyslog.c netof.c ntp_calendar.c ntp_crypto_rnd.c \ - ntp_intres.c ntp_libopts.c ntp_lineedit.c ntp_random.c \ - ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c octtoint.c \ - prettydate.c refidsmear.c recvbuff.c refnumtoa.c snprintf.c \ - socket.c socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \ - strl_obsd.c syssignal.c timetoa.c timevalops.c uglydate.c \ - vint64ops.c work_fork.c work_thread.c ymd2yd.c \ - $(srcdir)/../lib/isc/assertions.c \ + is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \ + mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \ + ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \ + ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \ + octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \ + snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \ + statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \ + timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \ + ymd2yd.c $(srcdir)/../lib/isc/assertions.c \ $(srcdir)/../lib/isc/buffer.c \ $(srcdir)/../lib/isc/backtrace-emptytbl.c \ $(srcdir)/../lib/isc/backtrace.c \ @@ -209,20 +209,21 @@ am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \ getopt.$(OBJEXT) hextoint.$(OBJEXT) hextolfp.$(OBJEXT) \ humandate.$(OBJEXT) icom.$(OBJEXT) iosignal.$(OBJEXT) \ is_ip_address.$(OBJEXT) lib_strbuf.$(OBJEXT) \ - machines.$(OBJEXT) mktime.$(OBJEXT) modetoa.$(OBJEXT) \ - mstolfp.$(OBJEXT) msyslog.$(OBJEXT) netof.$(OBJEXT) \ - ntp_calendar.$(OBJEXT) ntp_crypto_rnd.$(OBJEXT) \ - ntp_intres.$(OBJEXT) ntp_libopts.$(OBJEXT) \ - ntp_lineedit.$(OBJEXT) ntp_random.$(OBJEXT) \ - ntp_rfc2553.$(OBJEXT) ntp_worker.$(OBJEXT) numtoa.$(OBJEXT) \ - numtohost.$(OBJEXT) octtoint.$(OBJEXT) prettydate.$(OBJEXT) \ - refidsmear.$(OBJEXT) recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) \ - snprintf.$(OBJEXT) socket.$(OBJEXT) socktoa.$(OBJEXT) \ - socktohost.$(OBJEXT) ssl_init.$(OBJEXT) statestr.$(OBJEXT) \ - strdup.$(OBJEXT) strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) \ - timetoa.$(OBJEXT) timevalops.$(OBJEXT) uglydate.$(OBJEXT) \ - vint64ops.$(OBJEXT) work_fork.$(OBJEXT) work_thread.$(OBJEXT) \ - ymd2yd.$(OBJEXT) $(am__objects_3) $(am__objects_1) + libssl_compat.$(OBJEXT) machines.$(OBJEXT) mktime.$(OBJEXT) \ + modetoa.$(OBJEXT) mstolfp.$(OBJEXT) msyslog.$(OBJEXT) \ + netof.$(OBJEXT) ntp_calendar.$(OBJEXT) \ + ntp_crypto_rnd.$(OBJEXT) ntp_intres.$(OBJEXT) \ + ntp_libopts.$(OBJEXT) ntp_lineedit.$(OBJEXT) \ + ntp_random.$(OBJEXT) ntp_rfc2553.$(OBJEXT) \ + ntp_worker.$(OBJEXT) numtoa.$(OBJEXT) numtohost.$(OBJEXT) \ + octtoint.$(OBJEXT) prettydate.$(OBJEXT) refidsmear.$(OBJEXT) \ + recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) snprintf.$(OBJEXT) \ + socket.$(OBJEXT) socktoa.$(OBJEXT) socktohost.$(OBJEXT) \ + ssl_init.$(OBJEXT) statestr.$(OBJEXT) strdup.$(OBJEXT) \ + strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timetoa.$(OBJEXT) \ + timevalops.$(OBJEXT) uglydate.$(OBJEXT) vint64ops.$(OBJEXT) \ + work_fork.$(OBJEXT) work_thread.$(OBJEXT) ymd2yd.$(OBJEXT) \ + $(am__objects_3) $(am__objects_1) am_libntp_a_OBJECTS = systime.$(OBJEXT) $(am__objects_4) libntp_a_OBJECTS = $(am_libntp_a_OBJECTS) libntpsim_a_AR = $(AR) $(ARFLAGS) @@ -233,15 +234,15 @@ am__libntpsim_a_SOURCES_DIST = systime_s.c a_md5encrypt.c adjtime.c \ calyearstart.c clocktime.c clocktypes.c decodenetnum.c \ dofptoa.c dolfptoa.c emalloc.c findconfig.c getopt.c \ hextoint.c hextolfp.c humandate.c icom.c iosignal.c \ - is_ip_address.c lib_strbuf.c machines.c mktime.c modetoa.c \ - mstolfp.c msyslog.c netof.c ntp_calendar.c ntp_crypto_rnd.c \ - ntp_intres.c ntp_libopts.c ntp_lineedit.c ntp_random.c \ - ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c octtoint.c \ - prettydate.c refidsmear.c recvbuff.c refnumtoa.c snprintf.c \ - socket.c socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \ - strl_obsd.c syssignal.c timetoa.c timevalops.c uglydate.c \ - vint64ops.c work_fork.c work_thread.c ymd2yd.c \ - $(srcdir)/../lib/isc/assertions.c \ + is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \ + mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \ + ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \ + ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \ + octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \ + snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \ + statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \ + timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \ + ymd2yd.c $(srcdir)/../lib/isc/assertions.c \ $(srcdir)/../lib/isc/buffer.c \ $(srcdir)/../lib/isc/backtrace-emptytbl.c \ $(srcdir)/../lib/isc/backtrace.c \ @@ -665,6 +666,7 @@ libntp_a_SRCS = \ iosignal.c \ is_ip_address.c \ lib_strbuf.c \ + libssl_compat.c \ machines.c \ mktime.c \ modetoa.c \ @@ -813,6 +815,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_ip_address.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_strbuf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_compat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machines.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@ diff --git a/libntp/a_md5encrypt.c b/libntp/a_md5encrypt.c index 618ccd9de10..7edcd2e3058 100644 --- a/libntp/a_md5encrypt.c +++ b/libntp/a_md5encrypt.c @@ -11,6 +11,7 @@ #include "ntp.h" #include "ntp_md5.h" /* provides OpenSSL digest API */ #include "isc/string.h" +#include "libssl_compat.h" /* * MD5authencrypt - generate message digest * @@ -26,7 +27,7 @@ MD5authencrypt( { u_char digest[EVP_MAX_MD_SIZE]; u_int len; - EVP_MD_CTX ctx; + EVP_MD_CTX *ctx; /* * Compute digest of key concatenated with packet. Note: the @@ -34,18 +35,20 @@ MD5authencrypt( * was creaded. */ INIT_SSL(); -#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL - if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) { + ctx = EVP_MD_CTX_new(); + if (!(ctx && EVP_DigestInit(ctx, EVP_get_digestbynid(type)))) { msyslog(LOG_ERR, "MAC encrypt: digest init failed"); + EVP_MD_CTX_free(ctx); return (0); } -#else - EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); -#endif - EVP_DigestUpdate(&ctx, key, cache_secretsize); - EVP_DigestUpdate(&ctx, (u_char *)pkt, length); - EVP_DigestFinal(&ctx, digest, &len); + EVP_DigestUpdate(ctx, key, cache_secretsize); + EVP_DigestUpdate(ctx, (u_char *)pkt, length); + EVP_DigestFinal(ctx, digest, &len); + EVP_MD_CTX_free(ctx); + /* If the MAC is longer than the MAX then truncate it. */ + if (len > MAX_MAC_LEN - 4) + len = MAX_MAC_LEN - 4; memmove((u_char *)pkt + length + 4, digest, len); return (len + 4); } @@ -67,7 +70,7 @@ MD5authdecrypt( { u_char digest[EVP_MAX_MD_SIZE]; u_int len; - EVP_MD_CTX ctx; + EVP_MD_CTX *ctx; /* * Compute digest of key concatenated with packet. Note: the @@ -75,24 +78,26 @@ MD5authdecrypt( * was created. */ INIT_SSL(); -#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL - if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) { + ctx = EVP_MD_CTX_new(); + if (!(ctx && EVP_DigestInit(ctx, EVP_get_digestbynid(type)))) { msyslog(LOG_ERR, "MAC decrypt: digest init failed"); + EVP_MD_CTX_free(ctx); return (0); } -#else - EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); -#endif - EVP_DigestUpdate(&ctx, key, cache_secretsize); - EVP_DigestUpdate(&ctx, (u_char *)pkt, length); - EVP_DigestFinal(&ctx, digest, &len); + EVP_DigestUpdate(ctx, key, cache_secretsize); + EVP_DigestUpdate(ctx, (u_char *)pkt, length); + EVP_DigestFinal(ctx, digest, &len); + EVP_MD_CTX_free(ctx); + /* If the MAC is longer than the MAX then truncate it. */ + if (len > MAX_MAC_LEN - 4) + len = MAX_MAC_LEN - 4; if (size != (size_t)len + 4) { msyslog(LOG_ERR, "MAC decrypt: MAC length error"); return (0); } - return !isc_tsmemcmp(digest, (const char *)pkt + length + 4, len); + return !isc_tsmemcmp(digest, (u_char *)pkt + length + 4, len); } /* @@ -106,7 +111,7 @@ addr2refid(sockaddr_u *addr) { u_char digest[20]; u_int32 addr_refid; - EVP_MD_CTX ctx; + EVP_MD_CTX *ctx; u_int len; if (IS_IPV4(addr)) @@ -114,24 +119,23 @@ addr2refid(sockaddr_u *addr) INIT_SSL(); -#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL - EVP_MD_CTX_init(&ctx); + ctx = EVP_MD_CTX_new(); + EVP_MD_CTX_init(ctx); #ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW /* MD5 is not used as a crypto hash here. */ - EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); + EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); #endif - if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) { + if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL)) { msyslog(LOG_ERR, "MD5 init failed"); + EVP_MD_CTX_free(ctx); /* pedantic... but safe */ exit(1); } -#else - EVP_DigestInit(&ctx, EVP_md5()); -#endif - EVP_DigestUpdate(&ctx, (u_char *)PSOCK_ADDR6(addr), + EVP_DigestUpdate(ctx, (u_char *)PSOCK_ADDR6(addr), sizeof(struct in6_addr)); - EVP_DigestFinal(&ctx, digest, &len); + EVP_DigestFinal(ctx, digest, &len); + EVP_MD_CTX_free(ctx); memcpy(&addr_refid, digest, sizeof(addr_refid)); return (addr_refid); } diff --git a/libntp/audio.c b/libntp/audio.c index 726dfa94d81..3b0a0b364c1 100644 --- a/libntp/audio.c +++ b/libntp/audio.c @@ -55,7 +55,7 @@ static struct audio_device device; /* audio device ident */ #ifdef PCM_STYLE_SOUND # define INIT_FILE "/etc/ntp.audio" int agc = SOUND_MIXER_WRITE_RECLEV; /* or IGAIN or LINE */ -int monitor = SOUND_MIXER_WRITE_VOLUME; /* or OGAIN */ +int audiomonitor = SOUND_MIXER_WRITE_VOLUME; /* or OGAIN */ int devmask = 0; int recmask = 0; char cf_c_dev[100], cf_i_dev[100], cf_agc[100], cf_monitor[100]; @@ -334,7 +334,7 @@ audio_init( /* devmask */ i = mixer_name(cf_monitor, devmask); if (i >= 0) - monitor = MIXER_WRITE(i); + audiomonitor = MIXER_WRITE(i); else printf("monitor %s not in devmask %#x\n", cf_monitor, devmask); @@ -412,7 +412,7 @@ audio_gain( # endif l |= r << 8; if (cf_monitor[0] != '\0') - rval = ioctl(ctl_fd, monitor, &l ); + rval = ioctl(ctl_fd, audiomonitor, &l ); else rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_VOLUME, &l); diff --git a/libntp/libssl_compat.c b/libntp/libssl_compat.c new file mode 100644 index 00000000000..ce6acb7d3c7 --- /dev/null +++ b/libntp/libssl_compat.c @@ -0,0 +1,335 @@ +/* + * libssl_compat.c -- OpenSSL v1.1 compatibility functions + * + * --------------------------------------------------------------------- + * Written by Juergen Perlinger for the NTP project + * + * Based on an idea by Kurt Roeckx + * + * --------------------------------------------------------------------- + * This is a clean room implementation of shim functions that have + * counterparts in the OpenSSL v1.1 API but not in earlier versions. So + * while OpenSSL broke binary compatibility with v1.1, this shim module + * should provide the necessary source code compatibility with older + * versions of OpenSSL. + * --------------------------------------------------------------------- + */ +#include "config.h" + +#include +#include +#include + +#include "ntp_types.h" + +/* ----------------------------------------------------------------- */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +/* ----------------------------------------------------------------- */ + +#include "libssl_compat.h" +#include "ntp_assert.h" + +/* -------------------------------------------------------------------- + * replace a BIGNUM owned by the caller with another one if it's not + * NULL, taking over the ownership of the new value. This clears & frees + * the old value -- the clear might be overkill, but it's better to err + * on the side of paranoia here. + */ +static void +replace_bn_nn( + BIGNUM ** ps, + BIGNUM * n + ) +{ + if (n) { + REQUIRE(*ps != n); + BN_clear_free(*ps); + *ps = n; + } +} + +/* -------------------------------------------------------------------- + * allocation and deallocation of prime number callbacks + */ +BN_GENCB* +sslshimBN_GENCB_new(void) +{ + return calloc(1,sizeof(BN_GENCB)); +} + +void +sslshimBN_GENCB_free( + BN_GENCB *cb + ) +{ + free(cb); +} + +/* -------------------------------------------------------------------- + * allocation and deallocation of message digests + */ +EVP_MD_CTX* +sslshim_EVP_MD_CTX_new(void) +{ + return calloc(1, sizeof(EVP_MD_CTX)); +} + +void +sslshim_EVP_MD_CTX_free( + EVP_MD_CTX * pctx + ) +{ + free(pctx); +} + +/* -------------------------------------------------------------------- + * get EVP keys and key type + */ +int +sslshim_EVP_PKEY_id( + const EVP_PKEY *pkey + ) +{ + return (pkey) ? pkey->type : EVP_PKEY_NONE; +} + +int +sslshim_EVP_PKEY_base_id( + const EVP_PKEY *pkey + ) +{ + return (pkey) ? EVP_PKEY_type(pkey->type) : EVP_PKEY_NONE; +} + +RSA* +sslshim_EVP_PKEY_get0_RSA( + EVP_PKEY * pkey + ) +{ + return (pkey) ? pkey->pkey.rsa : NULL; +} + +DSA* +sslshim_EVP_PKEY_get0_DSA( + EVP_PKEY * pkey + ) +{ + return (pkey) ? pkey->pkey.dsa : NULL; +} + +/* -------------------------------------------------------------------- + * set/get RSA params + */ +void +sslshim_RSA_get0_key( + const RSA * prsa, + const BIGNUM ** pn, + const BIGNUM ** pe, + const BIGNUM ** pd + ) +{ + REQUIRE(prsa != NULL); + + if (pn) + *pn = prsa->n; + if (pe) + *pe = prsa->e; + if (pd) + *pd = prsa->d; +} + +int +sslshim_RSA_set0_key( + RSA * prsa, + BIGNUM * n, + BIGNUM * e, + BIGNUM * d + ) +{ + REQUIRE(prsa != NULL); + if (!((prsa->n || n) && (prsa->e || e))) + return 0; + + replace_bn_nn(&prsa->n, n); + replace_bn_nn(&prsa->e, e); + replace_bn_nn(&prsa->d, d); + + return 1; +} + +void +sslshim_RSA_get0_factors( + const RSA * prsa, + const BIGNUM ** pp, + const BIGNUM ** pq + ) +{ + REQUIRE(prsa != NULL); + + if (pp) + *pp = prsa->p; + if (pq) + *pq = prsa->q; +} + +int +sslshim_RSA_set0_factors( + RSA * prsa, + BIGNUM * p, + BIGNUM * q + ) +{ + REQUIRE(prsa != NULL); + if (!((prsa->p || p) && (prsa->q || q))) + return 0; + + replace_bn_nn(&prsa->p, p); + replace_bn_nn(&prsa->q, q); + + return 1; +} + +int +sslshim_RSA_set0_crt_params( + RSA * prsa, + BIGNUM * dmp1, + BIGNUM * dmq1, + BIGNUM * iqmp + ) +{ + REQUIRE(prsa != NULL); + if (!((prsa->dmp1 || dmp1) && + (prsa->dmq1 || dmq1) && + (prsa->iqmp || iqmp) )) + return 0; + + replace_bn_nn(&prsa->dmp1, dmp1); + replace_bn_nn(&prsa->dmq1, dmq1); + replace_bn_nn(&prsa->iqmp, iqmp); + + return 1; +} + +/* -------------------------------------------------------------------- + * set/get DSA signature parameters + */ +void +sslshim_DSA_SIG_get0( + const DSA_SIG * psig, + const BIGNUM ** pr, + const BIGNUM ** ps + ) +{ + REQUIRE(psig != NULL); + + if (pr != NULL) + *pr = psig->r; + if (ps != NULL) + *ps = psig->s; +} + +int +sslshim_DSA_SIG_set0( + DSA_SIG * psig, + BIGNUM * r, + BIGNUM * s + ) +{ + REQUIRE(psig != NULL); + if (!(r && s)) + return 0; + + replace_bn_nn(&psig->r, r); + replace_bn_nn(&psig->s, s); + + return 1; +} + +/* -------------------------------------------------------------------- + * get/set DSA parameters + */ +void +sslshim_DSA_get0_pqg( + const DSA * pdsa, + const BIGNUM ** pp, + const BIGNUM ** pq, + const BIGNUM ** pg + ) +{ + REQUIRE(pdsa != NULL); + + if (pp != NULL) + *pp = pdsa->p; + if (pq != NULL) + *pq = pdsa->q; + if (pg != NULL) + *pg = pdsa->g; +} + +int +sslshim_DSA_set0_pqg( + DSA * pdsa, + BIGNUM * p, + BIGNUM * q, + BIGNUM * g + ) +{ + if (!((pdsa->p || p) && (pdsa->q || q) && (pdsa->g || g))) + return 0; + + replace_bn_nn(&pdsa->p, p); + replace_bn_nn(&pdsa->q, q); + replace_bn_nn(&pdsa->g, g); + + return 1; +} + +void +sslshim_DSA_get0_key( + const DSA * pdsa, + const BIGNUM ** ppub_key, + const BIGNUM ** ppriv_key + ) +{ + REQUIRE(pdsa != NULL); + + if (ppub_key != NULL) + *ppub_key = pdsa->pub_key; + if (ppriv_key != NULL) + *ppriv_key = pdsa->priv_key; +} + +int +sslshim_DSA_set0_key( + DSA * pdsa, + BIGNUM * pub_key, + BIGNUM * priv_key + ) +{ + REQUIRE(pdsa != NULL); + if (!(pdsa->pub_key || pub_key)) + return 0; + + replace_bn_nn(&pdsa->pub_key, pub_key); + replace_bn_nn(&pdsa->priv_key, priv_key); + + return 1; +} + +int +sslshim_X509_get_signature_nid( + const X509 *x + ) +{ + return OBJ_obj2nid(x->sig_alg->algorithm); +} + +/* ----------------------------------------------------------------- */ +#else /* OPENSSL_VERSION_NUMBER >= v1.1.0 */ +/* ----------------------------------------------------------------- */ + +NONEMPTY_TRANSLATION_UNIT + +/* ----------------------------------------------------------------- */ +#endif +/* ----------------------------------------------------------------- */ diff --git a/libntp/ntp_calendar.c b/libntp/ntp_calendar.c index ff6ead364e5..4bfb0e723c0 100644 --- a/libntp/ntp_calendar.c +++ b/libntp/ntp_calendar.c @@ -91,7 +91,7 @@ /* *--------------------------------------------------------------------- * replacing the 'time()' function - * -------------------------------------------------------------------- + *--------------------------------------------------------------------- */ static systime_func_ptr systime_func = &time; @@ -395,7 +395,7 @@ ntpcal_get_build_date( /* *--------------------------------------------------------------------- * basic calendar stuff - * -------------------------------------------------------------------- + *--------------------------------------------------------------------- */ /* month table for a year starting with March,1st */ @@ -443,11 +443,11 @@ static const uint16_t real_month_table[2][13] = { */ /* - * ================================================================== + * ==================================================================== * * General algorithmic stuff * - * ================================================================== + * ==================================================================== */ /* @@ -495,7 +495,7 @@ static const uint16_t real_month_table[2][13] = { * 32/16bit divisions and is still performant is a bit more * difficult. Since most usecases can be coded in a way that does only * require the 32-bit version a 64bit version is NOT provided here. - * --------------------------------------------------------------------- + *--------------------------------------------------------------------- */ int32_t ntpcal_periodic_extend( @@ -542,8 +542,35 @@ ntpcal_periodic_extend( return pivot; } +/*--------------------------------------------------------------------- + * Note to the casual reader + * + * In the next two functions you will find (or would have found...) + * the expression + * + * res.Q_s -= 0x80000000; + * + * There was some ruckus about a possible programming error due to + * integer overflow and sign propagation. + * + * This assumption is based on a lack of understanding of the C + * standard. (Though this is admittedly not one of the most 'natural' + * aspects of the 'C' language and easily to get wrong.) + * + * see + * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf + * "ISO/IEC 9899:201x Committee Draft — April 12, 2011" + * 6.4.4.1 Integer constants, clause 5 + * + * why there is no sign extension/overflow problem here. + * + * But to ease the minds of the doubtful, I added back the 'u' qualifiers + * that somehow got lost over the last years. + */ + + /* - *------------------------------------------------------------------- + *--------------------------------------------------------------------- * Convert a timestamp in NTP scale to a 64bit seconds value in the UN*X * scale with proper epoch unfolding around a given pivot or the current * system time. This function happily accepts negative pivot values as @@ -553,7 +580,7 @@ ntpcal_periodic_extend( * This is also a periodic extension, but since the cycle is 2^32 and * the shift is 2^31, we can do some *very* fast math without explicit * divisions. - *------------------------------------------------------------------- + *--------------------------------------------------------------------- */ vint64 ntpcal_ntp_to_time( @@ -568,7 +595,7 @@ ntpcal_ntp_to_time( res.q_s = (pivot != NULL) ? *pivot : now(); - res.Q_s -= 0x80000000; /* unshift of half range */ + res.Q_s -= 0x80000000u; /* unshift of half range */ ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */ ntp -= res.D_s.lo; /* cycle difference */ res.Q_s += (uint64_t)ntp; /* get expanded time */ @@ -581,7 +608,7 @@ ntpcal_ntp_to_time( ? *pivot : now(); res = time_to_vint64(&tmp); - M_SUB(res.D_s.hi, res.D_s.lo, 0, 0x80000000); + M_SUB(res.D_s.hi, res.D_s.lo, 0, 0x80000000u); ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */ ntp -= res.D_s.lo; /* cycle difference */ M_ADD(res.D_s.hi, res.D_s.lo, 0, ntp); @@ -592,7 +619,7 @@ ntpcal_ntp_to_time( } /* - *------------------------------------------------------------------- + *--------------------------------------------------------------------- * Convert a timestamp in NTP scale to a 64bit seconds value in the NTP * scale with proper epoch unfolding around a given pivot or the current * system time. @@ -602,7 +629,7 @@ ntpcal_ntp_to_time( * This is also a periodic extension, but since the cycle is 2^32 and * the shift is 2^31, we can do some *very* fast math without explicit * divisions. - *------------------------------------------------------------------- + *--------------------------------------------------------------------- */ vint64 ntpcal_ntp_to_ntp( @@ -617,7 +644,7 @@ ntpcal_ntp_to_ntp( res.q_s = (pivot) ? *pivot : now(); - res.Q_s -= 0x80000000; /* unshift of half range */ + res.Q_s -= 0x80000000u; /* unshift of half range */ res.Q_s += (uint32_t)JAN_1970; /* warp into NTP domain */ ntp -= res.D_s.lo; /* cycle difference */ res.Q_s += (uint64_t)ntp; /* get expanded time */ @@ -642,20 +669,20 @@ ntpcal_ntp_to_ntp( /* - * ================================================================== + * ==================================================================== * * Splitting values to composite entities * - * ================================================================== + * ==================================================================== */ /* - *------------------------------------------------------------------- + *--------------------------------------------------------------------- * Split a 64bit seconds value into elapsed days in 'res.hi' and * elapsed seconds since midnight in 'res.lo' using explicit floor * division. This function happily accepts negative time values as * timestamps before the respective epoch start. - * ------------------------------------------------------------------- + *--------------------------------------------------------------------- */ ntpcal_split ntpcal_daysplit( @@ -736,11 +763,11 @@ ntpcal_daysplit( } /* - *------------------------------------------------------------------- + *--------------------------------------------------------------------- * Split a 32bit seconds value into h/m/s and excessive days. This * function happily accepts negative time values as timestamps before * midnight. - * ------------------------------------------------------------------- + *--------------------------------------------------------------------- */ static int32_t priv_timesplit( @@ -773,7 +800,7 @@ priv_timesplit( } /* - * --------------------------------------------------------------------- + *--------------------------------------------------------------------- * Given the number of elapsed days in the calendar era, split this * number into the number of elapsed years in 'res.hi' and the number * of elapsed days of that year in 'res.lo'. @@ -1053,11 +1080,11 @@ ntpcal_time_to_date( /* - * ================================================================== + * ==================================================================== * * merging composite entities * - * ================================================================== + * ==================================================================== */ /* @@ -1251,8 +1278,8 @@ ntpcal_edate_to_eradays( * Convert ELAPSED years/months/days of gregorian calendar to elapsed * days in year. * - * Note: This will give the true difference to the start of the given year, - * even if months & days are off-scale. + * Note: This will give the true difference to the start of the given + * year, even if months & days are off-scale. *--------------------------------------------------------------------- */ int32_t @@ -1434,11 +1461,11 @@ ntpcal_date_to_time( /* - * ================================================================== + * ==================================================================== * * extended and unchecked variants of caljulian/caltontp * - * ================================================================== + * ==================================================================== */ int ntpcal_ntp64_to_date( @@ -1500,11 +1527,11 @@ ntpcal_date_to_ntp( /* - * ================================================================== + * ==================================================================== * * day-of-week calculations * - * ================================================================== + * ==================================================================== */ /* * Given a RataDie and a day-of-week, calculate a RDN that is reater-than, @@ -1557,7 +1584,7 @@ ntpcal_weekday_lt( } /* - * ================================================================== + * ==================================================================== * * ISO week-calendar conversions * @@ -1601,7 +1628,7 @@ ntpcal_weekday_lt( * smallest possible powers of two, so the division can be implemented * as shifts if the optimiser chooses to do so. * - * ================================================================== + * ==================================================================== */ /* diff --git a/libntp/ntp_intres.c b/libntp/ntp_intres.c index 0b5bb753425..7aa288af57b 100644 --- a/libntp/ntp_intres.c +++ b/libntp/ntp_intres.c @@ -118,14 +118,16 @@ * is managed by the code which calls the *_complete routines. */ + /* === typedefs === */ typedef struct blocking_gai_req_tag { /* marshalled args */ size_t octets; u_int dns_idx; time_t scheduled; time_t earliest; - struct addrinfo hints; int retry; + struct addrinfo hints; + u_int qflags; gai_sometime_callback callback; void * context; size_t nodesize; @@ -205,8 +207,8 @@ static dnsworker_ctx * get_worker_context(blocking_child *, u_int); static void scheduled_sleep(time_t, time_t, dnsworker_ctx *); static void manage_dns_retry_interval(time_t *, time_t *, - int *, - time_t *); + int *, time_t *, + int/*BOOL*/); static int should_retry_dns(int, int); #ifdef HAVE_RES_INIT static void reload_resolv_conf(dnsworker_ctx *); @@ -230,13 +232,14 @@ static void getnameinfo_sometime_complete(blocking_work_req, * invokes provided callback completion function. */ int -getaddrinfo_sometime( +getaddrinfo_sometime_ex( const char * node, const char * service, const struct addrinfo * hints, int retry, gai_sometime_callback callback, - void * context + void * context, + u_int qflags ) { blocking_gai_req * gai_req; @@ -277,6 +280,7 @@ getaddrinfo_sometime( gai_req->context = context; gai_req->nodesize = nodesize; gai_req->servsize = servsize; + gai_req->qflags = qflags; memcpy((char *)gai_req + sizeof(*gai_req), node, nodesize); memcpy((char *)gai_req + sizeof(*gai_req) + nodesize, service, @@ -451,6 +455,20 @@ blocking_getaddrinfo( return 0; } +int +getaddrinfo_sometime( + const char * node, + const char * service, + const struct addrinfo * hints, + int retry, + gai_sometime_callback callback, + void * context + ) +{ + return getaddrinfo_sometime_ex(node, service, hints, retry, + callback, context, 0); +} + static void getaddrinfo_sometime_complete( @@ -470,7 +488,7 @@ getaddrinfo_sometime_complete( char * service; char * canon_start; time_t time_now; - int again; + int again, noerr; int af; const char * fam_spec; int i; @@ -498,8 +516,9 @@ getaddrinfo_sometime_complete( gai_req->dns_idx, humantime(time_now))); } } else { - again = should_retry_dns(gai_resp->retcode, - gai_resp->gai_errno); + noerr = !!(gai_req->qflags & GAIR_F_IGNDNSERR); + again = noerr || should_retry_dns( + gai_resp->retcode, gai_resp->gai_errno); /* * exponential backoff of DNS retries to 64s */ @@ -528,9 +547,10 @@ getaddrinfo_sometime_complete( gai_strerror(gai_resp->retcode), gai_resp->retcode); } - manage_dns_retry_interval(&gai_req->scheduled, - &gai_req->earliest, &gai_req->retry, - &child_ctx->next_dns_timeslot); + manage_dns_retry_interval( + &gai_req->scheduled, &gai_req->earliest, + &gai_req->retry, &child_ctx->next_dns_timeslot, + noerr); if (!queue_blocking_request( BLOCKING_GETADDRINFO, gai_req, @@ -826,7 +846,7 @@ getnameinfo_sometime_complete( if (gni_req->retry > 0) manage_dns_retry_interval(&gni_req->scheduled, &gni_req->earliest, &gni_req->retry, - &child_ctx->next_dns_timeslot); + &child_ctx->next_dns_timeslot, FALSE); if (gni_req->retry > 0 && again) { if (!queue_blocking_request( @@ -1033,18 +1053,32 @@ manage_dns_retry_interval( time_t * pscheduled, time_t * pwhen, int * pretry, - time_t * pnext_timeslot + time_t * pnext_timeslot, + int forever ) { time_t now; time_t when; int retry; + int retmax; now = time(NULL); retry = *pretry; when = max(now + retry, *pnext_timeslot); *pnext_timeslot = when; - retry = min(64, retry << 1); + + /* this exponential backoff is slower than doubling up: The + * sequence goes 2-3-4-6-8-12-16-24-32... and the upper limit is + * 64 seconds for things that should not repeat forever, and + * 1024 when repeated forever. + */ + retmax = forever ? 1024 : 64; + retry <<= 1; + if (retry & (retry - 1)) + retry &= (retry - 1); + else + retry -= (retry >> 2); + retry = min(retmax, retry); *pscheduled = now; *pwhen = when; diff --git a/libntp/ssl_init.c b/libntp/ssl_init.c index a9d1d546dfb..ef0f1c185a8 100644 --- a/libntp/ssl_init.c +++ b/libntp/ssl_init.c @@ -15,6 +15,7 @@ #ifdef OPENSSL #include "openssl/err.h" #include "openssl/evp.h" +#include "libssl_compat.h" void atexit_ssl_cleanup(void); @@ -62,6 +63,7 @@ ssl_check_version(void) INIT_SSL(); } + #endif /* OPENSSL */ @@ -84,7 +86,6 @@ keytype_from_text( u_char digest[EVP_MAX_MD_SIZE]; char * upcased; char * pch; - EVP_MD_CTX ctx; /* * OpenSSL digest short names are capitalized, so uppercase the @@ -110,8 +111,12 @@ keytype_from_text( if (NULL != pdigest_len) { #ifdef OPENSSL - EVP_DigestInit(&ctx, EVP_get_digestbynid(key_type)); - EVP_DigestFinal(&ctx, digest, &digest_len); + EVP_MD_CTX *ctx; + + ctx = EVP_MD_CTX_new(); + EVP_DigestInit(ctx, EVP_get_digestbynid(key_type)); + EVP_DigestFinal(ctx, digest, &digest_len); + EVP_MD_CTX_free(ctx); if (digest_len > max_digest_len) { fprintf(stderr, "key type %s %u octet digests are too big, max %lu\n", diff --git a/libntp/work_fork.c b/libntp/work_fork.c index 6c9545aa9cb..8223fdd2f9b 100644 --- a/libntp/work_fork.c +++ b/libntp/work_fork.c @@ -114,18 +114,24 @@ interrupt_worker_sleep(void) /* * harvest_child_status() runs in the parent. + * + * Note the error handling -- this is an interaction with SIGCHLD. + * SIG_IGN on SIGCHLD on some OSes means do not wait but reap + * automatically. Since we're not really interested in the result code, + * we simply ignore the error. */ static void harvest_child_status( blocking_child * c ) { - if (c->pid) - { + if (c->pid) { /* Wait on the child so it can finish terminating */ if (waitpid(c->pid, NULL, 0) == c->pid) TRACE(4, ("harvested child %d\n", c->pid)); - else msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid); + else if (errno != ECHILD) + msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid); + c->pid = 0; } } @@ -162,7 +168,6 @@ cleanup_after_child( close(c->resp_read_pipe); c->resp_read_pipe = -1; } - c->pid = 0; c->resp_read_ctx = NULL; DEBUG_INSIST(-1 == c->req_read_pipe); DEBUG_INSIST(-1 == c->resp_write_pipe); @@ -461,7 +466,10 @@ fork_blocking_child( fflush(stdout); fflush(stderr); - signal_no_reset(SIGCHLD, SIG_IGN); + /* [BUG 3050] setting SIGCHLD to SIG_IGN likely causes unwanted + * or undefined effects. We don't do it and leave SIGCHLD alone. + */ + /* signal_no_reset(SIGCHLD, SIG_IGN); */ childpid = fork(); if (-1 == childpid) { diff --git a/libparse/clk_hopf6021.c b/libparse/clk_hopf6021.c index 235962890f8..c5980ef13f2 100644 --- a/libparse/clk_hopf6021.c +++ b/libparse/clk_hopf6021.c @@ -113,13 +113,10 @@ static struct format hopf6021_fmt = #define OFFS(x) format->field_offsets[(x)].offset #define STOI(x, y) Stoi(&buffer[OFFS(x)], y, format->field_offsets[(x)].length) -#define hexval(x) (('0' <= (x) && (x) <= '9') ? (x) - '0' : \ - ('a' <= (x) && (x) <= 'f') ? (x) - 'a' + 10 : \ - ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \ - -1) static parse_cvt_fnc_t cvt_hopf6021; static parse_inp_fnc_t inp_hopf6021; +static unsigned char hexval(unsigned char); clockformat_t clock_hopf6021 = { @@ -160,40 +157,40 @@ cvt_hopf6021( return CVT_FAIL|CVT_BADFMT; } - clock_time->usecond = 0; - clock_time->utcoffset = 0; + clock_time->usecond = 0; + clock_time->flags = 0; - status = (u_char) hexval(buffer[OFFS(O_FLAGS)]); - weekday= (u_char) hexval(buffer[OFFS(O_WDAY)]); + status = hexval(buffer[OFFS(O_FLAGS)]); + weekday = hexval(buffer[OFFS(O_WDAY)]); if ((status == 0xFF) || (weekday == 0xFF)) { return CVT_FAIL|CVT_BADFMT; } - clock_time->flags = 0; - if (weekday & HOPF_UTC) { - clock_time->flags |= PARSEB_UTC; + clock_time->flags |= PARSEB_UTC; + clock_time->utcoffset = 0; + } + else if (status & HOPF_DST) + { + clock_time->flags |= PARSEB_DST; + clock_time->utcoffset = -2*60*60; /* MET DST */ } else { - if (status & HOPF_DST) - { - clock_time->flags |= PARSEB_DST; - clock_time->utcoffset = -2*60*60; /* MET DST */ - } - else - { - clock_time->utcoffset = -1*60*60; /* MET */ - } + clock_time->utcoffset = -1*60*60; /* MET */ } - clock_time->flags |= (status & HOPF_DSTWARN) ? PARSEB_ANNOUNCE : 0; - + if (status & HOPF_DSTWARN) + { + clock_time->flags |= PARSEB_ANNOUNCE; + } + switch (status & HOPF_MODE) { + default: /* dummy: we cover all 4 cases. */ case HOPF_INVALID: /* Time/Date invalid */ clock_time->flags |= PARSEB_POWERUP; break; @@ -205,9 +202,6 @@ cvt_hopf6021( case HOPF_RADIO: /* Radio clock */ case HOPF_RADIOHP: /* Radio clock high precision */ break; - - default: - return CVT_FAIL|CVT_BADFMT; } return CVT_OK; @@ -244,6 +238,30 @@ inp_hopf6021( } } +/* + * convert a hex-digit to numeric value + */ +static unsigned char +hexval( + unsigned char ch + ) +{ + unsigned int dv; + + if ((dv = ch - '0') >= 10u) + { + if ((dv -= 'A'-'0') < 6u || (dv -= 'a'-'A') < 6u) + { + dv += 10; + } + else + { + dv = 0xFF; + } + } + return (unsigned char)dv; +} + #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_HOPF6021) */ int clk_hopf6021_bs; #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_HOPF6021) */ diff --git a/ntpd/complete.conf.in b/ntpd/complete.conf.in index 2c547fac7d5..4c6c0459b5f 100644 --- a/ntpd/complete.conf.in +++ b/ntpd/complete.conf.in @@ -26,7 +26,7 @@ controlkey 12 requestkey 12 enable auth ntp monitor stats disable bclient calibrate kernel mode7 peer_clear_digest_early unpeer_crypto_early unpeer_crypto_nak_early unpeer_digest_early -tos beacon 3600 ceiling 16 cohort 0 floor 1 maxclock 10 maxdist 1.5 minclock 3 mindist 0.001 minsane 1 orphan 16 orphanwait 300 +tos beacon 3600 ceiling 16 cohort 0 floor 1 maxclock 10 maxdist 1.5 minclock 3 mindist 0.001 minsane 1 orphan 16 orphanwait 300 bcpollbstep 3 rlimit@HAVE_RLIMIT_MEMLOCK@@HAVE_RLIMIT_STACK@ tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepout 900 tick 0.01 broadcastclient diff --git a/ntpd/invoke-ntp.conf.texi b/ntpd/invoke-ntp.conf.texi index 7efeceebbfe..afd92ffd97b 100644 --- a/ntpd/invoke-ntp.conf.texi +++ b/ntpd/invoke-ntp.conf.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi) # -# It has been AutoGen-ed June 2, 2016 at 07:36:07 AM by AutoGen 5.18.5 +# It has been AutoGen-ed November 21, 2016 at 08:01:55 AM by AutoGen 5.18.5 # From the definitions ntp.conf.def # and the template file agtexi-file.tpl @end ignore @@ -1925,6 +1925,21 @@ At the same time, the manycast scheme starts all over from the beginning and the expanding ring shrinks to the minimum and increments from there while collecting all servers in scope. +@subsubsection Broadcast Options +@table @asis +@item @code{tos} @code{[@code{bcpollbstep} @kbd{gate}]} +This command provides a way to delay, +by the specified number of broadcast poll intervals, +believing backward time steps from a broadcast server. +Broadcast time networks are expected to be trusted. +In the event a broadcast server's time is stepped backwards, +there is clear benefit to having the clients notice this change +as soon as possible. +Attacks such as replay attacks can happen, however, +and even though there are a number of protections built in to +broadcast mode, attempts to perform a replay attack are possible. +This value defaults to 0, but can be changed +to any number of poll intervals between 0 and 4. @subsubsection Manycast Options @table @asis @item @code{tos} @code{[@code{ceiling} @kbd{ceiling} | @code{cohort} @code{@{} @code{0} | @code{1} @code{@}} | @code{floor} @kbd{floor} | @code{minclock} @kbd{minclock} | @code{minsane} @kbd{minsane}]} diff --git a/ntpd/invoke-ntp.keys.texi b/ntpd/invoke-ntp.keys.texi index 8585e65b6e6..5982f036dba 100644 --- a/ntpd/invoke-ntp.keys.texi +++ b/ntpd/invoke-ntp.keys.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi) # -# It has been AutoGen-ed June 2, 2016 at 07:36:10 AM by AutoGen 5.18.5 +# It has been AutoGen-ed November 21, 2016 at 08:01:58 AM by AutoGen 5.18.5 # From the definitions ntp.keys.def # and the template file agtexi-file.tpl @end ignore diff --git a/ntpd/invoke-ntpd.texi b/ntpd/invoke-ntpd.texi index 7c1275ab720..975494be71c 100644 --- a/ntpd/invoke-ntpd.texi +++ b/ntpd/invoke-ntpd.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi) # -# It has been AutoGen-ed June 2, 2016 at 07:36:12 AM by AutoGen 5.18.5 +# It has been AutoGen-ed November 21, 2016 at 08:02:00 AM by AutoGen 5.18.5 # From the definitions ntpd-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -142,7 +142,7 @@ with a status code of 0. @exampleindent 0 @example -ntpd - NTP daemon program - Ver. 4.2.8p8 +ntpd - NTP daemon program - Ver. 4.2.8p9 Usage: ntpd [ - [] | --[@{=| @}] ]... \ [ ... ] Flg Arg Option-Name Description diff --git a/ntpd/keyword-gen-utd b/ntpd/keyword-gen-utd index 69665c2d8df..683453dc644 100644 --- a/ntpd/keyword-gen-utd +++ b/ntpd/keyword-gen-utd @@ -1 +1 @@ - * Generated 2016-05-19 06:35:34 UTC diff_ignore_line + * Generated 2016-11-09 11:39:28 UTC diff_ignore_line diff --git a/ntpd/keyword-gen.c b/ntpd/keyword-gen.c index 648b3ae01bc..c9d30bece22 100644 --- a/ntpd/keyword-gen.c +++ b/ntpd/keyword-gen.c @@ -148,6 +148,7 @@ struct key_tok ntp_keywords[] = { { "cohort", T_Cohort, FOLLBY_TOKEN }, { "mindist", T_Mindist, FOLLBY_TOKEN }, { "maxdist", T_Maxdist, FOLLBY_TOKEN }, +{ "bcpollbstep", T_Bcpollbstep, FOLLBY_TOKEN }, { "beacon", T_Beacon, FOLLBY_TOKEN }, { "orphan", T_Orphan, FOLLBY_TOKEN }, { "orphanwait", T_Orphanwait, FOLLBY_TOKEN }, diff --git a/ntpd/ntp.conf.5man b/ntpd/ntp.conf.5man index b3fc3d80e56..35fa0aae5a6 100644 --- a/ntpd/ntp.conf.5man +++ b/ntpd/ntp.conf.5man @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5man "02 Jun 2016" "4.2.8p8" "File Formats" +.TH ntp.conf 5man "21 Nov 2016" "4.2.8p9" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-OzaOIT/ag-3zaGHT) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Q_ai3f/ag-2_aa2f) .\" -.\" It has been AutoGen-ed June 2, 2016 at 07:35:50 AM by AutoGen 5.18.5 +.\" It has been AutoGen-ed November 21, 2016 at 08:01:41 AM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME @@ -2174,7 +2174,23 @@ At the same time, the manycast scheme starts all over from the beginning and the expanding ring shrinks to the minimum and increments from there while collecting all servers in scope. +.SS Broadcast Options +.TP 7 +.NOP \f\*[B-Font]tos\f[] [\f\*[B-Font]bcpollbstep\f[] \f\*[I-Font]gate\f[]] +This command provides a way to delay, +by the specified number of broadcast poll intervals, +believing backward time steps from a broadcast server. +Broadcast time networks are expected to be trusted. +In the event a broadcast server's time is stepped backwards, +there is clear benefit to having the clients notice this change +as soon as possible. +Attacks such as replay attacks can happen, however, +and even though there are a number of protections built in to +broadcast mode, attempts to perform a replay attack are possible. +This value defaults to 0, but can be changed +to any number of poll intervals between 0 and 4. .SS Manycast Options +.RS .TP 7 .NOP \f\*[B-Font]tos\f[] [\f\*[B-Font]ceiling\f[] \f\*[I-Font]ceiling\f[] | \f\*[B-Font]cohort\f[] { \f\*[B-Font]0\f[] | \f\*[B-Font]1\f[] } | \f\*[B-Font]floor\f[] \f\*[I-Font]floor\f[] | \f\*[B-Font]minclock\f[] \f\*[I-Font]minclock\f[] | \f\*[B-Font]minsane\f[] \f\*[I-Font]minsane\f[]] This command affects the clock selection and clustering @@ -2244,7 +2260,7 @@ In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31. -.PP +.RE .SH Reference Clock Support The NTP Version 4 daemon supports some three dozen different radio, satellite and modem reference clocks plus a special pseudo-clock @@ -2411,6 +2427,7 @@ option is used for this purpose. Except where noted, these options apply to all clock drivers. .SS Reference Clock Commands +.RS .TP 7 .NOP \f\*[B-Font]server\f[] \f[C]127.127.\f[]\f\*[I-Font]t\f[].\f\*[I-Font]u\f[] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]mode\f[] \f\*[I-Font]int\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]int\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]int\f[]] This command can be used to configure reference clocks in @@ -2559,8 +2576,9 @@ Further information on the command can be found in \fIMonitoring\f[] \fIOptions\f[]. .RE -.PP +.RE .SH Miscellaneous Options +.RS .TP 7 .NOP \f\*[B-Font]broadcastdelay\f[] \f\*[I-Font]seconds\f[] The broadcast and multicast modes require a special calibration @@ -3079,8 +3097,9 @@ In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31. -.PP +.RE .SH "OPTIONS" +.RS .TP .NOP \f\*[B-Font]\-\-help\f[] Display usage information and exit. @@ -3092,7 +3111,7 @@ Pass the extended usage information through a pager. Output version of program and exit. The default mode is `v', a simple version. The `c' mode will print copyright information and `n' will print the full copyright notice. -.PP +.RE .SH "OPTION PRESETS" Any option that is not marked as \fInot presettable\fP may be preset by loading values from environment variables named: @@ -3103,6 +3122,7 @@ by loading values from environment variables named: .SH "ENVIRONMENT" See \fBOPTION PRESETS\fP for configuration environment variables. .SH FILES +.RS .TP 15 .NOP \fI/etc/ntp.conf\f[] the default name of the configuration file @@ -3126,9 +3146,10 @@ RSA public key .TP 15 .NOP \fIntp_dh\f[] Diffie-Hellman agreement parameters -.PP +.RE .SH "EXIT STATUS" One of the following exit values will be returned: +.RS .TP .NOP 0 " (EXIT_SUCCESS)" Successful program execution. @@ -3139,7 +3160,7 @@ The operation failed or the command syntax was not valid. .NOP 70 " (EX_SOFTWARE)" libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you. -.PP +.RE .SH "SEE ALSO" \fCntpd\f[]\fR(1ntpdmdoc)\f[], \fCntpdc\f[]\fR(1ntpdcmdoc)\f[], diff --git a/ntpd/ntp.conf.5mdoc b/ntpd/ntp.conf.5mdoc index 21806bc2ea7..3d328eb8ddc 100644 --- a/ntpd/ntp.conf.5mdoc +++ b/ntpd/ntp.conf.5mdoc @@ -1,9 +1,9 @@ -.Dd June 2 2016 +.Dd November 21 2016 .Dt NTP_CONF 5mdoc File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed June 2, 2016 at 07:36:16 AM by AutoGen 5.18.5 +.\" It has been AutoGen-ed November 21, 2016 at 08:02:03 AM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -1995,6 +1995,25 @@ At the same time, the manycast scheme starts all over from the beginning and the expanding ring shrinks to the minimum and increments from there while collecting all servers in scope. +.Ss Broadcast Options +.Bl -tag -width indent +.It Xo Ic tos +.Oo +.Cm bcpollbstep Ar gate +.Oc +.Xc +This command provides a way to delay, +by the specified number of broadcast poll intervals, +believing backward time steps from a broadcast server. +Broadcast time networks are expected to be trusted. +In the event a broadcast server's time is stepped backwards, +there is clear benefit to having the clients notice this change +as soon as possible. +Attacks such as replay attacks can happen, however, +and even though there are a number of protections built in to +broadcast mode, attempts to perform a replay attack are possible. +This value defaults to 0, but can be changed +to any number of poll intervals between 0 and 4. .Ss Manycast Options .Bl -tag -width indent .It Xo Ic tos diff --git a/ntpd/ntp.conf.def b/ntpd/ntp.conf.def index a62e9765073..5ae8c382bd1 100644 --- a/ntpd/ntp.conf.def +++ b/ntpd/ntp.conf.def @@ -1997,6 +1997,25 @@ At the same time, the manycast scheme starts all over from the beginning and the expanding ring shrinks to the minimum and increments from there while collecting all servers in scope. +.Ss Broadcast Options +.Bl -tag -width indent +.It Xo Ic tos +.Oo +.Cm bcpollbstep Ar gate +.Oc +.Xc +This command provides a way to delay, +by the specified number of broadcast poll intervals, +believing backward time steps from a broadcast server. +Broadcast time networks are expected to be trusted. +In the event a broadcast server's time is stepped backwards, +there is clear benefit to having the clients notice this change +as soon as possible. +Attacks such as replay attacks can happen, however, +and even though there are a number of protections built in to +broadcast mode, attempts to perform a replay attack are possible. +This value defaults to 0, but can be changed +to any number of poll intervals between 0 and 4. .Ss Manycast Options .Bl -tag -width indent .It Xo Ic tos diff --git a/ntpd/ntp.conf.html b/ntpd/ntp.conf.html index 2f0db057bbd..31cf87e4707 100644 --- a/ntpd/ntp.conf.html +++ b/ntpd/ntp.conf.html @@ -33,9 +33,9 @@ Up: (dir)

This document describes the configuration file for the NTP Project's ntpd program. -

This document applies to version 4.2.8p8 of ntp.conf. +

This document applies to version 4.2.8p9 of ntp.conf. -

+

Short Contents

    NTP's Configuration File User Manual @@ -1926,9 +1926,25 @@ scheme starts all over from the beginning and the expanding ring shrinks to the minimum and increments from there while collecting all servers in scope. -
    Manycast Options
    +
    Broadcast Options
    +
    tos [bcpollbstep gate]
    This command provides a way to delay, +by the specified number of broadcast poll intervals, +believing backward time steps from a broadcast server. +Broadcast time networks are expected to be trusted. +In the event a broadcast server's time is stepped backwards, +there is clear benefit to having the clients notice this change +as soon as possible. +Attacks such as replay attacks can happen, however, +and even though there are a number of protections built in to +broadcast mode, attempts to perform a replay attack are possible. +This value defaults to 0, but can be changed +to any number of poll intervals between 0 and 4. + +
    Manycast Options
    + +
    tos [ceiling ceiling | cohort { 0 | 1 } | floor floor | minclock minclock | minsane minsane]
    This command affects the clock selection and clustering algorithms. It can be used to select the quality and @@ -1936,7 +1952,7 @@ quantity of peers used to synchronize the system clock and is most useful in manycast mode. The variables operate as follows: -
    +
    ceiling ceiling
    Peers with strata above ceiling will be discarded if there are at least @@ -1978,14 +1994,14 @@ Byzantine agreement, should be at least 4 in order to detect and discard a single falseticker.
    -
    ttl hop ...
    This command specifies a list of TTL values in increasing +
    ttl hop ...
    This command specifies a list of TTL values in increasing order, up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
    -
    +



    @@ -1993,7 +2009,7 @@ multiples of 32 starting at 31.

    Reference Clock Support

    -

    The NTP Version 4 daemon supports some three dozen different radio, +

    The NTP Version 4 daemon supports some three dozen different radio, satellite and modem reference clocks plus a special pseudo-clock used for backup or when no other clock source is available. Detailed descriptions of individual device drivers and options can @@ -2030,7 +2046,7 @@ page provided in /usr/share/doc/ntp). -

    A reference clock will generally (though not always) be a radio +

    A reference clock will generally (though not always) be a radio timecode receiver which is synchronized to a source of standard time such as the services offered by the NRC in Canada and NIST and USNO in the US. @@ -2046,7 +2062,7 @@ or the hardware port has not been appropriately configured results in a scalding remark to the system log file, but is otherwise non hazardous. -

    For the purposes of configuration, +

    For the purposes of configuration, ntpd(1ntpdmdoc) treats reference clocks in a manner analogous to normal NTP peers as much @@ -2067,7 +2083,7 @@ While it may seem overkill, it is in fact sometimes useful to configure multiple reference clocks of the same type, in which case the unit numbers must be unique. -

    The +

    The server command is used to configure a reference clock, where the @@ -2105,7 +2121,7 @@ meaning only for selected clock drivers. See the individual clock driver document pages for additional information. -

    The +

    The fudge command is used to provide additional information for individual clock drivers and normally follows @@ -2127,7 +2143,7 @@ in the fudge command as well. -

    The stratum number of a reference clock is by default zero. +

    The stratum number of a reference clock is by default zero. Since the ntpd(1ntpdmdoc) daemon adds one to the stratum of each @@ -2150,11 +2166,11 @@ these options apply to all clock drivers.

    Reference Clock Commands
    -
    +
    server 127.127.t.u [prefer] [mode int] [minpoll int] [maxpoll int]
    This command can be used to configure reference clocks in special ways. The options are interpreted as follows: -
    +
    prefer
    Marks the reference clock as preferred. All other things being equal, this host will be chosen for synchronization among a set of @@ -2187,7 +2203,7 @@ defaults to 10 (17.1 m) and defaults to 14 (4.5 h). The allowable range is 4 (16 s) to 17 (36.4 h) inclusive.
    -
    fudge 127.127.t.u [time1 sec] [time2 sec] [stratum int] [refid string] [mode int] [flag1 0 | 1] [flag2 0 | 1] [flag3 0 | 1] [flag4 0 | 1]
    This command can be used to configure reference clocks in +
    fudge 127.127.t.u [time1 sec] [time2 sec] [stratum int] [refid string] [mode int] [flag1 0 | 1] [flag2 0 | 1] [flag3 0 | 1] [flag4 0 | 1]
    This command can be used to configure reference clocks in special ways. It must immediately follow the server @@ -2198,7 +2214,7 @@ is possible at run time using the program. The options are interpreted as follows: -
    +
    time1 sec
    Specifies a constant to be added to the time offset produced by the driver, a fixed-point decimal number in seconds. This is used @@ -2269,8 +2285,8 @@ Further information on the command can be found in Monitoring Options.
    -
    -
    +
    +



    @@ -2278,7 +2294,7 @@ command can be found in

    Miscellaneous Options

    -
    +
    broadcastdelay seconds
    The broadcast and multicast modes require a special calibration to determine the network delay between the local and remote servers. @@ -2311,7 +2327,7 @@ frequency of zero and creates the file when writing it for the first time. If this command is not given, the daemon will always start with an initial frequency of zero. -

    The file format consists of a single line containing a single +

    The file format consists of a single line containing a single floating point number, which records the frequency offset measured in parts-per-million (PPM). The file is updated by first writing @@ -2331,7 +2347,7 @@ Note that all of these flags can be controlled remotely using the ntpdc(1ntpdcmdoc) utility program. -

    +
    auth
    Enables the server to synchronize with unconfigured peers only if the peer has been correctly authenticated using either public key or private key cryptography. @@ -2466,7 +2482,7 @@ The default for this flag is enable.
    -
    includefile includefile
    This command allows additional configuration commands +
    includefile includefile
    This command allows additional configuration commands to be included from a separate file. Include files may be nested to a depth of five; upon reaching the end of any @@ -2527,7 +2543,7 @@ and status messages (status). -

    Configuration keywords are formed by concatenating the message class with +

    Configuration keywords are formed by concatenating the message class with the event class. The all @@ -2539,20 +2555,20 @@ keyword to enable/disable all messages of the respective message class. Thus, a minimal log configuration could look like this: -

         
    -     logconfig =syncstatus +sysevents
    -
    +
              
    +          logconfig =syncstatus +sysevents
    +     
    -

    This would just list the synchronizations state of +

    This would just list the synchronizations state of ntpd(1ntpdmdoc) and the major system events. For a simple reference server, the following minimum message configuration could be useful: -

         
    -     logconfig =syncall +clockall
    -
    +
              
    +          logconfig =syncall +clockall
    +     
    -

    This configuration will list all clock information and +

    This configuration will list all clock information and synchronization information. All other events and messages about peers, system events and so on is suppressed. @@ -2611,8 +2627,8 @@ for them. Emphasis added: twisters are on their own and can expect no help from the support group. -

    The variables operate as follows: -

    +

    The variables operate as follows: +

    allan allan
    The argument becomes the new value for the minimum Allan intercept, which is a parameter of the PLL/FLL clock discipline algorithm. @@ -2661,8 +2677,8 @@ be set to any positive number in seconds. If set to zero, the stepout pulses will not be suppressed.
    -
    rlimit [memlock Nmegabytes | stacksize N4kPages filenum Nfiledescriptors]
    -
    +
    rlimit [memlock Nmegabytes | stacksize N4kPages filenum Nfiledescriptors]
    +
    memlock Nmegabytes
    Specify the number of megabytes of memory that should be allocated and locked. Probably only available under Linux, this option may be useful @@ -2679,7 +2695,7 @@ Defaults to 50 4k pages (200 4k pages in OpenBSD).
    filenum Nfiledescriptors
    Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default.
    -
    trap host_address [port port_number] [interface interface_address]
    This command configures a trap receiver at the given host +
    trap host_address [port port_number] [interface interface_address]
    This command configures a trap receiver at the given host address and port number for sending messages with the specified local interface address. If the port number is unspecified, a value @@ -2690,7 +2706,7 @@ message is sent through. Note that on a multihomed host the interface used may vary from time to time with routing changes. -

    The trap receiver will generally log event messages and other +

    The trap receiver will generally log event messages and other information from the server in a log file. While such monitor programs may also request their own trap dynamically, configuring a @@ -2704,11 +2720,11 @@ The default is eight multiples of 32 starting at 31.

    -

    This section was generated by AutoGen, +

    This section was generated by AutoGen, using the agtexi-cmd template and the option descriptions for the ntp.conf program. This software is released under the NTP license, <http://ntp.org/license>. -