diff options
| author | HubretXie <[email protected]> | 2019-04-28 15:14:42 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-04-28 15:14:42 +0800 |
| commit | 08a9887a28de879bbb4c8801d6c065a45e0beed8 (patch) | |
| tree | 21abaa91d5b0549ec6496412ad928810a27c1f5f /libcpu | |
| parent | 25cdd8bba95499656594a1d3dfd42fd014df1f9f (diff) | |
| parent | b57e075867ec075f520863757906ced4d181357e (diff) | |
Merge pull request #3 from RT-Thread/master
sync
Diffstat (limited to 'libcpu')
| -rw-r--r-- | libcpu/arm/cortex-a/gic.h | 2 | ||||
| -rw-r--r-- | libcpu/arm/cortex-a/interrupt.h | 2 | ||||
| -rw-r--r-- | libcpu/arm/cortex-a/start_gcc.S | 4 | ||||
| -rw-r--r-- | libcpu/arm/cortex-a/trap.c | 2 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m7/cpu_cache.c | 89 | ||||
| -rw-r--r-- | libcpu/ti-dsp/c28x/context.s | 41 | ||||
| -rw-r--r-- | libcpu/ti-dsp/c28x/cpuport.c | 4 |
7 files changed, 131 insertions, 13 deletions
diff --git a/libcpu/arm/cortex-a/gic.h b/libcpu/arm/cortex-a/gic.h index 6d86dd31e0..a16d0467fb 100644 --- a/libcpu/arm/cortex-a/gic.h +++ b/libcpu/arm/cortex-a/gic.h @@ -12,7 +12,7 @@ #define __GIC_H__ #include <rthw.h> -#include <platform.h> +#include <board.h> int arm_gic_dist_init(rt_uint32_t index, rt_uint32_t dist_base, int irq_start); int arm_gic_cpu_init(rt_uint32_t index, rt_uint32_t cpu_base); diff --git a/libcpu/arm/cortex-a/interrupt.h b/libcpu/arm/cortex-a/interrupt.h index bff29d402d..31f79cc66e 100644 --- a/libcpu/arm/cortex-a/interrupt.h +++ b/libcpu/arm/cortex-a/interrupt.h @@ -12,7 +12,7 @@ #define __INTERRUPT_H__ #include <rthw.h> -#include <platform.h> +#include <board.h> #define INT_IRQ 0x00 #define INT_FIQ 0x01 diff --git a/libcpu/arm/cortex-a/start_gcc.S b/libcpu/arm/cortex-a/start_gcc.S index 7464ba6161..51026b7ed5 100644 --- a/libcpu/arm/cortex-a/start_gcc.S +++ b/libcpu/arm/cortex-a/start_gcc.S @@ -241,9 +241,7 @@ rt_hw_context_switch_interrupt_do: .endm .align 5 - .globl vector_swi -.weak SVC_Handler -SVC_Handler: +.weak vector_swi vector_swi: push_svc_reg bl rt_hw_trap_swi diff --git a/libcpu/arm/cortex-a/trap.c b/libcpu/arm/cortex-a/trap.c index 54628933ff..a25f6ac862 100644 --- a/libcpu/arm/cortex-a/trap.c +++ b/libcpu/arm/cortex-a/trap.c @@ -10,7 +10,7 @@ #include <rtthread.h> #include <rthw.h> -#include <platform.h> +#include <board.h> #include "armv7.h" #include "interrupt.h" diff --git a/libcpu/arm/cortex-m7/cpu_cache.c b/libcpu/arm/cortex-m7/cpu_cache.c new file mode 100644 index 0000000000..4a1a9c2201 --- /dev/null +++ b/libcpu/arm/cortex-m7/cpu_cache.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-04-02 tanek first implementation + * 2019-04-27 misonyo update to cortex-m7 series + */ + +#include <rthw.h> +#include <rtdef.h> +#include <board.h> + +/* The L1-caches on all Cortex®-M7s are divided into lines of 32 bytes. */ +#define L1CACHE_LINESIZE_BYTE (32) + +void rt_hw_cpu_icache_enable(void) +{ + SCB_EnableICache(); +} + +void rt_hw_cpu_icache_disable(void) +{ + SCB_DisableICache(); +} + +rt_base_t rt_hw_cpu_icache_status(void) +{ + return 0; +} + +void rt_hw_cpu_icache_ops(int ops, void* addr, int size) +{ + rt_uint32_t address = (rt_uint32_t)addr & (rt_uint32_t) ~(L1CACHE_LINESIZE_BYTE - 1); + rt_int32_t size_byte = size + address - (rt_uint32_t)addr; + rt_uint32_t linesize = 32U; + if (ops & RT_HW_CACHE_INVALIDATE) + { + __DSB(); + while (size_byte > 0) + { + SCB->ICIMVAU = address; + address += linesize; + size_byte -= linesize; + } + __DSB(); + __ISB(); + } +} + +void rt_hw_cpu_dcache_enable(void) +{ + SCB_EnableDCache(); +} + +void rt_hw_cpu_dcache_disable(void) +{ + SCB_DisableDCache(); +} + +rt_base_t rt_hw_cpu_dcache_status(void) +{ + return 0; +} + +void rt_hw_cpu_dcache_ops(int ops, void* addr, int size) +{ + rt_uint32_t startAddr = (rt_uint32_t)addr & (rt_uint32_t)~(L1CACHE_LINESIZE_BYTE - 1); + rt_uint32_t size_byte = size + (rt_uint32_t)addr - startAddr; + + if (ops & (RT_HW_CACHE_FLUSH | RT_HW_CACHE_INVALIDATE)) + { + SCB_CleanInvalidateDCache_by_Addr((rt_uint32_t *)startAddr, size_byte); + } + else if (ops & RT_HW_CACHE_FLUSH) + { + SCB_CleanDCache_by_Addr((rt_uint32_t *)startAddr, size_byte); + } + else if (ops & RT_HW_CACHE_INVALIDATE) + { + SCB_InvalidateDCache_by_Addr((rt_uint32_t *)startAddr, size_byte); + } + else + { + RT_ASSERT(0); + } +} diff --git a/libcpu/ti-dsp/c28x/context.s b/libcpu/ti-dsp/c28x/context.s index 019b5def13..2b853a0075 100644 --- a/libcpu/ti-dsp/c28x/context.s +++ b/libcpu/ti-dsp/c28x/context.s @@ -94,11 +94,10 @@ _rt_hw_interrupt_enable: .asmfunc _rt_hw_context_switch_interrupt: -_rt_hw_context_switch: MOVL XAR0, #0 MOV AR0, AL MOVL XAR4, *-SP[4] - ; set rt_thread_switch_interrupt_flag to 1 + ; set rt_thread_switch_interrupt_flag to 1 MOVL XAR5, #_rt_thread_switch_interrupt_flag MOVL XAR6, *XAR5 MOVL ACC, XAR6 @@ -114,6 +113,36 @@ _reswitch: MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread MOVL *XAR5, XAR4 + LRETR + .endasmfunc + +; +; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); +; r0 --> from +; r4 --> to + + + .asmfunc +_rt_hw_context_switch: + MOVL XAR0, #0 + MOV AR0, AL + MOVL XAR4, *-SP[4] + ; set rt_thread_switch_interrupt_flag to 1 + MOVL XAR5, #_rt_thread_switch_interrupt_flag + MOVL XAR6, *XAR5 + MOVL ACC, XAR6 + CMPB AL, #1 + B _reswitch2, EQ + MOVL XAR6, #1 + MOVL *XAR5, XAR6 + + MOVL XAR5, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread + MOVL *XAR5, XAR0 + +_reswitch2: + MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread + MOVL *XAR5, XAR4 + TRAP #16 LRETR .endasmfunc @@ -139,8 +168,6 @@ _RTOSINT_Handler: MOV AR1, AL CMP AR1, #0 B switch_to_thread, EQ ; skip register save at the first time - - ;MOVZ AR1, @SP ; get from thread stack pointer ;#if defined (__VFP_FP__) && !defined(__SOFTFP__) ; TST lr, #0x10 ; if(!EXC_RETURN[4]) @@ -159,9 +186,9 @@ _RTOSINT_Handler: ;#endif MOV AL, *AR0 - MOV AR1, AL + MOV AR0, AL MOVZ AR1, @SP ; get from thread stack pointer - MOV *AR0, AR1 ; update from thread stack pointer + MOV *AR0, AR1 ; update from thread stack pointer switch_to_thread: MOV AR1, #_rt_interrupt_to_thread @@ -175,7 +202,7 @@ switch_to_thread: ;#endif MOV @SP, AR1 - INC SP + RT_CTX_RESTORE ; pop r4 - r11 register rtosint_exit: diff --git a/libcpu/ti-dsp/c28x/cpuport.c b/libcpu/ti-dsp/c28x/cpuport.c index 8885f647a9..2d42884bed 100644 --- a/libcpu/ti-dsp/c28x/cpuport.c +++ b/libcpu/ti-dsp/c28x/cpuport.c @@ -17,6 +17,9 @@ rt_uint32_t rt_thread_switch_interrupt_flag; /* exception hook */ static rt_err_t (*rt_exception_hook)(void *context) = RT_NULL; +extern rt_uint16_t rt_hw_get_st0(void); +extern rt_uint16_t rt_hw_get_st1(void); + struct exception_stack_frame { rt_uint32_t t_st0; @@ -59,6 +62,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, stk = stack_addr; stk = (rt_uint8_t *)RT_ALIGN((rt_uint32_t)stk, 8); //stk -= sizeof(struct stack_frame); + stk += 1; stack_frame = (struct stack_frame *)stk; |
