Ata boot fix.

This commit is contained in:
Valentin Charbonnier 2017-10-10 21:40:11 +02:00
parent e132b0f473
commit c75cdffbb4
2 changed files with 40 additions and 9 deletions

View file

@ -15,6 +15,7 @@ namespace Cosmos.HAL
public static TextScreenBase TextScreen = new TextScreen(); public static TextScreenBase TextScreen = new TextScreen();
public static PCI Pci; public static PCI Pci;
public static int atamode;
static public void Init(TextScreenBase textScreen) static public void Init(TextScreenBase textScreen)
{ {
@ -46,16 +47,26 @@ namespace Cosmos.HAL
mDebugger.Send("Done initializing Cosmos.HAL.Global"); mDebugger.Send("Done initializing Cosmos.HAL.Global");
mDebugger.Send("ATA Primary Master"); if (atamode == 1)
InitAta(Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master); {
//TODO Implement an AHCI Driver
//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. else if (atamode == 2)
// Or is it always here, and was our compiler stack corruption issue? {
mDebugger.Send("ATA Secondary Master"); //TODO Implement a RAID Driver
InitAta(Ata.ControllerIdEnum.Secondary, Ata.BusPositionEnum.Master); }
//InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave); else if (atamode == 3)
{
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);
}
} }
public static void EnableInterrupts() public static void EnableInterrupts()

View file

@ -32,6 +32,26 @@ namespace Cosmos.HAL
CheckBus(fn); 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) private static void CheckBus(ushort xBus)