sycall: conform to POSIX
This commit is contained in:
parent
22c07fb544
commit
4a3e33dc05
5 changed files with 14 additions and 15 deletions
|
@ -39,8 +39,8 @@ syscall:
|
|||
mov r12, r3 /* arg3 */
|
||||
mov r2, r12
|
||||
|
||||
pop {r3}
|
||||
mov r12, r3
|
||||
pop {r4}
|
||||
mov r12, r4
|
||||
|
||||
/* stack params begin at 12 bytes offset because we already pushed three registers */
|
||||
ldr r3, [sp, #12] /* arg4 */
|
||||
|
|
|
@ -27,8 +27,8 @@ extern const int (*sys_table[NSYSCALLS])(sysarg_t arg1, sysarg_t arg2, sysarg_t
|
|||
/* catchall handler that returns -ENOSYS */
|
||||
int sys_stub(void);
|
||||
|
||||
int sys_read(int fd, void *buf, size_t len, size_t off);
|
||||
int sys_write(int fd, const void *buf, size_t len, size_t off);
|
||||
int sys_read(int fd, void *buf, size_t len);
|
||||
int sys_write(int fd, const void *buf, size_t len);
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Felix Kopp <sandtler@sandtler.club>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
|
||||
ssize_t read(int fildes, void *buf, size_t nbyte);
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||
|
||||
/*
|
||||
|
|
|
@ -10,25 +10,25 @@
|
|||
#include <stddef.h>
|
||||
#include <toolchain.h>
|
||||
|
||||
ssize_t sys_write(int fd, __user const void *buf, size_t len, size_t off)
|
||||
ssize_t sys_write(int fd, __user const void *buf, size_t len)
|
||||
{
|
||||
ssize_t ret;
|
||||
void *copy;
|
||||
|
||||
if (fd != 1) /* we only support stdout (serial console) right now ... */
|
||||
return -ENOTSUP;
|
||||
if (off != 0) /* ... and the serial console doesn't support seeking */
|
||||
return -ESPIPE;
|
||||
if (fd != 1) /* we only support stdout (serial console) right now */
|
||||
return -EBADF;
|
||||
|
||||
copy = malloc(len);
|
||||
if (copy == NULL)
|
||||
return -ENOMEM;
|
||||
ret = (ssize_t)copy_from_user(copy, buf, (size_t)len);
|
||||
ret = (ssize_t)copy_from_user(copy, buf, len);
|
||||
|
||||
/* TODO: reschedule if blocking */
|
||||
ret = serial_write(serial_default_interface, copy, (size_t)ret);
|
||||
|
||||
return ret;
|
||||
free(copy);
|
||||
|
||||
return 0x42424242;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -8,10 +8,9 @@
|
|||
#include <toolchain.h>
|
||||
#include <unistd.h>
|
||||
|
||||
__shared ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
|
||||
__shared ssize_t read(int fildes, void *buf, size_t nbyte)
|
||||
{
|
||||
return syscall(SYSCALL_WRITE, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte,
|
||||
(sysarg_t)offset, 0, 0);
|
||||
return syscall(SYSCALL_READ, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte, 0, 0, 0);
|
||||
}
|
||||
|
||||
__shared ssize_t write(int fildes, const void *buf, size_t nbyte)
|
||||
|
|
Loading…
Reference in a new issue