Explain task_init

This commit is contained in:
pjht 2024-08-18 15:21:45 -05:00
parent b9097759c8
commit 8b949ba1f1
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -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)
)
}