arm: unify linker script
[oweals/u-boot.git] / cpu / arm925t / start.S
index 0a3042d9a650a92277c1840ecef2605bf0d9f53c..567e80479e2f68fdd5f75cf1052bd1aa57121e9f 100644 (file)
@@ -7,9 +7,9 @@
  *
  *  Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
  *  Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
- *  Copyright (c) 2002 Gary Jennejohn <gj@denx.de>
+ *  Copyright (c) 2002 Gary Jennejohn <garyj@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.
@@ -89,16 +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
+
+.globl _bss_end
+_bss_end:
+       .word _end
 
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
@@ -165,10 +164,11 @@ poll1:
         * we do sys-critical inits only at reboot,
         * not when booting from ram!
         */
-#ifdef CONFIG_INIT_CRITICAL
+#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 */
@@ -176,7 +176,7 @@ relocate:                           /* relocate U-Boot to RAM           */
        beq     stack_setup
 
        ldr     r2, _armboot_start
-       ldr     r3, _armboot_end
+       ldr     r3, _bss_start
        sub     r2, r3, r2              /* r2 <- size of armboot            */
        add     r2, r0, r2              /* r2 <- source end address         */
 
@@ -185,17 +185,28 @@ copy_loop:
        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, #CFG_MALLOC_LEN /* malloc area                      */
-       sub     r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo                        */
+       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    */
 
+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
 
 _start_armboot:        .word start_armboot
@@ -235,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 */
 /*
@@ -283,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
 
@@ -316,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
@@ -346,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
 
@@ -378,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
@@ -386,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
@@ -395,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