Chinaunix首页 | 论坛 | 博客
  • 博客访问: 545423
  • 博文数量: 101
  • 博客积分: 1889
  • 博客等级: 上尉
  • 技术积分: 906
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-14 16:22
文章分类

全部博文(101)

文章存档

2012年(11)

2011年(19)

2010年(59)

2009年(12)

我的朋友

分类: LINUX

2010-05-21 11:08:08

//

.section start
    .text

     #include "include/part.h"

/*----------------------------------------------------------------------------
 Area Definition
----------------
 Must be defined as function to put first in the code as it must be mapped
 at offset 0 of the flash EBI_CSR0, ie. at address 0 before remap.
_---------------------------------------------------------------------------*/

/* Application startup entry point */

    .globl reset
    .align 4
reset:

/* Exception vectors (should be a branch to be detected as a valid code by the rom */
_exception_vectors:
    b     reset_vector /* reset */
    b     undef_vector     /* Undefined Instruction */
    b     swi_vector     /* Software Interrupt */
    b     pabt_vector     /* Prefetch Abort */
    b     dabt_vector     /* Data Abort */
    b     rsvd_vector     /* reserved */
    b     irq_vector    /* IRQ : read the AIC */
    b     fiq_vector /* FIQ */

undef_vector:
    b     undef_vector
swi_vector:
    b     swi_vector
pabt_vector:
    b     pabt_vector
dabt_vector:
    b     dabt_vector
rsvd_vector:
    b     rsvd_vector
irq_vector:
    b     irq_vector
fiq_vector:
    b     fiq_vector
reset_vector:

/* Init the stack */
_init_stack:
    ldr sp,=TOP_OF_MEM      //设置栈

/* Test if main oscillator is enabled */
    ldr     r0,=AT91C_PMC_SR  
    ldr     r1, [r0]
    ldr     r2,=AT91C_PMC_MOSCS
    ands     r1, r1, r2
    bne _switch_to_mosc        //main oscillator可以使用,则切换

/* Enable the main oscillator */   //main oscillator未启用,则启用
_enable_mosc:
    ldr     r0,=AT91C_PMC_MOR
    mov     r1, #(0x40 << 8)
    ldr     r2,=AT91C_CKGR_MOSCEN
    orr     r1, r1, r2
    str    r1, [r0]
    ldr     r0,=AT91C_PMC_SR
1:
    ldr     r1, [r0]
    ldr     r2,=AT91C_PMC_MOSCS
    ands     r1, r1, r2
    beq 1b
    
/* Test if MCK == SLOW CLOCK */

//MCK=master clock,可以是main clock、slow clock、PLLA、PLLB中的一个
_switch_to_mosc:
    ldr     r0,=AT91C_PMC_MCKR
    ldr     r1,=AT91C_PMC_CSS
    ldr     r2, [r0]
    and     r2, r2, r1
    mov    r1, #0
    cmp     r1, r2
/* No => Do nothing */
    bne    _init_bss
/* Yes => Switch to the main oscillator */
    ldr     r1,=AT91C_PMC_CSS_MAIN_CLK
    ldr     r2,=AT91C_PMC_PRES_CLK
    orr    r1, r1, r2
    str     r1, [r0]
    ldr     r0,=AT91C_PMC_SR
1:
    ldr r1, [r0]
    ldr    r2,=AT91C_PMC_MCKRDY
    ands r1, r1, r2
    beq 1b

/* Initialize the bss segment */
_init_bss:
    adr r2, _lp_bss
    ldmia r2, {r3, r4}
    mov r2, #0
1:
    cmp r3, r4
    strcc r2, [r3], #4
    bcc 1b

#ifdef CFG_NORFLASH        

//如果是从NorFlash启动,那么拷贝NorFlash中的4K代码到内部的sram0中
/*if boot from nor flash then relocate to RAM */
relocate:
        ldr r1, _loop_start
        ldr r2, _loop_end
        ldr r3, _loop_target

copy_loop:
        ldr r4,[r1],#4
        str r4,[r3],#4
        cmp r3,r2
        ble copy_loop
#endif


/* Branch on C code Main function (with interworking) */
_branch_main:
    ldr r4, = main
    mov lr, pc
    bx r4

/* Branch to the application at the end of the bootstrap init */
_go:
    ldr     r1, =MACH_TYPE
    mov lr, pc
    bx r0

    .align
_lp_bss:
    .word __bss_start__
    .word __bss_end__

 _loop_start:
        .word 0x10000000     //NorFlash的起始地址

_loop_end:
        .word 0x201000      //内部sram0的结束地址

_loop_target:
        .word 0x200000      //内部sram0的起始地址


 

阅读(1233) | 评论(0) | 转发(0) |
0

上一篇:ATMEL9260 REMAP理解

下一篇:9260的启动方式

给主人留下些什么吧!~~