forked from Mirrors/opensbi
lib: sbi: Fix writes to emulated 32-bit htimedelta CSR
Writes to the low half CSR should not affect the high half of the value.
Make this separation explicit by writing to the delta in memory as two
adjacent XLEN-sized values.
Fixes: 1e9f88889f
("lib: Emulate HTIMEDELTA CSR for platforms not having TIME CSR")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
65f04badf7
commit
ebfaf1974e
@@ -78,8 +78,10 @@ u64 sbi_timer_get_delta(void);
|
||||
/** Set timer delta value for current HART */
|
||||
void sbi_timer_set_delta(ulong delta);
|
||||
|
||||
#if __riscv_xlen == 32
|
||||
/** Set upper 32-bits of timer delta value for current HART */
|
||||
void sbi_timer_set_delta_upper(ulong delta_upper);
|
||||
#endif
|
||||
|
||||
/** Start timer event for current HART */
|
||||
void sbi_timer_event_start(u64 next_event);
|
||||
|
@@ -114,20 +114,21 @@ u64 sbi_timer_get_delta(void)
|
||||
|
||||
void sbi_timer_set_delta(ulong delta)
|
||||
{
|
||||
u64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),
|
||||
time_delta_off);
|
||||
ulong *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),
|
||||
time_delta_off);
|
||||
|
||||
*time_delta = (u64)delta;
|
||||
*time_delta = delta;
|
||||
}
|
||||
|
||||
#if __riscv_xlen == 32
|
||||
void sbi_timer_set_delta_upper(ulong delta_upper)
|
||||
{
|
||||
u64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),
|
||||
time_delta_off);
|
||||
ulong *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),
|
||||
time_delta_off);
|
||||
|
||||
*time_delta &= 0xffffffffULL;
|
||||
*time_delta |= ((u64)delta_upper << 32);
|
||||
*(time_delta + 1) = delta_upper;
|
||||
}
|
||||
#endif
|
||||
|
||||
void sbi_timer_event_start(u64 next_event)
|
||||
{
|
||||
|
Reference in New Issue
Block a user