示例#1
0
        /// <summary>
        /// Finds the driver.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        /// <returns></returns>
        public DeviceDriver FindDriver(IPCIDevice pciDevice)
        {
            DeviceDriver bestDeviceDriver = null;
            int          bestPriority     = System.Int32.MaxValue;

            foreach (DeviceDriver deviceDriver in deviceDrivers)
            {
                if (deviceDriver.Attribute is PCIDeviceDriverAttribute)
                {
                    PCIDeviceDriverAttribute pciDeviceDriverAttribute = deviceDriver.Attribute as PCIDeviceDriverAttribute;
                    if ((pciDeviceDriverAttribute.Priority != 0) && (pciDeviceDriverAttribute.Priority < bestPriority))
                    {
                        if (pciDeviceDriverAttribute.CompareTo(pciDevice))
                        {
                            bestDeviceDriver = deviceDriver;
                            bestPriority     = pciDeviceDriverAttribute.Priority;
                        }
                    }
                }
            }

            return(bestDeviceDriver);
        }
示例#2
0
 private IDeviceDriver GetIDeviceDriver(CustomAttributeData attributeData)
 {
     if (attributeData.AttributeType == typeof(ISADeviceDriverAttribute))
     {
         var attribute = new ISADeviceDriverAttribute();
         foreach (var arg in attributeData.NamedArguments)
         {
             if (arg.MemberName == "Platforms")
             {
                 attribute.Platforms = (PlatformArchitecture)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "BasePort")
             {
                 attribute.BasePort = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "PortRange")
             {
                 attribute.PortRange = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "AltBasePort")
             {
                 attribute.AltBasePort = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "AltPortRange")
             {
                 attribute.AltPortRange = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "AutoLoad")
             {
                 attribute.AutoLoad = (bool)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "ForceOption")
             {
                 attribute.ForceOption = (string)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "IRQ")
             {
                 attribute.IRQ = (byte)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "BaseAddress")
             {
                 attribute.BaseAddress = (uint)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "AddressRange")
             {
                 attribute.AddressRange = (uint)arg.TypedValue.Value;
             }
         }
         return(attribute);
     }
     else
     {
         var attribute = new PCIDeviceDriverAttribute();
         foreach (var arg in attributeData.NamedArguments)
         {
             if (arg.MemberName == "Platforms")
             {
                 attribute.Platforms = (PlatformArchitecture)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "DeviceID")
             {
                 attribute.DeviceID = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "VendorID")
             {
                 attribute.VendorID = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "SubVendorID")
             {
                 attribute.SubVendorID = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "SubDeviceID")
             {
                 attribute.SubDeviceID = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "RevisionID")
             {
                 attribute.RevisionID = (byte)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "ProgIF")
             {
                 attribute.ProgIF = (byte)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "ClassCode")
             {
                 attribute.ClassCode = (ushort)arg.TypedValue.Value;
             }
             else if (arg.MemberName == "SubClassCode")
             {
                 attribute.SubClassCode = (byte)arg.TypedValue.Value;
             }
         }
         return(attribute);
     }
 }
 private IDeviceDriver GetIDeviceDriver(CustomAttributeData attributeData)
 {
     if (attributeData.AttributeType == typeof(ISADeviceDriverAttribute))
     {
         var attribute = new ISADeviceDriverAttribute();
         foreach (var arg in attributeData.NamedArguments)
         {
             if (arg.MemberName == "Platforms")
                 attribute.Platforms = (PlatformArchitecture)arg.TypedValue.Value;
             else if (arg.MemberName == "BasePort")
                 attribute.BasePort = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "PortRange")
                 attribute.PortRange = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "AltBasePort")
                 attribute.AltBasePort = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "AltPortRange")
                 attribute.AltPortRange = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "AutoLoad")
                 attribute.AutoLoad = (bool)arg.TypedValue.Value;
             else if (arg.MemberName == "ForceOption")
                 attribute.ForceOption = (string)arg.TypedValue.Value;
             else if (arg.MemberName == "IRQ")
                 attribute.IRQ = (byte)arg.TypedValue.Value;
             else if (arg.MemberName == "BaseAddress")
                 attribute.BaseAddress = (uint)arg.TypedValue.Value;
             else if (arg.MemberName == "AddressRange")
                 attribute.AddressRange = (uint)arg.TypedValue.Value;
         }
         return attribute;
     }
     else
     {
         var attribute = new PCIDeviceDriverAttribute();
         foreach (var arg in attributeData.NamedArguments)
         {
             if (arg.MemberName == "Platforms")
                 attribute.Platforms = (PlatformArchitecture)arg.TypedValue.Value;
             else if (arg.MemberName == "DeviceID")
                 attribute.DeviceID = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "VendorID")
                 attribute.VendorID = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "SubVendorID")
                 attribute.SubSystemVendorID = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "SubDeviceID")
                 attribute.SubSystemID = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "RevisionID")
                 attribute.RevisionID = (byte)arg.TypedValue.Value;
             else if (arg.MemberName == "ProgIF")
                 attribute.ProgIF = (byte)arg.TypedValue.Value;
             else if (arg.MemberName == "ClassCode")
                 attribute.ClassCode = (ushort)arg.TypedValue.Value;
             else if (arg.MemberName == "SubClassCode")
                 attribute.SubClassCode = (byte)arg.TypedValue.Value;
         }
         return attribute;
     }
 }