Cosmos/source/FrodeTest/Shell/Session.cs
Scalpel_cp 05b23b6ba8 RTL driver changes.
Initializes buffers earlier, begin IRQ to detect incoming packet
Added Recieve Configuration Register. 
Loopback.
2008-03-22 02:38:08 +00:00

88 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace FrodeTest.Shell
{
public class Session
{
Security.User xUser = null;
static ushort xSessionId;
static Cosmos.Driver.RTL8139.RTL8139 nic = null;
public Session(Security.User user)
{
xSessionId++;
xUser = user;
}
internal void Run()
{
Console.Write(Prompt.LoadPrompt(xUser).PromptText());
string command = Console.ReadLine();
if (command.Equals("exit"))
return;
/* else if (command.Equals("nic"))
{
Cosmos.Hardware.PC.Bus.PCIDevice pciNic = Cosmos.Hardware.PC.Bus.PCIBus.GetPCIDevice(0, 3, 0);
nic = new Cosmos.Driver.RTL8139.RTL8139(pciNic);
nic.Enable();
Console.WriteLine("Enabled Network card");
}
*/ else if(command.Equals("load"))
{
List<Cosmos.Driver.RTL8139.RTL8139> list = Cosmos.Driver.RTL8139.RTL8139.FindRTL8139Devices();
if (list.Count != 0)
{
nic = list[0];
}
nic.Enable();
nic.InitializeDriver();
}
else if (command.Equals("send"))
{
Cosmos.Driver.RTL8139.PacketHeader head = new Cosmos.Driver.RTL8139.PacketHeader(0xFF);
byte[] data = FrodeTest.Test.Mock.FakeBroadcastPacket.GetFakePacket();
Cosmos.Driver.RTL8139.Packet packet = new Cosmos.Driver.RTL8139.Packet(head, data);
if (nic == null)
{
Console.WriteLine("Enable NIC with command load first");
return;
}
nic.Transmit(packet);
}
else if (command.Equals("reset"))
{
//nic.TimerCount = 1;
nic.SoftReset();
nic.InitializeDriver();
Console.WriteLine("NIC has been reset");
}
else if(command.Equals("loop"))
{
Console.WriteLine("Toggle - current loopback mode: " + nic.GetLoopbackMode().ToString());
nic.SetLoopbackMode(!nic.GetLoopbackMode());
Console.WriteLine("Set to: " + nic.GetLoopbackMode().ToString());
}
else if (command.Equals("help"))
{
Console.WriteLine("Valid commands: load, send, loop, reset or exit");
}
else
Console.WriteLine("No such systemcommand or application: " + command);
Run(); //Recursive call
}
internal static Session CreateSession(FrodeTest.Security.User currentUser)
{
return new Session(currentUser);
}
}
}