This is a discussion on combined apm and acpi within the mailing.openbsd.tech forums, part of the OpenBSD category; --> this creates a new almost-pseudo-device "power" on i386. it then uses function pointers to route the apm device to ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| this creates a new almost-pseudo-device "power" on i386. it then uses function pointers to route the apm device to the right place, apm or acpi. acpi only attaches if apm does not, as before. then, on i386, we remove the apm and acpi devices (apm becomes power only in the kernel, node stays as /dev/apmctl, acpi node is gone). on amd64, i renamed acpi to apm so the default names work for apmd. would appreciate testing on acpi and not-acpi i386 laptops. Index: etc/etc.amd64/MAKEDEV.md ================================================== ================= RCS file: /home/tedu/cvs/src/etc/etc.amd64/MAKEDEV.md,v retrieving revision 1.19 diff -u -u -r1.19 MAKEDEV.md --- etc/etc.amd64/MAKEDEV.md 2 Aug 2007 16:40:26 -0000 1.19 +++ etc/etc.amd64/MAKEDEV.md 24 Nov 2007 18:59:50 -0000 @@ -17,7 +17,7 @@ dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. dnl dnl -__devitem(acpi, acpi, Advanced Configuration and Power Interface)dnl +__devitem(apm, apm, Advanced Configuration and Power Interface)dnl __devitem(nvram, nvram, NVRAM access)dnl _mkdev(nvram, nvram, {-M nvram c major_nvram_c 0 440 kmem-})dnl _TITLE(make) @@ -66,7 +66,7 @@ _DEV(uscan, 77) _TITLE(spec) dnl _DEV(apm, 21) -_DEV(acpi, 83) +_DEV(apm, 83) _DEV(au, 42) _DEV(bio, 79) _DEV(bthub, 84) Index: etc/etc.i386/MAKEDEV ================================================== ================= RCS file: /home/tedu/cvs/src/etc/etc.i386/MAKEDEV,v retrieving revision 1.185 diff -u -u -r1.185 MAKEDEV --- etc/etc.i386/MAKEDEV 23 Jul 2007 23:22:33 -0000 1.185 +++ etc/etc.i386/MAKEDEV 24 Nov 2007 19:09:52 -0000 @@ -70,7 +70,6 @@ # uscanner* Scanners # Special purpose devices: # apm Power management device -# acpi Advanced Configuration and Power Interface # audio* Audio devices # bio ioctl tunnel pseudo-device # bktr* Video frame grabbers @@ -385,10 +384,6 @@ MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl" ;; -acpi*) - M acpi c 85 0 644 - ;; - apm*) M apm c 21 0 644 M apmctl c 21 8 644 @@ -590,7 +585,7 @@ R rmidi6 rmidi7 tuner0 radio0 music0 speaker audio0 uk0 random R joy0 joy1 lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 R tty02 tty03 ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 - R acpi apm crypto pf pctr systrace wd0 wd1 wd2 wd3 raid0 raid1 + R apm crypto pf pctr systrace wd0 wd1 wd2 wd3 raid0 raid1 R raid2 raid3 std st0 st1 fd mcd0 ;; Index: etc/etc.i386/MAKEDEV.md ================================================== ================= RCS file: /home/tedu/cvs/src/etc/etc.i386/MAKEDEV.md,v retrieving revision 1.38 diff -u -u -r1.38 MAKEDEV.md --- etc/etc.i386/MAKEDEV.md 23 Jul 2007 23:21:25 -0000 1.38 +++ etc/etc.i386/MAKEDEV.md 24 Nov 2007 19:09:58 -0000 @@ -18,7 +18,6 @@ dnl dnl __devitem(apm, apm, Power management device)dnl -__devitem(acpi, acpi, Advanced Configuration and Power Interface)dnl __devitem(nvram, nvram, NVRAM access)dnl _mkdev(nvram, nvram, {-M nvram c major_nvram_c 0 440 kmem-})dnl _TITLE(make) @@ -67,7 +66,6 @@ _DEV(uscan, 77) _TITLE(spec) _DEV(apm, 21) -_DEV(acpi, 85) _DEV(au, 42) _DEV(bio, 79) _DEV(bktr, 49) Index: sys/dev/acpi/acpi.c ================================================== ================= RCS file: /home/tedu/cvs/src/sys/dev/acpi/acpi.c,v retrieving revision 1.105 diff -u -u -r1.105 acpi.c --- sys/dev/acpi/acpi.c 19 Nov 2007 19:17:30 -0000 1.105 +++ sys/dev/acpi/acpi.c 24 Nov 2007 18:56:49 -0000 @@ -38,6 +38,10 @@ #include <dev/acpi/acpidev.h> #include <dev/acpi/dsdt.h> +#ifdef __i386__ +#include <machine/power.h> +#endif + #include <machine/apmvar.h> #ifdef ACPI_DEBUG @@ -472,6 +476,12 @@ else sc->sc_facs = (struct acpi_facs *)handle.va; +#ifdef __i386__ + power_open = acpiopen; + power_close = acpiclose; + power_ioctl = acpiioctl; + power_kqfilter = acpikqfilter; +#endif acpi_enabled = 1; /* Create opcode hashtable */ Index: sys/arch/i386/conf/files.i386 ================================================== ================= RCS file: /home/tedu/cvs/src/sys/arch/i386/conf/files.i386,v retrieving revision 1.167 diff -u -u -r1.167 files.i386 --- sys/arch/i386/conf/files.i386 16 Nov 2007 21:07:01 -0000 1.167 +++ sys/arch/i386/conf/files.i386 24 Nov 2007 19:14:43 -0000 @@ -300,6 +300,8 @@ file arch/i386/i386/apm.c apm needs-count file arch/i386/i386/apmcall.S apm +file arch/i386/i386/power.c apm | acpi + # Intel SMP specification 1.4 define mpbios file arch/i386/i386/mpbios.c mpbios needs-flag Index: sys/arch/i386/i386/apm.c ================================================== ================= RCS file: /home/tedu/cvs/src/sys/arch/i386/i386/apm.c,v retrieving revision 1.78 diff -u -u -r1.78 apm.c --- sys/arch/i386/i386/apm.c 3 Nov 2007 03:37:08 -0000 1.78 +++ sys/arch/i386/i386/apm.c 24 Nov 2007 19:40:44 -0000 @@ -66,6 +66,7 @@ #include <i386/isa/nvram.h> #include <dev/isa/isavar.h> +#include <machine/power.h> #include <machine/biosvar.h> #include <machine/apmvar.h> @@ -916,6 +917,10 @@ } /* All is well, let the rest of the world know */ + power_open = acpiopen; + power_close = acpiclose; + power_ioctl = acpiioctl; + power_kqfilter = acpikqfilter; apm_attached = 1; } } else { Index: sys/arch/i386/i386/conf.c ================================================== ================= RCS file: /home/tedu/cvs/src/sys/arch/i386/i386/conf.c,v retrieving revision 1.119 diff -u -u -r1.119 conf.c --- sys/arch/i386/i386/conf.c 18 Sep 2007 18:13:06 -0000 1.119 +++ sys/arch/i386/i386/conf.c 24 Nov 2007 19:15:29 -0000 @@ -151,8 +151,6 @@ #include "sequencer.h" cdev_decl(music); #include "joy.h" -#include "acpi.h" -#include "apm.h" #include "bthub.h" #include "pctr.h" #include "bios.h" @@ -224,7 +222,7 @@ cdev_disk_init(NCCD,ccd), /* 18: concatenated disk driver */ cdev_ss_init(NSS,ss), /* 19: SCSI scanner */ cdev_uk_init(NUK,uk), /* 20: unknown SCSI */ - cdev_apm_init(NAPM,apm), /* 21: Advanced Power Management */ + cdev_power_init(1,power), /* 21: Advanced Power Management */ cdev_fd_init(1,filedesc), /* 22: file descriptor pseudo-device */ cdev_bpftun_init(NBPFILTER,bpf),/* 23: Berkeley packet filter */ cdev_notdef(), /* 24 */ @@ -307,7 +305,7 @@ cdev_hotplug_init(NHOTPLUG,hotplug), /* 82: devices hot plugging */ cdev_gpio_init(NGPIO,gpio), /* 83: GPIO interface */ cdev_nvram_init(NNVRAM,nvram), /* 84: NVRAM interface */ - cdev_acpi_init(NACPI,acpi), /* 85: ACPI */ + cdev_notdef(), /* 85: ACPI (deprecated) */ cdev_bthub_init(NBTHUB,bthub), /* 86: bthub */ }; int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]); Index: sys/arch/i386/include/conf.h ================================================== ================= RCS file: /home/tedu/cvs/src/sys/arch/i386/include/conf.h,v retrieving revision 1.12 diff -u -u -r1.12 conf.h --- sys/arch/i386/include/conf.h 31 Dec 2005 21:22:34 -0000 1.12 +++ sys/arch/i386/include/conf.h 24 Nov 2007 19:41:06 -0000 @@ -49,13 +49,7 @@ cdev_decl(pc); -#define cdev_apm_init(c,n) {\ - dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ - (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ - (dev_type_mmap((*))) enodev, 0, D_KQFILTER, dev_init(c,n,kqfilter) } - -#define cdev_acpi_init(c,n) {\ +#define cdev_power_init(c,n) {\ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ @@ -77,6 +71,8 @@ cdev_decl(acpi); cdev_decl(apm); + +cdev_decl(power); #define pctrpoll seltrue cdev_decl(pctr); --- /dev/null Sat Nov 24 19:42:26 2007 +++ sys/arch/i386/include/power.h Sat Nov 24 19:40:30 2007 @@ -0,0 +1,23 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2007 Ted Unangst <tedu@openbsd.org> + * + * 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. + */ + + +extern int (*power_open)(dev_t, int, int, struct proc *); +extern int (*power_close)(dev_t, int, int, struct proc *); +extern int (*power_ioctl)(dev_t, u_long, caddr_t, int, struct proc *); +extern int (*power_kqfilter)(dev_t, struct knote *); + --- /dev/null Sat Nov 24 19:42:28 2007 +++ sys/arch/i386/i386/power.c Sat Nov 24 19:40:05 2007 @@ -0,0 +1,58 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2007 Ted Unangst <tedu@openbsd.org> + * + * 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 <machine/conf.h> +#include <sys/event.h> + + +int (*power_open)(dev_t, int, int, struct proc *); +int (*power_close)(dev_t, int, int, struct proc *); +int (*power_ioctl)(dev_t, u_long, caddr_t, int, struct proc *); +int (*power_kqfilter)(dev_t, struct knote *); + +int +poweropen(dev_t dev, int flag, int mode, struct proc *p) +{ + if (!power_open) + return ENODEV; + return power_open(dev, flag, mode, p); +} + +int +powerclose(dev_t dev, int flag, int mode, struct proc *p) +{ + if (!power_close) + return ENODEV; + return power_close(dev, flag, mode, p); +} + +int +powerioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +{ + if (!power_ioctl) + return ENODEV; + return power_ioctl(dev, cmd, data, flag, p); +} + +int +powerkqfilter(dev_t dev, struct knote *kn) +{ + if (!power_kqfilter) + return ENODEV; + return power_kqfilter(dev, kn); +} Index: etc/etc.amd64/MAKEDEV ================================================== ================= RCS file: /home/tedu/cvs/src/etc/etc.amd64/MAKEDEV,v retrieving revision 1.40 diff -u -u -r1.40 MAKEDEV --- etc/etc.amd64/MAKEDEV 2 Aug 2007 16:42:19 -0000 1.40 +++ etc/etc.amd64/MAKEDEV 24 Nov 2007 19:51:41 -0000 @@ -69,7 +69,7 @@ # usb* Bus control devices used by usbd for attach/detach # uscanner* Scanners # Special purpose devices: -# acpi Advanced Configuration and Power Interface +# apm Advanced Configuration and Power Interface # audio* Audio devices # bio ioctl tunnel pseudo-device # bthub* Bluetooth Hubs @@ -379,8 +379,9 @@ MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl" ;; -acpi*) - M acpi c 83 0 644 +apm*) + M apm c 83 0 644 + M apmctl c 83 8 644 ;; uscanner*) @@ -578,7 +579,7 @@ R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0 R radio0 music0 speaker audio0 uk0 random joy0 joy1 lpa0 lpa1 R lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 tty02 tty03 ttyc0 ttyc1 - R ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 acpi crypto pf pctr + R ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm crypto pf pctr R systrace wd0 wd1 wd2 wd3 raid0 raid1 raid2 raid3 std st0 st1 R fd mcd0 ;; |