微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ARM启动代码注释

ARM启动代码注释

时间:11-11 来源:互联网 点击:

WIDTH=16

andeqr14,r7,r0,lsl #20 ;DCD 0x0007ea00

]

[ ENTRY_BUS_WIDTH=8

streqr0,[r0,-r10,ror #1] ;DCD 0x070000ea

]

|

bResetHandler

]

bHandlerUndef   ;handler for Undefined mode

bHandlerSWI   ;handler for SWI interrupt

bHandlerPabort  ;handler for PAbort

bHandlerDabort ;handler for DAbort

b.     ;reserved

bHandlerIRQ   ;handler for IRQ interrupt

bHandlerFIQ   ;handler for FIQ interrupt

;//@0x20

bEnterPWDN

ChangeBigEndian

;//@0x24

[ ENTRY_BUS_WIDTH=32

DCD0xee110f10;0xee110f10 => mrc p15,0,r0,c1,c0,0

DCD0xe3800080;0xe3800080 => orr r0,r0,#0x80; //Big-endian

DCD0xee010f10;0xee010f10 => mcr p15,0,r0,c1,c0,0

]

[ ENTRY_BUS_WIDTH=16

DCD 0x0f10ee11 ;分配一段字的内存单元,并用指令的数据初始化

DCD 0x0080e380

DCD 0x0f10ee01

]

[ ENTRY_BUS_WIDTH=8

DCD 0x100f11ee

DCD 0x800080e3

DCD 0x100f01ee

]

DCD 0xffffffff ;swinv 0xffffff is similar with NOP and run well in both endian mode.

DCD 0xffffffff

DCD 0xffffffff

DCD 0xffffffff

DCD 0xffffffff

b ResetHandler

;//Function for entering power down mode

;// 1. SDRAM should be in self-refresh mode.

;// 2. All interrupt should be maksked for SDRAM/DRAM self-refresh.

;// 3. LCD controller should be disabled for SDRAM/DRAM self-refresh.

;// 4. The I-cache may have to be turned on.

;// 5. The location of the following code may have not to be changed.

;//void EnterPWDN(int CLKCON);

EnterPWDN

mov r2,r0      ;r2=rCLKCON

tst r0,#0x8     ;POWER_OFF mode?

bne ENTER_POWER_OFF

ENTER_STOP

ldr r0,=REFRESH

ldr r3,[r0]     ;r3=rREFRESH

mov r1, r3

orr r1, r1, #BIT_SELFREFRESH

str r1, [r0]     ;Enable SDRAM self-refresh

mov r1,#16    ;wait until self-refresh is issued. may not be needed.

0subs r1,r1,#1

bne %B0

ldr r0,=CLKCON    ;enter STOP mode.

str r2,[r0]

mov r1,#32

0subs r1,r1,#1    ;1) wait until the STOP mode is in effect.

bne %B0       ;2) Or wait here until the CPU&Peripherals will be turned-off

        ; Entering POWER_OFF mode, only the reset by wake-up is available.

ldr r0,=REFRESH   ;exit from SDRAM self refresh mode.

str r3,[r0]

MOV_PC_LR

ENTER_POWER_OFF

;//NOTE.

;//1) rGSTATUS3 should have the return address after wake-up from POWER_OFF mode.

ldr r0,=REFRESH

ldr r1,[r0]    ;r1=rREFRESH

orr r1, r1, #BIT_SELFREFRESH

str r1, [r0]    ;Enable SDRAM self-refresh

mov r1,#16   ;Wait until self-refresh is issued,which may not be needed.

0subs r1,r1,#1

bne %B0

ldr r1,=MISCCR

ldrr0,[r1]

orrr0,r0,#(7<17) ;Make sure that SCLK0:SCLK->0, SCLK1:SCLK->0, SCKE="L" during boot-up

strr0,[r1]

ldr r0,=CLKCON

str r2,[r0]

b .      ;CPU will die here.

WAKEUP_POWER_OFF

;Release SCLKn after wake-up from the POWER_OFF mode.

ldr r1,=MISCCR

ldrr0,[r1]

bicr0,r0,#(7<17) ;SCLK0:0->SCLK, SCLK1:0->SCLK, SCKE:L->H

strr0,[r1]

      ;Set memory control registers

ldrr0,=SMRDATA

ldrr1,=BWSCON   ;BWSCON Address

addr2, r0, #52   ;End address of SMRDATA

0

ldrr3, [r0], #4

strr3, [r1], #4

cmpr2, r0

bne%B0

mov r1,#256

0subs r1,r1,#1   ;1) wait until the SelfRefresh is released.

bne %B0

ldr r1,=GSTATUS3  ;GSTATUS3 has the start address just after POWER_OFF wake-up

ldr r0,[r1]

mov pc,r0

LTORG

HandlerFIQ HANDLER HandleFIQ

HandlerIRQ HANDLER HandleIRQ

HandlerUndef HANDLER HandleUndef

HandlerSWI HANDLER HandleSWI

HandlerDabort HANDLER HandleDabort

HandlerPabort HANDLER HandlePabort

IsrIRQ

subsp,sp,#4 ;reserved for PC

stmfdsp!,{r8-r9}

ldrr9,=INTOFFSET

ldrr9,[r9]

ldrr8,=HandleEINT0

addr8,r8,r9,lsl #2

ldrr8,[r8]

strr8,[sp,#8]

ldmfdsp!,{r8-r9,pc}

;================================================================================================

; ENTRY 将看门狗、中断之类的程序关掉,省得他们来打扰初始化程序的进行

;=================================================================================================

ResetHandler

ldrr0,=WTCON ;watch dog disable

ldrr1,=0x0

strr1,[r0]

ldrr0,=INTMSK

ldrr1,=0xffffffff ;all interrupt disable

strr1,[r0]

ldrr0,=INTSUBMSK

ldrr1,=0x7ff   ;all sub interrupt disable, 2002/04/10

strr1,[r0]

[ {F

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top