You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
953 B
C

3 years ago
#include "ecall.h"
#include "sched.h"
#include "csr.h"
void ecall_handle_spawn(void* entry, void* args)
3 years ago
{
}
void ecall_handle_sleep(int until)
{
}
void ecall_handle_join(int pid, int timeout)
3 years ago
{
}
void ecall_handle_kill(int pid)
{
}
void ecall_handle_exit(int status)
{
}
void trap_handle_ecall() {
int *regs = get_current_process_registers();
int code = regs[16];
__asm__("ebreak");
HALT(18);
}
void trap_handle(int interrupt_bit, int code, int mtval)
{
if (interrupt_bit) {
switch (code) {
case 7:
scheduler_run_next();
break;
default:
// impossible
HALT(12)
break;
}
} else {
switch (code) {
case 8: // user ecall
trap_handle_ecall();
break;
default:
HALT(13);
}
}
HALT(1);
__builtin_unreachable();
}