Subject: kern/18792: Make kernel beep when system is completely halted
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: netbsd-bugs
Date: 10/24/2002 22:20:37
>Number:         18792
>Category:       kern
>Synopsis:       Make kernel beep when system is completely halted
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 24 13:17:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Julio Merino
>Release:        NetBSD 1.6J
>Organization:
HispaBSD
>Environment:
	
	
System: NetBSD darkstar.local 1.6J NetBSD 1.6J (DARKSTAR) #31: Thu Oct 24 13:23:40 CEST 2002 jmmv@darkstar.local:/var/build/kernel/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
	The following patch implements the "Beep on halt" feature. This has
	been discussed in tech-kern some days ago.

	In summary: this new feature makes the kernel issue several beeps
	when the system is completely halted, i.e., when the "The operating
	system has halted." message apperes after doing a "halt" or
	"shutdown -h now". This is useful in headless servers that do not
	have a serial console nor power management, so that you can safely
	issue a halt command from a remote machine and then, wait until you
	hear the beeps that will tell you that it is safe to power down the
	computer.

	In the discussion, most of the people suggested to use sysctl to tune	
	this feature, so I did the patch this way. Although, all details can
	also be configured during kernel's build time with some options, so
	that whoever does not like sysctl can get rid of it ;)

	Variables allow how many beeps you want on halt (0 means none), the
	frequency and the duration of each beep. Note that all these features
	can be completely enabled/disabled setting the BEEP_EVENTS option in
	the kernel (by default, disabled).

	The implementation... Most of the code is MI, so that any platform
	can easily take advantadge of defined sysctl variables and use them
	to issue the beeps. In fact, the MD code is in i386/machdep.c, which
	directly calls the sysbeep() function with the variables that "define"
	the beep. To implement this feature on more archs, you should just
	need to port that small bit of code to them. (I've only implemented
	i386).

	This feature is similar to what BLINK does in sparc machines, and
	many people seems to want it... IIRC, nobody really rejected it
	in the lists ;-)

	The attached patch contains two files: patch-kern.diff, which is the
	kernel patch, and patch-sysctl.diff which modifies sysctl. I have
	my doubts about the sysctl patch... maybe is a better way to do this
	same thing in this obscure program.
>How-To-Repeat:
	
>Fix:

begin 644 patches.tar.gz
M'XL(`)52N#T``^T::W/;1BY?J5^!2]I4MEZDWI+K3AQ)231U9-62>\WD,CJ*
M7$4\4R1+4DZ<C/_[`;M\2I23]AIW;H8[MD0M\5A@`2P`TE%];5VY9JY5U8W5
MZM&W&(HLMYM->`2@=%HR?8,B?M-0.@VY#M!IM=IR2U$Z"D[5&^W.(Y"_R6IV
MQM;S51?@T7\VFYO[X9CK/<2"'G:,+9U][(/J:NN:T>BV:YIMK6HO1Y/1Y7A0
M./W?1^%R,(.58;(^U+0;S[5MO^;=>IZKT5<MFW'YIN`RWS78C6&]!Q>_/,.V
M0*FVE%Z![!0J6_[G\BD(UUNI5,)KJ2[+]9HBUY0N**V^HN"?)`B42J4]J'H3
ME%Z_WNRWFH5GSZ#2;9?;4,)/I0'/GA7`=GQ<@0?2U6QT.;B8O)">`)D$K;K8
M/`)OZSBVZQ?@200Y'4]'B]G%X.?1?'HVOD0$;Z.:)G/+L-SZX)GV!^:"8SBL
M6#\J0*'T!)XSY@"[89;O0=%EOV\-EWF`>EK2#1WUH+&C*D)&3)Z/1M/%Z-?1
M9#Z3)&0QLM2ER6`9$R*Z\S6#E6TB1])GB*RZC&AKO@G^EN/MD[Z8O#H[GR\&
M%U>3^:E,'.;&!M?DVX('[LI:-?U#>-/Q?/#J5&G)''7(5NK6]&%%HC%+NX6B
M8<&K3T<Q>AH;M^AB>%IOI;#UK:L2+$?>>$SS$!\5'\K./CK,Q45:OFJBIE<K
MU#*RVZ*P/F*R][>H"Q>7[_MX!Q7L(%_#8IX'6_0&%XC6VGB_!MWPKF%<NP#3
M5O4J7'D,#!\^&/X:-'7+UU#!F1\\L&P?'-=&A0O-("N^EEOF5Y,V,1G]<_'\
MZL4OB]G\\FP^>OFFL.>`_&.C:FN=.57M05TPS?J@$S9[S5TGQ"F(UTQN&/U*
MNIC<Z3<;_3H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