X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FStorage%2FFDD%2Ffdd.c;h=e507e94e3de226d1f5958956c76c9ee5edb31de5;hb=246109db20d55bb7deb50af2f62f40b96fa4e831;hp=a7b20f7d763edbe4681751478e9b6ca720525180;hpb=e6795eb552a6be88b7870dae14a958ab391bfae8;p=tpg%2Facess2.git diff --git a/Modules/Storage/FDD/fdd.c b/Modules/Storage/FDD/fdd.c index a7b20f7d..e507e94e 100644 --- a/Modules/Storage/FDD/fdd.c +++ b/Modules/Storage/FDD/fdd.c @@ -107,7 +107,7 @@ Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk); int FDD_ReadSector(Uint32 disk, Uint64 lba, void *Buffer); int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer); // --- Helpers -void FDD_IRQHandler(int Num); +void FDD_IRQHandler(int Num, void *Ptr); inline void FDD_WaitIRQ(); void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl); int FDD_int_SendByte(int base, Uint8 Byte); @@ -172,7 +172,7 @@ int FDD_Install(char **Arguments) } // Install IRQ6 Handler - IRQ_AddHandler(6, FDD_IRQHandler); + IRQ_AddHandler(6, FDD_IRQHandler, NULL); // Ensure the FDD version is 0x90 { @@ -676,7 +676,7 @@ int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt) * \fn void FDD_IRQHandler(int Num) * \brief Handles IRQ6 */ -void FDD_IRQHandler(int Num) +void FDD_IRQHandler(int Num, void *Ptr) { gbFDD_IrqFired = 1; } @@ -707,8 +707,13 @@ int FDD_int_SendByte(int base, Uint8 byte) { tTime end = now() + 1000; // 1s - while( (inb(base + PORT_MAINSTATUS) & 0xC0) != 0x80 && now() < end ) + while( (inb(base + PORT_MAINSTATUS) & 0x80) != 0x80 && now() < end ) Threads_Yield(); //Delay + + if( inb(base + PORT_MAINSTATUS) & 0x40 ) { + Log_Warning("FDD", "FDD_int_SendByte: DIO set, is this ok?"); + return -2; + } if( now() < end ) { @@ -731,9 +736,14 @@ int FDD_int_GetByte(int base, Uint8 *value) { tTime end = now() + 1000; // 1s - while( (inb(base + PORT_MAINSTATUS) & 0xd0) != 0xd0 && now() < end ) + while( (inb(base + PORT_MAINSTATUS) & 0x80) != 0x80 && now() < end ) Threads_Yield(); + if( !(inb(base + PORT_MAINSTATUS) & 0x40) ) { + Log_Warning("FDD", "FDD_int_GetByte: DIO unset, is this ok?"); + return -2; + } + if( now() < end ) { Uint8 tmp = inb(base + PORT_DATA); @@ -834,11 +844,13 @@ int FDD_Reset(int id) // Recalibrate disks LOG("Recalibrate disks (16x seek)"); retries = 16; - while(FDD_int_SeekTrack(0, 0, 1) == 0 && retries --); // set track + while(FDD_int_SeekTrack(0, 0, 1) == 0 && retries --) + Threads_Yield(); // set track if(retries < 0) LEAVE_RET('i', -1); retries = 16; - while(FDD_int_SeekTrack(0, 1, 1) == 0 && retries --); // set track + while(FDD_int_SeekTrack(0, 1, 1) == 0 && retries --) + Threads_Yield(); // set track if(retries < 0) LEAVE_RET('i', -1); LOG("Recalibrating Disk");