normal_boot:
/* check the first 1MB of BLOB_START in increments of 4k */
mov r7, #0x1000
mov r6, r7, lsl #8 /* 4k << 2^8 = 1MB */
ldr r5, BLOB_START
BLOB_START内存装载bootloader的起始地址 |
mem_test_loop:
mov r0, r5
bl testram
.text .globl testram @ r0 = address to test @ returns r0 = 0 - ram present, r0 = 1 - no ram @ clobbers r1 - r4 testram: ldmia r0, {r1, r2} @ store current value in r1 and r2 mov r3, #0x55 @ write 0x55 to first word mov r4, #0xaa @ 0xaa to second stmia r0, {r3, r4} ldmia r0, {r3, r4} @ read it back teq r3, #0x55 @ do the values match teqeq r4, #0xaa bne bad @ oops, no mov r3, #0xaa @ write 0xaa to first word mov r4, #0x55 @ 0x55 to second stmia r0, {r3, r4} ldmia r0, {r3, r4} @ read it back teq r3, #0xaa @ do the values match teqeq r4, #0x55 bad: stmia r0, {r1, r2} @ in any case, restore old data moveq r0, #0 @ ok - all values matched movne r0, #1 @ no ram at this location mov pc, lr 程序思想:
先保存memory page地址开始的两个字
想这两字写入数字
立即读回这两个字,显然这两个字的内容就是刚写的,若内容不相等,说明RAM出错
然后再写入两字,读回比较
最后恢复开始两个字的内容
返回一个值到(r1)中,0表示RAM是好的,1表示RAM出错 |
teq r0, #1
beq badram
add r5, r5, r7
subs r6, r6, r7
bne mem_test_loop
relocate:
/* relocate the second stage loader */
add r2, r0, #(64 * 1024) /* blob maximum size is 64kB */
_start 为bootloader启动的第一条指令的地址 |
add r0, r0, #0x400 /* skip first 1024 bytes */
跳过前面的1KB,有待理解,然道是由于前面的1Kb是存放了stage1,不许载入,这样解释到是很合理~ |
ldr r1, BLOB_START
/* r0 = source address
* r1 = target address
* r2 = source end address
*/
copy_loop:
ldmia r0!, {r3-r10}
将R0指向的单元中的数据读出到R3-r10,r0地址将自动实现加1 |
stmia r1!, {r3-r10}
将R3~R10的值读出到R1指向的连续空间,r0地址将自动实现加1 |
cmp r0, r2
ble copy_loop
阅读(1120) | 评论(0) | 转发(0) |