Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kernel] Fix BIOS track read retry errors under QEMU #2063

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions elks/arch/i86/drivers/block/bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
#include <linuxmt/kernel.h>
#include <linuxmt/kdev_t.h>
#include <linuxmt/debug.h>
#include <linuxmt/sched.h>
#include <arch/system.h>
#include <arch/param.h>
#include "bioshd.h"

#define RESET_DISK_CHG 0 /* =1 to reset BIOS on drive change fixes QEMU retry */
#define RESET_DISK_CHG 1 /* =1 to reset BIOS on drive change fixes QEMU retry */
#define IODELAY 0 /* emulate delay for floppy on QEMU */

/*
* Indices for fd_types array. Note these match the value returned
Expand Down Expand Up @@ -105,7 +108,7 @@ int BFPROC bios_disk_rw(unsigned cmd, unsigned num_sectors, unsigned drive,

#if RESET_DISK_CHG
static unsigned last = 0;
if (drive != last) {
if (running_qemu && drive != last) {
bios_disk_reset(1); /* fixes QEMU retry when switching drive types #1119 */
last = drive;
}
Expand All @@ -119,10 +122,15 @@ int BFPROC bios_disk_rw(unsigned cmd, unsigned num_sectors, unsigned drive,
debug_bios("BIOSHD(%x): %s CHS %d/%d/%d count %d\n", drive,
cmd==BIOSHD_READ? "read": "write",
cylinder, head, sector, num_sectors);
#ifdef IODELAY
/* emulate floppy delay for QEMU */
unsigned long timeout = jiffies + IODELAY*HZ/100;
while (!time_after(jiffies, timeout)) continue;
#if IODELAY
debug_bios("[%ur%u]", drive, num_sectors);
if (drive < 2) { /* emulate floppy delay for QEMU */
unsigned int ms = 10 + num_sectors; /* 1440k @ 300rpm = 100ms + ~10ms/sector */
if (drive == 1)
ms = 8 + (num_sectors<<1); /* 360k @ 360rpm = 83ms + ~20ms/sector */
unsigned long timeout = jiffies + ms*HZ/100;
while (!time_after(jiffies, timeout)) continue;
}
#endif
return call_bios(&bdt);
}
Expand Down
1 change: 0 additions & 1 deletion elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#define DEBUG_PROBE 0 /* =1 to display more floppy probing information */
#define FORCE_PROBE 0 /* =1 to force floppy probing */
#define FULL_TRACK 0 /* =1 to read full tracks when track caching */
//#define IODELAY 5 /* times 10ms, emulated delay for floppy on QEMU */
#define MAX_ERRS 5 /* maximum sector read/write error retries */

#define MAJOR_NR BIOSHD_MAJOR
Expand Down
Loading