-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.S
executable file
·149 lines (121 loc) · 3.37 KB
/
start.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* 张旭写于 2018.12.27 9:42pm
*
* Asymptote的程序入口
*
*
*
*/
.equ MEM_CTL_BASE, 0x48000000
.equ CLKDIVN, 0x4C000014
.equ MPLLCON, 0x4C000004
#define S3C2440_MPLL_200MHZ ((0x5c<<12)|(0x01<<4)|(0x02))
#define S3C2440_MPLL_400MHZ ((0x5c<<12)|(0x01<<4)|(0x01))
.text
.global _start
/*****************************************************************************/
@程序入口
_start:
@ 0x00: 复位异常的向量地址
b Reset
@ 0x04: 未定义指令中止模式的向量地址
HandleUndef:
b HandleUndef
@ 0x08: 管理模式的向量地址(在用户模式下,可通过SWI指令进入该模式)
HandleSvc:
b HandleSvc
@ 0x0c: 指令预取中止异常的向量地址
HandlePrefetchAbort:
b HandlePrefetchAbort
@ 0x10: 数据访问中止异常的向量地址
HandleDataAbort:
b HandleDataAbort
@ 0x14: 保留
HandleNotUsed:
b HandleNotUsed
@ 0x18: 中断模式的向量地址
HandleIRQ:
b HandleIRQ
@ 0x1c: 快中断模式的向量地址
HandleFIQ:
b HandleFIQ
/*****************************************************************************/
@复位异常入口
Reset:
ldr sp, =4096 @重启默认进入SVC模式,此处设置SVC模式栈指针
bl disable_watch_dog
bl clock_init
bl sdram_init
bl nand_init @初始化 NAND Flash
@nand_read函数需要3个参数:
ldr r1, =0x30000000 @1.目标地址=0x30000000,这是SDRAM的起始地址
mov r0, #0 @2.源地址 = 0
mov r2, #(1024*20) @3.复制长度 = 20KB
bl nand_read @调用C函数nand_read
ldr pc, =on_sdram @跳到SDRAM中继续执行
on_sdram:
msr cpsr_c, #0xdf @进入系统模式
ldr sp, =0x34000000 @设置系统模式栈指针
@ ldr lr, =loop
ldr lr, =0x32000000
ldr pc, =main
loop:
b loop
/***************************************************************/
disable_watch_dog:
ldr r0, =0x53000000 @关闭看门狗
mov r1, #0
str r1, [r0]
mov pc, lr
clock_init:
ldr r0, =CLKDIVN
@ mov r1, #0x03 @1:2:4
mov r1, #0x05 @1:4:8
str r1, [r0]
mrc p15, 0, r1, c1, c0, 0
orr r1, r1, #0xc0000000
mcr p15, 0, r1, c1, c0, 0
ldr r0, =MPLLCON
@ ldr r1, =S3C2440_MPLL_200MHZ
ldr r1, =S3C2440_MPLL_400MHZ
str r1, [r0]
mov pc, lr
sdram_init:
mov r1, #MEM_CTL_BASE @r1存放存储控制器基地址
adrl r2, mem_cfg_val @
add r3, r1, #13*4 @r3存放存储控制器尾地址
1:
ldr r4, [r2], #4 @
str r4, [r1], #4
cmp r1, r3
bne 1b
mov pc, lr
.align 4
mem_cfg_val:
@ 存储控制器13个寄存器的设置值
@ .long 0x22011110 @ BWSCON
@ .long 0x00000700 @ BANKCON0
@ .long 0x00000700 @ BANKCON1
@ .long 0x00000700 @ BANKCON2
@ .long 0x00000700 @ BANKCON3
@ .long 0x00000700 @ BANKCON4
@ .long 0x00000700 @ BANKCON5
@ .long 0x00018005 @ BANKCON6
@ .long 0x00018005 @ BANKCON7
@ .long 0x008C07A3 @ REFRESH
@ .long 0x000000B1 @ BANKSIZE
@ .long 0x00000030 @ MRSRB6
@ .long 0x00000030 @ MRSRB7
.long 0x22011110 //BWSCON
.long 0x00000700 //BANKCON0
.long 0x00000700 //BANKCON1
.long 0x00000700 //BANKCON2
.long 0x00000700 //BANKCON3
.long 0x00000740 //BANKCON4
.long 0x00000700 //BANKCON5
.long 0x00018005 //BANKCON6
.long 0x00018005 //BANKCON7
.long 0x008C04F4 // REFRESH
.long 0x000000B1 //BANKSIZE
.long 0x00000030 //MRSRB6
.long 0x00000030 //MRSRB7