2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
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>
16 /* Processor information */
17 static ULONG processorcount
;
19 #define SIMULATE_USAGE_FREQ 0
21 /* Processor functions */
22 static BOOL
InitProcessor(struct SysMonData
*smdata
)
24 #if SIMULATE_USAGE_FREQ
28 ProcessorBase
= OpenResource(PROCESSORNAME
);
32 struct TagItem tags
[] =
34 { GCIT_NumberOfProcessors
, (IPTR
)&processorcount
},
48 static VOID
DeInitProcessor(struct SysMonData
*smdata
)
52 ULONG
GetProcessorCount()
54 return processorcount
;
57 VOID
UpdateProcessorInformation(struct SysMonData
* smdata
)
62 for (i
= 0; i
< processorcount
; i
++)
66 #if SIMULATE_USAGE_FREQ
69 usage
= (ds
.ds_Tick
* (i
+ 1)) % 100;
70 frequency
= usage
* 10;
72 struct TagItem tags
[] =
74 { GCIT_SelectedProcessor
, (IPTR
)i
},
75 { GCIT_ProcessorSpeed
, (IPTR
)&frequency
},
76 { GCIT_ProcessorLoad
, (IPTR
)&usage
},
77 { TAG_DONE
, TAG_DONE
}
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
)
96 CONST_STRPTR modelstring
;
98 for (i
= 0; i
< processorcount
; i
++)
100 #if SIMULATE_USAGE_FREQ
101 modelstring
= _(MSG_SIMULATED_CPU
);
103 struct TagItem tags
[] =
105 { GCIT_SelectedProcessor
, (IPTR
)i
},
106 { GCIT_ModelString
, (IPTR
)&modelstring
},
107 { TAG_DONE
, TAG_DONE
}
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
,