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