35 lines
790 B
C++
35 lines
790 B
C++
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <errno.h>
|
|
|
|
#include "scheduler.hh"
|
|
#include "globals.hh"
|
|
#include "cortexa8.hh"
|
|
#include "syscall.hh"
|
|
|
|
extern cortexa8::thread_cb *_current_thread_cb;
|
|
|
|
void syscall_handler(int num) {
|
|
int32_t rval = 0;
|
|
|
|
//printf("Syscall %d PC: %.8lx SP: %.8lx\n", num, _current_thread_cb->regs[15], _current_thread_cb->regs[13]);
|
|
|
|
switch(num) {
|
|
case SYSCALL_EXIT:
|
|
global::scheduler->exit();
|
|
break;
|
|
case SYSCALL_YIELD:
|
|
global::scheduler->yield();
|
|
break;
|
|
default:
|
|
printf("WARNING: Unknown syscall %d\n", num);
|
|
printf("PC: %.8lx SP: %.8lx\n", _current_thread_cb->regs[15], _current_thread_cb->regs[13]);
|
|
rval = -EINVAL;
|
|
}
|
|
|
|
// Write return value
|
|
_current_thread_cb->regs[0] = rval;
|
|
|
|
global::scheduler->update();
|
|
}
|