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