Skip to content

Commit

Permalink
Update Satapi.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte authored Dec 30, 2017
1 parent a512891 commit 14fa401
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions source/Cosmos.HAL2/BlockDevice/Ports/Satapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,44 +91,28 @@ public void SendSATAPICommand(ATACommands aCommand, uint aStart, uint aCount)

if (xSpin == 1000000)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\n[Error]: ");
Console.Write("Port timed out!");
Console.ResetColor();
mSATAPIDebugger.Send($"Port {mPortNumber} timed out!");
return;
};

mPortReg.CI = 1U;

while(true)
{
if((mPortReg.CI & (1 << xSlot)) == 0)
{
break;
}
if((mPortReg.CI & (1 << xSlot)) == 0) break;
if ((mPortReg.IS & (1 << 30)) != 0)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.Write("\n[Fatal]: ");
Console.Write("Fatal error occurred while sending command!");
Console.ResetColor();
throw new Exception("SATA Fatal error: Command aborted");
//mSATADebugger.Send("[Fatal]: Fatal error occurred while sending command!");
//PortReset(mPortReg);
return;
}
}

if ((mPortReg.IS & (1 << 30)) != 0)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.Write("\n[Fatal]: ");
Console.Write("Fatal error occurred while sending command!");
Console.ResetColor();
return;
}

Console.ForegroundColor = ConsoleColor.Green;
Console.Write("\n[Success]: ");
Console.Write("Command has been sent successfully!");
Console.ResetColor();
//Console.ForegroundColor = ConsoleColor.Green;
//Console.Write("\n[Success]: ");
//Console.Write("Command has been sent successfully!");
//Console.ResetColor();

return;
}
Expand All @@ -144,10 +128,7 @@ public int FindCMDSlot(PortRegisters aPort)
return i;
xSlots >>= 1;
}
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\n[Error]: ");
Console.Write("Cannot find a free command slot!");
Console.ResetColor();
mSATAPIDebugger.Send("SATA Error: Cannot find a free command slot!");
return -1;
}

Expand All @@ -164,7 +145,7 @@ public override void ReadBlock(ulong aBlockNo, ulong aBlockCount, byte[] aData)

public override void WriteBlock(ulong aBlockNo, ulong aBlockCount, byte[] aData)
{

// To be implemented!
}
}
}

0 comments on commit 14fa401

Please sign in to comment.