]> git.sur5r.net Git - u-boot/blobdiff - examples/stubs.c
FSL: Move board/mpc8260ads under board/freescale
[u-boot] / examples / stubs.c
index 6f563ed9ba865f7745f0a31e220d815238f0f185..b9dbcf9065b9a8e635f1c1b9f5bcb9b99b391145 100644 (file)
@@ -1,5 +1,9 @@
 #include <exports.h>
 
+#ifndef GCC_VERSION
+#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+#endif /* GCC_VERSION */
+
 #if defined(CONFIG_I386)
 /*
  * x86 does not have a dedicated register to store the pointer to
@@ -21,14 +25,14 @@ gd_t *global_data;
        : : "i"(XF_ ## x * sizeof(void *)) : "eax", "ecx");
 #elif defined(CONFIG_PPC)
 /*
- * r29 holds the pointer to the global_data, r11 is a call-clobbered
+ * r2 holds the pointer to the global_data, r11 is a call-clobbered
  * register
  */
 #define EXPORT_FUNC(x) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
-"      lwz     %%r11, %0(%%r29)\n"     \
+"      lwz     %%r11, %0(%%r2)\n"      \
 "      lwz     %%r11, %1(%%r11)\n"     \
 "      mtctr   %%r11\n"                \
 "      bctr\n"                         \
@@ -78,6 +82,21 @@ gd_t *global_data;
 "      jmp     %%g0\n"                 \
 "      nop     \n"                     \
        : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x) : "r0");
+#elif defined(CONFIG_NIOS2)
+/*
+ * r15 holds the pointer to the global_data, r8 is call-clobbered
+ */
+#define EXPORT_FUNC(x) \
+       asm volatile (                  \
+"      .globl " #x "\n"                \
+#x ":\n"                               \
+"      movhi   r8, %%hi(%0)\n"         \
+"      ori     r8, r0, %%lo(%0)\n"     \
+"      add     r8, r8, r15\n"          \
+"      ldw     r8, 0(r8)\n"            \
+"      ldw     r8, %1(r8)\n"           \
+"      jmp     r8\n"                   \
+       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r15");
 #elif defined(CONFIG_M68K)
 /*
  * d7 holds the pointer to the global_data, a0 is a call-clobbered
@@ -94,7 +113,7 @@ gd_t *global_data;
 "      move.l  (%%a0), %%a0\n"         \
 "      jmp     (%%a0)\n"                       \
        : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "a0");
-#elif defined(CONFIG_MICROBLZE)
+#elif defined(CONFIG_MICROBLAZE)
 /*
  * r31 holds the pointer to the global_data. r5 is a call-clobbered.
  */
@@ -106,6 +125,48 @@ gd_t *global_data;
 "      lwi     r5, r5, %1\n"                   \
 "      bra     r5\n"                           \
        : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r5");
+#elif defined(CONFIG_BLACKFIN)
+/*
+ * P5 holds the pointer to the global_data, P0 is a call-clobbered
+ * register
+ */
+#define EXPORT_FUNC(x)                 \
+       asm volatile (                  \
+"      .globl _" #x "\n_"              \
+#x ":\n"                               \
+"      P0 = [P5 + %0]\n"               \
+"      P0 = [P0 + %1]\n"               \
+"      JUMP (P0)\n"                    \
+       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "P0");
+#elif defined(CONFIG_AVR32)
+/*
+ * r6 holds the pointer to the global_data. r8 is call clobbered.
+ */
+#define EXPORT_FUNC(x)                                 \
+       asm volatile(                                   \
+               "       .globl\t" #x "\n"               \
+               #x ":\n"                                \
+               "       ld.w    r8, r6[%0]\n"           \
+               "       ld.w    pc, r8[%1]\n"           \
+               :                                       \
+               : "i"(offsetof(gd_t, jt)), "i"(XF_ ##x) \
+               : "r8");
+#elif defined(CONFIG_SH)
+/*
+ * r13 holds the pointer to the global_data. r1 is a call clobbered.
+ */
+#define EXPORT_FUNC(x)                                 \
+       asm volatile (                                  \
+               "       .align  2\n"                    \
+               "       .globl " #x "\n"                \
+               #x ":\n"                                \
+               "       mov     r13, r1\n"              \
+               "       add     %0, r1\n"               \
+               "       add     %1, r1\n"               \
+               "       jmp     @r1\n"                  \
+               "       nop\n"                          \
+               "       nop\n"                          \
+               : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r1");
 #else
 #error stubs definition missing for this architecture
 #endif
@@ -117,7 +178,10 @@ gd_t *global_data;
  * implementation. On the other hand, asm() statements with
  * arguments can be used only inside the functions (gcc limitation)
  */
-static void __attribute__((unused)) dummy(void)
+#if GCC_VERSION < 3004
+static
+#endif /* GCC_VERSION */
+void __attribute__((unused)) dummy(void)
 {
 #include <_exports.h>
 }
@@ -126,10 +190,10 @@ extern unsigned long __bss_start, _end;
 
 void app_startup(char **argv)
 {
-       unsigned long * cp = &__bss_start;
+       unsigned char * cp = (unsigned char *) &__bss_start;
 
        /* Zero out BSS */
-       while (cp < &_end) {
+       while (cp < (unsigned char *)&_end) {
                *cp++ = 0;
        }