Date: Mon, 03 Nov 1997 18:40:16 +0100 From: Tommy Hallgren <md6tommy@mdstud.chalmers.se> To: freebsd-hackers@freebsd.org Subject: IDE util Message-ID: <345E0C80.41C67EA6@mdstud.chalmers.se>
next in thread | raw e-mail | index | archive | help
Hi!
I've made a small utility so one can set the spindown times on IDE
drives. Works great for me. I hope this helps those who wishes to keep
the drives quiet. I start it in autoexec.bat. I guess most people have
this functionality in their BIOS's. Well, my old computer don't have it.
:-/
Please take a look at the source, maybe I'm doing something wrong, I'm
not an expert coding IDE hardware.
regards, Tommy Hallgren(md6tommy@mdstud.chalmers.se)
/*
* Program to set IDE drive spindown times. Made in November 1997 by
Tommy
* Hallgren(md6tommy@mdstud.chalmers.se)
*
* Please note that the drive spins down immediately when this program
is run.
*
* Do whatever you feel like with this sourcecode.
*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include "wdreg.h" /* /sys/i386/isa/wdreg.h */
#define WDCC_STANDBY_APD 0xe2
void
wdwait(int base)
{
unsigned char status;
status = inp(base + wd_status);
while ((status & WDCS_BUSY) != 0)
status = inp(base + wd_status);
}
void
wdsetsleep(int base, int drive, int mins)
{
wdwait(base);
printf("Setting sleep delay... ");
outp(base + wd_seccnt, mins * 60 / 5);
outp(base + wd_sdh, (drive & 1) << 4);
outp(base + wd_command, WDCC_STANDBY_APD);
wdwait(base);
puts("ok");
}
int
main(int argc, char *argv[])
{
int base, drive, mins;
if (argc != 4) {
printf("Usage: %s base drive minutes", argv[0]);
puts(" base: Portbase. 0x1f0 primary, 0x170 secondary.");
puts("drive: 0 or 1.");
puts(" mins: delay in minutes.");
return (1);
}
sscanf(argv[1], "%x", &base);
sscanf(argv[2], "%d", &drive);
sscanf(argv[3], "%d", &mins);
wdsetsleep(base, drive, mins);
return 0;
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?345E0C80.41C67EA6>
