mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00: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:
parent
c4fd6f9636
commit
fd4d93e928
1 changed files with 4 additions and 0 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue