Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
bencollver

Homepage

23.02.2026, 05:50
 

disable IDE write cache (Miscellaneous)

The Linux hdparm(1) command has an option to disable the on-disk IDE write cache.

-W     Get/set the IDE/SATA drive´s write-caching feature.

https://www.man7.org/linux/man-pages/man8/hdparm.8.html

Does DOS have a way to accomplish the same thing?

Note that i mean the onboard cache built-in to the disk (ATA-1 and above), not OS-level caches such as LBACACHE.

Japheth

Homepage

Germany (South),
23.02.2026, 13:40

@ bencollver

disable IDE write cache

> The Linux hdparm(1) command has an option to disable the on-disk IDE write
> cache.
>
> Does DOS have a way to accomplish the same thing?

You can always talk to the device directly.

There's the ATA/ATAPI "Set Features" command (0xEF):


General feature set
− Mandatory for all devices.
− Set transfer mode subcommand is mandatory.
− Enable/disable write cache subcommands are mandatory when a write cache is implemented.
− Enable/Disable Media Status Notification sub commands are mandatory if the Removable
Media feature set is implemented.
− All other subcommands are optional.



02h Enable write cache
82h Disable write cache


I got this from document "d1153r18-ATA-ATAPI-4.pdf"

---
MS-DOS forever!

bencollver

Homepage

23.02.2026, 17:09

@ Japheth

disable IDE write cache

> You can always talk to the device directly.

Challenge accepted.

hwinfo16.exe reports whether the write cache is disabled or enabled.

https://www.hwinfo.com/files/HWINF623.ZIP

In a system with only one disk and no CD-ROM:

C:\>debug.com
-a 100
1674:0100 mov dx,1f1
1674:0103 mov al,82
1674:0105 out dx,al
1674:0106 mov dx,1f7
1674:0109 mov al,ef
1674:010B out dx,al
1674:010C in al,dx
1674:010D mov ah,4c
1674:010F int 21
1674:0111
-g =100

Program terminated normally (00C0)
-q


After running that, hwinfo16.exe reports that the write cache is disabled.

For a different IDE bus, the ports would need to be adjusted. To select a drive, the Drive / Head register would need to be set before issuing the Set Feature command, and then the status would need to be read 15 times to clear the status and delay 400 ns. It's so simple! (not)

Helpful links:

https://web.archive.org/web/20250820020434/https://wiki.osdev.org/ATA_PIO_Mode

https://en.wikibooks.org/wiki/First_steps_towards_system_programming_under_MS-DOS_7/Debugger%27s_assembler_commands

RayeR

Homepage

CZ,
23.02.2026, 17:58

@ bencollver

disable IDE write cache

There are some low-level DOS HDD tools like Hitachi HDF tool that can enable/disable cache. On most HDD I saw the write cache was disabled by default (let OS to enable it). I'm not sure if the setting is persistent or it will return back to default after drive reset/power cycle...

---
DOS gives me freedom to unlimited HW access.

bencollver

Homepage

23.02.2026, 18:44

@ RayeR

disable IDE write cache

> There are some low-level DOS HDD tools like Hitachi HDF tool that can
> enable/disable cache. On most HDD I saw the write cache was disabled by
> default (let OS to enable it). I'm not sure if the setting is persistent or
> it will return back to default after drive reset/power cycle...

Thanks, i will look for the Hitachi HDF tool.

NetBSD's dkctl(8) manual implies that it can persist on some but not all drives.

     setcache none | r | w | rw [save]
...

                               save    If specified, and the cache enables are
                                       savable, saves the cache enables in the
                                       disk's non-volatile parameter storage.


https://man.netbsd.org/dkctl.8

bencollver

Homepage

21.06.2026, 02:10

@ bencollver

disable IDE write cache

> Thanks, i will look for the Hitachi HDF tool.

I wasn't able to locate the Hitachi HDF tool.

I booted SvarDOS on a desktop PC with a Samsung SV-1363D (ATA-4) IDE disk.

`hwinfo16` reported that the IDE disk write cache was enabled

booted BasLinux from floppy
https://distro.ibiblio.org/baslinux/

copied hdparm from Slackware
ftp://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/slackware-4.0/slakware/a3/bin.tgz

ran:

`hdparm -W 0 /dev/hda` to disable the write cache
`hdparm -K 1 /dev/hda` to keep features across reboot
`hdparm -k 1 /dev/hda` to keep settings across reboot
`hdparm -W 0 /dev/hda` to disable the write cache, just to be thorough

shut down, then booted DOS again.

`hwinfo16` reported that the IDE disk write cache was still enabled

I guess either hdparm silently failed or this disk can't persist that setting.

My debug.com script didn't disable it either. The status indicated that the drive was busy.

I tried the following debug.com listing to select drive number 0 prior to disabling the write cache. The 15 IN instructions are supposed to clear the status and delay 400 ns. This didn't help either.

mov dx,1f6
mov al,50
out dx,al
mov dx,1f1
mov al,82
out dx,al
mov dx,1f7
mov al,ef
out dx,al
in al,dx
push ax
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
in al,dx
pop ax
mov ah,4c
int 21


Notes:

Drive/Head Bitfield: 50h -- 01010000 (
    0 -- Unused 0,
    1 -- Always set 1,
    0 -- Use CHS not LBA,
    1 -- Always set
    0 -- DRV 0,
  000 -- CHS
)

ATA Command:    EFh -- SET FEATURES
ATA Subcommand: 82h -- DISABLE WRITE CACHE

ATA Register:   (1F0h + 1): WRITE -- Features
ATA Register:   (1F0h + 6): WRITE -- Drive / Head
ATA Register:   (1F0h + 7): WRITE -- Command
ATA Register:   (1F0h + 7): READ  -- Status

rr

Homepage E-mail

Berlin, Germany,
21.06.2026, 10:33

@ bencollver

disable IDE write cache

> > Thanks, i will look for the Hitachi HDF tool.
>
> I wasn't able to locate the Hitachi HDF tool.

https://hddguru.com/software/2006.01.20-Hitachi-Drive-Feature-Tool/

---
Forum admin

bencollver

Homepage

21.06.2026, 20:02

@ rr

disable IDE write cache

> > > Thanks, i will look for the Hitachi HDF tool.
> >
> > I wasn't able to locate the Hitachi HDF tool.
>
> https://hddguru.com/software/2006.01.20-Hitachi-Drive-Feature-Tool/

Thanks!

Like `hdparm` in BasLinux, the Hitachi disk FTOOL.EXE reports that it disabled the write cache, but then shows that the write cache is still enabled. I tried using both the CLI and TUI and got the same results. I didn't reboot.

Now i guess this disk simply doesn't support disabling the write cache.

Joke's on me. :-P

Back to the board
Thread view  Mix view  Order
23449 Postings in 2213 Threads, 407 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum