Make the amd64 post-halt-press-a-key code match i386, and introduce into both a message for the case where cngetc() doesn't work. If there's no console attached, this won't accomplish anything; but if there's a screen but no keyboard, or the keyboard's wedged, or whatever, it might provide useful information. Suggested back in 2009 by some stuff in PR 37924 and has been hanging about in one of my trees ever since.diff -r1.200 -r1.201 src/sys/arch/amd64/amd64/machdep.c
(dholland)
--- src/sys/arch/amd64/amd64/machdep.c 2013/12/01 01:05:16 1.200
+++ src/sys/arch/amd64/amd64/machdep.c 2014/01/09 00:57:25 1.201
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.c,v 1.200 2013/12/01 01:05:16 christos Exp $ */ | 1 | /* $NetBSD: machdep.c,v 1.201 2014/01/09 00:57:25 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 | 4 | * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 | |
5 | * The NetBSD Foundation, Inc. | 5 | * The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | 9 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | |
10 | * Simulation Facility, NASA Ames Research Center. | 10 | * Simulation Facility, NASA Ames Research Center. | |
11 | * | 11 | * | |
12 | * This code is derived from software contributed to The NetBSD Foundation | 12 | * This code is derived from software contributed to The NetBSD Foundation | |
13 | * by Coyote Point Systems, Inc. which was written under contract to Coyote | 13 | * by Coyote Point Systems, Inc. which was written under contract to Coyote | |
14 | * Point by Jed Davis and Devon O'Dell. | 14 | * Point by Jed Davis and Devon O'Dell. | |
@@ -101,27 +101,27 @@ | @@ -101,27 +101,27 @@ | |||
101 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 101 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
102 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 102 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
103 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 103 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
104 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 104 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
105 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 105 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
106 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 106 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
107 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 107 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
108 | * SUCH DAMAGE. | 108 | * SUCH DAMAGE. | |
109 | * | 109 | * | |
110 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 | 110 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 | |
111 | */ | 111 | */ | |
112 | 112 | |||
113 | #include <sys/cdefs.h> | 113 | #include <sys/cdefs.h> | |
114 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.200 2013/12/01 01:05:16 christos Exp $"); | 114 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.201 2014/01/09 00:57:25 dholland Exp $"); | |
115 | 115 | |||
116 | /* #define XENDEBUG_LOW */ | 116 | /* #define XENDEBUG_LOW */ | |
117 | 117 | |||
118 | #include "opt_modular.h" | 118 | #include "opt_modular.h" | |
119 | #include "opt_user_ldt.h" | 119 | #include "opt_user_ldt.h" | |
120 | #include "opt_ddb.h" | 120 | #include "opt_ddb.h" | |
121 | #include "opt_kgdb.h" | 121 | #include "opt_kgdb.h" | |
122 | #include "opt_cpureset_delay.h" | 122 | #include "opt_cpureset_delay.h" | |
123 | #include "opt_mtrr.h" | 123 | #include "opt_mtrr.h" | |
124 | #include "opt_realmem.h" | 124 | #include "opt_realmem.h" | |
125 | #include "opt_xen.h" | 125 | #include "opt_xen.h" | |
126 | #ifndef XEN | 126 | #ifndef XEN | |
127 | #include "opt_physmem.h" | 127 | #include "opt_physmem.h" | |
@@ -718,27 +718,33 @@ haltsys: | @@ -718,27 +718,33 @@ haltsys: | |||
718 | } | 718 | } | |
719 | 719 | |||
720 | cpu_broadcast_halt(); | 720 | cpu_broadcast_halt(); | |
721 | 721 | |||
722 | if (howto & RB_HALT) { | 722 | if (howto & RB_HALT) { | |
723 | #if NACPICA > 0 | 723 | #if NACPICA > 0 | |
724 | acpi_disable(); | 724 | acpi_disable(); | |
725 | #endif | 725 | #endif | |
726 | 726 | |||
727 | printf("\n"); | 727 | printf("\n"); | |
728 | printf("The operating system has halted.\n"); | 728 | printf("The operating system has halted.\n"); | |
729 | printf("Please press any key to reboot.\n\n"); | 729 | printf("Please press any key to reboot.\n\n"); | |
730 | cnpollc(1); /* for proper keyboard command handling */ | 730 | cnpollc(1); /* for proper keyboard command handling */ | |
731 | cngetc(); | 731 | if (cngetc() == 0) { | |
732 | /* no console attached, so just hlt */ | |||
733 | printf("No keyboard - cannot reboot after all.\n"); | |||
734 | for(;;) { | |||
735 | x86_hlt(); | |||
736 | } | |||
737 | } | |||
732 | cnpollc(0); | 738 | cnpollc(0); | |
733 | } | 739 | } | |
734 | 740 | |||
735 | printf("rebooting...\n"); | 741 | printf("rebooting...\n"); | |
736 | if (cpureset_delay > 0) | 742 | if (cpureset_delay > 0) | |
737 | delay(cpureset_delay * 1000); | 743 | delay(cpureset_delay * 1000); | |
738 | cpu_reset(); | 744 | cpu_reset(); | |
739 | for(;;) ; | 745 | for(;;) ; | |
740 | /*NOTREACHED*/ | 746 | /*NOTREACHED*/ | |
741 | } | 747 | } | |
742 | 748 | |||
743 | /* | 749 | /* | |
744 | * XXXfvdl share dumpcode. | 750 | * XXXfvdl share dumpcode. |
--- src/sys/arch/i386/i386/machdep.c 2013/12/08 20:45:30 1.740
+++ src/sys/arch/i386/i386/machdep.c 2014/01/09 00:57:25 1.741
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.c,v 1.740 2013/12/08 20:45:30 dsl Exp $ */ | 1 | /* $NetBSD: machdep.c,v 1.741 2014/01/09 00:57:25 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009 | 4 | * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009 | |
5 | * The NetBSD Foundation, Inc. | 5 | * The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Charles M. Hannum, by Jason R. Thorpe of the Numerical Aerospace | 9 | * by Charles M. Hannum, by Jason R. Thorpe of the Numerical Aerospace | |
10 | * Simulation Facility NASA Ames Research Center, by Julio M. Merino Vidal, | 10 | * Simulation Facility NASA Ames Research Center, by Julio M. Merino Vidal, | |
11 | * and by Andrew Doran. | 11 | * and by Andrew Doran. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -57,27 +57,27 @@ | @@ -57,27 +57,27 @@ | |||
57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | * SUCH DAMAGE. | 64 | * SUCH DAMAGE. | |
65 | * | 65 | * | |
66 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 | 66 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 | |
67 | */ | 67 | */ | |
68 | 68 | |||
69 | #include <sys/cdefs.h> | 69 | #include <sys/cdefs.h> | |
70 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.740 2013/12/08 20:45:30 dsl Exp $"); | 70 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.741 2014/01/09 00:57:25 dholland Exp $"); | |
71 | 71 | |||
72 | #include "opt_beep.h" | 72 | #include "opt_beep.h" | |
73 | #include "opt_compat_ibcs2.h" | 73 | #include "opt_compat_ibcs2.h" | |
74 | #include "opt_compat_freebsd.h" | 74 | #include "opt_compat_freebsd.h" | |
75 | #include "opt_compat_netbsd.h" | 75 | #include "opt_compat_netbsd.h" | |
76 | #include "opt_compat_svr4.h" | 76 | #include "opt_compat_svr4.h" | |
77 | #include "opt_cpureset_delay.h" | 77 | #include "opt_cpureset_delay.h" | |
78 | #include "opt_ddb.h" | 78 | #include "opt_ddb.h" | |
79 | #include "opt_ipkdb.h" | 79 | #include "opt_ipkdb.h" | |
80 | #include "opt_kgdb.h" | 80 | #include "opt_kgdb.h" | |
81 | #include "opt_mtrr.h" | 81 | #include "opt_mtrr.h" | |
82 | #include "opt_modular.h" | 82 | #include "opt_modular.h" | |
83 | #include "opt_multiboot.h" | 83 | #include "opt_multiboot.h" | |
@@ -832,26 +832,27 @@ haltsys: | @@ -832,26 +832,27 @@ haltsys: | |||
832 | for (c = BEEP_ONHALT_COUNT; c > 0; c--) { | 832 | for (c = BEEP_ONHALT_COUNT; c > 0; c--) { | |
833 | sysbeep(BEEP_ONHALT_PITCH, | 833 | sysbeep(BEEP_ONHALT_PITCH, | |
834 | BEEP_ONHALT_PERIOD * hz / 1000); | 834 | BEEP_ONHALT_PERIOD * hz / 1000); | |
835 | delay(BEEP_ONHALT_PERIOD * 1000); | 835 | delay(BEEP_ONHALT_PERIOD * 1000); | |
836 | sysbeep(0, BEEP_ONHALT_PERIOD * hz / 1000); | 836 | sysbeep(0, BEEP_ONHALT_PERIOD * hz / 1000); | |
837 | delay(BEEP_ONHALT_PERIOD * 1000); | 837 | delay(BEEP_ONHALT_PERIOD * 1000); | |
838 | } | 838 | } | |
839 | } | 839 | } | |
840 | #endif | 840 | #endif | |
841 | 841 | |||
842 | cnpollc(1); /* for proper keyboard command handling */ | 842 | cnpollc(1); /* for proper keyboard command handling */ | |
843 | if (cngetc() == 0) { | 843 | if (cngetc() == 0) { | |
844 | /* no console attached, so just hlt */ | 844 | /* no console attached, so just hlt */ | |
845 | printf("No keyboard - cannot reboot after all.\n"); | |||
845 | for(;;) { | 846 | for(;;) { | |
846 | x86_hlt(); | 847 | x86_hlt(); | |
847 | } | 848 | } | |
848 | } | 849 | } | |
849 | cnpollc(0); | 850 | cnpollc(0); | |
850 | } | 851 | } | |
851 | 852 | |||
852 | printf("rebooting...\n"); | 853 | printf("rebooting...\n"); | |
853 | if (cpureset_delay > 0) | 854 | if (cpureset_delay > 0) | |
854 | delay(cpureset_delay * 1000); | 855 | delay(cpureset_delay * 1000); | |
855 | cpu_reset(); | 856 | cpu_reset(); | |
856 | for(;;) ; | 857 | for(;;) ; | |
857 | /*NOTREACHED*/ | 858 | /*NOTREACHED*/ |