From daae44735c7000a7fde092cbbe84aa385b776a9d Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Tue, 22 Feb 2011 22:52:19 +0000 Subject: [PATCH] --- .../Hardware/Cosmos.Hardware/BlockDevice/Ata.cs | 11 ++++++++++- .../Hardware/Cosmos.Hardware/BlockDevice/AtaPio.cs | 3 ++- .../System/Hardware/Cosmos.Hardware/Global.cs | 14 +++++++++++++- source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/Ata.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/Ata.cs index e3f217e36..7cfd0f2b2 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/Ata.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/Ata.cs @@ -5,7 +5,16 @@ using System.Text; namespace Cosmos.Hardware.BlockDevice { public abstract class Ata : BlockDevice { - public enum BusPositionEnum {Master, Slave} + + // In future may need to add a None for PCI ATA controllers. + // Or maybe they all have Primary and Secondary on them as well. + public enum ControllerIdEnum { Primary, Secondary } + protected ControllerIdEnum mControllerID; + public ControllerIdEnum ControllerID { + get { return mControllerID; } + } + + public enum BusPositionEnum { Master, Slave } protected BusPositionEnum mBusPosition; public BusPositionEnum BusPosition { get { return mBusPosition; } diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/AtaPio.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/AtaPio.cs index 523213073..9b1d92a6e 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/AtaPio.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/BlockDevice/AtaPio.cs @@ -22,8 +22,9 @@ namespace Cosmos.Hardware.BlockDevice { get { return mDriveType; } } - public AtaPio(Core.IOGroup.ATA aIO, Ata.BusPositionEnum aBusPosition) { + public AtaPio(Core.IOGroup.ATA aIO, Ata.ControllerIdEnum aControllerId, Ata.BusPositionEnum aBusPosition) { IO = aIO; + mControllerID = aControllerId; mBusPosition = aBusPosition; // Disable IRQs, we use polling currently IO.Control.Byte = 0x02; diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/Global.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/Global.cs index 5f9c55835..8018c98fc 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/Global.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/Global.cs @@ -12,6 +12,14 @@ namespace Cosmos.Hardware { // Must be static init, other static inits rely on it not being null static public TextScreen TextScreen = new TextScreen(); + static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID, BlockDevice.Ata.BusPositionEnum aBusPosition) { + var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary ? Cosmos.Core.Global.BaseIOGroups.ATA1 : Cosmos.Core.Global.BaseIOGroups.ATA2; + var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition); + if (xATA.DriveType != BlockDevice.AtaPio.SpecLevel.Null) { + BlockDevice.BlockDevice.Devices.Add(xATA); + } + } + // Init devices that are "static"/mostly static. These are devices // that all PCs are expected to have. Keyboards, screens, ATA hard drives etc. // Despite them being static, some discovery is required. For example, to see if @@ -22,7 +30,11 @@ namespace Cosmos.Hardware { Keyboard = new Keyboard(); - + // Find hardcoded ATA controllers + InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Master); + InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Slave); + InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Master); + InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave); } static internal void InitPciDevices() { diff --git a/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs b/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs index 142f0139e..1334c8fbe 100644 --- a/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs +++ b/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs @@ -26,7 +26,7 @@ namespace BreakpointsKernel { } protected override void Run() { - var xATA = new AtaPio(Cosmos.Core.Global.BaseIOGroups.ATA1, Ata.BusPositionEnum.Master); + var xATA = new AtaPio(Cosmos.Core.Global.BaseIOGroups.ATA1, Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master); var xWrite = new byte[512]; for (int i = 0; i < 512; i++) {