From e1938dd5a84ba824d7bd1885fbce8030aeeda4bf Mon Sep 17 00:00:00 2001 From: gkoehler Date: Thu, 10 Feb 2022 05:48:02 +0000 Subject: [PATCH] Add stubs for macppc suspend These stubs don't work; they only pretend to suspend the machine. SUSPEND + MULTIPROCESSOR doesn't build. zzz(8) stops giving an error message, even in no-SUSPEND kernels. Add intr_enable in , adapted from powerpc64, because subr_suspend.c calls intr_enable(). --- sys/arch/macppc/dev/apm.c | 80 +++++++++++++++++++++++++++++++--- sys/arch/powerpc/include/cpu.h | 8 +++- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/sys/arch/macppc/dev/apm.c b/sys/arch/macppc/dev/apm.c index d8259e4e46b..79459718840 100644 --- a/sys/arch/macppc/dev/apm.c +++ b/sys/arch/macppc/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.24 2021/03/26 23:34:50 kn Exp $ */ +/* $OpenBSD: apm.c,v 1.25 2022/02/10 05:48:02 gkoehler Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -53,6 +53,9 @@ #include +#include "wsdisplay.h" +#include + #if defined(APMDEBUG) #define DPRINTF(x) printf x #else @@ -213,14 +216,14 @@ 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: - case APM_IOC_DEV_CTL: - if ((flag & FWRITE) == 0) + if ((flag & FWRITE) == 0) { error = EBADF; - else - error = EOPNOTSUPP; + break; + } +#ifdef SUSPEND + sleep_state(sc, SLEEP_SUSPEND); +#endif break; case APM_IOC_PRN_CTL: if ((flag & FWRITE) == 0) @@ -331,3 +334,66 @@ apmkqfilter(dev_t dev, struct knote *kn) return (0); } + +#ifdef SUSPEND +void +sleep_clocks(void *v) +{ +} + +int +sleep_showstate(void *v, int sleepmode) +{ + switch (sleepmode) { + case SLEEP_SUSPEND: + /* TODO blink the light */ + return 0; + default: + return EOPNOTSUPP; + } +} + +int +sleep_setstate(void *v) +{ + printf("TODO sleep_setstate\n"); + return 0; +} + +int +sleep_resume(void *v) +{ + return 0; +} + +void +gosleep(void *v) +{ +} + +void +display_suspend(void *v) +{ +#if NWSDISPLAY > 0 + wsdisplay_suspend(); +#endif /* NWSDISPLAY > 0 */ +} + +void +display_resume(void *v) +{ +#if NWSDISPLAY > 0 + wsdisplay_resume(); +#endif /* NWSDISPLAY > 0 */ +} + +void +suspend_finish(void *v) +{ +} + +void +disable_lid_wakeups(void *v) +{ +} +#endif /* SUSPEND */ diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h index 2c9e8db096a..727cd200096 100644 --- a/sys/arch/powerpc/include/cpu.h +++ b/sys/arch/powerpc/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.70 2021/07/06 09:34:06 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.71 2022/02/10 05:48:02 gkoehler Exp $ */ /* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */ /* @@ -423,6 +423,12 @@ ppc_intr_disable(void) return (emsr & PSL_EE); } +static inline void +intr_enable(void) +{ + ppc_mtmsr(ppc_mfmsr() | PSL_EE); +} + static __inline u_long intr_disable(void) { -- 2.20.1