Commit 0aeea07f authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL

Allow runtime adjustment of AplWorkMaxSize

Detail:
This adds a new OS_DynamicArea reason code, 26, for adjusting
AplWorkMaxSize at runtime. This allows compatibility tools such as
Aemulor to adjust the limit without resorting to patching the kernel.
Any adjustment made to the value will affect the upper limit of
application space, and the lower limit of dynamic area placement.
Attempting to adjust beyond the compile-time upper/default limit, or
such that it will interfere with existing dynamic areas / wimpslots,
will result in an error.

Relevant forum thread:
https://www.riscosopen.org/forum/forums/11/topics/14734

Admin:
Tested on BB-xM, desktop active & inactive

Version 6.24. Tagged as 'Kernel-6_24'
parent 0ee90f05
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate GBLS Module_ApplicationDate
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
Module_MajorVersion SETS "6.23" Module_MajorVersion SETS "6.24"
Module_Version SETA 623 Module_Version SETA 624
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "21 Sep 2019" Module_Date SETS "30 Sep 2019"
Module_ApplicationDate SETS "21-Sep-19" Module_ApplicationDate SETS "30-Sep-19"
Module_ComponentName SETS "Kernel" Module_ComponentName SETS "Kernel"
Module_FullVersion SETS "6.23" Module_FullVersion SETS "6.24"
Module_HelpVersion SETS "6.23 (21 Sep 2019)" Module_HelpVersion SETS "6.24 (30 Sep 2019)"
END END
/* (6.23) /* (6.24)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 6.23 #define Module_MajorVersion_CMHG 6.24
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 21 Sep 2019 #define Module_Date_CMHG 30 Sep 2019
#define Module_MajorVersion "6.23" #define Module_MajorVersion "6.24"
#define Module_Version 623 #define Module_Version 624
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "21 Sep 2019" #define Module_Date "30 Sep 2019"
#define Module_ApplicationDate "21-Sep-19" #define Module_ApplicationDate "30-Sep-19"
#define Module_ComponentName "Kernel" #define Module_ComponentName "Kernel"
#define Module_FullVersion "6.23" #define Module_FullVersion "6.24"
#define Module_HelpVersion "6.23 (21 Sep 2019)" #define Module_HelpVersion "6.24 (30 Sep 2019)"
#define Module_LibraryVersionInfo "6:23" #define Module_LibraryVersionInfo "6:24"
...@@ -1288,6 +1288,7 @@ ProcVecPreVeneersSize * 4*4 ; Space for preveneers for loading handl ...@@ -1288,6 +1288,7 @@ ProcVecPreVeneersSize * 4*4 ; Space for preveneers for loading handl
ProcVecPreVeneers # ProcVecPreVeneersSize ProcVecPreVeneers # ProcVecPreVeneersSize
AplWorkSize * AppSpaceDANode + DANode_Size AplWorkSize * AppSpaceDANode + DANode_Size
SoftAplWorkMaxSize * AppSpaceDANode + DANode_MaxSize
ExtendedROMFooter # 4 ; Pointer to the extended ROM footer structure. 0 if not initialised, -1 if not found. ExtendedROMFooter # 4 ; Pointer to the extended ROM footer structure. 0 if not initialised, -1 if not found.
......
...@@ -35,7 +35,8 @@ DAReason_PMP_LogOp * 22 ...@@ -35,7 +35,8 @@ DAReason_PMP_LogOp * 22
DAReason_PMP_Resize * 23 DAReason_PMP_Resize * 23
DAReason_PMP_GetInfo * 24 DAReason_PMP_GetInfo * 24
DAReason_PMP_GetPages * 25 DAReason_PMP_GetPages * 25
DAReason_Limit * 26 ;end of defined DA reasons DAReason_AplSpaceLimit * 26
DAReason_Limit * 27 ;end of defined DA reasons
; Dynamic area / page flags ; Dynamic area / page flags
......
...@@ -22,9 +22,6 @@ AMBInitialMaxNodes * 256 ...@@ -22,9 +22,6 @@ AMBInitialMaxNodes * 256
ApplicationStart * (32*1024) ApplicationStart * (32*1024)
AbsMaxAppSize * AplWorkMaxSize ;application space limit for RISC OS
AbsMaxAppPages * (AbsMaxAppSize:SHR:Log2PageSize) ;and same limit expressed in Pages
;whether to check handles given to AMBControl - not very useful when in kernel ;whether to check handles given to AMBControl - not very useful when in kernel
; ;
GBLL ValidateAMBHandles GBLL ValidateAMBHandles
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[ AMB_LazyMapIn [ AMB_LazyMapIn
AMBMIRegWords * (AbsMaxAppPages+31) :SHR: 5 ;no. of words for AMBMappedInRegister AMBMIRegWords * ((AplWorkMaxSize:SHR:Log2PageSize)+31) :SHR: 5 ;no. of words for AMBMappedInRegister
;convenient to set this at fixed max size ;convenient to set this at fixed max size
;(only 896 bytes for 28Mb AppSpace) ;(only 896 bytes for 28Mb AppSpace)
] ]
......
...@@ -31,7 +31,9 @@ allocate ...@@ -31,7 +31,9 @@ allocate
DebugReg r1, "allocate " DebugReg r1, "allocate "
] ]
LDR R3,=AbsMaxAppSize-ApplicationStart LDR R3,=ZeroPage
LDR R3,[R3,#SoftAplWorkMaxSize]
SUB R3,R3,#ApplicationStart
MOV R3,R3,LSR #Log2PageSize ;R3 = absolute max app pages MOV R3,R3,LSR #Log2PageSize ;R3 = absolute max app pages
CMP R1,R3 CMP R1,R3
...@@ -83,7 +85,9 @@ allocate ...@@ -83,7 +85,9 @@ allocate
STR R4,[R2,#AMBNode_DANode+DANode_Handler] STR R4,[R2,#AMBNode_DANode+DANode_Handler]
ADR R4,AMBDAName ADR R4,AMBDAName
STR R4,[R2,#AMBNode_DANode+DANode_Title] STR R4,[R2,#AMBNode_DANode+DANode_Title]
LDR R4,=AbsMaxAppSize-ApplicationStart LDR R4,=ZeroPage
LDR R4,[R4,#SoftAplWorkMaxSize]
SUB R4,R4,#ApplicationStart
STR R4,[R2,#AMBNode_DANode+DANode_MaxSize] STR R4,[R2,#AMBNode_DANode+DANode_MaxSize]
MOV R4,#ChangeDyn_AplSpace MOV R4,#ChangeDyn_AplSpace
STR R4,[R2,#AMBNode_DANode+DANode_Number] STR R4,[R2,#AMBNode_DANode+DANode_Number]
......
...@@ -35,7 +35,8 @@ growshrink ...@@ -35,7 +35,8 @@ growshrink
DebugReg r2 DebugReg r2
] ]
MOV R5,#AbsMaxAppSize LDR R5,=ZeroPage
LDR R5,[R5,#SoftAplWorkMaxSize]
SUB R5,R5,#ApplicationStart SUB R5,R5,#ApplicationStart
MOV R5,R5,LSR #Log2PageSize ;R5 = absolute max app pages MOV R5,R5,LSR #Log2PageSize ;R5 = absolute max app pages
CMP R1,R5 CMP R1,R5
......
...@@ -562,7 +562,7 @@ AMB_LazyFixUp ROUT ...@@ -562,7 +562,7 @@ AMB_LazyFixUp ROUT
; view of app space mapping, so that laziness is transparent) ; view of app space mapping, so that laziness is transparent)
; ;
AMB_MakeHonestLA ROUT AMB_MakeHonestLA ROUT
CMP r0,#AbsMaxAppSize ;quick dismiss if definitely not app address CMP r0,#AplWorkMaxSize ;quick dismiss if definitely not app address
MOVHS pc,lr MOVHS pc,lr
Push "r1,r12,lr" Push "r1,r12,lr"
LDR r12,=ZeroPage+AMBControl_ws LDR r12,=ZeroPage+AMBControl_ws
......
...@@ -344,11 +344,12 @@ readdyn_returnR2bit * &80 ...@@ -344,11 +344,12 @@ readdyn_returnR2bit * &80
CMP r0, #ChangeDyn_AplSpace ; if finding out about app space CMP r0, #ChangeDyn_AplSpace ; if finding out about app space
[ ZeroPage = 0 [ ZeroPage = 0
LDREQ r1, [r0, #AplWorkSize+1] ; then r1 = current size LDREQ r1, [r0, #AplWorkSize+1] ; then r1 = current size
LDREQ r2, [r0, #SoftAplWorkMaxSize+1] ; and r2 = max size
| |
LDREQ r1, =ZeroPage LDREQ r2, =ZeroPage
LDREQ r1, [r1, #AplWorkSize] LDREQ r1, [r2, #AplWorkSize] ; then r1 = current size
LDREQ r2, [r2, #SoftAplWorkMaxSize] ; and r2 = max size
] ]
LDREQ r2, =AplWorkMaxSize ; and r2 = max size
MOVEQ r0, #&8000 ; r0 = base address MOVEQ r0, #&8000 ; r0 = base address
SUBEQ r1, r1, r0 ; adjust size and maxsize SUBEQ r1, r1, r0 ; adjust size and maxsize
SUBEQ r2, r2, r0 ; to remove bottom 32K SUBEQ r2, r2, r0 ; to remove bottom 32K
...@@ -691,6 +692,7 @@ DynAreaSub ...@@ -691,6 +692,7 @@ DynAreaSub
B DynArea_PMP_Resize B DynArea_PMP_Resize
B DynArea_PMP_GetInfo B DynArea_PMP_GetInfo
B DynArea_PMP_GetPages B DynArea_PMP_GetPages
B DynArea_AplSpaceLimit
; ;
; unknown OS_DynamicArea reason code ; unknown OS_DynamicArea reason code
...@@ -3541,6 +3543,113 @@ DynArea_PMP_GetPages ROUT ...@@ -3541,6 +3543,113 @@ DynArea_PMP_GetPages ROUT
EXIT EXIT
;**************************************************************************
;
; DynArea_AplSpaceLimit - Read/Adjust application space limit
;
; Internal routine called by DynamicAreaSWI
;
; in: r0 = reason code (26)
; r1 = new application space limit, or 0 to read current limit
;
; out: r1 = previous application space limit
; r10-r12 may be corrupted
; All other registers preserved
;
; Note: Limit value is the (exclusive) upper address, i.e. size + &8000
;
DynArea_AplSpaceLimit ROUT
LDR r10, =ZeroPage
CMP r1, #0
LDR r11, [r10, #SoftAplWorkMaxSize]
MOVEQ r1, r11
CMPNE r1, r11
MOVEQ pc, lr ; Early exit if reading current value, or no change
Entry "r2-r5"
MOVS r2, r1, LSL #32-Log2PageSize
BNE %FT90 ; Must be page size multiple
CMP r1, #&8000+PageSize ; Assume size of zero will break things
BLO %FT90
CMP r1, #AplWorkMaxSize ; And can't be larger than the hard limit
BHI %FT90
LDR r12, [r10, #AMBControl_ws]
ADR r4, AMBAnchorNode
CMP r1, r11
BLO %FT50
; Increasing limit - check dynamic areas
;
; DANode_List is sorted in address order, so we only need to check the
; first entry (being careful to avoid entries with no logical mapping,
; like the free pool)
LDR r2, [r10, #DAList]
40
LDR r3, [r2, #DANode_MaxSize]
CMP r3, #0
BNE %FT41
LDR r2, [r2, #DANode_Link]
CMP r2, #0
BNE %BT40
B %FT80 ; No dynamic areas? Well, if you say so
41
LDR r5, [r2, #DANode_Flags]
TST r5, #DynAreaFlags_DoublyMapped
LDR r2, [r2, #DANode_Base]
SUBNE r2, r2, r3 ; Get true base of doubly-mapped area
CMP r2, r1
BLO %FT89
B %FT80
50
; Decreasing limit - check both AMB and non-AMB application space
LDR r2, [r10, #AplWorkSize]
CMP r1, r2
BLO %FT89
MOV r3, r4
SUB r2, r1, #ApplicationStart
55
; Use the PMP size to determine the size (DANode_Size will be zero
; for unmapped AMBNodes). This check will need changing if we allow
; programs to sparsely map application space.
;
; Note: For AMBControl, PMPSize should match PMPMaxSize. But we're
; checking PMPMaxSize just in case something's gone wrong.
LDR r5, [r3, #AMBNode_DANode+DANode_PMPMaxSize]
CMP r5, r2, LSR #Log2PageSize
BHI %FT89
LDR r3, [r3, #AMBNode_next]
CMP r3, r4
BNE %BT55
; Fall through
80
; Limit is good - update DANode_AppSpace + AMBControl nodes
STR r1, [r10, #SoftAplWorkMaxSize]
MOV r3, r4
SUB r2, r1, #ApplicationStart
85
STR r2, [r3, #AMBNode_DANode+DANode_MaxSize]
LDR r3, [r3, #AMBNode_next]
CMP r3, r4
BNE %BT85
MOV r1, r11
EXIT
89
; Overlaps something
ADRL r0, ErrorBlock_OverlappingAreas
B %FT91
90
; Address is outside hard limits
ADRL r0, ErrorBlock_BadParameters
91
[ International
BL TranslateError
|
SETV
]
EXIT
;************************************************************************** ;**************************************************************************
; ;
; CheckAreaNumber - Try to find area with number r1 ; CheckAreaNumber - Try to find area with number r1
...@@ -3664,6 +3773,9 @@ CheckForOverlappingAreas Entry "r0-r5" ...@@ -3664,6 +3773,9 @@ CheckForOverlappingAreas Entry "r0-r5"
LDMIA lr!, {r0, r1} ; r0 = start addr, r1 = size LDMIA lr!, {r0, r1} ; r0 = start addr, r1 = size
CMP r0, #-1 ; if at end of list CMP r0, #-1 ; if at end of list
BEQ %FT30 ; then OK wrt fixed areas BEQ %FT30 ; then OK wrt fixed areas
CMP r1, #-1 ; appspace?
LDREQ r1, =ZeroPage
LDREQ r1, [r1, #SoftAplWorkMaxSize]
ADD r1, r1, r0 ; r1 = end addr+1 ADD r1, r1, r0 ; r1 = end addr+1
CMP r5, r0 ; if end of our area is <= start of fixed, then OK wrt fixed areas CMP r5, r0 ; if end of our area is <= start of fixed, then OK wrt fixed areas
BLS %FT30 BLS %FT30
...@@ -3708,7 +3820,7 @@ CheckForOverlappingAreas Entry "r0-r5" ...@@ -3708,7 +3820,7 @@ CheckForOverlappingAreas Entry "r0-r5"
FixedAreasTable ; table of fixed areas (address, size) FixedAreasTable ; table of fixed areas (address, size)
& 0, AplWorkMaxSize ; application space & 0, -1 ; application space (size looked up later)
[ CursorChunkAddress < IO [ CursorChunkAddress < IO
& CursorChunkAddress, 64*1024 ; 32K for cursor, 32K for "nowhere" & CursorChunkAddress, 64*1024 ; 32K for cursor, 32K for "nowhere"
] ]
...@@ -3803,6 +3915,9 @@ AllocateAreaAddress Entry "r0-r2,r4-r7" ...@@ -3803,6 +3915,9 @@ AllocateAreaAddress Entry "r0-r2,r4-r7"
GetNextRange Entry "r7,r8" GetNextRange Entry "r7,r8"
LDMIA r0, {r2, r6} ; load start, size from fixed list LDMIA r0, {r2, r6} ; load start, size from fixed list
CMP r6, #-1 ; appspace?
LDREQ r6, =ZeroPage
LDREQ r6, [r6, #SoftAplWorkMaxSize]
ADD r6, r6, r2 ; r6 = end+1 ADD r6, r6, r2 ; r6 = end+1
ASSERT DANode_Link = 0 ASSERT DANode_Link = 0
......
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