-/* $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
*
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)
{
--- /dev/null
+/* $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 */
-# $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
#
option PCIVERBOSE
option USER_PCICONF # user-space PCI configuration
option USBVERBOSE
+option SUSPEND
makeoptions KERNEL_BASE_PHYS="0x00200000"
makeoptions KERNEL_BASE_VIRT="0xffffff8000200000"
-/* $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.
#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>
#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)
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;
}
break;
case APM_IOC_GETPOWER:
- power = (struct apm_power_info *)data;
+ power = (struct apm_power_info *)data;
error = (*get_apminfo)(power);
break;
default:
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 */
+