Hi!
I am currently in the process of implementing a round robin scheduler for my kernel in rust, i found a nice and simple example of scheduling at EliaOnceAgain/edu-x86-bootloader-kernel and i started implementing my scheduler in a similar fashion as the example, it all went smooth until i had to return to my "next_process" function with the iretq instruction.
asm!(
// we want to make iretq return to the next_process function.
"push next_process",
"iretq",
);
#[no_mangle]
pub extern "C" fn next_process() {
// here we are restoring the register state but it doesnt matter for this post.
}
When i try to compile this i get the following linker error:
= note: rust-lld: error: relocation R_X86_64_32S cannot be used against symbol 'next_process'; recompile with -fPIC
>>> defined in /home/proxin/Rust/lios/kernel/target/x86_64-unknown-none/debug/deps/lios-c028c9a0db928179.58u4cutpp6ltkxvokpvh3beeg.rcgu.o
>>> referenced by mod.rs:73 (src/interrupt/mod.rs:73)
>>> /home/proxin/Rust/lios/kernel/target/x86_64-unknown-none/debug/deps/lios-c028c9a0db928179.4uvqmwk2pnqtk3sygjmer33y5.rcgu.o:(lios::interrupt::timer_interrupt::hc490168c73fff0b9)
To sum up i am looking for a way to make the iretq
instruction call next_process
when returning from a interrupt.
If anyone knows how to achieve this i would greatly appreciate some help!