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 Antmicro.Renode.Core.Structure.Registers;
8 
9 namespace Antmicro.Renode.Peripherals.PCI.BAR
10 {
11     public class MemoryBaseAddressRegister : BaseAddressRegister
12     {
MemoryBaseAddressRegister(uint requestedSize, BarType barType, bool prefetchable)13         public MemoryBaseAddressRegister(uint requestedSize, BarType barType, bool prefetchable) : base(requestedSize)
14         {
15             this.barType = barType;
16             this.prefetchable = prefetchable;
17         }
18 
19         public override uint Value
20         {
21             get
22             {
23                 return baseAddress | ((prefetchable ? 1u : 0u) << 3) | ((uint)barType << 1);
24             }
25             set
26             {
27                 BaseAddress = value;
28             }
29         }
30 
31         protected override uint addressMask => ~0xFu;
32 
33         private readonly bool prefetchable;
34         private readonly BarType barType;
35 
36         public enum BarType
37         {
38             LocateIn32Bit = 0,
39             LocateIn64Bit = 2
40         }
41     }
42 }