Welcome, Guest. Please login or register.

Author Topic: How to detect CPU?  (Read 3280 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ejstansTopic starter

  • Newbie
  • *
  • Join Date: Jun 2009
  • Posts: 48
    • Show only replies by ejstans
How to detect CPU?
« on: July 23, 2009, 10:49:41 PM »
Hello (Again? Possible repost as forum seems to have eaten my previous one...)

Is there a way to determine the model (68000 - 68060) of the CPU? The old "How to code" document suggest to check the AttnFlags of Exec, but this only supports up to 68040, at least on V3.0. Does later versions support 68060? And how does the OS detect the model of the CPU anyway?
Also, short of trying to measure it, is there a way to determine the clock frequency of the CPU?

Thanks!
"It is preferable not to travel with a dead machine."

A500 1.3 / 512KiB slowmem / GVP HD8 w/ 8MiB fastmem & 52MB HDD
A600 2.05 / 1GB SSD
A1200 3.0 / Blizzard 1200/4 w/ 68882 @ 33MHz / 1GB SSD
A1200T 3.0 / Apollo 1260 w/ 68EC060 @ 50MHz & 16 MiB fastmem / 4GB SSD
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: How to detect CPU?
« Reply #1 on: July 24, 2009, 12:05:57 AM »
You can still use AttnFlags, but you might have to #define the value:

#ifndef AFB_68060
#define AFB_68060 7
#endif

#ifndef AFF_68060
#define AFF_68060 (1<#endif

I believe this only works if the 68060.library is installed. As for speed, timing a known-cycle (per CPU type) loop seems to be a way to do it, but you'll need to ensure the instruction cache (if present) is enabled.

Piru would be the man to ask as his WhichAmiga tool detects the entire gamut of m68k amiga configurations.
« Last Edit: July 24, 2009, 12:08:56 AM by Karlos »
int p; // A
 

Offline boing4000

  • Full Member
  • ***
  • Join Date: Apr 2006
  • Posts: 222
    • Show only replies by boing4000
    • http://www.amigademo.de
Re: How to detect CPU?
« Reply #2 on: July 24, 2009, 06:14:01 PM »
Take a look at this archive:
http://aminet.net/package/util/moni/WhichAmiga

It also contain the assembly source code with all kind of info and hardware detection issue.
 

Offline ejstansTopic starter

  • Newbie
  • *
  • Join Date: Jun 2009
  • Posts: 48
    • Show only replies by ejstans
Re: How to detect CPU?
« Reply #3 on: July 24, 2009, 07:27:12 PM »
Great! I think that's exactly what I need! :)

Thanks!
"It is preferable not to travel with a dead machine."

A500 1.3 / 512KiB slowmem / GVP HD8 w/ 8MiB fastmem & 52MB HDD
A600 2.05 / 1GB SSD
A1200 3.0 / Blizzard 1200/4 w/ 68882 @ 33MHz / 1GB SSD
A1200T 3.0 / Apollo 1260 w/ 68EC060 @ 50MHz & 16 MiB fastmem / 4GB SSD
 

Offline terminator4

  • Sr. Member
  • ****
  • Join Date: Dec 2003
  • Posts: 359
    • Show only replies by terminator4
    • http://none
Re: How to detect CPU?
« Reply #4 on: July 24, 2009, 07:43:23 PM »
Quote from: Karlos;516689

Piru would be the man to ask as his WhichAmiga tool detects the entire gamut of m68k amiga configurations.


Lets not exaggerate, not entire gamut.  Works fine on my Amiga 4000 060 but not with A2000 060.   In that respect it was quite disappointing for me.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: How to detect CPU?
« Reply #5 on: July 24, 2009, 08:22:26 PM »
Quote from: terminator4;516744
Lets not exaggerate, not entire gamut.  Works fine on my Amiga 4000 060 but not with A2000 060.   In that respect it was quite disappointing for me.


What I meant was it clearly has code that can differentiate 060 from every other m68k that has been used in an Amiga, which means that Piru obviously knows a suitable method.
int p; // A
 

Offline delshay

  • Hero Member
  • *****
  • Join Date: Mar 2004
  • Posts: 1009
    • Show only replies by delshay
Re: How to detect CPU?
« Reply #6 on: July 24, 2009, 09:42:41 PM »
i wonder if any program can detect my freescale MC68EC020AA25 located on my A1200 motherboard.
-------------
power is nothing without control
 

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: How to detect CPU?
« Reply #7 on: July 24, 2009, 10:20:31 PM »
Quote from: delshay;516752
i wonder if any program can detect my freescale MC68EC020AA25 located on my A1200 motherboard.
WhichAmiga can at least tell 68EC020 from full 68020.

Regarding WhichAmiga failing on certain configurations: It is a known feature. Unfortunately it's impossible to make such a hacky application work on every imaginable configuration.
 

Offline x303

Re: How to detect CPU?
« Reply #8 on: July 24, 2009, 10:32:59 PM »
What you need is this:

UBYTE *cpu[]= { "MC68000", "MC68010", "MC68020", "MC68030", "XC68040", "XC68060" };
int cpux=0;

int main()
{

UBYTE cpuname[40];
.......
checkcpu();
strcpy(cpuname, "CPU = ");
 strcat(cpuname, cpu[cpux]);
.......
}

void checkcpu(void)
{
  UWORD attn = SysBase->AttnFlags;

  if(attn & AFF_68010)
  {
    cpux=1;
  }
  if(attn & AFF_68020)
  {
    cpux=2;
  }
  if(attn & AFF_68030)
  {
    cpux=3;
  }
  if(attn & AFF_68040)
  {
    cpux=4;
  }
  if(attn & AFF_68060)
  {
    cpux=5;
  }
}

x303 :D :D :D
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: How to detect CPU?
« Reply #9 on: July 24, 2009, 10:44:55 PM »
If you need to differentiate between EC and non-EC versions, AttnFlags is no longer sufficient.

Incidentally, AFB_68060/AFF_68060 didn't seem to be #defined in any of my NDK versions.
int p; // A
 

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: How to detect CPU?
« Reply #10 on: July 24, 2009, 11:55:59 PM »
Quote from: Karlos;516759
If you need to differentiate between EC and non-EC versions, AttnFlags is no longer sufficient.

Incidentally, AFB_68060/AFF_68060 didn't seem to be #defined in any of my NDK versions.

68060 was never supported officially by commodore, so the define didn't make any C= NDK, either.

Basically phase5 (and Ralph Schmidt) defined all of that 68060 stuff. See here:

http://www.aminet.net/dev/misc/68060Guide.txt
 

Offline x303

Re: How to detect CPU?
« Reply #11 on: July 25, 2009, 06:25:00 PM »
Quote from: Karlos;516759
Incidentally, AFB_68060/AFF_68060 didn't seem to be #defined in any of my NDK versions.

Have you tried ndk os3.9 ? AFB_68060 and AFF_68060 are defined in exec/execbase.h !!!

x303 :D :D :D
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: How to detect CPU?
« Reply #12 on: July 25, 2009, 09:43:28 PM »
Quote from: x303;516831
Have you tried ndk os3.9 ? AFB_68060 and AFF_68060 are defined in exec/execbase.h !!!

x303 :D :D :D


Yes, but not in exec/execbase.i

It should look like this...

   BITDEF   AF,FPU40,6   ; Set if 68040/68060 FPU
   BITDEF   AF,68060,7   ; Set if 68060

The 68060 is bit 7 so we can do a tst.b to check it...

   tst.b (AttnFlags+1,a6)   ;btst #AFB_68060,(AttnFlags+1,a6)

Saves 2 bytes and it's faster on some 68k processors ;).
 

Offline JosephC

  • Jr. Member
  • **
  • Join Date: Aug 2007
  • Posts: 63
    • Show only replies by JosephC
Re: How to detect CPU?
« Reply #13 on: July 25, 2009, 11:57:40 PM »
How does one detect if running on ECS or AGA?
 

Offline x303

Re: How to detect CPU?
« Reply #14 on: July 26, 2009, 03:06:53 AM »
Quote from: JosephC;516852
How does one detect if running on ECS or AGA?

    Taken from RandyAGA.doc:

          LEA     $DFF000,A5
           MOVE.W  $7C(A5),D0      ; DeniseID or LisaID in AGA
           MOVEQ   #30,D2          ; Check 30 times ( prevents old denise random)
           ANDI.W  #%000000011111111,d0    ; low byte only
DENLOOP:
           MOVE.W  $7C(A5),D1      ; Denise ID (LisaID on AGA)
           ANDI.W  #%000000011111111,d1    ; low byte only
           CMP.B   d0,d1           ; same value?
           BNE.S   NOTAGA          ; Not the same value, then OCS Denise!
           DBRA    D2,DENLOOP      ; (THANX TO DDT/HBT FOR MULTICHECK HINT)
           ORI.B   #%11110000,D0   ; MASK AGA REVISION (will work on new aga)
           CMPI.B  #%11111000,D0   ; BIT 3=AGA (this bit will be=0 in AAA!)
           BNE.S   NOTAGA          ; IS THE AGA CHIPSET PRESENT?
           ST.B    AGA             ; Set the AGA flag that will be tested later
NOTAGA:                         ; NOT AGA, BUT IS POSSIBLE AN AAA MACHINE!!

You can find it here: http://aminet.net/docs/misc/RandyAGA.lha

x303 :D :D :D