Frustratingly, I keep on encountering 'real PC' errors with my FDC code that do not encounter under Bochs, both when booting from an image file and when booting from floppy. When reading a sector, using a FDC_READ (0x06) command, all is well in Bochs but two PCs, both an old 486 and a new Pentium 4, complain of a missing ID address mark.
I use WinImage to create an image, inserting files to it, and either run Bochs to use the image or write the image on a floppy (using Windows XP) and boot from floppy. I found some issues on the web on Win XP and the above ID address mark error, but I doubt whether it denotes the same problem.
Here's the relevant part of the code:
Code: Select all
void floppy_read(unsigned char head, unsigned char cylinder, void *address)
{
int i, retries = 5;
while (retries)
{
set_system_timer(FDC_TIMER, 1000); /* timeout on FDC activity */
fdc_motor_on();
if (!implied_seeks) /* to be used on older drives */
floppy_seek(head, cylinder);
setup_DMA_channel(FDC_DMA, 0x44, 0x2400, (unsigned int) address);
/* to mem, single transfer, 0x2400 bytes = 18 sectors */
fdc_sendbyte(FDC_READ | 0x60); /* read command MFM/SK set MT clear */
fdc_sendbyte(head * 4); /* bits 0 and 1 denote drive number ( = 0) */
fdc_sendbyte(cylinder); /* send head */
fdc_sendbyte(head); /* resend head */
fdc_sendbyte(1); /* first sector */
fdc_sendbyte(2); /* sector size = 512 */
fdc_sendbyte(18); /* 18 sectors per cylinder */
fdc_sendbyte(27); /* GPL gap length */
fdc_sendbyte(0xFF); /* DTL special code (ff = not used) */
while ((get_system_timer(FDC_TIMER)) && (fdc_done == 0))
; /* wait till fdc isr signals fdc ready */
fdc_done = 0; /* reset fdc-done flag */
if (!get_system_timer(FDC_TIMER)) /* timer zero's out - no good - retry */
{
panic(KERN_NOTICE, "Timeout on floppy read");
floppy_error = FDC_READ_TIMEOUT;
retries--;
break;
}
for (i = 0; i < 7; i++) /* get the status bytes */
fdc_statusbytes[i] = fdc_readbyte();
if ((fdc_statusbytes[0] & 0xC0) != 0x00) /* any error indicated? */
{
panic(KERN_NOTICE, "Read error in FDC driver\n%s", FDC_status_error(fdc_statusbytes[0],
fdc_statusbytes[1], fdc_statusbytes[2]));
panic(KERN_NOTICE, "Retrying to read");
floppy_error = FDC_READ_ERROR;
retries--;
}
else /* all's well! */
{
floppy_error = NO_ERROR;
retries = 0;
}
}
}
Best,
Johan