Commit d64fdb08 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

Use OS_TaskControl 0 to reset the SVC stack

Instead of manually resetting the SVC stack pointer when starting a new
task, prefer to use the stack reset routine that's exposed by
OS_TaskControl 0 in RISC OS Select / 5. If that routine isn't available,
fall back to the old method of doing it manually.

Requires Kernel-6_61 to build.
parent 5944f979
......@@ -342,8 +342,6 @@ Run_UndatedFile
MOV r1, r0 ; NB. Our strings are all dead now
BL SkipOverNameAndSpaces ; r1 -> copy of command tail
LDR r10, SVCSTK ; remember top of stack
;Check whether it's a squeezed app.
CMP r2, #&8000
BNE %FT77 ;Not an 'APP' (type FF8)
......@@ -427,13 +425,17 @@ Run_UndatedFile
]
77
MOV sp, r10 ; Flatten superstack, we don't return
MOV r8, r2
MOV lr, pc
LDR pc, ResetSVCStack ; R0-R3 corrupt, stack(s) reset
WritePSRc 0, r12 ; USR mode, all ints on
; Note: Compressed demoscene code produced by codepressor may assume
; that R4 is the file load address.
MOV r12, #&80000000 ; Cause address extinction if used
MOV r13, #&80000000 ; (keep 1.20 compat capable)
ADR lr, ReturnFromAbsoluteCode
MOV pc, r2 ; Go to it !
MOV pc, r8 ; Go to it !
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Type FFC
......
......@@ -397,7 +397,7 @@ streamtable # streamtable_size
EnvStringAddr # 4 ; Only needed when we're not bound to kernel
EnvTimeAddr # 4
SVCSTK # 4
ResetSVCStack # 4 ; Routine to reset the SVC stack pointer (and the other stacks, if OS_TaskControl 0 is available)
SysHeapStart # 4
ptr_DomainId # 4 ; Pointer to kernel's DomainId var
......@@ -788,15 +788,10 @@ FileSwitch_Init Entry "r7"
STR r0, EnvStringAddr ; in soft loaded version
STR r2, EnvTimeAddr
MOV r0, #6
MOV r1, #0
MOV r2, #OSRSI6_SVCSTK
SWI XOS_ReadSysInfo
MOVVS r2, #0
TEQ r2, #0
MOVEQ r2, #&01C00000
ADDEQ r2, r2, #&2000
STR r2, SVCSTK
MOV r0, #0
SWI XOS_TaskControl
ADRVSL r0, ResetSVCStack_Old ; Use manual stack reset code if OS_TaskControl unavailable
STR r0, ResetSVCStack
MOV r0, #6
MOV r1, #0
......@@ -937,6 +932,21 @@ fsw_varcount SETA fsw_varcount + 4
BL Init_InvalidateBGetCache
EXIT
; Out: R0-R3 corrupt, SVC stack reset
ResetSVCStack_Old
MOV r3, lr
; Try getting top of SVC stack from OS_ReadSysInfo 6
MOV r0, #6
MOV r1, #0
MOV r2, #OSRSI6_SVCSTK
SWI XOS_ReadSysInfo
MOVVS r2, #0
TEQ r2, #0
MOVEQ r2, #&01C00000 ; RISC OS 3 era address
ADDEQ r2, r2, #&2000
MOV r13, r2
MOV pc, r3
FileSwitch_FirstVariableToCreate * .
; ************************** Path variables ***********************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment