|
PatchworkOS
|
#include <kernel/sched/loader.h>#include <kernel/cpu/gdt.h>#include <kernel/fs/vfs.h>#include <kernel/log/log.h>#include <kernel/mem/vmm.h>#include <kernel/sched/sched.h>#include <kernel/sched/thread.h>#include <errno.h>#include <stdlib.h>#include <string.h>#include <sys/elf.h>#include <sys/math.h>Go to the source code of this file.
Functions | |
| static void * | loader_load_program (thread_t *thread) |
| static char ** | loader_setup_argv (thread_t *thread) |
| static void | loader_process_entry (void) |
| thread_t * | loader_spawn (const char **argv, priority_t priority, const path_t *cwd) |
| Spawns a child process from an executable file. | |
| SYSCALL_DEFINE (SYS_SPAWN, pid_t, const char **argv, const spawn_fd_t *fds, const char *cwdString, spawn_attr_t *attr) | |
| thread_t * | loader_thread_create (process_t *parent, void *entry, void *arg) |
| Creates a new thread within an existing process. | |
| SYSCALL_DEFINE (SYS_THREAD_CREATE, tid_t, void *entry, void *arg) | |
|
static |
Definition at line 16 of file loader.c.
References process_t::argv, argv_t::buffer, DEREF_DEFER, ELF_IS_VALID, ELF_PHDR_FLAGS_WRITE, ELF_PHDR_TYPE_LOAD, elf_hdr_t::entry, ERR, file, elf_phdr_t::fileSize, elf_phdr_t::flags, MAX, elf_phdr_t::memorySize, memset(), MIN, NULL, elf_phdr_t::offset, PATHNAME, elf_hdr_t::phdrAmount, elf_hdr_t::phdrSize, PML_PRESENT, PML_USER, PML_WRITE, thread_t::process, SEEK_SET, process_t::space, elf_phdr_t::type, UINT64_MAX, vfs_open(), vfs_read(), vfs_seek(), elf_phdr_t::virtAddr, vmm_alloc(), VMM_ALLOC_NONE, and vmm_protect().
Referenced by loader_process_entry().
|
static |
Definition at line 121 of file loader.c.
References argv_t::amount, process_t::argv, argv_t::buffer, interrupt_frame_t::cs, ESPAWNFAIL, thread_t::frame, GDT_CS_RING3, GDT_SS_RING3, process_t::id, loader_jump_to_user_space(), loader_load_program(), loader_setup_argv(), LOG_DEBUG, memset(), NULL, thread_t::process, interrupt_frame_t::rdi, interrupt_frame_t::rflags, RFLAGS_ALWAYS_SET, RFLAGS_INTERRUPT_ENABLE, interrupt_frame_t::rip, ROUND_DOWN, interrupt_frame_t::rsi, interrupt_frame_t::rsp, sched_process_exit(), sched_thread(), and interrupt_frame_t::ss.
Referenced by loader_spawn().
|
static |
Definition at line 103 of file loader.c.
References argv_t::amount, process_t::argv, argv_t::buffer, memcpy(), NULL, PAGE_SIZE, thread_t::process, argv_t::size, stack_pointer_t::top, and thread_t::userStack.
Referenced by loader_process_entry().
| SYSCALL_DEFINE | ( | SYS_SPAWN | , |
| pid_t | , | ||
| const char ** | argv, | ||
| const spawn_fd_t * | fds, | ||
| const char * | cwdString, | ||
| spawn_attr_t * | attr | ||
| ) |
Definition at line 206 of file loader.c.
References atomic_load, CONFIG_MAX_ARGC, CONFIG_MAX_FD, DEREF, EACCES, EBADF, ERR, errno, file, spawn_attr_t::flags, free(), process_t::id, loader_spawn(), MAX_PATH, NULL, PATH_EMPTY, path_put(), spawn_attr_t::priority, PRIORITY_MAX_USER, thread_t::process, sched_push_new_thread(), sched_thread(), SPAWN_FD_END, SPAWN_INHERIT_PRIORITY, thread_copy_from_user_pathname(), thread_copy_from_user_terminated(), thread_free(), vfs_ctx_get_file(), vfs_ctx_set_fd(), vfs_walk(), process_t::vfsCtx, and WALK_NONE.
| SYSCALL_DEFINE | ( | SYS_THREAD_CREATE | , |
| tid_t | , | ||
| void * | entry, | ||
| void * | arg | ||
| ) |
Definition at line 360 of file loader.c.
References ERR, thread_t::id, loader_thread_create(), NULL, thread_t::process, sched_push_new_thread(), sched_thread(), process_t::space, and space_check_access().