625daa063c2a7ef89f3d3de389948cf6db27a3bc
[AROS.git] / arch / ppc-native / processor / getcpuinfo.c
blob625daa063c2a7ef89f3d3de389948cf6db27a3bc
1 /*
2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: GetCPUInfo() - Provides information about installed CPUs
6 Lang: english
7 */
9 #define DEBUG 0
11 #include <aros/debug.h>
12 #include <exec/types.h>
13 #include <aros/libcall.h>
14 #include <proto/utility.h>
15 #include <resources/processor.h>
17 #include "defaults.h"
18 #include "processor_intern_arch.h"
20 /*****************************************************************************
22 NAME */
23 #include <proto/processor.h>
25 AROS_LH1(void, GetCPUInfo,
27 /* SYNOPSIS */
28 AROS_LHA(struct TagItem *, tagList, A0),
30 /* LOCATION */
31 struct ProcessorBase *, ProcessorBase, 1, Processor)
33 /* FUNCTION
35 Provides information about selected processor in the system
37 INPUTS
39 Function takes an array of tags. Data is returned for each tag. See
40 specific tag description. There is a control tag CGIT_SelecetProcessor.
42 TAGS
44 GCIT_SelectedProcessor - (ULONG) When this tag is set correctly, information
45 about choosen processor is provided. If this
46 tag is missing or this tag has invalid value,
47 information about first processor is returned.
49 GCIT_NumberOfProcessors - (ULONG *) Provides the number of processors
50 present in the system.
52 GCIT_ModelString - (CONST_STRPTR *) Provides the name of the model of the
53 processor. The string is considered read-only.
55 GCIT_Family - (ULONG *) Provides designation of processor family using
56 one of the CPUFAMILY_XXX values.
58 GCIT_VectorUnit - (ULONG *) Provides designation of available vectory
59 unit using one of the VECTORTYPE_XXX values.
61 GCIT_Architecture - (ULONG *) Provides designation of processor
62 architecture using one of the PROCESSORARCH_XXX
63 values.
65 GCIT_Endianness - (ULONG *) Provides designation of current processor
66 endianness using one of the ENDIANNESS_XXX values.
68 GCIT_ProcessorSpeed - (UQUAD *) Provides the current CPU speed in Hz
70 GCIT_FrontsideSpeed - (UQUAD *) Provides the current FSB speed in Hz
72 GCIT_ProcessorLoad - (UBYTE *) Provides the current CPU load in % (0-100)
74 Cache sizes - (ULONG *) Following tags are used to retrieve size of
75 specified caches.
77 GCIT_L1CacheSize
78 GCIT_L1DataCacheSize
79 GCIT_L1InstructionCacheSize
80 GCIT_L2CacheSize
81 GCIT_L3CacheSize
83 Size is returned in kB.
85 GCIT_CacheLineSize - (ULONG *) Provides the size of cache line in bytes.
86 In case these sizes differ per cache level, the
87 smallest size if provided.
89 Features - (BOOL *) Following tags are used to check availability of
90 certain features. The result is always a boolean.
92 GCIT_SupportsFPU
93 GCIT_SupportsAltiVec
94 GCIT_SupportsVMX
95 GCIT_SupportsMMX
96 GCIT_SupportsMMXEXT
97 GCIT_Supports3DNOW
98 GCIT_Supports3DNOWEXT
99 GCIT_SupportsSSE
100 GCIT_SupportsSSE2
101 GCIT_SupportsSSE3
102 GCIT_SupportsSSSE3
103 GCIT_SupportsSSE41
104 GCIT_SupportsSSE42
105 GCIT_SupportsSSE4A
106 GCIT_SupportsVME
107 GCIT_SupportsPSE
108 GCIT_SupportsPAE
109 GCIT_SupportsCX8
110 GCIT_SupportsAPIC
111 GCIT_SupportsCMOV
112 GCIT_SupportsPSE36
113 GCIT_SupportsCLFSH
114 GCIT_SupportsACPI
115 GCIT_SupportsFXSR
116 GCIT_SupportsHTT
117 GCIT_SupportsCX16
118 GCIT_SupportsVirtualization
119 GCIT_SupportsNoExecutionBit
120 GCIT_Supports64BitMode
121 GCIT_SupportsMSR
123 RESULT
125 None
127 NOTES
129 EXAMPLE
131 BUGS
133 SEE ALSO
135 INTERNALS
137 ******************************************************************************/
139 AROS_LIBFUNC_INIT
141 struct TagItem * passedTag = NULL;
142 struct SystemProcessors *sp = ProcessorBase->Private1;
144 while ((passedTag = LibNextTagItem(&tagList)) != NULL)
146 if ((passedTag->ti_Tag > GCIT_FeaturesBase) &&
147 (passedTag->ti_Tag <= GCIT_FeaturesLast))
149 *((BOOL *)passedTag->ti_Data) = FALSE;
150 continue;
152 else
154 switch(passedTag->ti_Tag)
156 case(GCIT_NumberOfProcessors):
157 *((ULONG *)passedTag->ti_Data) = ProcessorBase->cpucount;
158 break;
159 case(GCIT_Model):
160 *((ULONG *)passedTag->ti_Data) = sp->sp_PVR;
161 break;
162 case(GCIT_ModelString):
163 *((CONST_STRPTR *)passedTag->ti_Data) = "PowerPC";
164 break;
165 case(GCIT_Family):
166 *((ULONG *)passedTag->ti_Data) = CPUFAMILY_UNKNOWN;
167 break;
168 case(GCIT_VectorUnit):
169 *((ULONG *)passedTag->ti_Data) = VECTORTYPE_NONE;
170 break;
171 case(GCIT_L1CacheSize):
172 *((ULONG *)passedTag->ti_Data) = 0;
173 break;
174 case(GCIT_L1DataCacheSize):
175 *((ULONG *)passedTag->ti_Data) = 0;
176 break;
177 case(GCIT_L1InstructionCacheSize):
178 *((ULONG *)passedTag->ti_Data) = 0;
179 break;
180 case(GCIT_L2CacheSize):
181 *((ULONG *)passedTag->ti_Data) = 0;
182 break;
183 case(GCIT_L3CacheSize):
184 *((ULONG *)passedTag->ti_Data) = 0;
185 break;
186 case(GCIT_CacheLineSize):
187 *((ULONG *)passedTag->ti_Data) = 0;
188 break;
189 case(GCIT_Architecture):
190 *((ULONG *)passedTag->ti_Data) = PROCESSORARCH_DEF;
191 break;
192 case(GCIT_Endianness):
193 *((ULONG *)passedTag->ti_Data) = ENDIANNESS_DEF;
194 break;
195 case(GCIT_ProcessorSpeed):
196 *((UQUAD *)passedTag->ti_Data) = 0;
197 break;
198 case(GCIT_ProcessorLoad):
199 *((UBYTE *)passedTag->ti_Data) = 0;
200 break;
201 case(GCIT_FrontsideSpeed):
202 *((UQUAD *)passedTag->ti_Data) = 0;
203 break;
208 AROS_LIBFUNC_EXIT
209 } /* GetCPUInfo() */