Blackfin: fix dcache handling when doing dma memcpy's
[oweals/u-boot.git] / cpu / arm925t / start.S
index e8353f2a647e06cd6928ebbc483596a1571f087a..c48014d14be80820e6f54aa21418d016c1a64bdb 100644 (file)
@@ -9,7 +9,7 @@
  *  Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
  *  Copyright (c) 2002 Gary Jennejohn <gj@denx.de>
  *  Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
- *  Copyright (c) 2003 Kshitij          <kshitij@ti.com>
+ *  Copyright (c) 2003 Kshitij  <kshitij@ti.com>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -81,9 +81,6 @@ _fiq:                 .word fiq
  *************************************************************************
  */
 
-/*
- * CFG_MEM_END is in the board dependent config-file (configs/config_BOARD.h)
- */
 _TEXT_BASE:
        .word   TEXT_BASE
 
@@ -92,24 +89,15 @@ _armboot_start:
        .word _start
 
 /*
- * Note: _armboot_end_data and _armboot_end are defined
- * by the (board-dependent) linker script.
- * _armboot_end_data is the first usable FLASH address after armboot
+ * These are defined in the board-specific linker script.
  */
-.globl _armboot_end_data
-_armboot_end_data:
-       .word armboot_end_data
-.globl _armboot_end
-_armboot_end:
-       .word armboot_end
+.globl _bss_start
+_bss_start:
+       .word __bss_start
 
-/*
- * _armboot_real_end is the first usable RAM address behind armboot
- * and the various stacks
- */
-.globl _armboot_real_end
-_armboot_real_end:
-       .word 0x0badc0de
+.globl _bss_end
+_bss_end:
+       .word _end
 
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
@@ -171,34 +159,53 @@ poll1:
        ldrh r1, [r0]
        ands r1, r1, #0x01
        beq poll1
-       bl  cpu_init_crit
 
-relocate:
        /*
-        * relocate armboot to RAM
+        * we do sys-critical inits only at reboot,
+        * not when booting from ram!
         */
-       adr     r0, _start              /* r0 <- current position of code */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       bl  cpu_init_crit
+#endif
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+relocate:                              /* relocate U-Boot to RAM           */
+       adr     r0, _start              /* r0 <- current position of code   */
+       ldr     r1, _TEXT_BASE          /* test if we run from flash or RAM */
+       cmp     r0, r1                  /* don't reloc during debug         */
+       beq     stack_setup
+
        ldr     r2, _armboot_start
-       ldr     r3, _armboot_end
-       sub     r2, r3, r2              /* r2 <- size of armboot */
-       ldr     r1, _TEXT_BASE          /* r1 <- destination address */
-       add     r2, r0, r2              /* r2 <- source end address */
+       ldr     r3, _bss_start
+       sub     r2, r3, r2              /* r2 <- size of armboot            */
+       add     r2, r0, r2              /* r2 <- source end address         */
 
-       /*
-        * r0 = source address
-        * r1 = target address
-        * r2 = source end address
-        */
 copy_loop:
-       ldmia   r0!, {r3-r10}
-       stmia   r1!, {r3-r10}
-       cmp     r0, r2
+       ldmia   r0!, {r3-r10}           /* copy from source address [r0]    */
+       stmia   r1!, {r3-r10}           /* copy to   target address [r1]    */
+       cmp     r0, r2                  /* until source end addreee [r2]    */
        ble     copy_loop
+#endif /* CONFIG_SKIP_RELOCATE_UBOOT */
+
+       /* Set up the stack                                                 */
+stack_setup:
+       ldr     r0, _TEXT_BASE          /* upper 128 KiB: relocated uboot   */
+       sub     r0, r0, #CONFIG_SYS_MALLOC_LEN  /* malloc area                      */
+       sub     r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo                        */
+#ifdef CONFIG_USE_IRQ
+       sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
+#endif
+       sub     sp, r0, #12             /* leave 3 words for abort-stack    */
 
