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)
69 * k0 ($26) holds the pointer to the global_data; t9 ($25) is a call-
70 * clobbered register that is also used to set gp ($26). Note that the
71 * jr instruction also executes the instruction immediately following
72 * it; however, GCC/mips generates an additional `nop' after each asm
75 #define EXPORT_FUNC(f, a, x, ...) \
79 " lw $25, %0($26)\n" \
80 " lw $25, %1($25)\n" \
82 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
83 #elif defined(CONFIG_NIOS2)
85 * gp holds the pointer to the global_data, r8 is call-clobbered
87 #define EXPORT_FUNC(f, a, x, ...) \
91 " movhi r8, %%hi(%0)\n" \
92 " ori r8, r0, %%lo(%0)\n" \
97 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "gp");
98 #elif defined(CONFIG_M68K)
100 * d7 holds the pointer to the global_data, a0 is a call-clobbered
103 #define EXPORT_FUNC(f, a, x, ...) \
107 " move.l %%d7, %%a0\n" \
108 " adda.l %0, %%a0\n" \
109 " move.l (%%a0), %%a0\n" \
110 " adda.l %1, %%a0\n" \
111 " move.l (%%a0), %%a0\n" \
113 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "a0");
114 #elif defined(CONFIG_MICROBLAZE)
116 * r31 holds the pointer to the global_data. r5 is a call-clobbered.
118 #define EXPORT_FUNC(f, a, x, ...) \
122 " lwi r5, r31, %0\n" \
123 " lwi r5, r5, %1\n" \
125 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r5");
126 #elif defined(CONFIG_BLACKFIN)
128 * P3 holds the pointer to the global_data, P0 is a call-clobbered
131 #define EXPORT_FUNC(f, a, x, ...) \
133 " .globl _" #x "\n_" \
135 " P0 = [P3 + %0]\n" \
136 " P0 = [P0 + %1]\n" \
138 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "P0");
139 #elif defined(CONFIG_AVR32)
141 * r6 holds the pointer to the global_data. r8 is call clobbered.
143 #define EXPORT_FUNC(f, a, x, ...) \
145 " .globl\t" #x "\n" \
147 " ld.w r8, r6[%0]\n" \
148 " ld.w pc, r8[%1]\n" \
150 : "i"(offsetof(gd_t, jt)), "i"(FO(x)) \
152 #elif defined(CONFIG_SH)
154 * r13 holds the pointer to the global_data. r1 is a call clobbered.
156 #define EXPORT_FUNC(f, a, x, ...) \
169 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r1", "r2");
170 #elif defined(CONFIG_SPARC)
172 * g7 holds the pointer to the global_data. g1 is call clobbered.
174 #define EXPORT_FUNC(f, a, x, ...) \
176 " .globl\t" #x "\n" \
179 " or %%g1, %%g7, %%g1\n" \
180 " ld [%%g1], %%g1\n" \
181 " ld [%%g1 + %1], %%g1\n" \
184 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "g1");
185 #elif defined(CONFIG_NDS32)
187 * r16 holds the pointer to the global_data. gp is call clobbered.
188 * not support reduced register (16 GPR).
190 #define EXPORT_FUNC(f, a, x, ...) \
194 " lwi $r16, [$gp + (%0)]\n" \
195 " lwi $r16, [$r16 + (%1)]\n" \
197 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
198 #elif defined(CONFIG_OPENRISC)
200 * r10 holds the pointer to the global_data, r13 is a call-clobbered
203 #define EXPORT_FUNC(f, a, x, ...) \
207 " l.lwz r13, %0(r10)\n" \
208 " l.lwz r13, %1(r13)\n" \
211 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r13");
212 #elif defined(CONFIG_ARC)
214 * r25 holds the pointer to the global_data. r10 is call clobbered.
216 #define EXPORT_FUNC(f, a, x, ...) \
221 " ld r10, [r25, %0]\n" \
222 " ld r10, [r10, %1]\n" \
224 : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r10");
226 /*" addi $sp, $sp, -24\n" \
229 #error stubs definition missing for this architecture
232 /* This function is necessary to prevent the compiler from
233 * generating prologue/epilogue, preparing stack frame etc.
234 * The stub functions are special, they do not use the stack
235 * frame passed to them, but pass it intact to the actual
236 * implementation. On the other hand, asm() statements with
237 * arguments can be used only inside the functions (gcc limitation)
239 #if GCC_VERSION < 30400
241 #endif /* GCC_VERSION */
242 void __attribute__((unused)) dummy(void)
244 #include <_exports.h>
247 #include <asm/sections.h>
249 void app_startup(char * const *argv)
251 char *cp = __bss_start;
257 #if defined(CONFIG_X86)
258 /* x86 does not have a dedicated register for passing global_data */
259 global_data = (gd_t *)argv[-1];
260 jt = global_data->jt;