S3C2440 cpu初始化(reset內(nèi)容)
reset內(nèi)容(start.S文件):
1、設(shè)置svc模式
設(shè)置處理器的模式為svc模式,根據(jù)ARM架構(gòu)參考手冊(cè),處理器有七種工作模式:
在程序狀態(tài)寄存器講模式設(shè)置為10011:
匯編代碼如下:
set_svc:
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr, r0
mov pc,lr
2、關(guān)閉看門狗
在對(duì)應(yīng)的芯片手冊(cè)(我用的是S3C2440)找到看門狗相關(guān)的寄存器,并關(guān)閉看門狗定時(shí)器輸出的復(fù)位信號(hào):
對(duì)應(yīng)匯編代碼:
disable_watchdog:
ldr r0, #pWTCON
mov r1, #0x0
str r1, [r0]
mov pc,lr
3、關(guān)閉中斷
找到對(duì)應(yīng)芯片的中斷屏蔽寄存器,并關(guān)閉中斷:
對(duì)應(yīng)匯編代碼:
disable_interrupt:
mvn r1, #0x0
ldr r0, #4A000008
str r1, [r0]
mov pc,lr
4、關(guān)閉mmu和catch
主要包括:(1)使I/D catch內(nèi)容失效(2)關(guān)閉mmu和I/D catch
在ARM920T(ARM9)參考手冊(cè)找到相關(guān)寄存器,主要是寄存器1和寄存器7,并進(jìn)行相應(yīng)設(shè)置:
對(duì)應(yīng)匯編代碼:
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
mov pc,lr