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
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue