typo.
[AROS.git] / workbench / c / CPUInfo / main.c
blob105b69894c710d0a09e29264824c431fa60d9370
1 /*
2 Copyright © 2000-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Probe installed CPUs and display relevant information
6 Lang: english
7 */
9 /* BIG TO DO - SEPERATE THE INDIVIDUAL PROCESSOR FAMILY "PROBES" INTO RUNTIME SHARED LIBS OR SIMILAR */
11 /****************************************************************************************************
12 Currently Supports:
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
18 UMC
19 NexGen Nx586
20 Centaur C6/C2/C3
21 Rise Technology mP6
22 SiS 55x
23 Transmeta Crusoe TM3x00 and TM5x00
24 National Semiconductor Geode
26 Soon....
28 PPC?
30 *****************************************************************************************************/
32 #include "cpuinfo.h"
34 /********************************************
35 Version Information
36 ********************************************/
38 const TEXT version[] = VERSTAG;
39 BOOL VERBOSE=FALSE;
41 /********************************************
42 C Functions
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 ********************************************/
72 int main ( void )
74 struct CPUBase *CPUResBase;
75 struct CPU_Definition *CPUList, *FoundCPUs;
76 struct CPUFam_Definition *FamilyList, *FoundFamilies;
77 struct RDArgs *rda;
78 struct MinNode *CPUNode, *FamilyNode;
79 int cpu_count, family_count, currentFamily;
80 int error = RETURN_OK;
81 IPTR args[NOOFARGS] = { (IPTR)FALSE, };
83 rda = ReadArgs(ARG_TEMPLATE, args, NULL);
85 if (rda != NULL)
87 VERBOSE = (BOOL)args[ARG_VERBOSE];
88 FreeArgs(rda);
91 printf( APPNAME " - CPU Information tool v" VERSSTRING ".\n" );
92 printf( "© Copyright the AROS Dev Team.\n");
93 printf( "-------------------------------------\n\n" );
95 if (VERBOSE) printf( " Performing VERBOSE Probe...\n\n" );
97 if (( CPUResBase = OpenResource( "cpu.resource" ) ))
99 cpu_count = 0; /* Initialise the cpu list counter */
100 CPUList = (struct CPU_Definition *)CPUResBase->CPUB_Processors;
102 family_count = 0; /* Initialise the family list counter */
103 FamilyList = (struct CPUFam_Definition *)CPUResBase->CPUB_ProcFamilies;
104 FoundFamilies = FamilyList;
106 printf( "CPUBase->CPUB_ProcFamilies contains Family list @ %p\n\n", FamilyList );
108 FoundCPUs = (struct CPU_Definition *)CPUList->CPU_CPUList.mlh_Head;
110 printf( "CPUBase->CPUB_Processors contains CPU list @ %p\n\n", CPUList );
111 printf( "Found CPU(s) @ %p\n\n", FoundCPUs );
113 if ( CPUList->CPU_Physical == 1) printf("1 Processor is " );
114 else printf( "%u Processor's are ", CPUList->CPU_Physical );
115 printf( "present in this system.\n\n" );
117 /* . Main loop . */
118 FamilyNode = (struct MinNode *)&FamilyList->CPUF_FamilyList.mlh_Head;
121 FoundCPUs = (struct CPU_Definition *)CPUList->CPU_CPUList.mlh_Head;
123 printf( "Processor Family ID : %d\n", FoundFamilies->CPUF_FamilyID );
124 printf( "Processor Family Name: %s\nn", (char *)FoundFamilies->CPUF_Name );
125 printf( "Processor Handler @ %p\nn", FoundFamilies->CPUF_Resource );
127 currentFamily = FoundFamilies->CPUF_FamilyID;
129 /* . Main loop . */
130 CPUNode = (struct MinNode *)&CPUList->CPU_CPUList.mlh_Head;
133 if ( currentFamily == FoundCPUs->CPU_Family )
135 printf( " Processor ID : %u [PhysicalID = %u] @ %p ", FoundCPUs->CPU_ID, FoundCPUs->CPU_Physical, FoundCPUs );
136 if ( FoundCPUs->CPU_BootCPU == TRUE) printf( "[BOOT PROCESSOR]" );
138 if ( FoundCPUs->CPU_IsOnline == TRUE) printf(" (online)\n");
139 else printf( " (offline)\n" );
141 printf( " Processor Family : [0x%08x]\n", FoundCPUs->CPU_Family );
142 printf( " Processor Model : [0x%08x]\n", FoundCPUs->CPU_Model );
144 if ( VERBOSE ) /* Perform a thorough CPU list? */
147 if ( FoundCPUs->CPU_Family == CPU_Family_i386 ) parse_i386((struct i386_compat_intern *)FoundCPUs->CPU_Private1,FoundCPUs->CPU_ID);
151 if ( FoundCPUs->CPU_SMPGroup )
153 struct SMP_Definition *CPUsSMPGrp;
155 CPUsSMPGrp = (struct SMP_Definition *)FoundCPUs->CPU_SMPGroup;
157 /* . This CPU is a member of an SMP group .. */
158 printf(" Member of SMP Group @ %p\n", CPUsSMPGrp);
159 printf(" SMP Group Member No. %d of %d\n", FoundCPUs->CPU_Physical + 1, CPUsSMPGrp->SMP_CPUCount);
162 printf("\n");
164 cpu_count++; /* . All done with this CPU .. */
166 CPUNode = (struct MinNode *)&FoundCPUs->CPU_CPUList.mlh_Head;
167 FoundCPUs = (struct CPU_Definition *)CPUNode->mln_Succ; /* get the next cpu in the list .. */
169 //if ( cpu_count > MAX_CPU )
170 //{
171 //printf("WARNING: Number of CPUs in list exceeds MAX no of CPUS [%d]\n", MAX_CPU);
172 //error = RETURN_FAIL;
173 //break;
175 } while ( isLastNode( CPUNode ) == FALSE );
177 printf("\n");
178 family_count++; /* . All done with this CPU .. */
180 FamilyNode = (struct MinNode *)&FoundFamilies->CPUF_FamilyList.mlh_Head;
181 FoundFamilies = (struct CPUFam_Definition *)FamilyNode->mln_Succ; /* get the next cpu in the list .. */
183 } while ( isLastNode( FamilyNode ) == FALSE );
185 /* .. */
186 printf("Processor List Complete..\n");
188 if (cpu_count != (CPUList->CPU_Physical))
190 error = RETURN_FAIL;
191 printf("WARNING: Number of CPU's in list != registered number (list = %d,Registered= %d).\n",cpu_count, CPUList->CPU_Physical);
194 else
196 error = RETURN_FAIL;
197 printf("ERROR: Couldnt open cpu.resource.\n");
200 return error;