-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathprocess.c
More file actions
42 lines (37 loc) · 995 Bytes
/
Copy pathprocess.c
File metadata and controls
42 lines (37 loc) · 995 Bytes
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
#include "process.h"
#include "load.h"
#include "thread.h"
#include "loop.h"
#include "dump.h"
#include "panic.h"
void
process_create(process_t *process)
{
vm_create(&process->vm);
mm_init(&process->mm, &process->vm);
mm_setup_kernel(&process->mm);
mm_setup_stack(&process->mm);
process->thread_count = 1;
process->thread_count_max = 2;
process->thread = (thread_t *)calloc(process->thread_count_max, sizeof(thread_t));
if (process->thread == NULL)
panic("out of memory");
thread_create(&process->thread[0], process);
}
void
process_load(process_t *process, int argc, char *argv[])
{
load_info_t info;
ldr_load(&process->mm, argc, argv, &info);
mm_setup_heap(&process->mm, info.heap);
vcpu_sysregs_t sysregs;
mm_get_sysregs(&process->mm, &sysregs);
thread_init(process->thread, &sysregs, info.entry, info.stack);
dump_guest_stack(&process->mm, info.stack);
}
void
process_run(process_t *process)
{
// mm_dump_range_tree(&process->mm);
thread_run(&process->thread[0]);
}