From 23af4ccdab68fa7cf300dea1cf17c9a09a7370bf Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 2 May 2023 18:07:31 +0200 Subject: [PATCH] feature (syscalls): changed 'nx_fread' and 'nx_fwrite' to match updated sysabi --- src/platform/syscall.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/platform/syscall.c b/src/platform/syscall.c index bccc3a5..3e3800e 100644 --- a/src/platform/syscall.c +++ b/src/platform/syscall.c @@ -44,28 +44,23 @@ void syscall_handle_nx_fread(cpu_state_T* state) { case FILE_DESCRIPTOR_INVALID: case FILE_DESCRIPTOR_STDOUT: case FILE_DESCRIPTOR_STDERR: { - state->rax = STATUS_RESOURCE_NOT_AVAILABLE; break; } case FILE_DESCRIPTOR_STDIN: { read_bytes = pipe_read(&process->stdin, mem, n); - state->rax = STATUS_SUCCESS; break; } default: { vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd); - // TODO: set read_bytes - - vfs_file_read(node, offset, n, mem); - - state->rax = STATUS_SUCCESS; + read_bytes = vfs_file_read(node, offset, n, mem); break; } } - // TODO: return read_bytes to process + + state->rax = read_bytes; } void syscall_handle_nx_fwrite(cpu_state_T* state) { @@ -80,7 +75,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) { switch (fd) { case FILE_DESCRIPTOR_INVALID: case FILE_DESCRIPTOR_STDIN: { - state->rax = STATUS_RESOURCE_NOT_AVAILABLE; break; } @@ -88,8 +82,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) { if (process->stderr != NULL) { written_bytes = pipe_write(process->stderr, mem, n); } - - state->rax = STATUS_SUCCESS; break; } @@ -97,23 +89,18 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) { if (process->stdout != NULL) { written_bytes = pipe_write(process->stdout, mem, n); } - - state->rax = STATUS_SUCCESS; break; } default: { vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd); - // TODO: set written_bytes - - vfs_file_write(node, offset, n, mem); - state->rax = STATUS_SUCCESS; + written_bytes = vfs_file_write(node, offset, n, mem); break; } } - // TODO: return written_bytes to process + state->rax = written_bytes; } void syscall_handle_nx_fdelete(cpu_state_T* state) {