remove duplicate consts
[AROS.git] / rom / processor / getcpuinfo.c
blob4f0ecaa5606df4c17b92ded848a470fd52298efb
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.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_SelectedProcessor.
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 - (ULONG *) Provides the current CPU load (0-0xffffffff)
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;
144 /* This is the default implementation */
146 while ((passedTag = NextTagItem(&tagList)) != NULL)
148 if ((passedTag->ti_Tag > GCIT_FeaturesBase) &&
149 (passedTag->ti_Tag <= GCIT_FeaturesLast))
151 *((BOOL *)passedTag->ti_Data) = FALSE;
152 continue;
154 else
156 switch(passedTag->ti_Tag)
158 case(GCIT_NumberOfProcessors):
159 *((ULONG *)passedTag->ti_Data) = ProcessorBase->cpucount;
160 break;
161 case(GCIT_ModelString):
162 *((CONST_STRPTR *)passedTag->ti_Data) = "Unknown";
163 break;
164 case(GCIT_Family):
165 *((ULONG *)passedTag->ti_Data) = CPUFAMILY_UNKNOWN;
166 break;
167 case(GCIT_VectorUnit):
168 *((ULONG *)passedTag->ti_Data) = VECTORTYPE_NONE;
169 break;
170 case(GCIT_L1CacheSize):
171 *((ULONG *)passedTag->ti_Data) = 0;
172 break;
173 case(GCIT_L1DataCacheSize):
174 *((ULONG *)passedTag->ti_Data) = 0;
175 break;
176 case(GCIT_L1InstructionCacheSize):
177 *((ULONG *)passedTag->ti_Data) = 0;
178 break;
179 case(GCIT_L2CacheSize):
180 *((ULONG *)passedTag->ti_Data) = 0;
181 break;
182 case(GCIT_L3CacheSize):
183 *((ULONG *)passedTag->ti_Data) = 0;
184 break;
185 case(GCIT_CacheLineSize):
186 *((ULONG *)passedTag->ti_Data) = 0;
187 break;
188 case(GCIT_Architecture):
189 *((ULONG *)passedTag->ti_Data) = PROCESSORARCH_DEF;
190 break;
191 case(GCIT_Endianness):
192 *((ULONG *)passedTag->ti_Data) = ENDIANNESS_DEF;
193 break;
194 case(GCIT_ProcessorSpeed):
195 *((UQUAD *)passedTag->ti_Data) = 0;
196 break;
197 case(GCIT_ProcessorLoad):
198 *((ULONG *)passedTag->ti_Data) = 0;
199 break;
200 case(GCIT_FrontsideSpeed):
201 *((UQUAD *)passedTag->ti_Data) = 0;
202 break;
207 AROS_LIBFUNC_EXIT
208 } /* GetCPUInfo() */