|
PatchworkOS
|
Program loading and user stack management. More...
Functions | |
| NORETURN void | loader_jump_to_user_space (thread_t *thread) |
| Performs the initial jump to userspace. | |
| thread_t * | loader_spawn (const char **argv, priority_t priority, const path_t *cwd) |
| Spawns a child process from an executable file. | |
| thread_t * | loader_thread_create (process_t *parent, void *entry, void *arg) |
| Creates a new thread within an existing process. | |
Program loading and user stack management.
The loader is responsible for loading programs into memory and the jump to userspace.
Performs the initial jump to userspace.
| thread | The curently running thread that will jump to userspace. |
Referenced by loader_process_entry().
| thread_t * loader_spawn | ( | const char ** | argv, |
| priority_t | priority, | ||
| const path_t * | cwd | ||
| ) |
Spawns a child process from an executable file.
| argv | A null-terminated array of strings storing the arguments to be passed to usespace and the executable to be loaded in argv[0]. |
| priority | The priority of the first thread within the child process. |
| cwd | The current working directory for the child process, if cwd is null then the child inherits the working directory of the parent. |
NULL and errno is set. Definition at line 154 of file loader.c.
References assert, interrupt_frame_t::cs, DEREF_DEFER, EINVAL, EISDIR, ERR, errno, thread_t::frame, GDT_CS_RING0, GDT_SS_RING0, process_t::id, info, INODE_FILE, thread_t::kernelStack, loader_process_entry(), LOG_INFO, NULL, pathname_init(), process_new(), interrupt_frame_t::rflags, RFLAGS_ALWAYS_SET, RFLAGS_INTERRUPT_ENABLE, interrupt_frame_t::rip, interrupt_frame_t::rsp, sched_process(), interrupt_frame_t::ss, thread_new(), stack_pointer_t::top, and vfs_stat().
Referenced by init_process_spawn(), and SYSCALL_DEFINE().
Creates a new thread within an existing process.
| parent | The parent process for the new thread. |
| entry | The entry point address for the new thread. |
| arg | An argument to pass to the entry point. |
NULL and errno is set. Definition at line 343 of file loader.c.
References interrupt_frame_t::cs, thread_t::frame, GDT_CS_RING3, GDT_SS_RING3, NULL, interrupt_frame_t::rdi, interrupt_frame_t::rflags, RFLAGS_ALWAYS_SET, RFLAGS_INTERRUPT_ENABLE, interrupt_frame_t::rip, interrupt_frame_t::rsp, interrupt_frame_t::ss, thread_new(), stack_pointer_t::top, and thread_t::userStack.
Referenced by SYSCALL_DEFINE().