|
|
|
@ -5,7 +5,7 @@
|
|
|
|
|
#include "io.h"
|
|
|
|
|
|
|
|
|
|
// this type is only used here, therefore we don't need it in the ktypes header
|
|
|
|
|
typedef optional_int (*ecall_handler)(int*,ProcessControlBlock*);
|
|
|
|
|
typedef optional_int (*ecall_handler)(int*, ProcessControlBlock*);
|
|
|
|
|
|
|
|
|
|
ecall_handler ecall_table[ECALL_TABLE_LEN] = { 0 };
|
|
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ optional_int ecall_handle_spawn_thread(int* args_ptr, ProcessControlBlock* pcb)
|
|
|
|
|
void* args = (void*) args_ptr[1]; // a1
|
|
|
|
|
//int flags = args_ptr[2]; // a2
|
|
|
|
|
|
|
|
|
|
optional_pcbptr pcb_or_err = create_new_thread(pcb, entry, args, 1<<14);
|
|
|
|
|
optional_pcbptr pcb_or_err = create_new_thread(pcb, entry, args, 1 << 14);
|
|
|
|
|
|
|
|
|
|
if (has_error(pcb_or_err))
|
|
|
|
|
return (optional_int) { .error = pcb_or_err.error };
|
|
|
|
@ -31,6 +31,7 @@ optional_int ecall_handle_spawn_thread(int* args_ptr, ProcessControlBlock* pcb)
|
|
|
|
|
optional_int ecall_handle_sleep(int* args, ProcessControlBlock* pcb)
|
|
|
|
|
{
|
|
|
|
|
int len = args[0];
|
|
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
return (optional_int) { .error = EINVAL };
|
|
|
|
|
}
|
|
|
|
@ -59,10 +60,12 @@ optional_int ecall_handle_join(int* args, ProcessControlBlock* pcb)
|
|
|
|
|
pcb->waiting_for_process = target;
|
|
|
|
|
|
|
|
|
|
int timeout = args[1];
|
|
|
|
|
|
|
|
|
|
if (timeout <= 0)
|
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|
|
|
|
|
|
|
unsigned int len = (unsigned int) timeout;
|
|
|
|
|
|
|
|
|
|
pcb->asleep_until = read_time() + len;
|
|
|
|
|
|
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|
@ -181,5 +184,5 @@ void init_ecall_table()
|
|
|
|
|
void handle_exception(int ecode, int mtval)
|
|
|
|
|
{
|
|
|
|
|
dbgln("exception encountered!", 17);
|
|
|
|
|
__asm__("ebreak");
|
|
|
|
|
__asm__ ("ebreak");
|
|
|
|
|
}
|
|
|
|
|