From 5d9bd8a2de39f259ebed50ec55d723fbb3a0c7c9 Mon Sep 17 00:00:00 2001 From: Harley Travis Date: Sat, 27 Jun 2026 14:45:52 -0500 Subject: Update FDCWriteBlks FDCWriteBlks was patched for the same reasons as FDCReadBlks (64-bit variables, motor control, fix typo in head calculation, unlock at end), as well as fixing a bug where only [cnt] bytes were being copied into the DMA buffer instead of [cnt] sectors. --- Kernel/BlkDev/DskFDC.HC | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Kernel/BlkDev/DskFDC.HC b/Kernel/BlkDev/DskFDC.HC index 73102c6..cf06939 100644 --- a/Kernel/BlkDev/DskFDC.HC +++ b/Kernel/BlkDev/DskFDC.HC @@ -387,21 +387,26 @@ U0 FDCWBlks(CDrv *dv,U8 *buf,I64 blk,I64 cnt) U0 FDCWriteBlks(CBlkDev *bd,U8 *buf,I64 blk,I64 cnt) { I64 retries=3; - U8 c,h,s,st0; + U64 c,h,s,st0; Bool unlock=BlkDevLock(bd); if (Bt(InU8(bd->base0+FDC_STAT_A),1)) throw('BlkDev'); + FDCMotor(bd,ON); + retry: - if (!retries) throw('BlkDev'); + if (!retries) { + FDCMotor(bd,OFF); + throw('BlkDev'); + } - MemCpy(&FDC_DMA,buf,cnt); + MemCpy(&FDC_DMA,buf,cnt*bd->blk_size); FDCSelDrv(bd); c=blk/(bd->heads*bd->spt); - h=blk/bd->spt%heads; + h=blk/bd->spt%bd->heads; s=blk%bd->spt+1; st0=FDCWriteData(bd,c,h,s,s+cnt-1); @@ -410,6 +415,10 @@ U0 FDCWriteBlks(CBlkDev *bd,U8 *buf,I64 blk,I64 cnt) retries-=1; goto retry; } + + FDCMotor(bd,OFF); + + if (unlock) BlkDevUnlock(bd); } U8 FDCReadId(CBlkDev *bd,Bool hd) -- cgit v1.2.3