]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/GenericWatchdogDxe: Split 64bit register write to 2x32bit
authorMarcin Wojtas <mw@semihalf.com>
Thu, 2 Aug 2018 20:50:54 +0000 (22:50 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 3 Aug 2018 07:29:14 +0000 (09:29 +0200)
According to the SBSA specification the Watchdog Compare
Register is split into two separate 32bit registers.
EDK2 code uses a single 64bit transaction to update
them, which can be problematic, depending on the SoC
implementation and could result in unpredictable behavior.

Fix this by modifying WatchdogWriteCompareRegister routine to
use two consecutive 32bit writes to the Watchdog Compare Register
Low and High, using new dedicated macros.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h
ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c

index 9e2aebcfd5e557269bbc36556dbcbc8f6809aeb0..4f42c56a485337966d46348d02176855020ed40f 100644 (file)
@@ -20,7 +20,8 @@
 // Control Frame:\r
 #define GENERIC_WDOG_CONTROL_STATUS_REG       ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x000)\r
 #define GENERIC_WDOG_OFFSET_REG               ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x008)\r
-#define GENERIC_WDOG_COMPARE_VALUE_REG        ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)\r
+#define GENERIC_WDOG_COMPARE_VALUE_REG_LOW    ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)\r
+#define GENERIC_WDOG_COMPARE_VALUE_REG_HIGH   ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x014)\r
 \r
 // Values of bit 0 of the Control/Status Register\r
 #define GENERIC_WDOG_ENABLED          1\r
index 3180f011253639c408b7151c79c2106a352c7340..8ccf15366dfadbfc9199cbec729934f0d9bd855d 100644 (file)
@@ -56,7 +56,8 @@ WatchdogWriteCompareRegister (
   UINT64  Value\r
   )\r
 {\r
-  MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value);\r
+  MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_LOW, Value & MAX_UINT32);\r
+  MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_HIGH, (Value >> 32) & MAX_UINT32);\r
 }\r
 \r
 VOID\r