mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-20 10:32:19 +00:00
lib: timer: Provide a hart based timer feature
As per the RISC-V specification, time value can be obtained from a time CSR implemented in hardware or a MMIO based IP block. Qemu virt machine already supports timer csr while CLINT provides the timer for other platforms. Implement a hart specific timer feature that can be detected at runtime. As CSR based timer implementation are faster than MMIO address based, it is always preferred over MMIO based one. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
1 parent
4938024420
commit
ec0d2a7d7d
3 files changed
+28
-9
No files matched your search
@@ -271,6 +271,12 @@ static void sbi_hart_detect_features(u32 hartid)
|
||||
feature |= SBI_HART_HAS_MCOUNTEREN;
|
||||
}
|
||||
|
||||
/* Detect if hart supports time CSR */
|
||||
trap.cause = 0;
|
||||
csr_read_allowed(CSR_TIME, (unsigned long)&trap);
|
||||
if (!trap.cause)
|
||||
feature |= SBI_HART_HAS_TIME;
|
||||
|
||||
sbi_hart_set_feature(hartid, feature);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user