> Date: Fri, 25 Nov 2022 22:46:46 +0100 > From: Tobias Heider <tobias.hei...@stusta.de> > > This is the boilerplate code to route lid_action through to aplsmc(4) which I > previously sent as part of another diff. Depending on how we are going to use > it, the aplsmc(4) part might need a bit of refinement to distinguish between > LID_OPEN/CLOSE events.
I'd leave lid_action set to 0 for now. Otherwise ok kettenis@ > Index: arch/arm64/arm64/acpi_machdep.c > =================================================================== > RCS file: /cvs/src/sys/arch/arm64/arm64/acpi_machdep.c,v > retrieving revision 1.20 > diff -u -p -r1.20 acpi_machdep.c > --- arch/arm64/arm64/acpi_machdep.c 13 Sep 2022 17:14:54 -0000 1.20 > +++ arch/arm64/arm64/acpi_machdep.c 25 Nov 2022 21:22:09 -0000 > @@ -36,7 +36,6 @@ > > #include "apm.h" > > -int lid_action; > int pwr_action = 1; > > int acpi_fdt_match(struct device *, void *, void *); > Index: arch/arm64/arm64/machdep.c > =================================================================== > RCS file: /cvs/src/sys/arch/arm64/arm64/machdep.c,v > retrieving revision 1.77 > diff -u -p -r1.77 machdep.c > --- arch/arm64/arm64/machdep.c 24 Nov 2022 14:43:16 -0000 1.77 > +++ arch/arm64/arm64/machdep.c 25 Nov 2022 21:22:09 -0000 > @@ -71,6 +71,7 @@ void (*cpuresetfn)(void); > void (*powerdownfn)(void); > > int cold = 1; > +int lid_action = 1; > > 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, voi > 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 */ > } > Index: arch/arm64/dev/aplsmc.c > =================================================================== > RCS file: /cvs/src/sys/arch/arm64/dev/aplsmc.c,v > retrieving revision 1.19 > diff -u -p -r1.19 aplsmc.c > --- arch/arm64/dev/aplsmc.c 25 Nov 2022 20:33:11 -0000 1.19 > +++ arch/arm64/dev/aplsmc.c 25 Nov 2022 21:22:09 -0000 > @@ -37,6 +37,7 @@ > > #include "apm.h" > > +extern int lid_action; > extern void (*simplefb_burn_hook)(u_int); > > extern void (*cpuresetfn)(void); > @@ -390,6 +391,14 @@ aplsmc_handle_notification(struct aplsmc > default: > printf("%s: SMV_EV_TYPE_LID 0x%016llx\n", > sc->sc_dev.dv_xname, data); > + break; > + } > + switch (lid_action) { > + case 1: > + /* XXX: suspend */ > + break; > + case 2: > + /* XXX: hibernate */ > break; > } > break; > Index: arch/arm64/include/cpu.h > =================================================================== > RCS file: /cvs/src/sys/arch/arm64/include/cpu.h,v > retrieving revision 1.31 > diff -u -p -r1.31 cpu.h > --- arch/arm64/include/cpu.h 24 Nov 2022 14:43:16 -0000 1.31 > +++ arch/arm64/include/cpu.h 25 Nov 2022 21:22:09 -0000 > @@ -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 }, \ > >