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