Add syscall handler, still work in progress
Add elf files
This commit is contained in:
parent
71a17070b1
commit
5588c38178
1 changed files with 263 additions and 18 deletions
|
|
@ -20,6 +20,7 @@ pub unsafe fn init() {
|
|||
entry.set_flags(IDT_PRESENT | IDT_RING_0 | IDT_INTERRUPT);
|
||||
entry.set_offset(8, blank as usize);
|
||||
}
|
||||
IDT[0x80].set_offset(8, syscall as usize);
|
||||
IDTR.set_slice(&IDT);
|
||||
|
||||
init_ap();
|
||||
|
|
@ -54,6 +55,29 @@ interrupt_error!(page_fault, {
|
|||
}
|
||||
});
|
||||
|
||||
#[naked]
|
||||
pub unsafe extern fn syscall() {
|
||||
extern {
|
||||
fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> usize;
|
||||
}
|
||||
|
||||
let a;
|
||||
let b;
|
||||
let c;
|
||||
let d;
|
||||
let e;
|
||||
let f;
|
||||
asm!("" : "={rax}"(a), "={rbx}"(b), "={rcx}"(c), "={rdx}"(d), "={rsi}"(e), "={rdi}"(f)
|
||||
: : : "intel", "volatile");
|
||||
|
||||
let a = syscall(a, b, c, d, e, f);
|
||||
|
||||
asm!("" : : "{rax}"(a) : : "intel", "volatile");
|
||||
|
||||
// Pop scratch registers, error code, and return
|
||||
asm!("iretq" : : : : "intel", "volatile");
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub flags IdtFlags: u8 {
|
||||
const IDT_PRESENT = 1 << 7,
|
||||
|
|
|
|||
Loading…
Reference in a new issue