Skip to content

Commit

Permalink
Remove BDEV_SIZE_CHK and XMS ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Sep 13, 2023
1 parent 5a33552 commit 35708a0
Showing 1 changed file with 2 additions and 54 deletions.
56 changes: 2 additions & 54 deletions elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,6 @@ struct floppy_struct *base_type[4];
struct floppy_struct user_params[4];
#endif

#ifdef BDEV_SIZE_CHK
static int floppy_sizes[] = {
MAX_DISK_SIZE, MAX_DISK_SIZE, MAX_DISK_SIZE, MAX_DISK_SIZE,
360, 360, 360, 360,
1200, 1200, 1200, 1200,
360, 360, 360, 360,
720, 720, 720, 720,
360, 360, 360, 360,
720, 720, 720, 720,
1440, 1440, 1440, 1440
};
#endif

/*
* The driver is trying to determine the correct media format
* while probing is set. rw_interrupt() clears it after a
Expand Down Expand Up @@ -597,11 +584,7 @@ static void setup_DMA(void)
} else if (dma_addr >= LAST_DMA_ADDR) {
dma_addr = _MK_LINADDR(kernel_ds, tmp_floppy_area); /* use bounce buffer */
if (command == FD_WRITE) {
#ifdef CONFIG_FS_XMS_BUFFER
xms_fmemcpyw(tmp_floppy_area, kernel_ds, CURRENT->rq_buffer, CURRENT->rq_seg, BLOCK_SIZE/2);
#else
fmemcpyw(tmp_floppy_area, kernel_ds, CURRENT->rq_buffer, CURRENT->rq_seg, BLOCK_SIZE/2);
#endif
}
}
DEBUG("%d/%lx;", count, dma_addr);
Expand Down Expand Up @@ -842,40 +825,28 @@ static void rw_interrupt(void)
printk("Auto-detected floppy type %s in df%d\n",
floppy->name, drive);
current_type[drive] = floppy;
#ifdef BDEV_SIZE_CHK
floppy_sizes[drive] = floppy->size >> 1;
#endif
probing = 0;
}
if (read_track) {
buffer_track = (seek_track << 1) + head; /* This encoding is ugly, should
* save block-start, block-end instead */
buffer_drive = current_drive;
buffer_area = (unsigned char *)(sector << 9);
#ifdef CONFIG_FS_XMS_BUFFER
DEBUG("rd:%lx:%04x->%lx:%04x;", DMASEG, buffer_area, CURRENT->rq_seg, CURRENT->rq_buffer);
DEBUG("rd:%x:%04x->%lx:%04x;", DMASEG, buffer_area,
(unsigned long)CURRENT->rq_seg, CURRENT->rq_buffer);
xms_fmemcpyw(CURRENT->rq_buffer, CURRENT->rq_seg, buffer_area, DMASEG, BLOCK_SIZE/2);
#else
DEBUG("rd:%04x:%04x->%04x:%04x;", DMASEG, buffer_area, CURRENT->rq_seg, CURRENT->rq_buffer);
fmemcpyw(CURRENT->rq_buffer, CURRENT->rq_seg, buffer_area, DMASEG, BLOCK_SIZE/2);
#endif
} else if (command == FD_READ
#ifndef CONFIG_FS_XMS_BUFFER
&& _MK_LINADDR(CURRENT->rq_seg, CURRENT->rq_buffer) >= LAST_DMA_ADDR
#endif
) {
/* if the dest buffer is out of reach for DMA (always the case if using
* XMS buffers) we need to read/write via the bounce buffer */
#ifdef CONFIG_FS_XMS_BUFFER
xms_fmemcpyw(CURRENT->rq_buffer, CURRENT->rq_seg, tmp_floppy_area, kernel_ds, BLOCK_SIZE/2);
#else
fmemcpyw(CURRENT->rq_buffer, CURRENT->rq_seg, tmp_floppy_area, kernel_ds, BLOCK_SIZE/2);
#endif
printk("directfd: illegal buffer usage, rq_buffer %04x:%04x\n",
CURRENT->rq_seg, CURRENT->rq_buffer);
}
request_done(1);
//printk("RQOK;");
redo_fd_request();
}

Expand Down Expand Up @@ -1156,9 +1127,6 @@ static void floppy_ready(void)
printk("Disk type is undefined after disk change in df%d\n",
current_drive);
current_type[current_drive] = NULL;
#ifdef BDEV_SIZE_CHK
floppy_sizes[current_drive] = MAX_DISK_SIZE;
#endif
}
/* Forcing the drive to seek makes the "media changed" condition go
* away. There should be a cleaner solution for that ...
Expand Down Expand Up @@ -1329,19 +1297,11 @@ static void redo_fd_request(void)
DEBUG("bufrd tr/h/s %d/%d/%d\n", seek_track, head, sector);
char *buf_ptr = (char *) (sector << 9);
if (command == FD_READ) { /* requested data is in buffer */
#ifdef CONFIG_FS_XMS_BUFFER
xms_fmemcpyw(req->rq_buffer, req->rq_seg, buf_ptr, DMASEG, BLOCK_SIZE/2);
#else
fmemcpyw(req->rq_buffer, req->rq_seg, buf_ptr, DMASEG, BLOCK_SIZE/2);
#endif
request_done(1);
goto repeat;
} else if (command == FD_WRITE) /* update track buffer */
#ifdef CONFIG_FS_XMS_BUFFER
xms_fmemcpyw(buf_ptr, DMASEG, req->rq_buffer, req->rq_seg, BLOCK_SIZE/2);
#else
fmemcpyw(buf_ptr, DMASEG, req->rq_buffer, req->rq_seg, BLOCK_SIZE/2);
#endif
}

if (seek_track != current_track)
Expand Down Expand Up @@ -1456,19 +1416,13 @@ static int fd_ioctl(struct inode *inode,
switch (cmd) {
case FDCLRPRM:
current_type[drive] = NULL;
#ifdef BDEV_SIZE_CHK
floppy_sizes[drive] = MAX_DISK_SIZE;
#endif
keep_data[drive] = 0;
break;
case FDSETPRM:
case FDDEFPRM:
memcpy_fromfs(user_params + drive,
(void *) param, sizeof(struct floppy_struct));
current_type[drive] = &user_params[drive];
#ifdef BDEV_SIZE_CHK
floppy_sizes[drive] = user_params[drive].size >> 1;
#endif
if (cmd == FDDEFPRM)
keep_data[drive] = -1;
else {
Expand Down Expand Up @@ -1646,19 +1600,13 @@ static void floppy_interrupt(int unused, struct pt_regs *unused1)

void INITPROC floppy_init(void)
{
#ifdef BDEV_SIZE_CHK
extern int *blk_size[];
#endif
int err;

outb(current_DOR, FD_DOR); /* all motors off, DMA, /RST (0x0c) */
if (register_blkdev(MAJOR_NR, DEVICE_NAME, &floppy_fops)) {
printk("Unable to get major %d for floppy\n", MAJOR_NR);
return;
}
#ifdef BDEV_SIZE_CHK
blk_size[MAJOR_NR] = floppy_sizes;
#endif
blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;

config_types();
Expand Down

0 comments on commit 35708a0

Please sign in to comment.