Commit b68b72d7 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Make the Wimp automatically switch VFP contexts

Detail:
  s/Wimp, s/Wimp01, s/Wimp02, s/Wimp03, s/Wimp07 - The Wimp now uses the VFPSupport module to switch VFP contexts when performing task switches.
  Each task begins with the null context active (i.e. no VFP/NEON access). When paging out a task the ID of the active context is saved in the Wimp's per-task workspace. This context is then restored when the task is about to be resumed.
  Context save/restore is performed while the right task's memory is paged in, so it's safe to use with contexts located in application space.
Admin:
  Tested with Iyonix & Beagle ROM builds.


Version 5.09. Tagged as 'Wimp-5_09'
parent 8bfdcfc3
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.08"
Module_Version SETA 508
Module_MajorVersion SETS "5.09"
Module_Version SETA 509
Module_MinorVersion SETS ""
Module_Date SETS "14 Mar 2010"
Module_ApplicationDate SETS "14-Mar-10"
Module_Date SETS "26 Nov 2010"
Module_ApplicationDate SETS "26-Nov-10"
Module_ComponentName SETS "Wimp"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/Wimp"
Module_FullVersion SETS "5.08"
Module_HelpVersion SETS "5.08 (14 Mar 2010)"
Module_FullVersion SETS "5.09"
Module_HelpVersion SETS "5.09 (26 Nov 2010)"
END
/* (5.08)
/* (5.09)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.08
#define Module_MajorVersion_CMHG 5.09
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Mar 2010
#define Module_Date_CMHG 26 Nov 2010
#define Module_MajorVersion "5.08"
#define Module_Version 508
#define Module_MajorVersion "5.09"
#define Module_Version 509
#define Module_MinorVersion ""
#define Module_Date "14 Mar 2010"
#define Module_Date "26 Nov 2010"
#define Module_ApplicationDate "14-Mar-10"
#define Module_ApplicationDate "26-Nov-10"
#define Module_ComponentName "Wimp"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/Wimp"
#define Module_FullVersion "5.08"
#define Module_HelpVersion "5.08 (14 Mar 2010)"
#define Module_LibraryVersionInfo "5:8"
#define Module_FullVersion "5.09"
#define Module_HelpVersion "5.09 (26 Nov 2010)"
#define Module_LibraryVersionInfo "5:9"
......@@ -58,6 +58,7 @@ Module_BaseAddr
GET hdr:ScrBlank
GET hdr:OsWords
GET hdr:Countries
GET hdr:VFPSupport
GET VersionASM
......
......@@ -613,6 +613,7 @@ priority_top * 1:SHL:20
task_environment # 4*3*MaxEnvNumber ; environment pointers
task_registers # 4*17 ; USR register set
task_vfpcontext # 4 ; VFPSupport context ID
task_datasize # 0
; extra bits for Wimp_Poll - not stored in task_flagword
......
......@@ -51,6 +51,7 @@ markinitialised
STR R14,[R2,#task_fpblock]
STR R14,[R2,#task_windows]
STR R14,[R2,#task_messagessize]
STR R14,[R2,#task_vfpcontext]
MOV R14,#-1
STR R14,[R2,#task_messages] ; flag as accepting all messages
......
......@@ -437,6 +437,15 @@ SWIWimp_Poll
STR userblk,[R4,#task_registers+4*1] ; and user R1
STR R2,[R4,#task_registers+4*2] ; and target time
;
; save VFP context. Can't save lazily since it might be in application space.
;
MOV R0,#0
MOV R1,#0
SWI XVFPSupport_ChangeContext
MOVVS R0,#0 ; Ignore error (probably means VFPSupport isn't loaded)
STR R0,[R4,#task_vfpcontext]
CLRV
;
; check to see if there are any more outstanding parents
;
taskisused
......
......@@ -747,6 +747,16 @@ SWIWimp_StartTask
BLVC saveFPregs ; R4 -> task block
BVS ExitWimp
;
; save VFP context. Can't save lazily since it might be in application space.
;
Push "R0-R1"
MOV R0,#0
MOV R1,#0
SWI XVFPSupport_ChangeContext
MOVVS R0,#0 ; Ignore error (probably means VFPSupport isn't loaded)
STR R0,[R4,#task_vfpcontext]
Pull "R0-R1"
;
; find a spare task handle for the new task
;
ADRL R5,taskpointers
......@@ -1074,56 +1084,62 @@ returnerror
01
]
Push "R0-R1"
LDR R4,[wsptr,handle]
TEQ R4,#task_unused
[ debugtask4
; Stamp with event time for task priority and swapping
Push "R0",NE
SWINE XOS_ReadMonotonicTime
BEQ %FT00
Debug task4,"Time",R0
00
STRNE R0,[R4,#task_eventtime]
Pull "R0",NE
]
; restore FP registers if they were saved (ie. save block present)
LDRNE R4,[R4,#task_fpblock]
TEQNE R4,#0 ; NE => restore registers
LDRNE R0,[R4,#task_fpblock]
TEQNE R0,#0 ; NE => restore registers
MOVEQ R5,#C_runtime_status ; ensure caller gets &70000 if he didn't save regs
WFSEQ R5
BEQ %FT01
Debug fp,"Restoring FP state from block at",R4
Debug fp,"Restoring FP state from block at",R0
MOV R5,#0 ; avoid FP exceptions
WFS R5 ; will still occur if FPEmulator RMKilled
[ FPE4
[ false
LFM F0,4,[R4,#fp_reg0] ; (only gets here if active previously)
LFM F4,4,[R4,#fp_reg4]
LFM F0,4,[R0,#fp_reg0] ; (only gets here if active previously)
LFM F4,4,[R0,#fp_reg4]
|
; AAsm assembles the above as post-indexed not pre-indexed.
; Do it manually (bluch).
DCD &ED940200 :OR: (fp_reg0:SHR:2)
DCD &ED944200 :OR: (fp_reg4:SHR:2)
DCD &ED900200 :OR: (fp_reg0:SHR:2)
DCD &ED904200 :OR: (fp_reg4:SHR:2)
]
|
LDFE F0,[R4,#fp_reg0] ; (only gets here if active previously)
LDFE F1,[R4,#fp_reg1]
LDFE F2,[R4,#fp_reg2]
LDFE F3,[R4,#fp_reg3]
LDFE F4,[R4,#fp_reg4]
LDFE F5,[R4,#fp_reg5]
LDFE F6,[R4,#fp_reg6]
LDFE F7,[R4,#fp_reg7]
LDFE F0,[R0,#fp_reg0] ; (only gets here if active previously)
LDFE F1,[R0,#fp_reg1]
LDFE F2,[R0,#fp_reg2]
LDFE F3,[R0,#fp_reg3]
LDFE F4,[R0,#fp_reg4]
LDFE F5,[R0,#fp_reg5]
LDFE F6,[R0,#fp_reg6]
LDFE F7,[R0,#fp_reg7]
]
LDR R5,[R4,#fp_status]
LDR R5,[R0,#fp_status]
WFS R5
01
; restore VFP context
TEQ R4,#task_unused
LDRNE R0,[R4,#task_vfpcontext]
MOVNE R1,#VFPSupport_ChangeContext_Lazy
TEQNE R0,#0 ; We should already be on the null context, so only call if user does have a context to restore
SWINE XVFPSupport_ChangeContext
Pull "R0-R1"
;
[ StartTaskPostFilter
LDR R14,sender
......
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