diff options
| author | onelife.real <[email protected]> | 2011-06-20 01:56:28 +0000 |
|---|---|---|
| committer | onelife.real <[email protected]> | 2011-06-20 01:56:28 +0000 |
| commit | 69ad018bc04639dd295de0005dc128b99721064f (patch) | |
| tree | 64dd0b0235b9d81c38a2c1818456cb036b4f9ce5 /libcpu/arm | |
| parent | 1eca19cb01309eaddbdc42cb12c17f1425124800 (diff) | |
*** EFM32 branch ***
1. Add SD card driver (SPI mode)
2. Add ELM ChaN FatFs support (Please read "Readme.txt")
- Warning: FatFs is really FAT! (35KB)
3. Upgrade EFM32 libraries (CMSIS and efm32lib) to version 2.0.0
4. Merge all of the C source code in "libcpu\arm\cortex-m3\" into "cpuport.c"
5. Merge all of the assembly source code in "libcpu\arm\cortex-m3\" into "context_gcc.S" (except "start_gcc.S")
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1525 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'libcpu/arm')
| -rw-r--r-- | libcpu/arm/cortex-m3/context_gcc.S | 19 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/cpu.c | 54 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/cpuport.c (renamed from libcpu/arm/cortex-m3/fault.c) | 46 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/fault_gcc.S | 43 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/interrupt.c | 39 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/stack.c | 72 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m3/start_gcc.S | 6 |
7 files changed, 61 insertions, 218 deletions
diff --git a/libcpu/arm/cortex-m3/context_gcc.S b/libcpu/arm/cortex-m3/context_gcc.S index e5418a854e..8d4bed2979 100644 --- a/libcpu/arm/cortex-m3/context_gcc.S +++ b/libcpu/arm/cortex-m3/context_gcc.S @@ -13,6 +13,7 @@ * Date Author Notes
* 2009-10-11 Bernard first version
* 2010-12-29 onelife Modify for EFM32
+ * 2011-06-17 onelife Merge all of the assembly source code into context_gcc.S
*********************************************************************/
/******************************************************************//**
@@ -87,9 +88,9 @@ _reswitch: * R1 --> swith to thread stack
* psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack
*/
- .global rt_hw_pend_sv
- .type rt_hw_pend_sv, %function
-rt_hw_pend_sv:
+ .global PendSV_Handler
+ .type PendSV_Handler, %function
+PendSV_Handler:
/* disable interrupt to protect context switch */
MRS R2, PRIMASK
CPSID I
@@ -169,6 +170,18 @@ rt_hw_interrupt_thread_switch: BX LR
NOP
+ .global HardFault_Handler
+ .type HardFault_Handler, %function
+HardFault_Handler:
+ /* get current context */
+ MRS r0, psp /* get fault thread stack pointer */
+ PUSH {lr}
+ BL rt_hw_hard_fault_exception
+ POP {lr}
+
+ ORR lr, lr, #0x04
+ BX lr
+
/******************************************************************//**
* @}
*********************************************************************/
diff --git a/libcpu/arm/cortex-m3/cpu.c b/libcpu/arm/cortex-m3/cpu.c deleted file mode 100644 index c0b6f0430a..0000000000 --- a/libcpu/arm/cortex-m3/cpu.c +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************//**
- * @file cpu.c
- * @brief This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2011, RT-Thread Development Team
- * @author Bernard, onelife
- * @version 0.4 beta
- **********************************************************************
- * @section License
- * The license and distribution terms for this file may be found in the file LICENSE in this
- * distribution or at http://www.rt-thread.org/license/LICENSE
- **********************************************************************
- * @section Change Logs
- * Date Author Notes
- * 2009-01-05 Bernard first version
- * 2011-02-14 onelife Modify for EFM32
- *********************************************************************/
-
-/******************************************************************//**
-* @addtogroup cortex-m3
-* @{
-*********************************************************************/
-
-/* Includes -------------------------------------------------------------------*/
-#include <rtthread.h>
-
-/* Private typedef -------------------------------------------------------------*/
-/* Private define --------------------------------------------------------------*/
-/* Private macro --------------------------------------------------------------*/
-/* Private variables ------------------------------------------------------------*/
-/* Private function prototypes ---------------------------------------------------*/
-/* Private functions ------------------------------------------------------------*/
-/**
- * reset cpu by dog's time-out
- *
- */
-void rt_hw_cpu_reset()
-{
- /*NOTREACHED*/
-}
-
-/**
- * shutdown CPU
- *
- */
-void rt_hw_cpu_shutdown()
-{
- rt_kprintf("shutdown...\n");
-
- RT_ASSERT(0);
-}
-
-/******************************************************************//**
- * @}
-*********************************************************************/
diff --git a/libcpu/arm/cortex-m3/fault.c b/libcpu/arm/cortex-m3/cpuport.c index 8adaf372fa..b8532408e3 100644 --- a/libcpu/arm/cortex-m3/fault.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -1,5 +1,5 @@ /******************************************************************//**
- * @file fault.c
+ * @file cpu.c
* @brief This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
@@ -13,6 +13,7 @@ * Date Author Notes
* 2009-01-05 Bernard first version
* 2011-02-14 onelife Modify for EFM32
+ * 2011-06-17 onelife Merge all of the C source code into cpuport.c
*********************************************************************/
/******************************************************************//**
@@ -39,12 +40,42 @@ struct stack_contex /* Private define --------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------*/
-/* External function prototypes --------------------------------------------------*/
-extern void list_thread(void);
-extern rt_thread_t rt_current_thread;
+/* exception and interrupt handler table */
+rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
+rt_uint32_t rt_thread_switch_interrput_flag;
/* Private function prototypes ---------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
+rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
+ rt_uint8_t *stack_addr, void *texit)
+{
+ unsigned long *stk;
+
+ stk = (unsigned long *)stack_addr;
+ *(stk) = 0x01000000L; /* PSR */
+ *(--stk) = (unsigned long)tentry; /* entry point, pc */
+ *(--stk) = (unsigned long)texit; /* lr */
+ *(--stk) = 0; /* r12 */
+ *(--stk) = 0; /* r3 */
+ *(--stk) = 0; /* r2 */
+ *(--stk) = 0; /* r1 */
+ *(--stk) = (unsigned long)parameter; /* r0 : argument */
+
+ *(--stk) = 0; /* r11 */
+ *(--stk) = 0; /* r10 */
+ *(--stk) = 0; /* r9 */
+ *(--stk) = 0; /* r8 */
+ *(--stk) = 0; /* r7 */
+ *(--stk) = 0; /* r6 */
+ *(--stk) = 0; /* r5 */
+ *(--stk) = 0; /* r4 */
+
+ /* return task's current stack address */
+ return (rt_uint8_t *)stk;
+}
+
+extern void list_thread(void);
+extern rt_thread_t rt_current_thread;
void rt_hw_hard_fault_exception(struct stack_contex* contex)
{
rt_kprintf("psr: 0x%08x\n", contex->psr);
@@ -63,6 +94,13 @@ void rt_hw_hard_fault_exception(struct stack_contex* contex) while (1);
}
+void rt_hw_cpu_shutdown()
+{
+ rt_kprintf("shutdown...\n");
+
+ RT_ASSERT(0);
+}
+
/******************************************************************//**
* @}
*********************************************************************/
diff --git a/libcpu/arm/cortex-m3/fault_gcc.S b/libcpu/arm/cortex-m3/fault_gcc.S deleted file mode 100644 index b5e5e1e191..0000000000 --- a/libcpu/arm/cortex-m3/fault_gcc.S +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************//**
- * @file fault_gcc.S
- * @brief Faults handling functions
- * COPYRIGHT (C) 2011, RT-Thread Development Team
- * @author Bernard, onelife
- * @version 0.4 beta
- **********************************************************************
- * @section License
- * The license and distribution terms for this file may be found in the file LICENSE in this
- * distribution or at http://www.rt-thread.org/license/LICENSE
- **********************************************************************
- * @section Change Logs
- * Date Author Notes
- * 2009-10-11 Bernard first version
- * 2010-12-29 onelife Modify for EFM32
- *********************************************************************/
-
-/******************************************************************//**
-* @addtogroup cortex-m3
-* @{
-*********************************************************************/
-
- .cpu cortex-m3
- .fpu softvfp
- .syntax unified
- .thumb
- .text
-
- .global rt_hw_hard_fault
- .type rt_hw_hard_fault, %function
-rt_hw_hard_fault:
- /* get current context */
- MRS r0, psp /* get fault thread stack pointer */
- PUSH {lr}
- BL rt_hw_hard_fault_exception
- POP {lr}
-
- ORR lr, lr, #0x04
- BX lr
-
-/******************************************************************//**
- * @}
-*********************************************************************/
diff --git a/libcpu/arm/cortex-m3/interrupt.c b/libcpu/arm/cortex-m3/interrupt.c deleted file mode 100644 index a6087e691e..0000000000 --- a/libcpu/arm/cortex-m3/interrupt.c +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************//** - * @file interrupt.c - * @brief This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2011, RT-Thread Development Team - * @author Bernard, onelife - * @version 0.4 beta - ********************************************************************** - * @section License - * The license and distribution terms for this file may be found in the file LICENSE in this - * distribution or at http://www.rt-thread.org/license/LICENSE - ********************************************************************** - * @section Change Logs - * Date Author Notes - * 2009-01-05 Bernard first version - * 2011-02-14 onelife Modify for EFM32 - *********************************************************************/ - -/******************************************************************//** -* @addtogroup cortex-m3 -* @{ -*********************************************************************/ - -/* Includes -------------------------------------------------------------------*/ -#include <rtthread.h> - -/* Private typedef -------------------------------------------------------------*/ -/* Private define --------------------------------------------------------------*/ -/* Private macro --------------------------------------------------------------*/ -/* Private variables ------------------------------------------------------------*/ -/* exception and interrupt handler table */ -rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread; -rt_uint32_t rt_thread_switch_interrput_flag; - -/* Private function prototypes ---------------------------------------------------*/ -/* Private functions ------------------------------------------------------------*/ - -/******************************************************************//** - * @} -*********************************************************************/ diff --git a/libcpu/arm/cortex-m3/stack.c b/libcpu/arm/cortex-m3/stack.c deleted file mode 100644 index 3f9e1d8119..0000000000 --- a/libcpu/arm/cortex-m3/stack.c +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************//** - * @file stack.c - * @brief This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2011, RT-Thread Development Team - * @author Bernard, onelife - * @version 0.4 beta - ********************************************************************** - * @section License - * The license and distribution terms for this file may be found in the file LICENSE in this - * distribution or at http://www.rt-thread.org/license/LICENSE - ********************************************************************** - * @section Change Logs - * Date Author Notes - * 2006-08-23 Bernard first version - * 2011-02-14 onelife Modify for EFM32 - *********************************************************************/ - -/******************************************************************//** -* @addtogroup cortex-m3 -* @{ -*********************************************************************/ - -/* Includes -------------------------------------------------------------------*/ -#include <rtthread.h> - -/* Private typedef -------------------------------------------------------------*/ -/* Private define --------------------------------------------------------------*/ -/* Private macro --------------------------------------------------------------*/ -/* Private variables ------------------------------------------------------------*/ -/* Private function prototypes ---------------------------------------------------*/ -/* Private functions ------------------------------------------------------------*/ -/** - * This function will initialize thread stack - * - * @param tentry the entry of thread - * @param parameter the parameter of entry - * @param stack_addr the beginning stack address - * @param texit the function will be called when thread exit - * - * @return stack address - */ -rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, - rt_uint8_t *stack_addr, void *texit) -{ - unsigned long *stk; - - stk = (unsigned long *)stack_addr; - *(stk) = 0x01000000L; /* PSR */ - *(--stk) = (unsigned long)tentry; /* entry point, pc */ - *(--stk) = (unsigned long)texit; /* lr */ - *(--stk) = 0; /* r12 */ - *(--stk) = 0; /* r3 */ - *(--stk) = 0; /* r2 */ - *(--stk) = 0; /* r1 */ - *(--stk) = (unsigned long)parameter; /* r0 : argument */ - - *(--stk) = 0; /* r11 */ - *(--stk) = 0; /* r10 */ - *(--stk) = 0; /* r9 */ - *(--stk) = 0; /* r8 */ - *(--stk) = 0; /* r7 */ - *(--stk) = 0; /* r6 */ - *(--stk) = 0; /* r5 */ - *(--stk) = 0; /* r4 */ - - /* return task's current stack address */ - return (rt_uint8_t *)stk; -} - -/******************************************************************//** - * @} -*********************************************************************/ diff --git a/libcpu/arm/cortex-m3/start_gcc.S b/libcpu/arm/cortex-m3/start_gcc.S index f48c24a6c8..81ec65d2e3 100644 --- a/libcpu/arm/cortex-m3/start_gcc.S +++ b/libcpu/arm/cortex-m3/start_gcc.S @@ -51,7 +51,7 @@ g_pfnVectors: .word Initial_spTop
.word Reset_Handler
.word NMI_Handler
- .word rt_hw_hard_fault
+ .word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
@@ -62,8 +62,8 @@ g_pfnVectors: .word SVC_Handler
.word DebugMon_Handler
.word 0
- .word rt_hw_pend_sv
- .word rt_hw_timer_handler
+ .word PendSV_Handler
+ .word SysTick_Handler
/* External Interrupts */
.word DMA_IRQHandler /* 0: DMA Interrupt (efm32_dma.c) */
.word GPIO_EVEN_IRQHandler /* 1: GPIO_EVEN Interrupt */
|
