summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2019-01-19 20:45:07 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2019-01-19 20:45:07 +0000
commit0eb0f6611a16c46a129cb411403c90fea7546bad (patch)
treed52796d3d91108867379d80676db3e79b0b6f876 /sys/arch
parentcb42757ad7aadaa5be413a37d39bb489b19b79f6 (diff)
Add a pwraction sysctl that controls what the power button does on acpi.
By default, nothing changes -- shutdown is initiated. But allows turning power button into a sleep button if desired. (grudging) ok from a few parties
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/machdep.c13
-rw-r--r--sys/arch/amd64/include/cpu.h6
-rw-r--r--sys/arch/arm64/arm64/acpi_machdep.c3
-rw-r--r--sys/arch/i386/i386/machdep.c3
-rw-r--r--sys/arch/loongson/loongson/machdep.c3
5 files changed, 22 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index a044fa50ed0..0990d984320 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.252 2019/01/11 06:25:06 mlarkin Exp $ */
+/* $OpenBSD: machdep.c,v 1.253 2019/01/19 20:45:06 tedu Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -192,6 +192,7 @@ paddr_t tramp_pdirpa;
int kbd_reset;
int lid_action = 1;
+int pwr_action = 1;
int forceukbd;
/*
@@ -536,6 +537,16 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
lid_action = val;
}
return (error);
+ case CPU_PWRACTION:
+ val = pwr_action;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &val);
+ if (!error) {
+ if (val < 0 || val > 2)
+ error = EINVAL;
+ else
+ pwr_action = val;
+ }
+ return (error);
#if NPCKBC > 0 && NUKBD > 0
case CPU_FORCEUKBD:
if (forceukbd)
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 232c7febdd9..e5210e082d0 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.128 2018/12/05 10:28:21 jsg Exp $ */
+/* $OpenBSD: cpu.h,v 1.129 2019/01/19 20:45:06 tedu Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -443,7 +443,8 @@ void mp_setperf_init(void);
#define CPU_FORCEUKBD 15 /* Force ukbd(4) as console keyboard */
#define CPU_TSCFREQ 16 /* TSC frequency */
#define CPU_INVARIANTTSC 17 /* has invariant TSC */
-#define CPU_MAXID 18 /* number of valid machdep ids */
+#define CPU_PWRACTION 18 /* action caused by power button */
+#define CPU_MAXID 19 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
@@ -464,6 +465,7 @@ void mp_setperf_init(void);
{ "forceukbd", CTLTYPE_INT }, \
{ "tscfreq", CTLTYPE_QUAD }, \
{ "invarianttsc", CTLTYPE_INT }, \
+ { "pwraction", CTLTYPE_INT }, \
}
#endif /* !_MACHINE_CPU_H_ */
diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c
index f3bca958234..3aa24a97e4b 100644
--- a/sys/arch/arm64/arm64/acpi_machdep.c
+++ b/sys/arch/arm64/arm64/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.1 2018/07/01 19:30:37 kettenis Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.2 2019/01/19 20:45:06 tedu Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@@ -31,6 +31,7 @@
#include <dev/acpi/acpivar.h>
int lid_action;
+int pwr_action = 1;
int acpi_fdt_match(struct device *, void *, void *);
void acpi_fdt_attach(struct device *, struct device *, void *);
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 7add707307a..dcd73684aae 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.628 2019/01/18 01:34:50 pd Exp $ */
+/* $OpenBSD: machdep.c,v 1.629 2019/01/19 20:45:06 tedu Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -233,6 +233,7 @@ void via_update_sensor(void *args);
#endif
int kbd_reset;
int lid_action = 1;
+int pwr_action = 1;
int forceukbd;
/*
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 2e710d0dd23..0d605aeae7b 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.83 2018/04/20 14:08:12 visa Exp $ */
+/* $OpenBSD: machdep.c,v 1.84 2019/01/19 20:45:06 tedu Exp $ */
/*
* Copyright (c) 2009, 2010, 2014 Miodrag Vallat.
@@ -116,6 +116,7 @@ int ncpu = 1; /* At least one CPU in the system. */
int nnodes = 1; /* Number of NUMA nodes, only on 3A. */
struct user *proc0paddr;
int lid_action = 1;
+int pwr_action = 1;
#ifdef MULTIPROCESSOR
uint64_t cpu_spinup_a0;