Re: How to reliably detect USER or SUPERVISOR mode across CPUs
Posted: Sat Apr 27, 2019 2:29 pm
Nasta wrote:Dave wrote:How might detecting this tie in with detecting and enabling caches on the 68000, 68020, 68030 and 68060?
Enabling cache on a 68000 is REALLY hard.
Detecting it is even harder
In earnest: You don't detect cache on a 68k CPU (some cache modes make it impossible to be "seen" by the CPU itself) - you rather detect the CPU and then "know" the cache type and mode.
That is done by exploiting subtle (or not so subtle) differences between CPUs. The brute-force method is to try instructions or addressing modes that were only available on later CPUs and see if they trap out (you must be catching the exception though, which is a bit complicated). If your CPU does allow non-word-aligned word access, it must be >= 68020, there are also some small differences with post-increment and pre-decrement (move (sp),-(sp)) modes that can be used to detect the CPU you're working with.