mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
emulation: add spinor_soft_int and wfi
These two peripherals are required to run the current build. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
45008ebe36
commit
bb9472816f
4 changed files with 167 additions and 0 deletions
94
emulation/peripherals/spinor_soft_int.cs
Normal file
94
emulation/peripherals/spinor_soft_int.cs
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
//
|
||||
// Copyright (c) 2010-2018 Antmicro
|
||||
// Copyright (c) 2011-2015 Realtime Embedded
|
||||
//
|
||||
// This file is licensed under the MIT License.
|
||||
// Full license text is available in 'licenses/MIT.txt'.
|
||||
//
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Antmicro.Renode.Core;
|
||||
using Antmicro.Renode.Core.Structure.Registers;
|
||||
using Antmicro.Renode.Logging;
|
||||
using Antmicro.Renode.Peripherals.Bus;
|
||||
|
||||
namespace Antmicro.Renode.Peripherals.Miscellaneous
|
||||
{
|
||||
|
||||
public class SpinorSoftInt : IDoubleWordPeripheral, IProvidesRegisterCollection<DoubleWordRegisterCollection>, IKnownSize
|
||||
{
|
||||
public SpinorSoftInt(Machine machine)
|
||||
{
|
||||
this.RegistersCollection = new DoubleWordRegisterCollection(this);
|
||||
this.IRQ = new GPIO();
|
||||
DefineRegisters();
|
||||
Reset();
|
||||
}
|
||||
|
||||
private void DefineRegisters()
|
||||
{
|
||||
Registers.EV_STATUS.Define32(this)
|
||||
.WithFlag(0, FieldMode.Read, name: "SOFTINT", valueProviderCallback: _ => softintStatus)
|
||||
;
|
||||
|
||||
Registers.EV_PENDING.Define32(this)
|
||||
.WithFlag(0, out this.softintPending, FieldMode.Read | FieldMode.WriteOneToClear, name: "SOFTINT", changeCallback: (_, __) => UpdateInterrupts())
|
||||
;
|
||||
|
||||
Registers.EV_ENABLE.Define32(this)
|
||||
.WithFlag(0, out this.softintEnabled, name: "SOFTINT", changeCallback: (_, __) => UpdateInterrupts())
|
||||
;
|
||||
|
||||
Registers.SOFTINT.Define32(this)
|
||||
.WithFlag(0, writeCallback: (_, val) => { if (val) { this.softintStatus = true; UpdateInterrupts(); this.softintStatus = false; } })
|
||||
;
|
||||
}
|
||||
|
||||
private void UpdateInterrupts()
|
||||
{
|
||||
if (this.softintStatus)
|
||||
{
|
||||
this.softintPending.Value = true;
|
||||
}
|
||||
IRQ.Set(this.softintPending.Value && this.softintEnabled.Value);
|
||||
}
|
||||
|
||||
public void WriteDoubleWord(long address, uint value)
|
||||
{
|
||||
RegistersCollection.Write(address, value);
|
||||
}
|
||||
|
||||
public uint ReadDoubleWord(long offset)
|
||||
{
|
||||
return RegistersCollection.Read(offset);
|
||||
}
|
||||
|
||||
public long Size { get { return 4096; } }
|
||||
public DoubleWordRegisterCollection RegistersCollection { get; private set; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.softintStatus = false;
|
||||
this.softintPending.Value = false;
|
||||
this.softintEnabled.Value = false;
|
||||
}
|
||||
|
||||
public GPIO IRQ { get; private set; }
|
||||
|
||||
private IFlagRegisterField softintEnabled;
|
||||
private IFlagRegisterField softintPending;
|
||||
private bool softintStatus;
|
||||
|
||||
private enum Registers
|
||||
{
|
||||
EV_STATUS = 0x00,
|
||||
EV_PENDING = 0x04,
|
||||
EV_ENABLE = 0x08,
|
||||
SOFTINT = 0x0c
|
||||
}
|
||||
}
|
||||
}
|
||||
69
emulation/peripherals/wfi.cs
Normal file
69
emulation/peripherals/wfi.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// Copyright (c) 2010-2018 Antmicro
|
||||
// Copyright (c) 2011-2015 Realtime Embedded
|
||||
//
|
||||
// This file is licensed under the MIT License.
|
||||
// Full license text is available in 'licenses/MIT.txt'.
|
||||
//
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Antmicro.Renode.Core;
|
||||
using Antmicro.Renode.Core.Structure.Registers;
|
||||
using Antmicro.Renode.Logging;
|
||||
using Antmicro.Renode.Peripherals.Bus;
|
||||
using Antmicro.Renode.Utilities.Binding;
|
||||
|
||||
namespace Antmicro.Renode.Peripherals.Miscellaneous
|
||||
{
|
||||
|
||||
public class BetrustedWfi : IDoubleWordPeripheral, IProvidesRegisterCollection<DoubleWordRegisterCollection>, IKnownSize
|
||||
{
|
||||
[Import]
|
||||
private Action TlibEnterWfi;
|
||||
|
||||
public BetrustedWfi(Machine machine)
|
||||
{
|
||||
this.RegistersCollection = new DoubleWordRegisterCollection(this);
|
||||
DefineRegisters();
|
||||
Reset();
|
||||
}
|
||||
|
||||
private void DefineRegisters()
|
||||
{
|
||||
Registers.WFI.Define32(this)
|
||||
.WithFlag(0, writeCallback: (_, val) => { if (val) { /*TlibEnterWfi(); */ } })
|
||||
;
|
||||
|
||||
Registers.IGNORE_LOCKED.Define32(this)
|
||||
.WithFlag(0, name: "IGNORE_LOCKED", changeCallback: (_, __) => { })
|
||||
;
|
||||
}
|
||||
|
||||
public void WriteDoubleWord(long address, uint value)
|
||||
{
|
||||
RegistersCollection.Write(address, value);
|
||||
}
|
||||
|
||||
public uint ReadDoubleWord(long offset)
|
||||
{
|
||||
return RegistersCollection.Read(offset);
|
||||
}
|
||||
|
||||
public long Size { get { return 4096; } }
|
||||
public DoubleWordRegisterCollection RegistersCollection { get; private set; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
private enum Registers
|
||||
{
|
||||
WFI = 0x00,
|
||||
IGNORE_LOCKED = 0x04
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,9 +16,11 @@ i @peripherals/keyrom.cs
|
|||
i @peripherals/LiteX_Timer_32.cs
|
||||
i @peripherals/memlcd.cs
|
||||
i @peripherals/sha512.cs
|
||||
i @peripherals/spinor_soft_int.cs
|
||||
i @peripherals/ticktimer.cs
|
||||
i @peripherals/trng_kernel.cs
|
||||
i @peripherals/trng_server.cs
|
||||
i @peripherals/wfi.cs
|
||||
|
||||
############### Define the Betrusted SoC ###############
|
||||
mach create "SoC"
|
||||
|
|
|
|||
|
|
@ -638,11 +638,13 @@ pub fn generate<T: Read, U: Write>(src: T, dest: &mut U) -> Result<(), ParseErro
|
|||
cs_peripherals.insert("keyrom", "Miscellaneous.Keyrom");
|
||||
cs_peripherals.insert("memlcd", "Video.BetrustedLCD");
|
||||
cs_peripherals.insert("sha512", "Miscellaneous.Sha512");
|
||||
cs_peripherals.insert("spinor_soft_int", "Miscellaneous.SpinorSoftInt");
|
||||
cs_peripherals.insert("timer0", "Timers.LiteX_Timer_32");
|
||||
cs_peripherals.insert("trng_kernel", "Miscellaneous.BetrustedRNGKernel");
|
||||
cs_peripherals.insert("trng_server", "Miscellaneous.BetrustedRNGServer");
|
||||
cs_peripherals.insert("ticktimer", "Timers.TickTimer");
|
||||
cs_peripherals.insert("uart", "UART.LiteX_UART");
|
||||
cs_peripherals.insert("wfi", "Miscellaneous.BetrustedWfi");
|
||||
|
||||
print_header(dest).or(Err(ParseError::WriteError))?;
|
||||
print_peripherals(
|
||||
|
|
|
|||
Loading…
Reference in a new issue