33 lines
781 B
C
33 lines
781 B
C
#include "klibc.h"
|
|
#include "stdarg.h"
|
|
#include "syscall.h"
|
|
#include "thread.h"
|
|
|
|
int syscallExecute(int syscallId, const struct cpu_state *userCtx){
|
|
|
|
int ret;
|
|
|
|
switch (syscallId) {
|
|
case SYSCALL_ID_EXIT:
|
|
uint status;
|
|
ret = syscallGet1arg(userCtx, &status);
|
|
if(ret != 0)
|
|
break;
|
|
threadExit();
|
|
assert(0);
|
|
break;
|
|
case SYSCALL_ID_YOLO:
|
|
ret = printf("YOLO FROM USERSPACE\n");
|
|
break;
|
|
case SYSCALL_ID_PUTC:
|
|
unsigned int c;
|
|
ret = syscallGet1arg(userCtx, &c);
|
|
putc(c);
|
|
break;
|
|
default:
|
|
printf("Unknon syscall id %d\n", syscallId);
|
|
ret = -ENOENT;
|
|
}
|
|
return ret;
|
|
}
|