summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Travis <harleytravis123@outlook.com>2026-06-06 19:35:22 -0500
committerHarley Travis <harleytravis123@outlook.com>2026-06-06 19:35:22 -0500
commit0898cca4b9eb3465bc4507508d352502f6e5781a (patch)
treeb57078fe4166f5518594217597724f0e54537f96
parent245b41456767fce8c72e0a9a66c957fce1d47b9e (diff)
downloadtempleos-floppy-driver-0898cca4b9eb3465bc4507508d352502f6e5781a.tar.gz
Update DskFDC.HC
I have added a function that will check for the presence of valid sector data on either side of a floppy disk. This function is used to check for the presence of a disk in a way that does not rely on the proper handling of the disk change flag.
-rw-r--r--Kernel/BlkDev/DskFDC.HC51
1 files changed, 47 insertions, 4 deletions
diff --git a/Kernel/BlkDev/DskFDC.HC b/Kernel/BlkDev/DskFDC.HC
index 5b5105d..e9b0bdd 100644
--- a/Kernel/BlkDev/DskFDC.HC
+++ b/Kernel/BlkDev/DskFDC.HC
@@ -195,12 +195,12 @@ Bool FDCInit(CBlkDev *bd)
recalibrate:
// Recalibrate this drive
- fdc_irq_semaphore=FALSE;
+ fdc_int_semaphore=FALSE;
FDCSendByte(bd,FDC_RECALIBRATE);
FDCSendByte(bd,bd->unit); // Drive number
// Wait for an IRQ
- while (!fdc_irq_semaphore) Yield;
+ while (!fdc_int_semaphore) Yield;
// Get the result of the recalibration
FDCSendByte(bd,FDC_SENSE_INTR);
@@ -224,7 +224,7 @@ U8 FDCWriteData(CBlkDev *bd,U8 cyl,Bool head,U8 start,U8 end)
U16 length=(end-start+1)*bd->blk_size;
U8 st0,st1,st2,pcn,hd,sect,size
- fdc_irq_semaphore=FALSE;
+ fdc_int_semaphore=FALSE;
FDCDMAInit(length);
FDCDMAPrepWrite();
@@ -256,7 +256,7 @@ U8 FDCReadData(CBlkDev *bd,U8 cyl,Bool head,U8 start,U8 end)
U16 length=(end-start+1)*bd->blk_size;
U8 st0,st1,st2,pcn,hd,sect,size
- fdc_irq_semaphore=FALSE;
+ fdc_int_semaphore=FALSE;
FDCDMAInit(length);
FDCDMAPrepRead();
@@ -369,4 +369,47 @@ U0 FDCWriteBlks(CBlkDev *bd,U8 *buf,I64 blk,I64 cnt)
retries-=1;
goto retry;
}
+}
+
+U8 FDCReadId(CBlkDev *bd,Bool hd)
+{
+ U8 st0,st1,st2,c,h,r,n;
+ fdc_int_semaphore=FALSE;
+
+ FDCSendByte(*bd,FDC_READ_ID|bd->mfm<<6);
+ FDCSendByte(*bd,bd->unit|hd<<2);
+
+ while (!fdc_int_semaphore) Yield;
+
+ st0=FDCReadByte(*bd);
+ st1=FDCReadByte(*bd);
+ st2=FDCReadByte(*bd);
+ c=FDCReadByte(*bd);
+ h=FDCReadByte(*bd);
+ r=FDCReadByte(*bd);
+ n=FDCReadByte(*bd);
+
+ return st0>>6;
+}
+
+U8 FDCChk(CBlkDev *bd)
+{
+ // Check if there is a disk of the selected density in the drive
+
+ Bool unlock=BlkDevLock(bd),h0,h1;
+
+ FDCSelDrv(bd);
+
+ h0=!FDCReadId(bd,0);
+ h1=!FDCReadId(bd,1);
+
+ if (h0) {
+ if (h1) {
+ return FDC_CHK_DS;
+ } else {
+ return FDC_CHK_SS;
+ }
+ } else {
+ return FDC_CHK_ERR;
+ }
} \ No newline at end of file