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

Fix Service_Memory when shrinking appspace

Update AreaShrink so that (when shrinking appspace) CheckAppSpace is
passed the change amount as a negative number, so that Service_Memory is
issued with the correct sign.

Fixes issue reported on the forums, where BASIC was getting confused
because appspace shrinks were being reported as if they were a grow
operation:

https://www.riscosopen.org/forum/forums/4/topics/15067

It looks like this bug was introduced in Kernel-5_35-4_79_2_284
(introduction of PMPs), where the logic for appspace shrinks (which must
be performed via a grow of the free pool or some other DA) were moved
out of AreaGrow and into AreaShrink (because appspace shrinks are now
internally treated as "shrink appspace into free pool")
parent 0595a541
......@@ -5192,7 +5192,7 @@ AreaShrink ROUT
]
BNE %FT17 ; then don't call app
Push "r10" ; save -> to area we tried to shrink
MOV r10, r1
RSB r10, r1, #0 ; Shrinking appspace, make the change amount negative again
BL CheckAppSpace
Pull "r10"
BVS ChangeDynError
......@@ -6417,8 +6417,7 @@ DoTheGrowNotSpecified ROUT
;
; Internal routine, called by OS_ChangeDynamicArea
;
; in: r0 = area number passed in to ChangeDyn
; r10 = size of change (signed)
; in: r10 = size of appspace change (signed)
; r11 -> node for src
; r12 -> node for dest
;
......@@ -6447,6 +6446,9 @@ CheckAppSpace ROUT
MOVS r1, r10
RSBMI r1, r1, #0 ; r1 passed in is always +ve (probably a bug, but should be compat.)
[ DebugCDA2
DREG r10, "Asking UpCall_MovingMemory about "
]
SWI XOS_UpCall
CMP r0, #UpCall_Claimed ; if upcall claimed
EXIT EQ ; then OK to move memory, so exit (V=0 from CMP)
......@@ -6454,6 +6456,9 @@ CheckAppSpace ROUT
05
ADR r0, ErrorBlock_ChDynamCAO
10
[ DebugCDA2
DLINE "Change denied"
]
[ International
BL TranslateError
|
......@@ -6465,7 +6470,10 @@ CheckAppSpace ROUT
; IF service call claimed Then Error AplWSpaceInUse
20
MOV r0, r10 ; amount removing from aplspace
[ DebugCDA2
DREG r10, "Telling Service_Memory about "
]
MOV r0, r10 ; amount changing aplspace
MOV r1, #Service_Memory
BL Issue_Service
CMP r1, #Service_Serviced
......
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