在汇编程序中大家可以看到,如果检测失败,会跳转到CPUTestFail函数执行,如果检测成功则进行下一步的检测。
依次针对R2 ,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12寄存器进行与R1一样的操作,在上述的寄存器比较完成以后相应的寄存器会被赋予新的数据。
Class_StartUpCPUTest PROC
EXPORT Class_StartUpCPUTest
PUSH {R4-R6} ; Safe critical registers
MOVS R0, #0x00
UXTB R0,R0
ADDS R0,#0 ; Set Z(ero) Flag
BNE CPUTestFail ; Fails IF Z clear
BMI CPUTestFail ; Fails if N is set
SUBS R0,#1 ; Set N(egative) Flag
BPL CPUTestFail ; Fails if N clear
ADDS R0,#2 ; Set C(arry) Flag and do not set Z
BCC CPUTestFail ; Fails if C clear
BEQ CPUTestFail ; Fails if Z is set
BMI CPUTestFail ; Fails if N is set
LDR R0,=con80 ; Prepares OveRFlow test
LDR R0,[R0]
ADDS R0, R0, R0 ; Set V(overflow) Flag
BVC CPUTestFail ; Fails if V clear
; This is for control flow test (ENTRY point)
LDR R0,=CtrlFlowCnt
LDR R1,[R0]
ADDS R1,R1,#0x3 ; CtrlFlowCnt += OxO3
STR R1,[R0]
; Register R1
LDR R0, =conAA
LDR R1,[R0]
LDR R0,[R0]
CMP R0,R1
BNE CPUTestFail
LDR R0, =con55
LDR R1,[R0]
LDR R0,[R0]
CMP R0,R1
BNE CPUTestFail
MOVS R1, #0x1 ; For ramp test
; Register R2
LDR R0, =conAA
LDR R2,[R0]
LDR R0,[R0]
CMP R0,R2
BNE CPUTestFail
LDR R0, =con55
LDR R2,[R0]
LDR R0,[R0]
CMP R0,R2
BNE CPUTestFail
MOVS R2, #0x2 ; For ramp test
; Register R3
LDR R0, =conAA
LDR R3,[R0]
LDR R0,[R0]
CMP R0,R3
BNE CPUTestFail
LDR R0, =con55
LDR R3,[R0]
LDR R0,[R0]
CMP R0,R3
BNE CPUTestFail
MOVS R3, #0x3 ; For ramp test
; Register R4
LDR R0, =conAA
LDR R4,[R0]
LDR R0,[R0]
CMP R0,R4
BNE CPUTestFail
LDR R0, =con55
LDR R4,[R0]
LDR R0,[R0]
CMP R0,R4
BNE CPUTestFail
MOVS R4, #0x4 ; For ramp test
; Register R5
LDR R0, =conAA
LDR R5,[R0]
LDR R0,[R0]
CMP R0,R5
BNE CPUTestFail
LDR R0, =con55
LDR R5,[R0]
LDR R0,[R0]
CMP R0,R5
BNE CPUTestFail
MOVS R5, #0x5 ; For ramp test
; Register R6
LDR R0, =conAA
LDR R6,[R0]
LDR R0,[R0]
CMP R0,R6
BNE CPUTestFail
LDR R0, =con55
LDR R6,[R0]
LDR R0,[R0]
CMP R0,R6
BNE CPUTestFail
MOVS R6, #0x6 ; For ramp test
; Register R7
LDR R0, =conAA
LDR R7,[R0]
LDR R0,[R0]
CMP R0,R7
BNE CPUTestFail
LDR R0, =con55
LDR R7,[R0]
LDR R0,[R0]
CMP R0,R7
BNE CPUTestFail
MOVS R7, #0x7 ; For ramp test
; Register R8
LDR R0, =conAA
LDR R0,[R0]
MOV R8,R0
CMP R0,R8
BNE CPUTestFail
LDR R0, =con55
LDR R0,[R0]
MOV R8,R0
CMP R0,R8
BNE CPUTestFail
MOVS R0, #0x08 ; For ramp test
MOV R8,R0
BAL CPUTstCont
CPUTestFail
BLAL FailSafePOR
CPUTstCont
; Register R9
LDR R0, =conAA
LDR R0,[R0]
MOV R9,R0
CMP R0,R9
BNE CPUTestFail
LDR R0, =con55
LDR R0,[R0]
MOV R9,R0
CMP R0,R9
BNE CPUTestFail
MOVS R0, #0x09 ; For ramp test
MOV R9,R0
; Register R10
LDR R0, =conAA
LDR R0,[R0]
MOV R10,R0
CMP R0,R10
BNE CPUTestFail
LDR R0, =con55
LDR R0,[R0]
MOV R10,R0
CMP R0,R10
BNE CPUTestFail
MOVS R0, #0x0A ; For ramp test
MOV R10,R0
; Register R11
LDR R0, =conAA
LDR R0,[R0]
MOV R11,R0
CMP R0,R11
BNE CPUTestFail
LDR R0, =con55
LDR R0,[R0]
MOV R11,R0
CMP R0,R11
BNE CPUTestFail
MOVS R0, #0x0B ; For ramp test
MOV R11,R0
; Register R12
LDR R0, =conAA
LDR R0,[R0]
MOV R12,R0
CMP R0,R12
BNE CPUTestFail
LDR R0, =con55
LDR R0,[R0]
MOV R12,R0
CMP R0,R12
BNE CPUTestFail
MOVS R0, #0x0C ; For ramp test
MOV R12,R0
LDR R0, =CPUTstCont
R1~R12寄存器比较完成以后会在Ramp中做进一步的判断,判断R1寄存器的数值是否为0x01,R2寄存器的数值是否为0x02,依次判断到R12寄存器,如果以上的判断都是正确的则说明R1~R12寄存器验证通过。 |