Commit 66b9745b authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Extend possible range of OS_Call[After|Every]

OS_CallAfter and OS_CallEvery were treating the delay in R0 as a signed number, limiting its possible range. The PRM didn't require this (a -ve delay doesn't make sense, so implicitly times are unsigned), reworked to allow times up to 0xFFFFFBFF.
Aside:
  OSLib exports these functions as 'int', but it doesn't seem to make a distinction for unsigned versus signed anyway (other unsigned arguments are plain int too)
  The 'callx' library was already prototyped with unsigned times back in 1997

Added comment to hdr/Options about FirstUnpluggableModule - since the keyboard and mouse drivers got moved out of the kernel in 3.50, the original intent (to not allow you to unplug vital modules) has long since been lost, and really the only use of this value is to save 8 bits of CMOS frugal bits.

Version 5.35, 4.79.2.181. Tagged as 'Kernel-5_35-4_79_2_181'
parent b9898460
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "5.35" Module_MajorVersion SETS "5.35"
Module_Version SETA 535 Module_Version SETA 535
Module_MinorVersion SETS "4.79.2.180" Module_MinorVersion SETS "4.79.2.181"
Module_Date SETS "10 Jan 2013" Module_Date SETS "17 Jan 2013"
Module_ApplicationDate SETS "10-Jan-13" Module_ApplicationDate SETS "17-Jan-13"
Module_ComponentName SETS "Kernel" Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel" Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.35 (4.79.2.180)" Module_FullVersion SETS "5.35 (4.79.2.181)"
Module_HelpVersion SETS "5.35 (10 Jan 2013) 4.79.2.180" Module_HelpVersion SETS "5.35 (17 Jan 2013) 4.79.2.181"
END END
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
* *
*/ */
#define Module_MajorVersion_CMHG 5.35 #define Module_MajorVersion_CMHG 5.35
#define Module_MinorVersion_CMHG 4.79.2.180 #define Module_MinorVersion_CMHG 4.79.2.181
#define Module_Date_CMHG 10 Jan 2013 #define Module_Date_CMHG 17 Jan 2013
#define Module_MajorVersion "5.35" #define Module_MajorVersion "5.35"
#define Module_Version 535 #define Module_Version 535
#define Module_MinorVersion "4.79.2.180" #define Module_MinorVersion "4.79.2.181"
#define Module_Date "10 Jan 2013" #define Module_Date "17 Jan 2013"
#define Module_ApplicationDate "10-Jan-13" #define Module_ApplicationDate "17-Jan-13"
#define Module_ComponentName "Kernel" #define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel" #define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.35 (4.79.2.180)" #define Module_FullVersion "5.35 (4.79.2.181)"
#define Module_HelpVersion "5.35 (10 Jan 2013) 4.79.2.180" #define Module_HelpVersion "5.35 (17 Jan 2013) 4.79.2.181"
#define Module_LibraryVersionInfo "5:35" #define Module_LibraryVersionInfo "5:35"
...@@ -329,8 +329,8 @@ ConfiguredLang SETA 10 ...@@ -329,8 +329,8 @@ ConfiguredLang SETA 10
GBLA FirstUnpluggableModule GBLA FirstUnpluggableModule
FirstUnpluggableModule SETA 8 ; Podule, FileSwitch, ResourceFS, Messages, MessageTrans, FirstUnpluggableModule SETA 8 ; Podule, FileSwitch, ResourceFS, Messages, MessageTrans,
; TerritoryManager, UKTerritory ; TerritoryManager, UK. Moot now the keyboard and mouse aren't
; in the kernel - unplug those and you're stuffed.
[ DebugForcedReset [ DebugForcedReset
Reset_CannotResetFlag * 1 Reset_CannotResetFlag * 1
Reset_SysHeapCorrupt * 2 Reset_SysHeapCorrupt * 2
......
...@@ -17,23 +17,27 @@ ...@@ -17,23 +17,27 @@
; This file revised by TMD 28-Jan-94 to ; This file revised by TMD 28-Jan-94 to
; a) Correct internals to time n ticks not n+1 ; a) Correct internals to time n ticks not n+1
; b) Change externals to add 1 to compensate for user subtracting 1 ; b) Change externals to add 1 to compensate for user subtracting 1
; c) Fix RemoveTickerEvent to add this nodes time onto the next one ; c) Fix RemoveTickerEvent to add this node's time onto the next one
; These fix bug MED-02498. ; These fix bug MED-02498.
; There are two (centisecond) ticker SWIs : ; There are two (centisecond) ticker SWIs :
; SWI CallAfter calls the given address once, after the given number of ticks ; SWI CallAfter calls the given address once, after the given number of ticks
; SWI CallEvery " " " " every N centiseconds ; SWI CallEvery " " " " every N centiseconds
; In : R0 is (signed) number of centiseconds ; In : R0 is unsigned number of centiseconds
; R1 is address to call ; R1 is address to call
; R2 is value of R12 to pass to code ; R2 is value of R12 to pass to code
CallEvery_Code
ADD r10, r0, #1 ; compensate for n+1 bug
B TickTockCommon
CallAfter_Code ROUT CallAfter_Code ROUT
MOV r10, #0 MOV r10, #0
TickTockCommon TickTockCommon
Push "r0-r3, lr" Push "r0-r3, lr"
CMP r0, #0 ADD r14, r0, #1024
BLE %FT99 CMP r14, #1024
BLS %FT99 ; reject 0 and >= &FFFFFC00
[ ChocolateSysHeap [ ChocolateSysHeap
ASSERT ChocolateTKBlocks = ChocolateBlockArrays + 8 ASSERT ChocolateTKBlocks = ChocolateBlockArrays + 8
...@@ -72,9 +76,6 @@ TickTockCommon ...@@ -72,9 +76,6 @@ TickTockCommon
MakeErrorBlock BadTime MakeErrorBlock BadTime
CallEvery_Code
ADD r10, r0, #1 ; compensate for n+1 bug
B TickTockCommon
; Data structure : ; Data structure :
; chain of nodes ; chain of nodes
...@@ -111,8 +112,8 @@ InsertTickerEvent ROUT ...@@ -111,8 +112,8 @@ InsertTickerEvent ROUT
; R1 is node pointer, R0 ticks to wait ; R1 is node pointer, R0 ticks to wait
; R10-R12 corrupted ; R10-R12 corrupted
Push "r0,r2" Push "r0,lr"
PHPSEI r2 PHPSEI r14
LDR r10, =ZeroPage+TickNodeChain LDR r10, =ZeroPage+TickNodeChain
01 01
MOV r11, r10 MOV r11, r10
...@@ -120,9 +121,9 @@ InsertTickerEvent ROUT ...@@ -120,9 +121,9 @@ InsertTickerEvent ROUT
CMP r10, #0 CMP r10, #0
BEQ %FT02 ; end of chain BEQ %FT02 ; end of chain
LDR r12, [r10, #TickNodeLeft] LDR r12, [r10, #TickNodeLeft]
SUBS r0, r0, r12 CMP r12, r0
BGE %BT01 SUBLS r0, r0, r12
ADD r0, r0, r12 BLS %BT01 ; node R10 is earlier (or equal) to node R1
SUB r12, r12, r0 SUB r12, r12, r0
STR r12, [r10, #TickNodeLeft] STR r12, [r10, #TickNodeLeft]
02 02
...@@ -130,9 +131,8 @@ InsertTickerEvent ROUT ...@@ -130,9 +131,8 @@ InsertTickerEvent ROUT
STR r0, [r1, #TickNodeLeft] STR r0, [r1, #TickNodeLeft]
STR r10, [r1, #TickNodeLink] STR r10, [r1, #TickNodeLink]
PLP r2 PLP r14
Pull "r0,r2" Pull "r0,pc"
MOV pc, lr
ProcessTickEventChain ROUT ProcessTickEventChain ROUT
; R0-R3, R10-R12 corruptible ; R0-R3, R10-R12 corruptible
...@@ -145,7 +145,7 @@ ProcessTickEventChain ROUT ...@@ -145,7 +145,7 @@ ProcessTickEventChain ROUT
LDR r2, [r1, #TickNodeLeft] LDR r2, [r1, #TickNodeLeft]
SUBS r2, r2, #1 SUBS r2, r2, #1
STR r2, [r1, #TickNodeLeft] STR r2, [r1, #TickNodeLeft]
MOVGT pc, lr ; nothing to call yet (was MOVPL) MOVNE pc, lr ; nothing to call yet (was MOVPL)
Push "lr" ; save IRQ_lr Push "lr" ; save IRQ_lr
[ TickIrqReenter [ TickIrqReenter
...@@ -166,7 +166,7 @@ ProcessTickEventChain ROUT ...@@ -166,7 +166,7 @@ ProcessTickEventChain ROUT
LDR r0, [r1, #TickNodeRedo] LDR r0, [r1, #TickNodeRedo]
CMP r0, #0 ; CallEvery? CMP r0, #0 ; CallEvery?
BLE %FT05 BEQ %FT05
BL InsertTickerEvent ; yes, then re-insert timer BL InsertTickerEvent ; yes, then re-insert timer
B %FT10 B %FT10
...@@ -191,15 +191,15 @@ ProcessTickEventChain ROUT ...@@ -191,15 +191,15 @@ ProcessTickEventChain ROUT
] ]
WritePSRc SVC_mode+I_bit, r1 ; IRQ's off again WritePSRc SVC_mode+I_bit, r1 ; IRQ's off again
; Check for more events down the list ; Check for more events at the same level in the list
10 10
LDR r1, [r3, #TickNodeLink] ; get top of list LDR r1, [r3, #TickNodeLink] ; get top of list
CMP r1, #0 ; list empty? CMP r1, #0 ; list empty?
BEQ %FT02 ; yes then exit BEQ %FT02 ; yes then exit
LDR r0, [r1, #TickNodeLeft] LDR r0, [r1, #TickNodeLeft]
CMP r0, #0 ; timed out? CMP r0, #0 ; zero time delta?
BLE %BT01 ; yes then jump BEQ %BT01 ; yes then jump
02 02
Pull "lr" ; restore SVC_lr Pull "lr" ; restore SVC_lr
WritePSRc IRQ_mode+I_bit, r10 ; back to IRQ mode WritePSRc IRQ_mode+I_bit, r10 ; back to IRQ mode
......
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