aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/load.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/features/load.c')
-rw-r--r--kernel/features/load.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c
index 8a4aae3..610abf8 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -3,14 +3,19 @@
#include <fs.h>
#include <load.h>
#include <mem.h>
+#include <mm.h>
#include <str.h>
+#define PROC_STACK_SIZE 0x4000
+
void proc_load(struct proc *proc, void *data)
{
- u32 stack = (u32)malloc(0x2000) + 0x1000;
+ u32 stack;
+ memory_alloc(proc->page_dir, PROC_STACK_SIZE, MEMORY_CLEAR, &stack);
+ u32 ptr = stack + PROC_STACK_SIZE - 1;
- proc->regs.ebp = (u32)stack;
- proc->regs.useresp = (u32)stack;
+ proc->regs.ebp = (u32)ptr;
+ proc->regs.useresp = (u32)ptr;
proc->regs.eip = (u32)data;
proc->entry = (u32)data;
}
@@ -19,12 +24,13 @@ int bin_load(const char *path, struct proc *proc)
{
struct stat s = { 0 };
vfs_stat(path, &s);
- char *data = malloc(s.size);
- if (!vfs_read(path, data, 0, s.size))
+ u32 data;
+ memory_alloc(proc->page_dir, PAGE_ALIGN_UP(s.size), MEMORY_CLEAR, &data);
+ if (!vfs_read(path, (void *)data, 0, s.size))
return 1;
strcpy(proc->name, path);
- proc_load(proc, data);
+ proc_load(proc, (void *)data);
return 0;
}