mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-20 15:08:37 +03:00
Initial commit
This commit is contained in:
291
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM0.c
vendored
Normal file
291
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM0.c
vendored
Normal file
@ -0,0 +1,291 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM0.C
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M0
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_MemBox.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
__asm void rt_set_PSP (U32 stack) {
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
__asm U32 rt_get_PSP (void) {
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
__asm void os_set_env (void) {
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
MOV R0,SP ; PSP = MSP
|
||||
MSR PSP,R0
|
||||
LDR R0,=__cpp(&os_flags)
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
BNE PrivilegedE
|
||||
MOVS R0,#0x03 ; Unprivileged Thread mode, use PSP
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
PrivilegedE
|
||||
MOVS R0,#0x02 ; Privileged Thread mode, use PSP
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
__asm void *_alloc_box (void *box_mem) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R3,=__cpp(rt_alloc_box)
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedA
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedA
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedA
|
||||
BX R12
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
__asm U32 _free_box (void *box_mem, void *box) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R3,=__cpp(rt_free_box)
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedF
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedF
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedF
|
||||
BX R12
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
__asm void SVC_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
IMPORT SVC_Count
|
||||
IMPORT SVC_Table
|
||||
IMPORT rt_stk_check
|
||||
|
||||
MRS R0,PSP ; Read PSP
|
||||
LDR R1,[R0,#24] ; Read Saved PC from Stack
|
||||
SUBS R1,R1,#2 ; Point to SVC Instruction
|
||||
LDRB R1,[R1] ; Load SVC Number
|
||||
CMP R1,#0
|
||||
BNE SVC_User ; User SVC Number > 0
|
||||
|
||||
MOV LR,R4
|
||||
LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack
|
||||
MOV R12,R4
|
||||
MOV R4,LR
|
||||
BLX R12 ; Call SVC Function
|
||||
|
||||
MRS R3,PSP ; Read PSP
|
||||
STMIA R3!,{R0-R2} ; Store return values
|
||||
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit ; no task switch
|
||||
|
||||
SUBS R3,#8
|
||||
CMP R1,#0 ; Runtask deleted?
|
||||
BEQ SVC_Next
|
||||
|
||||
MRS R0,PSP ; Read PSP
|
||||
SUBS R0,R0,#32 ; Adjust Start Address
|
||||
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
STMIA R0!,{R4-R7} ; Save old context (R4-R7)
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
ADDS R0,R0,#16 ; Adjust Start Address
|
||||
LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11)
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 ; Write PSP
|
||||
SUBS R0,R0,#32 ; Adjust Start Address
|
||||
LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7)
|
||||
|
||||
SVC_Exit
|
||||
MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value
|
||||
MVNS R0,R0
|
||||
BX R0 ; RETI to Thread Mode, use PSP
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User
|
||||
PUSH {R4,LR} ; Save Registers
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done ; Overflow
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LSLS R1,R1,#2
|
||||
LDR R4,[R4,R1] ; Load SVC Function Address
|
||||
MOV LR,R4
|
||||
|
||||
LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack
|
||||
MOV R12,R4
|
||||
BLX LR ; Call SVC Function
|
||||
|
||||
MRS R4,PSP ; Read PSP
|
||||
STMIA R4!,{R0-R3} ; Function return values
|
||||
SVC_Done
|
||||
POP {R4,PC} ; RETI
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
__asm void PendSV_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
BL __cpp(rt_pop_req)
|
||||
|
||||
Sys_Switch
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit ; no task switch
|
||||
|
||||
SUBS R3,#8
|
||||
|
||||
MRS R0,PSP ; Read PSP
|
||||
SUBS R0,R0,#32 ; Adjust Start Address
|
||||
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
STMIA R0!,{R4-R7} ; Save old context (R4-R7)
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
ADDS R0,R0,#16 ; Adjust Start Address
|
||||
LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11)
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 ; Write PSP
|
||||
SUBS R0,R0,#32 ; Adjust Start Address
|
||||
LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7)
|
||||
|
||||
Sys_Exit
|
||||
MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value
|
||||
MVNS R0,R0
|
||||
BX R0 ; RETI to Thread Mode, use PSP
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
__asm void SysTick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
__asm void OS_Tick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
BL __cpp(os_tick_irqack)
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
264
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM3.c
vendored
Normal file
264
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM3.c
vendored
Normal file
@ -0,0 +1,264 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM3.C
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M3
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_MemBox.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
__asm void rt_set_PSP (U32 stack) {
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
__asm U32 rt_get_PSP (void) {
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
__asm void os_set_env (void) {
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
MOV R0,SP ; PSP = MSP
|
||||
MSR PSP,R0
|
||||
LDR R0,=__cpp(&os_flags)
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
MOVNE R0,#0x02 ; Privileged Thread mode, use PSP
|
||||
MOVEQ R0,#0x03 ; Unprivileged Thread mode, use PSP
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
__asm void *_alloc_box (void *box_mem) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R12,=__cpp(rt_alloc_box)
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
__asm U32 _free_box (void *box_mem, void *box) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R12,=__cpp(rt_free_box)
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
__asm void SVC_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
IMPORT SVC_Count
|
||||
IMPORT SVC_Table
|
||||
IMPORT rt_stk_check
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT SVC_Handler_Veneer
|
||||
SVC_Handler_Veneer
|
||||
#endif
|
||||
|
||||
MRS R0,PSP ; Read PSP
|
||||
LDR R1,[R0,#24] ; Read Saved PC from Stack
|
||||
LDRB R1,[R1,#-2] ; Load SVC Number
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
|
||||
BLX R12 ; Call SVC Function
|
||||
|
||||
MRS R12,PSP ; Read PSP
|
||||
STM R12,{R0-R2} ; Store return values
|
||||
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDM R3,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit ; no task switch
|
||||
|
||||
CBZ R1,SVC_Next ; Runtask deleted?
|
||||
STMDB R12!,{R4-R11} ; Save Old context
|
||||
STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
LDMIA R12!,{R4-R11} ; Restore New Context
|
||||
MSR PSP,R12 ; Write PSP
|
||||
|
||||
SVC_Exit
|
||||
MVN LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
#else
|
||||
BX LR
|
||||
#endif
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User
|
||||
PUSH {R4,LR} ; Save Registers
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done ; Overflow
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] ; Load SVC Function Address
|
||||
|
||||
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
|
||||
BLX R4 ; Call SVC Function
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} ; Function return values
|
||||
SVC_Done
|
||||
POP {R4,PC} ; RETI
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
__asm void PendSV_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT PendSV_Handler_Veneer
|
||||
PendSV_Handler_Veneer
|
||||
#endif
|
||||
|
||||
BL __cpp(rt_pop_req)
|
||||
|
||||
Sys_Switch
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDM R3,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit
|
||||
|
||||
MRS R12,PSP ; Read PSP
|
||||
STMDB R12!,{R4-R11} ; Save Old context
|
||||
STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
LDMIA R12!,{R4-R11} ; Restore New Context
|
||||
MSR PSP,R12 ; Write PSP
|
||||
|
||||
Sys_Exit
|
||||
MVN LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
#else
|
||||
BX LR ; Return to Thread Mode
|
||||
#endif
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
__asm void SysTick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT SysTick_Handler_Veneer
|
||||
SysTick_Handler_Veneer
|
||||
#endif
|
||||
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
__asm void OS_Tick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
BL __cpp(os_tick_irqack)
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
309
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM4.c
vendored
Normal file
309
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/HAL_CM4.c
vendored
Normal file
@ -0,0 +1,309 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM4.C
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M4
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_MemBox.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
__asm void rt_set_PSP (U32 stack) {
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
__asm U32 rt_get_PSP (void) {
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
__asm void os_set_env (void) {
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
MOV R0,SP ; PSP = MSP
|
||||
MSR PSP,R0
|
||||
LDR R0,=__cpp(&os_flags)
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
MOVNE R0,#0x02 ; Privileged Thread mode, use PSP
|
||||
MOVEQ R0,#0x03 ; Unprivileged Thread mode, use PSP
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
__asm void *_alloc_box (void *box_mem) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R12,=__cpp(rt_alloc_box)
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
__asm U32 _free_box (void *box_mem, void *box) {
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
LDR R12,=__cpp(rt_free_box)
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
__asm void SVC_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
IMPORT SVC_Count
|
||||
IMPORT SVC_Table
|
||||
IMPORT rt_stk_check
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT SVC_Handler_Veneer
|
||||
SVC_Handler_Veneer
|
||||
#endif
|
||||
|
||||
MRS R0,PSP ; Read PSP
|
||||
LDR R1,[R0,#24] ; Read Saved PC from Stack
|
||||
LDRB R1,[R1,#-2] ; Load SVC Number
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
|
||||
PUSH {R4,LR} ; Save EXC_RETURN
|
||||
BLX R12 ; Call SVC Function
|
||||
POP {R4,LR} ; Restore EXC_RETURN
|
||||
|
||||
MRS R12,PSP ; Read PSP
|
||||
STM R12,{R0-R2} ; Store return values
|
||||
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDM R3,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSHEQ {LR}
|
||||
POPEQ {PC}
|
||||
#else
|
||||
BXEQ LR ; RETI, no task switch
|
||||
#endif
|
||||
|
||||
CBNZ R1,SVC_ContextSave ; Runtask not deleted?
|
||||
|
||||
TST LR,#0x10 ; is it extended frame?
|
||||
BNE SVC_ContextRestore
|
||||
LDR R1,=0xE000EF34
|
||||
LDR R0,[R1] ; Load FPCCR
|
||||
BIC R0,#1 ; Clear LSPACT (Lazy state)
|
||||
STR R0,[R1] ; Store FPCCR
|
||||
B SVC_ContextRestore
|
||||
|
||||
SVC_ContextSave
|
||||
TST LR,#0x10 ; is it extended frame?
|
||||
VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs
|
||||
MOVEQ R0,#0x01 ; os_tsk->stack_frame val
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val
|
||||
STMDB R12!,{R4-R11} ; Save Old context
|
||||
STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_ContextRestore
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
LDMIA R12!,{R4-R11} ; Restore New Context
|
||||
LDRB R0,[R2,#TCB_STACKF] ; Stack Frame
|
||||
CMP R0,#0 ; Basic/Extended Stack Frame
|
||||
MVNEQ LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
|
||||
MVNNE LR,#:NOT:0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} ; restore VFP hi-registers
|
||||
MSR PSP,R12 ; Write PSP
|
||||
|
||||
SVC_Exit
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
#else
|
||||
BX LR
|
||||
#endif
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User
|
||||
PUSH {R4,LR} ; Save Registers
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done ; Overflow
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] ; Load SVC Function Address
|
||||
|
||||
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
|
||||
BLX R4 ; Call SVC Function
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} ; Function return values
|
||||
SVC_Done
|
||||
POP {R4,PC} ; RETI
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
__asm void PendSV_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT PendSV_Handler_Veneer
|
||||
PendSV_Handler_Veneer
|
||||
#endif
|
||||
|
||||
PUSH {R4,LR} ; Save EXC_RETURN
|
||||
BL __cpp(rt_pop_req)
|
||||
|
||||
Sys_Switch
|
||||
POP {R4,LR} ; Restore EXC_RETURN
|
||||
|
||||
LDR R3,=__cpp(&os_tsk)
|
||||
LDM R3,{R1,R2} ; os_tsk.run, os_tsk.next
|
||||
CMP R1,R2
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSHEQ {LR}
|
||||
POPEQ {PC}
|
||||
#else
|
||||
BXEQ LR ; RETI, no task switch
|
||||
#endif
|
||||
|
||||
MRS R12,PSP ; Read PSP
|
||||
TST LR,#0x10 ; is it extended frame?
|
||||
VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs
|
||||
MOVEQ R0,#0x01 ; os_tsk->stack_frame val
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val
|
||||
STMDB R12!,{R4-R11} ; Save Old context
|
||||
STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check ; Check for Stack overflow
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] ; os_tsk.run = os_tsk.next
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] ; os_tsk.next->tsk_stack
|
||||
LDMIA R12!,{R4-R11} ; Restore New Context
|
||||
LDRB R0,[R2,#TCB_STACKF] ; Stack Frame
|
||||
CMP R0,#0 ; Basic/Extended Stack Frame
|
||||
MVNEQ LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
|
||||
MVNNE LR,#:NOT:0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} ; restore VFP hi-regs
|
||||
MSR PSP,R12 ; Write PSP
|
||||
|
||||
Sys_Exit
|
||||
#ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
#else
|
||||
BX LR ; Return to Thread Mode
|
||||
#endif
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
__asm void SysTick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
#ifdef IFX_XMC4XXX
|
||||
EXPORT SysTick_Handler_Veneer
|
||||
SysTick_Handler_Veneer
|
||||
#endif
|
||||
|
||||
PUSH {R4,LR} ; Save EXC_RETURN
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
__asm void OS_Tick_Handler (void) {
|
||||
PRESERVE8
|
||||
|
||||
PUSH {R4,LR} ; Save EXC_RETURN
|
||||
BL __cpp(os_tick_irqack)
|
||||
BL __cpp(rt_systick)
|
||||
B Sys_Switch
|
||||
|
||||
ALIGN
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
1506
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/RTX_Lib_CM.uvoptx
vendored
Normal file
1506
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/RTX_Lib_CM.uvoptx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6107
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/RTX_Lib_CM.uvprojx
vendored
Normal file
6107
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/RTX_Lib_CM.uvprojx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
48
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/SVC_Table.s
vendored
Normal file
48
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/ARM/SVC_Table.s
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
;/*----------------------------------------------------------------------------
|
||||
; * CMSIS-RTOS - RTX
|
||||
; *----------------------------------------------------------------------------
|
||||
; * Name: SVC_TABLE.S
|
||||
; * Purpose: Pre-defined SVC Table for Cortex-M
|
||||
; * Rev.: V4.70
|
||||
; *----------------------------------------------------------------------------
|
||||
; *
|
||||
; * Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
; *
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
; * not use this file except in compliance with the License.
|
||||
; * You may obtain a copy of the License at
|
||||
; *
|
||||
; * www.apache.org/licenses/LICENSE-2.0
|
||||
; *
|
||||
; * Unless required by applicable law or agreed to in writing, software
|
||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; * See the License for the specific language governing permissions and
|
||||
; * limitations under the License.
|
||||
; *---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
AREA SVC_TABLE, CODE, READONLY
|
||||
|
||||
EXPORT SVC_Count
|
||||
|
||||
SVC_Cnt EQU (SVC_End-SVC_Table)/4
|
||||
SVC_Count DCD SVC_Cnt
|
||||
|
||||
; Import user SVC functions here.
|
||||
; IMPORT __SVC_1
|
||||
|
||||
EXPORT SVC_Table
|
||||
SVC_Table
|
||||
; Insert user SVC functions here. SVC 0 used by RTL Kernel.
|
||||
; DCD __SVC_1 ; user SVC function
|
||||
|
||||
SVC_End
|
||||
|
||||
END
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
360
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM0.S
vendored
Normal file
360
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM0.S
vendored
Normal file
@ -0,0 +1,360 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM0.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M0
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.syntax unified
|
||||
|
||||
.equ TCB_TSTACK, 40
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.thumb
|
||||
|
||||
.section ".text"
|
||||
.align 2
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
# void rt_set_PSP (U32 stack);
|
||||
|
||||
.thumb_func
|
||||
.type rt_set_PSP, %function
|
||||
.global rt_set_PSP
|
||||
rt_set_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_set_PSP, .-rt_set_PSP
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
# U32 rt_get_PSP (void);
|
||||
|
||||
.thumb_func
|
||||
.type rt_get_PSP, %function
|
||||
.global rt_get_PSP
|
||||
rt_get_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_get_PSP, .-rt_get_PSP
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
# void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
.thumb_func
|
||||
.type os_set_env, %function
|
||||
.global os_set_env
|
||||
os_set_env:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
BNE PrivilegedE
|
||||
MOVS R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
PrivilegedE:
|
||||
MOVS R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size os_set_env, .-os_set_env
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
# void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _alloc_box, %function
|
||||
.global _alloc_box
|
||||
_alloc_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R3,=rt_alloc_box
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedA
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedA
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedA:
|
||||
BX R12
|
||||
|
||||
.fnend
|
||||
.size _alloc_box, .-_alloc_box
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
# U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _free_box, %function
|
||||
.global _free_box
|
||||
_free_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R3,=rt_free_box
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedF
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedF
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedF:
|
||||
BX R12
|
||||
|
||||
.fnend
|
||||
.size _free_box, .-_free_box
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
# void SVC_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SVC_Handler, %function
|
||||
.global SVC_Handler
|
||||
SVC_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
SUBS R1,R1,#2 /* Point to SVC Instruction */
|
||||
LDRB R1,[R1] /* Load SVC Number */
|
||||
CMP R1,#0
|
||||
BNE SVC_User /* User SVC Number > 0 */
|
||||
|
||||
MOV LR,R4
|
||||
LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */
|
||||
MOV R12,R4
|
||||
MOV R4,LR
|
||||
BLX R12 /* Call SVC Function */
|
||||
|
||||
MRS R3,PSP /* Read PSP */
|
||||
STMIA R3!,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit /* no task switch */
|
||||
|
||||
SUBS R3,#8
|
||||
CMP R1,#0 /* Runtask deleted? */
|
||||
BEQ SVC_Next
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
STMIA R0!,{R4-R7} /* Save old context (R4-R7) */
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} /* Save old context (R8-R11) */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
ADDS R0,R0,#16 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 /* Write PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */
|
||||
|
||||
SVC_Exit:
|
||||
MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */
|
||||
MVNS R0,R0
|
||||
BX R0 /* RETI to Thread Mode, use PSP */
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LSLS R1,R1,#2
|
||||
LDR R4,[R4,R1] /* Load SVC Function Address */
|
||||
MOV LR,R4
|
||||
|
||||
LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */
|
||||
MOV R12,R4
|
||||
BLX LR /* Call SVC Function */
|
||||
|
||||
MRS R4,PSP /* Read PSP */
|
||||
STMIA R4!,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
.fnend
|
||||
.size SVC_Handler, .-SVC_Handler
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
# void PendSV_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type PendSV_Handler, %function
|
||||
.global PendSV_Handler
|
||||
.global Sys_Switch
|
||||
PendSV_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
LDR R3,=os_tsk
|
||||
LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit /* no task switch */
|
||||
|
||||
SUBS R3,#8
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
STMIA R0!,{R4-R7} /* Save old context (R4-R7) */
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} /* Save old context (R8-R11) */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
ADDS R0,R0,#16 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 /* Write PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */
|
||||
|
||||
Sys_Exit:
|
||||
MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */
|
||||
MVNS R0,R0
|
||||
BX R0 /* RETI to Thread Mode, use PSP */
|
||||
|
||||
.fnend
|
||||
.size PendSV_Handler, .-PendSV_Handler
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
# void SysTick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SysTick_Handler, %function
|
||||
.global SysTick_Handler
|
||||
SysTick_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size SysTick_Handler, .-SysTick_Handler
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
# void OS_Tick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type OS_Tick_Handler, %function
|
||||
.global OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size OS_Tick_Handler, .-OS_Tick_Handler
|
||||
|
||||
|
||||
.end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
335
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM3.S
vendored
Normal file
335
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM3.S
vendored
Normal file
@ -0,0 +1,335 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM3.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M3
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.syntax unified
|
||||
|
||||
.equ TCB_TSTACK, 40
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.thumb
|
||||
|
||||
.section ".text"
|
||||
.align 2
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
# void rt_set_PSP (U32 stack);
|
||||
|
||||
.thumb_func
|
||||
.type rt_set_PSP, %function
|
||||
.global rt_set_PSP
|
||||
rt_set_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_set_PSP, .-rt_set_PSP
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
# U32 rt_get_PSP (void);
|
||||
|
||||
.thumb_func
|
||||
.type rt_get_PSP, %function
|
||||
.global rt_get_PSP
|
||||
rt_get_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_get_PSP, .-rt_get_PSP
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
# void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
.thumb_func
|
||||
.type os_set_env, %function
|
||||
.global os_set_env
|
||||
os_set_env:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
ITE NE
|
||||
MOVNE R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MOVEQ R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size os_set_env, .-os_set_env
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
# void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _alloc_box, %function
|
||||
.global _alloc_box
|
||||
_alloc_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R12,=rt_alloc_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size _alloc_box, .-_alloc_box
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
# U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _free_box, %function
|
||||
.global _free_box
|
||||
_free_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R12,=rt_free_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size _free_box, .-_free_box
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
# void SVC_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SVC_Handler, %function
|
||||
.global SVC_Handler
|
||||
SVC_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global SVC_Handler_Veneer
|
||||
SVC_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
LDRB R1,[R1,#-2] /* Load SVC Number */
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R12 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STM R12,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit /* no task switch */
|
||||
|
||||
CBZ R1,SVC_Next /* Runtask deleted? */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
SVC_Exit:
|
||||
MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
.ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
.else
|
||||
BX LR
|
||||
.endif
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R4 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
.fnend
|
||||
.size SVC_Handler, .-SVC_Handler
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
# void PendSV_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type PendSV_Handler, %function
|
||||
.global PendSV_Handler
|
||||
.global Sys_Switch
|
||||
PendSV_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global PendSV_Handler_Veneer
|
||||
PendSV_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
Sys_Exit:
|
||||
MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
.ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
.else
|
||||
BX LR /* Return to Thread Mode */
|
||||
.endif
|
||||
|
||||
.fnend
|
||||
.size PendSV_Handler, .-PendSV_Handler
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
# void SysTick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SysTick_Handler, %function
|
||||
.global SysTick_Handler
|
||||
SysTick_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global SysTick_Handler_Veneer
|
||||
SysTick_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size SysTick_Handler, .-SysTick_Handler
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
# void OS_Tick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type OS_Tick_Handler, %function
|
||||
.global OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size OS_Tick_Handler, .-OS_Tick_Handler
|
||||
|
||||
|
||||
.end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
389
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM4.S
vendored
Normal file
389
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/HAL_CM4.S
vendored
Normal file
@ -0,0 +1,389 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM4.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M4
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.syntax unified
|
||||
|
||||
.equ TCB_STACKF, 37
|
||||
.equ TCB_TSTACK, 40
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
.thumb
|
||||
|
||||
.section ".text"
|
||||
.align 2
|
||||
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
# void rt_set_PSP (U32 stack);
|
||||
|
||||
.thumb_func
|
||||
.type rt_set_PSP, %function
|
||||
.global rt_set_PSP
|
||||
rt_set_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_set_PSP, .-rt_set_PSP
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
# U32 rt_get_PSP (void);
|
||||
|
||||
.thumb_func
|
||||
.type rt_get_PSP, %function
|
||||
.global rt_get_PSP
|
||||
rt_get_PSP:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size rt_get_PSP, .-rt_get_PSP
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
# void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
.thumb_func
|
||||
.type os_set_env, %function
|
||||
.global os_set_env
|
||||
os_set_env:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
ITE NE
|
||||
MOVNE R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MOVEQ R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size os_set_env, .-os_set_env
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
# void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _alloc_box, %function
|
||||
.global _alloc_box
|
||||
_alloc_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R12,=rt_alloc_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size _alloc_box, .-_alloc_box
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
# U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
.thumb_func
|
||||
.type _free_box, %function
|
||||
.global _free_box
|
||||
_free_box:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
LDR R12,=rt_free_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
.fnend
|
||||
.size _free_box, .-_free_box
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
# void SVC_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SVC_Handler, %function
|
||||
.global SVC_Handler
|
||||
SVC_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global SVC_Handler_Veneer
|
||||
SVC_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
LDRB R1,[R1,#-2] /* Load SVC Number */
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BLX R12 /* Call SVC Function */
|
||||
POP {R4,LR} /* Restore EXC_RETURN */
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STM R12,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
.ifdef IFX_XMC4XXX
|
||||
ITT EQ
|
||||
PUSHEQ {LR}
|
||||
POPEQ {PC}
|
||||
.else
|
||||
IT EQ
|
||||
BXEQ LR /* RETI, no task switch */
|
||||
.endif
|
||||
|
||||
CBNZ R1,SVC_ContextSave /* Runtask not deleted? */
|
||||
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
BNE SVC_ContextRestore
|
||||
LDR R1,=0xE000EF34
|
||||
LDR R0,[R1] /* Load FPCCR */
|
||||
BIC R0,#1 /* Clear LSPACT (Lazy state) */
|
||||
STR R0,[R1] /* Store FPCCR */
|
||||
B SVC_ContextRestore
|
||||
|
||||
SVC_ContextSave:
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_ContextRestore:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
ITEE EQ
|
||||
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
MVNNE LR,#~0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
SVC_Exit:
|
||||
.ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
.else
|
||||
BX LR
|
||||
.endif
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R4 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
.fnend
|
||||
.size SVC_Handler, .-SVC_Handler
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
# void PendSV_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type PendSV_Handler, %function
|
||||
.global PendSV_Handler
|
||||
.global Sys_Switch
|
||||
PendSV_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global PendSV_Handler_Veneer
|
||||
PendSV_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
POP {R4,LR} /* Restore EXC_RETURN */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
.ifdef IFX_XMC4XXX
|
||||
ITT EQ
|
||||
PUSHEQ {LR}
|
||||
POPEQ {PC}
|
||||
.else
|
||||
IT EQ
|
||||
BXEQ LR /* RETI, no task switch */
|
||||
.endif
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
ITEE EQ
|
||||
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
MVNNE LR,#~0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
Sys_Exit:
|
||||
.ifdef IFX_XMC4XXX
|
||||
PUSH {LR}
|
||||
POP {PC}
|
||||
.else
|
||||
BX LR /* Return to Thread Mode */
|
||||
.endif
|
||||
|
||||
.fnend
|
||||
.size PendSV_Handler, .-PendSV_Handler
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
# void SysTick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type SysTick_Handler, %function
|
||||
.global SysTick_Handler
|
||||
SysTick_Handler:
|
||||
.ifdef IFX_XMC4XXX
|
||||
.global SysTick_Handler_Veneer
|
||||
SysTick_Handler_Veneer:
|
||||
.endif
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size SysTick_Handler, .-SysTick_Handler
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
# void OS_Tick_Handler (void);
|
||||
|
||||
.thumb_func
|
||||
.type OS_Tick_Handler, %function
|
||||
.global OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
.fnend
|
||||
.size OS_Tick_Handler, .-OS_Tick_Handler
|
||||
|
||||
|
||||
.end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
1368
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/RTX_Lib_CM.uvoptx
vendored
Normal file
1368
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/RTX_Lib_CM.uvoptx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3819
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/RTX_Lib_CM.uvprojx
vendored
Normal file
3819
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/RTX_Lib_CM.uvprojx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
44
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/SVC_Table.S
vendored
Normal file
44
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/GCC/SVC_Table.S
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
;/*----------------------------------------------------------------------------
|
||||
; * CMSIS-RTOS - RTX
|
||||
; *----------------------------------------------------------------------------
|
||||
; * Name: SVC_TABLE.S
|
||||
; * Purpose: Pre-defined SVC Table for Cortex-M
|
||||
; * Rev.: V4.70
|
||||
; *----------------------------------------------------------------------------
|
||||
; *
|
||||
; * Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
; *
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
; * not use this file except in compliance with the License.
|
||||
; * You may obtain a copy of the License at
|
||||
; *
|
||||
; * www.apache.org/licenses/LICENSE-2.0
|
||||
; *
|
||||
; * Unless required by applicable law or agreed to in writing, software
|
||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; * See the License for the specific language governing permissions and
|
||||
; * limitations under the License.
|
||||
; *---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
.section ".svc_table"
|
||||
|
||||
.global SVC_Table
|
||||
SVC_Table:
|
||||
/* Insert user SVC functions here. SVC 0 used by RTL Kernel. */
|
||||
# .long __SVC_1 /* user SVC function */
|
||||
SVC_End:
|
||||
|
||||
.global SVC_Count
|
||||
SVC_Count:
|
||||
.long (SVC_End-SVC_Table)/4
|
||||
|
||||
|
||||
.end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
171
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/HAL_CM.c
vendored
Normal file
171
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/HAL_CM.c
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM.C
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef DBG_MSG
|
||||
BIT dbg_msg;
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_init_stack ---------------------------------*/
|
||||
|
||||
void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
|
||||
/* Prepare TCB and saved context for a first time start of a task. */
|
||||
U32 *stk,i,size;
|
||||
|
||||
/* Prepare a complete interrupt frame for first task start */
|
||||
size = p_TCB->priv_stack >> 2;
|
||||
if (size == 0U) {
|
||||
size = (U16)os_stackinfo >> 2;
|
||||
}
|
||||
|
||||
/* Write to the top of stack. */
|
||||
stk = &p_TCB->stack[size];
|
||||
|
||||
/* Auto correct to 8-byte ARM stack alignment. */
|
||||
if ((U32)stk & 0x04U) {
|
||||
stk--;
|
||||
}
|
||||
|
||||
stk -= 16;
|
||||
|
||||
/* Default xPSR and initial PC */
|
||||
stk[15] = INITIAL_xPSR;
|
||||
stk[14] = (U32)task_body;
|
||||
|
||||
/* Clear R4-R11,R0-R3,R12,LR registers. */
|
||||
for (i = 0U; i < 14U; i++) {
|
||||
stk[i] = 0U;
|
||||
}
|
||||
|
||||
/* Assign a void pointer to R0. */
|
||||
stk[8] = (U32)p_TCB->msg;
|
||||
|
||||
/* Initial Task stack pointer. */
|
||||
p_TCB->tsk_stack = (U32)stk;
|
||||
|
||||
/* Task entry point. */
|
||||
p_TCB->ptask = task_body;
|
||||
|
||||
/* Initialize stack with magic pattern. */
|
||||
if (os_stackinfo & 0x10000000U) {
|
||||
if (size > (16U+1U)) {
|
||||
for (i = ((size - 16U)/2U) - 1U; i; i--) {
|
||||
stk -= 2U;
|
||||
stk[1] = MAGIC_PATTERN;
|
||||
stk[0] = MAGIC_PATTERN;
|
||||
}
|
||||
if (--stk > p_TCB->stack) {
|
||||
*stk = MAGIC_PATTERN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a magic word for checking of stack overflow. */
|
||||
p_TCB->stack[0] = MAGIC_WORD;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_ret_val ----------------------------------*/
|
||||
|
||||
static __inline U32 *rt_ret_regs (P_TCB p_TCB) {
|
||||
/* Get pointer to task return value registers (R0..R3) in Stack */
|
||||
#if defined(__TARGET_FPU_VFP)
|
||||
if (p_TCB->stack_frame) {
|
||||
/* Extended Stack Frame: R4-R11,S16-S31,R0-R3,R12,LR,PC,xPSR,S0-S15,FPSCR */
|
||||
return (U32 *)(p_TCB->tsk_stack + (8U*4U) + (16U*4U));
|
||||
} else {
|
||||
/* Basic Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */
|
||||
return (U32 *)(p_TCB->tsk_stack + (8U*4U));
|
||||
}
|
||||
#else
|
||||
/* Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */
|
||||
return (U32 *)(p_TCB->tsk_stack + (8U*4U));
|
||||
#endif
|
||||
}
|
||||
|
||||
void rt_ret_val (P_TCB p_TCB, U32 v0) {
|
||||
U32 *ret;
|
||||
|
||||
ret = rt_ret_regs(p_TCB);
|
||||
ret[0] = v0;
|
||||
}
|
||||
|
||||
void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) {
|
||||
U32 *ret;
|
||||
|
||||
ret = rt_ret_regs(p_TCB);
|
||||
ret[0] = v0;
|
||||
ret[1] = v1;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- dbg_init --------------------------------------*/
|
||||
|
||||
#ifdef DBG_MSG
|
||||
void dbg_init (void) {
|
||||
if (((DEMCR & DEMCR_TRCENA) != 0U) &&
|
||||
((ITM_CONTROL & ITM_ITMENA) != 0U) &&
|
||||
((ITM_ENABLE & (1UL << 31)) != 0U)) {
|
||||
dbg_msg = __TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------- dbg_task_notify -------------------------------*/
|
||||
|
||||
#ifdef DBG_MSG
|
||||
void dbg_task_notify (P_TCB p_tcb, BOOL create) {
|
||||
while (ITM_PORT31_U32 == 0U);
|
||||
ITM_PORT31_U32 = (U32)p_tcb->ptask;
|
||||
while (ITM_PORT31_U32 == 0U);
|
||||
ITM_PORT31_U16 = (U16)((create << 8) | p_tcb->task_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------- dbg_task_switch -------------------------------*/
|
||||
|
||||
#ifdef DBG_MSG
|
||||
void dbg_task_switch (U32 task_id) {
|
||||
while (ITM_PORT31_U32 == 0U);
|
||||
ITM_PORT31_U8 = (U8)task_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
303
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM0.s
vendored
Normal file
303
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM0.s
vendored
Normal file
@ -0,0 +1,303 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM0.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M0
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
NAME HAL_CM0.S
|
||||
|
||||
#define TCB_TSTACK 40
|
||||
|
||||
EXTERN os_flags
|
||||
EXTERN os_tsk
|
||||
EXTERN rt_alloc_box
|
||||
EXTERN rt_free_box
|
||||
EXTERN rt_stk_check
|
||||
EXTERN rt_pop_req
|
||||
EXTERN rt_systick
|
||||
EXTERN os_tick_irqack
|
||||
EXTERN SVC_Table
|
||||
EXTERN SVC_Count
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
THUMB
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
; void rt_set_PSP (U32 stack);
|
||||
|
||||
PUBLIC rt_set_PSP
|
||||
rt_set_PSP:
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
; U32 rt_get_PSP (void);
|
||||
|
||||
PUBLIC rt_get_PSP
|
||||
rt_get_PSP:
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
; void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
PUBLIC os_set_env
|
||||
os_set_env:
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
BNE PrivilegedE
|
||||
MOVS R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
PrivilegedE:
|
||||
MOVS R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
; void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _alloc_box
|
||||
_alloc_box:
|
||||
|
||||
LDR R3,=rt_alloc_box
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedA
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedA
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedA:
|
||||
BX R12
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
; U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _free_box
|
||||
_free_box:
|
||||
|
||||
LDR R3,=rt_free_box
|
||||
MOV R12,R3
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
BNE PrivilegedF
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
BEQ PrivilegedF
|
||||
SVC 0
|
||||
BX LR
|
||||
PrivilegedF:
|
||||
BX R12
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
; void SVC_Handler (void);
|
||||
|
||||
PUBLIC SVC_Handler
|
||||
SVC_Handler:
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
SUBS R1,R1,#2 /* Point to SVC Instruction */
|
||||
LDRB R1,[R1] /* Load SVC Number */
|
||||
CMP R1,#0
|
||||
BNE SVC_User /* User SVC Number > 0 */
|
||||
|
||||
MOV LR,R4
|
||||
LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */
|
||||
MOV R12,R4
|
||||
MOV R4,LR
|
||||
BLX R12 /* Call SVC Function */
|
||||
|
||||
MRS R3,PSP /* Read PSP */
|
||||
STMIA R3!,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit /* no task switch */
|
||||
|
||||
SUBS R3,#8
|
||||
CMP R1,#0 /* Runtask deleted? */
|
||||
BEQ SVC_Next
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
STMIA R0!,{R4-R7} /* Save old context (R4-R7) */
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} /* Save old context (R8-R11) */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
ADDS R0,R0,#16 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 /* Write PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */
|
||||
|
||||
SVC_Exit:
|
||||
MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */
|
||||
MVNS R0,R0
|
||||
BX R0 /* RETI to Thread Mode, use PSP */
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LSLS R1,R1,#2
|
||||
LDR R4,[R4,R1] /* Load SVC Function Address */
|
||||
MOV LR,R4
|
||||
|
||||
LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */
|
||||
MOV R12,R4
|
||||
BLX LR /* Call SVC Function */
|
||||
|
||||
MRS R4,PSP /* Read PSP */
|
||||
STMIA R4!,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
; void PendSV_Handler (void);
|
||||
|
||||
PUBLIC PendSV_Handler
|
||||
PendSV_Handler:
|
||||
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
LDR R3,=os_tsk
|
||||
LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit /* no task switch */
|
||||
|
||||
SUBS R3,#8
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
STMIA R0!,{R4-R7} /* Save old context (R4-R7) */
|
||||
MOV R4,R8
|
||||
MOV R5,R9
|
||||
MOV R6,R10
|
||||
MOV R7,R11
|
||||
STMIA R0!,{R4-R7} /* Save old context (R8-R11) */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R0,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
ADDS R0,R0,#16 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */
|
||||
MOV R8,R4
|
||||
MOV R9,R5
|
||||
MOV R10,R6
|
||||
MOV R11,R7
|
||||
MSR PSP,R0 /* Write PSP */
|
||||
SUBS R0,R0,#32 /* Adjust Start Address */
|
||||
LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */
|
||||
|
||||
Sys_Exit:
|
||||
MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */
|
||||
MVNS R0,R0
|
||||
BX R0 /* RETI to Thread Mode, use PSP */
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
; void SysTick_Handler (void);
|
||||
|
||||
PUBLIC SysTick_Handler
|
||||
SysTick_Handler:
|
||||
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
; void OS_Tick_Handler (void);
|
||||
|
||||
PUBLIC OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
END
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
256
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM3.s
vendored
Normal file
256
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM3.s
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM3.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M3
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
NAME HAL_CM3.S
|
||||
|
||||
#define TCB_TSTACK 40
|
||||
|
||||
EXTERN os_flags
|
||||
EXTERN os_tsk
|
||||
EXTERN rt_alloc_box
|
||||
EXTERN rt_free_box
|
||||
EXTERN rt_stk_check
|
||||
EXTERN rt_pop_req
|
||||
EXTERN rt_systick
|
||||
EXTERN os_tick_irqack
|
||||
EXTERN SVC_Table
|
||||
EXTERN SVC_Count
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
THUMB
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
; void rt_set_PSP (U32 stack);
|
||||
|
||||
PUBLIC rt_set_PSP
|
||||
rt_set_PSP:
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
; U32 rt_get_PSP (void);
|
||||
|
||||
PUBLIC rt_get_PSP
|
||||
rt_get_PSP:
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
; void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
PUBLIC os_set_env
|
||||
os_set_env:
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
ITE NE
|
||||
MOVNE R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MOVEQ R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
; void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _alloc_box
|
||||
_alloc_box:
|
||||
|
||||
LDR R12,=rt_alloc_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
; U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _free_box
|
||||
_free_box:
|
||||
|
||||
LDR R12,=rt_free_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
; void SVC_Handler (void);
|
||||
|
||||
PUBLIC SVC_Handler
|
||||
SVC_Handler:
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
LDRB R1,[R1,#-2] /* Load SVC Number */
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R12 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STM R12,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ SVC_Exit /* no task switch */
|
||||
|
||||
CBZ R1,SVC_Next /* Runtask deleted? */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_Next:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
SVC_Exit:
|
||||
MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
BX LR
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R4 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
; void PendSV_Handler (void);
|
||||
|
||||
PUBLIC PendSV_Handler
|
||||
PendSV_Handler:
|
||||
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
BEQ Sys_Exit
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
Sys_Exit:
|
||||
MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
BX LR /* Return to Thread Mode */
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
; void SysTick_Handler (void);
|
||||
|
||||
PUBLIC SysTick_Handler
|
||||
SysTick_Handler:
|
||||
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
; void OS_Tick_Handler (void);
|
||||
|
||||
PUBLIC OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
END
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
298
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM4.s
vendored
Normal file
298
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/HAL_CM4.s
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: HAL_CM4.S
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M4
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
NAME HAL_CM4.S
|
||||
|
||||
#define TCB_STACKF 37
|
||||
#define TCB_TSTACK 40
|
||||
|
||||
EXTERN os_flags
|
||||
EXTERN os_tsk
|
||||
EXTERN rt_alloc_box
|
||||
EXTERN rt_free_box
|
||||
EXTERN rt_stk_check
|
||||
EXTERN rt_pop_req
|
||||
EXTERN rt_systick
|
||||
EXTERN os_tick_irqack
|
||||
EXTERN SVC_Table
|
||||
EXTERN SVC_Count
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
THUMB
|
||||
|
||||
/*--------------------------- rt_set_PSP ------------------------------------*/
|
||||
|
||||
; void rt_set_PSP (U32 stack);
|
||||
|
||||
PUBLIC rt_set_PSP
|
||||
rt_set_PSP:
|
||||
|
||||
MSR PSP,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- rt_get_PSP ------------------------------------*/
|
||||
|
||||
; U32 rt_get_PSP (void);
|
||||
|
||||
PUBLIC rt_get_PSP
|
||||
rt_get_PSP:
|
||||
|
||||
MRS R0,PSP
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- os_set_env ------------------------------------*/
|
||||
|
||||
; void os_set_env (void);
|
||||
/* Switch to Unprivileged/Privileged Thread mode, use PSP. */
|
||||
|
||||
PUBLIC os_set_env
|
||||
os_set_env:
|
||||
|
||||
MOV R0,SP /* PSP = MSP */
|
||||
MSR PSP,R0
|
||||
LDR R0,=os_flags
|
||||
LDRB R0,[R0]
|
||||
LSLS R0,#31
|
||||
ITE NE
|
||||
MOVNE R0,#0x02 /* Privileged Thread mode, use PSP */
|
||||
MOVEQ R0,#0x03 /* Unprivileged Thread mode, use PSP */
|
||||
MSR CONTROL,R0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- _alloc_box ------------------------------------*/
|
||||
|
||||
; void *_alloc_box (void *box_mem);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _alloc_box
|
||||
_alloc_box:
|
||||
|
||||
LDR R12,=rt_alloc_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
|
||||
/*--------------------------- _free_box -------------------------------------*/
|
||||
|
||||
; U32 _free_box (void *box_mem, void *box);
|
||||
/* Function wrapper for Unprivileged/Privileged mode. */
|
||||
|
||||
PUBLIC _free_box
|
||||
_free_box:
|
||||
|
||||
LDR R12,=rt_free_box
|
||||
MRS R3,IPSR
|
||||
LSLS R3,#24
|
||||
IT NE
|
||||
BXNE R12
|
||||
MRS R3,CONTROL
|
||||
LSLS R3,#31
|
||||
IT EQ
|
||||
BXEQ R12
|
||||
SVC 0
|
||||
BX LR
|
||||
|
||||
|
||||
/*-------------------------- SVC_Handler ------------------------------------*/
|
||||
|
||||
; void SVC_Handler (void);
|
||||
|
||||
PUBLIC SVC_Handler
|
||||
SVC_Handler:
|
||||
|
||||
MRS R0,PSP /* Read PSP */
|
||||
LDR R1,[R0,#24] /* Read Saved PC from Stack */
|
||||
LDRB R1,[R1,#-2] /* Load SVC Number */
|
||||
CBNZ R1,SVC_User
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BLX R12 /* Call SVC Function */
|
||||
POP {R4,LR} /* Restore EXC_RETURN */
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
STM R12,{R0-R2} /* Store return values */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
IT EQ
|
||||
BXEQ LR /* RETI, no task switch */
|
||||
|
||||
CBNZ R1,SVC_ContextSave /* Runtask not deleted? */
|
||||
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
BNE SVC_ContextRestore
|
||||
LDR R1,=0xE000EF34
|
||||
LDR R0,[R1] /* Load FPCCR */
|
||||
BIC R0,R0,#1 /* Clear LSPACT (Lazy state) */
|
||||
STR R0,[R1] /* Store FPCCR */
|
||||
B SVC_ContextRestore
|
||||
|
||||
SVC_ContextSave:
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
SVC_ContextRestore:
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
ITEE EQ
|
||||
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
MVNNE LR,#~0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
SVC_Exit:
|
||||
BX LR
|
||||
|
||||
/*------------------- User SVC ------------------------------*/
|
||||
|
||||
SVC_User:
|
||||
PUSH {R4,LR} /* Save Registers */
|
||||
LDR R2,=SVC_Count
|
||||
LDR R2,[R2]
|
||||
CMP R1,R2
|
||||
BHI SVC_Done /* Overflow */
|
||||
|
||||
LDR R4,=SVC_Table-4
|
||||
LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */
|
||||
|
||||
LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
|
||||
BLX R4 /* Call SVC Function */
|
||||
|
||||
MRS R12,PSP
|
||||
STM R12,{R0-R3} /* Function return values */
|
||||
SVC_Done:
|
||||
POP {R4,PC} /* RETI */
|
||||
|
||||
|
||||
/*-------------------------- PendSV_Handler ---------------------------------*/
|
||||
|
||||
; void PendSV_Handler (void);
|
||||
|
||||
PUBLIC PendSV_Handler
|
||||
PendSV_Handler:
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL rt_pop_req
|
||||
|
||||
Sys_Switch:
|
||||
POP {R4,LR} /* Restore EXC_RETURN */
|
||||
|
||||
LDR R3,=os_tsk
|
||||
LDM R3,{R1,R2} /* os_tsk.run, os_tsk.next */
|
||||
CMP R1,R2
|
||||
IT EQ
|
||||
BXEQ LR /* RETI, no task switch */
|
||||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
STMDB R12!,{R4-R11} /* Save Old context */
|
||||
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
|
||||
|
||||
PUSH {R2,R3}
|
||||
BL rt_stk_check /* Check for Stack overflow */
|
||||
POP {R2,R3}
|
||||
|
||||
STR R2,[R3] /* os_tsk.run = os_tsk.next */
|
||||
|
||||
LDR R12,[R2,#TCB_TSTACK] /* os_tsk.next->tsk_stack */
|
||||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
ITEE EQ
|
||||
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
|
||||
MVNNE LR,#~0xFFFFFFED
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
||||
Sys_Exit:
|
||||
BX LR /* Return to Thread Mode */
|
||||
|
||||
|
||||
/*-------------------------- SysTick_Handler --------------------------------*/
|
||||
|
||||
; void SysTick_Handler (void);
|
||||
|
||||
PUBLIC SysTick_Handler
|
||||
SysTick_Handler:
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
/*-------------------------- OS_Tick_Handler --------------------------------*/
|
||||
|
||||
; void OS_Tick_Handler (void);
|
||||
|
||||
PUBLIC OS_Tick_Handler
|
||||
OS_Tick_Handler:
|
||||
|
||||
PUSH {R4,LR} /* Save EXC_RETURN */
|
||||
BL os_tick_irqack
|
||||
BL rt_systick
|
||||
B Sys_Switch
|
||||
|
||||
|
||||
END
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
7876
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/RTX_Lib_CM.ewp
vendored
Normal file
7876
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/RTX_Lib_CM.ewp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/RTX_Lib_CM.eww
vendored
Normal file
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/RTX_Lib_CM.eww
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\RTX_Lib_CM.ewp</path>
|
||||
</project>
|
||||
<batchBuild>
|
||||
<batchDefinition>
|
||||
<name>RTX_Lib_CM</name>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM0_LE</configuration>
|
||||
</member>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM0_BE</configuration>
|
||||
</member>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM3_LE</configuration>
|
||||
</member>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM3_BE</configuration>
|
||||
</member>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM4F_LE</configuration>
|
||||
</member>
|
||||
<member>
|
||||
<project>RTX_Lib_CM</project>
|
||||
<configuration>CM4F_BE</configuration>
|
||||
</member>
|
||||
</batchDefinition>
|
||||
</batchBuild>
|
||||
</workspace>
|
50
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/SVC_Table.s
vendored
Normal file
50
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/IAR/SVC_Table.s
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
;/*----------------------------------------------------------------------------
|
||||
; * CMSIS-RTOS - RTX
|
||||
; *----------------------------------------------------------------------------
|
||||
; * Name: SVC_TABLE.S
|
||||
; * Purpose: Pre-defined SVC Table for Cortex-M
|
||||
; * Rev.: V4.70
|
||||
; *----------------------------------------------------------------------------
|
||||
; *
|
||||
; * Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH
|
||||
; * All rights reserved.
|
||||
; *
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
; * not use this file except in compliance with the License.
|
||||
; * You may obtain a copy of the License at
|
||||
; *
|
||||
; * www.apache.org/licenses/LICENSE-2.0
|
||||
; *
|
||||
; * Unless required by applicable law or agreed to in writing, software
|
||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; * See the License for the specific language governing permissions and
|
||||
; * limitations under the License.
|
||||
; *---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
NAME SVC_TABLE
|
||||
SECTION .text:CONST (2)
|
||||
|
||||
PUBLIC SVC_Count
|
||||
|
||||
SVC_Cnt EQU (SVC_End-SVC_Table)/4
|
||||
SVC_Count DCD SVC_Cnt
|
||||
|
||||
; Import user SVC functions here.
|
||||
; IMPORT __SVC_1
|
||||
|
||||
PUBLIC SVC_Table
|
||||
SVC_Table
|
||||
; Insert user SVC functions here. SVC 0 used by RTL Kernel.
|
||||
; DCD __SVC_1 ; user SVC function
|
||||
|
||||
SVC_End
|
||||
|
||||
END
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
71
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/RTX_Config.h
vendored
Normal file
71
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/RTX_Config.h
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RTX_CONFIG.H
|
||||
* Purpose: Exported functions of RTX_Config.c
|
||||
* Rev.: V4.81
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Error Codes */
|
||||
#define OS_ERR_STK_OVF 1U
|
||||
#define OS_ERR_FIFO_OVF 2U
|
||||
#define OS_ERR_MBX_OVF 3U
|
||||
#define OS_ERR_TIMER_OVF 4U
|
||||
|
||||
/* Definitions */
|
||||
#define BOX_ALIGN_8 0x80000000U
|
||||
#define _declare_box(pool,size,cnt) U32 pool[(((size)+3)/4)*(cnt) + 3]
|
||||
#define _declare_box8(pool,size,cnt) U64 pool[(((size)+7)/8)*(cnt) + 2]
|
||||
#define _init_box8(pool,size,bsize) _init_box (pool,size,(bsize) | BOX_ALIGN_8)
|
||||
|
||||
/* Variables */
|
||||
extern U32 mp_tcb[];
|
||||
extern U64 mp_stk[];
|
||||
extern U32 os_fifo[];
|
||||
extern void *os_active_TCB[];
|
||||
|
||||
/* Constants */
|
||||
extern U16 const os_maxtaskrun;
|
||||
extern U32 const os_trv;
|
||||
extern U8 const os_flags;
|
||||
extern U32 const os_stackinfo;
|
||||
extern U32 const os_rrobin;
|
||||
extern U32 const os_clockrate;
|
||||
extern U32 const os_timernum;
|
||||
extern U16 const mp_tcb_size;
|
||||
extern U32 const mp_stk_size;
|
||||
extern U32 const *m_tmr;
|
||||
extern U16 const mp_tmr_size;
|
||||
extern U8 const os_fifo_size;
|
||||
|
||||
/* Functions */
|
||||
extern void os_idle_demon (void);
|
||||
extern S32 os_tick_init (void);
|
||||
extern U32 os_tick_val (void);
|
||||
extern U32 os_tick_ovf (void);
|
||||
extern void os_tick_irqack (void);
|
||||
extern void os_tmr_call (U16 info);
|
||||
extern void os_error (uint32_t err_code);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
2180
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_CMSIS.c
vendored
Normal file
2180
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_CMSIS.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
181
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Event.c
vendored
Normal file
181
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Event.c
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_EVENT.C
|
||||
* Purpose: Implements waits and wake-ups for event flags
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_Event.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_evt_wait -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) {
|
||||
/* Wait for one or more event flags with optional time-out. */
|
||||
/* "wait_flags" identifies the flags to wait for. */
|
||||
/* "timeout" is the time-out limit in system ticks (0xffff if no time-out) */
|
||||
/* "and_wait" specifies the AND-ing of "wait_flags" as condition to be met */
|
||||
/* to complete the wait. (OR-ing if set to 0). */
|
||||
U32 block_state;
|
||||
|
||||
if (and_wait) {
|
||||
/* Check for AND-connected events */
|
||||
if ((os_tsk.run->events & wait_flags) == wait_flags) {
|
||||
os_tsk.run->events &= ~wait_flags;
|
||||
return (OS_R_EVT);
|
||||
}
|
||||
block_state = WAIT_AND;
|
||||
}
|
||||
else {
|
||||
/* Check for OR-connected events */
|
||||
if (os_tsk.run->events & wait_flags) {
|
||||
os_tsk.run->waits = os_tsk.run->events & wait_flags;
|
||||
os_tsk.run->events &= ~wait_flags;
|
||||
return (OS_R_EVT);
|
||||
}
|
||||
block_state = WAIT_OR;
|
||||
}
|
||||
/* Task has to wait */
|
||||
os_tsk.run->waits = wait_flags;
|
||||
rt_block (timeout, (U8)block_state);
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_evt_set ------------------------------------*/
|
||||
|
||||
void rt_evt_set (U16 event_flags, OS_TID task_id) {
|
||||
/* Set one or more event flags of a selectable task. */
|
||||
P_TCB p_tcb;
|
||||
|
||||
p_tcb = os_active_TCB[task_id-1U];
|
||||
if (p_tcb == NULL) {
|
||||
return;
|
||||
}
|
||||
p_tcb->events |= event_flags;
|
||||
event_flags = p_tcb->waits;
|
||||
/* If the task is not waiting for an event, it should not be put */
|
||||
/* to ready state. */
|
||||
if (p_tcb->state == WAIT_AND) {
|
||||
/* Check for AND-connected events */
|
||||
if ((p_tcb->events & event_flags) == event_flags) {
|
||||
goto wkup;
|
||||
}
|
||||
}
|
||||
if (p_tcb->state == WAIT_OR) {
|
||||
/* Check for OR-connected events */
|
||||
if (p_tcb->events & event_flags) {
|
||||
p_tcb->waits &= p_tcb->events;
|
||||
wkup: p_tcb->events &= ~event_flags;
|
||||
rt_rmv_dly (p_tcb);
|
||||
p_tcb->state = READY;
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val2(p_tcb, 0x08U/*osEventSignal*/, p_tcb->waits);
|
||||
#else
|
||||
rt_ret_val (p_tcb, OS_R_EVT);
|
||||
#endif
|
||||
rt_dispatch (p_tcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_evt_clr ------------------------------------*/
|
||||
|
||||
void rt_evt_clr (U16 clear_flags, OS_TID task_id) {
|
||||
/* Clear one or more event flags (identified by "clear_flags") of a */
|
||||
/* selectable task (identified by "task"). */
|
||||
P_TCB task = os_active_TCB[task_id-1U];
|
||||
|
||||
if (task == NULL) {
|
||||
return;
|
||||
}
|
||||
task->events &= ~clear_flags;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- isr_evt_set -----------------------------------*/
|
||||
|
||||
void isr_evt_set (U16 event_flags, OS_TID task_id) {
|
||||
/* Same function as "os_evt_set", but to be called by ISRs. */
|
||||
P_TCB p_tcb = os_active_TCB[task_id-1U];
|
||||
|
||||
if (p_tcb == NULL) {
|
||||
return;
|
||||
}
|
||||
rt_psq_enq (p_tcb, event_flags);
|
||||
rt_psh_req ();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_evt_get ------------------------------------*/
|
||||
|
||||
U16 rt_evt_get (void) {
|
||||
/* Get events of a running task after waiting for OR connected events. */
|
||||
return (os_tsk.run->waits);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_evt_psh ------------------------------------*/
|
||||
|
||||
void rt_evt_psh (P_TCB p_CB, U16 set_flags) {
|
||||
/* Check if task has to be waken up */
|
||||
U16 event_flags;
|
||||
|
||||
p_CB->events |= set_flags;
|
||||
event_flags = p_CB->waits;
|
||||
if (p_CB->state == WAIT_AND) {
|
||||
/* Check for AND-connected events */
|
||||
if ((p_CB->events & event_flags) == event_flags) {
|
||||
goto rdy;
|
||||
}
|
||||
}
|
||||
if (p_CB->state == WAIT_OR) {
|
||||
/* Check for OR-connected events */
|
||||
if (p_CB->events & event_flags) {
|
||||
p_CB->waits &= p_CB->events;
|
||||
rdy: p_CB->events &= ~event_flags;
|
||||
rt_rmv_dly (p_CB);
|
||||
p_CB->state = READY;
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val2(p_CB, 0x08U/*osEventSignal*/, p_CB->waits);
|
||||
#else
|
||||
rt_ret_val (p_CB, OS_R_EVT);
|
||||
#endif
|
||||
rt_put_prio (&os_rdy, p_CB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Event.h
vendored
Normal file
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Event.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_EVENT.H
|
||||
* Purpose: Implements waits and wake-ups for event flags
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Functions */
|
||||
extern OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait);
|
||||
extern void rt_evt_set (U16 event_flags, OS_TID task_id);
|
||||
extern void rt_evt_clr (U16 clear_flags, OS_TID task_id);
|
||||
extern void isr_evt_set (U16 event_flags, OS_TID task_id);
|
||||
extern U16 rt_evt_get (void);
|
||||
extern void rt_evt_psh (P_TCB p_CB, U16 set_flags);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
280
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_HAL_CM.h
vendored
Normal file
280
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_HAL_CM.h
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_HAL_CM.H
|
||||
* Purpose: Hardware Abstraction Layer for Cortex-M definitions
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Definitions */
|
||||
#define INITIAL_xPSR 0x01000000U
|
||||
#define DEMCR_TRCENA 0x01000000U
|
||||
#define ITM_ITMENA 0x00000001U
|
||||
#define MAGIC_WORD 0xE25A2EA5U
|
||||
#define MAGIC_PATTERN 0xCCCCCCCCU
|
||||
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
|
||||
#if ((defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) && !defined(NO_EXCLUSIVE_ACCESS))
|
||||
#define __USE_EXCLUSIVE_ACCESS
|
||||
#else
|
||||
#undef __USE_EXCLUSIVE_ACCESS
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_GENERIC
|
||||
#define __DMB() do {\
|
||||
__schedule_barrier();\
|
||||
__dmb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#elif defined (__GNUC__) /* GNU Compiler */
|
||||
|
||||
#undef __USE_EXCLUSIVE_ACCESS
|
||||
|
||||
#if defined (__CORTEX_M0)
|
||||
#define __TARGET_ARCH_6S_M
|
||||
#endif
|
||||
|
||||
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||
#define __TARGET_FPU_VFP
|
||||
#endif
|
||||
|
||||
#define __inline inline
|
||||
#define __weak __attribute__((weak))
|
||||
|
||||
#ifndef __CMSIS_GENERIC
|
||||
|
||||
__attribute__((always_inline)) static inline void __enable_irq(void)
|
||||
{
|
||||
__asm volatile ("cpsie i");
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline U32 __disable_irq(void)
|
||||
{
|
||||
U32 result;
|
||||
|
||||
__asm volatile ("mrs %0, primask" : "=r" (result));
|
||||
__asm volatile ("cpsid i");
|
||||
return(result & 1);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void __DMB(void)
|
||||
{
|
||||
__asm volatile ("dmb 0xF":::"memory");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
__attribute__(( always_inline)) static inline U8 __clz(U32 value)
|
||||
{
|
||||
U8 result;
|
||||
|
||||
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
|
||||
return(result);
|
||||
}
|
||||
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
|
||||
#undef __USE_EXCLUSIVE_ACCESS
|
||||
|
||||
#if (__CORE__ == __ARM6M__)
|
||||
#define __TARGET_ARCH_6S_M 1
|
||||
#endif
|
||||
|
||||
#if defined __ARMVFP__
|
||||
#define __TARGET_FPU_VFP 1
|
||||
#endif
|
||||
|
||||
#define __inline inline
|
||||
|
||||
#ifndef __CMSIS_GENERIC
|
||||
|
||||
static inline void __enable_irq(void)
|
||||
{
|
||||
__asm volatile ("cpsie i");
|
||||
}
|
||||
|
||||
static inline U32 __disable_irq(void)
|
||||
{
|
||||
U32 result;
|
||||
|
||||
__asm volatile ("mrs %0, primask" : "=r" (result));
|
||||
__asm volatile ("cpsid i");
|
||||
return(result & 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline U8 __clz(U32 value)
|
||||
{
|
||||
U8 result;
|
||||
|
||||
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
|
||||
return(result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* NVIC registers */
|
||||
#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010U))
|
||||
#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014U))
|
||||
#define NVIC_ST_CURRENT (*((volatile U32 *)0xE000E018U))
|
||||
#define NVIC_ISER ((volatile U32 *)0xE000E100U)
|
||||
#define NVIC_ICER ((volatile U32 *)0xE000E180U)
|
||||
#if defined(__TARGET_ARCH_6S_M)
|
||||
#define NVIC_IP ((volatile U32 *)0xE000E400U)
|
||||
#else
|
||||
#define NVIC_IP ((volatile U8 *)0xE000E400U)
|
||||
#endif
|
||||
#define NVIC_INT_CTRL (*((volatile U32 *)0xE000ED04U))
|
||||
#define NVIC_AIR_CTRL (*((volatile U32 *)0xE000ED0CU))
|
||||
#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1CU))
|
||||
#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20U))
|
||||
|
||||
#define OS_PEND_IRQ() NVIC_INT_CTRL = (1UL<<28)
|
||||
#define OS_PENDING ((NVIC_INT_CTRL >> 26) & 5U)
|
||||
#define OS_UNPEND(fl) NVIC_INT_CTRL = (U32)(fl = (U8)OS_PENDING) << 25
|
||||
#define OS_PEND(fl,p) NVIC_INT_CTRL = (U32)(fl | (U8)(p<<2)) << 26
|
||||
#define OS_LOCK() NVIC_ST_CTRL = 0x0005U
|
||||
#define OS_UNLOCK() NVIC_ST_CTRL = 0x0007U
|
||||
|
||||
#define OS_X_PENDING ((NVIC_INT_CTRL >> 28) & 1U)
|
||||
#define OS_X_UNPEND(fl) NVIC_INT_CTRL = (U32)(fl = (U8)OS_X_PENDING) << 27
|
||||
#define OS_X_PEND(fl,p) NVIC_INT_CTRL = (U32)(fl | p) << 28
|
||||
#if defined(__TARGET_ARCH_6S_M)
|
||||
#define OS_X_INIT(n) NVIC_IP[n>>2] |= (U32)0xFFU << ((n & 0x03U) << 3); \
|
||||
NVIC_ISER[n>>5] = (U32)1U << (n & 0x1FU)
|
||||
#else
|
||||
#define OS_X_INIT(n) NVIC_IP[n] = 0xFFU; \
|
||||
NVIC_ISER[n>>5] = (U32)1U << (n & 0x1FU)
|
||||
#endif
|
||||
#define OS_X_LOCK(n) NVIC_ICER[n>>5] = (U32)1U << (n & 0x1FU)
|
||||
#define OS_X_UNLOCK(n) NVIC_ISER[n>>5] = (U32)1U << (n & 0x1FU)
|
||||
|
||||
/* Core Debug registers */
|
||||
#define DEMCR (*((volatile U32 *)0xE000EDFCU))
|
||||
|
||||
/* ITM registers */
|
||||
#define ITM_CONTROL (*((volatile U32 *)0xE0000E80U))
|
||||
#define ITM_ENABLE (*((volatile U32 *)0xE0000E00U))
|
||||
#define ITM_PORT30_U32 (*((volatile U32 *)0xE0000078U))
|
||||
#define ITM_PORT31_U32 (*((volatile U32 *)0xE000007CU))
|
||||
#define ITM_PORT31_U16 (*((volatile U16 *)0xE000007CU))
|
||||
#define ITM_PORT31_U8 (*((volatile U8 *)0xE000007CU))
|
||||
|
||||
/* Variables */
|
||||
extern BIT dbg_msg;
|
||||
|
||||
/* Functions */
|
||||
#ifdef __USE_EXCLUSIVE_ACCESS
|
||||
#define rt_inc(p) while(__strex((__ldrex(p)+1U),p))
|
||||
#define rt_dec(p) while(__strex((__ldrex(p)-1U),p))
|
||||
#else
|
||||
#define rt_inc(p) __disable_irq();(*p)++;__enable_irq();
|
||||
#define rt_dec(p) __disable_irq();(*p)--;__enable_irq();
|
||||
#endif
|
||||
|
||||
__inline static U32 rt_inc_qi (U32 size, U8 *count, U8 *first) {
|
||||
U32 cnt,c2;
|
||||
#ifdef __USE_EXCLUSIVE_ACCESS
|
||||
do {
|
||||
if ((cnt = __ldrex(count)) == size) {
|
||||
__clrex();
|
||||
return (cnt); }
|
||||
} while (__strex(cnt+1U, count));
|
||||
do {
|
||||
c2 = (cnt = __ldrex(first)) + 1U;
|
||||
if (c2 == size) { c2 = 0U; }
|
||||
} while (__strex(c2, first));
|
||||
#else
|
||||
__disable_irq();
|
||||
if ((cnt = *count) < size) {
|
||||
*count = (U8)(cnt+1U);
|
||||
c2 = (cnt = *first) + 1U;
|
||||
if (c2 == size) { c2 = 0U; }
|
||||
*first = (U8)c2;
|
||||
}
|
||||
__enable_irq ();
|
||||
#endif
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
__inline static void rt_systick_init (void) {
|
||||
NVIC_ST_RELOAD = os_trv;
|
||||
NVIC_ST_CURRENT = 0U;
|
||||
NVIC_ST_CTRL = 0x0007U;
|
||||
NVIC_SYS_PRI3 |= 0xFF000000U;
|
||||
}
|
||||
|
||||
__inline static U32 rt_systick_val (void) {
|
||||
return (os_trv - NVIC_ST_CURRENT);
|
||||
}
|
||||
|
||||
__inline static U32 rt_systick_ovf (void) {
|
||||
return ((NVIC_INT_CTRL >> 26) & 1U);
|
||||
}
|
||||
|
||||
__inline static void rt_svc_init (void) {
|
||||
#if !defined(__TARGET_ARCH_6S_M)
|
||||
U32 sh,prigroup;
|
||||
#endif
|
||||
NVIC_SYS_PRI3 |= 0x00FF0000U;
|
||||
#if defined(__TARGET_ARCH_6S_M)
|
||||
NVIC_SYS_PRI2 |= (NVIC_SYS_PRI3<<(8+1)) & 0xFC000000U;
|
||||
#else
|
||||
sh = 8U - __clz(~((NVIC_SYS_PRI3 << 8) & 0xFF000000U));
|
||||
prigroup = ((NVIC_AIR_CTRL >> 8) & 0x07U);
|
||||
if (prigroup >= sh) {
|
||||
sh = prigroup + 1U;
|
||||
}
|
||||
NVIC_SYS_PRI2 = ((0xFEFFFFFFU << sh) & 0xFF000000U) | (NVIC_SYS_PRI2 & 0x00FFFFFFU);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void rt_set_PSP (U32 stack);
|
||||
extern U32 rt_get_PSP (void);
|
||||
extern void os_set_env (void);
|
||||
extern void *_alloc_box (void *box_mem);
|
||||
extern U32 _free_box (void *box_mem, void *box);
|
||||
|
||||
extern void rt_init_stack (P_TCB p_TCB, FUNCP task_body);
|
||||
extern void rt_ret_val (P_TCB p_TCB, U32 v0);
|
||||
extern void rt_ret_val2 (P_TCB p_TCB, U32 v0, U32 v1);
|
||||
|
||||
extern void dbg_init (void);
|
||||
extern void dbg_task_notify (P_TCB p_tcb, BOOL create);
|
||||
extern void dbg_task_switch (U32 task_id);
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_INIT() dbg_init()
|
||||
#define DBG_TASK_NOTIFY(p_tcb,create) if (dbg_msg) dbg_task_notify(p_tcb,create)
|
||||
#define DBG_TASK_SWITCH(task_id) if (dbg_msg && (os_tsk.next!=os_tsk.run)) \
|
||||
dbg_task_switch(task_id)
|
||||
#else
|
||||
#define DBG_INIT()
|
||||
#define DBG_TASK_NOTIFY(p_tcb,create)
|
||||
#define DBG_TASK_SWITCH(task_id)
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
309
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_List.c
vendored
Normal file
309
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_List.c
vendored
Normal file
@ -0,0 +1,309 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_LIST.C
|
||||
* Purpose: Functions for the management of different lists
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_Time.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* List head of chained ready tasks */
|
||||
struct OS_XCB os_rdy;
|
||||
/* List head of chained delay tasks */
|
||||
struct OS_XCB os_dly;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_put_prio -----------------------------------*/
|
||||
|
||||
void rt_put_prio (P_XCB p_CB, P_TCB p_task) {
|
||||
/* Put task identified with "p_task" into list ordered by priority. */
|
||||
/* "p_CB" points to head of list; list has always an element at end with */
|
||||
/* a priority less than "p_task->prio". */
|
||||
P_TCB p_CB2;
|
||||
U32 prio;
|
||||
BOOL sem_mbx = __FALSE;
|
||||
|
||||
if ((p_CB->cb_type == SCB) || (p_CB->cb_type == MCB) || (p_CB->cb_type == MUCB)) {
|
||||
sem_mbx = __TRUE;
|
||||
}
|
||||
prio = p_task->prio;
|
||||
p_CB2 = p_CB->p_lnk;
|
||||
/* Search for an entry in the list */
|
||||
while ((p_CB2 != NULL) && (prio <= p_CB2->prio)) {
|
||||
p_CB = (P_XCB)p_CB2;
|
||||
p_CB2 = p_CB2->p_lnk;
|
||||
}
|
||||
/* Entry found, insert the task into the list */
|
||||
p_task->p_lnk = p_CB2;
|
||||
p_CB->p_lnk = p_task;
|
||||
if (sem_mbx) {
|
||||
if (p_CB2 != NULL) {
|
||||
p_CB2->p_rlnk = p_task;
|
||||
}
|
||||
p_task->p_rlnk = (P_TCB)p_CB;
|
||||
}
|
||||
else {
|
||||
p_task->p_rlnk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_get_first ----------------------------------*/
|
||||
|
||||
P_TCB rt_get_first (P_XCB p_CB) {
|
||||
/* Get task at head of list: it is the task with highest priority. */
|
||||
/* "p_CB" points to head of list. */
|
||||
P_TCB p_first;
|
||||
|
||||
p_first = p_CB->p_lnk;
|
||||
p_CB->p_lnk = p_first->p_lnk;
|
||||
if ((p_CB->cb_type == SCB) || (p_CB->cb_type == MCB) || (p_CB->cb_type == MUCB)) {
|
||||
if (p_first->p_lnk != NULL) {
|
||||
p_first->p_lnk->p_rlnk = (P_TCB)p_CB;
|
||||
p_first->p_lnk = NULL;
|
||||
}
|
||||
p_first->p_rlnk = NULL;
|
||||
}
|
||||
else {
|
||||
p_first->p_lnk = NULL;
|
||||
}
|
||||
return (p_first);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_put_rdy_first ------------------------------*/
|
||||
|
||||
void rt_put_rdy_first (P_TCB p_task) {
|
||||
/* Put task identified with "p_task" at the head of the ready list. The */
|
||||
/* task must have at least a priority equal to highest priority in list. */
|
||||
p_task->p_lnk = os_rdy.p_lnk;
|
||||
p_task->p_rlnk = NULL;
|
||||
os_rdy.p_lnk = p_task;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_get_same_rdy_prio --------------------------*/
|
||||
|
||||
P_TCB rt_get_same_rdy_prio (void) {
|
||||
/* Remove a task of same priority from ready list if any exists. Other- */
|
||||
/* wise return NULL. */
|
||||
P_TCB p_first;
|
||||
|
||||
p_first = os_rdy.p_lnk;
|
||||
if (p_first->prio == os_tsk.run->prio) {
|
||||
os_rdy.p_lnk = os_rdy.p_lnk->p_lnk;
|
||||
return (p_first);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_resort_prio --------------------------------*/
|
||||
|
||||
void rt_resort_prio (P_TCB p_task) {
|
||||
/* Re-sort ordered lists after the priority of 'p_task' has changed. */
|
||||
P_TCB p_CB;
|
||||
|
||||
if (p_task->p_rlnk == NULL) {
|
||||
if (p_task->state == READY) {
|
||||
/* Task is chained into READY list. */
|
||||
p_CB = (P_TCB)&os_rdy;
|
||||
goto res;
|
||||
}
|
||||
}
|
||||
else {
|
||||
p_CB = p_task->p_rlnk;
|
||||
while (p_CB->cb_type == TCB) {
|
||||
/* Find a header of this task chain list. */
|
||||
p_CB = p_CB->p_rlnk;
|
||||
}
|
||||
res:rt_rmv_list (p_task);
|
||||
rt_put_prio ((P_XCB)p_CB, p_task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_put_dly ------------------------------------*/
|
||||
|
||||
void rt_put_dly (P_TCB p_task, U16 delay) {
|
||||
/* Put a task identified with "p_task" into chained delay wait list using */
|
||||
/* a delay value of "delay". */
|
||||
P_TCB p;
|
||||
U32 delta,idelay = delay;
|
||||
|
||||
p = (P_TCB)&os_dly;
|
||||
if (p->p_dlnk == NULL) {
|
||||
/* Delay list empty */
|
||||
delta = 0U;
|
||||
goto last;
|
||||
}
|
||||
delta = os_dly.delta_time;
|
||||
while (delta < idelay) {
|
||||
if (p->p_dlnk == NULL) {
|
||||
/* End of list found */
|
||||
last: p_task->p_dlnk = NULL;
|
||||
p->p_dlnk = p_task;
|
||||
p_task->p_blnk = p;
|
||||
p->delta_time = (U16)(idelay - delta);
|
||||
p_task->delta_time = 0U;
|
||||
return;
|
||||
}
|
||||
p = p->p_dlnk;
|
||||
delta += p->delta_time;
|
||||
}
|
||||
/* Right place found */
|
||||
p_task->p_dlnk = p->p_dlnk;
|
||||
p->p_dlnk = p_task;
|
||||
p_task->p_blnk = p;
|
||||
if (p_task->p_dlnk != NULL) {
|
||||
p_task->p_dlnk->p_blnk = p_task;
|
||||
}
|
||||
p_task->delta_time = (U16)(delta - idelay);
|
||||
p->delta_time -= p_task->delta_time;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_dec_dly ------------------------------------*/
|
||||
|
||||
void rt_dec_dly (void) {
|
||||
/* Decrement delta time of list head: remove tasks having a value of zero.*/
|
||||
P_TCB p_rdy;
|
||||
|
||||
if (os_dly.p_dlnk == NULL) {
|
||||
return;
|
||||
}
|
||||
os_dly.delta_time--;
|
||||
while ((os_dly.delta_time == 0U) && (os_dly.p_dlnk != NULL)) {
|
||||
p_rdy = os_dly.p_dlnk;
|
||||
if (p_rdy->p_rlnk != NULL) {
|
||||
/* Task is really enqueued, remove task from semaphore/mailbox */
|
||||
/* timeout waiting list. */
|
||||
p_rdy->p_rlnk->p_lnk = p_rdy->p_lnk;
|
||||
if (p_rdy->p_lnk != NULL) {
|
||||
p_rdy->p_lnk->p_rlnk = p_rdy->p_rlnk;
|
||||
p_rdy->p_lnk = NULL;
|
||||
}
|
||||
p_rdy->p_rlnk = NULL;
|
||||
}
|
||||
rt_put_prio (&os_rdy, p_rdy);
|
||||
os_dly.delta_time = p_rdy->delta_time;
|
||||
if (p_rdy->state == WAIT_ITV) {
|
||||
/* Calculate the next time for interval wait. */
|
||||
p_rdy->delta_time = p_rdy->interval_time + (U16)os_time;
|
||||
}
|
||||
p_rdy->state = READY;
|
||||
os_dly.p_dlnk = p_rdy->p_dlnk;
|
||||
if (p_rdy->p_dlnk != NULL) {
|
||||
p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly;
|
||||
p_rdy->p_dlnk = NULL;
|
||||
}
|
||||
p_rdy->p_blnk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_rmv_list -----------------------------------*/
|
||||
|
||||
void rt_rmv_list (P_TCB p_task) {
|
||||
/* Remove task identified with "p_task" from ready, semaphore or mailbox */
|
||||
/* waiting list if enqueued. */
|
||||
P_TCB p_b;
|
||||
|
||||
if (p_task->p_rlnk != NULL) {
|
||||
/* A task is enqueued in semaphore / mailbox waiting list. */
|
||||
p_task->p_rlnk->p_lnk = p_task->p_lnk;
|
||||
if (p_task->p_lnk != NULL) {
|
||||
p_task->p_lnk->p_rlnk = p_task->p_rlnk;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
p_b = (P_TCB)&os_rdy;
|
||||
while (p_b != NULL) {
|
||||
/* Search the ready list for task "p_task" */
|
||||
if (p_b->p_lnk == p_task) {
|
||||
p_b->p_lnk = p_task->p_lnk;
|
||||
return;
|
||||
}
|
||||
p_b = p_b->p_lnk;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_rmv_dly ------------------------------------*/
|
||||
|
||||
void rt_rmv_dly (P_TCB p_task) {
|
||||
/* Remove task identified with "p_task" from delay list if enqueued. */
|
||||
P_TCB p_b;
|
||||
|
||||
p_b = p_task->p_blnk;
|
||||
if (p_b != NULL) {
|
||||
/* Task is really enqueued */
|
||||
p_b->p_dlnk = p_task->p_dlnk;
|
||||
if (p_task->p_dlnk != NULL) {
|
||||
/* 'p_task' is in the middle of list */
|
||||
p_b->delta_time += p_task->delta_time;
|
||||
p_task->p_dlnk->p_blnk = p_b;
|
||||
p_task->p_dlnk = NULL;
|
||||
}
|
||||
else {
|
||||
/* 'p_task' is at the end of list */
|
||||
p_b->delta_time = 0U;
|
||||
}
|
||||
p_task->p_blnk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_psq_enq ------------------------------------*/
|
||||
|
||||
void rt_psq_enq (OS_ID entry, U32 arg) {
|
||||
/* Insert post service request "entry" into ps-queue. */
|
||||
U32 idx;
|
||||
|
||||
idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first);
|
||||
if (idx < os_psq->size) {
|
||||
os_psq->q[idx].id = entry;
|
||||
os_psq->q[idx].arg = arg;
|
||||
}
|
||||
else {
|
||||
os_error (OS_ERR_FIFO_OVF);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
56
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_List.h
vendored
Normal file
56
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_List.h
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_LIST.H
|
||||
* Purpose: Functions for the management of different lists
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Definitions */
|
||||
|
||||
/* Values for 'cb_type' */
|
||||
#define TCB 0U
|
||||
#define MCB 1U
|
||||
#define SCB 2U
|
||||
#define MUCB 3U
|
||||
#define HCB 4U
|
||||
|
||||
/* Variables */
|
||||
extern struct OS_XCB os_rdy;
|
||||
extern struct OS_XCB os_dly;
|
||||
|
||||
/* Functions */
|
||||
extern void rt_put_prio (P_XCB p_CB, P_TCB p_task);
|
||||
extern P_TCB rt_get_first (P_XCB p_CB);
|
||||
extern void rt_put_rdy_first (P_TCB p_task);
|
||||
extern P_TCB rt_get_same_rdy_prio (void);
|
||||
extern void rt_resort_prio (P_TCB p_task);
|
||||
extern void rt_put_dly (P_TCB p_task, U16 delay);
|
||||
extern void rt_dec_dly (void);
|
||||
extern void rt_rmv_list (P_TCB p_task);
|
||||
extern void rt_rmv_dly (P_TCB p_task);
|
||||
extern void rt_psq_enq (OS_ID entry, U32 arg);
|
||||
|
||||
/* This is a fast macro generating in-line code */
|
||||
#define rt_rdy_prio(void) (os_rdy.p_lnk->prio)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
284
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mailbox.c
vendored
Normal file
284
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mailbox.c
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MAILBOX.C
|
||||
* Purpose: Implements waits and wake-ups for mailbox messages
|
||||
* Rev.: V4.81
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Mailbox.h"
|
||||
#include "rt_MemBox.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_mbx_init -----------------------------------*/
|
||||
|
||||
void rt_mbx_init (OS_ID mailbox, U16 mbx_size) {
|
||||
/* Initialize a mailbox */
|
||||
P_MCB p_MCB = mailbox;
|
||||
|
||||
p_MCB->cb_type = MCB;
|
||||
p_MCB->state = 0U;
|
||||
p_MCB->isr_st = 0U;
|
||||
p_MCB->p_lnk = NULL;
|
||||
p_MCB->first = 0U;
|
||||
p_MCB->last = 0U;
|
||||
p_MCB->count = 0U;
|
||||
p_MCB->size = (U16)((mbx_size - (sizeof(struct OS_MCB) - (sizeof(void *))))
|
||||
/ sizeof(void *));
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mbx_send -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) {
|
||||
/* Send message to a mailbox */
|
||||
P_MCB p_MCB = mailbox;
|
||||
P_TCB p_TCB;
|
||||
|
||||
if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 1U)) {
|
||||
/* A task is waiting for message */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val2(p_TCB, 0x10U/*osEventMessage*/, (U32)p_msg);
|
||||
#else
|
||||
*p_TCB->msg = p_msg;
|
||||
rt_ret_val (p_TCB, OS_R_MBX);
|
||||
#endif
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_dispatch (p_TCB);
|
||||
}
|
||||
else {
|
||||
/* Store message in mailbox queue */
|
||||
if (p_MCB->count == p_MCB->size) {
|
||||
/* No free message entry, wait for one. If message queue is full, */
|
||||
/* then no task is waiting for message. The 'p_MCB->p_lnk' list */
|
||||
/* pointer can now be reused for send message waits task list. */
|
||||
if (timeout == 0U) {
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
if (p_MCB->p_lnk != NULL) {
|
||||
rt_put_prio ((P_XCB)p_MCB, os_tsk.run);
|
||||
}
|
||||
else {
|
||||
p_MCB->p_lnk = os_tsk.run;
|
||||
os_tsk.run->p_lnk = NULL;
|
||||
os_tsk.run->p_rlnk = (P_TCB)p_MCB;
|
||||
/* Task is waiting to send a message */
|
||||
p_MCB->state = 2U;
|
||||
}
|
||||
os_tsk.run->msg = p_msg;
|
||||
rt_block (timeout, WAIT_MBX);
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
/* Yes, there is a free entry in a mailbox. */
|
||||
p_MCB->msg[p_MCB->first] = p_msg;
|
||||
rt_inc (&p_MCB->count);
|
||||
if (++p_MCB->first == p_MCB->size) {
|
||||
p_MCB->first = 0U;
|
||||
}
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mbx_wait -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) {
|
||||
/* Receive a message; possibly wait for it */
|
||||
P_MCB p_MCB = mailbox;
|
||||
P_TCB p_TCB;
|
||||
|
||||
/* If a message is available in the fifo buffer */
|
||||
/* remove it from the fifo buffer and return. */
|
||||
if (p_MCB->count) {
|
||||
*message = p_MCB->msg[p_MCB->last];
|
||||
if (++p_MCB->last == p_MCB->size) {
|
||||
p_MCB->last = 0U;
|
||||
}
|
||||
if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2U)) {
|
||||
/* A task is waiting to send message */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val(p_TCB, 0U/*osOK*/);
|
||||
#else
|
||||
rt_ret_val(p_TCB, OS_R_OK);
|
||||
#endif
|
||||
p_MCB->msg[p_MCB->first] = p_TCB->msg;
|
||||
if (++p_MCB->first == p_MCB->size) {
|
||||
p_MCB->first = 0U;
|
||||
}
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_dispatch (p_TCB);
|
||||
}
|
||||
else {
|
||||
rt_dec (&p_MCB->count);
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
/* No message available: wait for one */
|
||||
if (timeout == 0U) {
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
if (p_MCB->p_lnk != NULL) {
|
||||
rt_put_prio ((P_XCB)p_MCB, os_tsk.run);
|
||||
}
|
||||
else {
|
||||
p_MCB->p_lnk = os_tsk.run;
|
||||
os_tsk.run->p_lnk = NULL;
|
||||
os_tsk.run->p_rlnk = (P_TCB)p_MCB;
|
||||
/* Task is waiting to receive a message */
|
||||
p_MCB->state = 1U;
|
||||
}
|
||||
rt_block(timeout, WAIT_MBX);
|
||||
#ifndef __CMSIS_RTOS
|
||||
os_tsk.run->msg = message;
|
||||
#endif
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mbx_check ----------------------------------*/
|
||||
|
||||
OS_RESULT rt_mbx_check (OS_ID mailbox) {
|
||||
/* Check for free space in a mailbox. Returns the number of messages */
|
||||
/* that can be stored to a mailbox. It returns 0 when mailbox is full. */
|
||||
P_MCB p_MCB = mailbox;
|
||||
|
||||
return ((U32)(p_MCB->size - p_MCB->count));
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- isr_mbx_send ----------------------------------*/
|
||||
|
||||
void isr_mbx_send (OS_ID mailbox, void *p_msg) {
|
||||
/* Same function as "os_mbx_send", but to be called by ISRs. */
|
||||
P_MCB p_MCB = mailbox;
|
||||
|
||||
rt_psq_enq (p_MCB, (U32)p_msg);
|
||||
rt_psh_req ();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- isr_mbx_receive -------------------------------*/
|
||||
|
||||
OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) {
|
||||
/* Receive a message in the interrupt function. The interrupt function */
|
||||
/* should not wait for a message since this would block the rtx os. */
|
||||
P_MCB p_MCB = mailbox;
|
||||
|
||||
if (p_MCB->count) {
|
||||
/* A message is available in the fifo buffer. */
|
||||
*message = p_MCB->msg[p_MCB->last];
|
||||
if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2U)) {
|
||||
/* A task is locked waiting to send message */
|
||||
rt_psq_enq (p_MCB, 0U);
|
||||
rt_psh_req ();
|
||||
}
|
||||
rt_dec (&p_MCB->count);
|
||||
if (++p_MCB->last == p_MCB->size) {
|
||||
p_MCB->last = 0U;
|
||||
}
|
||||
return (OS_R_MBX);
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mbx_psh ------------------------------------*/
|
||||
|
||||
void rt_mbx_psh (P_MCB p_CB, void *p_msg) {
|
||||
/* Store the message to the mailbox queue or pass it to task directly. */
|
||||
P_TCB p_TCB;
|
||||
void *mem;
|
||||
|
||||
if (p_CB->p_lnk != NULL) switch (p_CB->state) {
|
||||
#ifdef __CMSIS_RTOS
|
||||
case 3:
|
||||
/* Task is waiting to allocate memory, remove it from the waiting list */
|
||||
mem = rt_alloc_box(p_msg);
|
||||
if (mem == NULL) { break; }
|
||||
p_TCB = rt_get_first ((P_XCB)p_CB);
|
||||
rt_ret_val(p_TCB, (U32)mem);
|
||||
p_TCB->state = READY;
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
break;
|
||||
#endif
|
||||
case 2:
|
||||
/* Task is waiting to send a message, remove it from the waiting list */
|
||||
p_TCB = rt_get_first ((P_XCB)p_CB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val(p_TCB, 0U/*osOK*/);
|
||||
#else
|
||||
rt_ret_val(p_TCB, OS_R_OK);
|
||||
#endif
|
||||
p_CB->msg[p_CB->first] = p_TCB->msg;
|
||||
rt_inc (&p_CB->count);
|
||||
if (++p_CB->first == p_CB->size) {
|
||||
p_CB->first = 0U;
|
||||
}
|
||||
p_TCB->state = READY;
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
break;
|
||||
case 1:
|
||||
/* Task is waiting for a message, pass the message to the task directly */
|
||||
p_TCB = rt_get_first ((P_XCB)p_CB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val2(p_TCB, 0x10U/*osEventMessage*/, (U32)p_msg);
|
||||
#else
|
||||
*p_TCB->msg = p_msg;
|
||||
rt_ret_val (p_TCB, OS_R_MBX);
|
||||
#endif
|
||||
p_TCB->state = READY;
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} else {
|
||||
/* No task is waiting for a message, store it to the mailbox queue */
|
||||
if (p_CB->count < p_CB->size) {
|
||||
p_CB->msg[p_CB->first] = p_msg;
|
||||
rt_inc (&p_CB->count);
|
||||
if (++p_CB->first == p_CB->size) {
|
||||
p_CB->first = 0U;
|
||||
}
|
||||
}
|
||||
else {
|
||||
os_error (OS_ERR_MBX_OVF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
37
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mailbox.h
vendored
Normal file
37
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mailbox.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MAILBOX.H
|
||||
* Purpose: Implements waits and wake-ups for mailbox messages
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Functions */
|
||||
extern void rt_mbx_init (OS_ID mailbox, U16 mbx_size);
|
||||
extern OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout);
|
||||
extern OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout);
|
||||
extern OS_RESULT rt_mbx_check (OS_ID mailbox);
|
||||
extern void isr_mbx_send (OS_ID mailbox, void *p_msg);
|
||||
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);
|
||||
extern void rt_mbx_psh (P_MCB p_CB, void *p_msg);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
159
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_MemBox.c
vendored
Normal file
159
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_MemBox.c
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MEMBOX.C
|
||||
* Purpose: Interface functions for fixed memory block management system
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_MemBox.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- _init_box -------------------------------------*/
|
||||
|
||||
U32 _init_box (void *box_mem, U32 box_size, U32 blk_size) {
|
||||
/* Initialize memory block system, returns 0 if OK, 1 if fails. */
|
||||
void *end;
|
||||
void *blk;
|
||||
void *next;
|
||||
U32 sizeof_bm;
|
||||
|
||||
/* Create memory structure. */
|
||||
if (blk_size & BOX_ALIGN_8) {
|
||||
/* Memory blocks 8-byte aligned. */
|
||||
blk_size = ((blk_size & ~BOX_ALIGN_8) + 7U) & ~(U32)7U;
|
||||
sizeof_bm = (sizeof (struct OS_BM) + 7U) & ~(U32)7U;
|
||||
}
|
||||
else {
|
||||
/* Memory blocks 4-byte aligned. */
|
||||
blk_size = (blk_size + 3U) & ~(U32)3U;
|
||||
sizeof_bm = sizeof (struct OS_BM);
|
||||
}
|
||||
if (blk_size == 0U) {
|
||||
return (1U);
|
||||
}
|
||||
if ((blk_size + sizeof_bm) > box_size) {
|
||||
return (1U);
|
||||
}
|
||||
/* Create a Memory structure. */
|
||||
blk = ((U8 *) box_mem) + sizeof_bm;
|
||||
((P_BM) box_mem)->free = blk;
|
||||
end = ((U8 *) box_mem) + box_size;
|
||||
((P_BM) box_mem)->end = end;
|
||||
((P_BM) box_mem)->blk_size = blk_size;
|
||||
|
||||
/* Link all free blocks using offsets. */
|
||||
end = ((U8 *) end) - blk_size;
|
||||
while (1) {
|
||||
next = ((U8 *) blk) + blk_size;
|
||||
if (next > end) { break; }
|
||||
*((void **)blk) = next;
|
||||
blk = next;
|
||||
}
|
||||
/* end marker */
|
||||
*((void **)blk) = 0U;
|
||||
return (0U);
|
||||
}
|
||||
|
||||
/*--------------------------- rt_alloc_box ----------------------------------*/
|
||||
|
||||
void *rt_alloc_box (void *box_mem) {
|
||||
/* Allocate a memory block and return start address. */
|
||||
void **free;
|
||||
#ifndef __USE_EXCLUSIVE_ACCESS
|
||||
U32 irq_mask;
|
||||
|
||||
irq_mask = (U32)__disable_irq ();
|
||||
free = ((P_BM) box_mem)->free;
|
||||
if (free) {
|
||||
((P_BM) box_mem)->free = *free;
|
||||
}
|
||||
if (irq_mask == 0U) { __enable_irq (); }
|
||||
#else
|
||||
do {
|
||||
if ((free = (void **)__ldrex(&((P_BM) box_mem)->free)) == 0U) {
|
||||
__clrex();
|
||||
break;
|
||||
}
|
||||
} while (__strex((U32)*free, &((P_BM) box_mem)->free));
|
||||
#endif
|
||||
return (free);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _calloc_box -----------------------------------*/
|
||||
|
||||
void *_calloc_box (void *box_mem) {
|
||||
/* Allocate a 0-initialized memory block and return start address. */
|
||||
void *free;
|
||||
U32 *p;
|
||||
U32 i;
|
||||
|
||||
free = _alloc_box (box_mem);
|
||||
if (free) {
|
||||
p = free;
|
||||
for (i = ((P_BM) box_mem)->blk_size; i; i -= 4U) {
|
||||
*p = 0U;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
return (free);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_free_box -----------------------------------*/
|
||||
|
||||
U32 rt_free_box (void *box_mem, void *box) {
|
||||
/* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */
|
||||
#ifndef __USE_EXCLUSIVE_ACCESS
|
||||
U32 irq_mask;
|
||||
#endif
|
||||
|
||||
if ((box < box_mem) || (box >= ((P_BM) box_mem)->end)) {
|
||||
return (1U);
|
||||
}
|
||||
|
||||
#ifndef __USE_EXCLUSIVE_ACCESS
|
||||
irq_mask = (U32)__disable_irq ();
|
||||
*((void **)box) = ((P_BM) box_mem)->free;
|
||||
((P_BM) box_mem)->free = box;
|
||||
if (irq_mask == 0U) { __enable_irq (); }
|
||||
#else
|
||||
do {
|
||||
do {
|
||||
*((void **)box) = ((P_BM) box_mem)->free;
|
||||
__DMB();
|
||||
} while (*(void**)box != (void *)__ldrex(&((P_BM) box_mem)->free));
|
||||
} while (__strex ((U32)box, &((P_BM) box_mem)->free));
|
||||
#endif
|
||||
return (0U);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_MemBox.h
vendored
Normal file
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_MemBox.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MEMBOX.H
|
||||
* Purpose: Interface functions for fixed memory block management system
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Functions */
|
||||
#define rt_init_box _init_box
|
||||
#define rt_calloc_box _calloc_box
|
||||
extern U32 _init_box (void *box_mem, U32 box_size, U32 blk_size);
|
||||
extern void *rt_alloc_box (void *box_mem);
|
||||
extern void * _calloc_box (void *box_mem);
|
||||
extern U32 rt_free_box (void *box_mem, void *box);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
131
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Memory.c
vendored
Normal file
131
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Memory.c
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MEMORY.C
|
||||
* Purpose: Interface functions for Dynamic Memory Management System
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "rt_Memory.h"
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
// Initialize Dynamic Memory pool
|
||||
// Parameters:
|
||||
// pool: Pointer to memory pool
|
||||
// size: Size of memory pool in bytes
|
||||
// Return: 0 - OK, 1 - Error
|
||||
|
||||
U32 rt_init_mem (void *pool, U32 size) {
|
||||
MEMP *ptr;
|
||||
|
||||
if ((pool == NULL) || (size < sizeof(MEMP))) { return (1U); }
|
||||
|
||||
ptr = (MEMP *)pool;
|
||||
ptr->next = (MEMP *)((U32)pool + size - sizeof(MEMP *));
|
||||
ptr->next->next = NULL;
|
||||
ptr->len = 0U;
|
||||
|
||||
return (0U);
|
||||
}
|
||||
|
||||
// Allocate Memory from Memory pool
|
||||
// Parameters:
|
||||
// pool: Pointer to memory pool
|
||||
// size: Size of memory in bytes to allocate
|
||||
// Return: Pointer to allocated memory
|
||||
|
||||
void *rt_alloc_mem (void *pool, U32 size) {
|
||||
MEMP *p, *p_search, *p_new;
|
||||
U32 hole_size;
|
||||
|
||||
if ((pool == NULL) || (size == 0U)) { return NULL; }
|
||||
|
||||
/* Add header offset to 'size' */
|
||||
size += sizeof(MEMP);
|
||||
/* Make sure that block is 4-byte aligned */
|
||||
size = (size + 3U) & ~(U32)3U;
|
||||
|
||||
p_search = (MEMP *)pool;
|
||||
while (1) {
|
||||
hole_size = (U32)p_search->next - (U32)p_search;
|
||||
hole_size -= p_search->len;
|
||||
/* Check if hole size is big enough */
|
||||
if (hole_size >= size) { break; }
|
||||
p_search = p_search->next;
|
||||
if (p_search->next == NULL) {
|
||||
/* Failed, we are at the end of the list */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_search->len == 0U) {
|
||||
/* No block is allocated, set the Length of the first element */
|
||||
p_search->len = size;
|
||||
p = (MEMP *)(((U32)p_search) + sizeof(MEMP));
|
||||
} else {
|
||||
/* Insert new list element into the memory list */
|
||||
p_new = (MEMP *)((U32)p_search + p_search->len);
|
||||
p_new->next = p_search->next;
|
||||
p_new->len = size;
|
||||
p_search->next = p_new;
|
||||
p = (MEMP *)(((U32)p_new) + sizeof(MEMP));
|
||||
}
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
// Free Memory and return it to Memory pool
|
||||
// Parameters:
|
||||
// pool: Pointer to memory pool
|
||||
// mem: Pointer to memory to free
|
||||
// Return: 0 - OK, 1 - Error
|
||||
|
||||
U32 rt_free_mem (void *pool, void *mem) {
|
||||
MEMP *p_search, *p_prev, *p_return;
|
||||
|
||||
if ((pool == NULL) || (mem == NULL)) { return (1U); }
|
||||
|
||||
p_return = (MEMP *)((U32)mem - sizeof(MEMP));
|
||||
|
||||
/* Set list header */
|
||||
p_prev = NULL;
|
||||
p_search = (MEMP *)pool;
|
||||
while (p_search != p_return) {
|
||||
p_prev = p_search;
|
||||
p_search = p_search->next;
|
||||
if (p_search == NULL) {
|
||||
/* Valid Memory block not found */
|
||||
return (1U);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_prev == NULL) {
|
||||
/* First block to be released, only set length to 0 */
|
||||
p_search->len = 0U;
|
||||
} else {
|
||||
/* Discard block from chain list */
|
||||
p_prev->next = p_search->next;
|
||||
}
|
||||
|
||||
return (0U);
|
||||
}
|
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Memory.h
vendored
Normal file
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Memory.h
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MEMORY.H
|
||||
* Purpose: Interface functions for Dynamic Memory Management System
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Types */
|
||||
typedef struct mem { /* << Memory Pool management struct >> */
|
||||
struct mem *next; /* Next Memory Block in the list */
|
||||
U32 len; /* Length of data block */
|
||||
} MEMP;
|
||||
|
||||
/* Functions */
|
||||
extern U32 rt_init_mem (void *pool, U32 size);
|
||||
extern void *rt_alloc_mem (void *pool, U32 size);
|
||||
extern U32 rt_free_mem (void *pool, void *mem);
|
252
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mutex.c
vendored
Normal file
252
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mutex.c
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MUTEX.C
|
||||
* Purpose: Implements mutex synchronization objects
|
||||
* Rev.: V4.82
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_Mutex.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_mut_init -----------------------------------*/
|
||||
|
||||
void rt_mut_init (OS_ID mutex) {
|
||||
/* Initialize a mutex object */
|
||||
P_MUCB p_MCB = mutex;
|
||||
|
||||
p_MCB->cb_type = MUCB;
|
||||
p_MCB->level = 0U;
|
||||
p_MCB->p_lnk = NULL;
|
||||
p_MCB->owner = NULL;
|
||||
p_MCB->p_mlnk = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mut_delete ---------------------------------*/
|
||||
|
||||
#ifdef __CMSIS_RTOS
|
||||
OS_RESULT rt_mut_delete (OS_ID mutex) {
|
||||
/* Delete a mutex object */
|
||||
P_MUCB p_MCB = mutex;
|
||||
P_TCB p_TCB;
|
||||
P_MUCB p_mlnk;
|
||||
U8 prio;
|
||||
|
||||
if (p_MCB->level != 0U) {
|
||||
|
||||
p_TCB = p_MCB->owner;
|
||||
|
||||
/* Remove mutex from task mutex owner list. */
|
||||
p_mlnk = p_TCB->p_mlnk;
|
||||
if (p_mlnk == p_MCB) {
|
||||
p_TCB->p_mlnk = p_MCB->p_mlnk;
|
||||
}
|
||||
else {
|
||||
while (p_mlnk) {
|
||||
if (p_mlnk->p_mlnk == p_MCB) {
|
||||
p_mlnk->p_mlnk = p_MCB->p_mlnk;
|
||||
break;
|
||||
}
|
||||
p_mlnk = p_mlnk->p_mlnk;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore owner task's priority. */
|
||||
prio = p_TCB->prio_base;
|
||||
p_mlnk = p_TCB->p_mlnk;
|
||||
while (p_mlnk) {
|
||||
if ((p_mlnk->p_lnk != NULL) && (p_mlnk->p_lnk->prio > prio)) {
|
||||
/* A task with higher priority is waiting for mutex. */
|
||||
prio = p_mlnk->p_lnk->prio;
|
||||
}
|
||||
p_mlnk = p_mlnk->p_mlnk;
|
||||
}
|
||||
if (p_TCB->prio != prio) {
|
||||
p_TCB->prio = prio;
|
||||
if (p_TCB != os_tsk.run) {
|
||||
rt_resort_prio (p_TCB);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (p_MCB->p_lnk != NULL) {
|
||||
/* A task is waiting for mutex. */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
rt_ret_val(p_TCB, 0U/*osOK*/);
|
||||
rt_rmv_dly(p_TCB);
|
||||
p_TCB->state = READY;
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
}
|
||||
|
||||
if ((os_rdy.p_lnk != NULL) && (os_rdy.p_lnk->prio > os_tsk.run->prio)) {
|
||||
/* preempt running task */
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
|
||||
p_MCB->cb_type = 0U;
|
||||
|
||||
return (OS_R_OK);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------- rt_mut_release --------------------------------*/
|
||||
|
||||
OS_RESULT rt_mut_release (OS_ID mutex) {
|
||||
/* Release a mutex object */
|
||||
P_MUCB p_MCB = mutex;
|
||||
P_TCB p_TCB;
|
||||
P_MUCB p_mlnk;
|
||||
U8 prio;
|
||||
|
||||
if ((p_MCB->level == 0U) || (p_MCB->owner != os_tsk.run)) {
|
||||
/* Unbalanced mutex release or task is not the owner */
|
||||
return (OS_R_NOK);
|
||||
}
|
||||
if (--p_MCB->level != 0U) {
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
/* Remove mutex from task mutex owner list. */
|
||||
p_mlnk = os_tsk.run->p_mlnk;
|
||||
if (p_mlnk == p_MCB) {
|
||||
os_tsk.run->p_mlnk = p_MCB->p_mlnk;
|
||||
}
|
||||
else {
|
||||
while (p_mlnk) {
|
||||
if (p_mlnk->p_mlnk == p_MCB) {
|
||||
p_mlnk->p_mlnk = p_MCB->p_mlnk;
|
||||
break;
|
||||
}
|
||||
p_mlnk = p_mlnk->p_mlnk;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore owner task's priority. */
|
||||
prio = os_tsk.run->prio_base;
|
||||
p_mlnk = os_tsk.run->p_mlnk;
|
||||
while (p_mlnk) {
|
||||
if ((p_mlnk->p_lnk != NULL) && (p_mlnk->p_lnk->prio > prio)) {
|
||||
/* A task with higher priority is waiting for mutex. */
|
||||
prio = p_mlnk->p_lnk->prio;
|
||||
}
|
||||
p_mlnk = p_mlnk->p_mlnk;
|
||||
}
|
||||
os_tsk.run->prio = prio;
|
||||
|
||||
if (p_MCB->p_lnk != NULL) {
|
||||
/* A task is waiting for mutex. */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val(p_TCB, 0U/*osOK*/);
|
||||
#else
|
||||
rt_ret_val(p_TCB, OS_R_MUT);
|
||||
#endif
|
||||
rt_rmv_dly (p_TCB);
|
||||
/* A waiting task becomes the owner of this mutex. */
|
||||
p_MCB->level = 1U;
|
||||
p_MCB->owner = p_TCB;
|
||||
p_MCB->p_mlnk = p_TCB->p_mlnk;
|
||||
p_TCB->p_mlnk = p_MCB;
|
||||
/* Priority inversion, check which task continues. */
|
||||
if (os_tsk.run->prio >= rt_rdy_prio()) {
|
||||
rt_dispatch (p_TCB);
|
||||
}
|
||||
else {
|
||||
/* Ready task has higher priority than running task. */
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
os_tsk.run->state = READY;
|
||||
p_TCB->state = READY;
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Check if own priority lowered by priority inversion. */
|
||||
if (rt_rdy_prio() > os_tsk.run->prio) {
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_mut_wait -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout) {
|
||||
/* Wait for a mutex, continue when mutex is free. */
|
||||
P_MUCB p_MCB = mutex;
|
||||
|
||||
if (p_MCB->level == 0U) {
|
||||
p_MCB->owner = os_tsk.run;
|
||||
p_MCB->p_mlnk = os_tsk.run->p_mlnk;
|
||||
os_tsk.run->p_mlnk = p_MCB;
|
||||
p_MCB->level = 1U;
|
||||
return (OS_R_OK);
|
||||
}
|
||||
if (p_MCB->owner == os_tsk.run) {
|
||||
/* OK, running task is the owner of this mutex. */
|
||||
if (p_MCB->level == 0xFFFFU) {
|
||||
return (OS_R_NOK);
|
||||
}
|
||||
p_MCB->level++;
|
||||
return (OS_R_OK);
|
||||
}
|
||||
/* Mutex owned by another task, wait until released. */
|
||||
if (timeout == 0U) {
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
/* Raise the owner task priority if lower than current priority. */
|
||||
/* This priority inversion is called priority inheritance. */
|
||||
if (p_MCB->owner->prio < os_tsk.run->prio) {
|
||||
p_MCB->owner->prio = os_tsk.run->prio;
|
||||
rt_resort_prio (p_MCB->owner);
|
||||
}
|
||||
if (p_MCB->p_lnk != NULL) {
|
||||
rt_put_prio ((P_XCB)p_MCB, os_tsk.run);
|
||||
}
|
||||
else {
|
||||
p_MCB->p_lnk = os_tsk.run;
|
||||
os_tsk.run->p_lnk = NULL;
|
||||
os_tsk.run->p_rlnk = (P_TCB)p_MCB;
|
||||
}
|
||||
rt_block(timeout, WAIT_MUT);
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
34
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mutex.h
vendored
Normal file
34
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Mutex.h
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_MUTEX.H
|
||||
* Purpose: Implements mutex synchronization objects
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Functions */
|
||||
extern void rt_mut_init (OS_ID mutex);
|
||||
extern OS_RESULT rt_mut_delete (OS_ID mutex);
|
||||
extern OS_RESULT rt_mut_release (OS_ID mutex);
|
||||
extern OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
74
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Robin.c
vendored
Normal file
74
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Robin.c
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_ROBIN.C
|
||||
* Purpose: Round Robin Task switching
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_Time.h"
|
||||
#include "rt_Robin.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
struct OS_ROBIN os_robin;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------- rt_init_robin ---------------------------------*/
|
||||
|
||||
__weak void rt_init_robin (void) {
|
||||
/* Initialize Round Robin variables. */
|
||||
os_robin.task = NULL;
|
||||
os_robin.tout = (U16)os_rrobin;
|
||||
}
|
||||
|
||||
/*--------------------------- rt_chk_robin ----------------------------------*/
|
||||
|
||||
__weak void rt_chk_robin (void) {
|
||||
/* Check if Round Robin timeout expired and switch to the next ready task.*/
|
||||
P_TCB p_new;
|
||||
|
||||
if (os_robin.task != os_rdy.p_lnk) {
|
||||
/* New task was suspended, reset Round Robin timeout. */
|
||||
os_robin.task = os_rdy.p_lnk;
|
||||
os_robin.time = (U16)os_time + os_robin.tout - 1U;
|
||||
}
|
||||
if (os_robin.time == (U16)os_time) {
|
||||
/* Round Robin timeout has expired, swap Robin tasks. */
|
||||
os_robin.task = NULL;
|
||||
p_new = rt_get_first (&os_rdy);
|
||||
rt_put_prio ((P_XCB)&os_rdy, p_new);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Robin.h
vendored
Normal file
35
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Robin.h
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_ROBIN.H
|
||||
* Purpose: Round Robin Task switching definitions
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Variables */
|
||||
extern struct OS_ROBIN os_robin;
|
||||
|
||||
/* Functions */
|
||||
extern void rt_init_robin (void);
|
||||
extern void rt_chk_robin (void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
173
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Semaphore.c
vendored
Normal file
173
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Semaphore.c
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_SEMAPHORE.C
|
||||
* Purpose: Implements binary and counting semaphores
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_Semaphore.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_sem_init -----------------------------------*/
|
||||
|
||||
void rt_sem_init (OS_ID semaphore, U16 token_count) {
|
||||
/* Initialize a semaphore */
|
||||
P_SCB p_SCB = semaphore;
|
||||
|
||||
p_SCB->cb_type = SCB;
|
||||
p_SCB->p_lnk = NULL;
|
||||
p_SCB->tokens = token_count;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_sem_delete ---------------------------------*/
|
||||
|
||||
#ifdef __CMSIS_RTOS
|
||||
OS_RESULT rt_sem_delete (OS_ID semaphore) {
|
||||
/* Delete semaphore */
|
||||
P_SCB p_SCB = semaphore;
|
||||
P_TCB p_TCB;
|
||||
|
||||
while (p_SCB->p_lnk != NULL) {
|
||||
/* A task is waiting for token */
|
||||
p_TCB = rt_get_first ((P_XCB)p_SCB);
|
||||
rt_ret_val(p_TCB, 0U);
|
||||
rt_rmv_dly(p_TCB);
|
||||
p_TCB->state = READY;
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
}
|
||||
|
||||
if ((os_rdy.p_lnk != NULL) && (os_rdy.p_lnk->prio > os_tsk.run->prio)) {
|
||||
/* preempt running task */
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
|
||||
p_SCB->cb_type = 0U;
|
||||
|
||||
return (OS_R_OK);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------- rt_sem_send -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_sem_send (OS_ID semaphore) {
|
||||
/* Return a token to semaphore */
|
||||
P_SCB p_SCB = semaphore;
|
||||
P_TCB p_TCB;
|
||||
|
||||
if (p_SCB->p_lnk != NULL) {
|
||||
/* A task is waiting for token */
|
||||
p_TCB = rt_get_first ((P_XCB)p_SCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val(p_TCB, 1U);
|
||||
#else
|
||||
rt_ret_val(p_TCB, OS_R_SEM);
|
||||
#endif
|
||||
rt_rmv_dly (p_TCB);
|
||||
rt_dispatch (p_TCB);
|
||||
}
|
||||
else {
|
||||
/* Store token. */
|
||||
p_SCB->tokens++;
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_sem_wait -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) {
|
||||
/* Obtain a token; possibly wait for it */
|
||||
P_SCB p_SCB = semaphore;
|
||||
|
||||
if (p_SCB->tokens) {
|
||||
p_SCB->tokens--;
|
||||
return (OS_R_OK);
|
||||
}
|
||||
/* No token available: wait for one */
|
||||
if (timeout == 0U) {
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
if (p_SCB->p_lnk != NULL) {
|
||||
rt_put_prio ((P_XCB)p_SCB, os_tsk.run);
|
||||
}
|
||||
else {
|
||||
p_SCB->p_lnk = os_tsk.run;
|
||||
os_tsk.run->p_lnk = NULL;
|
||||
os_tsk.run->p_rlnk = (P_TCB)p_SCB;
|
||||
}
|
||||
rt_block(timeout, WAIT_SEM);
|
||||
return (OS_R_TMO);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- isr_sem_send ----------------------------------*/
|
||||
|
||||
void isr_sem_send (OS_ID semaphore) {
|
||||
/* Same function as "os_sem_send", but to be called by ISRs */
|
||||
P_SCB p_SCB = semaphore;
|
||||
|
||||
rt_psq_enq (p_SCB, 0U);
|
||||
rt_psh_req ();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_sem_psh ------------------------------------*/
|
||||
|
||||
void rt_sem_psh (P_SCB p_CB) {
|
||||
/* Check if task has to be waken up */
|
||||
P_TCB p_TCB;
|
||||
|
||||
if (p_CB->p_lnk != NULL) {
|
||||
/* A task is waiting for token */
|
||||
p_TCB = rt_get_first ((P_XCB)p_CB);
|
||||
rt_rmv_dly (p_TCB);
|
||||
p_TCB->state = READY;
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val(p_TCB, 1U);
|
||||
#else
|
||||
rt_ret_val(p_TCB, OS_R_SEM);
|
||||
#endif
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
}
|
||||
else {
|
||||
/* Store token */
|
||||
p_CB->tokens++;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Semaphore.h
vendored
Normal file
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Semaphore.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_SEMAPHORE.H
|
||||
* Purpose: Implements binary and counting semaphores
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Functions */
|
||||
extern void rt_sem_init (OS_ID semaphore, U16 token_count);
|
||||
extern OS_RESULT rt_sem_delete(OS_ID semaphore);
|
||||
extern OS_RESULT rt_sem_send (OS_ID semaphore);
|
||||
extern OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout);
|
||||
extern void isr_sem_send (OS_ID semaphore);
|
||||
extern void rt_sem_psh (P_SCB p_CB);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
316
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_System.c
vendored
Normal file
316
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_System.c
vendored
Normal file
@ -0,0 +1,316 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_SYSTEM.C
|
||||
* Purpose: System Task Manager
|
||||
* Rev.: V4.82
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_Event.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_Mailbox.h"
|
||||
#include "rt_Semaphore.h"
|
||||
#include "rt_Time.h"
|
||||
#include "rt_Timer.h"
|
||||
#include "rt_Robin.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
S32 os_tick_irqn;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
static volatile BIT os_lock;
|
||||
static volatile BIT os_psh_flag;
|
||||
static U8 pend_flags;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define RL_RTX_VER 0x482
|
||||
|
||||
#if defined (__CC_ARM)
|
||||
__asm void $$RTX$$version (void) {
|
||||
/* Export a version number symbol for a version control. */
|
||||
|
||||
EXPORT __RL_RTX_VER
|
||||
|
||||
__RL_RTX_VER EQU RL_RTX_VER
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------- rt_suspend ------------------------------------*/
|
||||
|
||||
extern U32 sysUserTimerWakeupTime(void);
|
||||
|
||||
U32 rt_suspend (void) {
|
||||
/* Suspend OS scheduler */
|
||||
U32 delta = 0xFFFFU;
|
||||
#ifdef __CMSIS_RTOS
|
||||
U32 sleep;
|
||||
#endif
|
||||
|
||||
rt_tsk_lock();
|
||||
|
||||
if (os_dly.p_dlnk) {
|
||||
delta = os_dly.delta_time;
|
||||
}
|
||||
#ifdef __CMSIS_RTOS
|
||||
sleep = sysUserTimerWakeupTime();
|
||||
if (sleep < delta) { delta = sleep; }
|
||||
#else
|
||||
if (os_tmr.next) {
|
||||
if (os_tmr.tcnt < delta) delta = os_tmr.tcnt;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (delta);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_resume -------------------------------------*/
|
||||
|
||||
extern void sysUserTimerUpdate (U32 sleep_time);
|
||||
|
||||
void rt_resume (U32 sleep_time) {
|
||||
/* Resume OS scheduler after suspend */
|
||||
P_TCB next;
|
||||
U32 delta;
|
||||
|
||||
os_tsk.run->state = READY;
|
||||
rt_put_rdy_first (os_tsk.run);
|
||||
|
||||
os_robin.task = NULL;
|
||||
|
||||
/* Update delays. */
|
||||
if (os_dly.p_dlnk) {
|
||||
delta = sleep_time;
|
||||
if (delta >= os_dly.delta_time) {
|
||||
delta -= os_dly.delta_time;
|
||||
os_time += os_dly.delta_time;
|
||||
os_dly.delta_time = 1U;
|
||||
while (os_dly.p_dlnk) {
|
||||
rt_dec_dly();
|
||||
if (delta == 0U) { break; }
|
||||
delta--;
|
||||
os_time++;
|
||||
}
|
||||
} else {
|
||||
os_time += delta;
|
||||
os_dly.delta_time -= (U16)delta;
|
||||
}
|
||||
} else {
|
||||
os_time += sleep_time;
|
||||
}
|
||||
|
||||
/* Check the user timers. */
|
||||
#ifdef __CMSIS_RTOS
|
||||
sysUserTimerUpdate(sleep_time);
|
||||
#else
|
||||
if (os_tmr.next) {
|
||||
delta = sleep_time;
|
||||
if (delta >= os_tmr.tcnt) {
|
||||
delta -= os_tmr.tcnt;
|
||||
os_tmr.tcnt = 1U;
|
||||
while (os_tmr.next) {
|
||||
rt_tmr_tick();
|
||||
if (delta == 0U) { break; }
|
||||
delta--;
|
||||
}
|
||||
} else {
|
||||
os_tmr.tcnt -= delta;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Switch back to highest ready task */
|
||||
next = rt_get_first (&os_rdy);
|
||||
rt_switch_req (next);
|
||||
|
||||
rt_tsk_unlock();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_lock -----------------------------------*/
|
||||
|
||||
void rt_tsk_lock (void) {
|
||||
/* Prevent task switching by locking out scheduler */
|
||||
if (os_tick_irqn < 0) {
|
||||
OS_LOCK();
|
||||
os_lock = __TRUE;
|
||||
OS_UNPEND(pend_flags);
|
||||
} else {
|
||||
OS_X_LOCK((U32)os_tick_irqn);
|
||||
os_lock = __TRUE;
|
||||
OS_X_UNPEND(pend_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_unlock ---------------------------------*/
|
||||
|
||||
void rt_tsk_unlock (void) {
|
||||
/* Unlock scheduler and re-enable task switching */
|
||||
if (os_tick_irqn < 0) {
|
||||
OS_UNLOCK();
|
||||
os_lock = __FALSE;
|
||||
OS_PEND(pend_flags, os_psh_flag);
|
||||
os_psh_flag = __FALSE;
|
||||
} else {
|
||||
OS_X_UNLOCK((U32)os_tick_irqn);
|
||||
os_lock = __FALSE;
|
||||
OS_X_PEND(pend_flags, os_psh_flag);
|
||||
os_psh_flag = __FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_psh_req ------------------------------------*/
|
||||
|
||||
void rt_psh_req (void) {
|
||||
/* Initiate a post service handling request if required. */
|
||||
if (os_lock == __FALSE) {
|
||||
OS_PEND_IRQ();
|
||||
}
|
||||
else {
|
||||
os_psh_flag = __TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_pop_req ------------------------------------*/
|
||||
|
||||
void rt_pop_req (void) {
|
||||
/* Process an ISR post service requests. */
|
||||
struct OS_XCB *p_CB;
|
||||
P_TCB next;
|
||||
U32 idx;
|
||||
|
||||
os_tsk.run->state = READY;
|
||||
rt_put_rdy_first (os_tsk.run);
|
||||
|
||||
idx = os_psq->last;
|
||||
while (os_psq->count) {
|
||||
p_CB = os_psq->q[idx].id;
|
||||
if (p_CB->cb_type == TCB) {
|
||||
/* Is of TCB type */
|
||||
rt_evt_psh ((P_TCB)p_CB, (U16)os_psq->q[idx].arg);
|
||||
}
|
||||
else if (p_CB->cb_type == MCB) {
|
||||
/* Is of MCB type */
|
||||
rt_mbx_psh ((P_MCB)p_CB, (void *)os_psq->q[idx].arg);
|
||||
}
|
||||
else {
|
||||
/* Must be of SCB type */
|
||||
rt_sem_psh ((P_SCB)p_CB);
|
||||
}
|
||||
if (++idx == os_psq->size) { idx = 0U; }
|
||||
rt_dec (&os_psq->count);
|
||||
}
|
||||
os_psq->last = (U8)idx;
|
||||
|
||||
next = rt_get_first (&os_rdy);
|
||||
rt_switch_req (next);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- os_tick_init ----------------------------------*/
|
||||
|
||||
__weak S32 os_tick_init (void) {
|
||||
/* Initialize SysTick timer as system tick timer. */
|
||||
rt_systick_init();
|
||||
return (-1); /* Return IRQ number of SysTick timer */
|
||||
}
|
||||
|
||||
/*--------------------------- os_tick_val -----------------------------------*/
|
||||
|
||||
__weak U32 os_tick_val (void) {
|
||||
/* Get SysTick timer current value (0 .. OS_TRV). */
|
||||
return rt_systick_val();
|
||||
}
|
||||
|
||||
/*--------------------------- os_tick_ovf -----------------------------------*/
|
||||
|
||||
__weak U32 os_tick_ovf (void) {
|
||||
/* Get SysTick timer overflow flag */
|
||||
return rt_systick_ovf();
|
||||
}
|
||||
|
||||
/*--------------------------- os_tick_irqack --------------------------------*/
|
||||
|
||||
__weak void os_tick_irqack (void) {
|
||||
/* Acknowledge timer interrupt. */
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_systick ------------------------------------*/
|
||||
|
||||
extern void sysTimerTick(void);
|
||||
|
||||
void rt_systick (void) {
|
||||
/* Check for system clock update, suspend running task. */
|
||||
P_TCB next;
|
||||
|
||||
os_tsk.run->state = READY;
|
||||
rt_put_rdy_first (os_tsk.run);
|
||||
|
||||
/* Check Round Robin timeout. */
|
||||
rt_chk_robin ();
|
||||
|
||||
/* Update delays. */
|
||||
os_time++;
|
||||
rt_dec_dly ();
|
||||
|
||||
/* Check the user timers. */
|
||||
#ifdef __CMSIS_RTOS
|
||||
sysTimerTick();
|
||||
#else
|
||||
rt_tmr_tick ();
|
||||
#endif
|
||||
|
||||
/* Switch back to highest ready task */
|
||||
next = rt_get_first (&os_rdy);
|
||||
rt_switch_req (next);
|
||||
}
|
||||
|
||||
/*--------------------------- rt_stk_check ----------------------------------*/
|
||||
|
||||
__weak void rt_stk_check (void) {
|
||||
/* Check for stack overflow. */
|
||||
if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) ||
|
||||
(os_tsk.run->stack[0] != MAGIC_WORD)) {
|
||||
os_error (OS_ERR_STK_OVF);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
42
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_System.h
vendored
Normal file
42
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_System.h
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_SYSTEM.H
|
||||
* Purpose: System Task Manager definitions
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Variables */
|
||||
#define os_psq ((P_PSQ)&os_fifo)
|
||||
extern S32 os_tick_irqn;
|
||||
|
||||
/* Functions */
|
||||
extern U32 rt_suspend (void);
|
||||
extern void rt_resume (U32 sleep_time);
|
||||
extern void rt_tsk_lock (void);
|
||||
extern void rt_tsk_unlock (void);
|
||||
extern void rt_psh_req (void);
|
||||
extern void rt_pop_req (void);
|
||||
extern void rt_systick (void);
|
||||
extern void rt_stk_check (void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
437
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Task.c
vendored
Normal file
437
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Task.c
vendored
Normal file
@ -0,0 +1,437 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TASK.C
|
||||
* Purpose: Task functions and system start up.
|
||||
* Rev.: V4.80
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_System.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_List.h"
|
||||
#include "rt_MemBox.h"
|
||||
#include "rt_Robin.h"
|
||||
#include "rt_HAL_CM.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Running and next task info. */
|
||||
struct OS_TSK os_tsk;
|
||||
|
||||
/* Task Control Blocks of idle demon */
|
||||
struct OS_TCB os_idle_TCB;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
static OS_TID rt_get_TID (void) {
|
||||
U32 tid;
|
||||
|
||||
for (tid = 1U; tid <= os_maxtaskrun; tid++) {
|
||||
if (os_active_TCB[tid-1U] == NULL) {
|
||||
return ((OS_TID)tid);
|
||||
}
|
||||
}
|
||||
return (0U);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_init_context -------------------------------*/
|
||||
|
||||
static void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) {
|
||||
/* Initialize general part of the Task Control Block. */
|
||||
p_TCB->cb_type = TCB;
|
||||
p_TCB->state = READY;
|
||||
p_TCB->prio = priority;
|
||||
p_TCB->prio_base = priority;
|
||||
p_TCB->p_lnk = NULL;
|
||||
p_TCB->p_rlnk = NULL;
|
||||
p_TCB->p_dlnk = NULL;
|
||||
p_TCB->p_blnk = NULL;
|
||||
p_TCB->p_mlnk = NULL;
|
||||
p_TCB->delta_time = 0U;
|
||||
p_TCB->interval_time = 0U;
|
||||
p_TCB->events = 0U;
|
||||
p_TCB->waits = 0U;
|
||||
p_TCB->stack_frame = 0U;
|
||||
|
||||
if (p_TCB->priv_stack == 0U) {
|
||||
/* Allocate the memory space for the stack. */
|
||||
p_TCB->stack = rt_alloc_box (mp_stk);
|
||||
}
|
||||
rt_init_stack (p_TCB, task_body);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_switch_req ---------------------------------*/
|
||||
|
||||
void rt_switch_req (P_TCB p_next) {
|
||||
/* Switch to next task (identified by "p_next"). */
|
||||
os_tsk.next = p_next;
|
||||
p_next->state = RUNNING;
|
||||
DBG_TASK_SWITCH(p_next->task_id);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_dispatch -----------------------------------*/
|
||||
|
||||
void rt_dispatch (P_TCB next_TCB) {
|
||||
/* Dispatch next task if any identified or dispatch highest ready task */
|
||||
/* "next_TCB" identifies a task to run or has value NULL (=no next task) */
|
||||
if (next_TCB == NULL) {
|
||||
/* Running task was blocked: continue with highest ready task */
|
||||
next_TCB = rt_get_first (&os_rdy);
|
||||
rt_switch_req (next_TCB);
|
||||
}
|
||||
else {
|
||||
/* Check which task continues */
|
||||
if (next_TCB->prio > os_tsk.run->prio) {
|
||||
/* preempt running task */
|
||||
rt_put_rdy_first (os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_switch_req (next_TCB);
|
||||
}
|
||||
else {
|
||||
/* put next task into ready list, no task switch takes place */
|
||||
next_TCB->state = READY;
|
||||
rt_put_prio (&os_rdy, next_TCB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_block --------------------------------------*/
|
||||
|
||||
void rt_block (U16 timeout, U8 block_state) {
|
||||
/* Block running task and choose next ready task. */
|
||||
/* "timeout" sets a time-out value or is 0xffff (=no time-out). */
|
||||
/* "block_state" defines the appropriate task state */
|
||||
P_TCB next_TCB;
|
||||
|
||||
if (timeout) {
|
||||
if (timeout < 0xFFFFU) {
|
||||
rt_put_dly (os_tsk.run, timeout);
|
||||
}
|
||||
os_tsk.run->state = block_state;
|
||||
next_TCB = rt_get_first (&os_rdy);
|
||||
rt_switch_req (next_TCB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_pass -----------------------------------*/
|
||||
|
||||
void rt_tsk_pass (void) {
|
||||
/* Allow tasks of same priority level to run cooperatively.*/
|
||||
P_TCB p_new;
|
||||
|
||||
p_new = rt_get_same_rdy_prio();
|
||||
if (p_new != NULL) {
|
||||
rt_put_prio ((P_XCB)&os_rdy, os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_switch_req (p_new);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_self -----------------------------------*/
|
||||
|
||||
OS_TID rt_tsk_self (void) {
|
||||
/* Return own task identifier value. */
|
||||
if (os_tsk.run == NULL) {
|
||||
return (0U);
|
||||
}
|
||||
return ((OS_TID)os_tsk.run->task_id);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_prio -----------------------------------*/
|
||||
|
||||
OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio) {
|
||||
/* Change execution priority of a task to "new_prio". */
|
||||
P_TCB p_task;
|
||||
|
||||
if (task_id == 0U) {
|
||||
/* Change execution priority of calling task. */
|
||||
os_tsk.run->prio = new_prio;
|
||||
os_tsk.run->prio_base = new_prio;
|
||||
run:if (rt_rdy_prio() > new_prio) {
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
os_tsk.run->state = READY;
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
/* Find the task in the "os_active_TCB" array. */
|
||||
if ((task_id > os_maxtaskrun) || (os_active_TCB[task_id-1U] == NULL)) {
|
||||
/* Task with "task_id" not found or not started. */
|
||||
return (OS_R_NOK);
|
||||
}
|
||||
p_task = os_active_TCB[task_id-1U];
|
||||
p_task->prio = new_prio;
|
||||
p_task->prio_base = new_prio;
|
||||
if (p_task == os_tsk.run) {
|
||||
goto run;
|
||||
}
|
||||
rt_resort_prio (p_task);
|
||||
if (p_task->state == READY) {
|
||||
/* Task enqueued in a ready list. */
|
||||
p_task = rt_get_first (&os_rdy);
|
||||
rt_dispatch (p_task);
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_create ---------------------------------*/
|
||||
|
||||
OS_TID rt_tsk_create (FUNCP task, U32 prio_stksz, void *stk, void *argv) {
|
||||
/* Start a new task declared with "task". */
|
||||
P_TCB task_context;
|
||||
U32 i;
|
||||
|
||||
/* Priority 0 is reserved for idle task! */
|
||||
if ((prio_stksz & 0xFFU) == 0U) {
|
||||
prio_stksz += 1U;
|
||||
}
|
||||
task_context = rt_alloc_box (mp_tcb);
|
||||
if (task_context == NULL) {
|
||||
return (0U);
|
||||
}
|
||||
/* If "size != 0" use a private user provided stack. */
|
||||
task_context->stack = stk;
|
||||
task_context->priv_stack = (U16)(prio_stksz >> 8);
|
||||
/* Pass parameter 'argv' to 'rt_init_context' */
|
||||
task_context->msg = argv;
|
||||
/* For 'size == 0' system allocates the user stack from the memory pool. */
|
||||
rt_init_context (task_context, (U8)(prio_stksz & 0xFFU), task);
|
||||
|
||||
/* Find a free entry in 'os_active_TCB' table. */
|
||||
i = rt_get_TID ();
|
||||
if (i == 0U) {
|
||||
return (0U);
|
||||
}
|
||||
os_active_TCB[i-1U] = task_context;
|
||||
task_context->task_id = (U8)i;
|
||||
DBG_TASK_NOTIFY(task_context, __TRUE);
|
||||
rt_dispatch (task_context);
|
||||
return ((OS_TID)i);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_tsk_delete ---------------------------------*/
|
||||
|
||||
OS_RESULT rt_tsk_delete (OS_TID task_id) {
|
||||
/* Terminate the task identified with "task_id". */
|
||||
P_TCB task_context;
|
||||
P_TCB p_TCB;
|
||||
P_MUCB p_MCB, p_MCB0;
|
||||
|
||||
if ((task_id == 0U) || (task_id == os_tsk.run->task_id)) {
|
||||
/* Terminate itself. */
|
||||
os_tsk.run->state = INACTIVE;
|
||||
os_tsk.run->tsk_stack = rt_get_PSP ();
|
||||
rt_stk_check ();
|
||||
p_MCB = os_tsk.run->p_mlnk;
|
||||
while (p_MCB) {
|
||||
/* Release mutexes owned by this task */
|
||||
if (p_MCB->p_lnk) {
|
||||
/* A task is waiting for mutex. */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val (p_TCB, 0U/*osOK*/);
|
||||
#else
|
||||
rt_ret_val (p_TCB, OS_R_MUT);
|
||||
#endif
|
||||
rt_rmv_dly (p_TCB);
|
||||
p_TCB->state = READY;
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
/* A waiting task becomes the owner of this mutex. */
|
||||
p_MCB0 = p_MCB->p_mlnk;
|
||||
p_MCB->level = 1U;
|
||||
p_MCB->owner = p_TCB;
|
||||
p_MCB->p_mlnk = p_TCB->p_mlnk;
|
||||
p_TCB->p_mlnk = p_MCB;
|
||||
p_MCB = p_MCB0;
|
||||
}
|
||||
else {
|
||||
p_MCB0 = p_MCB->p_mlnk;
|
||||
p_MCB->level = 0U;
|
||||
p_MCB->owner = NULL;
|
||||
p_MCB->p_mlnk = NULL;
|
||||
p_MCB = p_MCB0;
|
||||
}
|
||||
}
|
||||
os_active_TCB[os_tsk.run->task_id-1U] = NULL;
|
||||
rt_free_box (mp_stk, os_tsk.run->stack);
|
||||
os_tsk.run->stack = NULL;
|
||||
DBG_TASK_NOTIFY(os_tsk.run, __FALSE);
|
||||
rt_free_box (mp_tcb, os_tsk.run);
|
||||
os_tsk.run = NULL;
|
||||
rt_dispatch (NULL);
|
||||
/* The program should never come to this point. */
|
||||
}
|
||||
else {
|
||||
/* Find the task in the "os_active_TCB" array. */
|
||||
if ((task_id > os_maxtaskrun) || (os_active_TCB[task_id-1U] == NULL)) {
|
||||
/* Task with "task_id" not found or not started. */
|
||||
return (OS_R_NOK);
|
||||
}
|
||||
task_context = os_active_TCB[task_id-1U];
|
||||
rt_rmv_list (task_context);
|
||||
rt_rmv_dly (task_context);
|
||||
p_MCB = task_context->p_mlnk;
|
||||
while (p_MCB) {
|
||||
/* Release mutexes owned by this task */
|
||||
if (p_MCB->p_lnk) {
|
||||
/* A task is waiting for mutex. */
|
||||
p_TCB = rt_get_first ((P_XCB)p_MCB);
|
||||
#ifdef __CMSIS_RTOS
|
||||
rt_ret_val (p_TCB, 0U/*osOK*/);
|
||||
#else
|
||||
rt_ret_val (p_TCB, OS_R_MUT);
|
||||
#endif
|
||||
rt_rmv_dly (p_TCB);
|
||||
p_TCB->state = READY;
|
||||
rt_put_prio (&os_rdy, p_TCB);
|
||||
/* A waiting task becomes the owner of this mutex. */
|
||||
p_MCB0 = p_MCB->p_mlnk;
|
||||
p_MCB->level = 1U;
|
||||
p_MCB->owner = p_TCB;
|
||||
p_MCB->p_mlnk = p_TCB->p_mlnk;
|
||||
p_TCB->p_mlnk = p_MCB;
|
||||
p_MCB = p_MCB0;
|
||||
}
|
||||
else {
|
||||
p_MCB0 = p_MCB->p_mlnk;
|
||||
p_MCB->level = 0U;
|
||||
p_MCB->owner = NULL;
|
||||
p_MCB->p_mlnk = NULL;
|
||||
p_MCB = p_MCB0;
|
||||
}
|
||||
}
|
||||
os_active_TCB[task_id-1U] = NULL;
|
||||
rt_free_box (mp_stk, task_context->stack);
|
||||
task_context->stack = NULL;
|
||||
DBG_TASK_NOTIFY(task_context, __FALSE);
|
||||
rt_free_box (mp_tcb, task_context);
|
||||
if (rt_rdy_prio() > os_tsk.run->prio) {
|
||||
/* Ready task has higher priority than running task. */
|
||||
os_tsk.run->state = READY;
|
||||
rt_put_prio (&os_rdy, os_tsk.run);
|
||||
rt_dispatch (NULL);
|
||||
}
|
||||
}
|
||||
return (OS_R_OK);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_sys_init -----------------------------------*/
|
||||
|
||||
#ifdef __CMSIS_RTOS
|
||||
void rt_sys_init (void) {
|
||||
#else
|
||||
void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) {
|
||||
#endif
|
||||
/* Initialize system and start up task declared with "first_task". */
|
||||
U32 i;
|
||||
|
||||
DBG_INIT();
|
||||
|
||||
/* Initialize dynamic memory and task TCB pointers to NULL. */
|
||||
for (i = 0U; i < os_maxtaskrun; i++) {
|
||||
os_active_TCB[i] = NULL;
|
||||
}
|
||||
rt_init_box (mp_tcb, (U32)mp_tcb_size, sizeof(struct OS_TCB));
|
||||
rt_init_box (mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo));
|
||||
rt_init_box ((U32 *)m_tmr, (U32)mp_tmr_size, sizeof(struct OS_TMR));
|
||||
|
||||
/* Set up TCB of idle demon */
|
||||
os_idle_TCB.task_id = 255U;
|
||||
os_idle_TCB.priv_stack = 0U;
|
||||
rt_init_context (&os_idle_TCB, 0U, os_idle_demon);
|
||||
|
||||
/* Set up ready list: initially empty */
|
||||
os_rdy.cb_type = HCB;
|
||||
os_rdy.p_lnk = NULL;
|
||||
/* Set up delay list: initially empty */
|
||||
os_dly.cb_type = HCB;
|
||||
os_dly.p_dlnk = NULL;
|
||||
os_dly.p_blnk = NULL;
|
||||
os_dly.delta_time = 0U;
|
||||
|
||||
/* Fix SP and system variables to assume idle task is running */
|
||||
/* Transform main program into idle task by assuming idle TCB */
|
||||
#ifndef __CMSIS_RTOS
|
||||
rt_set_PSP (os_idle_TCB.tsk_stack+32U);
|
||||
#endif
|
||||
os_tsk.run = &os_idle_TCB;
|
||||
os_tsk.run->state = RUNNING;
|
||||
|
||||
/* Initialize ps queue */
|
||||
os_psq->first = 0U;
|
||||
os_psq->last = 0U;
|
||||
os_psq->size = os_fifo_size;
|
||||
|
||||
rt_init_robin ();
|
||||
|
||||
#ifndef __CMSIS_RTOS
|
||||
/* Initialize SVC and PendSV */
|
||||
rt_svc_init ();
|
||||
|
||||
/* Initialize and start system clock timer */
|
||||
os_tick_irqn = os_tick_init ();
|
||||
if (os_tick_irqn >= 0) {
|
||||
OS_X_INIT((U32)os_tick_irqn);
|
||||
}
|
||||
|
||||
/* Start up first user task before entering the endless loop */
|
||||
rt_tsk_create (first_task, prio_stksz, stk, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_sys_start ----------------------------------*/
|
||||
|
||||
#ifdef __CMSIS_RTOS
|
||||
void rt_sys_start (void) {
|
||||
/* Start system */
|
||||
|
||||
/* Initialize SVC and PendSV */
|
||||
rt_svc_init ();
|
||||
|
||||
/* Initialize and start system clock timer */
|
||||
os_tick_irqn = os_tick_init ();
|
||||
if (os_tick_irqn >= 0) {
|
||||
OS_X_INIT((U32)os_tick_irqn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
72
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Task.h
vendored
Normal file
72
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Task.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TASK.H
|
||||
* Purpose: Task functions and system start up.
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Definitions */
|
||||
|
||||
/* Values for 'state' */
|
||||
#define INACTIVE 0U
|
||||
#define READY 1U
|
||||
#define RUNNING 2U
|
||||
#define WAIT_DLY 3U
|
||||
#define WAIT_ITV 4U
|
||||
#define WAIT_OR 5U
|
||||
#define WAIT_AND 6U
|
||||
#define WAIT_SEM 7U
|
||||
#define WAIT_MBX 8U
|
||||
#define WAIT_MUT 9U
|
||||
|
||||
/* Return codes */
|
||||
#define OS_R_TMO 0x01U
|
||||
#define OS_R_EVT 0x02U
|
||||
#define OS_R_SEM 0x03U
|
||||
#define OS_R_MBX 0x04U
|
||||
#define OS_R_MUT 0x05U
|
||||
|
||||
#define OS_R_OK 0x00U
|
||||
#define OS_R_NOK 0xFFU
|
||||
|
||||
/* Variables */
|
||||
extern struct OS_TSK os_tsk;
|
||||
extern struct OS_TCB os_idle_TCB;
|
||||
|
||||
/* Functions */
|
||||
extern void rt_switch_req (P_TCB p_next);
|
||||
extern void rt_dispatch (P_TCB next_TCB);
|
||||
extern void rt_block (U16 timeout, U8 block_state);
|
||||
extern void rt_tsk_pass (void);
|
||||
extern OS_TID rt_tsk_self (void);
|
||||
extern OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio);
|
||||
extern OS_TID rt_tsk_create (FUNCP task, U32 prio_stksz, void *stk, void *argv);
|
||||
extern OS_RESULT rt_tsk_delete (OS_TID task_id);
|
||||
#ifdef __CMSIS_RTOS
|
||||
extern void rt_sys_init (void);
|
||||
extern void rt_sys_start (void);
|
||||
#else
|
||||
extern void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
84
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Time.c
vendored
Normal file
84
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Time.c
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TIME.C
|
||||
* Purpose: Delay and interval wait functions
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_Task.h"
|
||||
#include "rt_Time.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Free running system tick counter */
|
||||
U32 os_time;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------- rt_time_get -----------------------------------*/
|
||||
|
||||
U32 rt_time_get (void) {
|
||||
/* Get system time tick */
|
||||
return (os_time);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_dly_wait -----------------------------------*/
|
||||
|
||||
void rt_dly_wait (U16 delay_time) {
|
||||
/* Delay task by "delay_time" */
|
||||
rt_block (delay_time, WAIT_DLY);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_itv_set ------------------------------------*/
|
||||
|
||||
void rt_itv_set (U16 interval_time) {
|
||||
/* Set interval length and define start of first interval */
|
||||
os_tsk.run->interval_time = interval_time;
|
||||
os_tsk.run->delta_time = interval_time + (U16)os_time;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- rt_itv_wait -----------------------------------*/
|
||||
|
||||
void rt_itv_wait (void) {
|
||||
/* Wait for interval end and define start of next one */
|
||||
U16 delta;
|
||||
|
||||
delta = os_tsk.run->delta_time - (U16)os_time;
|
||||
os_tsk.run->delta_time += os_tsk.run->interval_time;
|
||||
if ((delta & 0x8000U) == 0U) {
|
||||
rt_block (delta, WAIT_ITV);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
37
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Time.h
vendored
Normal file
37
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Time.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TIME.H
|
||||
* Purpose: Delay and interval wait functions definitions
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Variables */
|
||||
extern U32 os_time;
|
||||
|
||||
/* Functions */
|
||||
extern U32 rt_time_get (void);
|
||||
extern void rt_dly_wait (U16 delay_time);
|
||||
extern void rt_itv_set (U16 interval_time);
|
||||
extern void rt_itv_wait (void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
125
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Timer.c
vendored
Normal file
125
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Timer.c
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TIMER.C
|
||||
* Purpose: User timer functions
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rt_TypeDef.h"
|
||||
#include "RTX_Config.h"
|
||||
#include "rt_Timer.h"
|
||||
#include "rt_MemBox.h"
|
||||
|
||||
#ifndef __CMSIS_RTOS
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* User Timer list pointer */
|
||||
struct OS_XTMR os_tmr;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------- rt_tmr_tick -----------------------------------*/
|
||||
|
||||
void rt_tmr_tick (void) {
|
||||
/* Decrement delta count of timer list head. Timers having the value of */
|
||||
/* zero are removed from the list and the callback function is called. */
|
||||
P_TMR p;
|
||||
|
||||
if (os_tmr.next == NULL) {
|
||||
return;
|
||||
}
|
||||
os_tmr.tcnt--;
|
||||
while ((os_tmr.tcnt == 0U) && ((p = os_tmr.next) != NULL)) {
|
||||
/* Call a user provided function to handle an elapsed timer */
|
||||
os_tmr_call (p->info);
|
||||
os_tmr.tcnt = p->tcnt;
|
||||
os_tmr.next = p->next;
|
||||
rt_free_box ((U32 *)m_tmr, p);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------- rt_tmr_create ---------------------------------*/
|
||||
|
||||
OS_ID rt_tmr_create (U16 tcnt, U16 info) {
|
||||
/* Create an user timer and put it into the chained timer list using */
|
||||
/* a timeout count value of "tcnt". User parameter "info" is used as a */
|
||||
/* parameter for the user provided callback function "os_tmr_call ()". */
|
||||
P_TMR p_tmr, p;
|
||||
U32 delta,itcnt = tcnt;
|
||||
|
||||
if ((tcnt == 0U) || (m_tmr == NULL)) {
|
||||
return (NULL);
|
||||
}
|
||||
p_tmr = rt_alloc_box ((U32 *)m_tmr);
|
||||
if (!p_tmr) {
|
||||
return (NULL);
|
||||
}
|
||||
p_tmr->info = info;
|
||||
p = (P_TMR)&os_tmr;
|
||||
delta = p->tcnt;
|
||||
while ((delta < itcnt) && (p->next != NULL)) {
|
||||
p = p->next;
|
||||
delta += p->tcnt;
|
||||
}
|
||||
/* Right place found, insert timer into the list */
|
||||
p_tmr->next = p->next;
|
||||
p_tmr->tcnt = (U16)(delta - itcnt);
|
||||
p->next = p_tmr;
|
||||
p->tcnt -= p_tmr->tcnt;
|
||||
return (p_tmr);
|
||||
}
|
||||
|
||||
/*--------------------------- rt_tmr_kill -----------------------------------*/
|
||||
|
||||
OS_ID rt_tmr_kill (OS_ID timer) {
|
||||
/* Remove user timer from the chained timer list. */
|
||||
P_TMR p, p_tmr;
|
||||
|
||||
p_tmr = (P_TMR)timer;
|
||||
p = (P_TMR)&os_tmr;
|
||||
/* Search timer list for requested timer */
|
||||
while (p->next != p_tmr) {
|
||||
if (p->next == NULL) {
|
||||
/* Failed, "timer" is not in the timer list */
|
||||
return (p_tmr);
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
/* Timer was found, remove it from the list */
|
||||
p->next = p_tmr->next;
|
||||
p->tcnt += p_tmr->tcnt;
|
||||
rt_free_box ((U32 *)m_tmr, p_tmr);
|
||||
/* Timer killed */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Timer.h
vendored
Normal file
36
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_Timer.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TIMER.H
|
||||
* Purpose: User timer functions
|
||||
* Rev.: V4.70
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Variables */
|
||||
extern struct OS_XTMR os_tmr;
|
||||
|
||||
/* Functions */
|
||||
extern void rt_tmr_tick (void);
|
||||
extern OS_ID rt_tmr_create (U16 tcnt, U16 info);
|
||||
extern OS_ID rt_tmr_kill (OS_ID timer);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
158
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_TypeDef.h
vendored
Normal file
158
external/CMSIS_5/CMSIS/RTOS/RTX/SRC/rt_TypeDef.h
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* CMSIS-RTOS - RTX
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: RT_TYPEDEF.H
|
||||
* Purpose: Type Definitions
|
||||
* Rev.: V4.79
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 1999-2009 KEIL, 2009-2017 ARM Germany GmbH. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Types */
|
||||
typedef char S8;
|
||||
typedef unsigned char U8;
|
||||
typedef short S16;
|
||||
typedef unsigned short U16;
|
||||
typedef int S32;
|
||||
typedef unsigned int U32;
|
||||
typedef long long S64;
|
||||
typedef unsigned long long U64;
|
||||
typedef unsigned char BIT;
|
||||
typedef unsigned int BOOL;
|
||||
typedef void (*FUNCP)(void);
|
||||
|
||||
typedef U32 OS_TID;
|
||||
typedef void *OS_ID;
|
||||
typedef U32 OS_RESULT;
|
||||
|
||||
typedef struct OS_TCB {
|
||||
/* General part: identical for all implementations. */
|
||||
U8 cb_type; /* Control Block Type */
|
||||
U8 state; /* Task state */
|
||||
U8 prio; /* Execution priority */
|
||||
U8 task_id; /* Task ID value for optimized TCB access */
|
||||
struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */
|
||||
struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */
|
||||
struct OS_TCB *p_dlnk; /* Link pointer for delay list */
|
||||
struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */
|
||||
U16 delta_time; /* Time until time out */
|
||||
U16 interval_time; /* Time interval for periodic waits */
|
||||
U16 events; /* Event flags */
|
||||
U16 waits; /* Wait flags */
|
||||
void **msg; /* Direct message passing when task waits */
|
||||
struct OS_MUCB *p_mlnk; /* Link pointer for mutex owner list */
|
||||
U8 prio_base; /* Base priority */
|
||||
|
||||
/* Hardware dependant part: specific for CM processor */
|
||||
U8 stack_frame; /* Stack frame: 0=Basic, 1=Extended, */
|
||||
/* (2=VFP/D16 stacked, 4=NEON/D32 stacked) */
|
||||
U16 priv_stack; /* Private stack size, 0= system assigned */
|
||||
U32 tsk_stack; /* Current task Stack pointer (R13) */
|
||||
U32 *stack; /* Pointer to Task Stack memory block */
|
||||
|
||||
/* Task entry point used for uVision debugger */
|
||||
FUNCP ptask; /* Task entry address */
|
||||
} *P_TCB;
|
||||
#define TCB_STACKF 37 /* 'stack_frame' offset */
|
||||
#define TCB_TSTACK 40 /* 'tsk_stack' offset */
|
||||
|
||||
typedef struct OS_PSFE { /* Post Service Fifo Entry */
|
||||
void *id; /* Object Identification */
|
||||
U32 arg; /* Object Argument */
|
||||
} *P_PSFE;
|
||||
|
||||
typedef struct OS_PSQ { /* Post Service Queue */
|
||||
U8 first; /* FIFO Head Index */
|
||||
U8 last; /* FIFO Tail Index */
|
||||
U8 count; /* Number of stored items in FIFO */
|
||||
U8 size; /* FIFO Size */
|
||||
struct OS_PSFE q[1]; /* FIFO Content */
|
||||
} *P_PSQ;
|
||||
|
||||
typedef struct OS_TSK {
|
||||
P_TCB run; /* Current running task */
|
||||
P_TCB next; /* Scheduled task to run */
|
||||
} *P_TSK;
|
||||
|
||||
typedef struct OS_ROBIN { /* Round Robin Control */
|
||||
P_TCB task; /* Round Robin task */
|
||||
U16 time; /* Round Robin switch time */
|
||||
U16 tout; /* Round Robin timeout */
|
||||
} *P_ROBIN;
|
||||
|
||||
typedef struct OS_XCB {
|
||||
U8 cb_type; /* Control Block Type */
|
||||
struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */
|
||||
struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */
|
||||
struct OS_TCB *p_dlnk; /* Link pointer for delay list */
|
||||
struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */
|
||||
U16 delta_time; /* Time until time out */
|
||||
} *P_XCB;
|
||||
|
||||
typedef struct OS_MCB {
|
||||
U8 cb_type; /* Control Block Type */
|
||||
U8 state; /* State flag variable */
|
||||
U8 isr_st; /* State flag variable for isr functions */
|
||||
struct OS_TCB *p_lnk; /* Chain of tasks waiting for message */
|
||||
U16 first; /* Index of the message list begin */
|
||||
U16 last; /* Index of the message list end */
|
||||
U16 count; /* Actual number of stored messages */
|
||||
U16 size; /* Maximum number of stored messages */
|
||||
void *msg[1]; /* FIFO for Message pointers 1st element */
|
||||
} *P_MCB;
|
||||
|
||||
typedef struct OS_SCB {
|
||||
U8 cb_type; /* Control Block Type */
|
||||
U8 mask; /* Semaphore token mask */
|
||||
U16 tokens; /* Semaphore tokens */
|
||||
struct OS_TCB *p_lnk; /* Chain of tasks waiting for tokens */
|
||||
} *P_SCB;
|
||||
|
||||
typedef struct OS_MUCB {
|
||||
U8 cb_type; /* Control Block Type */
|
||||
U16 level; /* Call nesting level */
|
||||
struct OS_TCB *p_lnk; /* Chain of tasks waiting for mutex */
|
||||
struct OS_TCB *owner; /* Mutex owner task */
|
||||
struct OS_MUCB *p_mlnk; /* Chain of mutexes by owner task */
|
||||
} *P_MUCB;
|
||||
|
||||
typedef struct OS_XTMR {
|
||||
struct OS_TMR *next;
|
||||
U16 tcnt;
|
||||
} *P_XTMR;
|
||||
|
||||
typedef struct OS_TMR {
|
||||
struct OS_TMR *next; /* Link pointer to Next timer */
|
||||
U16 tcnt; /* Timer delay count */
|
||||
U16 info; /* User defined call info */
|
||||
} *P_TMR;
|
||||
|
||||
typedef struct OS_BM {
|
||||
void *free; /* Pointer to first free memory block */
|
||||
void *end; /* Pointer to memory block end */
|
||||
U32 blk_size; /* Memory block size */
|
||||
} *P_BM;
|
||||
|
||||
/* Definitions */
|
||||
#define __TRUE 1U
|
||||
#define __FALSE 0U
|
||||
#define NULL ((void *) 0)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* end of file
|
||||
*---------------------------------------------------------------------------*/
|
Reference in New Issue
Block a user