uboot/arch/arm/cpu/arm_intcm/start.S
<<
>>
Prefs
   1/*
   2 *  armboot - Startup Code for ARM926EJS CPU-core
   3 *
   4 *  Copyright (c) 2003  Texas Instruments
   5 *
   6 *  ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------
   7 *
   8 *  Copyright (c) 2001  Marius Gröger <mag@sysgo.de>
   9 *  Copyright (c) 2002  Alex Züpke <azu@sysgo.de>
  10 *  Copyright (c) 2002  Gary Jennejohn <garyj@denx.de>
  11 *  Copyright (c) 2003  Richard Woodruff <r-woodruff2@ti.com>
  12 *  Copyright (c) 2003  Kshitij <kshitij@ti.com>
  13 *
  14 * See file CREDITS for list of people who contributed to this
  15 * project.
  16 *
  17 * This program is free software; you can redistribute it and/or
  18 * modify it under the terms of the GNU General Public License as
  19 * published by the Free Software Foundation; either version 2 of
  20 * the License, or (at your option) any later version.
  21 *
  22 * This program is distributed in the hope that it will be useful,
  23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25 * GNU General Public License for more details.
  26 *
  27 * You should have received a copy of the GNU General Public License
  28 * along with this program; if not, write to the Free Software
  29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30 * MA 02111-1307 USA
  31 */
  32
  33#include <asm-offsets.h>
  34#include <config.h>
  35#include <version.h>
  36
  37/*
  38 *************************************************************************
  39 *
  40 * Jump vector table
  41 *
  42 *************************************************************************
  43 */
  44
  45.globl _start
  46_start:
  47        b       reset
  48        ldr     pc, _undefined_instruction
  49        ldr     pc, _software_interrupt
  50        ldr     pc, _prefetch_abort
  51        ldr     pc, _data_abort
  52        ldr     pc, _not_used
  53        ldr     pc, _irq
  54        ldr     pc, _fiq
  55
  56_undefined_instruction:
  57        .word undefined_instruction
  58_software_interrupt:
  59        .word software_interrupt
  60_prefetch_abort:
  61        .word prefetch_abort
  62_data_abort:
  63        .word data_abort
  64_not_used:
  65        .word not_used
  66_irq:
  67        .word irq
  68_fiq:
  69        .word fiq
  70
  71        .balignl 16,0xdeadbeef
  72
  73/*
  74 *************************************************************************
  75 *
  76 * Startup Code (reset vector)
  77 *
  78 * do important init only if we don't start from memory!
  79 * setup memory and board specific bits prior to relocation.
  80 * relocate armboot to ram
  81 * setup stack
  82 *
  83 *************************************************************************
  84 */
  85
  86.globl _TEXT_BASE
  87_TEXT_BASE:
  88#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
  89        .word   CONFIG_SPL_TEXT_BASE
  90#else
  91        .word   CONFIG_SYS_TEXT_BASE
  92#endif
  93
  94/*
  95 * These are defined in the board-specific linker script.
  96 * Subtracting _start from them lets the linker put their
  97 * relative position in the executable instead of leaving
  98 * them null.
  99 */
 100.globl _bss_start_ofs
 101_bss_start_ofs:
 102        .word __bss_start - _start
 103
 104.globl _bss_end_ofs
 105_bss_end_ofs:
 106        .word __bss_end - _start
 107
 108.globl _end_ofs
 109_end_ofs:
 110        .word _end - _start
 111
 112#ifdef CONFIG_USE_IRQ
 113/* IRQ stack memory (calculated at run-time) */
 114.globl IRQ_STACK_START
 115IRQ_STACK_START:
 116        .word   0x0badc0de
 117
 118/* IRQ stack memory (calculated at run-time) */
 119.globl FIQ_STACK_START
 120FIQ_STACK_START:
 121        .word 0x0badc0de
 122#endif
 123
 124/* IRQ stack memory (calculated at run-time) + 8 bytes */
 125.globl IRQ_STACK_START_IN
 126IRQ_STACK_START_IN:
 127        .word   0x0badc0de
 128
 129/*
 130 * the actual reset code
 131 */
 132
 133reset:
 134        /*
 135         * set the cpu to SVC32 mode
 136         */
 137        mrs     r0,cpsr
 138        bic     r0,r0,#0x1f
 139        orr     r0,r0,#0xd3
 140        msr     cpsr,r0
 141
 142        /*
 143         * we do sys-critical inits only at reboot,
 144         * not when booting from ram!
 145         */
 146#ifndef CONFIG_SKIP_LOWLEVEL_INIT
 147        bl      cpu_init_crit
 148#endif
 149
 150        bl      _main
 151
 152/*------------------------------------------------------------------------------*/
 153
 154        .globl  c_runtime_cpu_setup
 155c_runtime_cpu_setup:
 156
 157        mov     pc, lr
 158
 159/*
 160 *************************************************************************
 161 *
 162 * CPU_init_critical registers
 163 *
 164 * setup important registers
 165 * setup memory timing
 166 *
 167 *************************************************************************
 168 */
 169
 170#ifndef CONFIG_SKIP_LOWLEVEL_INIT
 171cpu_init_crit:
 172        /*  arm_int_generic assumes the ARM boot monitor, or user software,
 173         * has initialized the platform
 174         */
 175        mov     pc, lr          /* back to my caller */
 176#endif
 177/*
 178 *************************************************************************
 179 *
 180 * Interrupt handling
 181 *
 182 *************************************************************************
 183 */
 184
 185@
 186@ IRQ stack frame.
 187@
 188#define S_FRAME_SIZE    72
 189
 190#define S_OLD_R0        68
 191#define S_PSR           64
 192#define S_PC            60
 193#define S_LR            56
 194#define S_SP            52
 195
 196#define S_IP            48
 197#define S_FP            44
 198#define S_R10           40
 199#define S_R9            36
 200#define S_R8            32
 201#define S_R7            28
 202#define S_R6            24
 203#define S_R5            20
 204#define S_R4            16
 205#define S_R3            12
 206#define S_R2            8
 207#define S_R1            4
 208#define S_R0            0
 209
 210#define MODE_SVC 0x13
 211#define I_BIT    0x80
 212
 213/*
 214 * use bad_save_user_regs for abort/prefetch/undef/swi ...
 215 * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling
 216 */
 217
 218        .macro  bad_save_user_regs
 219        @ carve out a frame on current user stack
 220        sub     sp, sp, #S_FRAME_SIZE
 221        stmia   sp, {r0 - r12}  @ Save user registers (now in svc mode) r0-r12
 222
 223        ldr     r2, IRQ_STACK_START_IN
 224        @ get values for "aborted" pc and cpsr (into parm regs)
 225        ldmia   r2, {r2 - r3}
 226        add     r0, sp, #S_FRAME_SIZE           @ grab pointer to old stack
 227        add     r5, sp, #S_SP
 228        mov     r1, lr
 229        stmia   r5, {r0 - r3}   @ save sp_SVC, lr_SVC, pc, cpsr
 230        mov     r0, sp          @ save current stack into r0 (param register)
 231        .endm
 232
 233        .macro  irq_save_user_regs
 234        sub     sp, sp, #S_FRAME_SIZE
 235        stmia   sp, {r0 - r12}                  @ Calling r0-r12
 236        @ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good.
 237        add     r8, sp, #S_PC
 238        stmdb   r8, {sp, lr}^           @ Calling SP, LR
 239        str     lr, [r8, #0]            @ Save calling PC
 240        mrs     r6, spsr
 241        str     r6, [r8, #4]            @ Save CPSR
 242        str     r0, [r8, #8]            @ Save OLD_R0
 243        mov     r0, sp
 244        .endm
 245
 246        .macro  irq_restore_user_regs
 247        ldmia   sp, {r0 - lr}^                  @ Calling r0 - lr
 248        mov     r0, r0
 249        ldr     lr, [sp, #S_PC]                 @ Get PC
 250        add     sp, sp, #S_FRAME_SIZE
 251        subs    pc, lr, #4              @ return & move spsr_svc into cpsr
 252        .endm
 253
 254        .macro get_bad_stack
 255        ldr     r13, IRQ_STACK_START_IN         @ setup our mode stack
 256
 257        str     lr, [r13]       @ save caller lr in position 0 of saved stack
 258        mrs     lr, spsr        @ get the spsr
 259        str     lr, [r13, #4]   @ save spsr in position 1 of saved stack
 260        mov     r13, #MODE_SVC  @ prepare SVC-Mode
 261        @ msr   spsr_c, r13
 262        msr     spsr, r13       @ switch modes, make sure moves will execute
 263        mov     lr, pc          @ capture return pc
 264        movs    pc, lr          @ jump to next instruction & switch modes.
 265        .endm
 266
 267        .macro get_irq_stack                    @ setup IRQ stack
 268        ldr     sp, IRQ_STACK_START
 269        .endm
 270
 271        .macro get_fiq_stack                    @ setup FIQ stack
 272        ldr     sp, FIQ_STACK_START
 273        .endm
 274
 275/*
 276 * exception handlers
 277 */
 278        .align  5
 279.globl undefined_instruction
 280undefined_instruction:
 281        get_bad_stack
 282        bad_save_user_regs
 283        bl      do_undefined_instruction
 284
 285        .align  5
 286.globl software_interrupt
 287software_interrupt:
 288        get_bad_stack
 289        bad_save_user_regs
 290        bl      do_software_interrupt
 291
 292        .align  5
 293.globl prefetch_abort
 294prefetch_abort:
 295        get_bad_stack
 296        bad_save_user_regs
 297        bl      do_prefetch_abort
 298
 299        .align  5
 300.globl data_abort
 301data_abort:
 302        get_bad_stack
 303        bad_save_user_regs
 304        bl      do_data_abort
 305
 306        .align  5
 307.globl not_used
 308not_used:
 309        get_bad_stack
 310        bad_save_user_regs
 311        bl      do_not_used
 312
 313#ifdef CONFIG_USE_IRQ
 314        .align  5
 315.globl irq
 316irq:
 317        get_irq_stack
 318        irq_save_user_regs
 319        bl      do_irq
 320        irq_restore_user_regs
 321
 322        .align  5
 323.globl fiq
 324fiq:
 325        get_fiq_stack
 326        /* someone ought to write a more effiction fiq_save_user_regs */
 327        irq_save_user_regs
 328        bl      do_fiq
 329        irq_restore_user_regs
 330
 331#else
 332
 333        .align  5
 334.globl irq
 335irq:
 336        get_bad_stack
 337        bad_save_user_regs
 338        bl      do_irq
 339
 340        .align  5
 341.globl fiq
 342fiq:
 343        get_bad_stack
 344        bad_save_user_regs
 345        bl      do_fiq
 346
 347#endif
 348