分类: LINUX
2010-03-31 08:35:12
上回书说到flashloader把bootloader load到0x0AFE0100, 然回跳了过去,
其实0x0AFE0100 就是烧在flash 0x0C000100中的真正的bootloader:
bootloader 有几个文件组成,先是START.s,也是唯一的一个汇编程序,其余的都是C写成的,START.s主要初始化堆栈:
_start:
ldr r1,=StackInit
ldr sp,[r1]
b main
//此处我们跳到了C代码的main函数,当C代码执行完后,还要调用
//下面的JumpToKernel0x跳到LINXU kernel运行
.equ StackInitValue, __end_data+0x1000 // 4K __end_data在连结脚本中指定
StackInit:
.long StackInitValue
.global JumpToKernel
JumpToKernel:
// jump to the copy code (get the arguments right)
mov pc, r0
.global JumpToKernel0x
// r0 = jump address
// r1-r4 = arguments to use (these get shifted)
JumpToKernel0x:
// jump to the copy code (get the arguments right)
mov r8, r0
mov r0, r1
mov r1, r2
mov r2, r3
mov r3, r4
mov pc, r8
.section ".data.boot"
.section ".bss.boot"