mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 22:09:12 +00:00
Move IDE to a new Location
This commit is contained in:
parent
74720b3be0
commit
6d960bd955
1 changed files with 65 additions and 0 deletions
65
source/Cosmos.HAL2/Drivers/Controllers/IDE.cs
Normal file
65
source/Cosmos.HAL2/Drivers/Controllers/IDE.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using Cosmos.HAL.BlockDevice;
|
||||
|
||||
namespace Cosmos.HAL.Drivers.PCI.SATA
|
||||
{
|
||||
public class IDE
|
||||
{
|
||||
public static void InitAta(Ata.ControllerIdEnum aControllerID, Ata.BusPositionEnum aBusPosition)
|
||||
{
|
||||
var xIO = aControllerID == Ata.ControllerIdEnum.Primary ? Core.Global.BaseIOGroups.ATA1 : Core.Global.BaseIOGroups.ATA2;
|
||||
var xATA = new AtaPio(xIO, aControllerID, aBusPosition);
|
||||
if (xATA.DriveType == AtaPio.SpecLevel.Null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (xATA.DriveType == AtaPio.SpecLevel.ATA)
|
||||
{
|
||||
BlockDevice.BlockDevice.Devices.Add(xATA);
|
||||
Ata.AtaDebugger.Send("ATA device with speclevel ATA found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ata.AtaDebugger.Send("ATA device with spec level " + (int)xATA.DriveType +
|
||||
// " found, which is not supported!");
|
||||
return;
|
||||
}
|
||||
var xMbrData = new byte[512];
|
||||
xATA.ReadBlock(0UL, 1U, xMbrData);
|
||||
var xMBR = new MBR(xMbrData);
|
||||
|
||||
if (xMBR.EBRLocation != 0)
|
||||
{
|
||||
//EBR Detected
|
||||
var xEbrData = new byte[512];
|
||||
xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData);
|
||||
var xEBR = new EBR(xEbrData);
|
||||
|
||||
for (int i = 0; i < xEBR.Partitions.Count; i++)
|
||||
{
|
||||
//var xPart = xEBR.Partitions[i];
|
||||
//var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
|
||||
//BlockDevice.BlockDevice.Devices.Add(xPartDevice);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Change this to foreach when foreach is supported
|
||||
Ata.AtaDebugger.Send("Number of MBR partitions found:");
|
||||
Ata.AtaDebugger.SendNumber(xMBR.Partitions.Count);
|
||||
for (int i = 0; i < xMBR.Partitions.Count; i++)
|
||||
{
|
||||
var xPart = xMBR.Partitions[i];
|
||||
if (xPart == null)
|
||||
{
|
||||
Console.WriteLine("Null partition found at idx: " + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
var xPartDevice = new Partition(xATA, xPart.StartSector, xPart.SectorCount);
|
||||
BlockDevice.BlockDevice.Devices.Add(xPartDevice);
|
||||
Console.WriteLine("Found partition at idx" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue