frameasm.h revision 1.4 1 /* $NetBSD: frameasm.h,v 1.4 2007/05/21 08:10:39 fvdl Exp $ */
2
3 #ifndef _AMD64_MACHINE_FRAMEASM_H
4 #define _AMD64_MACHINE_FRAMEASM_H
5
6 /*
7 * Macros to define pushing/popping frames for interrupts, traps
8 * and system calls. Currently all the same; will diverge later.
9 */
10
11 /*
12 * These are used on interrupt or trap entry or exit.
13 */
14 #define INTR_SAVE_GPRS \
15 subq $120,%rsp ; \
16 movq %r15,TF_R15(%rsp) ; \
17 movq %r14,TF_R14(%rsp) ; \
18 movq %r13,TF_R13(%rsp) ; \
19 movq %r12,TF_R12(%rsp) ; \
20 movq %r11,TF_R11(%rsp) ; \
21 movq %r10,TF_R10(%rsp) ; \
22 movq %r9,TF_R9(%rsp) ; \
23 movq %r8,TF_R8(%rsp) ; \
24 movq %rdi,TF_RDI(%rsp) ; \
25 movq %rsi,TF_RSI(%rsp) ; \
26 movq %rbp,TF_RBP(%rsp) ; \
27 movq %rbx,TF_RBX(%rsp) ; \
28 movq %rdx,TF_RDX(%rsp) ; \
29 movq %rcx,TF_RCX(%rsp) ; \
30 movq %rax,TF_RAX(%rsp)
31
32 #define INTR_RESTORE_GPRS \
33 movq TF_R15(%rsp),%r15 ; \
34 movq TF_R14(%rsp),%r14 ; \
35 movq TF_R13(%rsp),%r13 ; \
36 movq TF_R12(%rsp),%r12 ; \
37 movq TF_R11(%rsp),%r11 ; \
38 movq TF_R10(%rsp),%r10 ; \
39 movq TF_R9(%rsp),%r9 ; \
40 movq TF_R8(%rsp),%r8 ; \
41 movq TF_RDI(%rsp),%rdi ; \
42 movq TF_RSI(%rsp),%rsi ; \
43 movq TF_RBP(%rsp),%rbp ; \
44 movq TF_RBX(%rsp),%rbx ; \
45 movq TF_RDX(%rsp),%rdx ; \
46 movq TF_RCX(%rsp),%rcx ; \
47 movq TF_RAX(%rsp),%rax ; \
48 addq $120,%rsp
49
50 #define INTRENTRY \
51 subq $32,%rsp ; \
52 testq $SEL_UPL,56(%rsp) ; \
53 je 98f ; \
54 swapgs ; \
55 movw %gs,0(%rsp) ; \
56 movw %fs,8(%rsp) ; \
57 movw %es,16(%rsp) ; \
58 movw %ds,24(%rsp) ; \
59 98: INTR_SAVE_GPRS
60
61 #define INTRFASTEXIT \
62 INTR_RESTORE_GPRS ; \
63 testq $SEL_UPL,56(%rsp) ; \
64 je 99f ; \
65 cli ; \
66 swapgs ; \
67 movw 0(%rsp),%gs ; \
68 movw 8(%rsp),%fs ; \
69 movw 16(%rsp),%es ; \
70 movw 24(%rsp),%ds ; \
71 99: addq $48,%rsp ; \
72 iretq
73
74 #define INTR_RECURSE_HWFRAME \
75 movq %rsp,%r10 ; \
76 movl %ss,%r11d ; \
77 pushq %r11 ; \
78 pushq %r10 ; \
79 pushfq ; \
80 movl %cs,%r11d ; \
81 pushq %r11 ; \
82 pushq %r13 ;
83
84
85 #define CHECK_ASTPENDING(reg) cmpq $0, reg ; \
86 je 99f ; \
87 cmpl $0, L_MD_ASTPENDING(reg) ; \
88 99:
89
90 #define CLEAR_ASTPENDING(reg) movl $0, L_MD_ASTPENDING(reg)
91
92 #endif /* _AMD64_MACHINE_FRAMEASM_H */
93