|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
Functions to transfer execution to ring-3 and set up userspace argument arrays. More...
Functions | |
| void | enter_ring3 (uint64_t entry_rip, uint64_t user_rsp) |
| Builds an IRETQ stack frame (SS, RSP, RFLAGS=0x202, CS=user_cs, RIP) and executes IRETQ, transferring control to @entry_rip at CPL=3. Enables interrupts (RFLAGS.IF=1) as part of the frame. Does not return — execution continues in ring 3 at @entry_rip. | |
| int | copy_string_array_to_user (struct thread *t, char *const *arr, uint64_t *user_ptr) |
| Copies each string to the user stack, builds a pointer array below the strings, and writes the address of that array to *@user_ptr. Used by SYS_execve to pass argv/envp to the new process image. | |
Functions to transfer execution to ring-3 and set up userspace argument arrays.
Copies each string to the user stack, builds a pointer array below the strings, and writes the address of that array to *@user_ptr. Used by SYS_execve to pass argv/envp to the new process image.
copy_string_array_to_user() - Copy a NULL-terminated string array into a thread's user stack.
| t | Destination thread whose user stack will receive the strings. |
| arr | NULL-terminated array of C strings (e.g. argv[] or envp[]). |
| user_ptr | Output; set to the user-space address of the copied pointer array. |


Builds an IRETQ stack frame (SS, RSP, RFLAGS=0x202, CS=user_cs, RIP) and executes IRETQ, transferring control to @entry_rip at CPL=3. Enables interrupts (RFLAGS.IF=1) as part of the frame. Does not return — execution continues in ring 3 at @entry_rip.
enter_ring3() - Switch from ring 0 to ring 3 via IRETQ.
| entry_rip | Ring-3 instruction pointer to jump to (e.g. 0x400000 for ELF entry). |
| user_rsp | Ring-3 stack pointer (e.g. USER_STACK_TOP - 8). |
