alsa.audio: use correct name of libasound so file
[AROS.git] / workbench / system / SysMon / processor.c
blobf80a5407075186bbb25b2ce9d042a6f1e97c44c7
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "sysmon_intern.h"
8 #include <proto/processor.h>
9 #include <resources/processor.h>
10 #include <proto/dos.h>
12 #include <clib/alib_protos.h>
14 #include "locale.h"
16 /* Processor information */
17 static ULONG processorcount;
18 APTR ProcessorBase;
19 #define SIMULATE_USAGE_FREQ 0
21 /* Processor functions */
22 static BOOL InitProcessor(struct SysMonData *smdata)
24 #if SIMULATE_USAGE_FREQ
25 processorcount = 4;
26 return TRUE;
27 #else
28 ProcessorBase = OpenResource(PROCESSORNAME);
30 if (ProcessorBase)
32 struct TagItem tags [] =
34 { GCIT_NumberOfProcessors, (IPTR)&processorcount },
35 { 0, (IPTR)NULL }
38 GetCPUInfo(tags);
40 return TRUE;
44 return FALSE;
45 #endif
48 static VOID DeInitProcessor(struct SysMonData *smdata)
52 ULONG GetProcessorCount()
54 return processorcount;
57 VOID UpdateProcessorInformation(struct SysMonData * smdata)
59 ULONG i;
60 TEXT buffer[128];
62 for (i = 0; i < processorcount; i++)
64 UBYTE usage = 0;
65 UQUAD frequency = 0;
66 #if SIMULATE_USAGE_FREQ
67 struct DateStamp ds;
68 DateStamp(&ds);
69 usage = (ds.ds_Tick * (i + 1)) % 100;
70 frequency = usage * 10;
71 #else
72 struct TagItem tags [] =
74 { GCIT_SelectedProcessor, (IPTR)i },
75 { GCIT_ProcessorSpeed, (IPTR)&frequency },
76 { GCIT_ProcessorLoad, (IPTR)&usage },
77 { TAG_DONE, TAG_DONE }
80 GetCPUInfo(tags);
82 frequency /= 1000000;
83 #endif
84 __sprintf(buffer, " CPU %d : %d %% ", i, usage);
85 set(smdata->cpuusagegauges[i], MUIA_Gauge_Current, usage);
86 set(smdata->cpuusagegauges[i], MUIA_Gauge_InfoText, (IPTR)buffer);
87 __sprintf(buffer, "%d MHz", (ULONG)frequency);
88 set(smdata->cpufreqvalues[i], MUIA_Text_Contents, (IPTR)buffer);
92 VOID UpdateProcessorStaticInformation(struct SysMonData * smdata)
94 ULONG i;
95 TEXT buffer[172];
96 CONST_STRPTR modelstring;
98 for (i = 0; i < processorcount; i++)
100 #if SIMULATE_USAGE_FREQ
101 modelstring = _(MSG_SIMULATED_CPU);
102 #else
103 struct TagItem tags [] =
105 { GCIT_SelectedProcessor, (IPTR)i },
106 { GCIT_ModelString, (IPTR)&modelstring },
107 { TAG_DONE, TAG_DONE }
110 GetCPUInfo(tags);
111 #endif
112 __sprintf(buffer, (STRPTR)_(MSG_PROCESSOR), i + 1, modelstring);
113 set(smdata->cpufreqlabels[i], MUIA_Text_Contents, buffer);
117 struct SysMonModule processormodule =
119 .Init = InitProcessor,
120 .DeInit = DeInitProcessor,