summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Travis <harleytravis123@outlook.com>2026-05-26 18:05:55 -0500
committerHarley Travis <harleytravis123@outlook.com>2026-05-26 18:05:55 -0500
commit3198f0d5bbfea8692bf7ab9725cc298ae730d4d2 (patch)
tree206531adfa201010f450732e2739559d3070e7be
parent92570c206cfd38ab8ee875bd76d69184665909d2 (diff)
downloadtempleos-floppy-driver-3198f0d5bbfea8692bf7ab9725cc298ae730d4d2.tar.gz
Update KFloppy.HC and ReadMe.TXT
I have corrected a copy-paste error I made while writing the multi-track write code that caused controller timeouts. I have also done further line length reduction. See ChangeLog.TXT for details.
-rw-r--r--ChangeLog.TXT11
-rw-r--r--KFloppy.HC19
-rw-r--r--ReadMe.TXT41
3 files changed, 47 insertions, 24 deletions
diff --git a/ChangeLog.TXT b/ChangeLog.TXT
index 3e12b81..e0d7e98 100644
--- a/ChangeLog.TXT
+++ b/ChangeLog.TXT
@@ -1,3 +1,14 @@
+2026-05-26:
+I found a copy-paste error while testing my driver code on my main TOS machine
+(a Dell OptiPlex 755 Mini Tower). "2025 Me" seemingly forgot to change the DMA
+setup function in the multi-track write code. As a result, the DMA controller
+was being set up for reading instead of writing, causing the FDC to time out.
+
+I have also done some more line-breaking. Now, as far as I can tell, nearly
+every line of code has been broken down to 80 characters or less, save for a
+few long function calls. I have also done the same for ReadMe.TXT (I also did
+some rewording and correction while I was at it).
+
2026-05-24:
I updated the copyright statements to match those on the WTFPL FAQ, completed
the flags for the ST2 and ST3 in KFloppyA.HH, updating the copyright notice
diff --git a/KFloppy.HC b/KFloppy.HC
index cfebfed..14f892c 100644
--- a/KFloppy.HC
+++ b/KFloppy.HC
@@ -1,6 +1,6 @@
/*
New, (hopefully) Less Messy Floppy Driver
- Copyright (C) 2025 Harley Travis <yoshi128k@gmail.com>.
+ Copyright (C) 2026 Harley Travis <yoshi128k@gmail.com>.
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the Copying.TXT file for more details.
@@ -139,8 +139,9 @@ U0 FDCMotorOff(U16 base)
U0 FDCMotorPwrOffTimer()
{
- // You're supposed to run this function as a separate CTask. It will exit when the motor
- // exits the "wait" state (either because it has turned off or because something needs it to be on).
+ // You're supposed to run this function as a separate CTask. It will exit
+ // when the motor exits the "wait" state (either because it has turned off
+ // or because something needs it to be on).
// The driver only spawns this when the motor is moved from "on" to "wait".
while (fdc_mtr_state == FDC_MOTOR_WAIT) {
// Sanity check for if something wants the motor on at the last second
@@ -173,8 +174,10 @@ U0 FDCMotorCtrl(U16 base, Bool onoff)
}
fdc_mtr_ticks = 300; // 3 sec timeout before motor turns off
fdc_mtr_state = FDC_MOTOR_WAIT;
- // Only spawn the timer task of the motor is currently on; infinitely-looping tasks peg the CPU
- if (prev_mtr_state != FDC_MOTOR_WAIT) Spawn(&FDCMotorPwrOffTimer,,"FDCMotorPwrOffTimer");
+ // Only spawn the timer task of the motor is currently on.
+ // Infinitely-looping tasks peg the CPU!
+ if (prev_mtr_state != FDC_MOTOR_WAIT)
+ Spawn(&FDCMotorPwrOffTimer,,"FDCMotorPwrOffTimer");
}
}
@@ -242,7 +245,9 @@ I8 FDCReset(U16 base)
// Configure the FIFO
FDCSendCmd(base, FDC_CONFIGURE);
FDCSendCmd(base, 0x00); // 1st param is a 0
- FDCSendCmd(base, 0b01011011); // 2nd param: Implied seek on, FIFO on, Drive polling disabled, threshold = 12
+ // 2nd param:
+ // Implied seek on, FIFO on, Drive polling disabled, threshold = 12
+ FDCSendCmd(base, 0b01011011);
FDCSendCmd(base, 0x00); // 3rd param: write precomp = 0
// Lock the configuration
@@ -449,7 +454,7 @@ U0 FDCWriteMulti(U16 base, U8 cyl, U8 head, U8 sect, U8 trklen)
// Prepare the DMA controller
AdamLog("Preparing DMA\n");
FDCDMAInit(512*(trklen - sect + 1)*2);
- FDCDMAPrepRead();
+ FDCDMAPrepWrite();
FDCSendCmd(base, cmd);
FDCSendCmd(base, head << 2); // Drive 0, specified head
diff --git a/ReadMe.TXT b/ReadMe.TXT
index b67d7af..a4b7a26 100644
--- a/ReadMe.TXT
+++ b/ReadMe.TXT
@@ -1,4 +1,4 @@
-Copyright (C) 2025 Harley Travis <yoshi128k@gmail.com>.
+Copyright (C) 2026 Harley Travis <yoshi128k@gmail.com>.
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the Copying.TXT file for more details.
@@ -9,20 +9,23 @@ find it a bit beyond my capabilities.
To install the driver:
1. Copy KFloppy.HC, KFloppyA.HH, KFloppyB.HH, and KFloppyDMA.HC to ::/Kernel/
-2. In Kernel.PRJ(.Z), include KFloppyDMA.HC between KStart32 and KStart64; this adds a
-buffer for DMA transfers to/from the floppy disk controller (see notes)
-3. Then, include KFloppyA.HH and KFloppy.HC at the bottom of the above file.
-4. In ::/StartOS.HC, include KFLoppyB.HH after KernelC.HH; this exports the driver
-functions for use by your own programs.
+2. In Kernel.PRJ(.Z), include KFloppyDMA.HC between KStart32 and KStart64; this
+adds a buffer for DMA transfers to/from the floppy disk controller (see notes).
+Also include KFloppyA.HH and KFloppy.HC at the end of the #includes.
+4. In ::/StartOS.HC, include KFLoppyB.HH after KernelC.HH; this exports the
+driver functions for use by your own programs.
-On startup, you will have to unmask IRQ6 and point its int to the IRQ handler, FDCIrqHandler.
-To do this, write 0xB8 to port 0x21, then use IntEntrySet to set the vector for the aforementioned int (this may be included in the startup files).
+On startup, you will have to unmask IRQ6 and point its interrupt vector to my
+IRQ handler, FDCIrqHandler.
+To do this, write 0xB8 to port 0x21, then use IntEntrySet to set the vector for
+the aforementioned int (this may be included in the startup files).
In HolyC, that would be:
OutU8(0x21,0xB8); // Unmask IRQ6
IntEntrySet(0x26,&FDCIrqHandler); // IRQ mode is the default
-Use FDCReset to initialize the drive (make sure a disk is inserted; it does not test for one before doing things).
+Use FDCReset to initialize the drive (make sure a disk is inserted; it does not
+test for one before doing things).
FDCSeek does what it says.
@@ -31,20 +34,24 @@ FDCWrite/FDCWriteMulti will write data to the disk.
Data that has been read or is to be written goes in FDC_DMA.
(The FDC*Multi funs use multi-track mode; data will be read from both heads)
-The result of seeks, recalibrations, and data xfers will be displayed in the Adam Task.
+The result of seeks, recalibrations, and data xfers will be displayed in the
+Adam Task.
--A note about DMA--
-If things went to plan, I would have use PIO to do data transfers to and from the disk.
-However, they didn't, and my dev system would freeze when attempting to read from tracks
-beyond 0 (the drive would make a seek noise, at which point it froze).
+If things went to plan, I would have use PIO to do data transfers to and from
+the disk. However, they didn't, and my dev system would freeze when attempting
+to read from tracks beyond 0 (the drive would make a seek noise, at which point
+it froze).
In Terry's demands document, he wrote:
"We don't want to do DMA."
-This is a bit ambiguous, as there are two principle forms of DMA in the PC world:
+This is a bit ambiguous, as there are two main forms of DMA in the PC world:
1. ISA DMA, used by the floppy controller and ISA expansion cards.
-2. PCI Busmastering, which is used by modern hardware and is very different from ISA DMA.
+2. PCI Busmastering, which is used by newer hardware and is very different from
+ISA DMA.
-TheTinkerer on the TOS Discord suggested that Terry *may* have been fine ISA DMA, but I would still
-consider my usage of it to be at least a little blasphemous (though it is not mentioned in the Charter).
+TheTinkerer on the TOS Discord suggested that Terry *may* have been more
+tolerant of ISA DMA, but I would still consider my usage of it to be at least
+somewhat blasphemous (though it is not mentioned in the Charter).