summaryrefslogtreecommitdiff
path: root/Kernel/BlkDev
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/BlkDev')
-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