|
28 | 28 |
|
29 | 29 | .text
|
30 | 30 | .arm
|
| 31 | + .syntax unified |
31 | 32 |
|
32 | 33 | .set SYS_MODE, 0x1f
|
33 | 34 | .set SVC_MODE, 0x13
|
|
53 | 54 | .global vPortDisableInterrupts
|
54 | 55 | .global ulPortSetInterruptMaskFromISR
|
55 | 56 |
|
| 57 | + .weak vApplicationSVCHandler |
56 | 58 | /*-----------------------------------------------------------*/
|
57 | 59 |
|
58 | 60 | .macro portSAVE_CONTEXT
|
|
132 | 134 |
|
133 | 135 | /*-----------------------------------------------------------*/
|
134 | 136 |
|
135 |
| -/* |
136 |
| - * SVC handler is used to yield. |
137 |
| - */ |
138 |
| -.align 4 |
139 |
| -.type FreeRTOS_SVC_Handler, %function |
140 |
| -FreeRTOS_SVC_Handler: |
141 |
| - /* Save the context of the current task and select a new task to run. */ |
142 |
| - portSAVE_CONTEXT |
143 |
| - BLX vTaskSwitchContext |
144 |
| - portRESTORE_CONTEXT |
145 |
| - |
146 |
| - |
147 |
| -/*-----------------------------------------------------------*/ |
148 |
| - |
149 | 137 | /*
|
150 | 138 | * void vPortRestoreTaskContext( void );
|
151 | 139 | *
|
@@ -238,6 +226,51 @@ ulPortSetInterruptMaskFromISR:
|
238 | 226 |
|
239 | 227 | /*-----------------------------------------------------------*/
|
240 | 228 |
|
| 229 | +/* |
| 230 | + * void vApplicationSVCHandler( uint32_t ulSvcNumber ); |
| 231 | + */ |
| 232 | +.align 4 |
| 233 | +.type vApplicationSVCHandler, %function |
| 234 | +vApplicationSVCHandler: |
| 235 | + B vApplicationSVCHandler |
| 236 | + |
| 237 | +/*-----------------------------------------------------------*/ |
| 238 | + |
| 239 | +/* |
| 240 | + * SVC handler is used to yield. |
| 241 | + */ |
| 242 | +.align 4 |
| 243 | +.type FreeRTOS_SVC_Handler, %function |
| 244 | +FreeRTOS_SVC_Handler: |
| 245 | + PUSH { R0-R1 } |
| 246 | + |
| 247 | + /* ---------------------------- Get Caller SVC Number ---------------------------- */ |
| 248 | + MRS R0, SPSR /* R0 = CPSR at the time of SVC. */ |
| 249 | + TST R0, #0x20 /* Check Thumb bit (5) in CPSR. */ |
| 250 | + LDRHNE R0, [LR, #-0x2] /* If Thumb, load halfword. */ |
| 251 | + BICNE R0, R0, #0xFF00 /* And extract immidiate field (i.e. SVC number). */ |
| 252 | + LDREQ R0, [LR, #-0x4] /* If ARM, load word. */ |
| 253 | + BICEQ R0, R0, #0xFF000000 /* And extract immidiate field (i.e. SVC number). */ |
| 254 | + |
| 255 | + /* --------------------------------- SVC Routing --------------------------------- */ |
| 256 | + CMP R0, #0 |
| 257 | + BEQ svcPortYield |
| 258 | + BNE svcApplicationCall |
| 259 | + |
| 260 | +svcPortYield: |
| 261 | + POP { R0-R1 } |
| 262 | + portSAVE_CONTEXT |
| 263 | + BLX vTaskSwitchContext |
| 264 | + portRESTORE_CONTEXT |
| 265 | + |
| 266 | +svcApplicationCall: |
| 267 | + POP { R0-R1 } |
| 268 | + portSAVE_CONTEXT |
| 269 | + BLX vApplicationSVCHandler |
| 270 | + portRESTORE_CONTEXT |
| 271 | + |
| 272 | +/*-----------------------------------------------------------*/ |
| 273 | + |
241 | 274 | .align 4
|
242 | 275 | .type FreeRTOS_IRQ_Handler, %function
|
243 | 276 | FreeRTOS_IRQ_Handler:
|
|
0 commit comments