Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: srg86 on April 13, 2005, 06:31:20 PM
-
Hi
Is thare any standard algorithm for m68k cpu detection, as in detecting between 000, 010, 020, 030 etc etc. not forgetting the EC varients.
thanks
srg
-
Under AmigaOS you just use the CPU command from the shell. Other than that I don't know of any. 8-)
-
Hmm, WhichAmiga by Piru is a execelent program, gives you a lot of useful system information. You can find it on Aminet. Other similar tools are AmiGod and Scout.
-
This is for use insode my own program, so I can see weather it's safe to procede (requires and MMU).
srg
-
Detecting CPU is trivial job, except when trying to determine between 680EC030 (no mmu) and 68030 (mmu). There is no safe way here, some partially broken 68030 were labeled EC030 and will crash when MMU is used.
Easiest is to test bits in struct ExecBase AttnFlags, that gives you cpu type. That's a good start. Later you can add support for detecting EC040, LC040, EC060 and LC060.
68EC020 vs 68020 test is potentially dangerous as it involves detemining if upper 8bits of address register is ignored (68EC020 only does 24bit addressing, while full 68020 does 32bit).
-
How do I use ExecBase AttnFlags, how do I access it, I tried declaring:
ExecBase e_base;
and AttnFlags was 0
then I tried:
ExecBase *e_base;
and AttnFlags was $FFFF.
srg
-
#include <exec/execbase.h>
#include <proto/dos.h>
extern struct ExecBase *SysBase;
const char *getcpu(void);
int main(void)
{
Printf("CPU: %s\n", getcpu());
return 0;
}
const char *getcpu(void)
{
UWORD attnflags = SysBase->AttnFlags;
if (attnflags & 0x80) return "68060";
if (attnflags & AFF_68040) return "68040";
if (attnflags & AFF_68030) return "68030";
if (attnflags & AFF_68020) return "68020";
if (attnflags & AFF_68010) return "68010";
return "68000";
}
-
Thanks that's great.
srg