Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RTX5: added callback for MPU loading (experimental)
  • Loading branch information
RobertRostohar committed Dec 7, 2017
1 parent ff44f52 commit 0e45768
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CMSIS/RTOS2/RTX/Source/ARM/irq_armv8mbl.s
Expand Up @@ -51,6 +51,9 @@ SVC_Handler PROC
EXPORT SVC_Handler
IMPORT osRtxUserSVC
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF
IF DOMAIN_NS = 1
IMPORT TZ_LoadContext_S
IMPORT TZ_StoreContext_S
Expand Down Expand Up @@ -114,6 +117,13 @@ SVC_ContextSwitch
SUBS R3,R3,#8 ; Adjust address
STR R2,[R3] ; osRtxInfo.thread.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

SVC_ContextRestore
IF DOMAIN_NS = 1
LDR R0,[R2,#TCB_TZM_OFS] ; Load TrustZone memory identifier
Expand Down Expand Up @@ -215,6 +225,9 @@ SysTick_Handler PROC
Sys_Context PROC
EXPORT Sys_Context
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF
IF DOMAIN_NS = 1
IMPORT TZ_LoadContext_S
IMPORT TZ_StoreContext_S
Expand Down Expand Up @@ -262,6 +275,13 @@ Sys_ContextSwitch
SUBS R3,R3,#8 ; Adjust address
STR R2,[R3] ; osRtxInfo.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

Sys_ContextRestore
IF DOMAIN_NS = 1
LDR R0,[R2,#TCB_TZM_OFS] ; Load TrustZone memory identifier
Expand Down
20 changes: 20 additions & 0 deletions CMSIS/RTOS2/RTX/Source/ARM/irq_armv8mml.s
Expand Up @@ -57,6 +57,9 @@ SVC_Handler PROC
EXPORT SVC_Handler
IMPORT osRtxUserSVC
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF
IF DOMAIN_NS = 1
IMPORT TZ_LoadContext_S
IMPORT TZ_StoreContext_S
Expand Down Expand Up @@ -123,6 +126,13 @@ SVC_ContextSave2
SVC_ContextSwitch
STR R2,[R3] ; osRtxInfo.thread.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

SVC_ContextRestore
IF DOMAIN_NS = 1
LDR R0,[R2,#TCB_TZM_OFS] ; Load TrustZone memory identifier
Expand Down Expand Up @@ -205,6 +215,9 @@ SysTick_Handler PROC
Sys_Context PROC
EXPORT Sys_Context
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF
IF DOMAIN_NS = 1
IMPORT TZ_LoadContext_S
IMPORT TZ_StoreContext_S
Expand Down Expand Up @@ -245,6 +258,13 @@ Sys_ContextSave2
Sys_ContextSwitch
STR R2,[R3] ; osRtxInfo.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

Sys_ContextRestore
IF DOMAIN_NS = 1
LDR R0,[R2,#TCB_TZM_OFS] ; Load TrustZone memory identifier
Expand Down
10 changes: 10 additions & 0 deletions CMSIS/RTOS2/RTX/Source/ARM/irq_cm0.s
Expand Up @@ -44,6 +44,9 @@ SVC_Handler PROC
EXPORT SVC_Handler
IMPORT osRtxUserSVC
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF

MOV R0,LR
LSRS R0,R0,#3 ; Determine return stack from EXC_RETURN bit 2
Expand Down Expand Up @@ -88,6 +91,13 @@ SVC_ContextSwitch
SUBS R3,R3,#8 ; Adjust address
STR R2,[R3] ; osRtxInfo.thread.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

SVC_ContextRestore
LDR R0,[R2,#TCB_SP_OFS] ; Load SP
ADDS R0,R0,#16 ; Adjust address
Expand Down
10 changes: 10 additions & 0 deletions CMSIS/RTOS2/RTX/Source/ARM/irq_cm3.s
Expand Up @@ -44,6 +44,9 @@ SVC_Handler PROC
EXPORT SVC_Handler
IMPORT osRtxUserSVC
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF

TST LR,#0x04 ; Determine return stack from EXC_RETURN bit 2
ITE EQ
Expand Down Expand Up @@ -76,6 +79,13 @@ SVC_ContextSave
SVC_ContextSwitch
STR R2,[R3] ; osRtxInfo.thread.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

SVC_ContextRestore
LDR R0,[R2,#TCB_SP_OFS] ; Load SP
LDMIA R0!,{R4-R11} ; Restore R4..R11
Expand Down
10 changes: 10 additions & 0 deletions CMSIS/RTOS2/RTX/Source/ARM/irq_cm4f.s
Expand Up @@ -45,6 +45,9 @@ SVC_Handler PROC
EXPORT SVC_Handler
IMPORT osRtxUserSVC
IMPORT osRtxInfo
IF :DEF:MPU_LOAD
IMPORT osRtxMpuLoad
ENDIF

TST LR,#0x04 ; Determine return stack from EXC_RETURN bit 2
ITE EQ
Expand Down Expand Up @@ -88,6 +91,13 @@ SVC_ContextSave
SVC_ContextSwitch
STR R2,[R3] ; osRtxInfo.thread.run: curr = next

IF :DEF:MPU_LOAD
PUSH {R2,R3} ; Save registers
MOV R0,R2 ; osRtxMpuLoad parameter
BL osRtxMpuLoad ; Load MPU for next thread
POP {R2,R3} ; Restore registers
ENDIF

SVC_ContextRestore
LDRB R1,[R2,#TCB_SF_OFS] ; Load stack frame information
LDR R0,[R2,#TCB_SP_OFS] ; Load SP
Expand Down

0 comments on commit 0e45768

Please sign in to comment.