diff options
author | David Guillen Fandos <david.guillen@arm.com> | 2015-05-13 15:02:25 +0100 |
---|---|---|
committer | David Guillen Fandos <david.guillen@arm.com> | 2015-05-13 15:02:25 +0100 |
commit | 65ecd954861aa76532ca79453afcf66a837e1fa6 (patch) | |
tree | 65a7eef6c12995b1215ce5b0622da7732fd87cea /src/dev/arm/rv_ctrl.cc | |
parent | 75c82f1fe3e654ca7d472d8f824424ff450c01d1 (diff) | |
download | gem5-65ecd954861aa76532ca79453afcf66a837e1fa6.tar.xz |
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";
};
};
Diffstat (limited to 'src/dev/arm/rv_ctrl.cc')
-rw-r--r-- | src/dev/arm/rv_ctrl.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/dev/arm/rv_ctrl.cc b/src/dev/arm/rv_ctrl.cc index 507def0c1..f89f23b59 100644 --- a/src/dev/arm/rv_ctrl.cc +++ b/src/dev/arm/rv_ctrl.cc @@ -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); +} |