Skip to content

Commit

Permalink
kernel_riscv: kick timer off closer to when we have a full trap han…
Browse files Browse the repository at this point in the history
…dler
  • Loading branch information
IsaacWoods committed Apr 4, 2024
1 parent 2c06385 commit 82454c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kernel/kernel_riscv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ pub extern "C" fn kentry(boot_info: &BootInfo) -> ! {

SCHEDULER.initialize(Scheduler::new());
maitake::time::set_global_timer(&SCHEDULER.get().tasklet_scheduler.timer).unwrap();
// Kick the timer off
// TODO: global function for getting number of ticks per us or whatever from the device tree
sbi::timer::set_timer(hal_riscv::hw::csr::Time::read() as u64 + 0x989680 / 50).unwrap();

let (uart_prod, uart_cons) = kernel::tasklets::queue::SpscQueue::new();
serial::enable_input(&fdt, uart_prod);
Expand Down Expand Up @@ -195,6 +192,14 @@ pub extern "C" fn kentry(boot_info: &BootInfo) -> ! {
);
}

/*
* Kick the timer off. We do this just before installing the full handler because the shim
* handler doesn't support timer interrupts, so we'll get stuck if we do take too long between
* this and having the real handler in place.
*/
// TODO: global function for getting number of ticks per us or whatever from the device tree
sbi::timer::set_timer(hal_riscv::hw::csr::Time::read() as u64 + 0x989680 / 50).unwrap();

/*
* Move to a trap handler that can handle traps from both S-mode and U-mode. We can only do
* this now because we need a `sscratch` context installed (which hasn't technically happened
Expand Down

0 comments on commit 82454c1

Please sign in to comment.