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.Structure.Registers; 9 10 namespace Antmicro.Renode.Peripherals.PCI 11 { 12 [Flags] 13 public enum HeaderType 14 { 15 Endpoint = 0, 16 Bridge = 1, 17 CardBus = 2, 18 MultiFunctionDevice = 1 << 7, 19 } 20 21 public static class HeaderTypeExtensions 22 { MaxNumberOfBARs(this HeaderType type)23 public static int MaxNumberOfBARs(this HeaderType type) 24 { 25 switch(type) 26 { 27 case HeaderType.Bridge: 28 return 2; 29 case HeaderType.Endpoint: 30 default: 31 //6 is a safest default, but it's certainly ok for endpoints 32 return 6; 33 } 34 } 35 } 36 } 37