mirror of
https://github.com/apache/nuttx.git
synced 2025-12-07 18:12:33 +08:00
arch/risc-v: Ensure the timer setting atomicity on 32-bit platforms.
This commit guaranteed the timer setting atomicity on 32-bit platforms. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
c4fd6f9636
commit
fd4d93e928
@@ -77,9 +77,11 @@ void riscv_mtimer_set(uintreg_t mtime_addr,
|
||||
else
|
||||
# endif
|
||||
{
|
||||
irqstate_t flags = up_irq_save();
|
||||
putreg32(UINT32_MAX, mtimecmp_addr + 4);
|
||||
putreg32(value, mtimecmp_addr);
|
||||
putreg32(value >> 32, mtimecmp_addr + 4);
|
||||
up_irq_restore(flags);
|
||||
}
|
||||
|
||||
UP_DSB();
|
||||
@@ -93,8 +95,10 @@ static inline void riscv_write_stime(uint64_t value)
|
||||
# ifdef CONFIG_ARCH_RV64
|
||||
WRITE_CSR(CSR_STIMECMP, value);
|
||||
# else
|
||||
irqstate_t flags = up_irq_save();
|
||||
WRITE_CSR(CSR_STIMECMP, (uint32_t)value);
|
||||
WRITE_CSR(CSR_STIMECMPH, (uint32_t)(value >> 32));
|
||||
up_irq_restore(flags);
|
||||
# endif /* CONFIG_ARCH_RV64 */
|
||||
}
|
||||
# endif /* CONFIG_ARCH_RV_EXT_SSTC */
|
||||
|
||||
Reference in New Issue
Block a user