]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_f.c
common/board_f: factor out reserve_stacks
[karo-tx-uboot.git] / common / board_f.c
index 2a1022252c4c69c2f44945dfe4f2656a37d81e3b..541ca1a955ae27fac6f6bb15fbd3d863451fa966 100644 (file)
@@ -111,7 +111,7 @@ static int init_func_watchdog_init(void)
 {
 # if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \
        defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
-       defined(CONFIG_SH))
+       defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG))
        hw_watchdog_init();
 # endif
        puts("       Watchdog enabled\n");
@@ -262,7 +262,7 @@ static int zero_global_data(void)
 
 static int setup_mon_len(void)
 {
-#ifdef __ARM__
+#if defined(__ARM__) || defined(__MICROBLAZE__)
        gd->mon_len = (ulong)&__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX)
        gd->mon_len = (ulong)&_end - (ulong)_init;
@@ -280,6 +280,11 @@ __weak int arch_cpu_init(void)
        return 0;
 }
 
+__weak unsigned long get_timer_masked(void)
+{
+       return get_timer(0);
+}
+
 #ifdef CONFIG_OF_HOSTFILE
 
 static int read_fdt_from_file(void)
@@ -573,48 +578,22 @@ static int reserve_fdt(void)
        return 0;
 }
 
-static int reserve_stacks(void)
+int arch_reserve_stacks(void)
 {
-#ifdef CONFIG_SPL_BUILD
-# ifdef CONFIG_ARM
-       gd->start_addr_sp -= 128;       /* leave 32 words for abort-stack */
-       gd->irq_sp = gd->start_addr_sp;
-# endif
-#else
-# ifdef CONFIG_PPC
-       ulong *s;
-# endif
+       return 0;
+}
 
-       /* setup stack pointer for exceptions */
+static int reserve_stacks(void)
+{
+       /* make stack pointer 16-byte aligned */
        gd->start_addr_sp -= 16;
        gd->start_addr_sp &= ~0xf;
-       gd->irq_sp = gd->start_addr_sp;
 
        /*
-        * Handle architecture-specific things here
-        * TODO(sjg@chromium.org): Perhaps create arch_reserve_stack()
-        * to handle this and put in arch/xxx/lib/stack.c
+        * let the architecture specific code tailor gd->start_addr_sp and
+        * gd->irq_sp
         */
-# if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
-#  ifdef CONFIG_USE_IRQ
-       gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
-       debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
-               CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->start_addr_sp);
-
-       /* 8-byte alignment for ARM ABI compliance */
-       gd->start_addr_sp &= ~0x07;
-#  endif
-       /* leave 3 words for abort-stack, plus 1 for alignment */
-       gd->start_addr_sp -= 16;
-# elif defined(CONFIG_PPC)
-       /* Clear initial stack frame */
-       s = (ulong *) gd->start_addr_sp;
-       *s = 0; /* Terminate back chain */
-       *++s = 0; /* NULL return address */
-# endif /* Architecture specific code */
-
-       return 0;
-#endif
+       return arch_reserve_stacks();
 }
 
 static int display_new_sp(void)
@@ -734,7 +713,7 @@ static int reloc_fdt(void)
 static int setup_reloc(void)
 {
 #ifdef CONFIG_SYS_TEXT_BASE
-#ifndef CONFIG_SECURE_BOOT
+#ifndef CONFIG_ARM
        gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
 #else
        gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
@@ -913,7 +892,7 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        announce_dram_init,
        /* TODO: unify all these dram functions? */
-#if defined(CONFIG_ARM) || defined(CONFIG_X86)
+#if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
@@ -1079,4 +1058,22 @@ void board_init_f_r(void)
        /* NOTREACHED - board_init_r() does not return */
        hang();
 }
+#else
+ulong board_init_f_mem(ulong top)
+{
+       /* Leave space for the stack we are running with now */
+       top -= 0x40;
+
+       top -= sizeof(struct global_data);
+       top = ALIGN(top, 16);
+       gd = (struct global_data *)top;
+       memset((void *)gd, '\0', sizeof(*gd));
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       top -= CONFIG_SYS_MALLOC_F_LEN;
+       gd->malloc_base = top;
+#endif
+
+       return top;
+}
 #endif /* CONFIG_X86 */