mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-07 08:41:45 +00:00
Merge pull request #50 from aura-systems/fix-networking
NETWORK FIX. FINALLY.
This commit is contained in:
commit
3da5facc69
3 changed files with 51 additions and 24 deletions
|
|
@ -95,8 +95,8 @@ namespace Cosmos.Core
|
||||||
// set masks:
|
// set masks:
|
||||||
Master.Data.Byte = masterMask;
|
Master.Data.Byte = masterMask;
|
||||||
IOPort.Wait();
|
IOPort.Wait();
|
||||||
Slave.Data.Byte = slaveMask;
|
//Slave.Data.Byte = slaveMask;
|
||||||
IOPort.Wait();
|
//IOPort.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Init(IOGroup.PIC aPIC, byte aBase, byte aIDunno, byte aMask)
|
protected void Init(IOGroup.PIC aPIC, byte aBase, byte aIDunno, byte aMask)
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ namespace Cosmos.HAL.Drivers.PCI.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pciCard = device;
|
this.pciCard = device;
|
||||||
// this.pciCard.Claimed = true;
|
this.pciCard.Claimed = true;
|
||||||
//this.pciCard.EnableDevice();
|
this.pciCard.EnableDevice();
|
||||||
|
|
||||||
//this.io = new AMDPCNetIIIOGroup((ushort) this.pciCard.BaseAddresses[0].BaseAddress());
|
this.io = new AMDPCNetIIIOGroup((ushort) this.pciCard.BaseAddressBar[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
|
||||||
|
|
@ -97,7 +97,7 @@ namespace Cosmos.HAL.Drivers.PCI.Network
|
||||||
mTransmitBuffer = new Queue<byte[]>();
|
mTransmitBuffer = new Queue<byte[]>();
|
||||||
mRecvBuffer = new Queue<byte[]>();
|
mRecvBuffer = new Queue<byte[]>();
|
||||||
|
|
||||||
//INTs.SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt);
|
INTs.SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void HandleNetworkInterrupt(ref INTs.IRQContext aContext)
|
protected void HandleNetworkInterrupt(ref INTs.IRQContext aContext)
|
||||||
|
|
@ -135,16 +135,16 @@ namespace Cosmos.HAL.Drivers.PCI.Network
|
||||||
public static void FindAll()
|
public static void FindAll()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Scanning for AMD PCNetII cards...");
|
Console.WriteLine("Scanning for AMD PCNetII cards...");
|
||||||
// PCIDevice device = Cosmos.HAL.PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
|
PCIDevice device = Cosmos.HAL.PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
|
||||||
// if (device != null)
|
if (device != null)
|
||||||
// {
|
{
|
||||||
// AMDPCNetII nic = new AMDPCNetII((PCIDevice) device);
|
AMDPCNetII nic = new AMDPCNetII((PCIDevice) 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());
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Register Access Properties
|
#region Register Access Properties
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ namespace Cosmos.HAL
|
||||||
|
|
||||||
public enum PCIBist : byte
|
public enum PCIBist : byte
|
||||||
{
|
{
|
||||||
CocdMask = 0x0f,
|
CocdMask = 0x0f, /* Return result */
|
||||||
Start = 0x40,
|
Start = 0x40, /* 1 to start BIST, 2 secs or less */
|
||||||
Capable = 0x80
|
Capable = 0x80 /* 1 if BIST capable */
|
||||||
};
|
}
|
||||||
|
|
||||||
public enum PCIInterruptPIN : byte
|
public enum PCIInterruptPIN : byte
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +35,20 @@ namespace Cosmos.HAL
|
||||||
INTD = 0x04
|
INTD = 0x04
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public enum PCICommand : short
|
||||||
|
{
|
||||||
|
IO = 0x1, /* Enable response in I/O space */
|
||||||
|
Memory = 0x2, /* Enable response in Memory space */
|
||||||
|
Master = 0x4, /* Enable bus mastering */
|
||||||
|
Special = 0x8, /* Enable response to special cycles */
|
||||||
|
Invalidate = 0x10, /* Use memory write and invalidate */
|
||||||
|
VGA_Pallete = 0x20, /* Enable palette snooping */
|
||||||
|
Parity = 0x40, /* Enable parity checking */
|
||||||
|
Wait = 0x80, /* Enable address/data stepping */
|
||||||
|
SERR = 0x100, /* Enable SERR */
|
||||||
|
Fast_Back = 0x200, /* Enable back-to-back writes */
|
||||||
|
}
|
||||||
|
|
||||||
public enum Config : byte
|
public enum Config : byte
|
||||||
{
|
{
|
||||||
VendorID = 0, DeviceID = 2,
|
VendorID = 0, DeviceID = 2,
|
||||||
|
|
@ -63,7 +77,6 @@ namespace Cosmos.HAL
|
||||||
public readonly ushort VendorID;
|
public readonly ushort VendorID;
|
||||||
public readonly ushort DeviceID;
|
public readonly ushort DeviceID;
|
||||||
|
|
||||||
public readonly ushort Command;
|
|
||||||
public readonly ushort Status;
|
public readonly ushort Status;
|
||||||
|
|
||||||
public readonly byte RevisionID;
|
public readonly byte RevisionID;
|
||||||
|
|
@ -85,6 +98,14 @@ namespace Cosmos.HAL
|
||||||
|
|
||||||
protected static Core.IOGroup.PCI IO = new Core.IOGroup.PCI();
|
protected static Core.IOGroup.PCI IO = new Core.IOGroup.PCI();
|
||||||
|
|
||||||
|
public byte InterruptLine { get; private set; }
|
||||||
|
public PCICommand Command { get { return (PCICommand)ReadRegister16(0x04); } set { WriteRegister16(0x04, (ushort)value); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has this device been claimed by a driver
|
||||||
|
/// </summary>
|
||||||
|
public bool Claimed { get; set; }
|
||||||
|
|
||||||
public PCIDevice(uint bus, uint slot, uint function)
|
public PCIDevice(uint bus, uint slot, uint function)
|
||||||
{
|
{
|
||||||
this.bus = bus;
|
this.bus = bus;
|
||||||
|
|
@ -94,9 +115,8 @@ namespace Cosmos.HAL
|
||||||
VendorID = ReadRegister16((byte)Config.VendorID);
|
VendorID = ReadRegister16((byte)Config.VendorID);
|
||||||
DeviceID = ReadRegister16((byte)Config.DeviceID);
|
DeviceID = ReadRegister16((byte)Config.DeviceID);
|
||||||
|
|
||||||
Command = ReadRegister16((byte)Config.Command);
|
//Command = ReadRegister16((byte)Config.Command);
|
||||||
Status = ReadRegister16((byte)Config.Status);
|
//Status = ReadRegister16((byte)Config.Status);
|
||||||
|
|
||||||
|
|
||||||
RevisionID = ReadRegister8((byte)Config.RevisionID);
|
RevisionID = ReadRegister8((byte)Config.RevisionID);
|
||||||
ProgIF = ReadRegister8((byte)Config.ProgIF);
|
ProgIF = ReadRegister8((byte)Config.ProgIF);
|
||||||
|
|
@ -107,6 +127,8 @@ namespace Cosmos.HAL
|
||||||
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
|
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
|
||||||
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
|
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
|
||||||
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);
|
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);
|
||||||
|
InterruptLine = ReadRegister8((byte)Config.InterruptLine);
|
||||||
|
|
||||||
if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF)
|
if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF)
|
||||||
{
|
{
|
||||||
DeviceExists = false;
|
DeviceExists = false;
|
||||||
|
|
@ -127,6 +149,11 @@ namespace Cosmos.HAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnableDevice()
|
||||||
|
{
|
||||||
|
Command |= PCICommand.Master | PCICommand.IO | PCICommand.Memory;
|
||||||
|
}
|
||||||
|
|
||||||
public static ushort GetHeaderType(ushort Bus, ushort Slot, ushort Function)
|
public static ushort GetHeaderType(ushort Bus, ushort Slot, ushort Function)
|
||||||
{
|
{
|
||||||
UInt32 xAddr = GetAddressBase(Bus, Slot, Function) | 0xE & 0xFC;
|
UInt32 xAddr = GetAddressBase(Bus, Slot, Function) | 0xE & 0xFC;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue