From owner-freebsd-hackers Thu May 25 20:54:37 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from rm-rstar.sfu.ca (rm-rstar.sfu.ca [142.58.120.21]) by hub.freebsd.org (Postfix) with ESMTP id 1992F37B9C8 for ; Thu, 25 May 2000 20:54:23 -0700 (PDT) (envelope-from vanepp@sfu.ca) Received: from fraser.sfu.ca (vanepp@fraser.sfu.ca [142.58.101.25]) by rm-rstar.sfu.ca (8.10.1/8.10.1/SFU-5.0H) with ESMTP id e4Q3sJt22536 for ; Thu, 25 May 2000 20:54:20 -0700 (PDT) From: Peter Van Epp Received: (from vanepp@localhost) by fraser.sfu.ca (8.9.2/8.9.2/SFU-5.0C) id UAA19087 for hackers@freebsd.org; Thu, 25 May 2000 20:54:19 -0700 (PDT) Message-Id: <200005260354.UAA19087@fraser.sfu.ca> Subject: The proper way to get a beep out of the kernel after a halt? To: hackers@freebsd.org Date: Thu, 25 May 2000 20:54:19 -0700 (PDT) X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Because I'm running a couple of boxes headless, I have modified kern_shutdown.c to halt (rather than boot) on alt-ctl-delete and once the shutdown is complete beep three times via the speaker to indicate (in the absence of a tube) that it is now OK for the person to power down. Currently (out of ignorance) I am doing this ugly kludge to get beeps. I expect there is a proper way to get a beep from code in the kernel (although printf isn't it, the kernel version of printf don't seem to do no beeps!). Would some kind person enlighten me please? If there is interest (or even someone willing to add the change even if you don't see a need for it) I'll set this up as a kernel option (probably HEADLESS) which changes the SIGINT to SIGUSR1 in the signal to init to change the reboot to a halt and set the beep stuff up properly (which I expect isn't fiddling the bits directly althought this seems to work just fine which is all I currently care about) since I expect there are other folks running production machines headless (or more correctly tubeless) who would like the functionality too. While I'm here I should check that I am correct and that alt-cntl-delete is the only thing that calls shutdown_nice() as it appears to me? void shutdown_nice() { /* Send a signal to init(8) and have it shutdown the world */ if (initproc != NULL) { /* halt instead of reboot! */ psignal(initproc, SIGUSR1); ... static void shutdown_halt(void *junk, int howto) { /* + needs to go! */ #define TIMER_FREQ 1193182 u_int timer_freq = TIMER_FREQ; unsigned int divisor; /* - needs to go */ if (howto & RB_HALT) { printf("\n"); printf("The operating system has halted.\n"); printf("Please press any key to reboot.\n\n"); /* + needs to go */ /* set up timer2 for a 1 khz tone */ divisor = timer_freq / 1000; outb(TIMER_MODE, TIMER_SEL2 | ((TIMER_SQWAVE | TIMER_16BIT) & 0x 3f)); outb(TIMER_CNTR2, (divisor & 0xff)); /* send lo byte */ outb(TIMER_CNTR2, (divisor >> 8)); /* send hi byte */ /* turn the speaker on and off three times */ outb(IO_PPI, inb(IO_PPI) | PPI_SPKR); DELAY(1000 * 200); /* 2/10th second */ outb(IO_PPI, inb(IO_PPI) & ~PPI_SPKR); DELAY(1000 * 200); /* 2/10th second */ outb(IO_PPI, inb(IO_PPI) | PPI_SPKR); DELAY(1000 * 200); /* 2/10th second */ outb(IO_PPI, inb(IO_PPI) & ~PPI_SPKR); DELAY(1000 * 200); /* 2/10th second */ outb(IO_PPI, inb(IO_PPI) | PPI_SPKR); DELAY(1000 * 200); /* 2/10th second */ outb(IO_PPI, inb(IO_PPI) & ~PPI_SPKR); /* - needs to go */ switch (cngetc()) { case -1: /* No console, just die */ cpu_halt(); /* NOTREACHED */ default: Peter Van Epp / Operations and Technical Support Simon Fraser University, Burnaby, B.C. Canada To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message