mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 11:11:45 +00:00
ata works completely now
This commit is contained in:
parent
61f6cd1e8b
commit
e418dc4251
2 changed files with 40 additions and 11 deletions
|
|
@ -217,7 +217,41 @@ namespace Cosmos.Hardware.New.Storage {
|
|||
}
|
||||
|
||||
public override void WriteBlock(ulong aBlock, byte[] aContents) {
|
||||
throw new NotImplementedException();
|
||||
uint xSleepCount = Timeout;
|
||||
while (((IOReadByte(mController_Command) & 0x80) == 0x80) && xSleepCount > 0) {
|
||||
mSleep(1);
|
||||
xSleepCount--;
|
||||
}
|
||||
if (xSleepCount == 0) {
|
||||
throw new Exception("[ATA|WriteBlockNew] Failed 1");
|
||||
}
|
||||
IOWriteByte(mController_FeatureReg, 0);
|
||||
IOWriteByte(mController_SectorCount, 1);
|
||||
IOWriteByte(mController_SectorNumber, (byte)aBlock);
|
||||
IOWriteByte(mController_CylinderLow, (byte)(aBlock >> 8));
|
||||
IOWriteByte(mController_CylinderHigh, (byte)(aBlock >> 16));
|
||||
IOWriteByte( mController_DeviceHead, (byte)(0xE0 | (mDrive << 4) | (byte)(aBlock >> 24)));
|
||||
IOWriteByte(mController_DeviceControl, 0); // receive interrupts...
|
||||
IOWriteByte(mController_Command, 0x30);
|
||||
xSleepCount = Timeout;
|
||||
while (((IOReadByte(mController_Command) & 0x80) == 0x80) && xSleepCount > 0) {
|
||||
mSleep(1);
|
||||
xSleepCount--;
|
||||
}
|
||||
if (xSleepCount == 0) {
|
||||
throw new Exception("[ATA|WriteBlockNew] Failed 2");
|
||||
}
|
||||
xSleepCount = Timeout;
|
||||
while (((IOReadByte(mController_AlternateStatus) & 0x8) == 0x8) && xSleepCount > 0) {
|
||||
mSleep(1);
|
||||
xSleepCount--;
|
||||
}
|
||||
if (xSleepCount == 0) {
|
||||
throw new Exception("[ATA|WriteBlockNew] Failed 3");
|
||||
}
|
||||
for (int i = 0; i < 256; i++) {
|
||||
IOWriteWord(mController_Data, (ushort)((aContents[i * 2]) | (aContents[i * 2 + 1] << 8)));
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
|
|
|
|||
|
|
@ -50,16 +50,11 @@ namespace Cosmos.Shell.Console.Commands {
|
|||
System.Console.WriteLine("Storage device is null!");
|
||||
return;
|
||||
}
|
||||
var xBytes = xBD.ReadBlock(2);
|
||||
System.Console.Write("Byte 1-1: ");
|
||||
System.Console.WriteLine(xBytes[6].ToString());
|
||||
System.Console.Write("Byte 1-2: ");
|
||||
System.Console.WriteLine(xBytes[7].ToString());
|
||||
xBytes = xBD.ReadBlock(3);
|
||||
System.Console.Write("Byte 2-1: ");
|
||||
System.Console.WriteLine(xBytes[6].ToString());
|
||||
System.Console.Write("Byte 2-2: ");
|
||||
System.Console.WriteLine(xBytes[7].ToString());
|
||||
var xBytes = new byte[512];
|
||||
for (int i = 0; i < 512; i++) {
|
||||
xBytes[i] = (byte)(i % 255);
|
||||
}
|
||||
xBD.WriteBlock(0, xBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue