From c75cdffbb4300fff8935cda473882c96b58bc379 Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Tue, 10 Oct 2017 21:40:11 +0200 Subject: [PATCH] Ata boot fix. --- source/Cosmos.HAL2/Global.cs | 29 ++++++++++++++++++++--------- source/Cosmos.HAL2/PCI.cs | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/source/Cosmos.HAL2/Global.cs b/source/Cosmos.HAL2/Global.cs index d09b92700..aa79337dc 100644 --- a/source/Cosmos.HAL2/Global.cs +++ b/source/Cosmos.HAL2/Global.cs @@ -15,6 +15,7 @@ namespace Cosmos.HAL public static TextScreenBase TextScreen = new TextScreen(); public static PCI Pci; + public static int atamode; static public void Init(TextScreenBase textScreen) { @@ -46,16 +47,26 @@ namespace Cosmos.HAL mDebugger.Send("Done initializing Cosmos.HAL.Global"); - mDebugger.Send("ATA Primary Master"); - InitAta(Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master); + 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); - //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() diff --git a/source/Cosmos.HAL2/PCI.cs b/source/Cosmos.HAL2/PCI.cs index 200b3a09a..4595313c6 100644 --- a/source/Cosmos.HAL2/PCI.cs +++ b/source/Cosmos.HAL2/PCI.cs @@ -32,6 +32,26 @@ 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)