diff --git a/emulation/peripherals/BQ27421.cs b/emulation/peripherals/BQ27421.cs index bef2943be..0af712cbf 100644 --- a/emulation/peripherals/BQ27421.cs +++ b/emulation/peripherals/BQ27421.cs @@ -46,7 +46,7 @@ namespace Antmicro.Renode.Peripherals.Sensors firstByte = true; secondByte = false; Temperature = 298.1M; - Voltage = 3700; + Voltage = 4000; SoC = 90; AvgCur = 300; RemainingCapacity = 4000; diff --git a/emulation/peripherals/Jtag.cs b/emulation/peripherals/Jtag.cs index 0beb36321..0d08e1900 100644 --- a/emulation/peripherals/Jtag.cs +++ b/emulation/peripherals/Jtag.cs @@ -309,6 +309,7 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous public void Reset() { State = JtagState.TestLogicReset; + RegistersCollection.Reset(); } private enum JtagState diff --git a/emulation/peripherals/LiteX_Timer_32.cs b/emulation/peripherals/LiteX_Timer_32.cs index b0f6e7dc7..d755088c7 100644 --- a/emulation/peripherals/LiteX_Timer_32.cs +++ b/emulation/peripherals/LiteX_Timer_32.cs @@ -45,6 +45,7 @@ namespace Antmicro.Renode.Peripherals.Timers latchedValue = 0; loadValue = 0; reloadValue = 0; + RegistersCollection.Reset(); UpdateInterrupts(); } diff --git a/emulation/peripherals/engine.cs b/emulation/peripherals/engine.cs index de4529275..148df57da 100644 --- a/emulation/peripherals/engine.cs +++ b/emulation/peripherals/engine.cs @@ -594,6 +594,7 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous { this.powerIsOn.Value = false; } + RegistersCollection.Reset(); } private readonly Machine machine; diff --git a/emulation/peripherals/sha512.cs b/emulation/peripherals/sha512.cs index 5cc84d8f5..98a0b11c6 100644 --- a/emulation/peripherals/sha512.cs +++ b/emulation/peripherals/sha512.cs @@ -323,6 +323,7 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous { this.sha512.Initialize(); this.digestedLength = 0; + RegistersCollection.Reset(); } private readonly Machine machine; diff --git a/emulation/peripherals/spinor_soft_int.cs b/emulation/peripherals/spinor_soft_int.cs index b56f54562..a11d9bf9e 100644 --- a/emulation/peripherals/spinor_soft_int.cs +++ b/emulation/peripherals/spinor_soft_int.cs @@ -75,6 +75,7 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous this.softintStatus = false; this.softintPending.Value = false; this.softintEnabled.Value = false; + RegistersCollection.Reset(); } public GPIO IRQ { get; private set; } diff --git a/emulation/peripherals/susres.cs b/emulation/peripherals/susres.cs index 2575bf561..5f5de225d 100644 --- a/emulation/peripherals/susres.cs +++ b/emulation/peripherals/susres.cs @@ -118,7 +118,15 @@ namespace Antmicro.Renode.Peripherals.Timers ; Registers.Powerdown.Define32(this) - .WithFlag(0, FieldMode.Read | FieldMode.Write) + .WithFlag(0, FieldMode.Read | FieldMode.Write, changeCallback: (_, val) => { + if (val) { + this.Log(LogLevel.Info, "Pausing and resetting machine"); + machine.LocalTimeSource.ExecuteInNearestSyncedState(ts => { + machine.Pause(); + machine.Reset(); + }); + } + }) ; Registers.Wfi.Define32(this) diff --git a/emulation/peripherals/ticktimer.cs b/emulation/peripherals/ticktimer.cs index 8213abf0e..4ed6b4098 100644 --- a/emulation/peripherals/ticktimer.cs +++ b/emulation/peripherals/ticktimer.cs @@ -34,6 +34,7 @@ namespace Antmicro.Renode.Peripherals.Timers tickValue = 0; paused = true; msleepTarget = 0; + RegistersCollection.Reset(); } private void OnTick() @@ -45,6 +46,16 @@ namespace Antmicro.Renode.Peripherals.Timers } } + public uint Time0() + { + return (uint)(tickValue >> 0); + } + + public uint Time1() + { + return (uint)(tickValue >> 32); + } + private void UpdateInterrupts() { if ((Interlocked.Read(ref this.tickValue) >= (long)this.msleepTarget) && this.irqEnabled.Value) @@ -77,14 +88,14 @@ namespace Antmicro.Renode.Peripherals.Timers Registers.Time1.Define32(this) .WithValueField(0, 32, FieldMode.Read, name: "Time1", valueProviderCallback: _ => { - return (uint)(tickValue >> 32); + return Time1(); }) ; Registers.Time0.Define32(this) .WithValueField(0, 32, FieldMode.Read, name: "Time0", valueProviderCallback: _ => { - return (uint)(tickValue >> 0); + return Time0(); }) ; @@ -131,8 +142,8 @@ namespace Antmicro.Renode.Peripherals.Timers private IFlagRegisterField irqPending; private bool irqStatus; - bool paused; - long tickValue; + public bool paused; + public long tickValue; ulong msleepTarget; public GPIO IRQ { get; private set; }