blob: 1a43b9e5a93b73682e085bc94c2ae9696c36afe5 (
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
|
// MIT License, Copyright (c) 2020 Marvin Borner
#include <cpu.h>
#include <interrupts.h>
#include <load.h>
#include <print.h>
#include <proc.h>
#include <str.h>
#include <sys.h>
int i = 0;
void syscall_handler(struct regs *r)
{
enum sys num = r->eax;
printf("[SYSCALL] %d\n", num);
switch (num) {
case SYS_HALT: {
loop();
break;
}
case SYS_EXEC: {
char *path = (char *)r->ebx;
struct proc *proc = proc_make();
bin_load(path, proc);
strcpy(proc->name, path);
proc_print();
break;
}
default: {
printf("Unknown syscall!\n");
loop();
break;
}
}
}
void syscall_init()
{
idt_set_gate(0x80, (u32)isr128, 0x08, 0x8E);
isr_install_handler(0x80, syscall_handler);
}
|