blob: 20494de5bba11131d2edfb73e37629e1b3e50a25 (
plain)
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
43
44
45
46
47
|
#include <errno.h>
#include <kernel/con.h>
#include <kernel/sched.h>
#include <signal.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
int sys_puts(char *s) {
printk("[%04x] ", ctask->pid);
return printk(s);
}
time_t sys_time(void) {
return ticks / 100;
}
pid_t sys_getpid(void) {
return ctask->pid;
}
void *sys_getpdir(void) {
uint32_t pdir;
__asm__ ("mov %%cr3, %%eax" : "=a" (pdir));
return (void*) pdir;
}
void *sys_signal(int sig, void (*func)(int)) {
if(sig < 0 || sig >= NRSIG)
return NULL;
/* SIGKILL and SIGSTOP cannot be caught */
if(sig == SIGKILL || sig == SIGSTOP)
return NULL;
printk("Task %x registered new signal handler 0x%08x for signal %01x\n", ctask->pid, (uint32_t) func, sig);
ctask->sig_handlers[sig] = func;
return func;
}
int sys_dummy(void) {
return -ENOSYS;
}
|