1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 using Antmicro.Renode.Core; 9 using Antmicro.Renode.Core.Structure; 10 using Antmicro.Renode.Peripherals; 11 using Antmicro.Renode.Peripherals.Bus; 12 using Antmicro.Renode.Peripherals.CPU; 13 14 namespace Antmicro.Renode.UnitTests.Mocks 15 { 16 public class MockRegister : IPeripheralRegister<ICPU, NullRegistrationPoint>, IDoubleWordPeripheral, IKnownSize 17 { MockRegister(IMachine machine)18 public MockRegister(IMachine machine) 19 { 20 this.machine = machine; 21 } 22 Register(ICPU peripheral, NullRegistrationPoint registrationPoint)23 public void Register(ICPU peripheral, NullRegistrationPoint registrationPoint) 24 { 25 if(isRegistered) 26 { 27 throw new ArgumentException("Child is already registered."); 28 } 29 else 30 { 31 isRegistered = true; 32 machine.RegisterAsAChildOf(this, peripheral, registrationPoint); 33 } 34 } 35 Unregister(ICPU peripheral)36 public void Unregister(ICPU peripheral) 37 { 38 isRegistered = false; 39 machine.UnregisterAsAChildOf(this, peripheral); 40 } 41 Reset()42 public void Reset() 43 { 44 } 45 ReadDoubleWord(long offset)46 public uint ReadDoubleWord(long offset) 47 { 48 return 0; 49 } 50 WriteDoubleWord(long offset, uint value)51 public void WriteDoubleWord(long offset, uint value) 52 { 53 } 54 55 public long Size 56 { 57 get 58 { 59 return 0x4; 60 } 61 } 62 63 private bool isRegistered; 64 private IMachine machine; 65 } 66 } 67