The machdep.kbdreset sysctl currently serves two functions: On amd64
and i386 it enables a shutdown by Ctrl-Alt-Del.  On various other
archs, it enables a shutdown by pressing the soft power button.
There is currently no way to disable a shutdown by ACPI power button
on amd64 and i386.

The diff below
* adds a MI sysctl hw.allowpowerdown; if set to 1 (the default) it
  allows a power button shutdown;
* makes acpi(4)/acpibtn(4) honor hw.allowpowerdown;
* switches the various power button intercepts on landisk, sgi, sparc64
  and zaurus over to hw.allowpowerdown;
* garbage collects the machdep.kbdreset sysctl on all archs other than
  amd64 and i386;
* includes all the corresponding man page and /etc bits.

I have only tested this on amd64 and sparc64.

Note: You also need to make includes and rebuild /sbin/sysctl to
access hw.allowpowerdown.


Index: etc/etc.landisk/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.landisk/sysctl.conf,v
retrieving revision 1.3
diff -u -p -r1.3 sysctl.conf
--- etc/etc.landisk/sysctl.conf 29 Apr 2007 17:53:34 -0000      1.3
+++ etc/etc.landisk/sysctl.conf 10 Jun 2011 21:47:18 -0000
@@ -1,2 +1 @@
-#machdep.kbdreset=1            # permit console to do a nice halt
 #machdep.led_blink=1           # blink the power led
Index: etc/etc.loongson/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.loongson/sysctl.conf,v
retrieving revision 1.1
diff -u -p -r1.1 sysctl.conf
--- etc/etc.loongson/sysctl.conf        23 Jan 2010 19:26:45 -0000      1.1
+++ etc/etc.loongson/sysctl.conf        10 Jun 2011 21:47:23 -0000
@@ -1 +0,0 @@
-#machdep.kbdreset=1            # 1=Enable power button shutdown
Index: etc/etc.palm/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.palm/sysctl.conf,v
retrieving revision 1.1
diff -u -p -r1.1 sysctl.conf
--- etc/etc.palm/sysctl.conf    5 Sep 2009 02:19:09 -0000       1.1
+++ etc/etc.palm/sysctl.conf    10 Jun 2011 21:47:26 -0000
@@ -1,4 +1,3 @@
-#machdep.kbdreset=1            # permit zkbd(4) power key to do a nice halt
 #machdep.maxspeed=520          # set change maximum processor speed
 #machdep.lidsuspend=1          # closing the lid will suspend machine
 #hw.setperf=0                  # 0=slowest speed, 100=fastest speed
Index: etc/etc.sgi/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.sgi/sysctl.conf,v
retrieving revision 1.3
diff -u -p -r1.3 sysctl.conf
--- etc/etc.sgi/sysctl.conf     25 May 2008 16:25:22 -0000      1.3
+++ etc/etc.sgi/sysctl.conf     10 Jun 2011 21:47:31 -0000
@@ -1 +0,0 @@
-#machdep.kbdreset=1            # 1=Enable power button shutdown
Index: etc/etc.sparc64/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.sparc64/sysctl.conf,v
retrieving revision 1.4
diff -u -p -r1.4 sysctl.conf
--- etc/etc.sparc64/sysctl.conf 21 Jun 2006 21:53:32 -0000      1.4
+++ etc/etc.sparc64/sysctl.conf 10 Jun 2011 21:47:34 -0000
@@ -1,3 +1,2 @@
 #machdep.led_blink=1           # 1=On sparc64, make led(s) blink
 #machdep.allowaperture=1       # See xf86(4)
-#machdep.kbdreset=1            # permit console to do a nice halt
Index: etc/etc.zaurus/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/etc.zaurus/sysctl.conf,v
retrieving revision 1.8
diff -u -p -r1.8 sysctl.conf
--- etc/etc.zaurus/sysctl.conf  4 Aug 2009 18:45:44 -0000       1.8
+++ etc/etc.zaurus/sysctl.conf  10 Jun 2011 21:47:37 -0000
@@ -1,4 +1,3 @@
-#machdep.kbdreset=1            # permit zkbd(4) power key to do a nice halt
 #machdep.maxspeed=520          # set change maximum processor speed
 #machdep.lidsuspend=1          # closing the lid will suspend machine
 #hw.setperf=0                  # 0=slowest speed, 100=fastest speed
