Commit 994cc0d9 authored by Timothy E Baldwin's avatar Timothy E Baldwin Committed by ROOL
Browse files

Eliminate callback check to Portable_Idle races

Previously both `RdchInkey` and `PageTest` enabled interrupts after
running callbacks before calling Portable_Idle with the result that
callback could be delayed until the next interrupt.

* Change `process_callback_chain` to leave interrupts disabled, and
  rename accordingly.
* Remove redundant check of CallBack_Flag.
* In `PageTest` move running calbacks into `CtrlShiftTest`, so that
  it is immediately before the test.
* Re-enable interrupts at appropriate locations.

Tested on StrongARM Risc PC.

Version 6.44. Tagged as 'Kernel-6_44'
parent 02943d44
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "6.43"
Module_Version SETA 643
Module_MajorVersion SETS "6.44"
Module_Version SETA 644
Module_MinorVersion SETS ""
Module_Date SETS "19 Oct 2020"
Module_ApplicationDate SETS "19-Oct-20"
Module_Date SETS "24 Oct 2020"
Module_ApplicationDate SETS "24-Oct-20"
Module_ComponentName SETS "Kernel"
Module_FullVersion SETS "6.43"
Module_HelpVersion SETS "6.43 (19 Oct 2020)"
Module_FullVersion SETS "6.44"
Module_HelpVersion SETS "6.44 (24 Oct 2020)"
END
/* (6.43)
/* (6.44)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 6.43
#define Module_MajorVersion_CMHG 6.44
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 Oct 2020
#define Module_Date_CMHG 24 Oct 2020
#define Module_MajorVersion "6.43"
#define Module_Version 643
#define Module_MajorVersion "6.44"
#define Module_Version 644
#define Module_MinorVersion ""
#define Module_Date "19 Oct 2020"
#define Module_Date "24 Oct 2020"
#define Module_ApplicationDate "19-Oct-20"
#define Module_ApplicationDate "24-Oct-20"
#define Module_ComponentName "Kernel"
#define Module_FullVersion "6.43"
#define Module_HelpVersion "6.43 (19 Oct 2020)"
#define Module_LibraryVersionInfo "6:43"
#define Module_FullVersion "6.44"
#define Module_HelpVersion "6.44 (24 Oct 2020)"
#define Module_LibraryVersionInfo "6:44"
......@@ -921,7 +921,7 @@ Do_CallBack ; CallBack allowed:
Do_CallBack_postpone_already_clear
TST r11, #CBack_VectorReq ; now process any vector entries
MOV r12,lr
BLNE process_callback_chain
BLNE process_callbacks_disableIRQ
MOV lr,r12
MyCLREX r11, r12 ; CLREX required for the case where transient callbacks have been triggered on exit from IRQ handling
......@@ -958,11 +958,9 @@ Do_CallBack_postpone_already_clear
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Also called from source.pmf.key, during readc
process_callback_chain ROUT
process_callbacks_disableIRQ ROUT
Push "r0-r6, r10-r12, lr" ; save some for the callee too.
MRS r0, CPSR
Push "r0"
LDR r10, =ZeroPage
MSR CPSR_c, #I32_bit + SVC2632 ; ints off while flag updated
......@@ -974,9 +972,7 @@ process_callback_chain ROUT
MSR CPSR_c, #I32_bit + SVC2632 ; ints off while flag updated
LDR r2, [r10, #CallBack_Vector]
TEQ r2, #0
Pull "r0", EQ
MSREQ CPSR_c, r0 ; restore original interrupt state and 32bitness
Pull "r0-r6, r10-r12, PC",EQ
Pull "r0-r6, r10-r12, PC",EQ ; Leave interrupts disabled
LDMIA r2, {r1, r11, r12} ; link, addr, r12
MOV r0, #HeapReason_Free
......
......@@ -1025,17 +1025,7 @@ RdchLoop
; Enable interrupts so that keyboard can work properly
CLI SVC32_mode
; Sam's hack to call the callback vector if appropriate
LDR R0, =ZeroPage
LDRB R14, [R0, #CallBack_Flag]
TST R14, #CBack_VectorReq
BLNE process_callback_chain
; here endeth the hack
; Disable interrupts to prevent a race with Portable_Idle
SEI SVC32_mode
BL process_callbacks_disableIRQ
LDR R0, =ZeroPage
LDRB R0, [R0, #ESC_Status]
......
......@@ -2954,35 +2954,38 @@ DoOSBYTE87
; in: R6 = CursorFlags
;
; CtrlShiftTest disables interrupts so re-enable them before adjusting
; cursor, but not before calling Page_Idle, which also reenables them.
PageTest
Push R14
BL Page_ProcessCallbacks ; give callbacks at least one chance per line
BL CtrlShiftTest ; on exit, C=CTRL, N=SHIFT
CLI SVC32_mode
BCC Page40 ; CTRL up, then branch
BPL Page20 ; SHIFT up, then branch
; CTRL and SHIFT are down
CLI SVC32_mode
BL ClearLines ; CTRL+SHIFT down, so clear lines
BL PostWrchCursor ; we may be some time, so enable cursor
CSWaitLoop
BL CtrlShiftTest
BCC Page18
BLMI Page_ProcessCallbacksIdle
BLMI Page_Idle
BMI CSWaitLoop ; and wait for change (NB C=1 now)
Page18
BL PreWrchCursor ; get rid of cursor again
Page18
; CTRL and SHIFT are not both down
CLI SVC32_mode
BL PreWrchCursor ; get rid of cursor again
BL CtrlShiftTest
CLI SVC32_mode
BCC Page40 ; [CTRL not down]
Page20
; CTRL down, so wait for auto repeat delay time before continuing
BL PostWrchCursor ; we may be some time, so enable cursor
LDROSB R1, KeyRepRate
......@@ -2992,9 +2995,10 @@ Page30
BCC Page35 ; CTRL no longer down
LDROSB R1, CentiCounter
CMP R1, #1
BLCS Page_ProcessCallbacksIdle
BLCS Page_Idle
BCS Page30 ; loop with carry set
Page35
CLI SVC32_mode
BL PreWrchCursor ; remove cursor again
; CTRL not down, test for page mode
......@@ -3026,6 +3030,7 @@ IncLinesExit
Page50
BL CtrlShiftTest
CLI SVC32_mode
BMI Page55
; Waiting for shift
......@@ -3033,8 +3038,9 @@ Page50
BL PostWrchCursor ; put cursor back on for now
PageWaitLoop
BL CtrlShiftTest
BLPL Page_ProcessCallbacksIdle
BLPL Page_Idle
BPL PageWaitLoop
CLI SVC32_mode
BL PreWrchCursor
Page55
......@@ -3061,18 +3067,28 @@ BotRowCheck
MOV PC, R14
CtrlShiftTest ROUT
Entry
LDR R0, =ZeroPage
[ DebugROMInit
; Allow callback disabling in s.ModHand to work
SEI SVC32_mode
LDRB R14, [R0, #CallBack_Flag]
TST R14, #CBack_VectorReq
BLNE process_callbacks_disableIRQ
|
BL process_callbacks_disableIRQ
]
LDRB R0, [R0, #ESC_Status]
TST R0, #&40 ; escape condition ?
LDROSB R0, KeyBdStatus ; (preserves PSR)
BEQ %FT10 ; [no escape]
Push R14
BIC R0, R0, #KBStat_ScrollLock ; escape, so cancel scroll lock
STROSB R0, KeyBdStatus, R14 ; and store back
MOV R0, #&20 ; pretend shift down, ctrl up
MOVS R0, R0, LSL #(32-6) ; C=CTRL, N=SHIFT
Pull PC
EXIT
10
TST R0, #&08 ; shift bit
......@@ -3081,28 +3097,15 @@ CtrlShiftTest ROUT
TST R0, #KBStat_ScrollLock ; if scroll lock on
ORRNE R0, R0, #&60 ; then pretend ctrl and shift down
MOVS R0, R0, LSL #(32-6) ; C=CTRL, N=SHIFT
MOV PC, R14
Page_ProcessCallbacks
Entry
; See if there are any pending callbacks
LDR R0, =ZeroPage
LDRB R14, [R0, #CallBack_Flag]
TST R14, #CBack_VectorReq
BLNE process_callback_chain
EXIT
Page_ProcessCallbacksIdle
Page_Idle
EntryS ; routine must preserve flags
; See if there are any pending callbacks
LDR R0, =ZeroPage
LDRB R14, [R0, #CallBack_Flag]
TST R14, #CBack_VectorReq
BLNE process_callback_chain
; Now they're dealt with, we have nothing else to do, so call Idle
LDRB R14, [r0, #PortableFlags]
TST R14, #PortableFeature_Idle
SWINE XPortable_Idle
CLI SVC32_mode
EXITS
; *****************************************************************************
......
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