From be560349138158dc45af2441ea12b2db661077e9 Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <me@phlamethrower.co.uk>
Date: Thu, 8 Jul 2021 20:04:31 +0100
Subject: [PATCH] Fix Message_TaskInitialise reporting wrong slot size

Message_TaskInitialise was reporting that MemoryLimit was the slot size
of the application, which was resulting in the task manager showing the
wrong slot size if for some reason MemoryLimit had been artificially
reduced below ApplicationSpaceSize (e.g. due to the task being a child
of a C system() call). And because MemoryLimit is lower than
ApplicationSpaceSize, any attempt the task makes to grow/shrink its wimp
slot is denied, so task manager will be stuck showing the wrong value
for the entire lifetime of the task.

Fix Message_TaskInitialise to use ApplicationSpaceSize instead, so that
the total size of the slot is reported instead of just the usable area.

This fixes task manager incorrectly showing that Fat32Fs has a slot size
of 0 on some of my Raspberry Pis, when really it has a size of 256K.
This discrepancy was also causing the "System memory allocation" numbers
to not total up correctly (the sum was 256K lower than the displayed
total).
---
 s/Wimp02 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/s/Wimp02 b/s/Wimp02
index 578d2f2..6338663 100644
--- a/s/Wimp02
+++ b/s/Wimp02
@@ -876,7 +876,7 @@ returntaskhandle
         BL      fulltaskhandle          ; R14 = handle including version bits
         STR     R14,[sp,#0*4]           ; overwrite value of R1 on stack
 ;
-        MOV     R0,#MemoryLimit         ; do this now cos R0 needed
+        MOV     R0,#ApplicationSpaceSize; do this now cos R0 needed
         MOV     R1,#0
         SWI     XOS_ChangeEnvironment
         SUB     R5,R1,#ApplicationStart ; data + 4
-- 
GitLab