mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 03:01:32 +00:00
This commit is contained in:
parent
48e4e12cd3
commit
daae44735c
4 changed files with 26 additions and 4 deletions
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue