diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-26 13:59:54 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-26 13:59:54 +0100 |
| commit | 7870d56b155c2be73cdacfba94eeb893cd55628e (patch) | |
| tree | f95699d91e19635c7aa0e99dbf114da2a06e80a2 /kernel/trap.c | |
| parent | 30d6ab8c6b40b2897fa3f49cce0302cc6c3a66e6 (diff) | |
| download | fbos-7870d56b155c2be73cdacfba94eeb893cd55628e.tar.gz fbos-7870d56b155c2be73cdacfba94eeb893cd55628e.zip | |
dt: Fetch the CPU frequency as well
If the 'timebase-frequency' property is available under the 'cpus' node
from the DTB blob, it makes sense to try to fetch this value from there
instead of hardcoding it. For other use-cases, where this information is
not available through DT (e.g. ACPI on the VisionFive2 board), we will
have to hardcode it with a default value even if it's not the proper
one.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'kernel/trap.c')
| -rw-r--r-- | kernel/trap.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/kernel/trap.c b/kernel/trap.c index bf8a89e..f98fcc7 100644 --- a/kernel/trap.c +++ b/kernel/trap.c @@ -1,13 +1,6 @@ #include <fbos/init.h> #include <fbos/sbi.h> #include <fbos/printk.h> -#include <fbos/sched.h> - -// TODO: this is QEMU-specific. To obtain this: -// - Parse the DTB and look for the 'cpus.timebase-frequency' property. -// - If the system is on ACPI (e.g. VisionFive2), then the frequency has to be -// picked up from somewhere else (constant on known boards?). -#define TICKS_PER_SECOND 10000000 // Mask for 'scause' to check whether it came from an interrupt or an exception. #define INTERRUPT_MASK 0x8000000000000000 @@ -34,10 +27,10 @@ __kernel void time_out_in_one_second(void) register uint64_t one_second asm("a0"); asm volatile("rdtime t0\n\t" - "li t1, %1\n\t" + "mv t1, %1\n\t" "add %0, t0, t1" : "=r"(one_second) - : "i"(TICKS_PER_SECOND) + : "r"(info.cpu_freq) : "t0", "t1"); ret = sbi_ecall1(TIME_EXT, TIME_SET_TIMER, one_second); |
