Boot来DIY自己的arm11(6410)的bootloader(3)

/*
 *************************************************************************
 *
 * CPU_init_critical registers
 *
 * setup important registers
 * setup memory timing
 *
 *************************************************************************
 */
        /*
        * we do sys-critical inits only at reboot,
        * not when booting from ram!
        */
//cpu初始化
cpu_init_crit:
 /*
  * flush v4 I/D caches
  */
  //关闭I/Dcaches
 mov r0, #0
 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */

/*
  * disable MMU stuff and caches
  */
  //关闭MMU
 mrc p15, 0, r0, c1, c0, 0
 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
 orr r0, r0, #0x00000002 @ set bit 2 (A) Align
 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
 mcr p15, 0, r0, c1, c0, 0

/* Peri port setup */
 //外设基地址设置
 ldr r0, =0x70000000
 orr r0, r0, #0x13
    mcr p15,0,r0,c15,c2,4      @ 256M(0x70000000-0x7fffffff)
//因为是只定义了6410,别的都忽略
#ifdef CONFIG_BOOT_ONENAND
 ldr r0, =0x70000000  @ onenand controller setup
 orr r0, r0, #0x100000
 ldr r1, =0x4000
 orr r1, r1, #0xe0
 str r1, [r0]
//关闭6410的看门狗
#if defined(CONFIG_S3C6410) || defined(CONFIG_S3C6430)
 orr r0, r0, #300  @ disable watchdog
 mov r1, #1
 str r1, [r0]

mov r1, #0x23000000  @ start buffer register
 orr r1, r1, #0x30000
 orr r1, r1, #0xc800
#else  //不执行
 mov r1, =0x20000000  @ start buffer register
 orr r1, r1, #0xc30000
 orr r1, r1, #0xc800
#endif

sub r0, r1, #0x0400  @ start address1 register

ldr r2, [r1, #0x84]  @ ecc bypass
 orr r2, r2, #0x100
 str r2, [r1, #0x84]

mov r3, #0x0  @ DFS, FBA
 str r3, [r0, #0x00]
 str r3, [r0, #0x04]  @ select dataram for DDP as 0

mov r4, #0x104  @ interrupt register
 mov r5, #0x0002  @ FPA, FSA
 mov r6, #0x0800  @ BSA

onenand_bl1_load:
 str r5, [r0, #0x1c]  @ save FPA, FSA
 orr r6, r6, #0x02  @ BSC
 str r6, [r1, #0x00]  @ save BSA, BSC
 str r3, [r1, r4]  @ clear interrupt
 str r3, [r1, #0x80]  @ write load command

mov r7, #0x100  @ need small delay

onenand_wait_loop1:
 subs r7, r7, #0x1
 bne onenand_wait_loop1

add r5, r5, #0x2  @ next FPA, FSA
 sub r6, r6, #0x2
 add r6, r6, #0x200  @ next BSA
 cmp r5, #0x8
 bne onenand_bl1_load
#endif

/*
  * Go setup Memory and board specific bits prior to relocation.
  */
 bl lowlevel_init /* go setup pll,mux,memory */

/* when we already run in ram, we don't need to relocate U-Boot.
  * and actually, memory controller must be configured before U-Boot
  * is running in ram.
  */
 
  ldr r0, =0xff000fff
 
 


 bic r1, pc, r0  /* r0 <- current base addr of code */
 ldr r2, _TEXT_BASE  /* r1 <- original base addr in ram */
 bic r2, r2, r0  /* r0 <- current base addr of code */
 cmp    r1, r2                  /* compare r0, r1                  */
 beq    after_copy  /* r0 == r1 then skip flash copy  */
//使用nandflash,此处忽略
#ifdef CONFIG_BOOT_NOR  /* relocate U-Boot to RAM */
 adr r0, _start  /* r0 <- current position of code  */
 ldr r1, _TEXT_PHY_BASE /* r1 <- destination                */
 ldr r2, _armboot_start
 ldr r3, _bss_start
 sub r2, r3, r2  /* r2 <- size of armboot            */
 add r2, r0, r2  /* r2 <- source end address        */

nor_copy_loop:
 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 nor_copy_loop
 b after_copy
#endif
//从Nandflash启动,执行此处代码
#ifdef CONFIG_BOOT_NAND
 mov r0, #0x1000
 bl copy_from_nand
#endif

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2c4b5a376011f5a91a566a097dc0a659.html