10

Is there a register I can write to using a DOS based C app to spin the IDE HDD down after the app boots then back up upon the app close? Specifically I want to just put spin down/up commands in the C source code. Having to resort to C inline assembly language is OK for me.

For example I don't use any "canned" library functions to use the serial port. I write to the UART directly so I am fine with this level of deep system programming. (Comes from my STD and Multibuss days)

Reason is the app does not need HDD after boot and this is a kiosk type app. HDD is only needed to boot and for maintenance. I have tried CF and other flash disk products. This industrial PC board doesn't play well with them under DOS. It wants a real IDE HDD.

1
  • 1
    Sidetracking: do you have any idea whether you tried a Compact Flash card that supports UDMA and CHS addressing? I think both are potluck, and each affects whether some machines can boot from the card. I’m super uninformed on which subsets of IDE BIOSs tend to use, and which subsets have been commonly implemented by CF cards over time, but UDMA sounds like it wouldn’t be useful for USB bridging and CHS is obviously somewhat of a relic, so… (posted as a comment since it doesn’t answer your question at all, but luckily Vlad seems already to be on top of that)
    – Tommy
    Nov 7 '21 at 8:23
12

Sending ATA command "STANDBY IMMEDIATE" to the command register of the IDE drive should do the trick. I.e. output the value of 0xE0 to the command register port (0x1f7 for the primary IDE), provided you've checked that the drive isn't busy by reading status register.

The list of other commands can be found here: ATA Command Matrix

An introduction to accessing ATA/ATAPI devices: An introduction to programming with ATA and ATAPI

I remember writing a TSR to stop the HDD while leaving the PC to render some POVRay scenes. I was stopping the HDD by a hotkey. The drive would spin up again automatically with the next file operation initiated by the main application, no other manipulations was required.

1
  • 5
    There is also a command that tells the disk to spin down after a determined time with no other operations, so you don't have to care for.
    – fraxinus
    Nov 7 '21 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.