]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: asm.h,v 1.6 2006/09/05 19:00:42 ad Exp $ */\r |
2 | \r | |
3 | /*-\r | |
4 | * Copyright (c) 1990 The Regents of the University of California.\r | |
5 | * All rights reserved.\r | |
6 | *\r | |
7 | * This code is derived from software contributed to Berkeley by\r | |
8 | * William Jolitz.\r | |
9 | *\r | |
10 | * Redistribution and use in source and binary forms, with or without\r | |
11 | * modification, are permitted provided that the following conditions\r | |
12 | * are met:\r | |
13 | * 1. Redistributions of source code must retain the above copyright\r | |
14 | * notice, this list of conditions and the following disclaimer.\r | |
15 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
16 | * notice, this list of conditions and the following disclaimer in the\r | |
17 | * documentation and/or other materials provided with the distribution.\r | |
18 | * 3. Neither the name of the University nor the names of its contributors\r | |
19 | * may be used to endorse or promote products derived from this software\r | |
20 | * without specific prior written permission.\r | |
21 | *\r | |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
32 | * SUCH DAMAGE.\r | |
33 | *\r | |
34 | * @(#)asm.h 5.5 (Berkeley) 5/7/91\r | |
35 | */\r | |
36 | \r | |
37 | #ifndef _AMD64_ASM_H_\r | |
38 | #define _AMD64_ASM_H_\r | |
39 | \r | |
40 | #ifdef PIC\r | |
41 | #define PIC_PLT(x) x@PLT\r | |
42 | #define PIC_GOT(x) x@GOTPCREL(%rip)\r | |
43 | #else\r | |
44 | #define PIC_PLT(x) x\r | |
45 | #define PIC_GOT(x) x\r | |
46 | #endif\r | |
47 | \r | |
48 | # define _C_LABEL(x) x\r | |
49 | #define _ASM_LABEL(x) x\r | |
50 | \r | |
51 | #define CVAROFF(x,y) (_C_LABEL(x)+y)(%rip)\r | |
52 | \r | |
53 | #ifdef __STDC__\r | |
54 | # define __CONCAT(x,y) x ## y\r | |
55 | # define __STRING(x) #x\r | |
56 | #else\r | |
57 | # define __CONCAT(x,y) x/**/y\r | |
58 | # define __STRING(x) "x"\r | |
59 | #endif\r | |
60 | \r | |
61 | /* let kernels and others override entrypoint alignment */\r | |
62 | #ifndef _ALIGN_TEXT\r | |
63 | #define _ALIGN_TEXT .align 4\r | |
64 | #endif\r | |
65 | \r | |
66 | #define _ENTRY(x) \\r | |
67 | .text; _ALIGN_TEXT; .globl x; .type x,@function; x:\r | |
68 | \r | |
69 | #ifdef _KERNEL\r | |
70 | /* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */\r | |
71 | #ifdef __STDC__\r | |
72 | #define IDTVEC(name) \\r | |
73 | ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name:\r | |
74 | #else \r | |
75 | #define IDTVEC(name) \\r | |
76 | ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name:\r | |
77 | #endif /* __STDC__ */ \r | |
78 | #endif /* _KERNEL */\r | |
79 | \r | |
80 | #ifdef __STDC__\r | |
81 | #define CPUVAR(off) %gs:CPU_INFO_ ## off\r | |
82 | #else\r | |
83 | #define CPUVAR(off) %gs:CPU_INFO_/**/off\r | |
84 | #endif\r | |
85 | \r | |
86 | \r | |
87 | #ifdef GPROF\r | |
88 | # define _PROF_PROLOGUE \\r | |
89 | pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp\r | |
90 | #else\r | |
91 | # define _PROF_PROLOGUE\r | |
92 | #endif\r | |
93 | \r | |
94 | #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE\r | |
95 | #define NENTRY(y) _ENTRY(_C_LABEL(y))\r | |
96 | #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE\r | |
97 | \r | |
98 | #define ASMSTR .asciz\r | |
99 | \r | |
100 | #define RCSID(x) .text; .asciz x\r | |
101 | \r | |
102 | #define WEAK_ALIAS(alias,sym) \\r | |
103 | .weak alias; \\r | |
104 | alias = sym\r | |
105 | \r | |
106 | /*\r | |
107 | * STRONG_ALIAS: create a strong alias.\r | |
108 | */\r | |
109 | #define STRONG_ALIAS(alias,sym) \\r | |
110 | .globl alias; \\r | |
111 | alias = sym\r | |
112 | \r | |
113 | /* XXXfvdl do not use stabs here */\r | |
114 | #ifdef __STDC__\r | |
115 | #define WARN_REFERENCES(sym,msg) \\r | |
116 | .stabs msg ## ,30,0,0,0 ; \\r | |
117 | .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0\r | |
118 | #else\r | |
119 | #define WARN_REFERENCES(sym,msg) \\r | |
120 | .stabs msg,30,0,0,0 ; \\r | |
121 | .stabs __STRING(sym),1,0,0,0\r | |
122 | #endif /* __STDC__ */\r | |
123 | \r | |
124 | /*\r | |
125 | * Assembley equivalent of spllower(). Label contains the label to jump to\r | |
126 | * if we need to fire off pending interrupts (e.g. _C_LABEL(Xspllower)).\r | |
127 | *\r | |
128 | * On entry %rcx = new SPL.\r | |
129 | */\r | |
130 | #define SPLLOWER(label) \\r | |
131 | movq CPUVAR(SELF), %r9 ; \\r | |
132 | cmpl CPU_INFO_ILEVEL(%r9), %ecx ; \\r | |
133 | jae 99f ; \\r | |
134 | movl CPU_INFO_IUNMASK(%r9,%rcx,4), %edi ; \\r | |
135 | pushfq ; \\r | |
136 | popq %rax ; \\r | |
137 | cli ; \\r | |
138 | testl CPU_INFO_IPENDING(%r9), %edi ; \\r | |
139 | movq %rcx, %rdi ; \\r | |
140 | jnz label ; \\r | |
141 | movl %ecx, CPU_INFO_ILEVEL(%r9) ; \\r | |
142 | pushq %rax ; \\r | |
143 | popfq ; \\r | |
144 | 99:\r | |
145 | \r | |
146 | #endif /* !_AMD64_ASM_H_ */\r |