From owner-freebsd-hackers Mon Nov 3 09:41:41 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id JAA17499 for hackers-outgoing; Mon, 3 Nov 1997 09:41:41 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from piggy.mdstud.chalmers.se (root@piggy.mdstud.chalmers.se [129.16.234.10]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id JAA17493 for ; Mon, 3 Nov 1997 09:41:38 -0800 (PST) (envelope-from md6tommy@mdstud.chalmers.se) Received: from hallgren.se (ip181056.student.gu.se [130.241.181.56]) by piggy.mdstud.chalmers.se (8.8.5/8.8.5) with SMTP id SAA25038 for ; Mon, 3 Nov 1997 18:41:28 +0100 (MET) Message-ID: <345E0C80.41C67EA6@mdstud.chalmers.se> Date: Mon, 03 Nov 1997 18:40:16 +0100 From: Tommy Hallgren Organization: FreeBSD X-Mailer: Mozilla 3.01 (X11; I; FreeBSD 2.2.1-RELEASE i386) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: IDE util Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #include #include #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; }