Re: [hatari-devel] Adding cache support for the MegaSTE -> DONE

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 4.9.2024 9.47, Nicolas Pomarède wrote:
Le 04/09/2024 à 01:17, Eero Tamminen a écrit :
On 4.9.2024 0.12, Nicolas Pomarède wrote:
Note that the cache needs to be flushed on every transfer when using Gemdos HD emulation, or normal FDC / HDC. Else this would transfer data to RAM without invalidating the cache (which has no means to know RAM has been modified), thus creating crashes in the emulated program sooner or later.

GEMDOS HD (and NF SCSI driver) are already calling cache invalidation functions...?

Otherwise things would not have worked properly for 030+ caches.

See "git grep Flush.*Cache".


They were already calling them partly ; through STMemory_WriteLong for example, but STMemory_SafeCopy was missing.

so it's quite likely that STMemory_SafeCopy could have messed with the caches since quite some time, it's just that by luck it never triggered a bug.

Only thing in GEMDOS HD calling that, and SafeClear,
is GemDOS_LoadAndReloc(), which is subset of Pexec().

(NF SCSI driver does not use them.)

Because program is typically loaded to unused Atari memory (especially with Hatari autostarting), and there's some code executed between loading the data and actual program execution, it's unlikely to have been an issue with TT and Falcon, as 030 has only 256 bytes of i/d-cache.

Whereas emulation for 040 and 060 (with 4KB and 8KB caches) is often ran with cycle-accuracy i.e. caches disable, for speed reasons as 040/060 programs expect faster than 32Mhz machine...

(Only issues that I remember for 040/060 with caches enabled have been with m68k-linux, and there memory updates are done before emulation starts.)

=> MegaSTE's 16 KB cache is actually largest of these, i.e. most likely to trigger issues with bad cache handling!


	- Eero

PS. Wouldn't most correct behavior for SafeCopy/SafeClear would actually be to have last pieces of data written to memory, going also to cache, instead of cache having been flushed?



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/