Index: etc/sysctl.conf
===================================================================
RCS file: /cvs/src/etc/sysctl.conf,v
retrieving revision 1.51
diff -u -p -r1.51 sysctl.conf
--- etc/sysctl.conf     4 Apr 2011 11:14:33 -0000       1.51
+++ etc/sysctl.conf     10 Jun 2011 21:50:15 -0000
@@ -36,3 +36,4 @@
 #kern.watchdog.period=32       # >0=Enable hardware watchdog(4) timer if 
available
 #kern.watchdog.auto=0          # 0=Disable automatic watchdog(4) retriggering
 #kern.pool_debug=0             # 0=Disable pool corruption checks (faster)
+#hw.allowpowerdown=0           # 0=Disable power button shutdown
Index: sbin/sysctl/sysctl.8
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
retrieving revision 1.158
diff -u -p -r1.158 sysctl.8
--- sbin/sysctl/sysctl.8        23 May 2011 07:18:45 -0000      1.158
+++ sbin/sysctl/sysctl.8        10 Jun 2011 17:08:17 -0000
@@ -342,6 +342,7 @@ and a few require a kernel compiled with
 .It hw.serialno        string  no
 .It hw.uuid    string  no
 .It hw.ncpufound       integer no
+.It hw.allowpowerdown  integer yes
 .It machdep.console_device     dev_t   no
 .It machdep.unaligned_print    integer yes
 .It machdep.unaligned_fix      integer yes
Index: share/man/man4/acpibtn.4
===================================================================
RCS file: /cvs/src/share/man/man4/acpibtn.4,v
retrieving revision 1.3
diff -u -p -r1.3 acpibtn.4
--- share/man/man4/acpibtn.4    31 May 2007 19:19:48 -0000      1.3
+++ share/man/man4/acpibtn.4    10 Jun 2011 17:39:03 -0000
@@ -29,7 +29,10 @@ driver is used to handle the event trigg
 button.
 Currently, the only event handled is the press of a power button which
 causes the system to perform a regular system shutdown and power off the
-machine.
+machine if the
+.Va hw.allowpowerdown
+.Xr sysctl 8
+is set to 1.
 .Sh SEE ALSO
 .Xr acpi 4 ,
 .Xr intro 4
Index: share/man/man4/man4.landisk/power.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.landisk/power.4,v
retrieving revision 1.4
diff -u -p -r1.4 power.4
--- share/man/man4/man4.landisk/power.4 31 May 2007 19:19:55 -0000      1.4
+++ share/man/man4/man4.landisk/power.4 10 Jun 2011 20:29:35 -0000
@@ -30,7 +30,7 @@ The
 .Nm
 driver catches that interrupt.
 If the
-.Va machdep.kbdreset
+.Va hw.allowpowerdown
 .Xr sysctl 8
 is set to 1,
 .Nm power
@@ -39,7 +39,10 @@ will signal
 to do a clean shutdown.
 .Sh SEE ALSO
 .Xr intro 4 ,
-.Xr obio 4
+.Xr init 8 ,
+.Xr obio 4 ,
+.Xr rc.shutdown 8 ,
+.Xr sysctl 8
 .Sh HISTORY
 Support for the
 .Nm
Index: share/man/man4/man4.sgi/power.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.sgi/power.4,v
retrieving revision 1.3
diff -u -p -r1.3 power.4
--- share/man/man4/man4.sgi/power.4     26 Oct 2009 18:38:09 -0000      1.3
+++ share/man/man4/man4.sgi/power.4     10 Jun 2011 20:29:59 -0000
@@ -31,7 +31,7 @@ The
 .Nm
 driver catches that interrupt.
 If the
-.Va machdep.kbdreset
+.Va hw.allowpowerdown
 .Xr sysctl 8
 is set to 1,
 .Nm
@@ -41,8 +41,8 @@ to do a clean
 .Xr shutdown 8 .
 .Sh SEE ALSO
 .Xr intro 4 ,
