1 /* $NetBSD: frame_regs.h,v 1.3 2008/01/05 12:08:51 dsl Exp $ */
3 #ifndef _AMD64_FRAME_REGS_H_
4 #define _AMD64_FRAME_REGS_H_
7 * amd64 registers (and friends) ordered as in a trap/interrupt/syscall frame.
8 * Also the indexes into the 'general register state' (__greg_t) passed to
10 * Historically they were in the same order, but the order in the frames
11 * has been changed to improve syscall efficiency.
14 * 1) gdb (src/gnu/dist/gdb6/gdb/amd64nbsd-tdep.c) has a lookup table that
15 * assumes the __greg_t ordering.
16 * 2) src/lib/libc/arch/x86_64/gen/makecontext.c assumes that the first
17 * 6 entries in the __greg_t array match the registers used to pass
19 * 3) The 'struct reg' from machine/reg.h has to match __greg_t.
20 * Since they are both arrays and indexed with the same tokens this
21 * shouldn't be a problem, but is rather confusing.
22 * This assumption is made in a lot of places!
23 * 4) There might be other code out there that relies on the ordering.
25 * The first entries below match the registers used for syscall arguments
26 * (%rcx is destroyed by the syscall instruction, the libc system call
27 * stubs copy %rcx to %r10).
28 * arg6-arg9 are copied from the user stack for system calls with more
29 * than 6 args (SYS_MAXSYSARGS is 8, + 2 entries for SYS___SYSCALL).
31 #define _FRAME_REG(greg, freg) \
38 freg(arg6, @, @) /* syscall arg from stack */ \
39 freg(arg7, @, @) /* syscall arg from stack */ \
40 freg(arg8, @, @) /* syscall arg from stack */ \
41 freg(arg9, @, @) /* syscall arg from stack */ \
55 greg(trapno, TRAPNO, 19) \
56 /* below portion defined in hardware */ \
57 greg(err, ERR, 20) /* Dummy inserted if not defined */ \
60 greg(rflags, RFLAGS, 23) \
61 /* These are pushed unconditionally on the x86-64 */ \
65 #define _FRAME_NOREG(reg, REG, idx)
67 #define _FRAME_GREG(greg) _FRAME_REG(greg, _FRAME_NOREG)