Fix ata detection bug. CD drives were recognized as ATAPI devices, but still handled as ATA ones. Currently we don't have an ATAPI driver, so the CD drives are ignored.

Fixes #129
This commit is contained in:
Matthijs ter Woord 2015-07-05 13:28:16 +02:00
parent 9b13be0d02
commit 5fca0ecbb7
5 changed files with 85 additions and 58 deletions

View file

@ -32,11 +32,11 @@ namespace Cosmos.Debug.VSDebugEngine.Host
"floppy_bootsig_check: disabled=0\n" +
"# no floppya\n" +
"# no floppyb\n" +
"ata0-master: type=cdrom, path=\"%CDROMBOOTPATH%\", status=inserted, model=\"Generic 1234\", biosdetect=auto\n" +
"ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14\n" +
"ata0-master: type=disk, path=\"%HARDDISKPATH%\", mode=vmware4, cylinders=0, heads=0, spt=0, model=\"Generic 1234\", biosdetect=auto, translation=auto\n" +
"ata0-slave: type=none\n" +
"ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15\n" +
"ata1-master: type=cdrom, path=\"%CDROMBOOTPATH%\", status=inserted, model=\"Generic 1234\", biosdetect=auto\n" +
"ata1-master: type=disk, path=\"%HARDDISKPATH%\", mode=vmware4, cylinders=0, heads=0, spt=0, model=\"Generic 1234\", biosdetect=auto, translation=auto\n" +
"ata2: enabled=0\n" +
"ata3: enabled=0\n" +
"pci: enabled=1, chipset=i440fx\n" +
@ -85,11 +85,8 @@ namespace Cosmos.Debug.VSDebugEngine.Host
defaultConfigs.Set("com1", defaultConfigs.Get("com1").Replace("%PIPESERVERNAME%", xParts[1].ToLower()));
var xHarddiskFile = Path.Combine(CosmosPaths.Build, @"VMWare\Workstation\Filesystem.vmdk");
defaultConfigs.Set("ata0-master", defaultConfigs.Get("ata0-master").Replace("%HARDDISKPATH%", xHarddiskFile));
defaultConfigs.Set("ata1-master", defaultConfigs.Get("ata1-master").Replace("%CDROMBOOTPATH%", mParams["ISOFile"]));
defaultConfigs.Set("ata0-master", defaultConfigs.Get("ata0-master").Replace("%CDROMBOOTPATH%", mParams["ISOFile"]));
defaultConfigs.Set("ata1-master", defaultConfigs.Get("ata1-master").Replace("%HARDDISKPATH%", xHarddiskFile));
}
private void GenerateConfiguration(string filePath)

View file

@ -1,2 +1,8 @@
[*.cs]
indent_size=4
[Global.cs]
indent_size = 2
[BlockDevice/Ata.cs]
indent_size = 2

View file

@ -2,9 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.Debug.Kernel;
namespace Cosmos.HAL.BlockDevice {
public abstract class Ata : BlockDevice {
public abstract class Ata : BlockDevice
{
internal static Debugger AtaDebugger = new Debugger("HAL", "Ata");
protected Ata() {
mBlockSize = 512;

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading;
using Cosmos.Common;
using Cosmos.Debug.Kernel;
namespace Cosmos.HAL.BlockDevice
{
@ -127,6 +128,13 @@ namespace Cosmos.HAL.BlockDevice
}
#endregion
internal static Debugger mDebugger = new Debugger("HAL", "AtaPio");
private static void Debug(string message)
{
mDebugger.Send("AtaPio debug: " + message);
}
public AtaPio(Core.IOGroup.ATA aIO, Ata.ControllerIdEnum aControllerId, Ata.BusPositionEnum aBusPosition)
{
IO = aIO;
@ -206,7 +214,6 @@ namespace Cosmos.HAL.BlockDevice
return SendCmd(aCmd, true);
}
public Status SendCmd(Cmd aCmd, bool aThrowOnError)
{
IO.Command.Byte = (byte)aCmd;
@ -221,6 +228,7 @@ namespace Cosmos.HAL.BlockDevice
if (aThrowOnError && (xStatus & Status.Error) != 0)
{
// TODO: Read error port
Debug("ATA Error in SendCmd. Cmd = " + (byte)aCmd + ", Status = " + (byte)xStatus);
throw new Exception("ATA Error");
}
return xStatus;

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.HAL.BlockDevice;
namespace Cosmos.HAL {
static public class Global {
@ -14,11 +15,23 @@ namespace Cosmos.HAL {
public static PCI Pci;
static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID, BlockDevice.Ata.BusPositionEnum aBusPosition) {
private 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) {
if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.Null)
{
return;
}
if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.ATA)
{
BlockDevice.BlockDevice.Devices.Add(xATA);
}
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 BlockDevice.MBR(xMbrData);
@ -55,7 +68,6 @@ namespace Cosmos.HAL {
}
}
}
}
// Init devices that are "static"/mostly static. These are devices
// that all PCs are expected to have. Keyboards, screens, ATA hard drives etc.