-.Xr macebus 4 ,
 .Xr init 8 ,
+.Xr macebus 4 ,
 .Xr rc.shutdown 8 ,
 .Xr sysctl 8
 .Sh HISTORY
Index: share/man/man4/man4.sparc64/power.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.sparc64/power.4,v
retrieving revision 1.4
diff -u -p -r1.4 power.4
--- share/man/man4/man4.sparc64/power.4 31 May 2007 19:19:57 -0000      1.4
+++ share/man/man4/man4.sparc64/power.4 10 Jun 2011 20:20:37 -0000
@@ -39,7 +39,7 @@ The
 .Nm
 driver catches that interrupt.
 If the
-.Va machdep.kbdreset
+.Va hw.allowpowerdown
 .Xr sysctl 8
 is set to 1,
 .Nm power
Index: share/man/man4/man4.zaurus/zkbd.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.zaurus/zkbd.4,v
retrieving revision 1.16
diff -u -p -r1.16 zkbd.4
--- share/man/man4/man4.zaurus/zkbd.4   31 May 2007 19:19:57 -0000      1.16
+++ share/man/man4/man4.zaurus/zkbd.4   10 Jun 2011 20:43:50 -0000
@@ -77,7 +77,8 @@ End
 On/Off is special: pressing the key will immediately suspend the system.
 Pressing the key while the Zaurus is suspended will cause it to resume.
 Pressing the key longer than 3 seconds will do a nice halt if
-the machdep.kbdreset
+the
+.Va hw.allowpowerdown
 .Xr sysctl 8
 variable is 1.
 .Pp
Index: share/man/man7/securelevel.7
===================================================================
RCS file: /cvs/src/share/man/man7/securelevel.7,v
retrieving revision 1.22
diff -u -p -r1.22 securelevel.7
--- share/man/man7/securelevel.7        9 May 2009 13:45:28 -0000       1.22
+++ share/man/man7/securelevel.7        10 Jun 2011 21:44:35 -0000
@@ -80,6 +80,11 @@ the
 variable may not be changed
 .It
 the
+.Va hw.allowpowerdown
+.Xr sysctl 8
+variable may not be changed
+.It
+the
 .Va net.inet.ip.sourceroute
 .Xr sysctl 8
 variable may not be changed
Index: sys/arch/arm/arm/arm32_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/arm32_machdep.c,v
retrieving revision 1.37
diff -u -p -r1.37 arm32_machdep.c
--- sys/arch/arm/arm/arm32_machdep.c    5 Jun 2011 19:41:09 -0000       1.37
+++ sys/arch/arm/arm/arm32_machdep.c    10 Jun 2011 21:19:46 -0000
@@ -102,8 +102,6 @@ int allowaperture = 0;
 #endif
 
 #if defined(__zaurus__)
-/* Permit console keyboard to do a nice halt. */
-int kbd_reset;
 int lid_suspend;
 extern int xscale_maxspeed;
 #endif
@@ -357,12 +355,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp,
                return (sysctl_int(oldp, oldlenp, newp, newlen, &cpu_apmwarn));
 #endif
 #if defined(__zaurus__)
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp,
-                           kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen,
-                   &kbd_reset));
        case CPU_LIDSUSPEND:
                return (sysctl_int(oldp, oldlenp, newp, newlen,
                    &lid_suspend));
Index: sys/arch/arm/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/arm/include/cpu.h,v
retrieving revision 1.26
diff -u -p -r1.26 cpu.h
--- sys/arch/arm/include/cpu.h  28 Nov 2010 20:44:20 -0000      1.26
+++ sys/arch/arm/include/cpu.h  10 Jun 2011 21:11:36 -0000
@@ -61,7 +61,7 @@
 #define        CPU_POWERSAVE           5       /* int: use CPU powersave mode 
*/
 #define        CPU_ALLOWAPERTURE       6       /* int: allow mmap of /dev/xf86 
*/
 #define CPU_APMWARN            7       /* APM battery warning percentage */
