AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
execve.c
Go to the documentation of this file.
1
6
7#include <core/system.h>
8#include <core/arch.h>
9#include <sys/proc.h>
10
11/* x86: sets the thread's saved instruction pointer, stack pointer and
12 * flags, which it starts from when it next returns to user mode. The C
13 * library's start code finds `argc` at the stack pointer. */
15{
16 struct x86_thread *arch = thread->arch;
17
18#if ARCH_BITS==32
19 arch->eip = entry;
20 arch->esp = sp;
21 arch->eflags = X86_EFLAGS;
22#else
23 arch->rip = entry;
24 arch->rsp = sp;
25 arch->rflags = X86_EFLAGS;
26#endif
27}
void arch_exec_start(struct thread *thread, uintptr_t entry, uintptr_t sp)
Sets up a thread to start a new program when it next returns to user mode: at its entry point,...
Definition execve.c:15
#define X86_EFLAGS
Definition arch.h:12
__SIZE_TYPE__ uintptr_t
Definition stddef.h:12
A thread.
Definition thread.h:23
void * arch
the architecture's own data: its registers, its kernel stack
Definition thread.h:84
A thread's x86 state: its kernel stack, and where it resumes.
Definition arch.h:16
uintptr_t rip
Definition arch.h:27
uintptr_t rflags
Definition arch.h:30
uintptr_t rsp
Definition arch.h:28