📄 in_reset.s
字号:
/*@ ------------------------------------------------------------------------------@ - ATMEL Microcontroller Software Support - ROUSSET -@ ------------------------------------------------------------------------------@ The software is delivered "AS IS" without warranty or condition of any@ kind, either express, implied or statutory. This includes without@ limitation any warranty or condition with respect to merchantability or@ fitness for any particular purpose, or against the infringements of@ intellectual property rights of others.@ -----------------------------------------------------------------------------@ - File source : in_reset.s@ - Object : Boot of AT91EB01/DB01@ - Translator : ARM Software Development Toolkit V2.11a@ -@ - Exported Resources : __main - InitResetStacks@ - Imported Resources : MainApplication - InitTableEBI - InitTableStack@ -@ - 1.0 15/09/98 JLV : Creation@ - 2.0 21/10/98 JCZ : Clean up.@ - 2.1 16/03/99 JCZ : SDT V2.5@ - : Remove warning concerning CPSR field specifier.@ - : Reserve stack space on top of memory for ICE Debug.@ ------------------------------------------------------------------------------ AREA IN_RESET, CODE, READONLY, INTERWORK@ -------------------------- List of Included Files ---------------------------@ INCLUDE Include/arm.inc@ -------------------------------@ - ARM Core Mode and Status Bits@ -------------------------------*/ ARM_MODE_USER = 0x10 ARM_MODE_FIQ = 0x11 ARM_MODE_IRQ = 0x12 ARM_MODE_SVC = 0x13 ARM_MODE_ABORT= 0x17 ARM_MODE_UNDEF= 0x1B ARM_MODE_SYS = 0x1F I_BIT = 0x80 F_BIT = 0x40 T_BIT = 0x20/*@ INCLUDE Include/int_mem.inc@ ------------------------------@ - AT91 Internal RAM Definition@ ------------------------------*/ RAM_BASE = 0x00000000 RAM_SIZE = 4096 RAM_LIMIT = RAM_BASE + RAM_SIZE/*@ INCLUDE Include/aic.inc*/ AIC_BASE = 0xFFFFF000/*@ -----------------------------------------@ - Advanced Interrupt Controller Structure@ -----------------------------------------*/AIC_SMR = 0 @ Source Mode RegisterAIC_SVR = AIC_SMR + 32*4 @ Source Vector RegisterAIC_IVR = AIC_SVR + 32*4 @ Interrupt Vector RegisterAIC_FVR = AIC_IVR + 4 @ Fast Interrupt Vector RegisterAIC_ISR = AIC_FVR + 4 @ Interrupt Status RegisterAIC_IPR = AIC_ISR + 4 @ Interrupt Pending RegisterAIC_IMR = AIC_IPR + 4 @ Interrupt Mask RegisterAIC_CISR = AIC_IMR + 4 @ Core Interrupt Status RegisterAIC_IECR = AIC_CISR + 3*4 @ Interrupt Enable Command RegisterAIC_IDCR = AIC_IECR + 4 @ Interrupt Disable Command RegisterAIC_ICCR = AIC_IDCR + 4 @ Interrupt Clear Command RegisterAIC_ISCR = AIC_ICCR + 4 @ Interrupt Set Command RegisterAIC_EOICR = AIC_ISCR + 4 @ End Of Interrupt Command RegisterUS0IRQ = 2/*@ ------------------------ List of constants and types ------------------------@ None@ ------------------------ List of Imported resources -------------------------*/ .global InitMainSram/*@ .global InitTableStack@ IF :DEF:AT91_DEBUG_NONE@ .global InitTableEBI*/ .global MainApplication/* .global |Image$$RO$$Limit| @ End of ROM code (=start of ROM data) .global |Image$$RW$$Base| @ Base of RAM to initialise .global |Image$$ZI$$Base| @ Base and limit of area .global |Image$$ZI$$Limit| @ to zero initialise@ ENDIF@ ------------------------ List of Internal resources -------------------------@ None@ ------------------------ List of Exported resources -------------------------@ IF :DEF:AT91_DEBUG_NONE@ - Define the entry point@ ENTRY@ ------------------------------------------------------------------------------@ - Function : boot@ - Treatments : AT91 boot code@ - Input Parameters : None@ - Output Parameters : None@ - Registers lost : None@ - Called Functions : MainApplication@ - Called Macros : None@ ------------------------------------------------------------------------------@ - Define "__main" to ensure that C runtime system is not linked*/ .global _start .global _main_start:_main: b InitResetundefvec: b undefvecswivec: b swivecpabtvec: b pabtvecdabtvec: b dabtvecrsvdvec: b rsvdvecirqvec: ldr pc, [pc, #-0xf20]fiqvec: ldr pc, [pc, #-0xf20]InitReset:/*@ - | Initialise the Memory Controller@ - | ---------------------------------@ - | Copy the Image of the Memory Controller*/ ldr r10, PtInitTableEBI @ get the address of the chip select register image/* @ - | If pc > 0x100000 */ movs r0, pc, LSR #20/* @ - | | Mask the 12 highest bits of the address */ moveq r10, r10, LSL #12 moveq r10, r10, LSR #12/* @ - | EndIf *//* @ - | Load the address where to jump */ ldr r12, PtInitRemap @ get the real jump address ( after remap )/* @ - | Copy Chip Select Register Image to Memory Controller and command remap */ ldmia r10!, {r0-r9,r11} @ load the complete image and the EBI base stmia r11!, {r0-r9} @ store the complete image with the remap command/* @ - | Jump to ROM at its new address */ mov pc, r12 @ jump and break the pipelinePtInitTableEBI: .word InitTableEBI @ Table for EBI initializationPtInitRemap: .word InitRemap @ address where to jump after REMAPPtInitVector: .word _main @ Table for vector initializationInitRemap:/*@ - | Setup Exception Vectors@ - | -----------------------@ - | Copy the hard exception vectors*/ mov r8, #0 @ @ of the hard vector ldr r9, PtInitVector @ @ where to read values ldmia r9!, {r0-r7} @ read the vectors stmia r8!, {r0-r7} @ store them/* @ - | Set up the SVC mode and stack pointer on the top of the internal RAM */ mov r0, #ARM_MODE_SVC | I_BIT | F_BIT @ No interrupts msr cpsr, r0 ldr r13, =RAM_LIMIT/* @ - | Initialize the Stacks */ bl InitResetStacks/* @ - | Initialise memory required by C code ldr r0, =|Image$$RO$$Limit| @ Get pointer to ROM data ldr r1, =|Image$$RW$$Base| @ and RAM copy ldr r3, =|Image$$ZI$$Base| @ Zero init base => top of initialised data cmp r0, r1 @ Check that they are different beq NoRWLoopRw cmp r1, r3 @ Copy init data ldrcc r2, [r0], #4 strcc r2, [r1], #4 bcc LoopRwNoRW ldr r1, =|Image$$ZI$$Limit| @ Top of zero init segment mov r2, #0LoopZI cmp r3, r1 @ Zero init strcc r2, [r3], #4 bcc LoopZI@ - | Branch on C code Main function*/ ldr r0, =MainApplication mov lr, pc bx r0/* @ - | Loop for ever */InitEnd: b InitEnd/* @ ENDIF @ ------------------------------------------------------------------------------@ - Function : InitResetStacks@ - Treatments : AT91 boot code@ - Must be call in Supervisor mode@ - Input Parameters : None@ - Output Parameters :@ - <AdFiq> = address of FIQ treatment which initialize the stack@ - Registers lost : None@ - Called Functions : None@ - Called Macros : None@ ------------------------------------------------------------------------------*/ .global InitResetStacksInitResetStacks: ldr r1, =AIC_BASE/* IF :DEF:AT91_DEBUG_ANGEL@ - Disable all interrupt unless USART used by Angel mvn r0, #(1:SHL:US0IRQ) ELSE@ - Disable all interrupt*/ mvn r0, #0/* ENDIF */ str r0, [r1, #AIC_IDCR]/* @ - Perform 8 End Of Interrupt Command to make sure AIC will not lock out nIRQ */ mov r0, #8LoopAic: str r1, [r1, #AIC_EOICR] subs r0, r0, #1 bhi LoopAic/* IF :DEF:AT91_DEBUG_ICE@ - | -- Set IRQ and FIQ interrupt vectors
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -