2 (C) 2000 AROS - The Amiga Research OS
5 Desc: Probe installed CPUs and display relevant information
9 /* BIG TO DO - SEPERATE THE INDIVIDUAL PROCESSOR FAMILY "PROBES" INTO RUNTIME SHARED LIBS OR SIMILAR */
11 /****************************************************************************************************
14 i386 compatable families...
15 AMD 486/5x86/K5/K6/K6-II/K6-III/Athlon/Duron/Opteron/Athlon64
16 Intel P5/P54C/P55C/P24T/P6/P2/P3/PM/Itanium(IA-64)
17 Cyrix 5x86/M1/MediaGX/M2
23 Transmeta Crusoe TM3x00 and TM5x00
24 National Semiconductor Geode
30 *****************************************************************************************************/
34 /********************************************
36 ********************************************/
38 static const char version
[] = VERSTAG
;
41 /********************************************
43 ********************************************/
45 BOOL
isLastNode ( struct MinNode
*CurrNode
)
47 struct MinNode
*NextNode
;
49 if ( CurrNode
->mln_Succ
== NULL
) return TRUE
;
51 NextNode
= ( struct MinNode
*)CurrNode
->mln_Succ
;
52 if ( NextNode
->mln_Succ
!= NULL
) return FALSE
;
54 return TRUE
; /* yes we are the last .. */
57 /********************************************/
59 int AddBufferLine ( int buffpos
, char *buffer
, char *line
)
61 ULONG size
= strlen( line
);
63 sprintf ( buffer
+ buffpos
, line
);
64 return ( buffpos
+= size
);
68 /********************************************
69 Actual Code... Main Entry
70 ********************************************/
74 struct CPUBase
*CPUResBase
;
75 struct CPU_Definition
*CPUList
, *FoundCPUs
;
76 struct CPUFam_Definition
*FamilyList
, *FoundFamilies
;
78 struct MinNode
*CPUNode
, *FamilyNode
;
79 int cpu_count
, family_count
, currentFamily
;
81 int error
= RETURN_OK
;
82 IPTR args
[NOOFARGS
] = { (IPTR
)FALSE
, };
85 rda
= ReadArgs(ARG_TEMPLATE
, args
, NULL
);
89 VERBOSE
= (BOOL
)args
[ARG_VERBOSE
];
93 printf( APPNAME
" - CPU Information tool v" VERSSTRING
".\n" );
94 printf( "© Copyright the AROS Dev Team.\n");
95 printf( "-------------------------------------\n\n" );
97 if (VERBOSE
) printf( " Performing VERBOSE Probe...\n\n" );
99 if ( CPUResBase
= OpenResource( "cpu.resource" ) )
101 cpu_count
= 0; /* Initialise the cpu list counter */
102 CPUList
= (struct CPU_Definition
*)CPUResBase
->CPUB_Processors
;
104 family_count
= 0; /* Initialise the family list counter */
105 FamilyList
= (struct CPUFam_Definition
*)CPUResBase
->CPUB_ProcFamilies
;
106 FoundFamilies
= FamilyList
;
108 printf( "CPUBase->CPUB_ProcFamilies contains Family list @ %p\n\n", FamilyList
);
110 FoundCPUs
= (struct CPU_Definition
*)CPUList
->CPU_CPUList
.mlh_Head
;
112 printf( "CPUBase->CPUB_Processors contains CPU list @ %p\n\n", CPUList
);
113 printf( "Found CPU(s) @ %p\n\n", FoundCPUs
);
115 if ( CPUList
->CPU_Physical
== 1) printf("1 Processor is " );
116 else printf( "%u Processor's are ", CPUList
->CPU_Physical
);
117 printf( "present in this system.\n\n" );
120 FamilyNode
= (struct MinNode
*)&FamilyList
->CPUF_FamilyList
.mlh_Head
;
123 FoundCPUs
= (struct CPU_Definition
*)CPUList
->CPU_CPUList
.mlh_Head
;
125 printf( "Processor Family ID : %d\n", FoundFamilies
->CPUF_FamilyID
);
126 printf( "Processor Family Name: %s\nn", FoundFamilies
->CPUF_Name
);
127 printf( "Processor Handler @ %p\nn", FoundFamilies
->CPUF_Resource
);
129 currentFamily
= FoundFamilies
->CPUF_FamilyID
;
132 CPUNode
= (struct MinNode
*)&CPUList
->CPU_CPUList
.mlh_Head
;
135 if ( currentFamily
== FoundCPUs
->CPU_Family
)
137 printf( " Processor ID : %u [PhysicalID = %u] @ %p ", FoundCPUs
->CPU_ID
, FoundCPUs
->CPU_Physical
, FoundCPUs
);
138 if ( FoundCPUs
->CPU_BootCPU
== TRUE
) printf( "[BOOT PROCESSOR]" );
140 if ( FoundCPUs
->CPU_IsOnline
== TRUE
) printf(" (online)\n");
141 else printf( " (offline)\n" );
143 printf( " Processor Family : [%p]\n", FoundCPUs
->CPU_Family
);
144 printf( " Processor Model : [%p]\n", FoundCPUs
->CPU_Model
);
146 if ( VERBOSE
) /* Perform a thorough CPU list? */
149 if ( FoundCPUs
->CPU_Family
== CPU_Family_i386
) parse_i386((struct i386_compat_intern
*)FoundCPUs
->CPU_Private1
,FoundCPUs
->CPU_ID
);
153 if ( FoundCPUs
->CPU_SMPGroup
)
155 struct SMP_Definition
*CPUsSMPGrp
;
157 CPUsSMPGrp
= FoundCPUs
->CPU_SMPGroup
;
159 /* . This CPU is a member of an SMP group .. */
160 printf(" Member of SMP Group @ %p\n", CPUsSMPGrp
);
161 printf(" SMP Group Member No. %d of %d\n", FoundCPUs
->CPU_Physical
+ 1, CPUsSMPGrp
->SMP_CPUCount
);
166 cpu_count
++; /* . All done with this CPU .. */
168 CPUNode
= (struct MinNode
*)&FoundCPUs
->CPU_CPUList
.mlh_Head
;
169 FoundCPUs
= (struct CPU_Definition
*)CPUNode
->mln_Succ
; /* get the next cpu in the list .. */
171 //if ( cpu_count > MAX_CPU )
173 //printf("WARNING: Number of CPUs in list exceeds MAX no of CPUS [%d]\n", MAX_CPU);
174 //error = RETURN_FAIL;
177 } while ( isLastNode( CPUNode
) == FALSE
);
180 family_count
++; /* . All done with this CPU .. */
182 FamilyNode
= (struct MinNode
*)&FoundFamilies
->CPUF_FamilyList
.mlh_Head
;
183 FoundFamilies
= (struct CPUFam_Definition
*)FamilyNode
->mln_Succ
; /* get the next cpu in the list .. */
185 } while ( isLastNode( FamilyNode
) == FALSE
);
188 printf("Processor List Complete..\n");
190 if (cpu_count
!= (CPUList
->CPU_Physical
))
193 printf("WARNING: Number of CPU's in list != registered number (list = %p,Registered= %p).\n",cpu_count
,CPUList
->CPU_Physical
);
199 printf("ERROR: Couldnt open cpu.resource.\n");