diff --git a/drivers/bus/acpi/CMakeLists.txt b/drivers/bus/acpi/CMakeLists.txt index cc2cb2f07b8..b4d039fda22 100644 --- a/drivers/bus/acpi/CMakeLists.txt +++ b/drivers/bus/acpi/CMakeLists.txt @@ -162,6 +162,7 @@ list(APPEND ACPICA_SOURCE acpica/utilities/utstate.c acpica/utilities/utstring.c acpica/utilities/utstrtoul64.c + acpica/utilities/utstrsuppt.c # acpica/utilities/utuuid.c acpica/utilities/uttrack.c acpica/utilities/utxface.c diff --git a/drivers/bus/acpi/acpica/dispatcher/dscontrol.c b/drivers/bus/acpi/acpica/dispatcher/dscontrol.c index df22ddfb443..61415a6a759 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dscontrol.c +++ b/drivers/bus/acpi/acpica/dispatcher/dscontrol.c @@ -126,7 +126,8 @@ AcpiDsExecBeginControlOp ( WalkState->ParserState.PkgEnd; ControlState->Control.Opcode = Op->Common.AmlOpcode; - + ControlState->Control.LoopTimeout = AcpiOsGetTimer () + + (UINT64) (AcpiGbl_MaxLoopIterations * ACPI_100NSEC_PER_SEC); /* Push the control state on this walk's control stack */ @@ -219,15 +220,15 @@ AcpiDsExecEndControlOp ( /* Predicate was true, the body of the loop was just executed */ /* - * This loop counter mechanism allows the interpreter to escape - * possibly infinite loops. This can occur in poorly written AML - * when the hardware does not respond within a while loop and the - * loop does not implement a timeout. + * This infinite loop detection mechanism allows the interpreter + * to escape possibly infinite loops. This can occur in poorly + * written AML when the hardware does not respond within a while + * loop and the loop does not implement a timeout. */ - ControlState->Control.LoopCount++; - if (ControlState->Control.LoopCount > AcpiGbl_MaxLoopIterations) + if (ACPI_TIME_AFTER (AcpiOsGetTimer (), + ControlState->Control.LoopTimeout)) { - Status = AE_AML_INFINITE_LOOP; + Status = AE_AML_LOOP_TIMEOUT; break; } diff --git a/drivers/bus/acpi/acpica/dispatcher/dsfield.c b/drivers/bus/acpi/acpica/dispatcher/dsfield.c index a755606d4da..4b83954ab80 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dsfield.c +++ b/drivers/bus/acpi/acpica/dispatcher/dsfield.c @@ -232,7 +232,8 @@ AcpiDsCreateBufferField ( ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } } @@ -416,7 +417,8 @@ AcpiDsGetFieldNames ( WalkState, &Info->ConnectionNode); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Child->Common.Value.Name, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Child->Common.Value.Name, Status); return_ACPI_STATUS (Status); } } @@ -432,7 +434,8 @@ AcpiDsGetFieldNames ( WalkState, &Info->FieldNode); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Status); return_ACPI_STATUS (Status); } else @@ -531,7 +534,8 @@ AcpiDsCreateField ( #endif if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.Name, Status); return_ACPI_STATUS (Status); } } @@ -661,7 +665,8 @@ AcpiDsInitFieldObjects ( Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Status); if (Status != AE_ALREADY_EXISTS) { return_ACPI_STATUS (Status); @@ -726,7 +731,8 @@ AcpiDsCreateBankField ( #endif if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.Name, Status); return_ACPI_STATUS (Status); } } @@ -739,7 +745,8 @@ AcpiDsCreateBankField ( ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } @@ -812,7 +819,8 @@ AcpiDsCreateIndexField ( ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } @@ -824,7 +832,8 @@ AcpiDsCreateIndexField ( ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } diff --git a/drivers/bus/acpi/acpica/dispatcher/dsobject.c b/drivers/bus/acpi/acpica/dispatcher/dsobject.c index ef0f2b7fdb9..2924ca87321 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dsobject.c +++ b/drivers/bus/acpi/acpica/dispatcher/dsobject.c @@ -115,7 +115,8 @@ AcpiDsBuildInternalObject ( ACPI_NAMESPACE_NODE, &(Op->Common.Node))); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Op->Common.Value.String, Status); return_ACPI_STATUS (Status); } } diff --git a/drivers/bus/acpi/acpica/dispatcher/dspkginit.c b/drivers/bus/acpi/acpica/dispatcher/dspkginit.c index 65d3c69343e..f10b113b99f 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dspkginit.c +++ b/drivers/bus/acpi/acpica/dispatcher/dspkginit.c @@ -311,9 +311,12 @@ AcpiDsInitPackageElement ( ACPI_OPERAND_OBJECT **ElementPtr; + ACPI_FUNCTION_TRACE (DsInitPackageElement); + + if (!SourceObject) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -348,7 +351,7 @@ AcpiDsInitPackageElement ( SourceObject->Package.Flags |= AOPOBJ_DATA_VALID; } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -373,6 +376,7 @@ AcpiDsResolvePackageElement ( ACPI_GENERIC_STATE ScopeInfo; ACPI_OPERAND_OBJECT *Element = *ElementPtr; ACPI_NAMESPACE_NODE *ResolvedNode; + ACPI_NAMESPACE_NODE *OriginalNode; char *ExternalPath = NULL; ACPI_OBJECT_TYPE Type; @@ -468,6 +472,7 @@ AcpiDsResolvePackageElement ( * will remain as named references. This behavior is not described * in the ACPI spec, but it appears to be an oversight. */ + OriginalNode = ResolvedNode; Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); if (ACPI_FAILURE (Status)) { @@ -499,26 +504,27 @@ AcpiDsResolvePackageElement ( */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_THERMAL: - - /* TBD: This may not be necesssary */ - - AcpiUtAddReference (ResolvedNode->Object); + case ACPI_TYPE_METHOD: break; case ACPI_TYPE_MUTEX: - case ACPI_TYPE_METHOD: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_EVENT: case ACPI_TYPE_REGION: + /* AcpiExResolveNodeToValue gave these an extra reference */ + + AcpiUtRemoveReference (OriginalNode->Object); break; default: /* * For all other types - the node was resolved to an actual - * operand object with a value, return the object + * operand object with a value, return the object. Remove + * a reference on the existing object. */ + AcpiUtRemoveReference (Element); *ElementPtr = (ACPI_OPERAND_OBJECT *) ResolvedNode; break; } diff --git a/drivers/bus/acpi/acpica/dispatcher/dsutils.c b/drivers/bus/acpi/acpica/dispatcher/dsutils.c index 1b661a0ede9..6445f468496 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dsutils.c +++ b/drivers/bus/acpi/acpica/dispatcher/dsutils.c @@ -624,7 +624,8 @@ AcpiDsCreateOperand ( if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (NameString, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + NameString, Status); } } diff --git a/drivers/bus/acpi/acpica/dispatcher/dswexec.c b/drivers/bus/acpi/acpica/dispatcher/dswexec.c index a5b5db842de..d5a9053709f 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dswexec.c +++ b/drivers/bus/acpi/acpica/dispatcher/dswexec.c @@ -145,7 +145,7 @@ AcpiDsGetPredicateValue ( * object. Implicitly convert the argument if necessary. */ Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, - ACPI_STRTOUL_BASE16); + ACPI_IMPLICIT_CONVERSION); if (ACPI_FAILURE (Status)) { goto Cleanup; diff --git a/drivers/bus/acpi/acpica/dispatcher/dswload.c b/drivers/bus/acpi/acpica/dispatcher/dswload.c index e8fea3737e5..a6d1fd4a6f9 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dswload.c +++ b/drivers/bus/acpi/acpica/dispatcher/dswload.c @@ -217,7 +217,7 @@ AcpiDsLoad1BeginOp ( #endif if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Path, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status); return_ACPI_STATUS (Status); } @@ -387,7 +387,7 @@ AcpiDsLoad1BeginOp ( if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Path, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status); return_ACPI_STATUS (Status); } } diff --git a/drivers/bus/acpi/acpica/dispatcher/dswload2.c b/drivers/bus/acpi/acpica/dispatcher/dswload2.c index c9a142f5f0c..b8d06746a16 100644 --- a/drivers/bus/acpi/acpica/dispatcher/dswload2.c +++ b/drivers/bus/acpi/acpica/dispatcher/dswload2.c @@ -196,10 +196,12 @@ AcpiDsLoad2BeginOp ( } else { - ACPI_ERROR_NAMESPACE (BufferPtr, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + BufferPtr, Status); } #else - ACPI_ERROR_NAMESPACE (BufferPtr, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + BufferPtr, Status); #endif return_ACPI_STATUS (Status); } @@ -354,7 +356,8 @@ AcpiDsLoad2BeginOp ( if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (BufferPtr, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + BufferPtr, Status); return_ACPI_STATUS (Status); } @@ -736,7 +739,8 @@ AcpiDsLoad2EndOp ( } else { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, + Arg->Common.Value.String, Status); } break; diff --git a/drivers/bus/acpi/acpica/events/evgpe.c b/drivers/bus/acpi/acpica/events/evgpe.c index d4964309ce6..7896ab3de5e 100644 --- a/drivers/bus/acpi/acpica/events/evgpe.c +++ b/drivers/bus/acpi/acpica/events/evgpe.c @@ -443,8 +443,8 @@ AcpiEvGpeDetect ( ACPI_GPE_HANDLER_INFO *GpeHandlerInfo; UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT8 EnabledStatusByte; - UINT32 StatusReg; - UINT32 EnableReg; + UINT64 StatusReg; + UINT64 EnableReg; ACPI_CPU_FLAGS Flags; UINT32 i; UINT32 j; @@ -521,7 +521,7 @@ AcpiEvGpeDetect ( "RunEnable=%02X, WakeEnable=%02X\n", GpeRegisterInfo->BaseGpeNumber, GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), - StatusReg, EnableReg, + (UINT32) StatusReg, (UINT32) EnableReg, GpeRegisterInfo->EnableForRun, GpeRegisterInfo->EnableForWake)); diff --git a/drivers/bus/acpi/acpica/events/evregion.c b/drivers/bus/acpi/acpica/events/evregion.c index 16a2e755e72..266af68701b 100644 --- a/drivers/bus/acpi/acpica/events/evregion.c +++ b/drivers/bus/acpi/acpica/events/evregion.c @@ -315,6 +315,17 @@ AcpiEvAddressSpaceDispatch ( { ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]", AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + /* + * Special case for an EC timeout. These are seen so frequently + * that an additional error message is helpful + */ + if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && + (Status == AE_TIME)) + { + ACPI_ERROR ((AE_INFO, + "Timeout from EC hardware or EC device driver")); + } } if (!(HandlerDesc->AddressSpace.HandlerFlags & diff --git a/drivers/bus/acpi/acpica/executer/exconcat.c b/drivers/bus/acpi/acpica/executer/exconcat.c index aeb33bb0458..97a1b6a9f2e 100644 --- a/drivers/bus/acpi/acpica/executer/exconcat.c +++ b/drivers/bus/acpi/acpica/executer/exconcat.c @@ -165,7 +165,7 @@ AcpiExDoConcatenate ( case ACPI_TYPE_INTEGER: Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, - ACPI_STRTOUL_BASE16); + ACPI_IMPLICIT_CONVERSION); break; case ACPI_TYPE_BUFFER: diff --git a/drivers/bus/acpi/acpica/executer/exconvrt.c b/drivers/bus/acpi/acpica/executer/exconvrt.c index 2a6a14c376d..856b295f7ab 100644 --- a/drivers/bus/acpi/acpica/executer/exconvrt.c +++ b/drivers/bus/acpi/acpica/executer/exconvrt.c @@ -64,10 +64,10 @@ AcpiExConvertToAscii ( * * FUNCTION: AcpiExConvertToInteger * - * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String - * ResultDesc - Where the new Integer object is returned - * Flags - Used for string conversion + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new Integer object is returned + * ImplicitConversion - Used for string conversion * * RETURN: Status * @@ -79,14 +79,13 @@ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Flags) + UINT32 ImplicitConversion) { ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *Pointer; UINT64 Result; UINT32 i; UINT32 Count; - ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); @@ -136,12 +135,17 @@ AcpiExConvertToInteger ( * hexadecimal as per the ACPI specification. The only exception (as * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). + * + * Explicit conversion is used only by ToInteger. + * All other string-to-integer conversions are implicit conversions. */ - Status = AcpiUtStrtoul64 (ACPI_CAST_PTR (char, Pointer), - (AcpiGbl_IntegerByteWidth | Flags), &Result); - if (ACPI_FAILURE (Status)) + if (ImplicitConversion) { - return_ACPI_STATUS (Status); + Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer)); + } + else + { + Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer)); } break; @@ -684,7 +688,7 @@ AcpiExConvertToTargetType ( * a Buffer or a String to an Integer if necessary. */ Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, - ACPI_STRTOUL_BASE16); + ACPI_IMPLICIT_CONVERSION); break; case ACPI_TYPE_STRING: diff --git a/drivers/bus/acpi/acpica/executer/exdump.c b/drivers/bus/acpi/acpica/executer/exdump.c index f4d81ee6315..da5f72a5c14 100644 --- a/drivers/bus/acpi/acpica/executer/exdump.c +++ b/drivers/bus/acpi/acpica/executer/exdump.c @@ -639,7 +639,7 @@ AcpiExDumpOperand ( UINT32 Index; - ACPI_FUNCTION_NAME (ExDumpOperand) + ACPI_FUNCTION_NAME (ExDumpOperand); /* Check if debug output enabled */ @@ -934,7 +934,7 @@ AcpiExDumpOperands ( const char *OpcodeName, UINT32 NumOperands) { - ACPI_FUNCTION_NAME (ExDumpOperands); + ACPI_FUNCTION_TRACE (ExDumpOperands); if (!OpcodeName) @@ -962,7 +962,7 @@ AcpiExDumpOperands ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** End operand dump for [%s]\n", OpcodeName)); - return; + return_VOID; } diff --git a/drivers/bus/acpi/acpica/executer/exmisc.c b/drivers/bus/acpi/acpica/executer/exmisc.c index 67b8e1142f9..edc1bff1821 100644 --- a/drivers/bus/acpi/acpica/executer/exmisc.c +++ b/drivers/bus/acpi/acpica/executer/exmisc.c @@ -363,7 +363,7 @@ AcpiExDoLogicalOp ( case ACPI_TYPE_INTEGER: Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, - ACPI_STRTOUL_BASE16); + ACPI_IMPLICIT_CONVERSION); break; case ACPI_TYPE_STRING: diff --git a/drivers/bus/acpi/acpica/executer/exresop.c b/drivers/bus/acpi/acpica/executer/exresop.c index 98bbeed3ff0..9785eb6a5ea 100644 --- a/drivers/bus/acpi/acpica/executer/exresop.c +++ b/drivers/bus/acpi/acpica/executer/exresop.c @@ -433,7 +433,7 @@ AcpiExResolveOperands ( * Known as "Implicit Source Operand Conversion" */ Status = AcpiExConvertToInteger (ObjDesc, StackPtr, - ACPI_STRTOUL_BASE16); + ACPI_IMPLICIT_CONVERSION); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) diff --git a/drivers/bus/acpi/acpica/hardware/hwgpe.c b/drivers/bus/acpi/acpica/hardware/hwgpe.c index af33c93414d..83045dd77b0 100644 --- a/drivers/bus/acpi/acpica/hardware/hwgpe.c +++ b/drivers/bus/acpi/acpica/hardware/hwgpe.c @@ -109,7 +109,7 @@ AcpiHwLowSetGpe ( { ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status = AE_OK; - UINT32 EnableMask; + UINT64 EnableMask; UINT32 RegisterBit; @@ -234,7 +234,7 @@ AcpiHwGetGpeStatus ( ACPI_GPE_EVENT_INFO *GpeEventInfo, ACPI_EVENT_STATUS *EventStatus) { - UINT32 InByte; + UINT64 InByte; UINT32 RegisterBit; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_EVENT_STATUS LocalEventStatus = 0; diff --git a/drivers/bus/acpi/acpica/hardware/hwregs.c b/drivers/bus/acpi/acpica/hardware/hwregs.c index e28793235cf..7273acf8a31 100644 --- a/drivers/bus/acpi/acpica/hardware/hwregs.c +++ b/drivers/bus/acpi/acpica/hardware/hwregs.c @@ -247,9 +247,8 @@ AcpiHwValidateRegister ( * * RETURN: Status * - * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max - * version of AcpiRead, used internally since the overhead of - * 64-bit values is not needed. + * DESCRIPTION: Read from either memory or IO space. This is a 64-bit max + * version of AcpiRead. * * LIMITATIONS: * SpaceID must be SystemMemory or SystemIO. @@ -258,7 +257,7 @@ AcpiHwValidateRegister ( ACPI_STATUS AcpiHwRead ( - UINT32 *Value, + UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; @@ -276,18 +275,18 @@ AcpiHwRead ( /* Validate contents of the GAS register */ - Status = AcpiHwValidateRegister (Reg, 32, &Address); + Status = AcpiHwValidateRegister (Reg, 64, &Address); if (ACPI_FAILURE (Status)) { return (Status); } /* - * Initialize entire 32-bit return value to zero, convert AccessWidth + * Initialize entire 64-bit return value to zero, convert AccessWidth * into number of bits based */ *Value = 0; - AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 64); BitWidth = Reg->BitOffset + Reg->BitWidth; BitOffset = Reg->BitOffset; @@ -300,7 +299,7 @@ AcpiHwRead ( { if (BitOffset >= AccessWidth) { - Value32 = 0; + Value64 = 0; BitOffset -= AccessWidth; } else @@ -310,31 +309,31 @@ AcpiHwRead ( Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) Address + Index * ACPI_DIV_8 (AccessWidth), &Value64, AccessWidth); - Value32 = (UINT32) Value64; } else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ { Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address + Index * ACPI_DIV_8 (AccessWidth), &Value32, AccessWidth); + Value64 = (UINT64) Value32; } } /* * Use offset style bit writes because "Index * AccessWidth" is - * ensured to be less than 32-bits by AcpiHwValidateRegister(). + * ensured to be less than 64-bits by AcpiHwValidateRegister(). */ ACPI_SET_BITS (Value, Index * AccessWidth, - ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32); + ACPI_MASK_BITS_ABOVE_64 (AccessWidth), Value64); BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*Value), AccessWidth, + ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); } @@ -349,15 +348,14 @@ AcpiHwRead ( * * RETURN: Status * - * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max - * version of AcpiWrite, used internally since the overhead of - * 64-bit values is not needed. + * DESCRIPTION: Write to either memory or IO space. This is a 64-bit max + * version of AcpiWrite. * ******************************************************************************/ ACPI_STATUS AcpiHwWrite ( - UINT32 Value, + UINT64 Value, ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; @@ -365,7 +363,6 @@ AcpiHwWrite ( UINT32 BitWidth; UINT8 BitOffset; UINT64 Value64; - UINT32 Value32; UINT8 Index; ACPI_STATUS Status; @@ -375,7 +372,7 @@ AcpiHwWrite ( /* Validate contents of the GAS register */ - Status = AcpiHwValidateRegister (Reg, 32, &Address); + Status = AcpiHwValidateRegister (Reg, 64, &Address); if (ACPI_FAILURE (Status)) { return (Status); @@ -383,7 +380,7 @@ AcpiHwWrite ( /* Convert AccessWidth into number of bits based */ - AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 64); BitWidth = Reg->BitOffset + Reg->BitWidth; BitOffset = Reg->BitOffset; @@ -396,10 +393,10 @@ AcpiHwWrite ( { /* * Use offset style bit reads because "Index * AccessWidth" is - * ensured to be less than 32-bits by AcpiHwValidateRegister(). + * ensured to be less than 64-bits by AcpiHwValidateRegister(). */ - Value32 = ACPI_GET_BITS (&Value, Index * AccessWidth, - ACPI_MASK_BITS_ABOVE_32 (AccessWidth)); + Value64 = ACPI_GET_BITS (&Value, Index * AccessWidth, + ACPI_MASK_BITS_ABOVE_64 (AccessWidth)); if (BitOffset >= AccessWidth) { @@ -409,7 +406,6 @@ AcpiHwWrite ( { if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - Value64 = (UINT64) Value32; Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) Address + Index * ACPI_DIV_8 (AccessWidth), Value64, AccessWidth); @@ -418,7 +414,7 @@ AcpiHwWrite ( { Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address + Index * ACPI_DIV_8 (AccessWidth), - Value32, AccessWidth); + (UINT32) Value64, AccessWidth); } } @@ -431,9 +427,9 @@ AcpiHwWrite ( } ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), AccessWidth, + ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); } @@ -580,6 +576,7 @@ AcpiHwRegisterRead ( UINT32 *ReturnValue) { UINT32 Value = 0; + UINT64 Value64; ACPI_STATUS Status; @@ -618,12 +615,14 @@ AcpiHwRegisterRead ( case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwRead (&Value64, &AcpiGbl_FADT.XPm2ControlBlock); + Value = (UINT32) Value64; break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (&Value64, &AcpiGbl_FADT.XPmTimerBlock); + Value = (UINT32) Value64; break; case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ @@ -641,7 +640,7 @@ AcpiHwRegisterRead ( if (ACPI_SUCCESS (Status)) { - *ReturnValue = Value; + *ReturnValue = (UINT32) Value; } return_ACPI_STATUS (Status); @@ -681,6 +680,7 @@ AcpiHwRegisterWrite ( { ACPI_STATUS Status; UINT32 ReadValue; + UINT64 ReadValue64; ACPI_FUNCTION_TRACE (HwRegisterWrite); @@ -742,11 +742,12 @@ AcpiHwRegisterWrite ( * For control registers, all reserved bits must be preserved, * as per the ACPI spec. */ - Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwRead (&ReadValue64, &AcpiGbl_FADT.XPm2ControlBlock); if (ACPI_FAILURE (Status)) { goto Exit; } + ReadValue = (UINT32) ReadValue64; /* Insert the bits to be preserved */ @@ -802,26 +803,29 @@ AcpiHwReadMultiple ( { UINT32 ValueA = 0; UINT32 ValueB = 0; + UINT64 Value64; ACPI_STATUS Status; /* The first register is always required */ - Status = AcpiHwRead (&ValueA, RegisterA); + Status = AcpiHwRead (&Value64, RegisterA); if (ACPI_FAILURE (Status)) { return (Status); } + ValueA = (UINT32) Value64; /* Second register is optional */ if (RegisterB->Address) { - Status = AcpiHwRead (&ValueB, RegisterB); + Status = AcpiHwRead (&Value64, RegisterB); if (ACPI_FAILURE (Status)) { return (Status); } + ValueB = (UINT32) Value64; } /* diff --git a/drivers/bus/acpi/acpica/hardware/hwtimer.c b/drivers/bus/acpi/acpica/hardware/hwtimer.c index f90d27b0b2c..5dc224c55ab 100644 --- a/drivers/bus/acpi/acpica/hardware/hwtimer.c +++ b/drivers/bus/acpi/acpica/hardware/hwtimer.c @@ -107,6 +107,7 @@ AcpiGetTimer ( UINT32 *Ticks) { ACPI_STATUS Status; + UINT64 TimerValue; ACPI_FUNCTION_TRACE (AcpiGetTimer); @@ -124,7 +125,14 @@ AcpiGetTimer ( return_ACPI_STATUS (AE_SUPPORT); } - Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (&TimerValue, &AcpiGbl_FADT.XPmTimerBlock); + if (ACPI_SUCCESS (Status)) + { + /* ACPI PM Timer is defined to be 32 bits (PM_TMR_LEN) */ + + *Ticks = (UINT32) TimerValue; + } + return_ACPI_STATUS (Status); } @@ -167,7 +175,7 @@ AcpiGetTimerDuration ( UINT32 *TimeElapsed) { ACPI_STATUS Status; - UINT32 DeltaTicks; + UINT64 DeltaTicks; UINT64 Quotient; @@ -186,34 +194,33 @@ AcpiGetTimerDuration ( return_ACPI_STATUS (AE_SUPPORT); } + if (StartTicks == EndTicks) + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } + /* * Compute Tick Delta: * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. */ - if (StartTicks < EndTicks) - { - DeltaTicks = EndTicks - StartTicks; - } - else if (StartTicks > EndTicks) + DeltaTicks = EndTicks; + if (StartTicks > EndTicks) { if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) { /* 24-bit Timer */ - DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); + DeltaTicks |= (UINT64) 1 << 24; } else { /* 32-bit Timer */ - DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; + DeltaTicks |= (UINT64) 1 << 32; } } - else /* StartTicks == EndTicks */ - { - *TimeElapsed = 0; - return_ACPI_STATUS (AE_OK); - } + DeltaTicks -= StartTicks; /* * Compute Duration (Requires a 64-bit multiply and divide): @@ -221,7 +228,7 @@ AcpiGetTimerDuration ( * TimeElapsed (microseconds) = * (DeltaTicks * ACPI_USEC_PER_SEC) / ACPI_PM_TIMER_FREQUENCY; */ - Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * ACPI_USEC_PER_SEC, + Status = AcpiUtShortDivide (DeltaTicks * ACPI_USEC_PER_SEC, ACPI_PM_TIMER_FREQUENCY, &Quotient, NULL); *TimeElapsed = (UINT32) Quotient; diff --git a/drivers/bus/acpi/acpica/hardware/hwvalid.c b/drivers/bus/acpi/acpica/hardware/hwvalid.c index 8fce29b137d..a4b1917ea67 100644 --- a/drivers/bus/acpi/acpica/hardware/hwvalid.c +++ b/drivers/bus/acpi/acpica/hardware/hwvalid.c @@ -137,7 +137,7 @@ AcpiHwValidateIoRequest ( const ACPI_PORT_INFO *PortInfo; - ACPI_FUNCTION_NAME (HwValidateIoRequest); + ACPI_FUNCTION_TRACE (HwValidateIoRequest); /* Supported widths are 8/16/32 */ @@ -148,14 +148,15 @@ AcpiHwValidateIoRequest ( { ACPI_ERROR ((AE_INFO, "Bad BitWidth parameter: %8.8X", BitWidth)); - return (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_BAD_PARAMETER); } PortInfo = AcpiProtectedPorts; ByteWidth = ACPI_DIV_8 (BitWidth); LastAddress = Address + ByteWidth - 1; - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %8.8X%8.8X LastAddress %8.8X%8.8X Length %X", + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Address %8.8X%8.8X LastAddress %8.8X%8.8X Length %X", ACPI_FORMAT_UINT64 (Address), ACPI_FORMAT_UINT64 (LastAddress), ByteWidth)); @@ -166,14 +167,14 @@ AcpiHwValidateIoRequest ( ACPI_ERROR ((AE_INFO, "Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X", ACPI_FORMAT_UINT64 (Address), ByteWidth)); - return (AE_LIMIT); + return_ACPI_STATUS (AE_LIMIT); } /* Exit if requested address is not within the protected port table */ if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Check request against the list of protected I/O ports */ @@ -195,8 +196,8 @@ AcpiHwValidateIoRequest ( if (AcpiGbl_OsiData >= PortInfo->OsiDependency) { - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)", + ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, + "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)\n", ACPI_FORMAT_UINT64 (Address), ByteWidth, PortInfo->Name, PortInfo->Start, PortInfo->End)); @@ -212,7 +213,7 @@ AcpiHwValidateIoRequest ( } } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } diff --git a/drivers/bus/acpi/acpica/hardware/hwxface.c b/drivers/bus/acpi/acpica/hardware/hwxface.c index e367814da58..f4ebe575015 100644 --- a/drivers/bus/acpi/acpica/hardware/hwxface.c +++ b/drivers/bus/acpi/acpica/hardware/hwxface.c @@ -139,84 +139,14 @@ AcpiRead ( UINT64 *ReturnValue, ACPI_GENERIC_ADDRESS *Reg) { - UINT32 ValueLo; - UINT32 ValueHi; - UINT32 Width; - UINT64 Address; ACPI_STATUS Status; ACPI_FUNCTION_NAME (AcpiRead); - if (!ReturnValue) - { - return (AE_BAD_PARAMETER); - } - - /* Validate contents of the GAS register. Allow 64-bit transfers */ - - Status = AcpiHwValidateRegister (Reg, 64, &Address); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * Two address spaces supported: Memory or I/O. PCI_Config is - * not supported here because the GAS structure is insufficient - */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, ReturnValue, Reg->BitWidth); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - ValueLo = 0; - ValueHi = 0; - - Width = Reg->BitWidth; - if (Width == 64) - { - Width = 32; /* Break into two 32-bit transfers */ - } - - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, &ValueLo, Width); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (Reg->BitWidth == 64) - { - /* Read the top 32 bits */ - - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - (Address + 4), &ValueHi, 32); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - - /* Set the return value only if status is AE_OK */ - - *ReturnValue = (ValueLo | ((UINT64) ValueHi << 32)); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", - ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, - ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); - - return (AE_OK); + Status = AcpiHwRead (ReturnValue, Reg); + return (Status); } ACPI_EXPORT_SYMBOL (AcpiRead) @@ -240,67 +170,13 @@ AcpiWrite ( UINT64 Value, ACPI_GENERIC_ADDRESS *Reg) { - UINT32 Width; - UINT64 Address; ACPI_STATUS Status; ACPI_FUNCTION_NAME (AcpiWrite); - /* Validate contents of the GAS register. Allow 64-bit transfers */ - - Status = AcpiHwValidateRegister (Reg, 64, &Address); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * Two address spaces supported: Memory or IO. PCI_Config is - * not supported here because the GAS structure is insufficient - */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, Value, Reg->BitWidth); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Width = Reg->BitWidth; - if (Width == 64) - { - Width = 32; /* Break into two 32-bit transfers */ - } - - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, ACPI_LODWORD (Value), Width); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (Reg->BitWidth == 64) - { - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - (Address + 4), ACPI_HIDWORD (Value), 32); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", - ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, - ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); - + Status = AcpiHwWrite (Value, Reg); return (Status); } diff --git a/drivers/bus/acpi/acpica/include/acapps.h b/drivers/bus/acpi/acpica/include/acapps.h index b3a8eadc33e..1df37f20524 100644 --- a/drivers/bus/acpi/acpica/include/acapps.h +++ b/drivers/bus/acpi/acpica/include/acapps.h @@ -80,6 +80,9 @@ Prefix, ACPICA_COPYRIGHT, \ Prefix +#define ACPI_COMMON_BUILD_TIME \ + "Build date/time: %s %s\n", __DATE__, __TIME__ + /* Macros for usage messages */ #define ACPI_USAGE_HEADER(Usage) \ diff --git a/drivers/bus/acpi/acpica/include/acconfig.h b/drivers/bus/acpi/acpica/include/acconfig.h index a0e22703a32..b1eccb6fd8d 100644 --- a/drivers/bus/acpi/acpica/include/acconfig.h +++ b/drivers/bus/acpi/acpica/include/acconfig.h @@ -147,9 +147,9 @@ #define ACPI_ADDRESS_RANGE_MAX 2 -/* Maximum number of While() loops before abort */ +/* Maximum time (default 30s) of While() loops before abort */ -#define ACPI_MAX_LOOP_COUNT 0x000FFFFF +#define ACPI_MAX_LOOP_TIMEOUT 30 /****************************************************************************** diff --git a/drivers/bus/acpi/acpica/include/acdebug.h b/drivers/bus/acpi/acpica/include/acdebug.h index 73d02d1adac..98320ba780b 100644 --- a/drivers/bus/acpi/acpica/include/acdebug.h +++ b/drivers/bus/acpi/acpica/include/acdebug.h @@ -343,6 +343,12 @@ AcpiDbExecute ( ACPI_OBJECT_TYPE *Types, UINT32 Flags); +void +AcpiDbCreateExecutionThread ( + char *MethodNameArg, + char **Arguments, + ACPI_OBJECT_TYPE *Types); + void AcpiDbCreateExecutionThreads ( char *NumThreadsArg, diff --git a/drivers/bus/acpi/acpica/include/acdisasm.h b/drivers/bus/acpi/acpica/include/acdisasm.h index 73ad5c15f6c..d01ea22ca40 100644 --- a/drivers/bus/acpi/acpica/include/acdisasm.h +++ b/drivers/bus/acpi/acpica/include/acdisasm.h @@ -164,8 +164,10 @@ typedef enum ACPI_DMT_PMTT, ACPI_DMT_PPTT, ACPI_DMT_SDEI, + ACPI_DMT_SDEV, ACPI_DMT_SLIC, ACPI_DMT_SRAT, + ACPI_DMT_TPM2, /* Special opcodes */ @@ -394,6 +396,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit5[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPdtt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt1[]; @@ -407,6 +411,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPdtt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPptt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPptt0a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPptt1[]; @@ -421,6 +426,13 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdei[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdevHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev0a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev1a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSdev1b[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; @@ -438,6 +450,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaClient[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaServer[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm211[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoVrtc[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoVrtc0[]; @@ -478,7 +492,7 @@ AcpiDmDumpTable ( UINT32 TableLength, UINT32 TableOffset, void *Table, - UINT32 SubTableLength, + UINT32 SubtableLength, ACPI_DMTABLE_INFO *Info); void @@ -604,6 +618,10 @@ void AcpiDmDumpPcct ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpPdtt ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpPmtt ( ACPI_TABLE_HEADER *Table); @@ -624,6 +642,10 @@ UINT32 AcpiDmDumpS3pt ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpSdev ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpSlic ( ACPI_TABLE_HEADER *Table); @@ -644,6 +666,10 @@ void AcpiDmDumpTcpa ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpTpm2 ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpVrtc ( ACPI_TABLE_HEADER *Table); diff --git a/drivers/bus/acpi/acpica/include/acexcep.h b/drivers/bus/acpi/acpica/include/acexcep.h index 6bc741cb08d..0f0d38a86ca 100644 --- a/drivers/bus/acpi/acpica/include/acexcep.h +++ b/drivers/bus/acpi/acpica/include/acexcep.h @@ -129,8 +129,13 @@ typedef struct acpi_exception_info #define AE_NOT_CONFIGURED EXCEP_ENV (0x001C) #define AE_ACCESS EXCEP_ENV (0x001D) #define AE_IO_ERROR EXCEP_ENV (0x001E) +#define AE_NUMERIC_OVERFLOW EXCEP_ENV (0x001F) +#define AE_HEX_OVERFLOW EXCEP_ENV (0x0020) +#define AE_DECIMAL_OVERFLOW EXCEP_ENV (0x0021) +#define AE_OCTAL_OVERFLOW EXCEP_ENV (0x0022) +#define AE_END_OF_TABLE EXCEP_ENV (0x0023) -#define AE_CODE_ENV_MAX 0x001E +#define AE_CODE_ENV_MAX 0x0023 /* @@ -197,7 +202,7 @@ typedef struct acpi_exception_info #define AE_AML_CIRCULAR_REFERENCE EXCEP_AML (0x001E) #define AE_AML_BAD_RESOURCE_LENGTH EXCEP_AML (0x001F) #define AE_AML_ILLEGAL_ADDRESS EXCEP_AML (0x0020) -#define AE_AML_INFINITE_LOOP EXCEP_AML (0x0021) +#define AE_AML_LOOP_TIMEOUT EXCEP_AML (0x0021) #define AE_AML_UNINITIALIZED_NODE EXCEP_AML (0x0022) #define AE_AML_TARGET_TYPE EXCEP_AML (0x0023) @@ -263,7 +268,12 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Env[] = EXCEP_TXT ("AE_OWNER_ID_LIMIT", "There are no more Owner IDs available for ACPI tables or control methods"), EXCEP_TXT ("AE_NOT_CONFIGURED", "The interface is not part of the current subsystem configuration"), EXCEP_TXT ("AE_ACCESS", "Permission denied for the requested operation"), - EXCEP_TXT ("AE_IO_ERROR", "An I/O error occurred") + EXCEP_TXT ("AE_IO_ERROR", "An I/O error occurred"), + EXCEP_TXT ("AE_NUMERIC_OVERFLOW", "Overflow during string-to-integer conversion"), + EXCEP_TXT ("AE_HEX_OVERFLOW", "Overflow during ASCII hex-to-binary conversion"), + EXCEP_TXT ("AE_DECIMAL_OVERFLOW", "Overflow during ASCII decimal-to-binary conversion"), + EXCEP_TXT ("AE_OCTAL_OVERFLOW", "Overflow during ASCII octal-to-binary conversion"), + EXCEP_TXT ("AE_END_OF_TABLE", "Reached the end of table") }; static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Pgm[] = @@ -325,7 +335,7 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Aml[] = EXCEP_TXT ("AE_AML_CIRCULAR_REFERENCE", "Two references refer to each other"), EXCEP_TXT ("AE_AML_BAD_RESOURCE_LENGTH", "The length of a Resource Descriptor in the AML is incorrect"), EXCEP_TXT ("AE_AML_ILLEGAL_ADDRESS", "A memory, I/O, or PCI configuration address is invalid"), - EXCEP_TXT ("AE_AML_INFINITE_LOOP", "An apparent infinite AML While loop, method was aborted"), + EXCEP_TXT ("AE_AML_LOOP_TIMEOUT", "An AML While loop exceeded the maximum execution time"), EXCEP_TXT ("AE_AML_UNINITIALIZED_NODE", "A namespace node is uninitialized or unresolved"), EXCEP_TXT ("AE_AML_TARGET_TYPE", "A target operand of an incorrect type was encountered") }; diff --git a/drivers/bus/acpi/acpica/include/acglobal.h b/drivers/bus/acpi/acpica/include/acglobal.h index aa66f90fc22..704ad4dfea9 100644 --- a/drivers/bus/acpi/acpica/include/acglobal.h +++ b/drivers/bus/acpi/acpica/include/acglobal.h @@ -47,7 +47,7 @@ /***************************************************************************** * - * Globals related to the ACPI tables + * Globals related to the incoming ACPI tables * ****************************************************************************/ @@ -89,7 +89,7 @@ ACPI_GLOBAL (UINT8, AcpiGbl_IntegerNybbleWidth); /***************************************************************************** * - * Mutual exclusion within ACPICA subsystem + * Mutual exclusion within the ACPICA subsystem * ****************************************************************************/ @@ -170,7 +170,7 @@ ACPI_GLOBAL (UINT8, AcpiGbl_NextOwnerIdOffset); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_NamespaceInitialized, FALSE); -/* Misc */ +/* Miscellaneous */ ACPI_GLOBAL (UINT32, AcpiGbl_OriginalMode); ACPI_GLOBAL (UINT32, AcpiGbl_NsLookupCount); @@ -193,11 +193,9 @@ extern const char AcpiGbl_LowerHexDigits[]; extern const char AcpiGbl_UpperHexDigits[]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - /* Lists for tracking memory allocations (debug only) */ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS ACPI_GLOBAL (ACPI_MEMORY_LIST *, AcpiGbl_GlobalList); ACPI_GLOBAL (ACPI_MEMORY_LIST *, AcpiGbl_NsNodeList); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DisplayFinalMemStats); @@ -207,7 +205,7 @@ ACPI_GLOBAL (BOOLEAN, AcpiGbl_DisableMemTracking); /***************************************************************************** * - * Namespace globals + * ACPI Namespace * ****************************************************************************/ @@ -222,7 +220,6 @@ ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_RootNode); ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_FadtGpeDevice); ACPI_GLOBAL (ACPI_OPERAND_OBJECT *, AcpiGbl_ModuleCodeList); - extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; @@ -239,15 +236,20 @@ ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); /***************************************************************************** * - * Interpreter globals + * Interpreter/Parser globals * ****************************************************************************/ -ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); - /* Control method single step flag */ ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); +ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); +ACPI_INIT_GLOBAL (ACPI_PARSE_OBJECT, *AcpiGbl_CurrentScope, NULL); + +/* ASL/ASL+ converter */ + +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_CaptureComments, FALSE); +ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_LastListHead, NULL); /***************************************************************************** @@ -257,7 +259,6 @@ ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); ****************************************************************************/ extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; - ACPI_GLOBAL (UINT8, AcpiGbl_SleepTypeA); ACPI_GLOBAL (UINT8, AcpiGbl_SleepTypeB); @@ -269,18 +270,16 @@ ACPI_GLOBAL (UINT8, AcpiGbl_SleepTypeB); ****************************************************************************/ #if (!ACPI_REDUCED_HARDWARE) - ACPI_GLOBAL (UINT8, AcpiGbl_AllGpesInitialized); ACPI_GLOBAL (ACPI_GPE_XRUPT_INFO *, AcpiGbl_GpeXruptListHead); ACPI_GLOBAL (ACPI_GPE_BLOCK_INFO *, AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]); ACPI_GLOBAL (ACPI_GBL_EVENT_HANDLER, AcpiGbl_GlobalEventHandler); ACPI_GLOBAL (void *, AcpiGbl_GlobalEventHandlerContext); ACPI_GLOBAL (ACPI_FIXED_EVENT_HANDLER, AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]); - extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; - #endif /* !ACPI_REDUCED_HARDWARE */ + /***************************************************************************** * * Debug support @@ -294,7 +293,7 @@ ACPI_GLOBAL (UINT32, AcpiGpeCount); ACPI_GLOBAL (UINT32, AcpiSciCount); ACPI_GLOBAL (UINT32, AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]); -/* Support for dynamic control method tracing mechanism */ +/* Dynamic control method tracing mechanism */ ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLevel); ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLayer); @@ -302,12 +301,13 @@ ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLayer); /***************************************************************************** * - * Debugger and Disassembler globals + * Debugger and Disassembler * ****************************************************************************/ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DbOutputFlags, ACPI_DB_CONSOLE_OUTPUT); + #ifdef ACPI_DISASSEMBLER /* Do not disassemble buffers to resource descriptors */ @@ -319,7 +319,7 @@ 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_INIT_GLOBAL (ACPI_PARSE_OBJECT_LIST, *AcpiGbl_TempListHead, NULL); +ACPI_INIT_GLOBAL (ACPI_PARSE_OBJECT_LIST, *AcpiGbl_TempListHead, NULL); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Disasm); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Listing); @@ -330,7 +330,6 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #endif #ifdef ACPI_DEBUGGER - ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); @@ -344,7 +343,6 @@ ACPI_GLOBAL (UINT32, AcpiGbl_DbConsoleDebugLevel); ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_DbScopeNode); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbTerminateLoop); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbThreadsTerminated); - ACPI_GLOBAL (char *, AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]); ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARGS]); @@ -354,81 +352,66 @@ ACPI_GLOBAL (char, AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_ ACPI_GLOBAL (char, AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]); -/* - * Statistic globals - */ +/* Statistics globals */ + ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TOTAL_TYPES]); ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TOTAL_TYPES]); ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCountMisc); ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc); ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes); ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); - #endif /* ACPI_DEBUGGER */ #if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) - -ACPI_GLOBAL (const char, *AcpiGbl_PldPanelList[]); -ACPI_GLOBAL (const char, *AcpiGbl_PldVerticalPositionList[]); -ACPI_GLOBAL (const char, *AcpiGbl_PldHorizontalPositionList[]); -ACPI_GLOBAL (const char, *AcpiGbl_PldShapeList[]); - +ACPI_GLOBAL (const char, *AcpiGbl_PldPanelList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldVerticalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldHorizontalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldShapeList[]); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DisasmFlag, FALSE); - #endif -/* - * Meant for the -ca option. - */ -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentInlineComment, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentEndNodeComment, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentOpenBraceComment, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentCloseBraceComment, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_RootFilename, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentFilename, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentParentFilename, NULL); -ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentIncludeFilename, NULL); +/***************************************************************************** + * + * ACPICA application-specific globals + * + ****************************************************************************/ -ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_LastListHead, NULL); +/* ASL-to-ASL+ conversion utility (implemented within the iASL compiler) */ + +#ifdef ACPI_ASL_COMPILER +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentInlineComment, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentEndNodeComment, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentOpenBraceComment, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentCloseBraceComment, NULL); + +ACPI_INIT_GLOBAL (char *, AcpiGbl_RootFilename, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentFilename, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentParentFilename, NULL); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CurrentIncludeFilename, NULL); ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_DefBlkCommentListHead, NULL); ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_DefBlkCommentListTail, NULL); - ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_RegCommentListHead, NULL); ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_RegCommentListTail, NULL); - ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_IncCommentListHead, NULL); ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_IncCommentListTail, NULL); - ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_EndBlkCommentListHead, NULL); ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_EndBlkCommentListTail, NULL); -ACPI_INIT_GLOBAL (ACPI_COMMENT_ADDR_NODE, *AcpiGbl_CommentAddrListHead, NULL); - -ACPI_INIT_GLOBAL (ACPI_PARSE_OBJECT, *AcpiGbl_CurrentScope, NULL); - +ACPI_INIT_GLOBAL (ACPI_COMMENT_ADDR_NODE, *AcpiGbl_CommentAddrListHead, NULL); ACPI_INIT_GLOBAL (ACPI_FILE_NODE, *AcpiGbl_FileTreeRoot, NULL); ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_RegCommentCache); ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_CommentAddrCache); ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_FileCache); -ACPI_INIT_GLOBAL (BOOLEAN, Gbl_CaptureComments, FALSE); - -ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugAslConversion, FALSE); -ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_ConvDebugFile, NULL); - -ACPI_GLOBAL (char, AcpiGbl_TableSig[4]); - -/***************************************************************************** - * - * Application globals - * - ****************************************************************************/ +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugAslConversion, FALSE); +ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_ConvDebugFile, NULL); +ACPI_GLOBAL (char, AcpiGbl_TableSig[4]); +#endif #ifdef ACPI_APPLICATION - ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_DebugFile, NULL); ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_OutputFile, NULL); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugTimeout, FALSE); @@ -437,18 +420,6 @@ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugTimeout, FALSE); ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_PrintLock); /* For print buffer */ ACPI_GLOBAL (char, AcpiGbl_PrintBuffer[1024]); - #endif /* ACPI_APPLICATION */ - -/***************************************************************************** - * - * Info/help support - * - ****************************************************************************/ - -extern const AH_PREDEFINED_NAME AslPredefinedInfo[]; -extern const AH_DEVICE_ID AslDeviceIds[]; - - #endif /* __ACGLOBAL_H__ */ diff --git a/drivers/bus/acpi/acpica/include/achware.h b/drivers/bus/acpi/acpica/include/achware.h index a97ec5707e9..4c940efb341 100644 --- a/drivers/bus/acpi/acpica/include/achware.h +++ b/drivers/bus/acpi/acpica/include/achware.h @@ -77,12 +77,12 @@ AcpiHwValidateRegister ( ACPI_STATUS AcpiHwRead ( - UINT32 *Value, + UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg); ACPI_STATUS AcpiHwWrite ( - UINT32 Value, + UINT64 Value, ACPI_GENERIC_ADDRESS *Reg); ACPI_BIT_REGISTER_INFO * diff --git a/drivers/bus/acpi/acpica/include/acinterp.h b/drivers/bus/acpi/acpica/include/acinterp.h index 78eaa1afa20..06f9f31407d 100644 --- a/drivers/bus/acpi/acpica/include/acinterp.h +++ b/drivers/bus/acpi/acpica/include/acinterp.h @@ -106,7 +106,7 @@ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Flags); + UINT32 ImplicitConversion); ACPI_STATUS AcpiExConvertToBuffer ( @@ -575,9 +575,6 @@ AcpiExStoreObjectToNode ( ACPI_WALK_STATE *WalkState, UINT8 ImplicitConversion); -#define ACPI_IMPLICIT_CONVERSION TRUE -#define ACPI_NO_IMPLICIT_CONVERSION FALSE - /* * exstoren - resolve/store object diff --git a/drivers/bus/acpi/acpica/include/aclocal.h b/drivers/bus/acpi/acpica/include/aclocal.h index b2906a7a8c1..377eac18d7b 100644 --- a/drivers/bus/acpi/acpica/include/aclocal.h +++ b/drivers/bus/acpi/acpica/include/aclocal.h @@ -726,7 +726,7 @@ typedef struct acpi_control_state union acpi_parse_object *PredicateOp; UINT8 *AmlPredicateStart; /* Start of if/while predicate */ UINT8 *PackageEnd; /* End of if/while block */ - UINT32 LoopCount; /* While() loop counter */ + UINT64 LoopTimeout; /* While() loop timeout */ } ACPI_CONTROL_STATE; @@ -1424,16 +1424,17 @@ typedef struct acpi_db_method_info ACPI_OBJECT_TYPE *Types; /* - * Arguments to be passed to method for the command - * Threads - - * the Number of threads, ID of current thread and - * Index of current thread inside all them created. + * Arguments to be passed to method for the commands Threads and + * Background. Note, ACPI specifies a maximum of 7 arguments (0 - 6). + * + * For the Threads command, the Number of threads, ID of current + * thread and Index of current thread inside all them created. */ char InitArgs; #ifdef ACPI_DEBUGGER - ACPI_OBJECT_TYPE ArgTypes[4]; + ACPI_OBJECT_TYPE ArgTypes[ACPI_METHOD_NUM_ARGS]; #endif - char *Arguments[4]; + char *Arguments[ACPI_METHOD_NUM_ARGS]; char NumThreadsStr[11]; char IdOfThreadStr[11]; char IndexOfThreadStr[11]; diff --git a/drivers/bus/acpi/acpica/include/acmacros.h b/drivers/bus/acpi/acpica/include/acmacros.h index f9d9dacf023..f5a4d01939f 100644 --- a/drivers/bus/acpi/acpica/include/acmacros.h +++ b/drivers/bus/acpi/acpica/include/acmacros.h @@ -459,7 +459,7 @@ * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ -#define ACPI_ERROR_NAMESPACE(s, e) AcpiUtNamespaceError (AE_INFO, s, e); +#define ACPI_ERROR_NAMESPACE(s, p, e) AcpiUtPrefixedNamespaceError (AE_INFO, s, p, e); #define ACPI_ERROR_METHOD(s, n, p, e) AcpiUtMethodError (AE_INFO, s, n, p, e); #define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist #define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist diff --git a/drivers/bus/acpi/acpica/include/acnamesp.h b/drivers/bus/acpi/acpica/include/acnamesp.h index 651b0d021e3..460accd4eb2 100644 --- a/drivers/bus/acpi/acpica/include/acnamesp.h +++ b/drivers/bus/acpi/acpica/include/acnamesp.h @@ -380,6 +380,11 @@ AcpiNsGetNormalizedPathname ( ACPI_NAMESPACE_NODE *Node, BOOLEAN NoTrailing); +char * +AcpiNsBuildPrefixedPathname ( + ACPI_GENERIC_STATE *PrefixScope, + const char *InternalPath); + char * AcpiNsNameOfCurrentScope ( ACPI_WALK_STATE *WalkState); diff --git a/drivers/bus/acpi/acpica/include/acpixf.h b/drivers/bus/acpi/acpica/include/acpixf.h index e063533d118..06e252c71ce 100644 --- a/drivers/bus/acpi/acpica/include/acpixf.h +++ b/drivers/bus/acpi/acpica/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20170728 +#define ACPI_CA_VERSION 0x20171215 #include "acconfig.h" #include "actypes.h" @@ -262,11 +262,11 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_OsiData, 0); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ReducedHardware, FALSE); /* - * Maximum number of While() loop iterations before forced method abort. + * Maximum timeout for 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); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_MaxLoopIterations, ACPI_MAX_LOOP_TIMEOUT); /* * This mechanism is used to trace a specified AML method. The method is diff --git a/drivers/bus/acpi/acpica/include/actbl1.h b/drivers/bus/acpi/acpica/include/actbl1.h index bd601671f1a..a9b41706739 100644 --- a/drivers/bus/acpi/acpica/include/actbl1.h +++ b/drivers/bus/acpi/acpica/include/actbl1.h @@ -71,8 +71,10 @@ #define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ #define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ #define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ +#define ACPI_SIG_PDTT "PDTT" /* Platform Debug Trigger Table */ #define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Table */ #define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ +#define ACPI_SIG_SDEV "SDEV" /* Secure Devices table */ #define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ #define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ #define ACPI_SIG_NFIT "NFIT" /* NVDIMM Firmware Interface Table */ @@ -1339,7 +1341,8 @@ enum AcpiNfitType ACPI_NFIT_TYPE_CONTROL_REGION = 4, ACPI_NFIT_TYPE_DATA_REGION = 5, ACPI_NFIT_TYPE_FLUSH_ADDRESS = 6, - ACPI_NFIT_TYPE_RESERVED = 7 /* 7 and greater are reserved */ + ACPI_NFIT_TYPE_CAPABILITIES = 7, + ACPI_NFIT_TYPE_RESERVED = 8 /* 8 and greater are reserved */ }; /* @@ -1353,7 +1356,7 @@ typedef struct acpi_nfit_system_address ACPI_NFIT_HEADER Header; UINT16 RangeIndex; UINT16 Flags; - UINT32 Reserved; /* Reseved, must be zero */ + UINT32 Reserved; /* Reserved, must be zero */ UINT32 ProximityDomain; UINT8 RangeGuid[16]; UINT64 Address; @@ -1492,6 +1495,110 @@ typedef struct acpi_nfit_flush_address } ACPI_NFIT_FLUSH_ADDRESS; +/* 7: Platform Capabilities Structure */ + +typedef struct acpi_nfit_capabilities +{ + ACPI_NFIT_HEADER Header; + UINT8 HighestCapability; + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 Capabilities; + UINT32 Reserved2; + +} ACPI_NFIT_CAPABILITIES; + +/* Capabilities Flags */ + +#define ACPI_NFIT_CAPABILITY_CACHE_FLUSH (1) /* 00: Cache Flush to NVDIMM capable */ +#define ACPI_NFIT_CAPABILITY_MEM_FLUSH (1<<1) /* 01: Memory Flush to NVDIMM capable */ +#define ACPI_NFIT_CAPABILITY_MEM_MIRRORING (1<<2) /* 02: Memory Mirroring capable */ + + +/* + * NFIT/DVDIMM device handle support - used as the _ADR for each NVDIMM + */ +typedef struct nfit_device_handle +{ + UINT32 Handle; + +} NFIT_DEVICE_HANDLE; + +/* Device handle construction and extraction macros */ + +#define ACPI_NFIT_DIMM_NUMBER_MASK 0x0000000F +#define ACPI_NFIT_CHANNEL_NUMBER_MASK 0x000000F0 +#define ACPI_NFIT_MEMORY_ID_MASK 0x00000F00 +#define ACPI_NFIT_SOCKET_ID_MASK 0x0000F000 +#define ACPI_NFIT_NODE_ID_MASK 0x0FFF0000 + +#define ACPI_NFIT_DIMM_NUMBER_OFFSET 0 +#define ACPI_NFIT_CHANNEL_NUMBER_OFFSET 4 +#define ACPI_NFIT_MEMORY_ID_OFFSET 8 +#define ACPI_NFIT_SOCKET_ID_OFFSET 12 +#define ACPI_NFIT_NODE_ID_OFFSET 16 + +/* Macro to construct a NFIT/NVDIMM device handle */ + +#define ACPI_NFIT_BUILD_DEVICE_HANDLE(dimm, channel, memory, socket, node) \ + ((dimm) | \ + ((channel) << ACPI_NFIT_CHANNEL_NUMBER_OFFSET) | \ + ((memory) << ACPI_NFIT_MEMORY_ID_OFFSET) | \ + ((socket) << ACPI_NFIT_SOCKET_ID_OFFSET) | \ + ((node) << ACPI_NFIT_NODE_ID_OFFSET)) + +/* Macros to extract individual fields from a NFIT/NVDIMM device handle */ + +#define ACPI_NFIT_GET_DIMM_NUMBER(handle) \ + ((handle) & ACPI_NFIT_DIMM_NUMBER_MASK) + +#define ACPI_NFIT_GET_CHANNEL_NUMBER(handle) \ + (((handle) & ACPI_NFIT_CHANNEL_NUMBER_MASK) >> ACPI_NFIT_CHANNEL_NUMBER_OFFSET) + +#define ACPI_NFIT_GET_MEMORY_ID(handle) \ + (((handle) & ACPI_NFIT_MEMORY_ID_MASK) >> ACPI_NFIT_MEMORY_ID_OFFSET) + +#define ACPI_NFIT_GET_SOCKET_ID(handle) \ + (((handle) & ACPI_NFIT_SOCKET_ID_MASK) >> ACPI_NFIT_SOCKET_ID_OFFSET) + +#define ACPI_NFIT_GET_NODE_ID(handle) \ + (((handle) & ACPI_NFIT_NODE_ID_MASK) >> ACPI_NFIT_NODE_ID_OFFSET) + + +/******************************************************************************* + * + * PDTT - Platform Debug Trigger Table (ACPI 6.2) + * Version 0 + * + ******************************************************************************/ + +typedef struct acpi_table_pdtt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 TriggerCount; + UINT8 Reserved[3]; + UINT32 ArrayOffset; + +} ACPI_TABLE_PDTT; + + +/* + * PDTT Communication Channel Identifier Structure. + * The number of these structures is defined by TriggerCount above, + * starting at ArrayOffset. + */ +typedef struct acpi_pdtt_channel +{ + UINT8 SubchannelId; + UINT8 Flags; + +} ACPI_PDTT_CHANNEL; + +/* Flags for above */ + +#define ACPI_PDTT_RUNTIME_TRIGGER (1) +#define ACPI_PDTT_WAIT_COMPLETION (1<<1) + + /******************************************************************************* * * PPTT - Processor Properties Topology Table (ACPI 6.2) @@ -1518,7 +1625,8 @@ enum AcpiPpttType /* 0: Processor Hierarchy Node Structure */ -typedef struct acpi_pptt_processor { +typedef struct acpi_pptt_processor +{ ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; UINT32 Flags; @@ -1536,7 +1644,8 @@ typedef struct acpi_pptt_processor { /* 1: Cache Type Structure */ -typedef struct acpi_pptt_cache { +typedef struct acpi_pptt_cache +{ ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; UINT32 Flags; @@ -1565,10 +1674,24 @@ typedef struct acpi_pptt_cache { #define ACPI_PPTT_MASK_CACHE_TYPE (0x0C) /* Cache type */ #define ACPI_PPTT_MASK_WRITE_POLICY (0x10) /* Write policy */ +/* Attributes describing cache */ +#define ACPI_PPTT_CACHE_READ_ALLOCATE (0x0) /* Cache line is allocated on read */ +#define ACPI_PPTT_CACHE_WRITE_ALLOCATE (0x01) /* Cache line is allocated on write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE (0x02) /* Cache line is allocated on read and write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE_ALT (0x03) /* Alternate representation of above */ + +#define ACPI_PPTT_CACHE_TYPE_DATA (0x0) /* Data cache */ +#define ACPI_PPTT_CACHE_TYPE_INSTR (1<<2) /* Instruction cache */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED (2<<2) /* Unified I & D cache */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED_ALT (3<<2) /* Alternate representation of above */ + +#define ACPI_PPTT_CACHE_POLICY_WB (0x0) /* Cache is write back */ +#define ACPI_PPTT_CACHE_POLICY_WT (1<<4) /* Cache is write through */ /* 2: ID Structure */ -typedef struct acpi_pptt_id { +typedef struct acpi_pptt_id +{ ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; UINT32 VendorId; @@ -1598,6 +1721,82 @@ typedef struct acpi_table_sbst } ACPI_TABLE_SBST; +/******************************************************************************* + * + * SDEV - Secure Devices Table (ACPI 6.2) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_sdev +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_SDEV; + + +typedef struct acpi_sdev_header +{ + UINT8 Type; + UINT8 Flags; + UINT16 Length; + +} ACPI_SDEV_HEADER; + + +/* Values for subtable type above */ + +enum AcpiSdevType +{ + ACPI_SDEV_TYPE_NAMESPACE_DEVICE = 0, + ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE = 1, + ACPI_SDEV_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + +/* Values for flags above */ + +#define ACPI_SDEV_HANDOFF_TO_UNSECURE_OS (1) + +/* + * SDEV subtables + */ + +/* 0: Namespace Device Based Secure Device Structure */ + +typedef struct acpi_sdev_namespace +{ + ACPI_SDEV_HEADER Header; + UINT16 DeviceIdOffset; + UINT16 DeviceIdLength; + UINT16 VendorDataOffset; + UINT16 VendorDataLength; + +} ACPI_SDEV_NAMESPACE; + +/* 1: PCIe Endpoint Device Based Device Structure */ + +typedef struct acpi_sdev_pcie +{ + ACPI_SDEV_HEADER Header; + UINT16 Segment; + UINT16 StartBus; + UINT16 PathOffset; + UINT16 PathLength; + UINT16 VendorDataOffset; + UINT16 VendorDataLength; + +} ACPI_SDEV_PCIE; + +/* 1a: PCIe Endpoint path entry */ + +typedef struct acpi_sdev_pcie_path +{ + UINT8 Device; + UINT8 Function; + +} ACPI_SDEV_PCIE_PATH; + + /******************************************************************************* * * SLIT - System Locality Distance Information Table diff --git a/drivers/bus/acpi/acpica/include/actbl2.h b/drivers/bus/acpi/acpica/include/actbl2.h index a618a1f443f..09b89699df3 100644 --- a/drivers/bus/acpi/acpica/include/actbl2.h +++ b/drivers/bus/acpi/acpica/include/actbl2.h @@ -922,6 +922,7 @@ typedef struct acpi_iort_smmu_gsi UINT32 NSgIrptFlags; UINT32 NSgCfgIrpt; UINT32 NSgCfgIrptFlags; + } ACPI_IORT_SMMU_GSI; @@ -939,6 +940,7 @@ typedef struct acpi_iort_smmu_v3 UINT8 Pxm; UINT8 Reserved1; UINT16 Reserved2; + UINT32 IdMappingIndex; } ACPI_IORT_SMMU_V3; @@ -1441,6 +1443,8 @@ enum AcpiSpmiInterfaceTypes * TCPA - Trusted Computing Platform Alliance table * Version 2 * + * TCG Hardware Interface Table for TPM 1.2 Clients and Servers + * * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0", * Version 1.2, Revision 8 * February 27, 2017 @@ -1513,6 +1517,8 @@ typedef struct acpi_table_tcpa_server * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table * Version 4 * + * TCG Hardware Interface Table for TPM 2.0 Clients and Servers + * * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0", * Version 1.2, Revision 8 * February 27, 2017 @@ -1534,17 +1540,25 @@ typedef struct acpi_table_tpm2 /* Values for StartMethod above */ #define ACPI_TPM2_NOT_ALLOWED 0 +#define ACPI_TPM2_RESERVED1 1 #define ACPI_TPM2_START_METHOD 2 +#define ACPI_TPM2_RESERVED3 3 +#define ACPI_TPM2_RESERVED4 4 +#define ACPI_TPM2_RESERVED5 5 #define ACPI_TPM2_MEMORY_MAPPED 6 #define ACPI_TPM2_COMMAND_BUFFER 7 #define ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD 8 +#define ACPI_TPM2_RESERVED9 9 +#define ACPI_TPM2_RESERVED10 10 #define ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC 11 /* V1.2 Rev 8 */ +#define ACPI_TPM2_RESERVED 12 -/* Trailer appears after any StartMethod subtables */ +/* Optional trailer appears after any StartMethod subtables */ typedef struct acpi_tpm2_trailer { + UINT8 MethodParameters[12]; UINT32 MinimumLogLength; /* Minimum length for the event log area */ UINT64 LogAddress; /* Address of the event log area */ diff --git a/drivers/bus/acpi/acpica/include/actypes.h b/drivers/bus/acpi/acpica/include/actypes.h index 4177ccb4f56..e5afda600ae 100644 --- a/drivers/bus/acpi/acpica/include/actypes.h +++ b/drivers/bus/acpi/acpica/include/actypes.h @@ -478,6 +478,8 @@ typedef void * ACPI_HANDLE; /* Actually a ptr to a N #define ACPI_NSEC_PER_MSEC 1000000L #define ACPI_NSEC_PER_SEC 1000000000L +#define ACPI_TIME_AFTER(a, b) ((INT64)((b) - (a)) < 0) + /* Owner IDs are used to track namespace nodes for selective deletion */ @@ -1399,6 +1401,8 @@ typedef enum #define ACPI_OSI_WIN_7 0x0B #define ACPI_OSI_WIN_8 0x0C #define ACPI_OSI_WIN_10 0x0D +#define ACPI_OSI_WIN_10_RS1 0x0E +#define ACPI_OSI_WIN_10_RS2 0x0F /* Definitions of getopt */ diff --git a/drivers/bus/acpi/acpica/include/acutils.h b/drivers/bus/acpi/acpica/include/acutils.h index 1450b8591c1..6340fcc30da 100644 --- a/drivers/bus/acpi/acpica/include/acutils.h +++ b/drivers/bus/acpi/acpica/include/acutils.h @@ -119,9 +119,6 @@ extern const char *AcpiGbl_PtypDecode[]; #ifndef ACPI_MSG_ERROR #define ACPI_MSG_ERROR "ACPI Error: " #endif -#ifndef ACPI_MSG_EXCEPTION -#define ACPI_MSG_EXCEPTION "ACPI Exception: " -#endif #ifndef ACPI_MSG_WARNING #define ACPI_MSG_WARNING "ACPI Warning: " #endif @@ -130,10 +127,10 @@ extern const char *AcpiGbl_PtypDecode[]; #endif #ifndef ACPI_MSG_BIOS_ERROR -#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): " +#define ACPI_MSG_BIOS_ERROR "Firmware Error (ACPI): " #endif #ifndef ACPI_MSG_BIOS_WARNING -#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): " +#define ACPI_MSG_BIOS_WARNING "Firmware Warning (ACPI): " #endif /* @@ -142,6 +139,10 @@ extern const char *AcpiGbl_PtypDecode[]; #define ACPI_MSG_SUFFIX \ AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) +/* Flags to indicate implicit or explicit string-to-integer conversion */ + +#define ACPI_IMPLICIT_CONVERSION TRUE +#define ACPI_NO_IMPLICIT_CONVERSION FALSE /* Types for Resource descriptor entries */ @@ -222,19 +223,57 @@ AcpiUtStricmp ( char *String1, char *String2); + +/* + * utstrsuppt - string-to-integer conversion support functions + */ +ACPI_STATUS +AcpiUtConvertOctalString ( + char *String, + UINT64 *ReturnValue); + +ACPI_STATUS +AcpiUtConvertDecimalString ( + char *String, + UINT64 *ReturnValuePtr); + +ACPI_STATUS +AcpiUtConvertHexString ( + char *String, + UINT64 *ReturnValuePtr); + +char +AcpiUtRemoveWhitespace ( + char **String); + +char +AcpiUtRemoveLeadingZeros ( + char **String); + +BOOLEAN +AcpiUtDetectHexPrefix ( + char **String); + +BOOLEAN +AcpiUtDetectOctalPrefix ( + char **String); + + +/* + * utstrtoul64 - string-to-integer conversion functions + */ ACPI_STATUS AcpiUtStrtoul64 ( char *String, - UINT32 Flags, UINT64 *RetInteger); -/* - * Values for Flags above - * Note: LIMIT values correspond to AcpiGbl_IntegerByteWidth values (4/8) - */ -#define ACPI_STRTOUL_32BIT 0x04 /* 4 bytes */ -#define ACPI_STRTOUL_64BIT 0x08 /* 8 bytes */ -#define ACPI_STRTOUL_BASE16 0x10 /* Default: Base10/16 */ +UINT64 +AcpiUtExplicitStrtoul64 ( + char *String); + +UINT64 +AcpiUtImplicitStrtoul64 ( + char *String); /* @@ -244,12 +283,12 @@ ACPI_STATUS AcpiUtInitGlobals ( void); -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - const char * AcpiUtGetMutexName ( UINT32 MutexId); +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + const char * AcpiUtGetNotifyName ( UINT32 NotifyValue, @@ -912,6 +951,12 @@ AcpiUtSafeStrcpy ( ACPI_SIZE DestSize, char *Source); +void +AcpiUtSafeStrncpy ( + char *Dest, + char *Source, + ACPI_SIZE DestSize); + BOOLEAN AcpiUtSafeStrcat ( char *Dest, @@ -1065,9 +1110,10 @@ AcpiUtPredefinedBiosError ( ...); void -AcpiUtNamespaceError ( +AcpiUtPrefixedNamespaceError ( const char *ModuleName, UINT32 LineNumber, + ACPI_GENERIC_STATE *PrefixScope, const char *InternalName, ACPI_STATUS LookupStatus); diff --git a/drivers/bus/acpi/acpica/namespace/nsaccess.c b/drivers/bus/acpi/acpica/namespace/nsaccess.c index 4c6307c1e9b..94c944da09c 100644 --- a/drivers/bus/acpi/acpica/namespace/nsaccess.c +++ b/drivers/bus/acpi/acpica/namespace/nsaccess.c @@ -667,19 +667,19 @@ AcpiNsLookup ( ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; } } -#ifdef ACPI_ASL_COMPILER - if (!AcpiGbl_DisasmFlag && - (ThisNode->Flags & ANOBJ_IS_EXTERNAL)) - { - ThisNode->Flags |= IMPLICIT_EXTERNAL; - } -#endif } /* Special handling for the last segment (NumSegments == 0) */ else { +#ifdef ACPI_ASL_COMPILER + if (!AcpiGbl_DisasmFlag && (ThisNode->Flags & ANOBJ_IS_EXTERNAL)) + { + ThisNode->Flags &= ~IMPLICIT_EXTERNAL; + } +#endif + /* * Sanity typecheck of the target object: * diff --git a/drivers/bus/acpi/acpica/namespace/nsconvert.c b/drivers/bus/acpi/acpica/namespace/nsconvert.c index 17125efa89e..b4771fc2c65 100644 --- a/drivers/bus/acpi/acpica/namespace/nsconvert.c +++ b/drivers/bus/acpi/acpica/namespace/nsconvert.c @@ -83,8 +83,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ - Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - AcpiGbl_IntegerByteWidth, &Value); + Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, &Value); if (ACPI_FAILURE (Status)) { return (Status); @@ -537,7 +536,8 @@ AcpiNsConvertToReference ( { /* Check if we are resolving a named reference within a package */ - ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status); + ACPI_ERROR_NAMESPACE (&ScopeInfo, + OriginalObject->String.Pointer, Status); goto ErrorExit; } diff --git a/drivers/bus/acpi/acpica/namespace/nsnames.c b/drivers/bus/acpi/acpica/namespace/nsnames.c index 0df136abcad..160edf83d72 100644 --- a/drivers/bus/acpi/acpica/namespace/nsnames.c +++ b/drivers/bus/acpi/acpica/namespace/nsnames.c @@ -50,6 +50,12 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsnames") +/* Local Prototypes */ + +static void +AcpiNsNormalizePathname ( + char *OriginalPath); + /******************************************************************************* * @@ -399,3 +405,169 @@ AcpiNsGetNormalizedPathname ( return_PTR (NameBuffer); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildPrefixedPathname + * + * PARAMETERS: PrefixScope - Scope/Path that prefixes the internal path + * InternalPath - Name or path of the namespace node + * + * RETURN: None + * + * DESCRIPTION: Construct a fully qualified pathname from a concatenation of: + * 1) Path associated with the PrefixScope namespace node + * 2) External path representation of the Internal path + * + ******************************************************************************/ + +char * +AcpiNsBuildPrefixedPathname ( + ACPI_GENERIC_STATE *PrefixScope, + const char *InternalPath) +{ + ACPI_STATUS Status; + char *FullPath = NULL; + char *ExternalPath = NULL; + char *PrefixPath = NULL; + UINT32 PrefixPathLength = 0; + + + /* If there is a prefix, get the pathname to it */ + + if (PrefixScope && PrefixScope->Scope.Node) + { + PrefixPath = AcpiNsGetNormalizedPathname (PrefixScope->Scope.Node, TRUE); + if (PrefixPath) + { + PrefixPathLength = strlen (PrefixPath); + } + } + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Merge the prefix path and the path. 2 is for one dot and trailing null */ + + FullPath = ACPI_ALLOCATE_ZEROED ( + PrefixPathLength + strlen (ExternalPath) + 2); + if (!FullPath) + { + goto Cleanup; + } + + /* Don't merge if the External path is already fully qualified */ + + if (PrefixPath && + (*ExternalPath != '\\') && + (*ExternalPath != '^')) + { + strcat (FullPath, PrefixPath); + if (PrefixPath[1]) + { + strcat (FullPath, "."); + } + } + + AcpiNsNormalizePathname (ExternalPath); + strcat (FullPath, ExternalPath); + +Cleanup: + if (PrefixPath) + { + ACPI_FREE (PrefixPath); + } + if (ExternalPath) + { + ACPI_FREE (ExternalPath); + } + + return (FullPath); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsNormalizePathname + * + * PARAMETERS: OriginalPath - Path to be normalized, in External format + * + * RETURN: The original path is processed in-place + * + * DESCRIPTION: Remove trailing underscores from each element of a path. + * + * For example: \A___.B___.C___ becomes \A.B.C + * + ******************************************************************************/ + +static void +AcpiNsNormalizePathname ( + char *OriginalPath) +{ + char *InputPath = OriginalPath; + char *NewPathBuffer; + char *NewPath; + UINT32 i; + + + /* Allocate a temp buffer in which to construct the new path */ + + NewPathBuffer = ACPI_ALLOCATE_ZEROED (strlen (InputPath) + 1); + NewPath = NewPathBuffer; + if (!NewPathBuffer) + { + return; + } + + /* Special characters may appear at the beginning of the path */ + + if (*InputPath == '\\') + { + *NewPath = *InputPath; + NewPath++; + InputPath++; + } + + while (*InputPath == '^') + { + *NewPath = *InputPath; + NewPath++; + InputPath++; + } + + /* Remainder of the path */ + + while (*InputPath) + { + /* Do one nameseg at a time */ + + for (i = 0; (i < ACPI_NAME_SIZE) && *InputPath; i++) + { + if ((i == 0) || (*InputPath != '_')) /* First char is allowed to be underscore */ + { + *NewPath = *InputPath; + NewPath++; + } + + InputPath++; + } + + /* Dot means that there are more namesegs to come */ + + if (*InputPath == '.') + { + *NewPath = *InputPath; + NewPath++; + InputPath++; + } + } + + *NewPath = 0; + strcpy (OriginalPath, NewPathBuffer); + ACPI_FREE (NewPathBuffer); +} diff --git a/drivers/bus/acpi/acpica/namespace/nssearch.c b/drivers/bus/acpi/acpica/namespace/nssearch.c index 30f7ce2b31e..fce62ec3882 100644 --- a/drivers/bus/acpi/acpica/namespace/nssearch.c +++ b/drivers/bus/acpi/acpica/namespace/nssearch.c @@ -437,6 +437,7 @@ AcpiNsSearchAndEnter ( (WalkState && WalkState->Opcode == AML_SCOPE_OP)) { NewNode->Flags |= ANOBJ_IS_EXTERNAL; + NewNode->Flags |= IMPLICIT_EXTERNAL; } #endif diff --git a/drivers/bus/acpi/acpica/namespace/nsxfeval.c b/drivers/bus/acpi/acpica/namespace/nsxfeval.c index 1186fa9d64d..d0bea020050 100644 --- a/drivers/bus/acpi/acpica/namespace/nsxfeval.c +++ b/drivers/bus/acpi/acpica/namespace/nsxfeval.c @@ -66,11 +66,11 @@ AcpiNsResolveReferences ( * * PARAMETERS: Handle - Object handle (optional) * Pathname - Object pathname (optional) - * ExternalParams - List of parameters to pass to method, + * ExternalParams - List of parameters to pass to a method, * terminated by NULL. May be NULL * if no parameters are being passed. - * ReturnBuffer - Where to put method's return value (if - * any). If NULL, no value is returned. + * ReturnBuffer - Where to put the object return value (if + * any). Required. * ReturnType - Expected type of return object * * RETURN: Status @@ -110,10 +110,16 @@ AcpiEvaluateObjectTyped ( FreeBufferOnError = TRUE; } - Status = AcpiGetHandle (Handle, Pathname, &TargetHandle); - if (ACPI_FAILURE (Status)) + /* Get a handle here, in order to build an error message if needed */ + + TargetHandle = Handle; + if (Pathname) { - return_ACPI_STATUS (Status); + Status = AcpiGetHandle (Handle, Pathname, &TargetHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } FullPathname = AcpiNsGetExternalPathname (TargetHandle); diff --git a/drivers/bus/acpi/acpica/parser/psargs.c b/drivers/bus/acpi/acpica/parser/psargs.c index 4fc55b2e186..9f795506565 100644 --- a/drivers/bus/acpi/acpica/parser/psargs.c +++ b/drivers/bus/acpi/acpica/parser/psargs.c @@ -392,7 +392,7 @@ AcpiPsGetNextNamepath ( if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Path, Status); + ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status); if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) diff --git a/drivers/bus/acpi/acpica/parser/psobject.c b/drivers/bus/acpi/acpica/parser/psobject.c index c4e34639e33..67138db3e0d 100644 --- a/drivers/bus/acpi/acpica/parser/psobject.c +++ b/drivers/bus/acpi/acpica/parser/psobject.c @@ -392,15 +392,10 @@ AcpiPsCreateOp ( * external declaration opcode. Setting WalkState->Aml to * WalkState->ParserState.Aml + 2 moves increments the * WalkState->Aml past the object type and the paramcount of the - * external opcode. For the error message, only print the AML - * offset. We could attempt to print the name but this may cause - * a segmentation fault when printing the namepath because the - * AML may be incorrect. + * external opcode. */ - AcpiOsPrintf ( - "// Invalid external declaration at AML offset 0x%x.\n", - WalkState->Aml - WalkState->ParserState.AmlStart); WalkState->Aml = WalkState->ParserState.Aml + 2; + WalkState->ParserState.Aml = WalkState->Aml; return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); } #endif diff --git a/drivers/bus/acpi/acpica/parser/psutils.c b/drivers/bus/acpi/acpica/parser/psutils.c index 05699489adc..c51d20ed63e 100644 --- a/drivers/bus/acpi/acpica/parser/psutils.c +++ b/drivers/bus/acpi/acpica/parser/psutils.c @@ -105,7 +105,7 @@ AcpiPsInitOp ( Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; Op->Common.AmlOpcode = Opcode; - ACPI_DISASM_ONLY_MEMBERS (strncpy (Op->Common.AmlOpName, + ACPI_DISASM_ONLY_MEMBERS (AcpiUtSafeStrncpy (Op->Common.AmlOpName, (AcpiPsGetOpcodeInfo (Opcode))->Name, sizeof (Op->Common.AmlOpName))); } @@ -184,11 +184,11 @@ AcpiPsAllocOp ( { AcpiGbl_CurrentScope = Op; } - } - if (Gbl_CaptureComments) - { - ASL_CV_TRANSFER_COMMENTS (Op); + if (AcpiGbl_CaptureComments) + { + ASL_CV_TRANSFER_COMMENTS (Op); + } } return (Op); diff --git a/drivers/bus/acpi/acpica/tables/tbxface.c b/drivers/bus/acpi/acpica/tables/tbxface.c index a34e445b62f..388802df5e6 100644 --- a/drivers/bus/acpi/acpica/tables/tbxface.c +++ b/drivers/bus/acpi/acpica/tables/tbxface.c @@ -192,10 +192,13 @@ AcpiReallocateRootTable ( /* - * Only reallocate the root table if the host provided a static buffer - * for the table array in the call to AcpiInitializeTables. + * If there are tables unverified, it is required to reallocate the + * root table list to clean up invalid table entries. Otherwise only + * reallocate the root table list if the host provided a static buffer + * for the table array in the call to AcpiInitializeTables(). */ - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + if ((AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) && + AcpiGbl_EnableTableValidation) { return_ACPI_STATUS (AE_SUPPORT); } diff --git a/drivers/bus/acpi/acpica/utilities/utdebug.c b/drivers/bus/acpi/acpica/utilities/utdebug.c index cbe4487dc17..95f1683e481 100644 --- a/drivers/bus/acpi/acpica/utilities/utdebug.c +++ b/drivers/bus/acpi/acpica/utilities/utdebug.c @@ -182,7 +182,9 @@ AcpiDebugPrint ( { ACPI_THREAD_ID ThreadId; va_list args; - +#ifdef ACPI_APPLICATION + int FillCount; +#endif /* Check if debug output enabled */ @@ -226,10 +228,21 @@ AcpiDebugPrint ( AcpiOsPrintf ("[%u] ", (UINT32) ThreadId); } - AcpiOsPrintf ("[%02ld] ", AcpiGbl_NestingLevel); -#endif + FillCount = 48 - AcpiGbl_NestingLevel - + strlen (AcpiUtTrimFunctionName (FunctionName)); + if (FillCount < 0) + { + FillCount = 0; + } + AcpiOsPrintf ("[%02ld] %*s", + AcpiGbl_NestingLevel, AcpiGbl_NestingLevel + 1, " "); + AcpiOsPrintf ("%s%*s: ", + AcpiUtTrimFunctionName (FunctionName), FillCount, " "); + +#else AcpiOsPrintf ("%-22.22s: ", AcpiUtTrimFunctionName (FunctionName)); +#endif va_start (args, Format); AcpiOsVprintf (Format, args); diff --git a/drivers/bus/acpi/acpica/utilities/utdecode.c b/drivers/bus/acpi/acpica/utilities/utdecode.c index 16b70a9079c..bbf2657e903 100644 --- a/drivers/bus/acpi/acpica/utilities/utdecode.c +++ b/drivers/bus/acpi/acpica/utilities/utdecode.c @@ -450,11 +450,6 @@ AcpiUtGetReferenceName ( } -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -/* - * Strings and procedures used for debug only - */ - /******************************************************************************* * * FUNCTION: AcpiUtGetMutexName @@ -493,6 +488,12 @@ AcpiUtGetMutexName ( } +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* + * Strings and procedures used for debug only + */ + /******************************************************************************* * * FUNCTION: AcpiUtGetNotifyName diff --git a/drivers/bus/acpi/acpica/utilities/uterror.c b/drivers/bus/acpi/acpica/utilities/uterror.c index 1d6a3446900..dbaef4de077 100644 --- a/drivers/bus/acpi/acpica/utilities/uterror.c +++ b/drivers/bus/acpi/acpica/utilities/uterror.c @@ -203,6 +203,82 @@ AcpiUtPredefinedBiosError ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtPrefixedNamespaceError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * PrefixScope - Scope/Path that prefixes the internal path + * InternalPath - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup + * + * RETURN: None + * + * DESCRIPTION: Print error message with the full pathname constructed this way: + * + * PrefixScopeNodeFullPath.ExternalizedInternalPath + * + * NOTE: 10/2017: Treat the major NsLookup errors as firmware errors + * + ******************************************************************************/ + +void +AcpiUtPrefixedNamespaceError ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_GENERIC_STATE *PrefixScope, + const char *InternalPath, + ACPI_STATUS LookupStatus) +{ + char *FullPath; + const char *Message; + + + /* + * Main cases: + * 1) Object creation, object must not already exist + * 2) Object lookup, object must exist + */ + switch (LookupStatus) + { + case AE_ALREADY_EXISTS: + + AcpiOsPrintf (ACPI_MSG_BIOS_ERROR); + Message = "Failure creating"; + break; + + case AE_NOT_FOUND: + + AcpiOsPrintf (ACPI_MSG_BIOS_ERROR); + Message = "Failure looking up"; + break; + + default: + + AcpiOsPrintf (ACPI_MSG_ERROR); + Message = "Failure looking up"; + break; + } + + /* Concatenate the prefix path and the internal path */ + + FullPath = AcpiNsBuildPrefixedPathname (PrefixScope, InternalPath); + + AcpiOsPrintf ("%s [%s], %s", Message, + FullPath ? FullPath : "Could not get pathname", + AcpiFormatException (LookupStatus)); + + if (FullPath) + { + ACPI_FREE (FullPath); + } + + ACPI_MSG_SUFFIX; +} + + +#ifdef __OBSOLETE_FUNCTION /******************************************************************************* * * FUNCTION: AcpiUtNamespaceError @@ -270,7 +346,7 @@ AcpiUtNamespaceError ( ACPI_MSG_SUFFIX; ACPI_MSG_REDIRECT_END; } - +#endif /******************************************************************************* * diff --git a/drivers/bus/acpi/acpica/utilities/utinit.c b/drivers/bus/acpi/acpica/utilities/utinit.c index c2b6e9b86a2..6389656e516 100644 --- a/drivers/bus/acpi/acpica/utilities/utinit.c +++ b/drivers/bus/acpi/acpica/utilities/utinit.c @@ -226,7 +226,6 @@ AcpiUtInitGlobals ( AcpiGbl_NextOwnerIdOffset = 0; AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_OsiMutex = NULL; - AcpiGbl_MaxLoopIterations = ACPI_MAX_LOOP_COUNT; /* Hardware oriented */ diff --git a/drivers/bus/acpi/acpica/utilities/utmath.c b/drivers/bus/acpi/acpica/utilities/utmath.c index 758b8bf69b7..c4bb215a99a 100644 --- a/drivers/bus/acpi/acpica/utilities/utmath.c +++ b/drivers/bus/acpi/acpica/utilities/utmath.c @@ -152,7 +152,7 @@ AcpiUtShortShiftLeft ( if ((Count & 63) >= 32) { OperandOvl.Part.Hi = OperandOvl.Part.Lo; - OperandOvl.Part.Lo ^= OperandOvl.Part.Lo; + OperandOvl.Part.Lo = 0; Count = (Count & 63) - 32; } ACPI_SHIFT_LEFT_64_BY_32 (OperandOvl.Part.Hi, @@ -197,7 +197,7 @@ AcpiUtShortShiftRight ( if ((Count & 63) >= 32) { OperandOvl.Part.Lo = OperandOvl.Part.Hi; - OperandOvl.Part.Hi ^= OperandOvl.Part.Hi; + OperandOvl.Part.Hi = 0; Count = (Count & 63) - 32; } ACPI_SHIFT_RIGHT_64_BY_32 (OperandOvl.Part.Hi, diff --git a/drivers/bus/acpi/acpica/utilities/utmutex.c b/drivers/bus/acpi/acpica/utilities/utmutex.c index 52ca917dbda..a2b5ea1757c 100644 --- a/drivers/bus/acpi/acpica/utilities/utmutex.c +++ b/drivers/bus/acpi/acpica/utilities/utmutex.c @@ -324,8 +324,8 @@ AcpiUtAcquireMutex ( else { ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %u could not acquire Mutex [0x%X]", - (UINT32) ThisThreadId, MutexId)); + "Thread %u could not acquire Mutex [%s] (0x%X)", + (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId), MutexId)); } return (Status); @@ -365,7 +365,8 @@ AcpiUtReleaseMutex ( if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) { ACPI_ERROR ((AE_INFO, - "Mutex [0x%X] is not acquired, cannot release", MutexId)); + "Mutex [%s] (0x%X) is not acquired, cannot release", + AcpiUtGetMutexName (MutexId), MutexId)); return (AE_NOT_ACQUIRED); } diff --git a/drivers/bus/acpi/acpica/utilities/utnonansi.c b/drivers/bus/acpi/acpica/utilities/utnonansi.c index fad1ae8828b..414ed94119a 100644 --- a/drivers/bus/acpi/acpica/utilities/utnonansi.c +++ b/drivers/bus/acpi/acpica/utilities/utnonansi.c @@ -236,4 +236,17 @@ AcpiUtSafeStrncat ( strncat (Dest, Source, MaxTransferLength); return (FALSE); } + +void +AcpiUtSafeStrncpy ( + char *Dest, + char *Source, + ACPI_SIZE DestSize) +{ + /* Always terminate destination string */ + + strncpy (Dest, Source, DestSize); + Dest[DestSize - 1] = 0; +} + #endif diff --git a/drivers/bus/acpi/acpica/utilities/utosi.c b/drivers/bus/acpi/acpica/utilities/utosi.c index 4a050c4933c..57600b0b36c 100644 --- a/drivers/bus/acpi/acpica/utilities/utosi.c +++ b/drivers/bus/acpi/acpica/utilities/utosi.c @@ -106,6 +106,8 @@ static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] = {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */ {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */ {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10}, /* Windows 10 - Added 03/2015 */ + {"Windows 2016", NULL, 0, ACPI_OSI_WIN_10_RS1}, /* Windows 10 version 1607 - Added 12/2017 */ + {"Windows 2017", NULL, 0, ACPI_OSI_WIN_10_RS2}, /* Windows 10 version 1703 - Added 12/2017 */ /* Feature Group Strings */ diff --git a/drivers/bus/acpi/acpica/utilities/utstrsuppt.c b/drivers/bus/acpi/acpica/utilities/utstrsuppt.c new file mode 100644 index 00000000000..27f87861b52 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utstrsuppt.c @@ -0,0 +1,513 @@ +/******************************************************************************* + * + * Module Name: utstrsuppt - Support functions for string-to-integer conversion + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2017, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstrsuppt") + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtInsertDigit ( + UINT64 *AccumulatedValue, + UINT32 Base, + int AsciiDigit); + +static ACPI_STATUS +AcpiUtStrtoulMultiply64 ( + UINT64 Multiplicand, + UINT32 Base, + UINT64 *OutProduct); + +static ACPI_STATUS +AcpiUtStrtoulAdd64 ( + UINT64 Addend1, + UINT32 Digit, + UINT64 *OutSum); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertOctalString + * + * PARAMETERS: String - Null terminated input string + * ReturnValuePtr - Where the converted value is returned + * + * RETURN: Status and 64-bit converted integer + * + * DESCRIPTION: Performs a base 8 conversion of the input string to an + * integer value, either 32 or 64 bits. + * + * NOTE: Maximum 64-bit unsigned octal value is 01777777777777777777777 + * Maximum 32-bit unsigned octal value is 037777777777 + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtConvertOctalString ( + char *String, + UINT64 *ReturnValuePtr) +{ + UINT64 AccumulatedValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* Convert each ASCII byte in the input string */ + + while (*String) + { + /* Character must be ASCII 0-7, otherwise terminate with no error */ + + if (!(ACPI_IS_OCTAL_DIGIT (*String))) + { + break; + } + + /* Convert and insert this octal digit into the accumulator */ + + Status = AcpiUtInsertDigit (&AccumulatedValue, 8, *String); + if (ACPI_FAILURE (Status)) + { + Status = AE_OCTAL_OVERFLOW; + break; + } + + String++; + } + + /* Always return the value that has been accumulated */ + + *ReturnValuePtr = AccumulatedValue; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertDecimalString + * + * PARAMETERS: String - Null terminated input string + * ReturnValuePtr - Where the converted value is returned + * + * RETURN: Status and 64-bit converted integer + * + * DESCRIPTION: Performs a base 10 conversion of the input string to an + * integer value, either 32 or 64 bits. + * + * NOTE: Maximum 64-bit unsigned decimal value is 18446744073709551615 + * Maximum 32-bit unsigned decimal value is 4294967295 + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtConvertDecimalString ( + char *String, + UINT64 *ReturnValuePtr) +{ + UINT64 AccumulatedValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* Convert each ASCII byte in the input string */ + + while (*String) + { + /* Character must be ASCII 0-9, otherwise terminate with no error */ + + if (!isdigit (*String)) + { + break; + } + + /* Convert and insert this decimal digit into the accumulator */ + + Status = AcpiUtInsertDigit (&AccumulatedValue, 10, *String); + if (ACPI_FAILURE (Status)) + { + Status = AE_DECIMAL_OVERFLOW; + break; + } + + String++; + } + + /* Always return the value that has been accumulated */ + + *ReturnValuePtr = AccumulatedValue; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertHexString + * + * PARAMETERS: String - Null terminated input string + * ReturnValuePtr - Where the converted value is returned + * + * RETURN: Status and 64-bit converted integer + * + * DESCRIPTION: Performs a base 16 conversion of the input string to an + * integer value, either 32 or 64 bits. + * + * NOTE: Maximum 64-bit unsigned hex value is 0xFFFFFFFFFFFFFFFF + * Maximum 32-bit unsigned hex value is 0xFFFFFFFF + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtConvertHexString ( + char *String, + UINT64 *ReturnValuePtr) +{ + UINT64 AccumulatedValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* Convert each ASCII byte in the input string */ + + while (*String) + { + /* Must be ASCII A-F, a-f, or 0-9, otherwise terminate with no error */ + + if (!isxdigit (*String)) + { + break; + } + + /* Convert and insert this hex digit into the accumulator */ + + Status = AcpiUtInsertDigit (&AccumulatedValue, 16, *String); + if (ACPI_FAILURE (Status)) + { + Status = AE_HEX_OVERFLOW; + break; + } + + String++; + } + + /* Always return the value that has been accumulated */ + + *ReturnValuePtr = AccumulatedValue; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveLeadingZeros + * + * PARAMETERS: String - Pointer to input ASCII string + * + * RETURN: Next character after any leading zeros. This character may be + * used by the caller to detect end-of-string. + * + * DESCRIPTION: Remove any leading zeros in the input string. Return the + * next character after the final ASCII zero to enable the caller + * to check for the end of the string (NULL terminator). + * + ******************************************************************************/ + +char +AcpiUtRemoveLeadingZeros ( + char **String) +{ + + while (**String == ACPI_ASCII_ZERO) + { + *String += 1; + } + + return (**String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveWhitespace + * + * PARAMETERS: String - Pointer to input ASCII string + * + * RETURN: Next character after any whitespace. This character may be + * used by the caller to detect end-of-string. + * + * DESCRIPTION: Remove any leading whitespace in the input string. Return the + * next character after the final ASCII zero to enable the caller + * to check for the end of the string (NULL terminator). + * + ******************************************************************************/ + +char +AcpiUtRemoveWhitespace ( + char **String) +{ + + while (isspace ((UINT8) **String)) + { + *String += 1; + } + + return (**String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDetectHexPrefix + * + * PARAMETERS: String - Pointer to input ASCII string + * + * RETURN: TRUE if a "0x" prefix was found at the start of the string + * + * DESCRIPTION: Detect and remove a hex "0x" prefix + * + ******************************************************************************/ + +BOOLEAN +AcpiUtDetectHexPrefix ( + char **String) +{ + + if ((**String == ACPI_ASCII_ZERO) && + (tolower ((int) *(*String + 1)) == 'x')) + { + *String += 2; /* Go past the leading 0x */ + return (TRUE); + } + + return (FALSE); /* Not a hex string */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDetectOctalPrefix + * + * PARAMETERS: String - Pointer to input ASCII string + * + * RETURN: True if an octal "0" prefix was found at the start of the + * string + * + * DESCRIPTION: Detect and remove an octal prefix (zero) + * + ******************************************************************************/ + +BOOLEAN +AcpiUtDetectOctalPrefix ( + char **String) +{ + + if (**String == ACPI_ASCII_ZERO) + { + *String += 1; /* Go past the leading 0 */ + return (TRUE); + } + + return (FALSE); /* Not an octal string */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInsertDigit + * + * PARAMETERS: AccumulatedValue - Current value of the integer value + * accumulator. The new value is + * returned here. + * Base - Radix, either 8/10/16 + * AsciiDigit - ASCII single digit to be inserted + * + * RETURN: Status and result of the convert/insert operation. The only + * possible returned exception code is numeric overflow of + * either the multiply or add conversion operations. + * + * DESCRIPTION: Generic conversion and insertion function for all bases: + * + * 1) Multiply the current accumulated/converted value by the + * base in order to make room for the new character. + * + * 2) Convert the new character to binary and add it to the + * current accumulated value. + * + * Note: The only possible exception indicates an integer + * overflow (AE_NUMERIC_OVERFLOW) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtInsertDigit ( + UINT64 *AccumulatedValue, + UINT32 Base, + int AsciiDigit) +{ + ACPI_STATUS Status; + UINT64 Product; + + + /* Make room in the accumulated value for the incoming digit */ + + Status = AcpiUtStrtoulMultiply64 (*AccumulatedValue, Base, &Product); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Add in the new digit, and store the sum to the accumulated value */ + + Status = AcpiUtStrtoulAdd64 (Product, AcpiUtAsciiCharToHex (AsciiDigit), + AccumulatedValue); + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoulMultiply64 + * + * PARAMETERS: Multiplicand - Current accumulated converted integer + * Base - Base/Radix + * OutProduct - Where the product is returned + * + * RETURN: Status and 64-bit product + * + * DESCRIPTION: Multiply two 64-bit values, with checking for 64-bit overflow as + * well as 32-bit overflow if necessary (if the current global + * integer width is 32). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtStrtoulMultiply64 ( + UINT64 Multiplicand, + UINT32 Base, + UINT64 *OutProduct) +{ + UINT64 Product; + UINT64 Quotient; + + + /* Exit if either operand is zero */ + + *OutProduct = 0; + if (!Multiplicand || !Base) + { + return (AE_OK); + } + + /* + * Check for 64-bit overflow before the actual multiplication. + * + * Notes: 64-bit division is often not supported on 32-bit platforms + * (it requires a library function), Therefore ACPICA has a local + * 64-bit divide function. Also, Multiplier is currently only used + * as the radix (8/10/16), to the 64/32 divide will always work. + */ + AcpiUtShortDivide (ACPI_UINT64_MAX, Base, &Quotient, NULL); + if (Multiplicand > Quotient) + { + return (AE_NUMERIC_OVERFLOW); + } + + Product = Multiplicand * Base; + + /* Check for 32-bit overflow if necessary */ + + if ((AcpiGbl_IntegerBitWidth == 32) && (Product > ACPI_UINT32_MAX)) + { + return (AE_NUMERIC_OVERFLOW); + } + + *OutProduct = Product; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoulAdd64 + * + * PARAMETERS: Addend1 - Current accumulated converted integer + * Digit - New hex value/char + * OutSum - Where sum is returned (Accumulator) + * + * RETURN: Status and 64-bit sum + * + * DESCRIPTION: Add two 64-bit values, with checking for 64-bit overflow as + * well as 32-bit overflow if necessary (if the current global + * integer width is 32). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtStrtoulAdd64 ( + UINT64 Addend1, + UINT32 Digit, + UINT64 *OutSum) +{ + UINT64 Sum; + + + /* Check for 64-bit overflow before the actual addition */ + + if ((Addend1 > 0) && (Digit > (ACPI_UINT64_MAX - Addend1))) + { + return (AE_NUMERIC_OVERFLOW); + } + + Sum = Addend1 + Digit; + + /* Check for 32-bit overflow if necessary */ + + if ((AcpiGbl_IntegerBitWidth == 32) && (Sum > ACPI_UINT32_MAX)) + { + return (AE_NUMERIC_OVERFLOW); + } + + *OutSum = Sum; + return (AE_OK); +} diff --git a/drivers/bus/acpi/acpica/utilities/utstrtoul64.c b/drivers/bus/acpi/acpica/utilities/utstrtoul64.c index 7894a4cebd8..e3b9c51674c 100644 --- a/drivers/bus/acpi/acpica/utilities/utstrtoul64.c +++ b/drivers/bus/acpi/acpica/utilities/utstrtoul64.c @@ -1,6 +1,7 @@ /******************************************************************************* * - * Module Name: utstrtoul64 - string to 64-bit integer support + * Module Name: utstrtoul64 - String-to-integer conversion support for both + * 64-bit and 32-bit integers * ******************************************************************************/ @@ -44,84 +45,47 @@ #include "acpi.h" #include "accommon.h" - -/******************************************************************************* - * - * The functions in this module satisfy the need for 64-bit string-to-integer - * conversions on both 32-bit and 64-bit platforms. - * - ******************************************************************************/ - #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utstrtoul64") -/* Local prototypes */ - -static UINT64 -AcpiUtStrtoulBase10 ( - char *String, - UINT32 Flags); - -static UINT64 -AcpiUtStrtoulBase16 ( - char *String, - UINT32 Flags); - /******************************************************************************* * - * String conversion rules as written in the ACPI specification. The error - * conditions and behavior are different depending on the type of conversion. + * This module contains the top-level string to 64/32-bit unsigned integer + * conversion functions: * + * 1) A standard strtoul() function that supports 64-bit integers, base + * 8/10/16, with integer overflow support. This is used mainly by the + * iASL compiler, which implements tighter constraints on integer + * constants than the runtime (interpreter) integer-to-string conversions. + * 2) Runtime "Explicit conversion" as defined in the ACPI specification. + * 3) Runtime "Implicit conversion" as defined in the ACPI specification. * - * Implicit data type conversion: string-to-integer - * -------------------------------------------------- + * Current users of this module: * - * Base is always 16. This is the ACPI_STRTOUL_BASE16 case. + * iASL - Preprocessor (constants and math expressions) + * iASL - Main parser, conversion of constants to integers + * iASL - Data Table Compiler parser (constants and math expressions) + * Interpreter - Implicit and explicit conversions, GPE method names + * Interpreter - Repair code for return values from predefined names + * Debugger - Command line input string conversion + * AcpiDump - ACPI table physical addresses + * AcpiExec - Support for namespace overrides * - * Example: - * Add ("BA98", Arg0, Local0) + * Notes concerning users of these interfaces: * - * The integer is initialized to the value zero. - * The ASCII string is interpreted as a hexadecimal constant. + * AcpiGbl_IntegerByteWidth is used to set the 32/64 bit limit for explicit + * and implicit conversions. This global must be set to the proper width. + * For the core ACPICA code, the width depends on the DSDT version. For the + * AcpiUtStrtoul64 interface, all conversions are 64 bits. This interface is + * used primarily for iASL, where the default width is 64 bits for all parsers, + * but error checking is performed later to flag cases where a 64-bit constant + * is wrongly defined in a 32-bit DSDT/SSDT. * - * 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). - * (NO ERROR) - * - * 3) The first non-hex character terminates the conversion without error. - * (NO ERROR) - * - * 4) Conversion of a null (zero-length) string to an integer is not - * allowed. However, ACPICA allows this for compatibility with previous - * ACPICA. This conversion returns the value 0. (NO ERROR) - * - * - * Explicit data type conversion: ToInteger() with string operand - * --------------------------------------------------------------- - * - * Base is either 10 (default) or 16 (with 0x prefix) - * - * Examples: - * ToInteger ("1000") - * ToInteger ("0xABCD") - * - * 1) Can be (must be) either a decimal or hexadecimal numeric string. - * A hex value must be prefixed by "0x" or it is interpreted as a decimal. - * - * 2) The value must not exceed the maximum of an integer value. ACPI spec - * states the behavior is "unpredictable", so ACPICA matches the behavior - * of the implicit conversion case.(NO ERROR) - * - * 3) Behavior on the first non-hex character is not specified by the ACPI - * spec, so ACPICA matches the behavior of the implicit conversion case - * and terminates. (NO ERROR) - * - * 4) A null (zero-length) string is illegal. - * However, ACPICA allows this for compatibility with previous ACPICA. - * This conversion returns the value 0. (NO ERROR) + * In ACPI, the only place where octal numbers are supported is within + * the ASL language itself. This is implemented via the main AcpiUtStrtoul64 + * interface. According the ACPI specification, there is no ACPI runtime + * support (explicit/implicit) for octal string conversions. * ******************************************************************************/ @@ -130,261 +94,301 @@ AcpiUtStrtoulBase16 ( * * FUNCTION: AcpiUtStrtoul64 * - * PARAMETERS: String - Null terminated input string - * Flags - Conversion info, see below + * PARAMETERS: String - Null terminated input string, + * must be a valid pointer * ReturnValue - Where the converted integer is - * returned + * returned. Must be a valid pointer * - * RETURN: Status and Converted value + * RETURN: Status and converted integer. Returns an exception on a + * 64-bit numeric overflow * - * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the input integer - * size in Flags (often the current mode of the interpreter). + * DESCRIPTION: Convert a string into an unsigned integer. Always performs a + * full 64-bit conversion, regardless of the current global + * integer width. Supports Decimal, Hex, and Octal strings. * - * Values for Flags: - * ACPI_STRTOUL_32BIT - Max integer value is 32 bits - * ACPI_STRTOUL_64BIT - Max integer value is 64 bits - * ACPI_STRTOUL_BASE16 - Input string is hexadecimal. Default - * is 10/16 based on string prefix (0x). + * Current users of this function: * - * NOTES: - * Negative numbers are not supported, as they are not supported by ACPI. - * - * Supports only base 16 or base 10 strings/values. Does not - * support Octal strings, as these are not supported by ACPI. - * - * Current users of this support: - * - * Interpreter - Implicit and explicit conversions, GPE method names - * Debugger - Command line input string conversion - * iASL - Main parser, conversion of constants to integers - * iASL - Data Table Compiler parser (constant math expressions) - * iASL - Preprocessor (constant math expressions) - * AcpiDump - Input table addresses - * AcpiExec - Testing of the AcpiUtStrtoul64 function - * - * Note concerning callers: - * AcpiGbl_IntegerByteWidth can be used to set the 32/64 limit. If used, - * this global should be set to the proper width. For the core ACPICA code, - * this width depends on the DSDT version. For iASL, the default byte - * width is always 8 for the parser, but error checking is performed later - * to flag cases where a 64-bit constant is defined in a 32-bit DSDT/SSDT. + * iASL - Preprocessor (constants and math expressions) + * iASL - Main ASL parser, conversion of ASL constants to integers + * iASL - Data Table Compiler parser (constants and math expressions) + * Interpreter - Repair code for return values from predefined names + * AcpiDump - ACPI table physical addresses + * AcpiExec - Support for namespace overrides * ******************************************************************************/ ACPI_STATUS AcpiUtStrtoul64 ( char *String, - UINT32 Flags, UINT64 *ReturnValue) { ACPI_STATUS Status = AE_OK; - UINT32 Base; + UINT8 OriginalBitWidth; + UINT32 Base = 10; /* Default is decimal */ ACPI_FUNCTION_TRACE_STR (UtStrtoul64, String); - /* Parameter validation */ - - if (!String || !ReturnValue) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - *ReturnValue = 0; - /* Check for zero-length string, returns 0 */ + /* A NULL return string returns a value of zero */ if (*String == 0) { return_ACPI_STATUS (AE_OK); } - /* Skip over any white space at start of string */ - - while (isspace ((int) *String)) - { - String++; - } - - /* End of string? return 0 */ - - if (*String == 0) + if (!AcpiUtRemoveWhitespace (&String)) { return_ACPI_STATUS (AE_OK); } /* - * 1) The "0x" prefix indicates base 16. Per the ACPI specification, - * the "0x" prefix is only allowed for implicit (non-strict) conversions. - * However, we always allow it for compatibility with older ACPICA. + * 1) Check for a hex constant. A "0x" prefix indicates base 16. */ - if ((*String == ACPI_ASCII_ZERO) && - (tolower ((int) *(String + 1)) == 'x')) - { - String += 2; /* Go past the 0x */ - if (*String == 0) - { - return_ACPI_STATUS (AE_OK); /* Return value 0 */ - } - - Base = 16; - } - - /* 2) Force to base 16 (implicit conversion case) */ - - else if (Flags & ACPI_STRTOUL_BASE16) + if (AcpiUtDetectHexPrefix (&String)) { Base = 16; } - /* 3) Default fallback is to Base 10 */ - - else + /* + * 2) Check for an octal constant, defined to be a leading zero + * followed by sequence of octal digits (0-7) + */ + else if (AcpiUtDetectOctalPrefix (&String)) { - Base = 10; + Base = 8; } - /* Skip all leading zeros */ - - while (*String == ACPI_ASCII_ZERO) + if (!AcpiUtRemoveLeadingZeros (&String)) { - String++; - if (*String == 0) - { - return_ACPI_STATUS (AE_OK); /* Return value 0 */ - } + return_ACPI_STATUS (AE_OK); /* Return value 0 */ } - /* Perform the base 16 or 10 conversion */ + /* + * Force a full 64-bit conversion. The caller (usually iASL) must + * check for a 32-bit overflow later as necessary (If current mode + * is 32-bit, meaning a 32-bit DSDT). + */ + OriginalBitWidth = AcpiGbl_IntegerBitWidth; + AcpiGbl_IntegerBitWidth = 64; - if (Base == 16) + /* + * Perform the base 8, 10, or 16 conversion. A 64-bit numeric overflow + * will return an exception (to allow iASL to flag the statement). + */ + switch (Base) { - *ReturnValue = AcpiUtStrtoulBase16 (String, Flags); - } - else - { - *ReturnValue = AcpiUtStrtoulBase10 (String, Flags); + case 8: + Status = AcpiUtConvertOctalString (String, ReturnValue); + break; + + case 10: + Status = AcpiUtConvertDecimalString (String, ReturnValue); + break; + + case 16: + default: + Status = AcpiUtConvertHexString (String, ReturnValue); + break; } + /* Only possible exception from above is a 64-bit overflow */ + + AcpiGbl_IntegerBitWidth = OriginalBitWidth; return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiUtStrtoulBase10 + * FUNCTION: AcpiUtImplicitStrtoul64 * - * PARAMETERS: String - Null terminated input string - * Flags - Conversion info + * PARAMETERS: String - Null terminated input string, + * must be a valid pointer * - * RETURN: 64-bit converted integer + * RETURN: Converted integer * - * DESCRIPTION: Performs a base 10 conversion of the input string to an - * integer value, either 32 or 64 bits. - * Note: String must be valid and non-null. + * DESCRIPTION: Perform a 64-bit conversion with restrictions placed upon + * an "implicit conversion" by the ACPI specification. Used by + * many ASL operators that require an integer operand, and support + * an automatic (implicit) conversion from a string operand + * to the final integer operand. The major restriction is that + * only hex strings are supported. + * + * ----------------------------------------------------------------------------- + * + * Base is always 16, either with or without the 0x prefix. Decimal and + * Octal strings are not supported, as per the ACPI specification. + * + * Examples (both are hex values): + * Add ("BA98", Arg0, Local0) + * Subtract ("0x12345678", Arg1, Local1) + * + * Conversion rules as extracted from the ACPI specification: + * + * The converted integer is initialized to the value zero. + * The ASCII string is always interpreted as a hexadecimal constant. + * + * 1) According to the ACPI specification, a "0x" prefix is not allowed. + * However, ACPICA allows this as an ACPI extension on general + * principle. (NO ERROR) + * + * 2) The conversion terminates when the size of an integer is reached + * (32 or 64 bits). There are no numeric overflow conditions. (NO ERROR) + * + * 3) The first non-hex character terminates the conversion and returns + * the current accumulated value of the converted integer (NO ERROR). + * + * 4) Conversion of a null (zero-length) string to an integer is + * technically not allowed. However, ACPICA allows this as an ACPI + * extension. The conversion returns the value 0. (NO ERROR) + * + * NOTE: There are no error conditions returned by this function. At + * the minimum, a value of zero is returned. + * + * Current users of this function: + * + * Interpreter - All runtime implicit conversions, as per ACPI specification + * iASL - Data Table Compiler parser (constants and math expressions) * ******************************************************************************/ -static UINT64 -AcpiUtStrtoulBase10 ( - char *String, - UINT32 Flags) +UINT64 +AcpiUtImplicitStrtoul64 ( + char *String) { - int AsciiDigit; - UINT64 NextValue; - UINT64 ReturnValue = 0; + UINT64 ConvertedInteger = 0; - /* Main loop: convert each ASCII byte in the input string */ + ACPI_FUNCTION_TRACE_STR (UtImplicitStrtoul64, String); - while (*String) + + if (!AcpiUtRemoveWhitespace (&String)) { - AsciiDigit = *String; - if (!isdigit (AsciiDigit)) - { - /* Not ASCII 0-9, terminate */ - - goto Exit; - } - - /* Convert and insert (add) the decimal digit */ - - AcpiUtShortMultiply (ReturnValue, 10, &NextValue); - NextValue += (AsciiDigit - ACPI_ASCII_ZERO); - - /* Check for overflow (32 or 64 bit) - return current converted value */ - - if (((Flags & ACPI_STRTOUL_32BIT) && (NextValue > ACPI_UINT32_MAX)) || - (NextValue < ReturnValue)) /* 64-bit overflow case */ - { - goto Exit; - } - - ReturnValue = NextValue; - String++; + return_VALUE (0); } -Exit: - return (ReturnValue); + /* + * Per the ACPI specification, only hexadecimal is supported for + * implicit conversions, and the "0x" prefix is "not allowed". + * However, allow a "0x" prefix as an ACPI extension. + */ + AcpiUtDetectHexPrefix (&String); + + if (!AcpiUtRemoveLeadingZeros (&String)) + { + return_VALUE (0); + } + + /* + * Ignore overflow as per the ACPI specification. This is implemented by + * ignoring the return status from the conversion function called below. + * On overflow, the input string is simply truncated. + */ + AcpiUtConvertHexString (String, &ConvertedInteger); + return_VALUE (ConvertedInteger); } /******************************************************************************* * - * FUNCTION: AcpiUtStrtoulBase16 + * FUNCTION: AcpiUtExplicitStrtoul64 * - * PARAMETERS: String - Null terminated input string - * Flags - conversion info + * PARAMETERS: String - Null terminated input string, + * must be a valid pointer * - * RETURN: 64-bit converted integer + * RETURN: Converted integer * - * DESCRIPTION: Performs a base 16 conversion of the input string to an - * integer value, either 32 or 64 bits. - * Note: String must be valid and non-null. + * DESCRIPTION: Perform a 64-bit conversion with the restrictions placed upon + * an "explicit conversion" by the ACPI specification. The + * main restriction is that only hex and decimal are supported. + * + * ----------------------------------------------------------------------------- + * + * Base is either 10 (default) or 16 (with 0x prefix). Octal (base 8) strings + * are not supported, as per the ACPI specification. + * + * Examples: + * ToInteger ("1000") Decimal + * ToInteger ("0xABCD") Hex + * + * Conversion rules as extracted from the ACPI specification: + * + * 1) The input string is either a decimal or hexadecimal numeric string. + * A hex value must be prefixed by "0x" or it is interpreted as decimal. + * + * 2) The value must not exceed the maximum of an integer value + * (32 or 64 bits). The ACPI specification states the behavior is + * "unpredictable", so ACPICA matches the behavior of the implicit + * conversion case. There are no numeric overflow conditions. (NO ERROR) + * + * 3) Behavior on the first non-hex character is not defined by the ACPI + * specification (for the ToInteger operator), so ACPICA matches the + * behavior of the implicit conversion case. It terminates the + * conversion and returns the current accumulated value of the converted + * integer. (NO ERROR) + * + * 4) Conversion of a null (zero-length) string to an integer is + * technically not allowed. However, ACPICA allows this as an ACPI + * extension. The conversion returns the value 0. (NO ERROR) + * + * NOTE: There are no error conditions returned by this function. At the + * minimum, a value of zero is returned. + * + * Current users of this function: + * + * Interpreter - Runtime ASL ToInteger operator, as per the ACPI specification * ******************************************************************************/ -static UINT64 -AcpiUtStrtoulBase16 ( - char *String, - UINT32 Flags) +UINT64 +AcpiUtExplicitStrtoul64 ( + char *String) { - int AsciiDigit; - UINT32 ValidDigits = 1; - UINT64 ReturnValue = 0; + UINT64 ConvertedInteger = 0; + UINT32 Base = 10; /* Default is decimal */ - /* Main loop: convert each ASCII byte in the input string */ + ACPI_FUNCTION_TRACE_STR (UtExplicitStrtoul64, String); - while (*String) + + if (!AcpiUtRemoveWhitespace (&String)) { - /* Check for overflow (32 or 64 bit) - return current converted value */ - - if ((ValidDigits > 16) || - ((ValidDigits > 8) && (Flags & ACPI_STRTOUL_32BIT))) - { - goto Exit; - } - - AsciiDigit = *String; - if (!isxdigit (AsciiDigit)) - { - /* Not Hex ASCII A-F, a-f, or 0-9, terminate */ - - goto Exit; - } - - /* Convert and insert the hex digit */ - - AcpiUtShortShiftLeft (ReturnValue, 4, &ReturnValue); - ReturnValue |= AcpiUtAsciiCharToHex (AsciiDigit); - - String++; - ValidDigits++; + return_VALUE (0); } -Exit: - return (ReturnValue); + /* + * Only Hex and Decimal are supported, as per the ACPI specification. + * A "0x" prefix indicates hex; otherwise decimal is assumed. + */ + if (AcpiUtDetectHexPrefix (&String)) + { + Base = 16; + } + + if (!AcpiUtRemoveLeadingZeros (&String)) + { + return_VALUE (0); + } + + /* + * Ignore overflow as per the ACPI specification. This is implemented by + * ignoring the return status from the conversion functions called below. + * On overflow, the input string is simply truncated. + */ + switch (Base) + { + case 10: + default: + AcpiUtConvertDecimalString (String, &ConvertedInteger); + break; + + case 16: + AcpiUtConvertHexString (String, &ConvertedInteger); + break; + } + + return_VALUE (ConvertedInteger); } diff --git a/drivers/bus/acpi/acpica/utilities/uttrack.c b/drivers/bus/acpi/acpica/utilities/uttrack.c index 2bb1801d5bd..364cf59397f 100644 --- a/drivers/bus/acpi/acpica/utilities/uttrack.c +++ b/drivers/bus/acpi/acpica/utilities/uttrack.c @@ -449,8 +449,7 @@ AcpiUtTrackAllocation ( Allocation->Component = Component; Allocation->Line = Line; - strncpy (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); - Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; + AcpiUtSafeStrncpy (Allocation->Module, (char *) Module, ACPI_MAX_MODULE_NAME); if (!Element) { @@ -783,7 +782,7 @@ Exit: } else { - ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations", + ACPI_ERROR ((AE_INFO, "%u (0x%X) Outstanding cache allocations", NumOutstanding, NumOutstanding)); } diff --git a/drivers/bus/acpi/acpica/utilities/utxferror.c b/drivers/bus/acpi/acpica/utilities/utxferror.c index e88108682e4..5dd4141f91a 100644 --- a/drivers/bus/acpi/acpica/utilities/utxferror.c +++ b/drivers/bus/acpi/acpica/utilities/utxferror.c @@ -106,8 +106,8 @@ ACPI_EXPORT_SYMBOL (AcpiError) * * RETURN: None * - * DESCRIPTION: Print "ACPI Exception" message with module/line/version info - * and decoded ACPI_STATUS. + * DESCRIPTION: Print an "ACPI Error" message with module/line/version + * info as well as decoded ACPI_STATUS. * ******************************************************************************/ @@ -128,12 +128,12 @@ AcpiException ( if (ACPI_SUCCESS (Status)) { - AcpiOsPrintf (ACPI_MSG_EXCEPTION); + AcpiOsPrintf (ACPI_MSG_ERROR); } else { - AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", + AcpiOsPrintf (ACPI_MSG_ERROR "%s, ", AcpiFormatException (Status)); }