feat: extend stopchldtarget with syscall4 and syscall6
This commit is contained in:
1 parent
2709025a74
commit
fa03edc4a5
2 files changed
+113
No files matched your search
+45
@@ -11,6 +11,41 @@ static long syscall3(long number, long a1, long a2, long a3)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Same trap as syscall3, with a 4th argument -- passed in r10, not rcx,
|
||||
the same choice the real Linux x86-64 syscall ABI makes (rcx is already
|
||||
spoken for by the `int $0x80`/syscall instruction's own use, so a fourth
|
||||
argument needs a register the trap does not otherwise touch). Only
|
||||
userSigAction needs one today. */
|
||||
static long syscall4(long number, long a1, long a2, long a3, long a4)
|
||||
{
|
||||
long ret;
|
||||
register long a4Reg __asm__("r10") = a4;
|
||||
__asm__ volatile(
|
||||
"int $0x80"
|
||||
: "=a"(ret)
|
||||
: "a"(number), "D"(a1), "S"(a2), "d"(a3), "r"(a4Reg)
|
||||
: "memory", "rcx", "r11");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Same trap again, with a 5th and 6th argument in r8/r9 -- the same real
|
||||
Linux x86-64 syscall ABI register order this file's own 4th-argument
|
||||
choice (r10) already follows, continued one register further. Only
|
||||
userMmap needs this many today. */
|
||||
static long syscall6(long number, long a1, long a2, long a3, long a4, long a5, long a6)
|
||||
{
|
||||
long ret;
|
||||
register long a4Reg __asm__("r10") = a4;
|
||||
register long a5Reg __asm__("r8") = a5;
|
||||
register long a6Reg __asm__("r9") = a6;
|
||||
__asm__ volatile(
|
||||
"int $0x80"
|
||||
: "=a"(ret)
|
||||
: "a"(number), "D"(a1), "S"(a2), "d"(a3), "r"(a4Reg), "r"(a5Reg), "r"(a6Reg)
|
||||
: "memory", "rcx", "r11");
|
||||
return ret;
|
||||
}
|
||||
|
||||
long userWrite(int fd, const char* buffer, unsigned long length)
|
||||
{
|
||||
return syscall3(sysWrite, fd, (long)buffer, (long)length);
|
||||
@@ -46,6 +81,16 @@ void userSleep(unsigned long milliseconds)
|
||||
syscall3(sysSleep, (long)milliseconds, 0, 0);
|
||||
}
|
||||
|
||||
unsigned long userAlarm(unsigned long seconds)
|
||||
{
|
||||
return (unsigned long)syscall3(sysAlarm, (long)seconds, 0, 0);
|
||||
}
|
||||
|
||||
long userPoll(PollFd* fds, unsigned long nfds, long timeoutMs)
|
||||
{
|
||||
return syscall3(sysPoll, (long)fds, (long)nfds, timeoutMs);
|
||||
}
|
||||
|
||||
long userOpen(const char* path, unsigned int flags)
|
||||
{
|
||||
return syscall3(sysOpen, (long)path, (long)flags, 0);
|
||||
|
||||
Reference in new issue
Block a user