Implement syscalls, hello world from userspace
This commit is contained in:
27
kernel/syscall/syscall.c
Normal file
27
kernel/syscall/syscall.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
#include "errors.h"
|
||||
#include "dlmalloc/malloc.h"
|
||||
#include "kprintf.h"
|
||||
#include "proc/proc.h"
|
||||
|
||||
int32_t SYSCALL2(sys_debugprint, string1, len) {
|
||||
char *buf = dlmalloc(len);
|
||||
if (buf == NULL) {
|
||||
return E_NOMEMORY;
|
||||
}
|
||||
ksnprintf(buf, len, "%s", string1);
|
||||
kprintf("%s\n", buf);
|
||||
dlfree(buf);
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t SYSCALL0(sys_quitproc) {
|
||||
proc_killself();
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
||||
[SYS_DEBUGPRINT] = &sys_debugprint,
|
||||
[SYS_QUITPROC] = &sys_quitproc,
|
||||
};
|
Reference in New Issue
Block a user