frame_regs.h revision 1.2 1 /* $NetBSD: frame_regs.h,v 1.2 2008/01/04 23:29:54 dsl Exp $ */
2
3 #ifndef _AMD64_FRAME_REGS_H_
4 #define _AMD64_FRAME_REGS_H_
5
6 /*
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
9 * userland.
10 * Historically they were in the same order, but the order in the frames
11 * will be changed to improve syscall efficiency.
12 *
13 * Notes:
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
18 * function arguments.
19 * 3) PTHREAD_UCONTEXT_TO_REG (src/lib/libpthread/arch/?*?/pthread_md.h)
20 * assumes that something matches the __greg_t layout, but there
21 * are no (obvious) references.
22 * 4) There might be other code out there that relies on the ordering.
23 */
24 #define _FRAME_REG(greg, freg) \
25 greg(rdi, RDI, 0) \
26 greg(rsi, RSI, 1) \
27 greg(rdx, RDX, 2) \
28 greg(rcx, RCX, 3) \
29 greg(r8, R8, 4) \
30 greg(r9, R9, 5) \
31 greg(r10, R10, 6) \
32 greg(r11, R11, 7) \
33 greg(r12, R12, 8) \
34 greg(r13, R13, 9) \
35 greg(r14, R14, 10) \
36 greg(r15, R15, 11) \
37 greg(rbp, RBP, 12) \
38 greg(rbx, RBX, 13) \
39 greg(rax, RAX, 14) \
40 greg(gs, GS, 15) \
41 greg(fs, FS, 16) \
42 greg(es, ES, 17) \
43 greg(ds, DS, 18) \
44 greg(trapno, TRAPNO, 19) \
45 /* below portion defined in hardware */ \
46 greg(err, ERR, 20) /* Dummy inserted if not defined */ \
47 greg(rip, RIP, 21) \
48 greg(cs, CS, 22) \
49 greg(rflags, RFLAGS, 23) \
50 /* These are pushed unconditionally on the x86-64 */ \
51 greg(rsp, RSP, 24) \
52 greg(ss, SS, 25)
53
54 #define _FRAME_NOREG(reg, REG, idx)
55
56 #define _FRAME_GREG(greg) _FRAME_REG(greg, _FRAME_NOREG)
57
58 #endif
59