RTL - RxBuffer changes

This commit is contained in:
Scalpel_cp 2008-04-25 22:11:05 +00:00
parent 7fb2b38e78
commit dfa240f2bf
4 changed files with 54 additions and 36 deletions

View file

@ -181,7 +181,7 @@ namespace Cosmos.Build.Windows {
// Ethernet card - Later the model should be a QEMU option on
// options screen
+ " -net nic,model=rtl8139,macaddr=52:54:00:12:34:57"
//+ " -redir tcp:5555::23" //use 'telnet localhost 5555' to access machine
//+ " -redir tcp:5555::23" //use f.instance 'telnet localhost 5555' or 'http://localhost:5555/' to access machine
//+ " -net tap,ifname=CosmosTAP" //requires TAP installed on development computer
+ " -net user"
, ToolsPath + @"qemu\", false, true);

View file

@ -100,7 +100,8 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
private void InitReceiveBuffer()
{
//Prepare a buffer area
RxBuffer = new byte[100];
UInt16 bufferSize = (1024 * 16) + (4 * 4); //last 4 bytes used for CRC
RxBuffer = new byte[bufferSize];
UInt32 address = pciCard.BaseAddress1 + (byte)Register.MainRegister.Bit.RxBuf;
@ -257,7 +258,38 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
public byte[] ReadReceiveBuffer()
{
return RxBuffer;
List<byte> receivedBytes = new List<byte>();
Console.WriteLine("RxBuffer is at address " + GetMemoryAddress(ref RxBuffer));
Console.WriteLine("Received data from address " + valueReg.CurrentAddressOfPacketRead + " to address " + valueReg.CurrentBufferAddress);
//The data to be read is in the RxBuffer, but offset by the CBR.
//UInt16 readPointer =
/*for (int i = valueReg.CurrentAddressOfPacketRead; i < valueReg.CurrentBufferAddress; i++)
{
receivedBytes.Add(RxBuffer[i]);
}*/
UInt16 readPointer = valueReg.CurrentAddressOfPacketRead;
UInt16 writtenPointer = valueReg.CurrentBufferAddress;
while (readPointer != writtenPointer)
{
receivedBytes.Add(RxBuffer[readPointer]);
if (readPointer == 0xFFF0)
readPointer = 0;
else
readPointer++;
}
//Update the CAPR so that the RTL8139 knows that we've read the data.
//valueReg.CurrentAddressOfPacketRead = valueReg.CurrentBufferAddress;
Console.WriteLine("Setting CAPR to " + readPointer);
valueReg.CurrentAddressOfPacketRead = readPointer;
return receivedBytes.ToArray();
}
public override bool QueueBytes(byte[] buffer, int offset, int length)
@ -437,7 +469,7 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
Console.WriteLine("RxBufPtr: " + reg.RxBufPtr.ToString());
Console.WriteLine("Speed 10Mb?: " + msr.Speed10MB.ToString());
Console.WriteLine("Link OK?: " + (!msr.LinkStatusInverse).ToString());
Console.WriteLine("CBR (byte count): " + valueReg.CurrentBufferPointer.ToString());
Console.WriteLine("CBR (byte count): " + valueReg.CurrentBufferAddress.ToString());
Console.WriteLine("IMR: " + imr.ToString());
Console.WriteLine("ISR: " + isr.ToString());
}
@ -460,10 +492,12 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
//Just for testing
public void DisplayReadBuffer()
{
Console.WriteLine("Read buffer contains " + this.ReadReceiveBuffer().Length + " bytes.");
byte[] readData = this.ReadReceiveBuffer();
Console.WriteLine("Read buffer contains " + readData.Length + " bytes.");
Console.WriteLine("---------------------------------");
foreach (byte b in this.ReadReceiveBuffer())
foreach (byte b in readData)
Console.Write(b.ToHex() + ":");
Console.WriteLine();

View file

@ -14,29 +14,6 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139.Register
this.mem = mem;
}
//[Obsolete]
//public byte Config0
//{
// get { return mem.Read8Unchecked((UInt32)Bit.Config0); }
// set { mem.Write8Unchecked((UInt32)Bit.Config0, value); }
//}
//[Obsolete]
//public byte Config1
//{
// get { return mem.Read8Unchecked((UInt32)Bit.Config1); }
// set { mem.Write8Unchecked((UInt32)Bit.Config1, value); }
//}
//[Obsolete]
//public UInt32 TxConfig
//{
// get { return mem.Read32((UInt32)Bit.TxConfig); }
// set { mem.Write32((UInt32)Bit.TxConfig, value); }
//}
/// <summary>
/// Current Address of RX pointer. Also known as CAPR.
/// </summary>

View file

@ -130,19 +130,26 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139.Register
//RBSTART
//CAPR(?)
/// <summary>
/// The address in the RxBuffer that the driver has read up to.
/// Also known as: CAPR / Current Address Pointer Read
/// </summary>
public UInt16 CurrentAddressOfPacketRead
{
get { return xMem.Read16((UInt32)MainRegister.Bit.RxBufPtr); }
set { xMem.Write16((UInt32)MainRegister.Bit.RxBufPtr, value); }
}
//CBR
#region CBR/CBP/Current Buffer Address/Buffer Write Pointer/Received byte count
public UInt16 CurrentBufferPointer
/// <summary>
/// The CBR contains the address of the last byte in the RXBuffer.
/// Also known as: CBR/CBP/Current Buffer Address/Buffer Write Pointer/Received byte count
/// </summary>
public UInt16 CurrentBufferAddress
{
get { return xMem.Read16((UInt32)MainRegister.Bit.RxBufAddr); }
private set { ;}
}
#endregion
//TCTR
//MPC