*/
void FDD_int_SendByte(int base, char byte)
{
- volatile int state;
- int timeout = 128;
- for( ; timeout--; )
+ int timeout = 128;
+
+ while( (inb(base + PORT_MAINSTATUS) & 0xC0) != 0x80 && timeout-- )
+ inb(0x80); //Delay
+
+ if( timeout >= 0 )
{
- state = inb(base + PORT_MAINSTATUS);
- if ((state & 0xC0) == 0x80)
- {
- outb(base + PORT_DATA, byte);
- return;
- }
- inb(0x80); //Delay
+ outb(base + PORT_DATA, byte);
+ }
+ else
+ {
+ Log_Warning("FDD", "FDD_int_SendByte: Timeout sending byte 0x%x to base 0x%x\n", byte, base);
}
-
- #if WARN
- Warning("FDD_int_SendByte - Timeout sending byte 0x%x to base 0x%x\n", byte, base);
- #endif
}
/**
*/
int FDD_int_GetByte(int base)
{
- volatile int state;
- int timeout;
- for( timeout = 128; timeout--; )
+ int timeout = 128;
+
+ while( (inb(base + PORT_MAINSTATUS) & 0xd0) != 0xd0 && timeout-- )
+ inb(0x80); //Delay
+
+ if( timeout >= 0 )
{
- state = inb((base + PORT_MAINSTATUS));
- if ((state & 0xd0) == 0xd0)
- return inb(base + PORT_DATA);
- inb(0x80);
+ return inb(base + PORT_DATA);
+ }
+ else
+ {
+ Log_Warning("FDD", "FDD_int_GetByte: Timeout reading byte from base 0x%x\n", base);
+ return -1;
}
- return -1;
}
/**