Bug 19273

Summary: Syscons has no key for halting the machine.
Product: Base System Reporter: dwmalone <dwmalone>
Component: kernAssignee: dwmalone
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.4-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description dwmalone 2000-06-14 21:00:01 UTC
The version of syscons in 4.X and 5.X provides a selection of keys
for triggering a reboot, a panic, break to the debugger, activate
the screen saver and suspend a machine using APM. However there is
no way to halt a machine, which is useful in these days of having
to hold the power button in for 10 seconds before the machine goes
off.

Fix: The following patch seems to work fine and just copies the way the
control-alt-del action works. I couldn't test the pc98 bit, but it
should be simple enough not to cause any prbolems.
How-To-Repeat: 
N/A
Comment 1 dwmalone 2000-07-10 10:48:05 UTC
Here is another version of the halt patch which defines a powerdown
action for syscons, aswell as the halt action in the old patch.

	David.

Index: src/sys/kern/kern_shutdown.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/kern/kern_shutdown.c,v
retrieving revision 1.76
diff -u -r1.76 kern_shutdown.c
--- src/sys/kern/kern_shutdown.c	2000/07/04 11:25:22	1.76
+++ src/sys/kern/kern_shutdown.c	2000/07/10 07:43:56
@@ -162,6 +162,30 @@
 	}
 	return;
 }
+void
+halt_nice()
+{
+	/* Send a signal to init(8) and have it shutdown the world */
+	if (initproc != NULL) {
+		psignal(initproc, SIGUSR1);
+	} else {
+		/* No init(8) running, so simply halt */
+		boot(RB_NOSYNC|RB_HALT);
+	}
+	return;
+}
+void
+pdwn_nice()
+{
+	/* Send a signal to init(8) and have it shutdown the world */
+	if (initproc != NULL) {
+		psignal(initproc, SIGUSR2);
+	} else {
+		/* No init(8) running, so simply halt and poweroff */
+		boot(RB_NOSYNC|RB_HALT|RB_POWEROFF);
+	}
+	return;
+}
 static int	waittime = -1;
 static struct pcb dumppcb;
 
Index: src/sys/pc98/pc98/syscons.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/pc98/pc98/syscons.c,v
retrieving revision 1.147
diff -u -r1.147 syscons.c
--- src/sys/pc98/pc98/syscons.c	2000/06/25 09:55:12	1.147
+++ src/sys/pc98/pc98/syscons.c	2000/07/10 07:45:08
@@ -3117,6 +3117,18 @@
 #endif
 		break;
 
+	    case HALT:
+#ifndef SC_DISABLE_REBOOT
+		halt_nice();
+#endif
+		break;
+
+	    case PDWN:
+#ifndef SC_DISABLE_REBOOT
+		pdwn_nice();
+#endif
+		break;
+
 #if NAPM > 0
 	    case SUSP:
 		apm_suspend(PMST_SUSPEND);
Index: src/sys/sys/kbio.h
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/sys/kbio.h,v
retrieving revision 1.5
diff -u -r1.5 kbio.h
--- src/sys/sys/kbio.h	1999/12/29 04:24:43	1.5
+++ src/sys/sys/kbio.h	2000/07/10 07:45:45
@@ -171,6 +171,8 @@
 #define RCTRA		0x9e		/* right ctrl key / alt lock	*/
 #define LALTA		0x9f		/* left alt key / alt lock	*/
 #define RALTA		0xa0		/* right alt key / alt lock	*/
+#define HALT		0xa1		/* halt machine */
+#define PDWN		0xa2		/* halt machine and power down */
 
 #define F(x)		((x)+F_FN-1)
 #define	S(x)		((x)+F_SCR-1)
Index: src/sys/sys/systm.h
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/sys/systm.h,v
retrieving revision 1.116
diff -u -r1.116 systm.h
--- src/sys/sys/systm.h	2000/06/05 18:30:55	1.116
+++ src/sys/sys/systm.h	2000/07/10 07:46:17
@@ -185,6 +185,8 @@
 
 /* Finalize the world. */
 void	shutdown_nice __P((void));
