Welcome, Guest. Please login or register.

Author Topic: CPU detection  (Read 3479 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline srg86Topic starter

  • Full Member
  • ***
  • Join Date: Aug 2004
  • Posts: 211
    • Show only replies by srg86
    • http://www.aopp12.dsl.pipex.com
CPU detection
« 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
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2281
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: CPU detection
« Reply #1 on: April 13, 2005, 06:41:56 PM »
Under AmigaOS you just use the CPU command from the shell.  Other than that I don't know of any.  8-)
 

Offline doctorq

  • Hero Member
  • *****
  • Join Date: Aug 2003
  • Posts: 2082
    • Show only replies by doctorq
Re: CPU detection
« Reply #2 on: April 13, 2005, 06:44:31 PM »
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.
 

Offline srg86Topic starter

  • Full Member
  • ***
  • Join Date: Aug 2004
  • Posts: 211
    • Show only replies by srg86
    • http://www.aopp12.dsl.pipex.com
Re: CPU detection
« Reply #3 on: April 13, 2005, 06:45:44 PM »
This is for use insode my own program, so I can see weather it's safe to procede (requires and MMU).

srg
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: CPU detection
« Reply #4 on: April 13, 2005, 08:58:20 PM »
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).
 

Offline srg86Topic starter

  • Full Member
  • ***
  • Join Date: Aug 2004
  • Posts: 211
    • Show only replies by srg86
    • http://www.aopp12.dsl.pipex.com
Re: CPU detection
« Reply #5 on: April 15, 2005, 10:21:37 AM »
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
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: CPU detection
« Reply #6 on: April 15, 2005, 10:26:58 AM »
Code: [Select]

#include <exec/execbase.h>

#include <proto/dos.h>

extern struct ExecBase *SysBase;

const char *getcpu(void);

int main(void)
{
  Printf(&quot;CPU: %s\n&quot;, getcpu());
  return 0;
}

const char *getcpu(void)
{
  UWORD attnflags = SysBase->AttnFlags;

  if (attnflags & 0x80) return &quot;68060&quot;;
  if (attnflags & AFF_68040) return &quot;68040&quot;;
  if (attnflags & AFF_68030) return &quot;68030&quot;;
  if (attnflags & AFF_68020) return &quot;68020&quot;;
  if (attnflags & AFF_68010) return &quot;68010&quot;;
  return &quot;68000&quot;;
}
 

Offline srg86Topic starter

  • Full Member
  • ***
  • Join Date: Aug 2004
  • Posts: 211
    • Show only replies by srg86
    • http://www.aopp12.dsl.pipex.com
Re: CPU detection
« Reply #7 on: April 15, 2005, 02:18:21 PM »
Thanks that's great.

srg