;/*************************************************************************************
; File Name : startup.s
; File Description : This file implements the startup procedure.
;*************************************************************************************/
GET ..\inc\option.inc
;=======================================================
; ENTRY
;=======================================================
AREA Init,CODE,READONLY ;定义一个代码段,名字是init,属性是只读
ENTRY ;程序执行的入口点
ResetHandler ;这段代码
LDR R13, =top_of_stacks ;R13用作堆栈指针
;=======================================================
;关闭看门狗
;=======================================================
ldr r0,=0x7E004000
mov r1,#0
str r1,[r0]
[ (USE_TCM = 1) ;USE_TCM has been set to 1 in predefined handle
; ----------------------------------------
; Initialize TCM
; ----------------------------------------
; TCM0(D-TCM, I-TCM) Configuration
mov r0,#0x0
mcr p15,0,r0,c9,c2,0 ; Write TCM Selection register
;上面那句指令的意思是:将ARM寄存器r0的数据传送到
;协处理器P15,语法参见内核文档第140页(3-8)内容在
;228页(3-96)00选中TCM0,01选中TCM1,10和11是忽略写访问。
ldr r0,=ITCM0_BaseAddress ;0x80000011传递给R0
mcr p15,0,r0,c9,c1,1 ; Write Instruction TCM0 region register(3-91)
ldr r0,=DTCM0_BaseAddress ;写数据TCM
mcr p15,0,r0,c9,c1,0 ; Write Data TCM0 region register(3-90)
; TCM1(D-TCM, I-TCM) Configuration
mov r0,#0x1 ;选中TCM1
mcr p15,0,r0,c9,c2,0 ; Write TCM Selection register
ldr r0,=ITCM1_BaseAddress
mcr p15,0,r0,c9,c1,1 ; Write Instruction TCM1 region register
ldr r0,=DTCM1_BaseAddress
mcr p15,0,r0,c9,c1,0 ; Write Data TCM0 region register
] ;Endif
IMPORT ScatterLoad
LDR R0, =ScatterLoad
MOV LR, PC ;LR指的是linker register,也就是R14;这个地方时调用子程序
BX R0 ;跳转执行
EXPORT __main ;这里初始化C语言程序入口
__main
;; initialise the C library (which calls main())
IMPORT __rt_entry
LDR R0, =__rt_entry
BX R0 ;跳转到C语言执行
b .
;=======================================================
END