RISC-V: Updated syscall to take 6 arguments

This commit is contained in:
Jim Wilson 2017-12-26 12:26:19 -08:00
parent a6633677b9
commit 347b083911
2 changed files with 26 additions and 22 deletions

View File

@ -57,12 +57,14 @@
extern long __syscall_error(long);
static inline long
__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3)
__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3, long _a4, long _a5)
{
register long a0 asm("a0") = _a0;
register long a1 asm("a1") = _a1;
register long a2 asm("a2") = _a2;
register long a3 asm("a3") = _a3;
register long a4 asm("a4") = _a4;
register long a5 asm("a5") = _a5;
#ifdef __riscv_32e
register long syscall_id asm("t0") = n;
@ -71,7 +73,7 @@ __internal_syscall(long n, long _a0, long _a1, long _a2, long _a3)
#endif
asm volatile ("scall"
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(syscall_id));
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), "r"(syscall_id));
if (a0 < 0)
return __syscall_error (a0);

View File

@ -69,8 +69,9 @@
#include <unistd.h>
#include <utime.h>
#define syscall_errno(n, a, b, c, d) \
__internal_syscall(n, (long)(a), (long)(b), (long)(c), (long)(d))
#define syscall_errno(n, a, b, c, d, e, f) \
__internal_syscall(n, (long)(a), (long)(b), (long)(c), \
(long)(d), (long)(e), (long)(f))
long
__syscall_error(long a0)
@ -83,35 +84,35 @@ __syscall_error(long a0)
int
_open(const char *name, int flags, int mode)
{
return syscall_errno (SYS_open, name, flags, mode, 0);
return syscall_errno (SYS_open, name, flags, mode, 0, 0, 0);
}
/* Open file relative to given directory. */
int
_openat(int dirfd, const char *name, int flags, int mode)
{
return syscall_errno (SYS_openat, dirfd, name, flags, mode);
return syscall_errno (SYS_openat, dirfd, name, flags, mode, 0, 0);
}
/* Set position in a file. */
off_t
_lseek(int file, off_t ptr, int dir)
{
return syscall_errno (SYS_lseek, file, ptr, dir, 0);
return syscall_errno (SYS_lseek, file, ptr, dir, 0, 0, 0);
}
/* Read from a file. */
ssize_t
_read(int file, void *ptr, size_t len)
{
return syscall_errno (SYS_read, file, ptr, len, 0);
return syscall_errno (SYS_read, file, ptr, len, 0, 0, 0);
}
/* Write to a file. */
ssize_t
_write(int file, const void *ptr, size_t len)
{
return syscall_errno (SYS_write, file, ptr, len, 0);
return syscall_errno (SYS_write, file, ptr, len, 0, 0, 0);
}
struct kernel_stat
@ -159,7 +160,7 @@ int
_fstat(int file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_fstat, file, &kst, 0, 0);
int rv = syscall_errno (SYS_fstat, file, &kst, 0, 0, 0, 0);
conv_stat (st, &kst);
return rv;
}
@ -169,7 +170,7 @@ int
_stat(const char *file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_stat, file, &kst, 0, 0);
int rv = syscall_errno (SYS_stat, file, &kst, 0, 0, 0, 0);
conv_stat (st, &kst);
return rv;
}
@ -179,7 +180,7 @@ int
_lstat(const char *file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_lstat, file, &kst, 0, 0);
int rv = syscall_errno (SYS_lstat, file, &kst, 0, 0, 0, 0);
conv_stat (st, &kst);
return rv;
}
@ -189,7 +190,7 @@ int
_fstatat(int dirfd, const char *file, struct stat *st, int flags)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_fstatat, dirfd, file, &kst, flags);
int rv = syscall_errno (SYS_fstatat, dirfd, file, &kst, flags, 0, 0);
conv_stat (st, &kst);
return rv;
}
@ -198,35 +199,35 @@ _fstatat(int dirfd, const char *file, struct stat *st, int flags)
int
_access(const char *file, int mode)
{
return syscall_errno (SYS_access, file, mode, 0, 0);
return syscall_errno (SYS_access, file, mode, 0, 0, 0, 0);
}
/* Permissions of a file (by name) in a given directory. */
int
_faccessat(int dirfd, const char *file, int mode, int flags)
{
return syscall_errno (SYS_faccessat, dirfd, file, mode, flags);
return syscall_errno (SYS_faccessat, dirfd, file, mode, flags, 0, 0);
}
/* Close a file. */
int
_close(int file)
{
return syscall_errno (SYS_close, file, 0, 0, 0);
return syscall_errno (SYS_close, file, 0, 0, 0, 0, 0);
}
/* Establish a new name for an existing file. */
int
_link(const char *old_name, const char *new_name)
{
return syscall_errno (SYS_link, old_name, new_name, 0, 0);
return syscall_errno (SYS_link, old_name, new_name, 0, 0, 0, 0);
}
/* Remove a file's directory entry. */
int
_unlink(const char *name)
{
return syscall_errno (SYS_unlink, name, 0, 0, 0);
return syscall_errno (SYS_unlink, name, 0, 0, 0, 0, 0);
}
/* Transfer control to a new process. Minimal implementation for a
@ -295,7 +296,7 @@ _isatty(int file)
int
_gettimeofday(struct timeval *tp, void *tz)
{
return syscall_errno (SYS_gettimeofday, tp, 0, 0, 0);
return syscall_errno (SYS_gettimeofday, tp, 0, 0, 0, 0, 0);
}
/* Timing information for current process. From
@ -396,13 +397,14 @@ _sbrk(ptrdiff_t incr)
if (heap_end == 0)
{
long brk = syscall_errno (SYS_brk, 0, 0, 0, 0);
long brk = syscall_errno (SYS_brk, 0, 0, 0, 0, 0, 0);
if (brk == -1)
return (void *)-1;
heap_end = brk;
}
if (syscall_errno (SYS_brk, heap_end + incr, 0, 0, 0) != heap_end + incr)
if (syscall_errno (SYS_brk, heap_end + incr, 0, 0, 0, 0, 0)
!= heap_end + incr)
return (void *)-1;
heap_end += incr;
@ -414,6 +416,6 @@ _sbrk(ptrdiff_t incr)
void
_exit(int exit_status)
{
syscall_errno (SYS_exit, exit_status, 0, 0, 0);
syscall_errno (SYS_exit, exit_status, 0, 0, 0, 0, 0);
while (1);
}