aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/load.c
blob: 14a308602c0f8ef3b3038cae0162dd17cc10d7c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// MIT License, Copyright (c) 2020 Marvin Borner

#include <def.h>
#include <fs.h>
#include <mem.h>
#include <proc.h>
#include <str.h>

void bin_load(char *path, struct proc *proc)
{
	char *data = read_file(path);
	u32 stack = (u32)malloc(0x1000) + 0x1000;

	proc->regs.ebp = (u32)stack;
	proc->regs.esp = (u32)stack;
	proc->regs.useresp = (u32)stack;
	proc->regs.eip = (u32)data;
	strcpy(proc->name, path + 1);
}