summaryrefslogtreecommitdiff
path: root/src/library/grapes/syscall.c
blob: 38adc01838f3bb2acdea481c3c61a02b7e5bf36b (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
#include "syscall.h"

static int call(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f) {
	unsigned ret;
	asm volatile("int $64" : "=a"(ret) : "a"(a), "b"(b), "c"(c), "d"(d), "S"(e), "D"(f));
	return ret;
}

void thread_exit() {
	call(0, 0, 0, 0, 0, 0);
}

void schedule() {
	call(1, 0, 0,0, 0, 0);
}

void thread_sleep(int time) {
	call(2, time, 0, 0, 0, 0);
}

void process_exit(int retval) {
	call(3, retval, 0, 0, 0, 0);
}

void printk(char* str) {
	call(4, (unsigned)str, 0, 0, 0, 0);
}

void thread_new(void (*entry)(void*), void *data) {
	call(5, (unsigned)entry, (unsigned)data, 0, 0, 0);
}

void irq_wait(int number) {
	call(6, number, 0, 0, 0, 0);
}