-#define CPU_KBDRESET           8       /* int: console keyboard reset */
+               /*              8          formerly int: keyboard reset */
                /*              9          formerly int: CPU_ZTSRAWMODE */
                /*              10         formerly struct: CPU_ZTSSCALE */
 #define        CPU_MAXSPEED            11      /* int: number of valid machdep 
ids */
@@ -77,7 +77,7 @@
        { "powersave", CTLTYPE_INT }, \
        { "allowaperture", CTLTYPE_INT }, \
        { "apmwarn", CTLTYPE_INT }, \
-       { "kbdreset", CTLTYPE_INT }, \
+       { 0, 0 }, \
        { 0, 0 }, \
        { 0, 0 }, \
        { "maxspeed", CTLTYPE_INT }, \
Index: sys/arch/landisk/dev/power.c
===================================================================
RCS file: /cvs/src/sys/arch/landisk/dev/power.c,v
retrieving revision 1.4
diff -u -p -r1.4 power.c
--- sys/arch/landisk/dev/power.c        15 Jun 2007 18:17:25 -0000      1.4
+++ sys/arch/landisk/dev/power.c        10 Jun 2011 20:31:36 -0000
@@ -90,7 +90,7 @@ power_attach(struct device *parent, stru
 int
 power_intr(void *arg)
 {
-       extern int kbd_reset;
+       extern int allowpowerdown;
        int status;
 
        status = (int8_t)_reg_read_1(LANDISK_BTNSTAT);
@@ -105,8 +105,8 @@ power_intr(void *arg)
                Debugger();
 #endif
                _reg_write_1(LANDISK_PWRSW_INTCLR, 1);
-               if (kbd_reset == 1) {
-                       kbd_reset = 0;
+               if (allowpowerdown == 1) {
+                       allowpowerdown = 0;
                        psignal(initproc, SIGUSR1);
                }
                return (1);
Index: sys/arch/landisk/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/landisk/include/cpu.h,v
retrieving revision 1.3
diff -u -p -r1.3 cpu.h
--- sys/arch/landisk/include/cpu.h      23 Mar 2011 16:54:35 -0000      1.3
+++ sys/arch/landisk/include/cpu.h      10 Jun 2011 21:17:14 -0000
@@ -12,14 +12,14 @@ void machine_reset(void);
  * CTL_MACHDEP definitions.
  */
 #define        CPU_CONSDEV             1       /* dev_t: console terminal 
device */
-#define        CPU_KBDRESET            2       /* keyboard reset */
-#define        CPU_LED_BLINK           3       /* keyboard reset */
+               /*              2          formerly: keyboard reset */
+#define        CPU_LED_BLINK           3       /* blink leds */
 #define        CPU_MAXID               4       /* number of valid machdep ids 
*/
 
 #define        CTL_MACHDEP_NAMES {                                             
\
        { 0, 0 },                                                       \
        { "console_device",     CTLTYPE_STRUCT },                       \
-       { "kbdreset",           CTLTYPE_INT },                          \
+       { 0, 0 },                                                       \
        { "led_blink",          CTLTYPE_INT }                           \
 }
 
Index: sys/arch/landisk/landisk/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/landisk/landisk/machdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 machdep.c
--- sys/arch/landisk/landisk/machdep.c  30 May 2011 22:25:21 -0000      1.24
+++ sys/arch/landisk/landisk/machdep.c  10 Jun 2011 21:20:45 -0000
@@ -110,7 +110,6 @@ __dead void main(void);
 void   cpu_init_kcore_hdr(void);
 void   blink_led(void *);
 
-int    kbd_reset;
 int    led_blink;
 
 extern u_int32_t getramsize(void);
@@ -472,11 +471,6 @@ cpu_sysctl(int *name, u_int namelen, voi
                return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
                    sizeof consdev));
        }
-
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
 
        case CPU_LED_BLINK:
                oldval = led_blink;
Index: sys/arch/loongson/loongson/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/loongson/loongson/machdep.c,v
retrieving revision 1.30
diff -u -p -r1.30 machdep.c
--- sys/arch/loongson/loongson/machdep.c        5 Jun 2011 19:41:07 -0000       
1.30
+++ sys/arch/loongson/loongson/machdep.c        10 Jun 2011 21:23:47 -0000
@@ -105,7 +105,6 @@ vaddr_t     uncached_base;
 int    physmem;                /* Max supported memory, changes to actual. */
 int    ncpu = 1;               /* At least one CPU in the system. */
 struct user *proc0paddr;
