URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_AT91SAM7X256_Eclipse/] [RTOSDemo/] [SrcAtmel/] [Cstartup.s79] - Rev 577
Compare with Previous | Blame | View Log
;------------------------------------------------------------------------------;- 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 : Cstartup.s79;- Object : Generic CStartup for IAR No Use REMAP;- Compilation flag : None;-;- 1.0 15/Jun/04 JPP : Creation;------------------------------------------------------------------------------#include "AT91SAM7X256_inc.h";------------------------------------------------------------------------------;- Area Definition;------------------------------------------------------------------------------;---------------------------------------------------------------; ?RESET; Reset Vector.; Normally, segment INTVEC is linked at address 0.; For debugging purposes, INTVEC may be placed at other; addresses.; A debugger that honors the entry point will start the; program in a normal way even if INTVEC is not at address 0.;-------------------------------------------------------------PROGRAM ?RESETRSEG INTRAMSTART_REMAPRSEG INTRAMEND_REMAPEXTERN vPortYieldProcessorRSEG ICODE:CODE:ROOT(2)CODE32 ; Always ARM mode after resetorg 0reset;------------------------------------------------------------------------------;- Exception vectors;--------------------;- These vectors can be read at address 0 or at RAM address;- They ABSOLUTELY requires to be in relative addresssing mode in order to;- guarantee a valid jump. For the moment, all are just looping.;- If an exception occurs before remap, this would result in an infinite loop.;- To ensure if a exeption occurs before start application to infinite loop.;------------------------------------------------------------------------------B InitReset ; 0x00 Reset handlerundefvec:B undefvec ; 0x04 Undefined Instructionswivec:B vPortYieldProcessor ; 0x08 Software Interruptpabtvec:B pabtvec ; 0x0C Prefetch Abortdabtvec:B dabtvec ; 0x10 Data Abortrsvdvec:B rsvdvec ; 0x14 reservedirqvec:LDR PC, [PC, #-0xF20] ; Jump directly to the address given by the AICfiqvec: ; 0x1c FIQ;------------------------------------------------------------------------------;- Function : FIQ_Handler_Entry;- Treatments : FIQ Controller Interrupt Handler.;- Called Functions : AIC_FVR[interrupt];------------------------------------------------------------------------------FIQ_Handler_Entry:;- Switch in SVC/User Mode to allow User Stack access for C code; because the FIQ is not yet acknowledged;- Save and r0 in FIQ_Registermov r9,r0ldr r0 , [r8, #AIC_FVR]msr CPSR_c,#I_BIT | F_BIT | ARM_MODE_SVC;- Save scratch/used registers and LR in User Stackstmfd sp!, { r1-r3, r12, lr};- Branch to the routine pointed by the AIC_FVRmov r14, pcbx r0;- Restore scratch/used registers and LR from User Stackldmia sp!, { r1-r3, r12, lr};- Leave Interrupts disabled and switch back in FIQ modemsr CPSR_c, #I_BIT | F_BIT | ARM_MODE_FIQ;- Restore the R0 ARM_MODE_SVC registermov r0,r9;- Restore the Program Counter using the LR_fiq directly in the PCsubs pc,lr,#4InitReset:;------------------------------------------------------------------------------;- Low level Init (PMC, AIC, ? ....) by C function AT91F_LowLevelInit;------------------------------------------------------------------------------EXTERN AT91F_LowLevelInit#define __iramend SFB(INTRAMEND_REMAP);- minumum C initialization;- call AT91F_LowLevelInit( void)ldr r13,=__iramend ; temporary stack in internal RAM;--Call Low level init function in ABSOLUTE through the Interworkingldr r0,=AT91F_LowLevelInitmov lr, pcbx r0;------------------------------------------------------------------------------;- Stack Sizes Definition;------------------------;- Interrupt Stack requires 2 words x 8 priority level x 4 bytes when using;- the vectoring. This assume that the IRQ management.;- The Interrupt Stack must be adjusted depending on the interrupt handlers.;- Fast Interrupt not requires stack If in your application it required you must;- be definehere.;- The System stack size is not defined and is limited by the free internal;- SRAM.;------------------------------------------------------------------------------;------------------------------------------------------------------------------;- Top of Stack Definition;-------------------------;- Interrupt and Supervisor Stack are located at the top of internal memory in;- order to speed the exception handling context saving and restoring.;- ARM_MODE_SVC (Application, C) Stack is located at the top of the external memory.;------------------------------------------------------------------------------IRQ_STACK_SIZE EQU 300ARM_MODE_FIQ EQU 0x11ARM_MODE_IRQ EQU 0x12ARM_MODE_SVC EQU 0x13I_BIT EQU 0x80F_BIT EQU 0x40;------------------------------------------------------------------------------;- Setup the stack for each mode;-------------------------------ldr r0, =__iramend;- Set up Fast Interrupt Mode and set FIQ Mode Stackmsr CPSR_c, #ARM_MODE_FIQ | I_BIT | F_BIT;- Init the FIQ registerldr r8, =AT91C_BASE_AIC;- Set up Interrupt Mode and set IRQ Mode Stackmsr CPSR_c, #ARM_MODE_IRQ | I_BIT | F_BITmov r13, r0 ; Init stack IRQsub r0, r0, #IRQ_STACK_SIZE;- Enable interrupt & Set up Supervisor Mode and set Supervisor Mode Stackmsr CPSR_c, #ARM_MODE_SVCmov r13, r0;---------------------------------------------------------------; ?CSTARTUP;---------------------------------------------------------------EXTERN __segment_initEXTERN main; Initialize segments.; __segment_init is assumed to use; instruction set and to be reachable by BL from the ICODE segment; (it is safest to link them in segment ICODE).ldr r0,=__segment_initmov lr, pcbx r0PUBLIC __main?jump_to_main:ldr lr,=?call_exitldr r0,=main__main:bx r0;------------------------------------------------------------------------------;- Loop for ever;---------------;- End of application. Normally, never occur.;- Could jump on Software Reset ( B 0x0 ).;------------------------------------------------------------------------------?call_exit:Endb End;---------------------------------------------------------------; ?EXEPTION_VECTOR; This module is only linked if needed for closing files.;---------------------------------------------------------------PUBLIC AT91F_Default_FIQ_handlerPUBLIC AT91F_Default_IRQ_handlerPUBLIC AT91F_Spurious_handlerCODE32 ; Always ARM mode after exeptionAT91F_Default_FIQ_handlerb AT91F_Default_FIQ_handlerAT91F_Default_IRQ_handlerb AT91F_Default_IRQ_handlerAT91F_Spurious_handlerb AT91F_Spurious_handlerENDMODEND
