1 /* $Id: btfixup.h,v 1.4 1998/03/09 14:04:43 jj Exp $
2 * asm-sparc/btfixup.h: Macros for boot time linking.
3 *
4 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */
6
7 #ifndef _SPARC_BTFIXUP_H
8 #define _SPARC_BTFIXUP_H
9
10 #include <linux/init.h>
11
12 #ifndef __ASSEMBLY__
13
14 #ifdef MODULE
15 extern unsigned int ___illegal_use_of_BTFIXUP_SIMM13_in_module(void);
16 extern unsigned int ___illegal_use_of_BTFIXUP_SETHI_in_module(void);
17 extern unsigned int ___illegal_use_of_BTFIXUP_HALF_in_module(void);
18 extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
19 #endif
20
21 /* Fixup call xx */
22
23 #define BTFIXUPDEF_CALL(__type, __name, __args...) \
24 extern __type ___f_##__name(__args); \
25 extern unsigned ___fs_##__name[3];
26 #define BTFIXUPDEF_CALL_CONST(__type, __name, __args...) \
27 extern __type ___f_##__name(__args) __attribute__((const)); \
28 extern unsigned ___fs_##__name[3];
29 #define BTFIXUP_CALL(__name) ___f_##__name
30
31 #define BTFIXUPDEF_BLACKBOX(__name) \
32 extern unsigned ___bs_##__name[2];
33 #ifdef MODULE
34 #define BTFIXUP_BLACKBOX(__name) ___illegal_use_of_BTFIXUP_BLACKBOX_in_module
35 #else
36 /* This must be written in assembly and present in a sethi */
37 #define BTFIXUP_BLACKBOX(__name) ___b_##__name
38 #endif
39
40 /* Put bottom 13bits into some register variable */
41
42 #define BTFIXUPDEF_SIMM13(__name) \
43 extern unsigned int ___sf_##__name(void) __attribute__((const)); \
44 extern unsigned ___ss_##__name[2]; \
45 extern __inline__ unsigned int ___sf_##__name(void) { \
46 unsigned int ret; \
47 __asm__ ("or %%g0, ___s_" #__name ", %0" : "=r"(ret)); \
48 return ret; \
49 }
50 #define BTFIXUPDEF_SIMM13_INIT(__name,__val) \
51 extern unsigned int ___sf_##__name(void) __attribute__((const)); \
52 extern unsigned ___ss_##__name[2]; \
53 extern __inline__ unsigned int ___sf_##__name(void) { \
54 unsigned int ret; \
55 __asm__ ("or %%g0, ___s_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
56 return ret; \
57 }
58 #ifdef MODULE
59 #define BTFIXUP_SIMM13(__name) ___illegal_use_of_BTFIXUP_SIMM13_in_module()
60 #else
61 #define BTFIXUP_SIMM13(__name) ___sf_##__name()
62 #endif
63
64 /* Put either bottom 13 bits, or upper 22 bits into some register variable
65 * (depending on the value, this will lead into sethi FIX, reg; or
66 * mov FIX, reg; )
67 */
68
69 #define BTFIXUPDEF_HALF(__name) \
70 extern unsigned int ___af_##__name(void) __attribute__((const)); \
71 extern unsigned ___as_##__name[2]; \
72 extern __inline__ unsigned int ___af_##__name(void) { \
73 unsigned int ret; \
74 __asm__ ("or %%g0, ___a_" #__name ", %0" : "=r"(ret)); \
75 return ret; \
76 }
77 #define BTFIXUPDEF_HALF_INIT(__name,__val) \
78 extern unsigned int ___af_##__name(void) __attribute__((const)); \
79 extern unsigned ___as_##__name[2]; \
80 extern __inline__ unsigned int ___af_##__name(void) { \
81 unsigned int ret; \
82 __asm__ ("or %%g0, ___a_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
83 return ret; \
84 }
85 #ifdef MODULE
86 #define BTFIXUP_HALF(__name) ___illegal_use_of_BTFIXUP_HALF_in_module()
87 #else
88 #define BTFIXUP_HALF(__name) ___af_##__name()
89 #endif
90
91 /* Put upper 22 bits into some register variable */
92
93 #define BTFIXUPDEF_SETHI(__name) \
94 extern unsigned int ___hf_##__name(void) __attribute__((const)); \
95 extern unsigned ___hs_##__name[2]; \
96 extern __inline__ unsigned int ___hf_##__name(void) { \
97 unsigned int ret; \
98 __asm__ ("sethi %%hi(___h_" #__name "), %0" : "=r"(ret)); \
99 return ret; \
100 }
101 #define BTFIXUPDEF_SETHI_INIT(__name,__val) \
102 extern unsigned int ___hf_##__name(void) __attribute__((const)); \
103 extern unsigned ___hs_##__name[2]; \
104 extern __inline__ unsigned int ___hf_##__name(void) { \
105 unsigned int ret; \
106 __asm__ ("sethi %%hi(___h_" #__name "__btset_" #__val "), %0" : \
107 "=r"(ret)); \
108 return ret; \
109 }
110 #ifdef MODULE
111 #define BTFIXUP_SETHI(__name) ___illegal_use_of_BTFIXUP_SETHI_in_module()
112 #else
113 #define BTFIXUP_SETHI(__name) ___hf_##__name()
114 #endif
115
116 /* Put a full 32bit integer into some register variable */
117
118 #define BTFIXUPDEF_INT(__name) \
119 extern unsigned char ___i_##__name; \
120 extern unsigned ___is_##__name[2];
121 #ifdef MODULE
122 #define BTFIXUP_INT(__name) ___illegal_use_of_BTFIXUP_INT_in_module()
123 #else
124 #define BTFIXUP_INT(__name) ((unsigned int)&___i_##__name)
125 #endif
126
127 #define BTFIXUPCALL_NORM 0x00000000 /* Always call */
128 #define BTFIXUPCALL_NOP 0x01000000 /* Possibly optimize to nop */
129 #define BTFIXUPCALL_RETINT(i) (0x90102000|((i) & 0x1fff)) /* Possibly optimize to mov i, %o0 */
130 #define BTFIXUPCALL_ORINT(i) (0x90122000|((i) & 0x1fff)) /* Possibly optimize to or %o0, i, %o0 */
131 #define BTFIXUPCALL_RETO0 0x01000000 /* Return first parameter, actually a nop */
132 #define BTFIXUPCALL_ANDNINT(i) (0x902a2000|((i) & 0x1fff)) /* Possibly optimize to andn %o0, i, %o0 */
133 #define BTFIXUPCALL_SWAPO0O1 0xd27a0000 /* Possibly optimize to swap [%o0],%o1 */
134 #define BTFIXUPCALL_SWAPO0G0 0xc07a0000 /* Possibly optimize to swap [%o0],%g0 */
135 #define BTFIXUPCALL_SWAPG1G2 0xc4784000 /* Possibly optimize to swap [%g1],%g2 */
136 #define BTFIXUPCALL_STG0O0 0xc0220000 /* Possibly optimize to st %g0,[%o0] */
137 #define BTFIXUPCALL_STO1O0 0xd2220000 /* Possibly optimize to st %o1,[%o0] */
138
139 #define BTFIXUPSET_CALL(__name, __addr, __insn) \
140 do { \
141 ___fs_##__name[0] |= 1; \
142 ___fs_##__name[1] = (unsigned long)__addr; \
143 ___fs_##__name[2] = __insn; \
144 } while (0)
145
146 #define BTFIXUPSET_BLACKBOX(__name, __func) \
147 do { \
148 ___bs_##__name[0] |= 1; \
149 ___bs_##__name[1] = (unsigned long)__func; \
150 } while (0)
151
152 #define BTFIXUPCOPY_CALL(__name, __from) \
153 do { \
154 ___fs_##__name[0] |= 1; \
155 ___fs_##__name[1] = ___fs_##__from[1]; \
156 ___fs_##__name[2] = ___fs_##__from[2]; \
157 } while (0)
158
159 #define BTFIXUPSET_SIMM13(__name, __val) \
160 do { \
161 ___ss_##__name[0] |= 1; \
162 ___ss_##__name[1] = (unsigned)__val; \
163 } while (0)
164
165 #define BTFIXUPCOPY_SIMM13(__name, __from) \
166 do { \
167 ___ss_##__name[0] |= 1; \
168 ___ss_##__name[1] = ___ss_##__from[1]; \
169 } while (0)
170
171 #define BTFIXUPSET_HALF(__name, __val) \
172 do { \
173 ___as_##__name[0] |= 1; \
174 ___as_##__name[1] = (unsigned)__val; \
175 } while (0)
176
177 #define BTFIXUPCOPY_HALF(__name, __from) \
178 do { \
179 ___as_##__name[0] |= 1; \
180 ___as_##__name[1] = ___as_##__from[1]; \
181 } while (0)
182
183 #define BTFIXUPSET_SETHI(__name, __val) \
184 do { \
185 ___hs_##__name[0] |= 1; \
186 ___hs_##__name[1] = (unsigned)__val; \
187 } while (0)
188
189 #define BTFIXUPCOPY_SETHI(__name, __from) \
190 do { \
191 ___hs_##__name[0] |= 1; \
192 ___hs_##__name[1] = ___hs_##__from[1]; \
193 } while (0)
194
195 #define BTFIXUPSET_INT(__name, __val) \
196 do { \
197 ___is_##__name[0] |= 1; \
198 ___is_##__name[1] = (unsigned)__val; \
199 } while (0)
200
201 #define BTFIXUPCOPY_INT(__name, __from) \
202 do { \
203 ___is_##__name[0] |= 1; \
204 ___is_##__name[1] = ___is_##__from[1]; \
205 } while (0)
206
207 #define BTFIXUPVAL_CALL(__name) \
208 ((unsigned long)___fs_##__name[1])
209
210 extern void btfixup(void);
211
212 #else /* __ASSEMBLY__ */
213
214 #define BTFIXUP_SETHI(__name) %hi(___h_ ## __name)
215 #define BTFIXUP_SETHI_INIT(__name,__val) %hi(___h_ ## __name ## __btset_ ## __val)
216
217 #endif /* __ASSEMBLY__ */
218
219 #endif /* !(_SPARC_BTFIXUP_H) */
220
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.