From: tobhe Date: Sat, 26 Nov 2022 17:23:15 +0000 (+0000) Subject: Add arm64 lid_action sysctl for Apple Silicon laptops. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ec9fe3b72f8f3554e5a0f578a4e0ff4d2e972d34;p=openbsd Add arm64 lid_action sysctl for Apple Silicon laptops. ok kettenis@ --- diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c index abcdfe70b12..425fe8c186b 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.20 2022/09/13 17:14:54 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.21 2022/11/26 17:23:15 tobhe Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -36,7 +36,6 @@ #include "apm.h" -int lid_action; int pwr_action = 1; int acpi_fdt_match(struct device *, void *, void *); diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index 311d8bb9460..0534221d90f 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.77 2022/11/24 14:43:16 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.78 2022/11/26 17:23:15 tobhe Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -71,6 +71,7 @@ void (*cpuresetfn)(void); void (*powerdownfn)(void); int cold = 1; +int lid_action = 0; struct vm_map *exec_map = NULL; struct vm_map *phys_map = NULL; @@ -322,6 +323,10 @@ extern uint64_t cpu_id_aa64pfr1; * machine dependent system variables. */ +const struct sysctl_bounded_args cpuctl_vars[] = { + { CPU_LIDACTION, &lid_action, 0, 2 }, +}; + int cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) @@ -372,7 +377,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case CPU_ID_AA64ZFR0: return sysctl_rdquad(oldp, oldlenp, newp, 0); default: - return (EOPNOTSUPP); + return (sysctl_bounded_arr(cpuctl_vars, nitems(cpuctl_vars), + name, namelen, oldp, oldlenp, newp, newlen)); } /* NOTREACHED */ } diff --git a/sys/arch/arm64/dev/aplsmc.c b/sys/arch/arm64/dev/aplsmc.c index 449a4f7ce66..01737c7c282 100644 --- a/sys/arch/arm64/dev/aplsmc.c +++ b/sys/arch/arm64/dev/aplsmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplsmc.c,v 1.19 2022/11/25 20:33:11 tobhe Exp $ */ +/* $OpenBSD: aplsmc.c,v 1.20 2022/11/26 17:23:15 tobhe Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -37,6 +37,7 @@ #include "apm.h" +extern int lid_action; extern void (*simplefb_burn_hook)(u_int); extern void (*cpuresetfn)(void); @@ -392,6 +393,14 @@ aplsmc_handle_notification(struct aplsmc_softc *sc, uint64_t data) sc->sc_dev.dv_xname, data); break; } + switch (lid_action) { + case 1: + /* XXX: suspend */ + break; + case 2: + /* XXX: hibernate */ + break; + } break; default: #ifdef APLSMC_DEBUG diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 30154c3ad41..b7cbad2339d 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.31 2022/11/24 14:43:16 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.32 2022/11/26 17:23:15 tobhe Exp $ */ /* * Copyright (c) 2016 Dale Rahn * @@ -36,7 +36,8 @@ #define CPU_ID_AA64PFR1 9 #define CPU_ID_AA64SMFR0 10 #define CPU_ID_AA64ZFR0 11 -#define CPU_MAXID 12 /* number of valid machdep ids */ +#define CPU_LIDACTION 12 +#define CPU_MAXID 13 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \