Commit 4aff63cd authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Update to cope with physical memory pools

Detail:
  For physical memory pools, the max size returned by OS_ReadDynamicArea/OS_DynamicArea 2 might be a lie - although the maximum logical size of a PMP is fixed, the maximum physical size can be updated dynamically, so that a PMP can avoid wasting memory for a page list which is mostly unused.
  So whenever we want to resize a PMP, we ignore the max size indicated by the OS and instead treat it as if it has a max of 4GB
  s/Switcher - Implement the above, by replacing calls to OS_ReadDynamicArea with calls to OS_DynamicArea 2 (so DA flags can be read). Also fix some bits of code to do unsigned comparisons on size values, and to cope with the fact that OS_ChangeDynamicArea essentially limits us to +/-2GB at a time (although currently we just clamp the request, rather than make multiple requests)
Admin:
  Tested on Pandaboard


Version 1.46. Tagged as 'Switcher-1_46'
parent db9b49d0
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.45"
Module_Version SETA 145
Module_MajorVersion SETS "1.46"
Module_Version SETA 146
Module_MinorVersion SETS ""
Module_Date SETS "17 Jul 2015"
Module_ApplicationDate SETS "17-Jul-15"
Module_Date SETS "31 Aug 2015"
Module_ApplicationDate SETS "31-Aug-15"
Module_ComponentName SETS "Switcher"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/Switcher"
Module_FullVersion SETS "1.45"
Module_HelpVersion SETS "1.45 (17 Jul 2015)"
Module_FullVersion SETS "1.46"
Module_HelpVersion SETS "1.46 (31 Aug 2015)"
END
/* (1.45)
/* (1.46)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.45
#define Module_MajorVersion_CMHG 1.46
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Jul 2015
#define Module_Date_CMHG 31 Aug 2015
#define Module_MajorVersion "1.45"
#define Module_Version 145
#define Module_MajorVersion "1.46"
#define Module_Version 146
#define Module_MinorVersion ""
#define Module_Date "17 Jul 2015"
#define Module_Date "31 Aug 2015"
#define Module_ApplicationDate "17-Jul-15"
#define Module_ApplicationDate "31-Aug-15"
#define Module_ComponentName "Switcher"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/Switcher"
#define Module_FullVersion "1.45"
#define Module_HelpVersion "1.45 (17 Jul 2015)"
#define Module_LibraryVersionInfo "1:45"
#define Module_FullVersion "1.46"
#define Module_HelpVersion "1.46 (31 Aug 2015)"
#define Module_LibraryVersionInfo "1:46"
......@@ -4417,7 +4417,9 @@ switcher_click
LDREQ r1, [userblk,#icb_taskage] ; DA number
MOVS r0, r1
BEQ notdyn
SWI XOS_ReadDynamicArea ; out: r0 = base address, r1 = cur.size, r2 = max size
Push "r14"
BL ReadDynamicArea ; out: r0 = base address, r1 = cur.size, r2 = max size
Pull "r14"
MOVVC r14, r2
notdyn
Pull "r1,r2"
......@@ -4770,10 +4772,14 @@ null_event ROUT
Push "R0"
LDR R0,max_mem_drag
CMP R1,R0
MOVGT R1,R0
MOVHI R1,R0
Pull "R0"
]
SUB R1,R1,R14 ; R1 = change in area size
SUBS R1,R1,R14 ; R1 = change in area size
BVC %FT01
LDR R1,=&7FFFF000 ; Clamp to +/- 2GB-4KB if overflow
RSBLT R1,R1,#0
01
SWI XOS_ChangeDynamicArea
BVC %FT01
......@@ -4819,7 +4825,7 @@ setwimpslot ROUT
LDR R14,max_mem_drag
CMP R1,R14
MOVGT R1,R14 ; restrict drag by ammount available
MOVHI R1,R14 ; restrict drag by ammount available
LDRB R14,[userblk,#icb_icon3]
TEQ R14,#ic_freeBar ; if free bar,
......@@ -4855,20 +4861,22 @@ setcdamem
; R1 is proposed new memory
LDR R0,max_mem_drag
CMP R1,R0
MOVGT R1,R0 ; restrict drag by ammount available
MOVHI R1,R0 ; restrict drag by ammount available
MOV R3,R1
LDR R0,[userblk,#icb_taskage] ; area number
CMP R0,#128
ORRLT R0,R0,#128 ; want max size as well
SWI XOS_ReadDynamicArea
BL ReadDynamicArea
MOV R0,R3
BVS %FT02
CMP R0,R2
MOVGT R0,R2
MOVHI R0,R2
MOV R3,R1
SUBS R1,R0,R1 ; is proposed size the current size?
MOV R4,R1
SUBS R1,R0,R1
BVC %FT01
LDR R1,=&7FFFF000 ; Clamp to +/- 2GB-4KB if overflow
RSBLT R1,R1,#0
01
MOVS R4,R1 ; is proposed size the current size?
Pull "PC",EQ
; R1 is change in size
LDR R0,[userblk,#icb_taskage]
......@@ -7011,6 +7019,33 @@ MyXWimp_Poll Push "R0,R14"
ADD SP,SP,#4
Pull "PC"
ReadDynamicArea ROUT
; In: R0 = DA number
; Out: R0 = base address
; R1 = current size
; R2 = max size
[ {TRUE}
Entry "r3-r8"
; Use OS_DynamicArea so that we can claim PMPs have unlimited size
CMP r0, #256
BICLO r0, r0, #128 ; Clear the OS_ReadDynamicArea "return max size" flag
MOV r1, r0
MOV r0, #2
SWI XOS_DynamicArea
TST r4, #1:SHL:20 ; Physical memory pool?
MOVNE r5, #-1 ; Remove size limit (assume will grow as needed)
MOVVC r0, r3
MOV r1, r2
MOV r2, r5
EXIT
|
CMP R0,#128
ADDLO R0,R0,#128 ; Set flag if not already set
SWI XOS_ReadDynamicArea
MOV PC,LR
]
;;----------------------------------------------------------------------------
;; Included resource files
;;----------------------------------------------------------------------------
......
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