mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-05 04:37:13 +00:00
Give a "Betrusted" namespace to all of the peripherals. This will enable us to upstream various modules without breaking compatibility with our own versions of these peripherals. Signed-off-by: Sean Cross <sean@xobs.io>
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
//
|
|
// 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 Antmicro.Renode.Core;
|
|
using Antmicro.Renode.Core.Structure.Registers;
|
|
using Antmicro.Renode.Peripherals.Bus;
|
|
|
|
namespace Antmicro.Renode.Peripherals.Miscellaneous.Betrusted
|
|
{
|
|
public class EcPower : IDoubleWordPeripheral, IProvidesRegisterCollection<DoubleWordRegisterCollection>, IKnownSize
|
|
{
|
|
public EcPower(Machine machine)
|
|
{
|
|
Machine = machine;
|
|
RegistersCollection = new DoubleWordRegisterCollection(this);
|
|
|
|
Registers.POWER.Define32(this)
|
|
.WithFlag(0, out Self, FieldMode.Read | FieldMode.Write, name: "SELF")
|
|
.WithFlag(1, out SocOn, FieldMode.Read | FieldMode.Write, name: "SOC_ON")
|
|
.WithFlag(2, out KbdDrive, FieldMode.Read | FieldMode.Write, name: "KBDDRIVE")
|
|
;
|
|
Registers.STATS.Define32(this)
|
|
.WithFlag(0, out State, FieldMode.Read, name: "STATE")
|
|
.WithValueField(1, 2, out MonKey, FieldMode.Read, name: "MONKEY")
|
|
;
|
|
|
|
Reset();
|
|
}
|
|
|
|
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()
|
|
{
|
|
Self.Value = true;
|
|
SocOn.Value = true;
|
|
KbdDrive.Value = false;
|
|
|
|
// Keep the SoC powered "on" to work around power emulation issues
|
|
State.Value = true;
|
|
MonKey.Value = 0;
|
|
}
|
|
|
|
private readonly Machine Machine;
|
|
private IFlagRegisterField Self;
|
|
private IFlagRegisterField SocOn;
|
|
private IFlagRegisterField KbdDrive;
|
|
|
|
private IFlagRegisterField State;
|
|
private IValueRegisterField MonKey;
|
|
|
|
private enum Registers
|
|
{
|
|
POWER = 0x0,
|
|
STATS = 0x04,
|
|
}
|
|
}
|
|
}
|