blob: 3f6da6d91c4bd173592884ffbbe8e093522cedf9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/**
* @file proc.c
* Process handling, might be merged into \ref common/tcb.c.
*/
#include <apos/elf.h>
#include <apos/proc.h>
#include <apos/conf.h>
#include <apos/string.h>
#include <apos/initrd.h>
#include <arch/arch.h>
#include <arch/proc.h>
stat_t prepare_proc(struct tcb *t, vm_t bin, vm_t interp)
{
vm_t entry = load_elf(t, bin, interp);
if (!entry)
return ERR_INVAL;
alloc_stacks(t);
prepare_thread(t);
set_return(entry);
return OK;
}
stat_t init_proc(void *fdt)
{
init_tcbs();
/* TODO: cleanup or something */
struct tcb *t = create_proc(NULL);
if (!t)
return ERR_OOMEM;
/* set current tcb */
use_tcb(t);
use_vmem(t->b_r);
/* allocate stacks after ELF file to make sure nothing of importance
* clashes */
return prepare_proc(t, get_init_base(fdt), 0);
}
|