From 8b949ba1f1f2b1eed386c517bf26c99052bc2b5a Mon Sep 17 00:00:00 2001 From: pjht Date: Sun, 18 Aug 2024 15:21:45 -0500 Subject: [PATCH] Explain task_init --- src/tasking.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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) ) }