Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion kernel/process/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ uint64_t syscall_sleep(process_t *ctx){
return 0;
}

uint64_t syscall_yield(process_t *ctx){
syscall_depth--;
switch_proc(YIELD);
return 0;
}

uint64_t syscall_halt(process_t *ctx){
kprintf("Process has ended with code %i",ctx->PROC_X0);
syscall_depth--;
Expand Down Expand Up @@ -186,7 +192,7 @@ uint64_t syscall_fopen(process_t *ctx){
char path[255];
if (!(ctx->PROC_PRIV) && strstart("/resources/", req_path, true) == 11){
string_format_buf(path, sizeof(path),"%s%s", ctx->bundle, req_path);
} else memcpy(path, req_path, strlen(req_path, 0));
} else memcpy(path, req_path, strlen(req_path, 0) + 1);
//TODO: Restrict access to own bundle, own fs and require privilege escalation for full-ish filesystem access
file *descriptor = (file*)ctx->PROC_X1;
return open_file(path, descriptor);
Expand Down Expand Up @@ -232,6 +238,7 @@ syscall_entry syscalls[] = {
[GPU_CHAR_SIZE_CODE] = syscall_char_size,
[RESIZE_DRAW_CTX_CODE] = syscall_gpu_resize_ctx,
[SLEEP_CODE] = syscall_sleep,
[PROCESS_YIELD_CODE] = syscall_yield,
[HALT_CODE] = syscall_halt,
[EXEC_CODE] = syscall_exec,
[GET_TIME_CODE] = syscall_get_time,
Expand Down
1 change: 1 addition & 0 deletions shared/syscalls/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern bool read_event(kbd_event *event);
extern void get_mouse_status(mouse_input *in);

extern void sleep(uint64_t time);
extern void process_yield();
extern void halt(uint32_t exit_code);
extern uint16_t exec(const char* prog_name, int argc, const char* argv[]);

Expand Down