Skip to content

Commit

Permalink
Update Sata.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte authored Dec 30, 2017
1 parent 5bbab33 commit 75320a7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions source/Cosmos.HAL2/BlockDevice/Ports/Sata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public void SendSATACommand(ATACommands aCommand)
Device = 0
};

while ((mPortReg.TFD & 0x88) != 0 && xSpin < 1000000);
int xSpin = 0;

while ((mPortReg.TFD & 0x88) != 0) && xSpin < 1000000) xSpin++;

if (xSpin == 1000000)
{
Expand Down Expand Up @@ -181,7 +183,15 @@ public void SendSATA28Command(ATACommands aCommand, uint aStart, uint aCount)
};
}

while ((mPortReg.TFD & 0x88) != 0);
int xSpin = 0;

while ((mPortReg.TFD & 0x88) != 0) && xSpin < 1000000) xSpin++;

if (xSpin == 1000000)
{
mSATAPIDebugger.Send($"Port {mPortNumber} timed out!");
return;
};

mPortReg.CI = 1U;

Expand Down Expand Up @@ -247,8 +257,16 @@ public void SendSATA48Command(ATACommands aCommand, ulong aStart, uint aCount)
CountH = (byte)((aCount >> 8) & 0xFF)
};

while ((mPortReg.TFD & 0x88) != 0) ;
int xSpin = 0;

while ((mPortReg.TFD & 0x88) != 0) && xSpin < 1000000) xSpin++;

if (xSpin == 1000000)
{
mSATAPIDebugger.Send($"Port {mPortNumber} timed out!");
return;
};

mPortReg.CI = 1U;

while (true)
Expand Down

0 comments on commit 75320a7

Please sign in to comment.