Update AMDPCNetII.cs

This commit is contained in:
Valentin Charbonnier 2018-01-22 22:36:42 +01:00 committed by GitHub
parent ce1c49a13d
commit 9c78f671ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ namespace Cosmos.HAL.Drivers.PCI.Network
{ {
public class AMDPCNetII : NetworkDevice public class AMDPCNetII : NetworkDevice
{ {
protected PCIDevice pciCard; protected PCIDeviceNormal pciCard;
protected AMDPCNetIIIOGroup io; protected AMDPCNetIIIOGroup io;
protected MACAddress mac; protected MACAddress mac;
protected bool mInitDone; protected bool mInitDone;
@ -24,7 +24,7 @@ namespace Cosmos.HAL.Drivers.PCI.Network
protected Queue<byte[]> mTransmitBuffer; protected Queue<byte[]> mTransmitBuffer;
private int mNextTXDesc; private int mNextTXDesc;
public AMDPCNetII(PCIDevice device) public AMDPCNetII(PCIDeviceNormal device)
: base() : base()
{ {
if (device == null) if (device == null)
@ -36,7 +36,7 @@ namespace Cosmos.HAL.Drivers.PCI.Network
// this.pciCard.Claimed = true; // this.pciCard.Claimed = true;
//this.pciCard.EnableDevice(); //this.pciCard.EnableDevice();
this.io = new AMDPCNetIIIOGroup((ushort) this.pciCard.BaseAddressBar[0].BaseAddress); //this.io = new AMDPCNetIIIOGroup((ushort) this.pciCard.BaseAddresses[0].BaseAddress());
this.io.RegisterData.DWord = 0; this.io.RegisterData.DWord = 0;
// Get the EEPROM MAC Address and set it as the devices MAC // Get the EEPROM MAC Address and set it as the devices MAC
@ -129,55 +129,22 @@ namespace Cosmos.HAL.Drivers.PCI.Network
Cosmos.Core.Global.PIC.EoiSlave(); Cosmos.Core.Global.PIC.EoiSlave();
} }
// /// <summary>
// Retrieve all AMD PCNetII network cards found on computer. /// Retrieve all AMD PCNetII network cards found on computer.
// /// </summary>
//public static void FindAll() public static void FindAll()
//{ {
// Console.WriteLine("Scanning for AMD PCNetII cards..."); Console.WriteLine("Scanning for AMD PCNetII cards...");
// PCIDevice device; // PCIDevice device = Cosmos.HAL.PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
// device = HAL.PCI.GetDevice(0x1022, 0x2000);
// if (device != null) // if (device != null)
// { // {
// AMDPCNetII nic = new AMDPCNetII(device); // AMDPCNetII nic = new AMDPCNetII((PCIDeviceNormal) device);
//
// Console.WriteLine("Found AMD PCNetII NIC on PCI " + device.bus + ":" + device.slot + ":" + // Console.WriteLine("Found AMD PCNetII NIC on PCI " + device.bus + ":" + device.slot + ":" +
// device.function); // device.function);
// Console.WriteLine("NIC IRQ: " + device.InterruptLine); // Console.WriteLine("NIC IRQ: " + device.InterruptLine);
// Console.WriteLine("NIC MAC Address: " + nic.MACAddress.ToString()); // Console.WriteLine("NIC MAC Address: " + nic.MACAddress.ToString());
// } // }
//}
public static bool NetworkCardAvailable()
{
PCIDevice device;
device = HAL.PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
if (device != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Get MAC Address String
/// </summary>
public static string PhysicalAdress()
{
PCIDevice device;
device = HAL.PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
if (NetworkCardAvailable())
{
AMDPCNetII nic = new AMDPCNetII(device);
return nic.MACAddress.ToString();
}
else
{
return "";
}
} }
#region Register Access Properties #region Register Access Properties