frameasm.h revision 1.2.2.1 1 /* $NetBSD: frameasm.h,v 1.2.2.1 2007/05/17 13:40:51 yamt 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 %es,16(%rsp) ; \
56 movw %ds,24(%rsp) ; \
57 98: INTR_SAVE_GPRS
58
59 #define INTRFASTEXIT \
60 INTR_RESTORE_GPRS ; \
61 testq $SEL_UPL,56(%rsp) ; \
62 je 99f ; \
63 cli ; \
64 swapgs ; \
65 movw 16(%rsp),%es ; \
66 movw 24(%rsp),%ds ; \
67 99: addq $48,%rsp ; \
68 iretq
69
70 #define INTR_RECURSE_HWFRAME \
71 movq %rsp,%r10 ; \
72 movl %ss,%r11d ; \
73 pushq %r11 ; \
74 pushq %r10 ; \
75 pushfq ; \
76 movl %cs,%r11d ; \
77 pushq %r11 ; \
78 pushq %r13 ;
79
80
81 #define CHECK_ASTPENDING(reg) cmpq $0, reg ; \
82 je 99f ; \
83 cmpl $0, L_MD_ASTPENDING(reg) ; \
84 99:
85
86 #define CLEAR_ASTPENDING(reg) movl $0, L_MD_ASTPENDING(reg)
87
88 #endif /* _AMD64_MACHINE_FRAMEASM_H */
89