-       /* set up the stack */
-       ldr     r0, _armboot_end
-       add     r0, r0, #CONFIG_STACKSIZE
-       sub     sp, r0, #12             /* leave 3 words for abort-stack */
+clear_bss:
+       ldr     r0, _bss_start          /* find start of bss segment        */
+       ldr     r1, _bss_end            /* stop here                        */
+       mov     r2, #0x00000000         /* clear                            */
+
+clbss_l:str    r2, [r0]                /* clear loop...                    */
+       add     r0, r0, #4
+       cmp     r0, r1
+       ble     clbss_l
 
        ldr     pc, _start_armboot
 
@@ -239,7 +246,7 @@ cpu_init_crit:
         * Go setup Memory and board specific bits prior to relocation.
         */
        mov     ip, lr          /* perserve link reg across call */
-       bl      platformsetup   /* go setup pll,mux,memory */
+       bl      lowlevel_init   /* go setup pll,mux,memory */
        mov     lr, ip          /* restore link */
        mov     pc, lr          /* back to my caller */
 /*
@@ -287,9 +294,9 @@ cpu_init_crit:
        sub     sp, sp, #S_FRAME_SIZE           @ carve out a frame on current user stack
        stmia   sp, {r0 - r12}                  @ Save user registers (now in svc mode) r0-r12
 
-       ldr     r2, _armboot_end                @ find top of stack
-       add     r2, r2, #CONFIG_STACKSIZE       @ find base of normal stack
-       sub     r2, r2, #8                      @ set base 2 words into abort stack
+       ldr     r2, _armboot_start
+       sub     r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
+       sub     r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
        ldmia   r2, {r2 - r3}                   @ get values for "aborted" pc and cpsr (into parm regs)
        add     r0, sp, #S_FRAME_SIZE           @ grab pointer to old stack
 
@@ -320,9 +327,9 @@ cpu_init_crit:
        .endm
 
        .macro get_bad_stack
-       ldr     r13, _armboot_end               @ get bottom of stack (into sp by by user stack pointer).
-       add     r13, r13, #CONFIG_STACKSIZE     @ head to reserved words at the top of the stack
-       sub     r13, r13, #8                    @ reserved a couple spots in abort stack
+       ldr     r13, _armboot_start             @ setup our mode stack
+       sub     r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
+       sub     r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
 
        str     lr, [r13]                       @ save caller lr in position 0 of saved stack
        mrs     lr, spsr                        @ get the spsr
@@ -350,31 +357,31 @@ cpu_init_crit:
 undefined_instruction:
        get_bad_stack
        bad_save_user_regs
-       bl      do_undefined_instruction
+       bl      do_undefined_instruction
 
        .align  5
 software_interrupt:
        get_bad_stack
        bad_save_user_regs
-       bl      do_software_interrupt
+       bl      do_software_interrupt
 
        .align  5
 prefetch_abort:
        get_bad_stack
        bad_save_user_regs
-       bl      do_prefetch_abort
+       bl      do_prefetch_abort
 
        .align  5
 data_abort:
        get_bad_stack
        bad_save_user_regs
-       bl      do_data_abort
+       bl      do_data_abort
 
        .align  5
 not_used:
        get_bad_stack
        bad_save_user_regs
-       bl      do_not_used
+       bl      do_not_used
 
 #ifdef CONFIG_USE_IRQ
 
@@ -382,7 +389,7 @@ not_used:
 irq:
        get_irq_stack
        irq_save_user_regs
-       bl      do_irq
+       bl      do_irq
        irq_restore_user_regs
 
        .align  5
@@ -390,7 +397,7 @@ fiq:
        get_fiq_stack
        /* someone ought to write a more effiction fiq_save_user_regs */
        irq_save_user_regs
-       bl      do_fiq
+       bl      do_fiq
        irq_restore_user_regs
 
 #else
@@ -399,13 +406,13 @@ fiq:
 irq:
        get_bad_stack
        bad_save_user_regs
-       bl      do_irq
+       bl      do_irq
 
        .align  5
 fiq:
        get_bad_stack
        bad_save_user_regs
-       bl      do_fiq
+       bl      do_fiq
 
 #endif