sim: Thermal support for Linux
This patch enables Linux to read the temperature using hwmon infrastructure.
In order to use this in your gem5 you need to compile the kernel using the
following configs:
CONFIG_HWMON=y
CONFIG_SENSORS_VEXPRESS=y
And a proper dts file (containing an entry such as):
dcc {
compatible = "arm,vexpress,config-bus";
arm,vexpress,config-bridge = <&v2m_sysreg>;
temp@0 {
compatible = "arm,vexpress-temp";
arm,vexpress-sysreg,func = <4 0>;
label = "DCC";
};
};
This commit is contained in:
@@ -37,11 +37,14 @@
|
||||
* Authors: Ali Saidi
|
||||
*/
|
||||
|
||||
#include "dev/arm/rv_ctrl.hh"
|
||||
|
||||
#include "base/trace.hh"
|
||||
#include "debug/RVCTRL.hh"
|
||||
#include "dev/arm/rv_ctrl.hh"
|
||||
#include "mem/packet.hh"
|
||||
#include "mem/packet_access.hh"
|
||||
#include "sim/power/thermal_model.hh"
|
||||
#include "sim/system.hh"
|
||||
#include "sim/voltage_domain.hh"
|
||||
|
||||
RealViewCtrl::RealViewCtrl(Params *p)
|
||||
@@ -293,7 +296,21 @@ RealViewOsc::write(uint32_t freq)
|
||||
clockPeriod(SimClock::Float::s / freq);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
RealViewTemperatureSensor::read() const
|
||||
{
|
||||
// Temperature reported in uC
|
||||
ThermalModel * tm = system->getThermalModel();
|
||||
if (tm) {
|
||||
double t = tm->getTemp();
|
||||
if (t < 0)
|
||||
warn("Temperature below zero!\n");
|
||||
return fmax(0, t) * 1000000;
|
||||
}
|
||||
|
||||
// Report a dummy 25 degrees temperature
|
||||
return 25000000;
|
||||
}
|
||||
|
||||
RealViewCtrl *
|
||||
RealViewCtrlParams::create()
|
||||
@@ -306,3 +323,9 @@ RealViewOscParams::create()
|
||||
{
|
||||
return new RealViewOsc(this);
|
||||
}
|
||||
|
||||
RealViewTemperatureSensor *
|
||||
RealViewTemperatureSensorParams::create()
|
||||
{
|
||||
return new RealViewTemperatureSensor(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user