📄 post.h
字号:
str r1, [r0]
START_UART r0, r1
/* ---------- XScale Scratchpad test ---------- */
/* -------------------------------------------- */
bl PrintString
.ascii "\n"
.ascii " Testing Xscale Scratchpad memory... \0"
.align 2
ldr r5, =0x5A5A5A5A //pattern
ldr r8, =SCRATCHPAD_BASE //load scratch base
ldr r7, =SCRATCH_TEST_END_ADDR
10:
//initialize entire memory to be tetsed with the pattern
str r5, [r8], #0x4
cmp r8, r7
bne 10b
// Check for pattern going from START to END address, while loading inverse pattern
ldr r8, =SCRATCHPAD_BASE //load scratch base
112:
ldr r6, [r8] //read back the value at addr in r4 to r6 and increment the addrin r4
cmp r6,r5 //compare the read and written values
blne 223f //scratch_err
ldr r6, = 0xA5A5A5A5
str r6, [r8], #0x4 //store the inverse pattern and increment addr
cmp r8, r7
bne 112b
// Check for inverse pattern going from END to START
ldr r7, =SCRATCHPAD_BASE //load scratch base
ldr r5, =0xA5A5A5A5 // inverse pattern
113:
sub r8,r8, #0x4 //load the last addr
ldr r6,[r8] //read test location
cmp r6, r5 //compare with inverse pattern
blne 223f //error
cmp r8, r7
bne 113b
HEX_DISPLAY 'X', 'S', 'C', 'P'
bl PrintString
.ascii "PASS\n\0"
.align 2
b 224f
223:
mov r11, lr
HEX_DISPLAY 'X', 'S', 'C', 'F'
bl PrintString
.ascii "\n"
.ascii " Xscale Scratch Test failed at address 0x\0"
.align 2
mov r0, r8 //move the failed addr from r4 to r0 to print
bl PrintHex32 //prints the addr in r0
bl PrintString
.ascii "\n Expected Value: 0x\0"
.align 2
mov r0, r5 //move the expected value from r1 to ro to print
bl PrintHex32 //prints the addr in r0
bl PrintString
.ascii "\n Actual Value: 0x\0"
.align 2
mov r0, r6 //move the actual value from r2 to ro to print
bl PrintHex32 //prints the addr in r0
bl PrintString
.ascii "\n\0"
.align 2
mov pc, r11
224:
/* ---------- I2C TEST ---------- */
/* ------------------------------ */
//I2C_INIT0
bl PrintString
.ascii " Testing I2C Interface... \0"
.align 2
I2C_DEVICE_BUSY 0xa0, r0, r1, r2
cmp r2, #0x0
bne 1224f
I2C_STOP r0, r1
HEX_DISPLAY 'I', '2', 'C', 'P'
bl PrintString
.ascii "PASS\n\0"
.align 2
b 225f
1224:
HEX_DISPLAY 'I', '2', 'C', 'F'
bl PrintString
.ascii "FAIL\n\0"
.align 2
225:
/* ---------- SDRAM TEST ----------- */
/* --------------------------------- */
sdram_post:
//#define DEBUG
#ifdef DEBUG
bl PrintString
.ascii "DU Control: 0x\0"
.align 2
ldr r1, =DU_CONTROL
ldr r0, [r1]
bl PrintHex32
bl PrintString
.ascii "\n\0"
.align 2
bl PrintString
.ascii "CCR: 0x\0"
.align 2
ldr r1, =CCR
ldr r0, [r1]
bl PrintHex32
bl PrintString
.ascii "\n\0"
.align 2
#endif
cmp r10, #0 // if single boot, slave skips SDRAM POST
beq calc_dram_size
bl PrintString
.ascii " Testing SDRAM memory... \0"
.align 2
ldr r5, =0x5A5A5A5A //pattern
ldr r8, =0x0 //load SDRAM base addr
ldr r7, =SDRAM_TEST_END_ADDR
110:
//initialize entire memory to be tested with the pattern
str r5, [r8], #0x4
cmp r8, r7
bne 110b
// Check for pattern going from START to END address, while loading inverse pattern
ldr r8, =0x0 //load SDRAM BASE
111:
ldr r6, [r8] //read back the value at addr in r4 to r6 and increment the addrin r4
cmp r6, r5 //compare the read and written values
bne 226f //sdram_err
ldr r6, =0xA5A5A5A5
str r6, [r8], #0x4 //store the inverse pattern and increment addr
cmp r8, r7
bne 111b
// Check for inverse pattern going from END to START
ldr r7, =0x0 //load SDRAM BASE
ldr r5, =0xA5A5A5A5 // inverse pattern
113:
sub r8,r8, #0x4 //load the last addr
ldr r6,[r8] //read test location
cmp r6, r5 //compare with inverse pattern
bne 226f //error
cmp r8, r7
bne 113b
HEX_DISPLAY 'D', 'D', 'R', 'P'
bl PrintString
.ascii "PASS\n\0"
.align 2
b 227f
226:
HEX_DISPLAY 'D', 'D', 'R', 'F'
bl PrintString
.ascii " \nSDRAM Test failed at address 0x\0"
.align 2
mov r0, r8
bl PrintHex32 //prints the addr in r0
bl PrintString
.ascii "\n Expected Value: 0x\0"
.align 2
mov r0, r5
bl PrintHex32
bl PrintString
.ascii "\n Actual Value: 0x\0"
.align 2
mov r0, r6
bl PrintHex32
bl PrintString
.ascii "\n\0"
.align 2
hang_loop:
b hang_loop
227:
b calc_dram_size
.ltorg
/* ---------- CALCULATE SDRAM ----------- */
/* -------------------------------------- */
calc_dram_size:
I2C_READ 0xa0, 0x5, r5
I2C_READ 0xa0, 0x1F, r6
ldr r7, =0x0
ldr r1, =0x1
50:
and r0, r6, r1
cmp r0, #0x0
bne 55f
mov r1, r1, LSL #1
add r7, r7, #0x1
cmp r7, #0x8
bne 50b
55:
ldr r8, =0x400000 // 1 << 22
60:
cmp r7, #0x0
beq 65f
mov r8, r8, LSL #1
sub r7, r7, #0x1
b 60b
65:
cmp r5, #0x1
beq 70f
add r8, r8, r8
sub r5, r5, #0x1
b 65b
70:
b post_done
PrintString:
115:
ldrb r0, [lr], #1
//the following chunk enables LF to CR+LF translation
teq r0, #0x0A // LF
bne 120f
mov r0, #0x0D // CR
UARTTx r0, r1, r2
mov r0, #0x0A // LF
120:
teq r0, #0 // test for the string termination character (0)
beq 130f
UARTTx r0, r1, r2
b 115b
130:
add lr, lr, #3 // round up to next word boundary
bic pc, lr, #3
/*
* Print 32-bit hex value subroutine
* in: r0 = value to print in hex
*/
PrintHex32:
mov r2, lr
mov r1, r0, LSR #28
bl PrintHexDigit
mov r1, r0, LSR #24
bl PrintHexDigit
mov r1, r0, LSR #20
bl PrintHexDigit
mov r1, r0, LSR #16
bl PrintHexDigit
mov r1, r0, LSR #12
bl PrintHexDigit
mov r1, r0, LSR #04
mov r1, r1, LSR #04
bl PrintHexDigit
mov r1, r0, LSR #04
bl PrintHexDigit
mov r1, r0
bl PrintHexDigit
mov pc, r2
PrintHexDigit:
and r1, r1, #0x0F
cmp r1, #10
addcc r1, r1, #'0'
addcs r1, r1, #'A'-10
UARTTx r1, r3, r4
mov pc, lr
post_done:
#ifdef DEBUG
bl PrintString
.ascii "DDR Size: 0x\0"
.align 2
mov r0, r8
bl PrintHex32
bl PrintString
.ascii "\n\0"
.align 2
#endif
bl PrintString
.ascii "Scrubbing SDRAM\n\0"
.align 2
ldr r0, =SLAVE_POST_FLAG_LOC
ldr r1, =POST_DONE
str r1, [r0]
.endm // end of POST macro
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -