aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/main.c11
-rw-r--r--kernel/trap.c11
2 files changed, 11 insertions, 11 deletions
diff --git a/kernel/main.c b/kernel/main.c
index fdcef1f..a39ed29 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -16,6 +16,13 @@ struct task_struct tasks[4] = {
[TASK_FIZZBUZZ] = { .stack = stack[3], .entry_addr = nullptr, },
};
+// Defined in fbos/init.h.
+struct dt_info info = {
+ .cpu_freq = 0,
+ .initrd_start = 0,
+ .initrd_end = 0,
+};
+
/*
* This is the main entry point of the kernel after head.S is done. This
* function can (and will) assume that everything has been reset and that we can
@@ -26,8 +33,8 @@ __noreturn __kernel void start_kernel(void *dtb)
printk("Welcome to FizzBuzz OS!\n");
// Extract information from the DTB blob.
- struct initrd_addr addr = find_dt_initrd_addr(dtb);
- extract_initrd((unsigned char *)addr.start, addr.end - addr.start, tasks);
+ get_dt_info(dtb, &info);
+ extract_initrd((unsigned char *)info.initrd_start, info.initrd_end - info.initrd_start, tasks);
// At this point everything has already been handled: setup the interrupt
// vector and enable the timer to start ticking and scheduling the three
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);