+void	halt_nice __P((void));
+void	pdwn_nice __P((void));
 
 /*
  * Kernel to clock driver interface.
Index: src/usr.sbin/kbdcontrol/kbdcontrol.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/kbdcontrol/kbdcontrol.c,v
retrieving revision 1.30
diff -u -r1.30 kbdcontrol.c
--- src/usr.sbin/kbdcontrol/kbdcontrol.c	1999/12/10 04:24:26	1.30
+++ src/usr.sbin/kbdcontrol/kbdcontrol.c	2000/07/10 07:47:56
@@ -197,6 +197,10 @@
 		return LALTA | 0x100;
 	case TRALTA:
 		return RALTA | 0x100;
+	case THALT:
+		return HALT | 0x100;
+	case TPDWN:
+		return PDWN | 0x100;
 	case TACC:
 		if (ACC(number) > L_ACC)
 			return -1;
@@ -428,6 +432,12 @@
 	case RALTA | 0x100:
 		fprintf(fp, " ralta ");
 		break;
+	case HALT | 0x100:
+		fprintf(fp, " halt  ");
+		break;
+	case PDWN | 0x100:
+		fprintf(fp, " pdwn  ");
+		break;
 	default:
 		if (value & 0x100) {
 		 	if (val >= F_FN && val <= L_FN)
@@ -620,6 +630,12 @@
 			break;
 		case RALTA:
 			printf("RALTA, ");
+			break;
+		case HALT:
+			printf(" HALT, ");
+			break;
+		case PDWN:
+			printf(" PDWN, ");
 			break;
 		default:
 	 		if (value >= F_FN && value <= L_FN)
Index: src/usr.sbin/kbdcontrol/lex.h
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/kbdcontrol/lex.h,v
retrieving revision 1.9
diff -u -r1.9 lex.h
--- src/usr.sbin/kbdcontrol/lex.h	1999/12/10 04:24:27	1.9
+++ src/usr.sbin/kbdcontrol/lex.h	2000/07/10 07:48:39
@@ -61,6 +61,8 @@
 #define TRCTRA		286
 #define TLALTA		287
 #define TRALTA		288
+#define THALT		289
+#define TPDWN		290
 
 extern int number;
 extern char letter;
Index: src/usr.sbin/kbdcontrol/lex.l
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/kbdcontrol/lex.l,v
retrieving revision 1.11
diff -u -r1.11 lex.l
--- src/usr.sbin/kbdcontrol/lex.l	1999/12/10 04:24:27	1.11
+++ src/usr.sbin/kbdcontrol/lex.l	2000/07/10 07:49:01
@@ -68,6 +68,8 @@
 rctrla		{ return TRCTRA; }
 lalta|alta	{ return TLALTA; }
 ralta		{ return TRALTA; }
+halt		{ return THALT; }
+pdwn		{ return TPDWN; }
 
 NUL|nul		{ number = 0; return TNUM; }
 SOH|soh		{ number = 1; return TNUM; }
Index: src/sys/dev/kbd/kbd.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/dev/kbd/kbd.c,v
retrieving revision 1.19
diff -u -r1.19 kbd.c
--- src/sys/dev/kbd/kbd.c	2000/05/26 02:03:00	1.19
+++ src/sys/dev/kbd/kbd.c	2000/07/10 07:39:23
@@ -1144,6 +1144,7 @@
 			/* NON-LOCKING KEYS */
 			case SPSC: case RBT:  case SUSP: case STBY:
 			case DBG:  case NEXT: case PREV: case PNC:
+			case HALT: case PDWN:
 				*accents = 0;
 				break;
 			case BTAB:
Index: src/sys/dev/syscons/syscons.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/dev/syscons/syscons.c,v
retrieving revision 1.342
diff -u -r1.342 syscons.c
--- src/sys/dev/syscons/syscons.c	2000/06/25 09:55:07	1.342
+++ src/sys/dev/syscons/syscons.c	2000/07/10 07:40:23
@@ -3098,6 +3098,19 @@
 #endif
 		break;
 
+	    case HALT:
+#ifndef SC_DISABLE_REBOOT
+		halt_nice();
+#endif
+		break;
+		
+	    case PDWN:
+#ifndef SC_DISABLE_REBOOT
+		pdwn_nice();
+#endif
+		break;
+		
+		
 #if NAPM > 0
 	    case SUSP:
 		apm_suspend(PMST_SUSPEND);
Comment 2 dwmalone freebsd_committer freebsd_triage 2000-07-11 12:25:07 UTC
Responsible Changed
From-To: freebsd-bugs->dwmalone

My PR.
Comment 3 dwmalone freebsd_committer freebsd_triage 2000-10-30 11:22:34 UTC
State Changed
From-To: open->closed

A version of this code in now in -current and -stable.