diff options
| author | Harley Travis <harleytravis123@outlook.com> | 2026-06-27 14:45:52 -0500 |
|---|---|---|
| committer | Harley Travis <harleytravis123@outlook.com> | 2026-06-27 14:45:52 -0500 |
| commit | 5d9bd8a2de39f259ebed50ec55d723fbb3a0c7c9 (patch) | |
| tree | ee6d1f60eba5c2fc9c299fbd9318fc7bb25ff9cb /Kernel/BlkDev | |
| parent | 93ddde6d5ec9e66e488acf7e7529f1fb796417bd (diff) | |
| download | templeos-floppy-driver-5d9bd8a2de39f259ebed50ec55d723fbb3a0c7c9.tar.gz | |
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.
Diffstat (limited to 'Kernel/BlkDev')
| -rw-r--r-- | Kernel/BlkDev/DskFDC.HC | 17 |
1 files 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) |
