problem with FDC
Posted: Tue Jun 22, 2010 4:48 am
I'm write code for reading sector from floppy disk. In the virtual machine(Bochs, qemu and VirtualBox) it works. But in the real machine memory at address 0x1000 contains 512 zeros. Why? And how to fix it?
My code:
My code:
Code: Select all
u32int read_sector(u8int head, u8int track, u8int sector)
{
u32int st0, cyl;
init_dma();
dma_read();
send_command(FDC_CMD_READ_SECT | FDC_CMD_EXT_MULTITRACK | FDC_CMD_EXT_SKIP | FDC_CMD_EXT_DENSITY);
send_command(head << 2 | 0 );
send_command(track);
send_command(head);
send_command(sector);
send_command(FLPYDSK_SECTOR_DTL_512);
send_command(FLPY_SECTORS_PER_TRACK);
send_command(FLPYDSK_GAP3_LENGTH_3_5);
send_command(0xFF);
wait_irq();
u32int retVal;
u8int j;
for (j=0; j<7; ++j)
{
u32int val = flpydsk_read_data();
if ((j==6) && (val==2))
retVal = 0;
else
retVal = -1;
}
check_int(&st0,&cyl);
return retVal;
}
void init_dma ()
{
outb (0x0a,0x06);
outb (0x0c,0xff);
outb (0x04, 0);
outb (0x04, 0x10);
outb (0x0c, 0xff);
outb (0x05, 0xff);
outb (0x05, 0x23);
outb (0x81, 0);
outb (0x0a, 0x02);
}
void dma_read ()
{
outb (0x0a, 0x06);
outb (0x0b, 0x46);
outb (0x0a, 0x02);
}