1 // 2 // Copyright (c) 2010-2020 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using Antmicro.Renode.Core.Structure.Registers; 8 9 namespace Antmicro.Renode.Peripherals.PCI.BAR 10 { 11 public abstract class BaseAddressRegister 12 { BaseAddressRegister(uint requestedSize)13 public BaseAddressRegister(uint requestedSize) 14 { 15 RequestedSize = requestedSize; 16 } 17 18 public abstract uint Value { get; set; } 19 public uint BaseAddress 20 { 21 get { return RequestedSize != 0 ? baseAddress : 0; } 22 set { baseAddress = ((value & addressMask) & ~(RequestedSize - 1)); } 23 } 24 //Base Address Register only implements as many bits as are necessary to decode the block size that it represents. 25 //When RequestedSize is equal to zero, the BAR is not used and BaseAdress should always return 0. 26 public uint RequestedSize { get; } 27 protected abstract uint addressMask { get; } 28 protected uint baseAddress; 29 } 30 } 31