-int    kbd_reset;
 
 const struct platform *sys_platform;
 struct cpu_hwinfo bootcpu_hwinfo;
@@ -754,10 +753,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp,
                return ENOTDIR;         /* Overloaded */
 
        switch (name[0]) {
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
        default:
                return EOPNOTSUPP;
        }
Index: sys/arch/mips64/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/mips64/include/cpu.h,v
retrieving revision 1.71
diff -u -p -r1.71 cpu.h
--- sys/arch/mips64/include/cpu.h       31 Mar 2011 20:37:44 -0000      1.71
+++ sys/arch/mips64/include/cpu.h       10 Jun 2011 21:16:49 -0000
@@ -504,13 +504,13 @@ void cpu_startclock(struct cpu_info *);
  * CTL_MACHDEP definitions.
  */
 #define        CPU_ALLOWAPERTURE       1       /* allow mmap of /dev/xf86 */
-#define        CPU_KBDRESET            2       /* keyboard reset */
+               /*              2          formerly: keyboard reset */
 #define        CPU_MAXID               3       /* number of valid machdep ids 
*/
 
 #define        CTL_MACHDEP_NAMES {                     \
        { 0, 0 },                               \
        { "allowaperture", CTLTYPE_INT },       \
-       { "kbdreset", CTLTYPE_INT },            \
+       { 0, 0 },                               \
 }
 
 /*
Index: sys/arch/octeon/octeon/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/octeon/octeon/machdep.c,v
retrieving revision 1.13
diff -u -p -r1.13 machdep.c
--- sys/arch/octeon/octeon/machdep.c    5 Jun 2011 19:41:07 -0000       1.13
+++ sys/arch/octeon/octeon/machdep.c    10 Jun 2011 21:26:34 -0000
@@ -176,7 +176,6 @@ vaddr_t     uncached_base;
 int    physmem;                /* Max supported memory, changes to actual. */
 int    ncpu = 1;               /* At least one CPU in the system. */
 struct user *proc0paddr;
-int    kbd_reset;
 
 struct cpu_hwinfo bootcpu_hwinfo;
 
@@ -630,10 +629,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp,
                return ENOTDIR;         /* Overloaded */
 
        switch (name[0]) {
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
        default:
                return EOPNOTSUPP;
        }
