1 /* 2 *head.S for sdram 3 */ 4 .include "2440addr.inc" 5 .include "option.inc" 6 .section .text 7 /* 8 * exception vector table 9 */ 10 .global _start 11 _start: 12 b reset 13 b HandleUndef 14 b HandleSWI 15 b HandlePrefetchAbort 16 b HandleDataAbort 17 b HandleNotUsed 18 b HandleIRQ 19 b HandleFIQ 20 21 .global _end 22 _end: 23 .word __bss@定义在sdram.lds中 24 reset: 25 @set cpu to svc32 mode 26 mrs r0, cpsr 27 bic r0, r0, #0x1f 28 orr r0, r0, #0xd3 29 msr cpsr, r0 30 31 @ disable watch dog timer 32 ldr r0, =rWTCON 33 mov r1, #0x0 34 str r1, [r0] 35 @through system clock,you can will see led is fast 36 #if 1 37 @diable all interrupts 38 mov r1, #0xffffffff 39 ldr r0, =rINTMSK 40 str r1, [r0] 41 42 ldr r1, = 0x7fff 43 ldr r0, = rINTSUBMSK 44 str r1, [r0] 45 46 @initialise system clocks 47 ldr r0, =rLOCKTIME 48 ldr r1, =0xffffff 49 str r1, [r0] 50 51 ldr r0, =rCAMDIVN 52 mov r1, #0 53 str r1, [r0] 54 55 ldr r0, =rCLKDIVN 56 ldr r1, =vCLKDIVN_148 57 str r1, [r0] 58 59 mrc p15, 0, r1, c1, c0, 0 60 orr r1, r1, #0xc0000000 61 mcr p15, 0, r1, c1, c0, 0 62 63 ldr r0, = rMPLLCON 64 ldr r1, = vMPLL_400 65 str r1, [r0] 66 #endif 67 bl memsetup 68 69 bl copysram4sdram 70 @jump to ram 71 ldr r1, =on_the_ram 72 add pc, r1, #0 73 nop 74 nop 75 1: b 1b 76 77 on_the_ram: 78 ldr sp,=0x34000000 79 bl start_main 80 81 copysram4sdram: 82 mov r1, #0 83 ldr r2, =0x30000000 84 ldr r3, =_end 85 ldr r3, [r3] 86 sub r3, r3, r2@要得到相对地址 87 88 1: ldr r4, [r1], #4 89 str r4, [r2], #4 90 cmp r1, r3 91 bne 1b 92 mov pc, lr 93 94 memsetup: 95 /*intialize the sdram*/ 96 mov r1, #0x48000000 97 adrl r2, mem_cfg_val 98 add r3, r1, #52 99 1: ldr r4, [r2], #4 100 str r4, [r1], #4 101 cmp r1, r3 116 1: b 1b 117 118 HandleNotUsed: 119 1: b 1b 120 121 HandleIRQ: 122 1: b 1b 123 124 HandleFIQ: 125 1: b 1b 126 127 .align 4 128 mem_cfg_val: 129 .word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5 _BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28)) 130 .word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+( B0_Tacp<<2)+(B0_PMC)) 131 .word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+( B1_Tacp<<2)+(B1_PMC)) 132 .word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+( B2_Tacp<<2)+(B2_PMC)) 133 .word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+( B3_Tacp<<2)+(B3_PMC)) 134 .word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+( B4_Tacp<<2)+(B4_PMC)) 135 .word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+( B5_Tacp<<2)+(B5_PMC)) 136 .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN)) 137 .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN)) 138 .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT) 139 .word 0x32 140 .word 0x30 141 .word 0x30
|