1 // 2 // Copyright (c) 2010-2017 Antmicro 3 // Copyright (c) 2017 Bas Stottelaar <basstottelaar@gmail.com> 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using Antmicro.Renode.Logging; 9 using Antmicro.Renode.Peripherals.Bus; 10 using Antmicro.Renode.Peripherals.Memory; 11 12 namespace Antmicro.Renode.Peripherals.Miscellaneous.SiLabs 13 { 14 [AllowedTranslations(AllowedTranslation.ByteToDoubleWord | AllowedTranslation.WordToDoubleWord)] 15 public class EFM32xGDeviceInformation : DeviceInformation, IDoubleWordPeripheral, IKnownSize 16 { EFM32xGDeviceInformation(DeviceFamily deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0)17 public EFM32xGDeviceInformation(DeviceFamily deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0) 18 : base(deviceFamily, deviceNumber, flashDevice, sramDevice, productRevision) 19 { 20 } 21 EFM32xGDeviceInformation(int deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0)22 public EFM32xGDeviceInformation(int deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0) 23 :this((DeviceFamily)deviceFamily, deviceNumber, flashDevice, sramDevice, productRevision) 24 { 25 } 26 Reset()27 public void Reset() 28 { 29 } 30 ReadDoubleWord(long offset)31 public uint ReadDoubleWord(long offset) 32 { 33 switch((Registers)offset) 34 { 35 case Registers.UNIQUEL: 36 return (uint)(Unique >> 32); 37 case Registers.UNIQUEH: 38 return (uint)(Unique & 0xFFFFFFFF); 39 case Registers.MSIZE: 40 return (uint)((sramSize << 16) | (flashSize & 0xFFFF)); 41 case Registers.PART: 42 return (uint)((productRevision << 24) | ((byte)deviceFamily << 16) | deviceNumber); 43 default: 44 this.LogUnhandledRead(offset); 45 return 0; 46 } 47 } 48 WriteDoubleWord(long offset, uint value)49 public void WriteDoubleWord(long offset, uint value) 50 { 51 this.LogUnhandledWrite(offset, value); 52 } 53 54 public long Size 55 { 56 get 57 { 58 return 0x50; 59 } 60 } 61 62 // This enum contains only used registers. 63 // The rest is platform-dependent. 64 private enum Registers 65 { 66 UNIQUEL = 0x03c, // Low 32 bits of device unique number 67 UNIQUEH = 0x040, // High 32 bits of device unique number 68 MSIZE = 0x044, // Flash and SRAM Memory size in KiloBytes 69 PART = 0x048, // Part description 70 } 71 } 72 } 73