Load a very simple ELF and launch it in usermode
This commit is contained in:
parent
398838dc1b
commit
850792bbf1
11 changed files with 201 additions and 59 deletions
|
@ -1,22 +1,29 @@
|
|||
#[naked]
|
||||
pub unsafe extern fn syscall() {
|
||||
extern {
|
||||
fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> usize;
|
||||
#[inline(never)]
|
||||
unsafe fn inner() {
|
||||
extern {
|
||||
fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> usize;
|
||||
}
|
||||
|
||||
let mut a;
|
||||
{
|
||||
let b;
|
||||
let c;
|
||||
let d;
|
||||
let e;
|
||||
let f;
|
||||
asm!("xchg bx, bx" : "={rax}"(a), "={rbx}"(b), "={rcx}"(c), "={rdx}"(d), "={rsi}"(e), "={rdi}"(f)
|
||||
: : : "intel", "volatile");
|
||||
|
||||
a = syscall(a, b, c, d, e, f);
|
||||
}
|
||||
|
||||
asm!("xchg bx, bx" : : "{rax}"(a) : : "intel", "volatile");
|
||||
}
|
||||
|
||||
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");
|
||||
inner();
|
||||
|
||||
let a = syscall(a, b, c, d, e, f);
|
||||
|
||||
asm!("" : : "{rax}"(a) : : "intel", "volatile");
|
||||
|
||||
// Pop scratch registers, error code, and return
|
||||
// Interrupt return
|
||||
asm!("iretq" : : : : "intel", "volatile");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue