3 #include <linux/compiler.h>
7 #define FO(x) offsetof(struct jt_funcs, x)
9 #if defined(CONFIG_X86)
11 * x86 does not have a dedicated register to store the pointer to
12 * the global_data. Thus the jump table address is stored in a
13 * global variable, but such approach does not allow for execution
14 * from flash memory. The global_data address is passed as argv[-1]
15 * to the application program.
17 static struct jt_funcs *jt;
20 #define EXPORT_FUNC(f, a, x, ...) \
26 " jmp *(%%ecx, %%eax)\n" \
27 : : "i"(FO(x)) : "eax", "ecx");
28 #elif defined(CONFIG_PPC)
30 * r2 holds the pointer to the global_data, r11 is a call-clobbered
33 #define EXPORT_FUNC(f, a, x, ...) \
37 " lwz %%r11, %0(%%r2)\n" \
38 " lwz %%r11, %1(%%r11)\n" \
41 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r11");
42 #elif defined(CONFIG_ARM)
45 * x18 holds the pointer to the global_data, x9 is a call-clobbered
48 #define EXPORT_FUNC(f, a, x, ...) \
52 " ldr x9, [x18, %0]\n" \
53 " ldr x9, [x9, %1]\n" \
55 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "x9");
58 * r9 holds the pointer to the global_data, ip is a call-clobbered
61 #define EXPORT_FUNC(f, a, x, ...) \
65 " ldr ip, [r9, %0]\n" \
66 " ldr pc, [ip, %1]\n" \
67 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "ip");
69 #elif defined(CONFIG_MIPS)
70 #ifdef CONFIG_CPU_MIPS64
72 * k0 ($26) holds the pointer to the global_data; t9 ($25) is a call-
73 * clobbered register that is also used to set gp ($26). Note that the
74 * jr instruction also executes the instruction immediately following
75 * it; however, GCC/mips generates an additional `nop' after each asm
78 #define EXPORT_FUNC(f, a, x, ...) \
82 " ld $25, %0($26)\n" \
83 " ld $25, %1($25)\n" \
85 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
88 * k0 ($26) holds the pointer to the global_data; t9 ($25) is a call-
89 * clobbered register that is also used to set gp ($26). Note that the
90 * jr instruction also executes the instruction immediately following
91 * it; however, GCC/mips generates an additional `nop' after each asm
94 #define EXPORT_FUNC(f, a, x, ...) \
98 " lw $25, %0($26)\n" \
99 " lw $25, %1($25)\n" \
101 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
103 #elif defined(CONFIG_NIOS2)
105 * gp holds the pointer to the global_data, r8 is call-clobbered
107 #define EXPORT_FUNC(f, a, x, ...) \
111 " movhi r8, %%hi(%0)\n" \
112 " ori r8, r0, %%lo(%0)\n" \
113 " add r8, r8, gp\n" \
115 " ldw r8, %1(r8)\n" \
117 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "gp");
118 #elif defined(CONFIG_M68K)
120 * d7 holds the pointer to the global_data, a0 is a call-clobbered
123 #define EXPORT_FUNC(f, a, x, ...) \
127 " move.l %%d7, %%a0\n" \
128 " adda.l %0, %%a0\n" \
129 " move.l (%%a0), %%a0\n" \
130 " adda.l %1, %%a0\n" \
131 " move.l (%%a0), %%a0\n" \
133 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "a0");
134 #elif defined(CONFIG_MICROBLAZE)
136 * r31 holds the pointer to the global_data. r5 is a call-clobbered.
138 #define EXPORT_FUNC(f, a, x, ...) \
142 " lwi r5, r31, %0\n" \
143 " lwi r5, r5, %1\n" \
145 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r5");
146 #elif defined(CONFIG_SH)
148 * r13 holds the pointer to the global_data. r1 is a call clobbered.
150 #define EXPORT_FUNC(f, a, x, ...) \
163 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r1", "r2");
164 #elif defined(CONFIG_NDS32)
166 * r16 holds the pointer to the global_data. gp is call clobbered.
167 * not support reduced register (16 GPR).
169 #define EXPORT_FUNC(f, a, x, ...) \
173 " lwi $r16, [$gp + (%0)]\n" \
174 " lwi $r16, [$r16 + (%1)]\n" \
176 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
177 #elif defined(CONFIG_RISCV)
179 * gp holds the pointer to the global_data. t0 is call clobbered.
181 #ifdef CONFIG_ARCH_RV64I
182 #define EXPORT_FUNC(f, a, x, ...) \
189 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t0");
191 #define EXPORT_FUNC(f, a, x, ...) \
198 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t0");
200 #elif defined(CONFIG_ARC)
202 * r25 holds the pointer to the global_data. r10 is call clobbered.
204 #define EXPORT_FUNC(f, a, x, ...) \
209 " ld r10, [r25, %0]\n" \
210 " ld r10, [r10, %1]\n" \
212 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r10");
213 #elif defined(CONFIG_XTENSA)
215 * Global data ptr is in global_data, jump table ptr is in jt.
216 * Windowed ABI: Jump just past 'entry' in target and adjust stack frame
217 * (extract stack frame size from target 'entry' instruction).
222 #if defined(__XTENSA_CALL0_ABI__)
223 #define EXPORT_FUNC(f, a, x, ...) \
229 " l32i a8, %0, 0\n" \
230 " l32i a8, a8, %1\n" \
232 : : "r"(jt), "i" (FO(x)) : "a8");
233 #elif defined(__XTENSA_WINDOWED_ABI__)
239 #define EXPORT_FUNC(f, a, x, ...) \
246 " l32i a8, %0, 0\n" \
247 " l32i a8, a8, %1\n" \
248 " l32i a9, a8, 0\n" \
249 " extui a9, a9, " SFT ", 12\n" \
250 " subx8 a9, a9, sp\n" \
252 " sub a9, a10, a9\n" \
254 " addi a8, a8, 3\n" \
256 : : "r"(jt), "i" (FO(x)) : "a8", "a9", "a10");
258 #error Unsupported Xtensa ABI
261 /*" addi $sp, $sp, -24\n" \
264 #error stubs definition missing for this architecture
267 /* This function is necessary to prevent the compiler from
268 * generating prologue/epilogue, preparing stack frame etc.
269 * The stub functions are special, they do not use the stack
270 * frame passed to them, but pass it intact to the actual
271 * implementation. On the other hand, asm() statements with
272 * arguments can be used only inside the functions (gcc limitation)
274 #if GCC_VERSION < 30400
276 #endif /* GCC_VERSION */
277 void __attribute__((unused)) dummy(void)
279 #include <_exports.h>
282 #include <asm/sections.h>
284 void app_startup(char * const *argv)
286 char *cp = __bss_start;
292 #if defined(CONFIG_X86)
293 /* x86 does not have a dedicated register for passing global_data */
294 global_data = (gd_t *)argv[-1];
295 jt = global_data->jt;