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

[directfd] Add IODELAY floppy delay emulation to DF driver #2076

Merged
merged 2 commits into from
Oct 15, 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
5 changes: 3 additions & 2 deletions elks/arch/i86/drivers/block/bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ int BFPROC bios_disk_rw(unsigned cmd, unsigned num_sectors, unsigned drive,
static unsigned lastcyl;
unsigned ms = abs(cylinder - lastcyl) * 4 / 10;
lastcyl = cylinder;
ms += 10 + num_sectors; /* 1440k @300rpm = 100ms + ~10ms/sector + 4ms/tr */
if (drive == 1)
if (drive == 0)
ms += 10 + num_sectors; /* 1440k @300rpm = 100ms + ~10ms/sector + 4ms/tr */
else
ms += 8 + (num_sectors<<1); /* 360k @360rpm = 83ms + ~20ms/sector + 3ms/tr */
unsigned long timeout = jiffies + ms*HZ/100;
while (!time_after(jiffies, timeout)) continue;
Expand Down
19 changes: 18 additions & 1 deletion elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
char USE_IMPLIED_SEEK = 0; /* =1 for QEMU with 360k/AT stretch floppies (not real hw) */
#define CHECK_DIR_REG 1 /* =1 to read and clear DIR DSKCHG when media changed */
#define CHECK_DISK_CHANGE 1 /* =1 to inform kernel of media changed */
#define IODELAY 0 /* =1 to emulate delay for floppy on QEMU */

/* adjustable timeouts */
#define TIMEOUT_MOTOR_ON (HZ/2) /* 500 ms wait for floppy motor on before I/O */
Expand All @@ -136,6 +137,8 @@ char USE_IMPLIED_SEEK = 0; /* =1 for QEMU with 360k/AT stretch floppies (not rea
//#define DEBUG printk
#define DEBUG(...)

#define abs(v) (((int)(v) >= 0)? (v): -(v))

#define bool unsigned char /* don't require stdbool.h yet */

static void (*do_floppy)(); /* interrupt routine to call */
Expand Down Expand Up @@ -771,8 +774,22 @@ static void rw_interrupt(void)
static void DFPROC setup_rw_floppy(void)
{
DEBUG("setup_rw-");
setup_DMA();
#if IODELAY
int num_sectors = read_track? floppy->sect + (floppy->sect & 1 && !head);
: CURRENT->rq_nr_sectors;
DEBUG("[%ur%u]", current_drive, num_sectors);
static unsigned lasttrack;
unsigned ms = abs(track - lasttrack) * 4 / 10;
lasttrack = track;
if (current_drive == 0)
ms += 10 + num_sectors; /* 1440k @300rpm = 100ms + ~10ms/sector + 4ms/tr */
else
ms += 8 + (num_sectors<<1); /* 360k @360rpm = 83ms + ~20ms/sector + 3ms/tr */
unsigned long timeout = jiffies + ms*HZ/100;
while (!time_after(jiffies, timeout)) continue;
#endif
do_floppy = rw_interrupt;
setup_DMA();
output_byte(command);
output_byte(head << 2 | current_drive);
output_byte(track);
Expand Down
Loading