English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. System (https://eab.abime.net/forumdisplay.php?f=113)
-   -   Temporary turning FAST memory off (https://eab.abime.net/showthread.php?t=93980)

dissident 31 August 2018 09:05

Quote:

Originally Posted by alkis (Post 1265435)
This.

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.

Good work, alkis. :great So the patching could have done with SetFunction(). Just a short own header-routine to change the memory request passed over in D1 and then run the original AllocMem() function. This patch could be removed easily by resetting the LVO to the original routine.

meynaf 31 August 2018 09:08

Quote:

Originally Posted by dissident (Post 1265561)
Yes, modifying the hunks could be a solution, but fails, if the exe file itself allocates memory not correctly and doesn't request CHIP memory in particular. To be honest, modifying hunks is not something I've done yet. :confused

If the exe file itself allocates memory not correctly, then it's a matter of patching it - something you already do for other reasons. Find calls to exec allocation functions and add the flag.

For altering the executable's header with a chipmem flag, it's not as complicated as it looks.
Get number of hunks at +8. Each one has a size longword, they start at +$14. Replace first byte (which is $00) with $40 and you're done.

Usually old intros will be single hunk and don't perform allocmems so that's a single byte to change. Don't use a tank to go shopping ;).

dissident 31 August 2018 09:14

So, I guess, I've got a solution for my case. I tend to use the second code I posted. If it isn't enough, I will patch AllocMem(). Modifying hunks is too complex for me at the moment, but I will keep this in mind.

Thanks everyone for your good ideas and hints. :bowdown As usual, I've learned something. ;)

dissident 31 August 2018 09:20

Quote:

Originally Posted by meynaf (Post 1265564)
If the exe file itself allocates memory not correctly, then it's a matter of patching it - something you already do for other reasons. Find calls to exec allocation functions and add the flag.

For altering the executable's header with a chipmem flag, it's not as complicated as it looks.
Get number of hunks at +8. Each one has a size longword, they start at +$14. Replace first byte (which is $00) with $40 and you're done.

Usually old intros will be single hunk and don't perform allocmems so that's a single byte to change. Don't use a tank to go shopping ;).

Hmm, modifying the hunks seems not so complex as I thought. It will try this. Thanks for the hints, meynaf.

Toni Wilen 31 August 2018 09:42

If you use LoadSeg() and want to make this more complex and more interesting: use InternalLoadSeg(), it uses caller defined alloc/free functions..

Quote:

Originally Posted by meynaf (Post 1265366)
Less dangerous than removing the entry, would be to set priority so that chipmem is allocated first. Then, no fast mem unless the system runs out of chip.
(But don't ask me how to do that, i've tried to change priority of the mem nodes and it didn't work :D).

You need to re-insert the entry (node) in correct position. Forbid() + Remove() + Enqueue() + Permit().

Memory allocator scans nodes one by one until it finds entry that succeeds in memory allocation. It does not care about priority field.

Hedeon 31 August 2018 09:49

Quote:

Originally Posted by Toni Wilen (Post 1265575)

Memory allocator scans nodes one by one until it finds entry that succeeds in memory allocation. It does not care about priority field.

That is why normally you would Enqueue() the memory node so it gets inserted based on priority. The list indeed gets searched from top to bottom.

So why not just Remove() memory with FASTRAM attributes from the MemList?

Toni Wilen 31 August 2018 09:54

Quote:

Originally Posted by Hedeon (Post 1265576)
That is why normally you would Enqueue() the memory node so it gets inserted based on priority. The list indeed gets searched from top to bottom.

Oops, I meant Enqueue().

Quote:

So why not just Remove() memory with FASTRAM attributes from the MemList?
It was already mentioned: if something (some other process, or OS internal allocation) decides to free memory that was originally allocated from fast ram: crash..

StingRay 31 August 2018 10:21

Quote:

Originally Posted by meynaf (Post 1265554)
I fail to see any good use for that in a bootblock. :confused


Such bootblocks were often used for game/demo compilations and allowed to run stuff which didn't work with fast memory.

Hedeon 31 August 2018 10:24

Quote:

Originally Posted by Toni Wilen (Post 1265579)
It was already mentioned: if something (some other process, or OS internal allocation) decides to free memory that was originally allocated from fast ram: crash..

Meh, me and my lame quick thread scan skills. And you're right of course about the crash. Mem header not found.

sigma63 31 August 2018 10:57

Quote:

Originally Posted by meynaf (Post 1265564)
For altering the executable's header with a chipmem flag, it's not as complicated as it looks.
Get number of hunks at +8. Each one has a size longword, they start at +$14. Replace first byte (which is $00) with $40 and you're done.

There was already a CLI-Command for that purpose called ATOM.
It was part of assemblers/compilers in these good old days :crazy.

If you need, i can look for it.

Cheers

dissident 31 August 2018 19:40

Quote:

Originally Posted by Toni Wilen (Post 1265575)
If you use LoadSeg() and want to make this more complex and more interesting: use InternalLoadSeg(), it uses caller defined alloc/free functions..

I will keep this in mind. A good hint.

Quote:

Originally Posted by Toni Wilen (Post 1265575)
You need to re-insert the entry (node) in correct position. Forbid() + Remove() + Enqueue() + Permit().

Memory allocator scans nodes one by one until it finds entry that succeeds in memory allocation. It does not care about priority field.

This is really interesting and confirms the system's list handling. Every node points to its predecessor and successor. So to insert a node at the head of the list, AddHead() could be used. Or AddTail() to append a note to the tail of the list I guess.

dissident 31 August 2018 19:44

Quote:

Originally Posted by sigma63 (Post 1265591)
There was already a CLI-Command for that purpose called ATOM.
It was part of assemblers/compilers in these good old days :crazy.

If you need, i can look for it.

Cheers

I would be interested in that tool.

Don_Adan 31 August 2018 20:48

Quote:

Originally Posted by dissident (Post 1265561)
Yes, modifying the hunks could be a solution, but fails, if the exe file itself allocates memory not correctly and doesn't request CHIP memory in particular. To be honest, modifying hunks is not something I've done yet. :confused



Yes, you got it. That's exactly what I will do.

For LoadSeg this is very easy job to do. I used hunks modification for one player, i dont remember exactly if i forced this exe player to load to chip ram ($00 to $40) or to load to fast/any ram ($40 to $00) for save some chip ram memory.

Ok. perhaps it was Amplifier version for EaglePlayer 2. For save chip ram. If FastLoading in EP2 was enabled.


All times are GMT +2. The time now is 08:21.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.05347 seconds with 10 queries