29 August 2018, 18:48 | #1 |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Temporary turning FAST memory off
Hi,
is there a way to turn off FAST memory so the system can't allocate it any more apart from this very common technique? Code:
CNOP 0,4 rd_turn_off_FAST_memory move.l #MEMF_FAST+MEMF_LARGEST,d1 ;Get largest FAST-memory block jsr -216(a6) ;AvailMem() tst.l d0 ;Still FAST memory ? beq.s rd_no_more_FAST_memory ;No -> skip move.l #MEMF_FAST+MEMF_LARGEST,d1 ;Get largest FAST-memory block jsr -198(a6) ;AllocMem() bra.s rd_turn_off_FAST_memory ;Loop CNOP 0,4 rd_no_more_FAST_memory rts Does anyone know a smarter way in assembler? |
29 August 2018, 19:21 | #2 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Start with an empty list
If list empty get all memory and store memory pointers to list if list not empty, walk list & free all list memory pointers |
29 August 2018, 19:34 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Even easier: store all address/size pairs in first (largest) allocated block.
|
29 August 2018, 19:58 | #4 | |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Quote:
|
|
29 August 2018, 21:32 | #5 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Why not patching AllocMem() and AvailMem() and let them simply return zero to all FastMem requests?
|
29 August 2018, 21:42 | #6 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Quote:
IMHO LVO patching should be only used if there is no other cleaner solution. |
|
29 August 2018, 23:14 | #7 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Ok, it depends on what you want to keep off from getting FastMem. And yes, of course, there are also Allocate(), AllocPooled(), AllocAbs() and AllocVec(). The latter calls AllocMem(). Don't know what the other functions are doing, whether they are based on AllocMem() too or not.
But I just had a short look into the disassembler listing of NoFastMem, which could be easily integrated into other programs. NoFastMem patches AvailMem() and AllocMem(), maybe in a little bit different way, but it's going into the same direction. On the other side, when you are trying to allocate all available FastMem blocks you are never finished with that task, because at any time other programs may set their used blocks of FastMem free again, and then you will get into a race condition with those which want to allocate these new FastMem blocks. Last edited by PeterK; 30 August 2018 at 00:26. |
30 August 2018, 09:28 | #8 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Why not using NoFastMem itself ?
From within a program it should be easy to call Execute() or a similar function. If it doesn't work on pre 2.0 then it can probably be adapted. |
30 August 2018, 09:29 | #9 | |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Quote:
Code:
CNOP 0,4 turn_off_FAST_memory move.l $4.w,a6 ;Get Exec-Base move.l #$20004,d1 ;Request: MEMF_FAST+MEMF_LARGEST move.l d1,d2 ;Save request jsr -216(a6) ;AvailMem(): Get first largest FAST-memory block move.l d0,-(a7) ;Save size move.l d2,d1 ;Request: MEMF_FAST+MEMF_LARGEST jsr -198(a6) ;AllocMem(): Allocate first largest FAST-memory block move.l d0,-(a7) ;Save pointer 2x move.l d0,a2 turn_off_FAST_memory_loop move.l d2,d1 ;Request: MEMF_FAST+MEMF_LARGEST jsr -216(a6) ;AvailMem(): Get largest FAST-memory block move.l d0,(a2)+ ;Save size beq.s no_more_FAST_memory ;If NULL -> skip move.l d2,d1 ;Request: MEMF_FAST+MEMF_LARGEST jsr -198(a6) ;AllocMem(): Allocate largest FAST-memory block move.l d0,(a2)+ ;Save pointer bra.s turn_off_FAST_memory_loop ;Loop CNOP 0,4 no_more_FAST_memory rts ... CNOP 0,4 turn_on_FAST_memory move.l (a7)+,a2 ;Get pointer to first largest block move.l a2,a3 ;Save it turn_on_FAST_memory_loop move.l (a2)+,d0 ;Get size beq.s free_first_block ;If NULL -> skip move.l (a2)+,a1 ;Get pointer jsr -210(a6) ;FreeMem() bra.s turn_on_FAST_memory_loop ;Loop CNOP 0,4 free_first_block move.l a3,a1 ;Get pointer of first largest block move.l (a7)+,d0 ;Get size of first largest block jmp -210(a6) ;FreeMem() My idea is to patch the memory-list at the pointer Exec-Base->MemList. Just removing the node of FAST memory out of the memory list with Remove() and inserting it again with Insert(). But this could be dangerous, because it's a private structure and could mess everything up. Last edited by dissident; 30 August 2018 at 09:44. |
|
30 August 2018, 09:37 | #10 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Quote:
Quote:
|
||
30 August 2018, 09:37 | #11 | |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Quote:
Yes, using it via Execute() could be a solution, but then my program would require the pre OS2.0 NoFastMem in a OS 2.0+ environment. Last edited by dissident; 30 August 2018 at 09:50. |
|
30 August 2018, 09:41 | #12 |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
|
30 August 2018, 12:36 | #13 |
Registered User
Join Date: Aug 2014
Location: Zagreb / Croatia
Posts: 302
|
I think that some bootblocks can do that. Turn off memory and floppy drives. And some could switch PAL/NTSC.
Last edited by Tomislav; 30 August 2018 at 13:24. |
30 August 2018, 14:43 | #14 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
(But don't ask me how to do that, i've tried to change priority of the mem nodes and it didn't work ). Quote:
Then again, it all depends why you want to remove fastmem from the system. What does your program do ? What is the final goal ? Perhaps better solutions exist than just removing the fastmem. |
||
30 August 2018, 14:57 | #15 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,958
|
Quote:
|
|
30 August 2018, 18:56 | #16 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
It patches AvailMem to never report the fast mem (which stays unallocated), and patches AllocMem to clear the bit of FAST_MEMORY and always return CHIP_MEMORY. |
|
31 August 2018, 08:13 | #17 |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Yes, I know such bootblocks. Often you have a menu there to select PAL/NTSC mode or turn off FAST memory. I didn't check such a bootcode yet, but I guess FAST memory is turned off like the first code I posted. As this routine is called before any CLI window is opened and the bootroutine is a main routine, there can't be much other routines releasing their allocated FAST memory after FAST memory was turned off.
|
31 August 2018, 08:26 | #18 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I fail to see any good use for that in a bootblock.
If you're running your own code, it's a magnitude simpler to just pass the correct flags to allocmem calls in order to get chipmem. And if it's not your own code that runs after, patching it shouldn't be that hard either. |
31 August 2018, 08:46 | #19 | ||
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Quote:
Quote:
Sorry, that I didn't mention it. What I intended to do is loading executable files with LoadSeg(). These files should not be loaded into FAST memory, because it is most likely, they were coded on a machine without extra memory and the coder didn't expect there will be such like in old intros/demos. So FAST memory must be turned off before. After some system modifications, the code of the file is executed. But if any error occurs during my modifications or the file can't be loaded, I have to free the allocated FAST memory and exit my program. To my mind, I already have a solution that is not too complicated with the second code I have posted. |
||
31 August 2018, 08:57 | #20 | |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 256
|
Quote:
Yes, you got it. That's exactly what I will do. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WinUAE 3.2.1. memory dump for fake fast memory areas broken | StingRay | support.WinUAE | 1 | 14 December 2015 20:39 |
A1200 Loses Fast Memory | Amicol | Amiga scene | 24 | 23 February 2014 17:49 |
Adding more then 8 MB of Fast Memory in WINUAE? | Kenan | support.WinUAE | 3 | 16 June 2013 19:20 |
Use of 4MB PCMCIA Fast Flash Memory as Fast RAM in A1200 | nkarytia | support.Hardware | 10 | 16 September 2011 13:37 |
Max Fast Memory In WinUAE | CodyJarrett | support.WinUAE | 11 | 19 April 2002 21:18 |
|
|