1、设置svc形式
设置处理器的形式为svc形式,依据ARM架构参考手册,处理器有七种作业形式:
在程序状况寄存器讲形式设置为10011:
汇编代码如下:
set_svc:
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr, r0
mov pc,lr
2、封闭看门狗
在对应的芯片手册(我用的是S3C2440)找到看门狗相关的寄存器,并封闭看门狗定时器输出的复位信号:
对应汇编代码:
disable_watchdog:
ldr r0, #pWTCON
mov r1, #0x0
str r1, [r0]
mov pc,lr
3、封闭中止
找到对应芯片的中止屏蔽寄存器,并封闭中止:
对应汇编代码:
disable_interrupt:
mvn r1, #0x0
ldr r0, #4A000008
str r1, [r0]
mov pc,lr
4、封闭mmu和catch
首要包含:(1)使I/D catch内容失效(2)封闭mmu和I/D catch
在ARM920T(ARM9)参考手册找到相关寄存器,首要是寄存器1和寄存器7,并进行相应设置:
对应汇编代码:
disable_mmu:
mcr p15,0,r0,c7,c7,0
mrc p15,0,r0,c1,c0,0
bic r0,r0,#0x00000007
mcr p15,0,r0,c1,c0,0
mov pc,lr
完好代码:
.text
.global _start
_start:
b reset
ldr pc, _undefined_instrucTIon
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
_undefined_instrucTIon: .word undefined_instrucTIon
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq
undefined_instrucTIon:
nop
software_interrupt:
nop
prefetch_abort:
nop
data_abort:
nop
not_used:
nop
irq:
nop
fiq:
nop
reset:
bl set_svc
bl disable_watchdog
bl disable_interrupt
bl disable_mmu
set_svc:
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr, r0
mov pc,lr
#define pWTCON 0x53000000
disable_watchdog:
ldr r0, #pWTCON
mov r1, #0x0
str r1, [r0]
mov pc,lr
disable_interrupt:
mvn r1, #0x0
ldr r0, #4A000008
str r1, [r0]
mov pc,lr
disable_mmu:
mcr p15,0,r0,c7,c7,0
mrc p15,0,r0,c1,c0,0
bic r0,r0,#0x00000007
mcr p15,0,r0,c1,c0,0