3 #include <linux/compiler.h>
5 #define FO(x) offsetof(struct jt_funcs, x)
7 #if defined(CONFIG_X86)
9 * x86 does not have a dedicated register to store the pointer to
10 * the global_data. Thus the jump table address is stored in a
11 * global variable, but such approach does not allow for execution
12 * from flash memory. The global_data address is passed as argv[-1]
13 * to the application program.
15 static struct jt_funcs *jt;
18 #define EXPORT_FUNC(f, a, x, ...) \
24 " jmp *(%%ecx, %%eax)\n" \
25 : : "i"(FO(x)) : "eax", "ecx");
26 #elif defined(CONFIG_PPC)
28 * r2 holds the pointer to the global_data, r11 is a call-clobbered
31 #define EXPORT_FUNC(f, a, x, ...) \
35 " lwz %%r11, %0(%%r2)\n" \
36 " lwz %%r11, %1(%%r11)\n" \
39 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r11");
40 #elif defined(CONFIG_ARM)
43 * x18 holds the pointer to the global_data, x9 is a call-clobbered
46 #define EXPORT_FUNC(f, a, x, ...) \
50 " ldr x9, [x18, %0]\n" \
51 " ldr x9, [x9, %1]\n" \
53 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "x9");
56 * r9 holds the pointer to the global_data, ip is a call-clobbered
59 #define EXPORT_FUNC(f, a, x, ...) \
63 " ldr ip, [r9, %0]\n" \
64 " ldr pc, [ip, %1]\n" \
65 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "ip");
67 #elif defined(CONFIG_MIPS)
68 #ifdef CONFIG_CPU_MIPS64
70 * k0 ($26) holds the pointer to the global_data; t9 ($25) is a call-
71 * clobbered register that is also used to set gp ($26). Note that the
72 * jr instruction also executes the instruction immediately following
73 * it; however, GCC/mips generates an additional `nop' after each asm
76 #define EXPORT_FUNC(f, a, x, ...) \
80 " ld $25, %0($26)\n" \
81 " ld $25, %1($25)\n" \
83 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
86 * k0 ($26) holds the pointer to the global_data; t9 ($25) is a call-
87 * clobbered register that is also used to set gp ($26). Note that the
88 * jr instruction also executes the instruction immediately following
89 * it; however, GCC/mips generates an additional `nop' after each asm
92 #define EXPORT_FUNC(f, a, x, ...) \
96 " lw $25, %0($26)\n" \
97 " lw $25, %1($25)\n" \
99 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
101 #elif defined(CONFIG_NIOS2)
103 * gp holds the pointer to the global_data, r8 is call-clobbered
105 #define EXPORT_FUNC(f, a, x, ...) \
109 " movhi r8, %%hi(%0)\n" \
110 " ori r8, r0, %%lo(%0)\n" \
111 " add r8, r8, gp\n" \
113 " ldw r8, %1(r8)\n" \
115 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "gp");
116 #elif defined(CONFIG_M68K)
118 * d7 holds the pointer to the global_data, a0 is a call-clobbered
121 #define EXPORT_FUNC(f, a, x, ...) \
125 " move.l %%d7, %%a0\n" \
126 " adda.l %0, %%a0\n" \
127 " move.l (%%a0), %%a0\n" \
128 " adda.l %1, %%a0\n" \
129 " move.l (%%a0), %%a0\n" \
131 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "a0");
132 #elif defined(CONFIG_MICROBLAZE)
134 * r31 holds the pointer to the global_data. r5 is a call-clobbered.
136 #define EXPORT_FUNC(f, a, x, ...) \
140 " lwi r5, r31, %0\n" \
141 " lwi r5, r5, %1\n" \
143 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r5");
144 #elif defined(CONFIG_BLACKFIN)
146 * P3 holds the pointer to the global_data, P0 is a call-clobbered
149 #define EXPORT_FUNC(f, a, x, ...) \
151 " .globl _" #x "\n_" \
153 " P0 = [P3 + %0]\n" \
154 " P0 = [P0 + %1]\n" \
156 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "P0");
157 #elif defined(CONFIG_AVR32)
159 * r6 holds the pointer to the global_data. r8 is call clobbered.
161 #define EXPORT_FUNC(f, a, x, ...) \
163 " .globl\t" #x "\n" \
165 " ld.w r8, r6[%0]\n" \
166 " ld.w pc, r8[%1]\n" \
168 : "i"(offsetof(gd_t, jt)), "i"(FO(x)) \
170 #elif defined(CONFIG_SH)
172 * r13 holds the pointer to the global_data. r1 is a call clobbered.
174 #define EXPORT_FUNC(f, a, x, ...) \
187 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r1", "r2");
188 #elif defined(CONFIG_SPARC)
190 * g7 holds the pointer to the global_data. g1 is call clobbered.
192 #define EXPORT_FUNC(f, a, x, ...) \
194 " .globl\t" #x "\n" \
197 " or %%g1, %%g7, %%g1\n" \
198 " ld [%%g1], %%g1\n" \
199 " ld [%%g1 + %1], %%g1\n" \
202 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "g1");
203 #elif defined(CONFIG_NDS32)
205 * r16 holds the pointer to the global_data. gp is call clobbered.
206 * not support reduced register (16 GPR).
208 #define EXPORT_FUNC(f, a, x, ...) \
212 " lwi $r16, [$gp + (%0)]\n" \
213 " lwi $r16, [$r16 + (%1)]\n" \
215 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
216 #elif defined(CONFIG_OPENRISC)
218 * r10 holds the pointer to the global_data, r13 is a call-clobbered
221 #define EXPORT_FUNC(f, a, x, ...) \
225 " l.lwz r13, %0(r10)\n" \
226 " l.lwz r13, %1(r13)\n" \
229 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r13");
230 #elif defined(CONFIG_ARC)
232 * r25 holds the pointer to the global_data. r10 is call clobbered.
234 #define EXPORT_FUNC(f, a, x, ...) \
239 " ld r10, [r25, %0]\n" \
240 " ld r10, [r10, %1]\n" \
242 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r10");
244 /*" addi $sp, $sp, -24\n" \
247 #error stubs definition missing for this architecture
250 /* This function is necessary to prevent the compiler from
251 * generating prologue/epilogue, preparing stack frame etc.
252 * The stub functions are special, they do not use the stack
253 * frame passed to them, but pass it intact to the actual
254 * implementation. On the other hand, asm() statements with
255 * arguments can be used only inside the functions (gcc limitation)
257 #if GCC_VERSION < 30400
259 #endif /* GCC_VERSION */
260 void __attribute__((unused)) dummy(void)
262 #include <_exports.h>
265 #include <asm/sections.h>
267 void app_startup(char * const *argv)
269 char *cp = __bss_start;
275 #if defined(CONFIG_X86)
276 /* x86 does not have a dedicated register for passing global_data */
277 global_data = (gd_t *)argv[-1];
278 jt = global_data->jt;