New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / c / CPUInfo / main.c
blob1af4576803ff65e986119e7845deff8c16036e15
1 /*
2 (C) 2000 AROS - The Amiga Research OS
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 static const char 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 result;
81 int error = RETURN_OK;
82 IPTR args[NOOFARGS] = { (IPTR)FALSE, };
83 ULONG buffers = 0;
85 rda = ReadArgs(ARG_TEMPLATE, args, NULL);
87 if (rda != NULL)
89 VERBOSE = (BOOL)args[ARG_VERBOSE];
90 FreeArgs(rda);
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" );
119 /* . Main loop . */
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;
131 /* . Main loop . */
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);
164 printf("\n");
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 )
172 //{
173 //printf("WARNING: Number of CPUs in list exceeds MAX no of CPUS [%d]\n", MAX_CPU);
174 //error = RETURN_FAIL;
175 //break;
177 } while ( isLastNode( CPUNode ) == FALSE );
179 printf("\n");
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 );
187 /* .. */
188 printf("Processor List Complete..\n");
190 if (cpu_count != (CPUList->CPU_Physical))
192 error = RETURN_FAIL;
193 printf("WARNING: Number of CPU's in list != registered number (list = %p,Registered= %p).\n",cpu_count,CPUList->CPU_Physical);
196 else
198 error = RETURN_FAIL;
199 printf("ERROR: Couldnt open cpu.resource.\n");
202 return error;