1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-28 04:13:31 +04:00
osblog/risc_v/src/syscall.rs

37 lines
1.0 KiB
Rust
Raw Normal View History

2020-03-16 04:18:46 +04:00
// syscall.rs
// System calls
// Stephen Marz
// 3 Jan 2020
use crate::cpu::TrapFrame;
pub fn do_syscall(mepc: usize, frame: *mut TrapFrame) -> usize {
let syscall_number;
unsafe {
// A0 is X10, so it's register number 10.
syscall_number = (*frame).regs[10];
// for i in 0..32 {
// print!("regs[{:02}] = 0x{:08x} ", i, (*frame).regs[i]);
// if (i+1) % 4 == 0 {
// println!();
// }
// }
}
match syscall_number {
0 => {
// Exit
// Currently, we cannot kill a process, it runs forever. We will delete
// the process later and free the resources, but for now, we want to get
// used to how processes will be scheduled on the CPU.
mepc + 4
},
1 => {
println!("Test syscall");
mepc + 4
},
_ => {
println!("Unknown syscall number {}", syscall_number);
mepc + 4
}
}
}