Load a very simple ELF and launch it in usermode

This commit is contained in:
Jeremy Soller 2016-09-07 21:16:30 -06:00
commit 850792bbf1
11 changed files with 196 additions and 54 deletions

View file

@ -137,28 +137,6 @@ pub unsafe extern fn kstart() -> ! {
kmain();
}
unsafe fn usermode(ip: usize, sp: usize) {
// Test usermode
asm!("xchg bx, bx
mov rax, 0x2B
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
push rax
push rbx
pushfq
mov rax, 0x23
push rax
push rcx
iretq"
:
: "{rbx}"(sp), "{rcx}"(ip)
: "rax", "rbx", "rcx", "sp"
: "intel", "volatile");
}
/// Entry to rust for an AP
pub unsafe extern fn kstart_ap(stack_start: usize, stack_end: usize) -> ! {
{
@ -223,3 +201,25 @@ pub unsafe extern fn kstart_ap(stack_start: usize, stack_end: usize) -> ! {
kmain_ap(ap_number);
}
pub unsafe fn usermode(ip: usize, sp: usize) {
// Test usermode
asm!("xchg bx, bx
mov rax, 0x2B
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
push rax
push rbx
pushfq
mov rax, 0x23
push rax
push rcx
iretq"
:
: "{rbx}"(sp), "{rcx}"(ip)
: "rax", "rbx", "rcx", "sp"
: "intel", "volatile");
}