diff --git a/src/tasking.rs b/src/tasking.rs index d8adeb0..d800efd 100644 --- a/src/tasking.rs +++ b/src/tasking.rs @@ -64,17 +64,17 @@ extern "C" fn switch_to_asm_exit(next_stack: *mut usize) { extern "C" fn task_init() { unsafe { asm!( - "pop rcx", - "pop rbx", - "push 43", - "push rcx", - "pushfq", + "pop rcx", // Get the user stack pointer + "pop rbx", // Get the entry point + "push 43", // Push the stack segment selector - same as data + "push rcx", // Push the stack pointer + "pushfq", // Get the flags into RAX "pop rax", - "or rax, 0x200", - "push rax", - "push 51", - "push rbx", - "iretq", + "or rax, 0x200", // Enable interrupts in the stored copy + "push rax", // Push the flags + "push 51", // Push the code selector + "push rbx", // Push the entry point + "iretq", // Return from the fake interrupt and enter user mode options(noreturn) ) }