This commit is contained in:
Valentin Charbonnier 2017-08-17 04:13:58 +02:00
parent 342d3f86d7
commit 4b02644e95
4 changed files with 119 additions and 51 deletions

View file

@ -137,7 +137,7 @@ namespace Cosmos.HAL.Drivers.PCI.Video
private MemoryBlock Video_Memory;
private MemoryBlock FIFO_Memory;
private PCIDeviceNormal device;
private PCIDevice device;
private uint height;
private uint width;
private uint depth;
@ -145,13 +145,13 @@ namespace Cosmos.HAL.Drivers.PCI.Video
public VMWareSVGAII()
{
//device = (PCIDeviceNormal)(HAL.PCI.GetDevice(0x15AD, 0x0405));
device = (HAL.PCI.GetDevice(0x15AD, 0x0405));
device.EnableMemory(true);
//uint basePort = device.BaseAddresses[0].BaseAddress();
//IndexPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Index));
//ValuePort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Value));
//BiosPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Bios));
// IRQPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.IRQ));
uint basePort = device.BaseAddressBar[0].BaseAddress;
IndexPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Index));
ValuePort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Value));
BiosPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Bios));
IRQPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.IRQ));
WriteRegister(Register.ID, (uint)ID.V2);
if (ReadRegister(Register.ID) != (uint)ID.V2)

View file

@ -15,7 +15,6 @@ namespace Cosmos.HAL
public static TextScreenBase TextScreen = new TextScreen();
public static PCI Pci;
public static int atamode;
static public void Init(TextScreenBase textScreen)
{
@ -47,26 +46,16 @@ namespace Cosmos.HAL
mDebugger.Send("Done initializing Cosmos.HAL.Global");
if (atamode == 1)
{
//TODO Implement an AHCI Driver
}
else if (atamode == 2)
{
//TODO Implement a RAID Driver
}
else if (atamode == 3)
{
mDebugger.Send("ATA Primary Master");
InitAta(Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master);
mDebugger.Send("ATA Primary Master");
InitAta(Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master);
//TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum?
// They do show up in PCI space as well as the fixed space.
// Or is it always here, and was our compiler stack corruption issue?
mDebugger.Send("ATA Secondary Master");
InitAta(Ata.ControllerIdEnum.Secondary, Ata.BusPositionEnum.Master);
//InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave);
}
//TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum?
// They do show up in PCI space as well as the fixed space.
// Or is it always here, and was our compiler stack corruption issue?
mDebugger.Send("ATA Secondary Master");
InitAta(Ata.ControllerIdEnum.Secondary, Ata.BusPositionEnum.Master);
//InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave);
}
public static void EnableInterrupts()

View file

@ -18,7 +18,6 @@ namespace Cosmos.HAL
public static void Setup()
{
Devices = new List<PCIDevice>();
if ((PCIDevice.GetHeaderType(0x0, 0x0, 0x0) & 0x80) == 0)
{
CheckBus(0x0);
@ -33,26 +32,6 @@ namespace Cosmos.HAL
CheckBus(fn);
}
}
foreach (PCIDevice device in Devices)
{
if (device.ClassCode == 0x01 && device.Subclass == 0x06 && device.ProgIF == 0x01)
{
//Serial ATA (AHCI 1.0)
Global.atamode = 1;
}
else if (device.ClassCode == 0x01 && device.Subclass == 0x04 && device.ProgIF == 0x00)
{
//RAID Controller
Global.atamode = 2;
}
else if (device.ClassCode == 0x01 && device.Subclass == 0x01)
{
//IDE Controller
Global.atamode = 3;
}
}
}
private static void CheckBus(ushort xBus)
@ -95,12 +74,12 @@ namespace Cosmos.HAL
return null;
}
public static PCIDevice GetDeviceClass(ushort Class, ushort SubClass)
public static PCIDevice GetDevice(ushort VendorID, ushort DeviceID)
{
for (int i = 0; i < Devices.Count; i++)
{
var xDevice = Devices[i];
if (xDevice.ClassCode == Class && xDevice.Subclass == SubClass)
if (xDevice.VendorID == VendorID && xDevice.DeviceID == DeviceID)
{
return Devices[i];
}
@ -108,4 +87,4 @@ namespace Cosmos.HAL
return null;
}
}
}
}

View file

@ -198,6 +198,106 @@ namespace Cosmos.HAL
WriteRegister16(0x04, command);
}
public class DeviceClass
{
public static string GetString(PCIDevice device)
{
switch (device.VendorID)
{
case 0x1022: //AMD
switch (device.DeviceID)
{
case 0x2000:
return "AMD PCnet LANCE PCI Ethernet Controller";
}
break;
case 0x104B: //Sony
switch (device.DeviceID)
{
case 0x1040:
return "Mylex BT958 SCSI Host Adaptor";
}
break;
case 0x1274: //Ensoniq
switch (device.DeviceID)
{
case 0x1371:
return "Ensoniq AudioPCI";
}
break;
case 0x15AD: //VMware
switch (device.DeviceID)
{
case 0x0405:
return "VMware NVIDIA 9500MGS";
case 0x0770:
return "VMware Standard Enhanced PCI to USB Host Controller";
case 0x0790:
return "VMware 6.0 Virtual USB 2.0 Host Controller";
case 0x07A0:
return "VMware PCI Express Root Port";
}
break;
case 0x8086: //Intel
switch (device.DeviceID)
{
case 0x7190:
return "Intel 440BX/ZX AGPset Host Bridge";
case 0x7191:
return "Intel 440BX/ZX AGPset PCI-to-PCI bridge";
case 0x7110:
return "Intel PIIX4/4E/4M ISA Bridge";
case 0x7112:
return "Intel PIIX4/4E/4M USB Interface";
}
break;
}
switch (device.ClassCode)
{
//case 0x00:
// return "Any device";
case 0x01:
return "Mass Storage Controller";
case 0x02:
return "Network Controller";
case 0x03:
return "Display Controller";
case 0x04:
return "Multimedia Controller";
case 0x05:
return "Memory Controller";
case 0x06:
return "Bridge Device";
case 0x07:
return "Simple Communication Controller";
case 0x08:
return "Base System Peripheral";
case 0x09:
return "Input Device";
case 0x0A:
return "Docking Station";
case 0x0B:
return "Processor";
case 0x0C:
return "Serial Bus Controller";
case 0x0D:
return "Wireless Controller";
case 0x0E:
return "Intelligent I/O Controller";
case 0x0F:
return "Satellite Communication Controller";
case 0x10:
return "Encryption/Decryption Controller";
case 0x11:
return "Data Acquisition and Signal Processing Controller";
//case 0xFF:
// return "Unkown device";
}
return "ClassCode: " + device.ClassCode + " Subclass: " + device.Subclass + " ProgIF: " + device.ProgIF;
}
}
private static string ToHex(uint aNumber, byte aBits)
{
return "0x" + aNumber.ToHex(aBits / 4);