CPCWiki forum

General Category => Programming => Topic started by: m_dr_m on 09:48, 15 April 20

Title: Ultra-fast and **non-destructive** RAM detection
Post by: m_dr_m on 09:48, 15 April 20
'joir. I'm quite bothered by Parados or YANCC corrupting all the memory just to measure how much RAM there is.
Granted, Orgams is also trashing some banks, yet only the ones it uses, and for the good cause: persistence across resets!

It's quite easy to detect RAM without corrupting it.
On top of that:
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: GUNHED on 12:35, 15 April 20
Using FutureOS there is a probably more quick and of course non-destructive way:

1. Bank in all expansion RAM (E-RAM) one after another, save bytes from &4000 / &4001 and then write to &4000/1 the physical RAM select (this is &78C4 up to &7FFF using 4 MB E-RAM space)
2. Assessing the bytes at &4000/1 (each E-RAM) and comparing them to the actual E-RAM configuration in BC, setting status bits for each E-RAM
3. Restoring the data in all E-RAMs at &4000/1

Why is it important to keep E-RAMs intact? Well, lots of users love RDOS and the 444 KB RAM disc it provides. Also supported by native OS and CP/M 2.2, CP/M Plus and so on...  :)
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: m_dr_m on 17:50, 15 April 20
That's slightly less reset-proof (: I.e. if a reset occurs before you have restored the bytes, all banks traversed are corrupted. With an incremental approach, you have to be very unlucky to trash just one bank!


BTW, why do you store 2 bytes for each?
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: SOS on 18:02, 15 April 20
Quote from: m_dr_m on 09:48, 15 April 20
'joir. I'm quite bothered by Parados or YANCC corrupting all the memory just to measure how much RAM there is.

You can easily give a tip in the YACC thread for improvement ;)

I need only one 16KB-Bank, so it should be enough to test against bank C4 if it exist or not?!
(is there any RAM-Extension available for the CPC464(Plus), which are not using C4-Bank?)
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: roudoudou on 19:05, 15 April 20
Quote from: m_dr_m on 17:50, 15 April 20
BTW, why do you store 2 bytes for each?
easier and faster to store BC switching value in the memory
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: roudoudou on 19:25, 15 April 20
Quote from: m_dr_m on 17:50, 15 April 20
That's slightly less reset-proof (: I.e. if a reset occurs before you have restored the bytes, all banks traversed are corrupted. With an incremental approach, you have to be very unlucky to trash just one bank!


BTW, why do you store 2 bytes for each?
Plus you cannot use incremental approach with moar than 512K due to decoding IO right?
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: GUNHED on 20:41, 15 April 20
Quote from: m_dr_m on 17:50, 15 April 20
That's slightly less reset-proof (: I.e. if a reset occurs before you have restored the bytes, all banks traversed are corrupted. With an incremental approach, you have to be very unlucky to trash just one bank!


BTW, why do you store 2 bytes for each?
Chances for a reset in about 0,001 seconds? I don't care.
Yes, two bytes. RAM select as indicated before. Checking for 4 MB RAM needs two bytes.
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: m_dr_m on 19:46, 16 April 20
Quote from: SOS on 18:02, 15 April 20
You can easily give a tip in the YACC thread for improvement ;)


I thought I already complained at one point, that's why i chose this more constructive approach!

I don't consider 7FC4 to 7FC7 as persistent memory, they can be trashed at will. By the way there is also 7CC4 to 7CC7 available from the CPC RAM (when a X-Mem is plugged).
So, yes, if your test just pokes C4, it would be perfect.



QuotePlus you cannot use incremental approach with moar than 512K due to decoding IO right?


Why not?

Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: SOS on 21:26, 16 April 20
Quote from: m_dr_m on 19:46, 16 April 20
I thought I already complained at one point

Öhh, nooo, not to me :blank:
I will change the RAM-Detection to the fixed question "Is 7FC4 as an RAM-Bank available - or not?".
Keeps the Code short & simple  :D
(but cost time, i must first release the next CubeMDOS-Version)
Title: Re: Ultra-fast and **non-destructive** RAM detection
Post by: roudoudou on 00:02, 17 April 20
Quote from: m_dr_m on 19:46, 16 April 20
I don't consider 7FC4 to 7FC7 as persistent memory, they can be trashed at will. By the way there is also 7CC4 to 7CC7 available from the CPC RAM (when a X-Mem is plugged).
So, yes, if your test just pokes C4, it would be perfect.

Why not?
#7CC4 is not CPC RAM with 2M memory expansion, you will experience confusion between 512K slots, like you just did
Powered by SMFPacks Menu Editor Mod