summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-09 23:54:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-09 23:54:56 +0000
commit02fdc2fff0301f0a1c7fba2112015d26ee3133b4 (patch)
treea5074b10981b9f7ab7474ead37686336c0a091a5 /sys/arch
parentdbb38f97fd82086fcd731a9c740693454021cb30 (diff)
*** empty log message ***
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/arm64/acpi_machdep.c32
-rw-r--r--sys/arch/arm64/arm64/suspend_machdep.c144
-rw-r--r--sys/arch/arm64/conf/GENERIC3
-rw-r--r--sys/arch/arm64/dev/apm.c144
4 files changed, 280 insertions, 43 deletions
diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c
index 4ad8b1afccf..97377d11654 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.18 2022/02/08 23:19:47 deraadt Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.19 2022/02/09 23:54:55 deraadt Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@@ -190,36 +190,6 @@ acpi_intr_disestablish(void *cookie)
free(aih, M_DEVBUF, sizeof(*aih));
}
-void
-sleep_clocks(void *v)
-{
-}
-
-int
-acpi_sleep_cpu(struct acpi_softc *sc, int state)
-{
- return 0;
-}
-
-void
-acpi_resume_cpu(struct acpi_softc *sc, int state)
-{
-}
-
-#ifdef MULTIPROCESSOR
-
-void
-acpi_sleep_mp(void)
-{
-}
-
-void
-acpi_resume_mp(void)
-{
-}
-
-#endif
-
bus_dma_tag_t
acpi_iommu_device_map(struct aml_node *node, bus_dma_tag_t dmat)
{
diff --git a/sys/arch/arm64/arm64/suspend_machdep.c b/sys/arch/arm64/arm64/suspend_machdep.c
new file mode 100644
index 00000000000..6162f07afb5
--- /dev/null
+++ b/sys/arch/arm64/arm64/suspend_machdep.c
@@ -0,0 +1,144 @@
+/* $OpenBSD: suspend_machdep.c,v 1.1 2022/02/09 23:54:55 deraadt Exp $ */
+/*
+ * Copyright (c) 2018 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/dsdt.h>
+
+#include <machine/apmvar.h>
+
+#include <arm64/dev/acpiiort.h>
+
+void
+sleep_clocks(void *v)
+{
+}
+
+int
+sleep_cpu(void *v, int state)
+{
+ return 0;
+}
+
+void
+resume_cpu(void *sc, int state)
+{
+}
+
+#ifdef MULTIPROCESSOR
+
+void
+sleep_mp(void)
+{
+}
+
+void
+resume_mp(void)
+{
+}
+
+int
+sleep_showstate(void *v, int sleepmode)
+{
+ return 0;
+}
+
+int
+sleep_setstate(void *v)
+{
+ return 0;
+}
+
+void
+gosleep(void *v)
+{
+ // XXX
+}
+
+int
+sleep_resume(void *v)
+{
+ return 0;
+}
+
+void
+display_suspend(void *v)
+{
+#if 0
+#if NWSDISPLAY > 0
+ struct acpi_softc *sc = v;
+
+ /*
+ * Temporarily release the lock to prevent the X server from
+ * blocking on setting the display brightness.
+ */
+ rw_exit_write(&sc->sc_lck); /* XXX replace this interlock */
+ wsdisplay_suspend();
+ rw_enter_write(&sc->sc_lck);
+#endif /* NWSDISPLAY > 0 */
+#endif
+}
+
+void
+display_resume(void *v)
+{
+#if 0
+#if NWSDISPLAY > 0
+ struct acpi_softc *sc = v;
+
+ rw_exit_write(&sc->sc_lck); /* XXX replace this interlock */
+ wsdisplay_resume();
+ rw_enter_write(&sc->sc_lck);
+#endif /* NWSDISPLAY > 0 */
+#endif
+}
+
+void
+suspend_finish(void *v)
+{
+#if 0
+ extern int lid_action;
+
+ acpi_record_event(sc, APM_NORMAL_RESUME);
+ acpi_indicator(sc, ACPI_SST_WORKING);
+
+ /* XXX won't work, there is no acpi thread on arm64 */
+
+ /* If we woke up but all the lids are closed, go back to sleep */
+ if (acpibtn_numopenlids() == 0 && lid_action != 0)
+ acpi_addtask(sc, acpi_sleep_task, sc, sc->sc_state);
+#endif
+}
+
+void
+disable_lid_wakeups(void *v)
+{
+}
+
+#endif /* !SMALL_KERNEL */
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC
index ba72ff6fa2f..dffce2c346e 100644
--- a/sys/arch/arm64/conf/GENERIC
+++ b/sys/arch/arm64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.222 2022/01/10 09:07:28 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.223 2022/02/09 23:54:55 deraadt Exp $
#
# GENERIC machine description file
#
@@ -25,6 +25,7 @@ maxusers 80
option PCIVERBOSE
option USER_PCICONF # user-space PCI configuration
option USBVERBOSE
+option SUSPEND
makeoptions KERNEL_BASE_PHYS="0x00200000"
makeoptions KERNEL_BASE_VIRT="0xffffff8000200000"
diff --git a/sys/arch/arm64/dev/apm.c b/sys/arch/arm64/dev/apm.c
index d79b3b1740b..074e656ca13 100644
--- a/sys/arch/arm64/dev/apm.c
+++ b/sys/arch/arm64/dev/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.8 2021/10/24 17:52:28 mpi Exp $ */
+/* $OpenBSD: apm.c,v 1.9 2022/02/09 23:54:55 deraadt Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -41,7 +41,6 @@
#include <sys/device.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#include <sys/buf.h>
#include <sys/event.h>
#include <sys/reboot.h>
#include <sys/hibernate.h>
@@ -109,7 +108,7 @@ int (*get_apminfo)(struct apm_power_info *) = apm_getdefaultinfo;
#define SCFLAG_PCTPRINT 0x0004000
#define SCFLAG_PRINT (SCFLAG_NOPRINT|SCFLAG_PCTPRINT)
-#define SCFLAG_OREAD (1 << 0)
+#define SCFLAG_OREAD (1 << 0)
#define SCFLAG_OWRITE (1 << 1)
#define SCFLAG_OPEN (SCFLAG_OREAD|SCFLAG_OWRITE)
@@ -210,18 +209,28 @@ apmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
switch (cmd) {
/* some ioctl names from linux */
case APM_IOC_STANDBY:
- case APM_IOC_STANDBY_REQ:
case APM_IOC_SUSPEND:
- case APM_IOC_SUSPEND_REQ:
+ if ((flag & FWRITE) == 0) {
+ error = EBADF;
+ break;
+ }
+ sleep_state(NULL, SLEEP_SUSPEND);
+ break;
#ifdef HIBERNATE
case APM_IOC_HIBERNATE:
-#endif
- case APM_IOC_DEV_CTL:
- if ((flag & FWRITE) == 0)
+ if ((error = suser(p)) != 0)
+ break;
+ if ((flag & FWRITE) == 0) {
error = EBADF;
- else
- error = EOPNOTSUPP; /* XXX */
+ break;
+ }
+ if (get_hibernate_io_function(swdevt[0].sw_dev) == NULL) {
+ error = EOPNOTSUPP;
+ break;
+ }
+ sleep_state(NULL, SLEEP_HIBERNATE);
break;
+#endif
case APM_IOC_PRN_CTL:
if ((flag & FWRITE) == 0)
error = EBADF;
@@ -247,7 +256,7 @@ apmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
}
break;
case APM_IOC_GETPOWER:
- power = (struct apm_power_info *)data;
+ power = (struct apm_power_info *)data;
error = (*get_apminfo)(power);
break;
default:
@@ -337,3 +346,116 @@ apm_record_event(u_int event, const char *src, const char *msg)
return (0);
}
+
+#ifdef SUSPEND
+
+void
+sleep_clocks(void *v)
+{
+}
+
+int
+sleep_cpu(void *v, int state)
+{
+ return 0;
+}
+
+void
+resume_cpu(void *sc, int state)
+{
+}
+
+#ifdef MULTIPROCESSOR
+
+void
+sleep_mp(void)
+{
+}
+
+void
+resume_mp(void)
+{
+}
+
+#endif /* MULTIPROCESSOR */
+
+int
+sleep_showstate(void *v, int sleepmode)
+{
+ return 0;
+}
+
+int
+sleep_setstate(void *v)
+{
+ return 0;
+}
+
+void
+gosleep(void *v)
+{
+ // XXX
+}
+
+int
+sleep_resume(void *v)
+{
+ return 0;
+}
+
+void
+display_suspend(void *v)
+{
+#if 0
+#if NWSDISPLAY > 0
+ struct acpi_softc *sc = v;
+
+ /*
+ * Temporarily release the lock to prevent the X server from
+ * blocking on setting the display brightness.
+ */
+ rw_exit_write(&sc->sc_lck); /* XXX replace this interlock */
+ wsdisplay_suspend();
+ rw_enter_write(&sc->sc_lck);
+#endif /* NWSDISPLAY > 0 */
+#endif
+}
+
+void
+display_resume(void *v)
+{
+#if 0
+#if NWSDISPLAY > 0
+ struct acpi_softc *sc = v;
+
+ rw_exit_write(&sc->sc_lck); /* XXX replace this interlock */
+ wsdisplay_resume();
+ rw_enter_write(&sc->sc_lck);
+#endif /* NWSDISPLAY > 0 */
+#endif
+}
+
+void
+suspend_finish(void *v)
+{
+#if 0
+ extern int lid_action;
+
+ acpi_record_event(sc, APM_NORMAL_RESUME);
+ acpi_indicator(sc, ACPI_SST_WORKING);
+
+ /* XXX won't work, there is no acpi thread on arm64 */
+
+ /* If we woke up but all the lids are closed, go back to sleep */
+ if (acpibtn_numopenlids() == 0 && lid_action != 0)
+ acpi_addtask(sc, acpi_sleep_task, sc, sc->sc_state);
+#endif
+}
+
+void
+disable_lid_wakeups(void *v)
+{
+}
+
+#endif /* SUSPEND */
+