feature (syscalls): changed 'nx_fread' and 'nx_fwrite' to match updated sysabi
This commit is contained in:
parent
406dc0ee9e
commit
23af4ccdab
|
@ -44,28 +44,23 @@ void syscall_handle_nx_fread(cpu_state_T* state) {
|
||||||
case FILE_DESCRIPTOR_INVALID:
|
case FILE_DESCRIPTOR_INVALID:
|
||||||
case FILE_DESCRIPTOR_STDOUT:
|
case FILE_DESCRIPTOR_STDOUT:
|
||||||
case FILE_DESCRIPTOR_STDERR: {
|
case FILE_DESCRIPTOR_STDERR: {
|
||||||
state->rax = STATUS_RESOURCE_NOT_AVAILABLE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case FILE_DESCRIPTOR_STDIN: {
|
case FILE_DESCRIPTOR_STDIN: {
|
||||||
read_bytes = pipe_read(&process->stdin, mem, n);
|
read_bytes = pipe_read(&process->stdin, mem, n);
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd);
|
vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd);
|
||||||
|
|
||||||
// TODO: set read_bytes
|
read_bytes = vfs_file_read(node, offset, n, mem);
|
||||||
|
|
||||||
vfs_file_read(node, offset, n, mem);
|
|
||||||
|
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: return read_bytes to process
|
|
||||||
|
state->rax = read_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
|
@ -80,7 +75,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
switch (fd) {
|
switch (fd) {
|
||||||
case FILE_DESCRIPTOR_INVALID:
|
case FILE_DESCRIPTOR_INVALID:
|
||||||
case FILE_DESCRIPTOR_STDIN: {
|
case FILE_DESCRIPTOR_STDIN: {
|
||||||
state->rax = STATUS_RESOURCE_NOT_AVAILABLE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +82,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
if (process->stderr != NULL) {
|
if (process->stderr != NULL) {
|
||||||
written_bytes = pipe_write(process->stderr, mem, n);
|
written_bytes = pipe_write(process->stderr, mem, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,23 +89,18 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
if (process->stdout != NULL) {
|
if (process->stdout != NULL) {
|
||||||
written_bytes = pipe_write(process->stdout, mem, n);
|
written_bytes = pipe_write(process->stdout, mem, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd);
|
vfs_node_T* node = file_descriptor_resolve(scheduler_get_current_process()->fd_array, fd);
|
||||||
|
|
||||||
// TODO: set written_bytes
|
written_bytes = vfs_file_write(node, offset, n, mem);
|
||||||
|
|
||||||
vfs_file_write(node, offset, n, mem);
|
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: return written_bytes to process
|
state->rax = written_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fdelete(cpu_state_T* state) {
|
void syscall_handle_nx_fdelete(cpu_state_T* state) {
|
||||||
|
|
Loading…
Reference in New Issue