2 Copyright (C) 2013, The AROS Development Team.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/memory.h>
10 #include <resources/hpet.h>
11 #include <libraries/mui.h>
12 #include <mui/NFloattext_mcc.h>
13 #include <resources/processor.h>
14 #include <utility/tagitem.h>
15 #include <utility/hooks.h>
17 #include <proto/alib.h>
18 #include <proto/aros.h>
19 #include <proto/dos.h>
20 #include <proto/exec.h>
21 #include <proto/hpet.h>
22 #include <proto/kernel.h>
23 #include <proto/muimaster.h>
24 #include <proto/utility.h>
25 #include <proto/intuition.h>
26 #include <proto/processor.h>
33 #include "cpuspecific.h"
36 #include <aros/debug.h>
38 #include <zune/customclasses.h>
40 APTR ProcessorBase
= NULL
;
43 /*** Instance Data **********************************************************/
44 struct ComputerWindow_DATA
50 ULONG
ExtUDivMod32(ULONG a
, ULONG b
, ULONG
*mod
)
58 void PrintNum(char *buffer
, LONG bufsize
, ULONG num
)
73 num
= ExtUDivMod32(UMult32(num
, 100) >> 10, 100, &x
);
76 x
= ExtUDivMod32(x
, 10, &xx
);
87 snprintf(buffer
, bufsize
, "%d.%d %s", (int)num
, (int)x
, fmt
);
91 snprintf(buffer
, bufsize
, "%d K", (int)num
);
95 ULONG
ComputeKBytes(APTR a
, APTR b
)
99 return (ULONG
)(result
>> 10);
102 static ULONG
GetProcessorsCount()
105 struct TagItem tags
[] =
107 {GCIT_NumberOfProcessors
, (IPTR
)&count
},
120 } ProcessorArchitecture
[] =
122 { PROCESSORARCH_UNKNOWN
, "Unknown" },
123 { PROCESSORARCH_M68K
, "Motorola 68K" },
124 { PROCESSORARCH_PPC
, "PowerPC" },
125 { PROCESSORARCH_X86
, "X86" },
126 { PROCESSORARCH_ARM
, "ARM" },
134 } CurrentEndianness
[] =
136 { ENDIANNESS_UNKNOWN
, "Unknown" },
137 { ENDIANNESS_LE
, "LE" },
138 { ENDIANNESS_BE
, "BE" },
142 static VOID
PrintProcessorInformation(char *buffer
, LONG bufsize
)
144 ULONG count
= GetProcessorsCount();
146 CONST_STRPTR modelstring
;
147 ULONG architecture
, endianness
;
148 CONST_STRPTR architecturestring
= "", endiannessstring
= "";
150 char *bufptr
= buffer
;
153 for (i
= 0; bufsize
> 0 && i
< count
; i
++)
155 struct TagItem tags
[] =
157 {GCIT_SelectedProcessor
, i
},
158 {GCIT_ModelString
, (IPTR
)&modelstring
},
159 {GCIT_Architecture
, (IPTR
)&architecture
},
160 {GCIT_Endianness
, (IPTR
)&endianness
},
161 {GCIT_ProcessorSpeed
, (IPTR
)&cpuspeed
},
168 while(ProcessorArchitecture
[j
].Description
!= NULL
)
170 if (ProcessorArchitecture
[j
].Architecture
== architecture
)
172 architecturestring
= ProcessorArchitecture
[j
].Description
;
179 while(CurrentEndianness
[j
].Description
!= NULL
)
181 if (CurrentEndianness
[j
].Endianness
== endianness
)
183 endiannessstring
= CurrentEndianness
[j
].Description
;
190 modelstring
= "Unknown";
192 snprintf(bufptr
, bufsize
, "PROCESSOR %d:\t[%s/%s] %s", (int)(i
+ 1), architecturestring
,
193 endiannessstring
, modelstring
);
194 slen
= strlen(bufptr
);
203 snprintf(bufptr
, bufsize
, " (%llu MHz)", (unsigned long long)(cpuspeed
/ 1000000));
204 slen
= strlen(bufptr
);
208 snprintf(bufptr
, bufsize
, "\n");
209 slen
= strlen(bufptr
);
213 PrintCPUSpecificInfo(bufptr
, bufsize
, i
, ProcessorBase
);
217 static inline void VersionStr(char *ptr
, int len
, struct Library
*base
)
219 snprintf(ptr
, len
, "%d.%d", base
->lib_Version
, base
->lib_Revision
);
222 static Object
*ComputerWindow__OM_NEW(Class
*cl
, Object
*self
, struct opSet
*msg
)
224 Object
*processors_flt
;
227 char aros_ver
[8], exec_ver
[8];
233 STRPTR pagetitles
[5];
236 VersionStr(aros_ver
, sizeof(aros_ver
), ArosBase
);
237 VersionStr(exec_ver
, sizeof(exec_ver
), &SysBase
->LibNode
);
239 KernelBase
= OpenResource("kernel.resource");
242 struct TagItem
*bootinfo
= KrnGetBootInfo();
244 bootldr
= GetTagData(KRN_BootLoader
, 0, bootinfo
);
245 args
= GetTagData(KRN_CmdLine
, 0, bootinfo
);
248 pagetitles
[pagecnt
++] = (STRPTR
)_(MSG_GENERAL
);
249 if ((ProcessorBase
= OpenResource(PROCESSORNAME
)) != NULL
)
251 pagetitles
[pagecnt
++] = (STRPTR
)_(MSG_PROCESSORS
);
253 pagetitles
[pagecnt
++] = (STRPTR
)_(MSG_RAM
);
254 if ((HPETBase
= OpenResource("hpet.resource")) != NULL
)
256 pagetitles
[pagecnt
++] = (STRPTR
)_(MSG_HPET
);
258 pagetitles
[pagecnt
] = NULL
;
260 self
= (Object
*) DoSuperNewTags
263 MUIA_Window_Title
, __(MSG_SYSTEM_PROPERTIES
),
264 MUIA_Window_ID
, MAKE_ID('S', 'Y', 'P', 'R'),
265 WindowContents
, (IPTR
)(RegisterObject
,
266 MUIA_Register_Titles
, (IPTR
) pagetitles
,
268 Child
, (IPTR
)(VGroup
,
269 Child
, (IPTR
)(HGroup
,
270 MUIA_FrameTitle
, __(MSG_VERSION
),
272 MUIA_Background
, MUII_GroupBack
,
273 Child
, (IPTR
)Label("AROS"),
274 Child
, (IPTR
)(TextObject
,
276 MUIA_Background
, MUII_TextBack
,
278 MUIA_Text_Contents
, (IPTR
)aros_ver
,
280 Child
, (IPTR
)Label("Exec"),
281 Child
, (IPTR
)(TextObject
,
283 MUIA_Background
, MUII_TextBack
,
285 MUIA_Text_Contents
, (IPTR
)exec_ver
,
288 Child
, (IPTR
)(HGroup
,
290 MUIA_FrameTitle
, __(MSG_BOOTLOADER
),
291 MUIA_Background
, MUII_GroupBack
,
292 Child
, (IPTR
)(TextObject
,
294 MUIA_Background
, MUII_TextBack
,
296 MUIA_Text_Contents
, bootldr
,
299 Child
, (IPTR
)(HGroup
,
301 MUIA_FrameTitle
, __(MSG_ARGUMENTS
),
302 MUIA_Background
, MUII_GroupBack
,
303 Child
, (IPTR
)(TextObject
,
305 MUIA_Background
, MUII_TextBack
,
307 MUIA_Text_Contents
, args
,
311 ProcessorBase
? Child
: TAG_IGNORE
, (IPTR
)(VGroup
,
312 Child
, (IPTR
)(NListviewObject
,
313 MUIA_NListview_NList
, (IPTR
)(processors_flt
= NFloattextObject
,
317 Child
, (IPTR
)(VGroup
,
318 Child
, (IPTR
)(NListviewObject
,
319 MUIA_NListview_NList
, (IPTR
)(ram_flt
= NFloattextObject
,
323 HPETBase
? Child
: TAG_IGNORE
, (IPTR
)(VGroup
,
324 Child
, (IPTR
)(NListviewObject
,
325 MUIA_NListview_NList
, (IPTR
)(hpet_flt
= NFloattextObject
,
335 struct MemHeader
*mh
;
344 PrintProcessorInformation(buffer
, sizeof(buffer
));
345 // we intentionally use MUIA_Floattext_Text because it copies the text
346 SET(processors_flt
, MUIA_Floattext_Text
, buffer
);
348 // high precision timers
351 bufsize
= sizeof(buffer
);
358 while (bufsize
> 5 && GetUnitAttrs(i
, HPET_UNIT_OWNER
, &owner
, TAG_DONE
))
361 owner
= _(MSG_AVAILABLE
);
363 snprintf(bufptr
, bufsize
, "HPET %u:\t\t%s\n", (unsigned)(++i
), owner
);
365 slen
= strlen(bufptr
);
370 // we intentionally use MUIA_Floattext_Text because it copies the text
371 SET(hpet_flt
, MUIA_Floattext_Text
, buffer
);
376 bufsize
= sizeof(buffer
);
380 mh
= (struct MemHeader
*)SysBase
->MemList
.lh_Head
;
381 bufsize
> 5 && mh
->mh_Node
.ln_Succ
;
382 mh
= (struct MemHeader
*)mh
->mh_Node
.ln_Succ
385 char *memtype
= "ROM";
387 if (mh
->mh_Attributes
& MEMF_CHIP
)
389 if (mh
->mh_Attributes
& MEMF_FAST
)
392 snprintf(bufptr
, bufsize
, "Node Type 0x%X, Attributes 0x%X (%s), at $%p-$%p (",
393 mh
->mh_Node
.ln_Type
, mh
->mh_Attributes
, memtype
, mh
->mh_Lower
, mh
->mh_Upper
- 1);
395 slen
= strlen(bufptr
);
402 PrintNum(bufptr
, bufsize
, ComputeKBytes(mh
->mh_Lower
, mh
->mh_Upper
));
403 slen
= strlen(bufptr
);
407 snprintf(bufptr
, bufsize
, ")\n");
408 slen
= strlen(bufptr
);
412 // we intentionally use MUIA_Floattext_Text because it copies the text
413 SET(ram_flt
, MUIA_Floattext_Text
, buffer
);
419 /*** Setup ******************************************************************/
422 ComputerWindow
, NULL
, MUIC_Window
, NULL
,
423 OM_NEW
, struct opSet
*