Index: sys/arch/sgi/dev/power.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/dev/power.c,v
retrieving revision 1.13
diff -u -p -r1.13 power.c
--- sys/arch/sgi/dev/power.c    25 Nov 2009 11:23:29 -0000      1.13
+++ sys/arch/sgi/dev/power.c    10 Jun 2011 20:32:13 -0000
@@ -126,7 +126,7 @@ power_mainbus_intr(void *v)
 int
 power_intr(void *unused)
 {
-       extern int kbd_reset;
+       extern int allowpowerdown;
        int val;
 
        /* 
@@ -140,8 +140,8 @@ power_intr(void *unused)
        /* debounce condition */
        dsrtc_register_write(DS1687_EXT_CTRL, val & ~DS1687_KICKSTART);
 
-       if (kbd_reset == 1) {
-               kbd_reset = 0;
+       if (allowpowerdown == 1) {
+               allowpowerdown = 0;
                psignal(initproc, SIGUSR2);
        }
 
Index: sys/arch/sgi/sgi/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/sgi/machdep.c,v
retrieving revision 1.110
diff -u -p -r1.110 machdep.c
--- sys/arch/sgi/sgi/machdep.c  5 Jun 2011 19:41:08 -0000       1.110
+++ sys/arch/sgi/sgi/machdep.c  10 Jun 2011 21:26:49 -0000
@@ -106,7 +106,6 @@ int rsvdmem;                /* Reserved memory not usa
 int    ncpu = 1;               /* At least one CPU in the system. */
 struct user *proc0paddr;
 int    console_ok;             /* Set when console initialized. */
-int    kbd_reset;
 int16_t        masternasid;
 
 int32_t *environment;
@@ -657,10 +656,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp,
                return ENOTDIR;         /* Overloaded */
 
        switch (name[0]) {
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
        default:
                return EOPNOTSUPP;
        }
Index: sys/arch/sparc64/dev/power.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/dev/power.c,v
retrieving revision 1.5
diff -u -p -r1.5 power.c
--- sys/arch/sparc64/dev/power.c        24 Apr 2007 18:30:45 -0000      1.5
+++ sys/arch/sparc64/dev/power.c        10 Jun 2011 20:16:42 -0000
@@ -132,10 +132,10 @@ power_attach(parent, self, aux)
 int
 power_intr(void *vsc)
 {
-       extern int kbd_reset;
+       extern int allowpowerdown;
 
-       if (kbd_reset == 1) {
-               kbd_reset = 0;
+       if (allowpowerdown == 1) {
+               allowpowerdown = 0;
                psignal(initproc, SIGUSR2);
        }
        return (1);
Index: sys/arch/sparc64/dev/rtc.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/dev/rtc.c,v
retrieving revision 1.8
diff -u -p -r1.8 rtc.c
--- sys/arch/sparc64/dev/rtc.c  10 Apr 2010 12:52:39 -0000      1.8
+++ sys/arch/sparc64/dev/rtc.c  10 Jun 2011 20:17:01 -0000
@@ -208,10 +208,10 @@ rtc_attach(struct device *parent, struct
 int
 rtc_intr(void *arg)
 {
-       extern int kbd_reset;
+       extern int allowpowerdown;
 
-       if (kbd_reset == 1) {
-               kbd_reset = 0;
+       if (allowpowerdown == 1) {
+               allowpowerdown = 0;
                psignal(initproc, SIGUSR2);
        }
        return (1);
Index: sys/arch/sparc64/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/include/cpu.h,v
retrieving revision 1.76
diff -u -p -r1.76 cpu.h
--- sys/arch/sparc64/include/cpu.h      23 Mar 2011 16:54:37 -0000      1.76
+++ sys/arch/sparc64/include/cpu.h      10 Jun 2011 21:16:40 -0000
@@ -47,12 +47,13 @@
 /*
  * CTL_MACHDEP definitions.
  */
+               /*              1       formerly: booted kernel name */
 #define        CPU_LED_BLINK           2       /* int: blink leds? */
 #define        CPU_ALLOWAPERTURE       3       /* allow xf86 operations */
 #define        CPU_CPUTYPE             4       /* cpu type */
 #define        CPU_CECCERRORS          5       /* Correctable ECC errors */
 #define        CPU_CECCLAST            6       /* Correctable ECC last fault 
addr */
-#define        CPU_KBDRESET            7       /* soft reset via keyboard */
+               /*              7       formerly: soft reset via keyboard */
 #define        CPU_MAXID               8       /* number of valid machdep ids 
*/
 
 #define        CTL_MACHDEP_NAMES {                     \
@@ -63,7 +64,7 @@
        { "cputype", CTLTYPE_INT },             \
        { "ceccerrs", CTLTYPE_INT },            \
        { "cecclast", CTLTYPE_QUAD },           \
-       { "kbdreset", CTLTYPE_INT },            \
+       { 0, 0 },                               \
 }
 
 #ifdef _KERNEL
Index: sys/arch/sparc64/sparc64/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/sparc64/machdep.c,v
retrieving revision 1.132
diff -u -p -r1.132 machdep.c
--- sys/arch/sparc64/sparc64/machdep.c  5 Jun 2011 19:41:08 -0000       1.132
+++ sys/arch/sparc64/sparc64/machdep.c  10 Jun 2011 21:21:15 -0000
@@ -167,7 +167,6 @@ int physmem;
 extern caddr_t msgbufaddr;
 
 int sparc_led_blink;
-int kbd_reset;
 
 #ifdef APERTURE
 #ifdef INSECURE
@@ -409,10 +408,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp,
                return (sysctl_rdint(oldp, oldlenp, newp, ceccerrs));
        case CPU_CECCLAST:
                return (sysctl_rdquad(oldp, oldlenp, newp, cecclast));
-       case CPU_KBDRESET:
-               if (securelevel > 0)
-                       return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
-               return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
        default:
                return (EOPNOTSUPP);
        }
Index: sys/arch/zaurus/dev/zaurus_kbd.c
===================================================================
RCS file: /cvs/src/sys/arch/zaurus/dev/zaurus_kbd.c,v
retrieving revision 1.31
diff -u -p -r1.31 zaurus_kbd.c
--- sys/arch/zaurus/dev/zaurus_kbd.c    7 Sep 2010 16:21:41 -0000       1.31
+++ sys/arch/zaurus/dev/zaurus_kbd.c    10 Jun 2011 20:43:20 -0000
@@ -429,7 +429,7 @@ zkbd_poll(void *v)
 }
 
 #if NAPM > 0
-extern int kbd_reset;
+extern int allowpowerdown;
 extern int apm_suspends;
 static int zkbdondown;                         /* on key is pressed */
 static struct timeval zkbdontv = { 0, 0 };     /* last on key event */
@@ -461,8 +461,8 @@ zkbd_on(void *v)
                }
        } else if (zkbdondown) {
                if (ratecheck(&zkbdontv, &zkbdhalttv)) {
-                       if (kbd_reset == 1) {
-                               kbd_reset = 0;
+                       if (allowpowerdown == 1) {
+                               allowpowerdown = 0;
                                psignal(initproc, SIGUSR1);
                        }
                } else if (ratecheck(&zkbdontv, &zkbdsleeptv)) {
Index: sys/dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.224
diff -u -p -r1.224 acpi.c
--- sys/dev/acpi/acpi.c 27 Apr 2011 20:55:42 -0000      1.224
+++ sys/dev/acpi/acpi.c 10 Jun 2011 17:29:25 -0000
@@ -1451,8 +1451,12 @@ acpi_sbtn_task(void *arg0, int dummy)
 void
 acpi_powerdown_task(void *arg0, int dummy)
 {
-       /* XXX put a knob in front of this */
-       psignal(initproc, SIGUSR2);
+       extern int allowpowerdown;
+
+       if (allowpowerdown == 1) {
+               allowpowerdown = 0;
+               psignal(initproc, SIGUSR2);
+       }
 }
 
 void
Index: sys/dev/wscons/wskbd.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.67
diff -u -p -r1.67 wskbd.c
--- sys/dev/wscons/wskbd.c      6 Jun 2011 06:13:46 -0000       1.67
+++ sys/dev/wscons/wskbd.c      10 Jun 2011 21:33:55 -0000
@@ -244,7 +244,9 @@ struct cfattach wskbd_ca = {
        wskbd_detach, wskbd_activate
 };
 
+#if defined(__i386__) || defined(__amd64__)
 extern int kbd_reset;
+#endif
 
 #ifndef WSKBD_DEFAULT_BELL_PITCH
 #define        WSKBD_DEFAULT_BELL_PITCH        400     /* 400Hz */
Index: sys/kern/kern_sysctl.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.203
diff -u -p -r1.203 kern_sysctl.c
--- sys/kern/kern_sysctl.c      9 Jun 2011 21:10:55 -0000       1.203
+++ sys/kern/kern_sysctl.c      10 Jun 2011 16:14:35 -0000
@@ -611,6 +611,7 @@ kern_sysctl(int *name, u_int namelen, vo
  * hardware related system variables.
  */
 char *hw_vendor, *hw_prod, *hw_uuid, *hw_serial, *hw_ver;
+int allowpowerdown = 1;
 
 int
 hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
@@ -716,6 +717,12 @@ hw_sysctl(int *name, u_int namelen, void
        case HW_USERMEM64:
                return (sysctl_rdquad(oldp, oldlenp, newp,
                    ptoa((psize_t)physmem - uvmexp.wired)));
+       case HW_ALLOWPOWERDOWN:
+               if (securelevel > 0)
+                       return (sysctl_rdint(oldp, oldlenp, newp,
+                           allowpowerdown));
+               return (sysctl_int(oldp, oldlenp, newp, newlen,
+                   &allowpowerdown));
        default:
                return (EOPNOTSUPP);
        }
Index: sys/sys/sysctl.h
===================================================================
RCS file: /cvs/src/sys/sys/sysctl.h,v
retrieving revision 1.113
diff -u -p -r1.113 sysctl.h
--- sys/sys/sysctl.h    18 Apr 2011 21:44:56 -0000      1.113
+++ sys/sys/sysctl.h    10 Jun 2011 22:15:22 -0000
@@ -757,28 +757,29 @@ struct kinfo_file2 {
 /*
  * CTL_HW identifiers
  */
-#define        HW_MACHINE       1              /* string: machine class */
-#define        HW_MODEL         2              /* string: specific machine 
model */
-#define        HW_NCPU          3              /* int: number of cpus being 
used */
-#define        HW_BYTEORDER     4              /* int: machine byte order */
-#define        HW_PHYSMEM       5              /* int: total memory */
-#define        HW_USERMEM       6              /* int: non-kernel memory */
-#define        HW_PAGESIZE      7              /* int: software page size */
-#define        HW_DISKNAMES     8              /* strings: disk drive names */
-#define        HW_DISKSTATS     9              /* struct: diskstats[] */
-#define        HW_DISKCOUNT    10              /* int: number of disks */
-#define        HW_SENSORS      11              /* node: hardware monitors */
-#define        HW_CPUSPEED     12              /* get CPU frequency */
-#define        HW_SETPERF      13              /* set CPU performance % */
-#define        HW_VENDOR       14              /* string: vendor name */
-#define        HW_PRODUCT      15              /* string: product name */
-#define        HW_VERSION      16              /* string: hardware version */
-#define        HW_SERIALNO     17              /* string: hardware serial 
number */
-#define        HW_UUID         18              /* string: universal unique id 
*/
-#define        HW_PHYSMEM64    19              /* quad: total memory */
-#define        HW_USERMEM64    20              /* quad: non-kernel memory */
-#define        HW_NCPUFOUND    21              /* int: number of cpus found*/
-#define        HW_MAXID        22              /* number of valid hw ids */
+#define        HW_MACHINE               1      /* string: machine class */
+#define        HW_MODEL                 2      /* string: specific machine 
model */
+#define        HW_NCPU                  3      /* int: number of cpus being 
used */
+#define        HW_BYTEORDER             4      /* int: machine byte order */
+#define        HW_PHYSMEM               5      /* int: total memory */
+#define        HW_USERMEM               6      /* int: non-kernel memory */
+#define        HW_PAGESIZE              7      /* int: software page size */
+#define        HW_DISKNAMES             8      /* strings: disk drive names */
+#define        HW_DISKSTATS             9      /* struct: diskstats[] */
+#define        HW_DISKCOUNT            10      /* int: number of disks */
+#define        HW_SENSORS              11      /* node: hardware monitors */
+#define        HW_CPUSPEED             12      /* get CPU frequency */
+#define        HW_SETPERF              13      /* set CPU performance % */
+#define        HW_VENDOR               14      /* string: vendor name */
+#define        HW_PRODUCT              15      /* string: product name */
+#define        HW_VERSION              16      /* string: hardware version */
+#define        HW_SERIALNO             17      /* string: hardware serial 
number */
+#define        HW_UUID                 18      /* string: universal unique id 
*/
+#define        HW_PHYSMEM64            19      /* quad: total memory */
+#define        HW_USERMEM64            20      /* quad: non-kernel memory */
+#define        HW_NCPUFOUND            21      /* int: number of cpus found*/
+#define        HW_ALLOWPOWERDOWN       22      /* allow power button shutdown 
*/
+#define        HW_MAXID                23      /* number of valid hw ids */
 
 #define        CTL_HW_NAMES { \
        { 0, 0 }, \
@@ -803,6 +804,7 @@ struct kinfo_file2 {
        { "physmem", CTLTYPE_QUAD }, \
        { "usermem", CTLTYPE_QUAD }, \
        { "ncpufound", CTLTYPE_INT }, \
+       { "allowpowerdown", CTLTYPE_INT }, \
 }
 
 /*
-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to