mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add user call back function for SVC Handler
This commit is contained in:
parent
9e1b7c6c81
commit
5652423c66
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.arm
|
.arm
|
||||||
|
.syntax unified
|
||||||
|
|
||||||
.set SYS_MODE, 0x1f
|
.set SYS_MODE, 0x1f
|
||||||
.set SVC_MODE, 0x13
|
.set SVC_MODE, 0x13
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
.global vPortDisableInterrupts
|
.global vPortDisableInterrupts
|
||||||
.global ulPortSetInterruptMaskFromISR
|
.global ulPortSetInterruptMaskFromISR
|
||||||
|
|
||||||
|
.weak vApplicationSVCHandler
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
.macro portSAVE_CONTEXT
|
.macro portSAVE_CONTEXT
|
||||||
|
@ -132,20 +134,6 @@
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
|
||||||
* SVC handler is used to yield.
|
|
||||||
*/
|
|
||||||
.align 4
|
|
||||||
.type FreeRTOS_SVC_Handler, %function
|
|
||||||
FreeRTOS_SVC_Handler:
|
|
||||||
/* Save the context of the current task and select a new task to run. */
|
|
||||||
portSAVE_CONTEXT
|
|
||||||
BLX vTaskSwitchContext
|
|
||||||
portRESTORE_CONTEXT
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void vPortRestoreTaskContext( void );
|
* void vPortRestoreTaskContext( void );
|
||||||
*
|
*
|
||||||
|
@ -238,6 +226,51 @@ ulPortSetInterruptMaskFromISR:
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void vApplicationSVCHandler( uint32_t ulSvcNumber );
|
||||||
|
*/
|
||||||
|
.align 4
|
||||||
|
.type vApplicationSVCHandler, %function
|
||||||
|
vApplicationSVCHandler:
|
||||||
|
B vApplicationSVCHandler
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SVC handler is used to yield.
|
||||||
|
*/
|
||||||
|
.align 4
|
||||||
|
.type FreeRTOS_SVC_Handler, %function
|
||||||
|
FreeRTOS_SVC_Handler:
|
||||||
|
PUSH { R0-R1 }
|
||||||
|
|
||||||
|
/* ---------------------------- Get Caller SVC Number ---------------------------- */
|
||||||
|
MRS R0, SPSR /* R0 = CPSR at the time of SVC. */
|
||||||
|
TST R0, #0x20 /* Check Thumb bit (5) in CPSR. */
|
||||||
|
LDRHNE R0, [LR, #-0x2] /* If Thumb, load halfword. */
|
||||||
|
BICNE R0, R0, #0xFF00 /* And extract immidiate field (i.e. SVC number). */
|
||||||
|
LDREQ R0, [LR, #-0x4] /* If ARM, load word. */
|
||||||
|
BICEQ R0, R0, #0xFF000000 /* And extract immidiate field (i.e. SVC number). */
|
||||||
|
|
||||||
|
/* --------------------------------- SVC Routing --------------------------------- */
|
||||||
|
CMP R0, #0
|
||||||
|
BEQ svcPortYield
|
||||||
|
BNE svcApplicationCall
|
||||||
|
|
||||||
|
svcPortYield:
|
||||||
|
POP { R0-R1 }
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
BLX vTaskSwitchContext
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
svcApplicationCall:
|
||||||
|
POP { R0-R1 }
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
BLX vApplicationSVCHandler
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.type FreeRTOS_IRQ_Handler, %function
|
.type FreeRTOS_IRQ_Handler, %function
|
||||||
FreeRTOS_IRQ_Handler:
|
FreeRTOS_IRQ_Handler:
|
||||||
|
|
Loading…
Reference in a new issue