I have the documents at debs.future.easyspace.com/Programming/Hardware/FDC/floppy.html as well as some from www.osdever.net
After reading i've decided that the first function to write would be the power_on of the FDC (obviously) so i implemented this with a simple
Code: Select all
void power_on()
{
outb(FDCA_BASE+DOR,0x1C);
delay(500); // a 500 ms delay
calib_drive(); // read on
}
Code: Select all
void FDCHandler(void)
{
kprintf("\nFloppy IRQ ");
fdc_flag=!fdc_flag;???// fdc_flag is a volatile BYTE
}
this however needed some other small routines such as waiting for the FDC etc.. So i wrote the following(in NASM)
Code: Select all
_FDC_cmd_ready:
.cont:
mov???dx,FDCA_BASE+MSR
in???al,dx
and???al,0xC0
cmp???al,0x80
jne???.cont
retn
Code: Select all
void calib_drive(void)
{
BYTE st0=-1,cyl=-1;
do{
fdc_flag=1;
kprintf("\nCalibrating Drive..");
FDC_cmd_ready();
outb(FDCA_BASE+DR,CALIBRATE_DRIVE);
outb(FDCA_BASE+DR,0);
while(fdc_flag);
chk_int_status(&st0,&cyl);??????// this is below
kprintf("\nst0=%d,cyl=%d",st0,cyl);
}while((st0 & 0x10)); // until UC bit is reset
}
Code: Select all
void chk_int_status(BYTE *st0,BYTE *cyl)
{
kprintf("\nChecking int status..");
FDC_cmd_ready();
outb(FDCA_BASE+DR,CHK_INT_STATUS);
*st0=inb(FDCA_BASE+DR);???
*cyl=inb(FDCA_BASE+DR);
}