aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/load.c
diff options
context:
space:
mode:
authorMarvin Borner2021-01-14 00:18:44 +0100
committerMarvin Borner2021-01-14 00:18:44 +0100
commit388b3fa1bd8af8c5df6aef8447ffd2a8b2cb9300 (patch)
tree2effeb407e96f4e43dc5332346c6f9d378f9b8ef /kernel/features/load.c
parent91abed9333241731d0cd877beba4e2d4675989c8 (diff)
Added kernel idle process
Diffstat (limited to 'kernel/features/load.c')
-rw-r--r--kernel/features/load.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c
index f7fc1a5..743c009 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -1,28 +1,30 @@
// MIT License, Copyright (c) 2020 Marvin Borner
-#include <assert.h>
-#include <cpu.h>
-#include <def.h>
#include <fs.h>
#include <load.h>
#include <mem.h>
-#include <proc.h>
#include <str.h>
+void proc_load(struct proc *proc, void *data)
+{
+ u32 stack = (u32)malloc(0x2000) + 0x1000;
+
+ proc->regs.ebp = (u32)stack;
+ proc->regs.useresp = (u32)stack;
+ proc->regs.eip = (u32)data;
+}
+
int bin_load(char *path, struct proc *proc)
{
// TODO: Remove hardcoded filesize
struct stat s = { 0 };
vfs_stat(path, &s);
char *data = malloc(s.size);
- vfs_read(path, data, 0, s.size);
-
- u32 stack = (u32)malloc(0x2000) + 0x1000;
+ if (!vfs_read(path, data, 0, s.size))
+ return 0;
- proc->regs.ebp = (u32)stack;
- proc->regs.useresp = (u32)stack;
- proc->regs.eip = (u32)data;
strcpy(proc->name, path);
+ proc_load(proc, data);
- return data ? 0 : 1;
+ return 1;
}