mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:47:45 +00:00
Kernel/riscv64: Implement Processor::initialize_context_switching
This code is based on the aarch64 implementation.
This commit is contained in:
parent
1429c83942
commit
7fff6eef09
1 changed files with 22 additions and 2 deletions
|
@ -172,9 +172,29 @@ u32 ProcessorBase<T>::smp_wake_n_idle_processors(u32)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void ProcessorBase<T>::initialize_context_switching(Thread&)
|
||||
void ProcessorBase<T>::initialize_context_switching(Thread& initial_thread)
|
||||
{
|
||||
TODO_RISCV64();
|
||||
VERIFY(initial_thread.process().is_kernel_process());
|
||||
|
||||
m_scheduler_initialized = true;
|
||||
|
||||
// FIXME: Figure out if we need to call {pre_,post_,}init_finished once riscv64 supports SMP
|
||||
Processor::set_current_in_scheduler(true);
|
||||
|
||||
auto& regs = initial_thread.regs();
|
||||
asm volatile(
|
||||
"mv sp, %[new_sp] \n"
|
||||
|
||||
"addi sp, sp, -32 \n"
|
||||
"sd %[from_to_thread], 0(sp) \n"
|
||||
"sd %[from_to_thread], 8(sp) \n"
|
||||
|
||||
"jr %[new_ip] \n" ::[new_sp] "r"(regs.sp()),
|
||||
[new_ip] "r"(regs.ip()),
|
||||
[from_to_thread] "r"(&initial_thread)
|
||||
: "t0");
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue