lib: timer: Provide a hart based timer feature
authorAtish Patra <atish.patra@wdc.com>
Sat, 9 May 2020 23:47:30 +0000 (16:47 -0700)
committerAnup Patel <anup@brainfault.org>
Sun, 10 May 2020 04:44:54 +0000 (10:14 +0530)
commitec0d2a7d7d8b78193375651627aa6f65b9219afe
tree4a694ae1b74eb02f5bfb3aa4f2cd35ea93e63f9b
parent49380244202460aa2fd322dc9a3bdd79b388bf9d
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>
include/sbi/sbi_hart.h
lib/sbi/sbi_hart.c
lib/sbi/sbi_timer.c