Commit 1c07c7cd authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Automatically adjust wimpslot when running AIFs via FSControl 4

Detail:
  s/FSCommon - Adjust ValidateR2R5_WriteToCoreCodeLoad to try and increase the wimpslot if it isn't already big enough to contain the region being validated (i.e. the program being loaded)
  s/FSControl - FSControl 4 now checks AIF memory limts and tries to extend wimpslot as necessary both before and after decompression. An extra 8K is added to the calculated memory requirements to take into account memory which isn't declared in the header (root stack chunk?) which is required by SCL initialisation.
Admin:
  Tested in Iyonix ROM softload
  This should eliminate most/all of the "No writeable memory at this address", abort on data transfer, and "Not enough memory for C library" errors users receive due to the wimpslot being too small when all they want to do is run a program


Version 2.81. Tagged as 'FileSwitch-2_81'
parent 9e83674d
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.80"
Module_Version SETA 280
Module_MajorVersion SETS "2.81"
Module_Version SETA 281
Module_MinorVersion SETS ""
Module_Date SETS "05 Jan 2013"
Module_ApplicationDate SETS "05-Jan-13"
Module_Date SETS "13 Jan 2013"
Module_ApplicationDate SETS "13-Jan-13"
Module_ComponentName SETS "FileSwitch"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/FileSwitch"
Module_FullVersion SETS "2.80"
Module_HelpVersion SETS "2.80 (05 Jan 2013)"
Module_FullVersion SETS "2.81"
Module_HelpVersion SETS "2.81 (13 Jan 2013)"
END
/* (2.80)
/* (2.81)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.80
#define Module_MajorVersion_CMHG 2.81
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 05 Jan 2013
#define Module_Date_CMHG 13 Jan 2013
#define Module_MajorVersion "2.80"
#define Module_Version 280
#define Module_MajorVersion "2.81"
#define Module_Version 281
#define Module_MinorVersion ""
#define Module_Date "05 Jan 2013"
#define Module_Date "13 Jan 2013"
#define Module_ApplicationDate "05-Jan-13"
#define Module_ApplicationDate "13-Jan-13"
#define Module_ComponentName "FileSwitch"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/FileSwitch"
#define Module_FullVersion "2.80"
#define Module_HelpVersion "2.80 (05 Jan 2013)"
#define Module_LibraryVersionInfo "2:80"
#define Module_FullVersion "2.81"
#define Module_HelpVersion "2.81 (13 Jan 2013)"
#define Module_LibraryVersionInfo "2:81"
......@@ -1624,6 +1624,40 @@ ValidateR2R5_WriteToCore ALTENTRY
ValidateR2R5_WriteToCoreCodeLoad ALTENTRY
; Be nice and try and allocate however much memory is needed
; First check if R2..R5 fits in application limit
MOV r0, #11
SWI XWimp_ReadSysInfo
BVS %FT96
; Start in &8000...ApplicationLimit ?
CMP r2, #&8000
CMPHS r0, r2
BLO %FT96 ; No
; Yes, start's in range, is end?
CMP r5, r0
BHI %BA90 ; No - give error
; Good, now check if wimp slot is already big enough
Push "r2,r4"
MVN r0, #0
MVN r1, #0
SWI XWimp_SlotSize
BVS %FT95
SUB r1, r5, #&8000
CMP r1, r0
BLE %FT95
; Attempt resize
MOV r0, r1
MVN r1, #0
SWI XWimp_SlotSize
95
Pull "r2,r4"
96
CLRV
; Do standard check
BL ValidateR2R5_WriteToCore
......
......@@ -378,9 +378,12 @@ Run_UndatedFile
Push "r1" ; Remember the old cache setting
]
; Check memory before decompression, since decompression code is dumb
MOV r2, #&8000
BL CheckAIFMemoryLimit ; Ignore any returned error since nonstandard compression may confuse our memory usage calculations
MOV r0, #0 ; Pre-decompression service call
MOV r1, #Service_UKCompression
MOV r2, #&8000
MOV r3, r7
MOV r4, #&8000
SWI XOS_ServiceCall ; A claimant of this does the decompression
......@@ -406,24 +409,7 @@ Run_UndatedFile
SWI XOS_SynchroniseCodeAreas
]
[ {TRUE}
;Check absolute AIF image memory limits
LDR lr, [r2, #&0C]
AND lr, lr, #&FF000000
TEQ lr, #&EB000000 ; is this instruction a branch
BNE %FT71 ; nope - not executable AIF then
LDR lr, [r2, #&10]! ; should be SWI OS_Exit (&EF000011 for AIF), R2 := R2 + 16
SUB lr, lr, #&EF000000
TEQ lr, #&00000011 ; OS_Exit check worked?
LDMEQIB r2, {r0,r1,r5,lr} ; load RO size, RW size, Debug size, ZI size
MOV r2, #&8000 ; R2 := &8000 like it was before
BNE %FT71 ; not AIF then
ADD lr, lr, r5 ; lr := debug + zero init
ADD r0, r0, r1 ; R0 := read only + read write
ADD r0, r0, lr ; R0 := read only + read write + debug + zero init
ADD r5, r2, r0 ; R5 := base address + size required
BL ValidateR2R5_WriteToCoreCodeLoad
BL CheckAIFMemoryLimit
BVC %FT71
; /* dead here - need to generate an error */
addr r0, ErrorBlock_CoreNotWriteable
......@@ -431,7 +417,7 @@ Run_UndatedFile
SWI XMessageTrans_ErrorLookup
SWI OS_GenerateError
71
]
[ StrongARM
;Finally, prepare to run the thing!
MOV r2, r4 ; We're gonna jump in where we're told!.
......@@ -540,6 +526,34 @@ Run_TransientFile
LTORG
CheckAIFMemoryLimit ROUT
Entry "r5"
; Check absolute AIF memory limits
; R2 = &8000
; R0-R1 corruptible
; V set/clear on exit for bad/good
LDR lr, [r2, #&0C]
AND lr, lr, #&FF000000
TEQ lr, #&EB000000 ; is this instruction a branch
BNE %FT90 ; nope - not executable AIF then
LDR lr, [r2, #&10]! ; should be SWI OS_Exit (&EF000011 for AIF), R2 := R2 + 16
SUB lr, lr, #&EF000000
TEQ lr, #&00000011 ; OS_Exit check worked?
LDMEQIB r2, {r0,r1,r5,lr} ; load RO size, RW size, Debug size, ZI size
MOV r2, #&8000 ; R2 := &8000 like it was before
BNE %FT90 ; not AIF then
ADD lr, lr, r5 ; lr := debug + zero init
ADD r0, r0, r1 ; R0 := read only + read write
ADD r0, r0, lr ; R0 := read only + read write + debug + zero init
ADD r0, r0, #&2000 ; 8K extra to avoid "Not enough memoy for C library" from silly C stubs
ADD r5, r2, r0 ; R5 := base address + size required
BL ValidateR2R5_WriteToCoreCodeLoad
EXIT
90
CLRV
EXIT
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; This is where position independent code will return to if it does MOV pc, lr
......
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