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

Fix GrowFreePool

Buggy since its introduction in Kernel-5_35-4_79_2_284, GrowFreePool was
attempting to grow the free pool by shrinking application space, an
operation which OS_ChangeDynamicArea doesn't support. Change it to grow
the free pool instead, and fix a couple of other issues that would have
caused it to work incorrectly (register corruption causing it to request
a size change of zero, and incorrect assumption that
OS_ChangeDynamicArea returns the amount unmoved, when really it returns
the amount moved)
parent 76d04b25
......@@ -5607,40 +5607,35 @@ GrowFreePool ROUT
; Check to see if there's already enough space
LDR r11, =ZeroPage+FreePoolDANode
LDR r2, [r11, #DANode_PMPSize]
SUBS r0, r2, r1
BHS %FT90
CMP r2, r1
EXIT CS
[ ShrinkableDAs
; Try and shrink shrinkables
CLC
BL TryToShrinkShrinkables
EXIT CS
SUB r0, r2, r1 ; Update how many pages still needed
]
; Try shrinking application space, if r12 != appspace
LDR lr, [r12, #DANode_Number]
CMP lr, #ChangeDyn_AplSpace
BEQ %FT80
SUB r0, r1, r2
LDR r2, [r11, #CDASemaphore-FreePoolDANode]
MOV r0, #0
STR r0, [r11, #CDASemaphore-FreePoolDANode] ; Allow nested call
CMN r0, #DynArea_PMP_BigPageCount ; r0 is negative
MOVGT r1, r0, LSL #12
LDRLE r1, =-DynArea_PMP_BigByteCount
MOV r0, #ChangeDyn_AplSpace
CMP r1, #DynArea_PMP_BigPageCount
MOVLT r1, r1, LSL #12
LDRGE r1, =DynArea_PMP_BigByteCount
MOV r0, #ChangeDyn_FreePool ; shrink appspace by growing free pool
SWI XOS_ChangeDynamicArea
STR r2, [r11, #CDASemaphore-FreePoolDANode] ; reclaim semaphore
MOVVS r1, #1
CMP r1, #0 ; if all moved
BEQ %FT90 ; then success
; Fall through...
LDR r2, [r11, #DANode_PMPSize]
FRAMLDR r1
CMP r2, r1 ; Free pool >= desired size?
EXIT
80
CLC
EXIT
90
SEC
EXIT
[ ShrinkableDAs
; ***********************************************************************************
;
......
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