syscall: Change x86-64 syscall register ABI
This commit is contained in:
parent
8392859f4e
commit
cf04ba62e8
@ -9,11 +9,11 @@ _Begin_C_Header
|
||||
# include <kernel/arch/x86_64/regs.h>
|
||||
# define uregs_syscall_result(r) ((r)->rax)
|
||||
# define uregs_syscall_num(r) ((r)->rax)
|
||||
# define uregs_syscall_arg1(r) ((r)->rbx)
|
||||
# define uregs_syscall_arg2(r) ((r)->rcx)
|
||||
# define uregs_syscall_arg1(r) ((r)->rdi)
|
||||
# define uregs_syscall_arg2(r) ((r)->rsi)
|
||||
# define uregs_syscall_arg3(r) ((r)->rdx)
|
||||
# define uregs_syscall_arg4(r) ((r)->rsi)
|
||||
# define uregs_syscall_arg5(r) ((r)->rdi)
|
||||
# define uregs_syscall_arg4(r) ((r)->r10)
|
||||
# define uregs_syscall_arg5(r) ((r)->r8)
|
||||
# define uregs_ip(r) ((r)->rip)
|
||||
# define uregs_bp(r) ((r)->rbp)
|
||||
# define UREGS_FMT \
|
||||
|
@ -24,7 +24,7 @@ _Begin_C_Header
|
||||
long syscall_##fn(P1 p1) { \
|
||||
long __res = num; __asm__ __volatile__("int $0x7F" \
|
||||
: "=a" (__res) \
|
||||
: "a" (__res), "b" ((long)(p1))); \
|
||||
: "a" (__res), "D" ((long)(p1))); \
|
||||
return __res; \
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ _Begin_C_Header
|
||||
long syscall_##fn(P1 p1, P2 p2) { \
|
||||
long __res = num; __asm__ __volatile__("int $0x7F" \
|
||||
: "=a" (__res) \
|
||||
: "a" (__res), "b" ((long)(p1)), "c"((long)(p2))); \
|
||||
: "a" (__res), "D" ((long)(p1)), "S"((long)(p2))); \
|
||||
return __res; \
|
||||
}
|
||||
|
||||
@ -40,23 +40,26 @@ _Begin_C_Header
|
||||
long syscall_##fn(P1 p1, P2 p2, P3 p3) { \
|
||||
long __res = num; __asm__ __volatile__("int $0x7F" \
|
||||
: "=a" (__res) \
|
||||
: "a" (__res), "b" ((long)(p1)), "c"((long)(p2)), "d"((long)(p3))); \
|
||||
: "a" (__res), "D" ((long)(p1)), "S"((long)(p2)), "d"((long)(p3))); \
|
||||
return __res; \
|
||||
}
|
||||
|
||||
#define DEFN_SYSCALL4(fn, num, P1, P2, P3, P4) \
|
||||
long syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4) { \
|
||||
register long p4_ __asm__("r10") = (long)p4; \
|
||||
long __res = num; __asm__ __volatile__("int $0x7F" \
|
||||
: "=a" (__res) \
|
||||
: "a" (__res), "b" ((long)(p1)), "c"((long)(p2)), "d"((long)(p3)), "S"((long)(p4))); \
|
||||
: "a" (__res), "D" ((long)(p1)), "S"((long)(p2)), "d"((long)(p3)), "r"((long)(p4_))); \
|
||||
return __res; \
|
||||
}
|
||||
|
||||
#define DEFN_SYSCALL5(fn, num, P1, P2, P3, P4, P5) \
|
||||
long syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { \
|
||||
register long p4_ __asm__("r10") = (long)p4; \
|
||||
register long p5_ __asm__("r8") = (long)p5; \
|
||||
long __res = num; __asm__ __volatile__("int $0x7F" \
|
||||
: "=a" (__res) \
|
||||
: "a" (__res), "b" ((long)(p1)), "c"((long)(p2)), "d"((long)(p3)), "S"((long)(p4)), "D"((long)(p5))); \
|
||||
: "a" (__res), "D" ((long)(p1)), "S"((long)(p2)), "d"((long)(p3)), "r"((long)(p4_)), "r"((long)(p5_))); \
|
||||
return __res; \
|
||||
}
|
||||
#elif defined(__aarch64__)
|
||||
|
@ -281,10 +281,10 @@ long arch_reboot(void) {
|
||||
/* Syscall parameter accessors */
|
||||
void arch_syscall_return(struct regs * r, long retval) { r->rax = retval; }
|
||||
long arch_syscall_number(struct regs * r) { return (unsigned long)r->rax; }
|
||||
long arch_syscall_arg0(struct regs * r) { return r->rbx; }
|
||||
long arch_syscall_arg1(struct regs * r) { return r->rcx; }
|
||||
long arch_syscall_arg0(struct regs * r) { return r->rdi; }
|
||||
long arch_syscall_arg1(struct regs * r) { return r->rsi; }
|
||||
long arch_syscall_arg2(struct regs * r) { return r->rdx; }
|
||||
long arch_syscall_arg3(struct regs * r) { return r->rsi; }
|
||||
long arch_syscall_arg4(struct regs * r) { return r->rdi; }
|
||||
long arch_syscall_arg3(struct regs * r) { return r->r10; }
|
||||
long arch_syscall_arg4(struct regs * r) { return r->r8; }
|
||||
long arch_stack_pointer(struct regs * r) { return r->rsp; }
|
||||
long arch_user_ip(struct regs * r) { return r->rip; }
|
||||
|
Loading…
Reference in New Issue
Block a user