mirror of
				https://github.com/FreeRTOS/FreeRTOS-Kernel.git
				synced 2025-11-04 02:32:42 -05:00 
			
		
		
		
	armv8-m: Modify ARMv8-M registers stacking procedure
ARMv8-M TrustZone variant registers stacking procedure is modified to be consistent with the NTZ port variant where one `stmdb` instruction is used instead of using 'subs' instruction along with `stmia` instruction, also, this result in more efficient context switching handling (lower latency). Signed-off-by: Ahmed Ismail <Ahmed.Ismail@arm.com>
This commit is contained in:
		
							parent
							
								
									3a7b3082cf
								
							
						
					
					
						commit
						c84fc7226e
					
				
					 10 changed files with 60 additions and 130 deletions
				
			
		| 
						 | 
					@ -419,31 +419,24 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
 | 
				
			||||||
            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB.*/
 | 
					 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   b select_next_task                              \n"
 | 
					            "   b select_next_task                              \n"
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " save_ns_context:                                  \n"
 | 
					            " save_ns_context:                                  \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
                "   it eq                                       \n"
 | 
					                "   it eq                                       \n"
 | 
				
			||||||
                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
					                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
            "   subs r2, r2, #44                                \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					            "   stmdb r2!, {r4-r11}                             \n" /* Store the registers that are not saved automatically. */
 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   adds r2, r2, #12                                \n" /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
            "   stm r2, {r4-r11}                                \n" /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* r2 = r2 - 12. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " select_next_task:                                 \n"
 | 
					            " select_next_task:                                 \n"
 | 
				
			||||||
            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
					            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -381,31 +381,24 @@ PendSV_Handler:
 | 
				
			||||||
    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ldr r3, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
    ldr r1, [r3]                            /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    subs r2, r2, #12                        /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
    str r2, [r1]                            /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
					    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
				
			||||||
    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
					    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
    stmia r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					    stmdb r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
    b select_next_task
 | 
					    b select_next_task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save_ns_context:
 | 
					    save_ns_context:
 | 
				
			||||||
        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
        it eq
 | 
					        it eq
 | 
				
			||||||
        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
					        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
        subs r2, r2, #44                    /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					        stmdb r2!, {r4-r11}                 /* Store the registers that are not saved automatically. */
 | 
				
			||||||
        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
        adds r2, r2, #12                    /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
        stm r2, {r4-r11}                    /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
					        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
				
			||||||
        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
					        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
        subs r2, r2, #12                    /* r2 = r2 - 12. */
 | 
					        stmdb r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
        stmia r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    select_next_task:
 | 
					    select_next_task:
 | 
				
			||||||
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
					        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -419,31 +419,24 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
 | 
				
			||||||
            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB.*/
 | 
					 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   b select_next_task                              \n"
 | 
					            "   b select_next_task                              \n"
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " save_ns_context:                                  \n"
 | 
					            " save_ns_context:                                  \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
                "   it eq                                       \n"
 | 
					                "   it eq                                       \n"
 | 
				
			||||||
                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
					                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
            "   subs r2, r2, #44                                \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					            "   stmdb r2!, {r4-r11}                             \n" /* Store the registers that are not saved automatically. */
 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   adds r2, r2, #12                                \n" /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
            "   stm r2, {r4-r11}                                \n" /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* r2 = r2 - 12. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " select_next_task:                                 \n"
 | 
					            " select_next_task:                                 \n"
 | 
				
			||||||
            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
					            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -419,31 +419,24 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
 | 
				
			||||||
            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB.*/
 | 
					 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   b select_next_task                              \n"
 | 
					            "   b select_next_task                              \n"
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " save_ns_context:                                  \n"
 | 
					            " save_ns_context:                                  \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
                "   it eq                                       \n"
 | 
					                "   it eq                                       \n"
 | 
				
			||||||
                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
					                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
            "   subs r2, r2, #44                                \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					            "   stmdb r2!, {r4-r11}                             \n" /* Store the registers that are not saved automatically. */
 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   adds r2, r2, #12                                \n" /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
            "   stm r2, {r4-r11}                                \n" /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* r2 = r2 - 12. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " select_next_task:                                 \n"
 | 
					            " select_next_task:                                 \n"
 | 
				
			||||||
            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
					            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -419,31 +419,24 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
 | 
				
			||||||
            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB.*/
 | 
					 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   b select_next_task                              \n"
 | 
					            "   b select_next_task                              \n"
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " save_ns_context:                                  \n"
 | 
					            " save_ns_context:                                  \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
                "   it eq                                       \n"
 | 
					                "   it eq                                       \n"
 | 
				
			||||||
                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
					                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
            "   subs r2, r2, #44                                \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					            "   stmdb r2!, {r4-r11}                             \n" /* Store the registers that are not saved automatically. */
 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   adds r2, r2, #12                                \n" /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
            "   stm r2, {r4-r11}                                \n" /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* r2 = r2 - 12. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " select_next_task:                                 \n"
 | 
					            " select_next_task:                                 \n"
 | 
				
			||||||
            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
					            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -419,31 +419,24 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
 | 
				
			||||||
            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					            "   lsls r1, r3, #25                                \n" /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					            "   bpl save_ns_context                             \n" /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB.*/
 | 
					 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   b select_next_task                              \n"
 | 
					            "   b select_next_task                              \n"
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " save_ns_context:                                  \n"
 | 
					            " save_ns_context:                                  \n"
 | 
				
			||||||
            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					            #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					                "   tst lr, #0x10                               \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
                "   it eq                                       \n"
 | 
					                "   it eq                                       \n"
 | 
				
			||||||
                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
					                "   vstmdbeq r2!, {s16-s31}                     \n" /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					            #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
            "   subs r2, r2, #44                                \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					            "   stmdb r2!, {r4-r11}                             \n" /* Store the registers that are not saved automatically. */
 | 
				
			||||||
            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
            "   adds r2, r2, #12                                \n" /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
            "   stm r2, {r4-r11}                                \n" /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
					            "   mrs r1, psplim                                  \n" /* r1 = PSPLIM. */
 | 
				
			||||||
            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
					            "   mov r3, lr                                      \n" /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
            "   subs r2, r2, #12                                \n" /* r2 = r2 - 12. */
 | 
					            "   stmdb r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
            "   stmia r2!, {r0, r1, r3}                         \n" /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					            "   ldr r3, =pxCurrentTCB                           \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					            "   ldr r1, [r3]                                    \n" /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					            "   str r2, [r1]                                    \n" /* Save the new top of stack in TCB. */
 | 
				
			||||||
            "                                                   \n"
 | 
					            "                                                   \n"
 | 
				
			||||||
            " select_next_task:                                 \n"
 | 
					            " select_next_task:                                 \n"
 | 
				
			||||||
            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
					            "   mov r0, %0                                      \n" /* r0 = configMAX_SYSCALL_INTERRUPT_PRIORITY */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -381,31 +381,24 @@ PendSV_Handler:
 | 
				
			||||||
    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ldr r3, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
    ldr r1, [r3]                            /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    subs r2, r2, #12                        /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
    str r2, [r1]                            /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
					    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
				
			||||||
    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
					    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
    stmia r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					    stmdb r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
    b select_next_task
 | 
					    b select_next_task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save_ns_context:
 | 
					    save_ns_context:
 | 
				
			||||||
        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
        it eq
 | 
					        it eq
 | 
				
			||||||
        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
					        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
        subs r2, r2, #44                    /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					        stmdb r2!, {r4-r11}                 /* Store the registers that are not saved automatically. */
 | 
				
			||||||
        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
        adds r2, r2, #12                    /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
        stm r2, {r4-r11}                    /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
					        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
				
			||||||
        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
					        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
        subs r2, r2, #12                    /* r2 = r2 - 12. */
 | 
					        stmdb r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
        stmia r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    select_next_task:
 | 
					    select_next_task:
 | 
				
			||||||
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
					        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -381,31 +381,24 @@ PendSV_Handler:
 | 
				
			||||||
    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ldr r3, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
    ldr r1, [r3]                            /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    subs r2, r2, #12                        /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
    str r2, [r1]                            /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
					    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
				
			||||||
    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
					    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
    stmia r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					    stmdb r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
    b select_next_task
 | 
					    b select_next_task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save_ns_context:
 | 
					    save_ns_context:
 | 
				
			||||||
        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
        it eq
 | 
					        it eq
 | 
				
			||||||
        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
					        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
        subs r2, r2, #44                    /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					        stmdb r2!, {r4-r11}                 /* Store the registers that are not saved automatically. */
 | 
				
			||||||
        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
        adds r2, r2, #12                    /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
        stm r2, {r4-r11}                    /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
					        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
				
			||||||
        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
					        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
        subs r2, r2, #12                    /* r2 = r2 - 12. */
 | 
					        stmdb r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
        stmia r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    select_next_task:
 | 
					    select_next_task:
 | 
				
			||||||
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
					        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -381,31 +381,24 @@ PendSV_Handler:
 | 
				
			||||||
    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ldr r3, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
    ldr r1, [r3]                            /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    subs r2, r2, #12                        /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
    str r2, [r1]                            /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
					    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
				
			||||||
    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
					    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
    stmia r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					    stmdb r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
    b select_next_task
 | 
					    b select_next_task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save_ns_context:
 | 
					    save_ns_context:
 | 
				
			||||||
        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
        it eq
 | 
					        it eq
 | 
				
			||||||
        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
					        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
        subs r2, r2, #44                    /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					        stmdb r2!, {r4-r11}                 /* Store the registers that are not saved automatically. */
 | 
				
			||||||
        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
        adds r2, r2, #12                    /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
        stm r2, {r4-r11}                    /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
					        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
				
			||||||
        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
					        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
        subs r2, r2, #12                    /* r2 = r2 - 12. */
 | 
					        stmdb r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
        stmia r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    select_next_task:
 | 
					    select_next_task:
 | 
				
			||||||
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
					        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -381,31 +381,24 @@ PendSV_Handler:
 | 
				
			||||||
    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
					    lsls r1, r3, #25                        /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
 | 
				
			||||||
    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
					    bpl save_ns_context                     /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ldr r3, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
    ldr r1, [r3]                            /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    subs r2, r2, #12                        /* Make space for xSecureContext, PSPLIM and LR on the stack. */
 | 
					 | 
				
			||||||
    str r2, [r1]                            /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
					    mrs r1, psplim                          /* r1 = PSPLIM. */
 | 
				
			||||||
    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
					    mov r3, lr                              /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
    stmia r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					    stmdb r2!, {r0, r1, r3}                 /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
    b select_next_task
 | 
					    b select_next_task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save_ns_context:
 | 
					    save_ns_context:
 | 
				
			||||||
        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
					 | 
				
			||||||
        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
					 | 
				
			||||||
    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
					    #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
 | 
				
			||||||
        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
					        tst lr, #0x10                       /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
 | 
				
			||||||
        it eq
 | 
					        it eq
 | 
				
			||||||
        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
					        vstmdbeq r2!, {s16-s31}             /* Store the additional FP context registers which are not saved automatically. */
 | 
				
			||||||
    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
					    #endif /* configENABLE_FPU || configENABLE_MVE */
 | 
				
			||||||
        subs r2, r2, #44                    /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
 | 
					        stmdb r2!, {r4-r11}                 /* Store the registers that are not saved automatically. */
 | 
				
			||||||
        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
					 | 
				
			||||||
        adds r2, r2, #12                    /* r2 = r2 + 12. */
 | 
					 | 
				
			||||||
        stm r2, {r4-r11}                    /* Store the registers that are not saved automatically. */
 | 
					 | 
				
			||||||
        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
					        mrs r1, psplim                      /* r1 = PSPLIM. */
 | 
				
			||||||
        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
					        mov r3, lr                          /* r3 = LR/EXC_RETURN. */
 | 
				
			||||||
        subs r2, r2, #12                    /* r2 = r2 - 12. */
 | 
					        stmdb r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
				
			||||||
        stmia r2!, {r0, r1, r3}             /* Store xSecureContext, PSPLIM and LR on the stack. */
 | 
					        ldr r3, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
 | 
				
			||||||
 | 
					        ldr r1, [r3]                        /* Read pxCurrentTCB. */
 | 
				
			||||||
 | 
					        str r2, [r1]                        /* Save the new top of stack in TCB. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    select_next_task:
 | 
					    select_next_task:
 | 
				
			||||||
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
					        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue