1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 using Antmicro.Renode.Logging; 10 using Antmicro.Renode.Peripherals.Bus; 11 using Antmicro.Renode.Utilities; 12 13 namespace Antmicro.Renode.Peripherals.MemoryControllers 14 { 15 public class ESAMemoryController : IDoubleWordPeripheral, IGaislerAPB 16 { ESAMemoryController()17 public ESAMemoryController() 18 { 19 Reset(); 20 } 21 22 #region IDoubleWordPeripheral implementation ReadDoubleWord(long offset)23 public uint ReadDoubleWord (long offset) 24 { 25 switch( (RegisterOffset) offset ) 26 { 27 case RegisterOffset.Config1: 28 return config1; 29 case RegisterOffset.Config2: 30 return config2; 31 case RegisterOffset.Config3: 32 return config3; 33 case RegisterOffset.PowerSavingConfig: 34 return powerSavingConfig; 35 default: 36 this.LogUnhandledRead(offset); 37 return 0; 38 } 39 } 40 WriteDoubleWord(long offset, uint value)41 public void WriteDoubleWord (long offset, uint value) 42 { 43 switch( (RegisterOffset) offset ) 44 { 45 case RegisterOffset.Config1: 46 config1 = value; 47 return; 48 case RegisterOffset.Config2: 49 config2 = value; 50 return; 51 case RegisterOffset.Config3: 52 config3 = value; 53 return; 54 case RegisterOffset.PowerSavingConfig: 55 powerSavingConfig = value; 56 return; 57 default: 58 this.LogUnhandledWrite(offset, value); 59 return; 60 } 61 } 62 #endregion 63 64 #region IGaislerAPB implementation GetVendorID()65 public uint GetVendorID () 66 { 67 return vendorID; 68 } 69 GetDeviceID()70 public uint GetDeviceID () 71 { 72 return deviceID; 73 } 74 GetSpaceType()75 public GaislerAPBPlugAndPlayRecord.SpaceType GetSpaceType () 76 { 77 return spaceType; 78 } 79 GetInterruptNumber()80 public uint GetInterruptNumber() 81 { 82 return 0; 83 } 84 #endregion 85 86 #region IPeripheral implementation Reset()87 public void Reset () 88 { 89 config1 = 0xFu; 90 config2 = 0; 91 config3 = 0; 92 powerSavingConfig = 0; 93 } 94 #endregion 95 96 private uint config1; 97 private uint config2; 98 private uint config3; 99 private uint powerSavingConfig; 100 private readonly uint vendorID = 0x04; // European Space Agency (ESA) 101 private readonly uint deviceID = 0x00f; // GRLIB MCTRL 102 private readonly GaislerAPBPlugAndPlayRecord.SpaceType spaceType = GaislerAPBPlugAndPlayRecord.SpaceType.APBIOSpace; 103 104 private enum RegisterOffset : uint 105 { 106 Config1 = 0x00, 107 Config2 = 0x04, 108 Config3 = 0x08, 109 PowerSavingConfig = 0x0c 110 } 111 } 112 } 113 114