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.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c
index 02c02ae..77bb680 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -157,33 +157,21 @@ res elf_load(const char *name, struct proc *proc)
memory_backup_dir(&prev);
memory_switch_dir(proc->page_dir);
- stac();
-
// Allocate user stack with readonly lower and upper page boundary
- u32 user_stack =
- PAGE_SIZE + (u32)memory_alloc(proc->page_dir, PROC_STACK_SIZE + 2 * PAGE_SIZE,
- MEMORY_USER | MEMORY_CLEAR);
- virtual_remap_readonly(proc->page_dir, memory_range(user_stack - PAGE_SIZE, PAGE_SIZE));
- virtual_remap_readonly(proc->page_dir,
- memory_range(user_stack + PROC_STACK_SIZE, PAGE_SIZE));
+ u32 user_stack = (u32)memory_alloc_with_boundary(proc->page_dir, PROC_STACK_SIZE,
+ MEMORY_CLEAR | MEMORY_USER);
// Allocate kernel stack with readonly lower and upper page boundary
u32 kernel_stack =
- PAGE_SIZE +
- (u32)memory_alloc(proc->page_dir, PROC_STACK_SIZE + 2 * PAGE_SIZE, MEMORY_CLEAR);
- virtual_remap_readonly(proc->page_dir, memory_range(kernel_stack - PAGE_SIZE, PAGE_SIZE));
- virtual_remap_readonly(proc->page_dir,
- memory_range(kernel_stack + PROC_STACK_SIZE, PAGE_SIZE));
-
- proc->user_stack = user_stack + PROC_STACK_SIZE;
- proc->kernel_stack = kernel_stack + PROC_STACK_SIZE;
- proc->regs.ebp = proc->user_stack;
- proc->regs.useresp = proc->user_stack;
+ (u32)memory_alloc_with_boundary(proc->page_dir, PROC_STACK_SIZE, MEMORY_CLEAR);
+
+ proc->stack.user = user_stack + PROC_STACK_SIZE;
+ proc->stack.kernel = kernel_stack + PROC_STACK_SIZE;
+ proc->regs.ebp = proc->stack.user;
+ proc->regs.useresp = proc->stack.user;
proc->regs.eip = header.entry + rand_off;
proc->entry = header.entry + rand_off;
- clac();
-
memory_switch_dir(prev);
return EOK;
}