Add vsyscall emulation

master
Harry Cheng 5 years ago
parent f4c31edab0
commit 17d447ff6f

@ -133,6 +133,10 @@ fn page_fault(tf: &mut TrapFrame) {
asm!("mov %cr2, $0" : "=r" (addr));
}
if vsyscall(addr, tf) {
return;
}
bitflags! {
struct PageError: u8 {
const PRESENT = 1 << 0;
@ -162,6 +166,20 @@ fn page_fault(tf: &mut TrapFrame) {
error(tf);
}
fn vsyscall(addr: usize, tf: &mut TrapFrame) -> bool {
let id: usize = match addr {
0xffffffffff600000 => 96,
_ => return false
};
debug!("vsyscall emulation");
let caller = unsafe { (tf.rsp as *mut u32).read() };
let ret = crate::syscall::syscall(id, [tf.rdi, tf.rsi, tf.rdx, tf.r10, tf.r8, tf.r9], tf);
tf.rip = caller as usize;
tf.rax = ret as usize;
tf.rsp += 8;
true
}
fn keyboard() {
use crate::arch::driver::keyboard;
use pc_keyboard::{DecodedKey, KeyCode};

Loading…
Cancel
Save