revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / identify / idhardwarenum.c
blob62d73394de849736c8b992c16c07c4d3929036c4
1 /*
2 * Copyright (c) 2010-2011 Matthias Rustler
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
22 * $Id$
25 #include <exec/execbase.h>
26 #include <graphics/gfxbase.h>
27 #include <aros/inquire.h>
28 #include <resources/battclock.h>
29 #include <resources/processor.h>
31 #include <proto/exec.h>
32 #include <proto/aros.h>
33 #include <proto/graphics.h>
34 #include <proto/battclock.h>
35 #include <proto/processor.h>
37 #include "identify_intern.h"
38 #include "identify.h"
40 /*****************************************************************************
42 NAME */
43 #include <proto/identify.h>
45 AROS_LH2(ULONG, IdHardwareNum,
47 /* SYNOPSIS */
48 AROS_LHA(ULONG , type , D0),
49 AROS_LHA(struct TagItem *, taglist, A0),
51 /* LOCATION */
52 struct IdentifyBaseIntern *, IdentifyBase, 9, Identify)
54 /* FUNCTION
55 Gets information about the current system environment. The result
56 is returned numerical. This function is fully DraCo compatible!
58 Once a information has been read, it will be cached internally, so
59 changes will be ignored. Use IdHardwareUpdate() to clear the cache
60 contents.
62 INPUTS
63 Type -- (ULONG) Information type. These types are known
64 (see include file and NOTE for detailed description):
66 IDHW_SYSTEM -- What system is used?
67 (include file: IDSYS_...)
69 IDHW_CPU -- What kind of CPU is available?
70 (include file: IDCPU_...)
72 IDHW_FPU -- What kind of FPU is available?
73 (include file: IDFPU_...)
75 IDHW_MMU -- What kind of MMU is available?
76 (include file: IDMMU_...)
78 IDHW_OSVER -- What OS version is used?
79 (version, revision)
81 IDHW_EXECVER -- What exec version is used?
82 (version, revision)
84 IDHW_WBVER -- What WorkBench version is used?
85 (version, revision; 0 if not available)
87 IDHW_ROMSIZE -- Size of AmigaOS ROM
88 (size in bytes)
90 IDHW_CHIPSET -- What Chipset is available?
91 (include file: IDCS_...)
93 IDHW_GFXSYS -- What Graphic OS is used?
94 (include file: IDGOS_...)
96 IDHW_CHIPRAM -- Size of complete Chip RAM
97 (size in bytes)
99 IDHW_FASTRAM -- Size of complete Fast RAM
100 (size in bytes)
102 IDHW_RAM -- Size of complete System RAM
103 (size in bytes)
105 IDHW_SETPATCHVER -- Version of current SetPatch
106 (version, revision; 0 if not available)
108 IDHW_AUDIOSYS -- What Audio OS is used?
109 (include file: IDAOS_...)
111 IDHW_OSNR -- What AmigaOS is used?
112 (include file: IDOS_...)
114 IDHW_VMMCHIPRAM -- Size of virtual Chip RAM
115 (size in bytes)
117 IDHW_VMMFASTRAM -- Size of virtual Fast RAM
118 (size in bytes)
120 IDHW_VMMRAM -- Size of total virtual RAM
121 (size in bytes)
123 IDHW_PLNCHIPRAM -- Size of non-virtual Chip RAM
124 (size in bytes)
126 IDHW_PLNFASTRAM -- Size of non-virtual Fast RAM
127 (size in bytes)
129 IDHW_PLNRAM -- Size of total non-virtual RAM
130 (size in bytes)
132 IDHW_VBR -- Vector Base Register contents
133 (address)
135 IDHW_LASTALERT -- Last Alert code
136 (ULONG, 0xFFFFFFFF: no last alert yet)
138 IDHW_VBLANKFREQ -- VBlank frequency (see execbase.h)
139 (ULONG, Unit Hertz)
141 IDHW_POWERFREQ -- Power supply frequency (see execbase.h)
142 (ULONG, Unit Hertz)
144 IDHW_ECLOCK -- System E clock frequency
145 (ULONG, Unit Hertz)
147 IDHW_SLOWRAM -- A500/A2000 "Slow" RAM expansion
148 (size in bytes)
150 IDHW_GARY -- GARY revision
151 (include file: IDGRY_...)
153 IDHW_RAMSEY -- RAMSEY revision
154 (include file: IDRSY_...)
156 IDHW_BATTCLOCK -- Battery backed up clock present?
157 (BOOL)
159 IDHW_CHUNKYPLANAR -- [V7] Chunky to planar hardware present?
160 (BOOL)
162 IDHW_POWERPC -- [V7] PowerPC CPU present?
163 (include file: IDPPC_...)
165 IDHW_PPCCLOCK -- [V7] PowerPC processor clock
166 (ULONG clock in MHz units, or 0: not available)
168 IDHW_CPUREV -- [V8] Revision of the main processor
169 (LONG revision or -1 if not available)
171 IDHW_CPUCLOCK -- [V8] CPU clock
172 (ULONG clock in MHz units)
174 IDHW_FPUCLOCK -- [V8] FPU clock, if available
175 (ULONG clock in MHz units, or 0: not available)
177 IDHW_RAMACCESS -- [V8] Access time of the main board RAM
178 (ULONG in ns units, or 0: not available)
180 IDHW_RAMWIDTH -- [V8] Width of the main board RAM
181 (ULONG in bit, or 0: not available)
183 IDHW_RAMCAS -- [V8] CAS mode of the main board RAM
184 (include file: IDCAS_...)
186 IDHW_RAMBANDWIDTH -- [V8] Bandwidth of the main board RAM
187 (ULONG in times, or 0: not available)
189 IDHW_TCPIP -- [V9] Used TCP/IP stack
190 (include file: IDTCP_...)
192 IDHW_PPCOS -- [V9] Used PowerPC OS
193 (include file: IDPOS_...)
195 IDHW_AGNUS -- [V9] Agnus chip type and revision
196 (include file: IDAG_...)
198 IDHW_AGNUSMODE -- [V9] Agnus chip mode
199 (include file: IDAM_...)
201 IDHW_DENISE -- [V10] Denise chip type
202 (include file: IDDN_...)
204 IDHW_DENISEREV -- [V10] Denise chip revision
205 (LONG, -1 means not available)
207 TagList -- (struct TagItem *) tags that describe further
208 options. You may provide NULL.
210 TAGS
211 None yet.
213 RESULT
214 Result -- (ULONG) Numerical result containing the desired
215 information.
217 NOTES
218 Some results are nonsense on AROS.
220 If you queried a version, you'll find the version in the *lower*
221 UWORD (because it is more important) and the revision in the
222 *upper* UWORD.
224 All memory sizes are always in bytes.
226 Boolean results are ==0 for FALSE, !=0 for TRUE.
228 If you have to look up the result in the include file, you might
229 also get a numerical result that is beyond the maximum value you'll
230 find there. Be prepared for it! In this case, just print "not known"
231 or anything similar, or use the IdHardware() result.
233 EXAMPLE
235 BUGS
237 SEE ALSO
238 IdHardware(), IdHardwareUpdate()
240 INTERNALS
242 HISTORY
245 *****************************************************************************/
247 AROS_LIBFUNC_INIT
249 // no tags
251 switch(type)
253 case IDHW_SYSTEM:
254 return IDSYS_AROS;
256 case IDHW_CPU:
257 #if defined __i386__
258 return IDCPU_i386;
259 #elif defined __x86_64__
260 return IDCPU_x86_64;
261 #elif defined __mc68000__
262 return IDCPU_68000;
263 #elif defined __powerpc__
264 return IDCPU_ppc;
265 #elif defined __arm__
266 return IDCPU_arm;
267 #else
268 return IDCPU_unknown;
269 #endif
271 case IDHW_FPU:
272 return IDFPU_NONE;
274 case IDHW_MMU:
275 return IDMMU_NONE;
277 case IDHW_OSVER:
279 IPTR version = 0;
280 IPTR revision = 0;
281 ArosInquire
283 AI_ArosReleaseMajor, &version,
284 AI_ArosReleaseMinor, &revision,
285 TAG_DONE
287 return version | (revision << 16);
290 case IDHW_EXECVER:
291 return
292 ((struct Library *)SysBase)->lib_Version
294 (((struct Library *)SysBase)->lib_Revision << 16);
296 case IDHW_WBVER:
297 return 40; // i.e. OS3.1
299 case IDHW_ROMSIZE:
301 ULONG storage = 0;
302 ArosInquire(AI_KickstartSize, &storage, TAG_DONE);
303 return storage;
306 case IDHW_CHIPSET:
307 return IDCS_OCS; // FIXME: there's no IDCS_NONE
309 case IDHW_GFXSYS:
310 return IDGOS_CGX;
312 case IDHW_CHIPRAM:
313 return AvailMem(MEMF_CHIP|MEMF_TOTAL);
315 case IDHW_FASTRAM:
316 return AvailMem(MEMF_FAST|MEMF_TOTAL);
318 case IDHW_RAM:
319 return AvailMem(MEMF_ANY|MEMF_TOTAL);
321 case IDHW_SETPATCHVER:
322 return 0;
324 case IDHW_AUDIOSYS:
325 return IDAOS_AHI;
327 case IDHW_OSNR:
328 return IDOS_3_1;
330 case IDHW_VMMCHIPRAM:
331 return 0;
333 case IDHW_VMMFASTRAM:
334 return 0;
336 case IDHW_VMMRAM:
337 return 0;
339 case IDHW_PLNCHIPRAM:
340 return AvailMem(MEMF_CHIP|MEMF_TOTAL);
342 case IDHW_PLNFASTRAM:
343 return AvailMem(MEMF_FAST|MEMF_TOTAL);
345 case IDHW_PLNRAM:
346 return AvailMem(MEMF_ANY|MEMF_TOTAL);
348 case IDHW_VBR:
349 return 0;
351 case IDHW_LASTALERT:
352 return SysBase->LastAlert[0];
354 case IDHW_VBLANKFREQ:
355 return SysBase->VBlankFrequency;
357 case IDHW_POWERFREQ:
358 return SysBase->PowerSupplyFrequency;
360 case IDHW_ECLOCK:
361 return SysBase->ex_EClockFrequency;
363 case IDHW_SLOWRAM:
364 return 0;
366 case IDHW_GARY:
367 return IDGRY_NONE;
369 case IDHW_RAMSEY:
370 return IDRSY_NONE;
372 case IDHW_BATTCLOCK:
374 struct Library *BattClockBase = OpenResource(BATTCLOCKNAME);
375 if (BattClockBase)
377 return ReadBattClock() ? TRUE : FALSE;
379 return FALSE;
382 case IDHW_CHUNKYPLANAR:
383 return GfxBase->ChunkyToPlanarPtr ? FALSE : TRUE;
385 case IDHW_POWERPC:
386 return IDPPC_NONE;
388 case IDHW_PPCCLOCK:
389 return 0;
391 case IDHW_CPUREV:
392 return -1;
394 case IDHW_CPUCLOCK:
396 QUAD speed = 0;
397 APTR ProcessorBase = OpenResource(PROCESSORNAME);
398 if (ProcessorBase)
400 struct TagItem tags [] =
402 { GCIT_ProcessorSpeed, (IPTR)&speed },
403 { TAG_DONE }
405 GetCPUInfo(tags);
407 return speed / 1000000;
409 case IDHW_FPUCLOCK:
410 return 0;
412 case IDHW_RAMACCESS:
413 return 0;
415 case IDHW_RAMWIDTH:
416 if (GfxBase->MemType & 1)
417 return 32;
418 else
419 return 16;
421 case IDHW_RAMCAS:
422 if (GfxBase->MemType & 2)
423 return IDCAS_DOUBLE;
424 else
425 return IDCAS_NORMAL;
427 case IDHW_RAMBANDWIDTH:
428 return 0;
430 case IDHW_TCPIP:
431 return IDTCP_AMITCP;
433 case IDHW_PPCOS:
434 return IDPOS_NONE;
436 case IDHW_AGNUS:
437 return IDAG_NONE;
439 case IDHW_AGNUSMODE:
440 return IDAM_NONE;
442 case IDHW_DENISE:
443 return IDDN_NONE;
445 case IDHW_DENISEREV:
446 return -1;
448 case IDHW_BOINGBAG:
449 return 0;
451 case IDHW_EMULATED:
452 return 0;
454 case IDHW_XLVERSION:
455 return 0;
457 case IDHW_HOSTOS:
458 return 0;
460 case IDHW_HOSTVERS:
461 return 0;
463 case IDHW_HOSTMACHINE:
464 return 0;
466 case IDHW_HOSTCPU:
467 return 0;
469 case IDHW_HOSTSPEED:
470 return 0;
473 return 0;
475 AROS_LIBFUNC_EXIT
476 } /* IdHardwareNum */