|
|
|
@ -86,14 +86,14 @@ static struct kinfo_t *kinfo;
|
|
|
|
|
// stack is not used after munmapping it, but before calling exit(2). we use
|
|
|
|
|
// this macro to make sure the clobbers are coherent for these three pieces of
|
|
|
|
|
// code using syscalls.
|
|
|
|
|
#define SYSCALL_CLOBBERS "cc", "memory", "r9", "r10", "r11", "r12", "r13", \
|
|
|
|
|
#define SYSCALL_CLOBBERS "cc", "memory", "r10", "r11", "r12", "r13", \
|
|
|
|
|
"r14", "r15"
|
|
|
|
|
long
|
|
|
|
|
syscall(long a1, long a2, long a3, long a4,
|
|
|
|
|
long a5, long trap)
|
|
|
|
|
syscall6(long a1, long a2, long a3, long a4, long a5, long a6, long trap)
|
|
|
|
|
{
|
|
|
|
|
long ret;
|
|
|
|
|
register long r8 asm("r8") = a5;
|
|
|
|
|
register long r9 asm("r9") = a6;
|
|
|
|
|
|
|
|
|
|
// we may want to follow the sys5 abi and have the kernel restore
|
|
|
|
|
// r14-r15 too...
|
|
|
|
@ -102,12 +102,19 @@ syscall(long a1, long a2, long a3, long a4,
|
|
|
|
|
"leaq 2(%%rip), %%r11\n"
|
|
|
|
|
"syscall\n"
|
|
|
|
|
: "=a"(ret)
|
|
|
|
|
: "0"(trap), "D"(a1), "S"(a2), "d"(a3), "c"(a4), "r"(r8)
|
|
|
|
|
: "0"(trap), "D"(a1), "S"(a2), "d"(a3), "c"(a4), "r"(r8), "r"(r9)
|
|
|
|
|
: SYSCALL_CLOBBERS);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long
|
|
|
|
|
syscall(long a1, long a2, long a3, long a4,
|
|
|
|
|
long a5, long trap)
|
|
|
|
|
{
|
|
|
|
|
return syscall6(a1, a2, a3, a4, a5, 0, trap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SA(x) ((long)x)
|
|
|
|
|
#define ERRNO_NZ(x) do { \
|
|
|
|
|
if (x != 0) { \
|
|
|
|
@ -443,10 +450,8 @@ mknod(const char *p, mode_t m, dev_t d)
|
|
|
|
|
void *
|
|
|
|
|
mmap(void *addr, size_t len, int prot, int flags, int fd, long offset)
|
|
|
|
|
{
|
|
|
|
|
ulong protflags = (ulong)prot << 32;
|
|
|
|
|
protflags |= flags;
|
|
|
|
|
long ret;
|
|
|
|
|
ret = syscall(SA(addr), SA(len), SA(protflags), SA(fd),
|
|
|
|
|
ret = syscall6(SA(addr), SA(len), SA(prot), SA(flags), SA(fd),
|
|
|
|
|
SA(offset), SYS_MMAP);
|
|
|
|
|
if (ret < 0 && -ret >= ERRNO_FIRST && -ret <= ERRNO_LAST) {
|
|
|
|
|
errno = -ret;
|
|
|
|
|