init_cm3.c
Go to the documentation of this file.00001 00038 #include <cfg/compiler.h> 00039 #include <cfg/cfg_proc.h> /* CONFIG_KERN_PREEMPT */ 00040 #include <kern/proc_p.h> 00041 #include <cfg/debug.h> 00042 #include <cpu/attr.h> /* PAUSE */ 00043 #include <cpu/irq.h> /* IRQ_DISABLE */ 00044 #include <cpu/types.h> 00045 #include <drv/irq_cm3.h> 00046 #include "switch_ctx_cm3.h" 00047 00048 #if CPU_CM3_LM3S 00049 #include <drv/clock_lm3s.h> 00050 #include <io/lm3s.h> 00051 #elif CPU_CM3_STM32 00052 #include <drv/clock_stm32.h> 00053 #include <io/stm32.h> 00054 #endif 00055 00056 extern size_t __text_end, __data_start, __data_end, __bss_start, __bss_end; 00057 00058 extern void __init2(void); 00059 00060 /* Architecture's entry point */ 00061 void __init2(void) 00062 { 00063 /* 00064 * The main application expects IRQs disabled. 00065 */ 00066 IRQ_DISABLE; 00067 00068 #if CPU_CM3_LM3S 00069 /* 00070 * PLL may not function properly at default LDO setting. 00071 * 00072 * Description: 00073 * 00074 * In designs that enable and use the PLL module, unstable device 00075 * behavior may occur with the LDO set at its default of 2.5 volts or 00076 * below (minimum of 2.25 volts). Designs that do not use the PLL 00077 * module are not affected. 00078 * 00079 * Workaround: Prior to enabling the PLL module, it is recommended that 00080 * the default LDO voltage setting of 2.5 V be adjusted to 2.75 V using 00081 * the LDO Power Control (LDOPCTL) register. 00082 * 00083 * Silicon Revision Affected: A1, A2 00084 * 00085 * See also: Stellaris LM3S1968 A2 Errata documentation. 00086 */ 00087 if (REVISION_IS_A1 | REVISION_IS_A2) 00088 HWREG(SYSCTL_LDOPCTL) = SYSCTL_LDOPCTL_2_75V; 00089 #endif 00090 /* Set the appropriate clocking configuration */ 00091 clock_init(); 00092 00093 /* Initialize IRQ vector table in RAM */ 00094 sysirq_init(); 00095 00096 #if (CONFIG_KERN && CONFIG_KERN_PREEMPT) 00097 /* 00098 * Voluntary context switch handler. 00099 * 00100 * This software interrupt can always be triggered and must be 00101 * dispatched as soon as possible, thus we just disable IRQ priority 00102 * for it. 00103 */ 00104 sysirq_setHandler(FAULT_SVCALL, svcall_handler); 00105 sysirq_setPriority(FAULT_SVCALL, IRQ_PRIO_MAX); 00106 /* 00107 * Preemptible context switch handler 00108 * 00109 * The priority of this IRQ must be the lowest priority in the system 00110 * in order to run last in the interrupt service routines' chain. 00111 */ 00112 sysirq_setHandler(FAULT_PENDSV, pendsv_handler); 00113 sysirq_setPriority(FAULT_PENDSV, IRQ_PRIO_MIN); 00114 #endif 00115 }
