|
ginnOS
The reference: libc, the libraries and the kernel
|
x86 implementation of the arch-neutral context-switch helpers. More...
Functions | |
| void | isr_fork_return (void) |
| void | arch_setup_initial_stack (process_t *proc, void(*entry_fn)(void)) |
| prepare a process's kernel stack so its first arch_context_switch() into it begins executing entry_fn. | |
| void | arch_setup_fork_stack (process_t *child, const struct registers *regs, uintptr_t user_sp) |
| prepare a forked child's kernel stack so its first arch_context_switch() into it returns to user mode with the parent's registers, except that the syscall returns 0 (and, for a thread, the user stack is its own). | |
x86 implementation of the arch-neutral context-switch helpers.
arch_context_switch itself is pure assembly (context_switch.asm). the one piece that needs C is priming a brand-new kernel stack so that the first switch into a process "returns" into its entry function. that layout mirrors exactly what arch_context_switch pushes, so it lives next to the asm here.
|
extern |
| void arch_setup_initial_stack | ( | process_t * | proc, |
| void(* | entry_fn )(void) ) |
prepare a process's kernel stack so its first arch_context_switch() into it begins executing entry_fn.
entry_fn takes no arguments and never returns. on return, proc->kernel_esp points at the prepared stack.
| proc | the process whose kernel stack to prime (uses kernel_stack). |
| entry_fn | the function the process should start running. |
prepare a forked child's kernel stack so its first arch_context_switch() into it returns to user mode with the parent's registers, except that the syscall returns 0 (and, for a thread, the user stack is its own).
| child | the new process (uses kernel_stack, sets kernel_esp). |
| regs | the parent's saved user registers (its fork syscall frame). |
| user_sp | the child's user stack pointer, or 0 for the parent's. |