kernel: Make floppies work again

Operating Systems / DragonFlyBSD - zrj [] - 29 November 2017 16:20 EST

Revive the old x86 32bit only fdc(4) driver, it only needs just a few changes. The fdc was never ported to work on x86_64 DragonFly, so rather than remove it together with its manpage, fix few things and hook it to LINT64 config so that we would keep track the state of it and not keep it in a dusty corner of sys/.

On modern x86_64 systems fdc($) has little value and it is getting harder and harder to find floppy drives that work or even the motherboards that still have the FDD headers to hook the 34pin ribbon cable, but I feel nostalgic about the scratching noises the floppy drive makes while performing the operations. So went through all storage closets and find one that works, blew out all the accumulated dusts, cleaned the magnetic heads with a folder paper tissue good. The hardest part was to find a floppy disk. Only could find just a single one stashed away deep on the floor of a very old safe under heeps of old documents.

For fdc(4) to actually work, some adjustmens to isa_dma.c were needed because of how ISA bus probing is done in platform/pc64/x86_64/autoconf.c. To work around the exhaustion of low DMA memory before it gets to isa_probe_children() now try to preallocate contiguous buffer of 512KB and free it just before the probe of ISA bus. This should help any legacy ISA drivers(including ppc(4)) or even some of more picky drivers that are not built in into the kernel.

For case where isa_dmainit() would still fail to allocate the buffer fitting the requirements, have added the safety checks and explicit fallback to non DMA mode by setting the FDC_NODMA flag to avoid panics on "bad bounce buffer". Floppy drive would not work properly, but it is this versus a panic. There are other issues too. For some reason some files tend to be read with stripes of zeros, but write operations seems to work. Same floppy is readable on linux.

Currently can not debug the issue cause my floppy had seen better days: _# time dd if=/dev/fd0 of=/tmp/recover.img conv=sync,noerror

dd: /dev/fd0: Input/output error 2880+0 records in 2880+0 records out 1474560 bytes transferred in 80.723953 secs (18267 bytes/sec)

while dmesg: fd0: hard error reading offset 00000000ae00 for 512 (ST0 40 ST1 20 ST2 20 cyl 2 hd 0 sec 16) fd0: hard error reading offset 00000000f600 for 512 (ST0 40 ST1 1 ST2 1 cyl 3 hd 0 sec 16) fd0: hard error reading offset 000000113800 for 512 (ST0 40 ST1 20 ST2 20 cyl 61 hd 0 sec 9) fd0: hard error reading offset 000000115c00 for 512 (ST0 44 ST1 4 ST2 10 cyl 61 hd 1 sec 9) fd0: hard error reading offset 00000011a400 for 512 (ST0 44 ST1 4 ST2 0 cyl 62 hd 1 sec 9) fd0: hard error reading offset 00000011ec00 for 512 (ST0 44 ST1 4 ST2 0 cyl 63 hd 1 sec 9) fd0: hard error reading offset 000000123400 for 512 (ST0 44 ST1 4 ST2 0 cyl 64 hd 1 sec 9) fd0: hard error reading offset 000000127c00 for 512 (ST0 44 ST1 4 ST2 0 cyl 65 hd 1 sec 9)

Given the state of my single floppy I cannot even do a proper newfs_msdos(8). So maybe someone who has a collection of good floppies could give it a go.

While there, hook old musycc(4) driver to LINT64, it was fixed in: 906779c3d1e064e55bb019342ad6c1621cc04399

0bc821c68b kernel: Make floppies work again.
sys/bus/isa/isavar.h | 8 ++++++-
sys/bus/isa/x86_64/isa_dma.c | 42 ++++++++++++++++++++++---------------
sys/conf/files | 2 ++
sys/config/LINT64 | 14 ++++++++-----
sys/dev/disk/fd/fd.c | 16 +++++++++++---
sys/dev/disk/fd/fdc.h | 3 +--
sys/platform/pc64/x86_64/autoconf.c | 23 ++++++++++++++++++++
sys/vm/vm_page.c | 2 +-
8 files changed, 81 insertions(+), 29 deletions(-)


  • Share