aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/tasks
diff options
context:
space:
mode:
authorMarvin Borner2020-04-29 00:39:24 +0200
committerMarvin Borner2020-04-29 00:39:24 +0200
commit50858d043cbd6f61cc091c6772f981ca2d6cca6b (patch)
tree82afcc2daf9c4b67d29832923283654913490d06 /src/kernel/tasks
parent34c752f6fe4f71169172f1b3e46b1eddf69eba6e (diff)
Added basic exec calls for init and started libc
Diffstat (limited to 'src/kernel/tasks')
-rw-r--r--src/kernel/tasks/process.c34
-rw-r--r--src/kernel/tasks/process.h6
2 files changed, 38 insertions, 2 deletions
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index 4cb8d8c..a4c525a 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -8,6 +8,7 @@
#include <kernel/memory/paging.h>
#include <kernel/memory/alloc.h>
#include <kernel/timer/timer.h>
+#include <kernel/fs/elf.h>
uint32_t pid = 0;
struct process *root;
@@ -203,4 +204,35 @@ struct process *process_make_new()
proc->pid = pid++;
return proc;
-} \ No newline at end of file
+}
+
+uint32_t kexec(char *path)
+{
+ struct process *proc = elf_load(path);
+ if (proc == NULL)
+ return -1;
+
+ // TODO: Add stdin etc support (?)
+ proc->stdin = NULL;
+ proc->stdout = NULL;
+ proc->stderr = NULL;
+ process_init(proc);
+}
+
+uint32_t uexec(char *path)
+{
+ process_suspend(current_proc->pid);
+
+ struct process *proc = elf_load(path);
+ if (proc == NULL)
+ return -1;
+
+ proc->stdin = NULL;
+ proc->stdout = NULL;
+ proc->stderr = NULL;
+
+ proc->parent = current_proc;
+ proc->gid = current_proc->pid;
+ process_spawn(proc);
+ return 0;
+}
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index 1a5c607..5230ea4 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -54,6 +54,10 @@ void process_init(struct process *proc);
struct process *process_make_new();
+uint32_t kexec(char *path);
+
+uint32_t uexec(char *path);
+
extern struct process *current_proc;
extern uint32_t stack_hold;
@@ -70,4 +74,4 @@ extern uint32_t stack_hold;
#define WAIT_ERROR (-1)
#define WAIT_OKAY 0
-#endif \ No newline at end of file
+#endif