From ca7fa91803d196312c3f62437d179c798610ca82 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 8 Feb 2022 21:19:24 +0000 Subject: [PATCH 37/39] sys: Split struct device into a private device_impl.h. Include this only inside autoconf itself, and a few files that abuse autoconf in ways I can't confidently make easy fixes for. XXX kernel ABI change requires bump -- no more use of struct device internals allowed, previously done by some drivers --- sys/arch/amiga/amiga/autoconf.c | 1 + sys/arch/amiga/dev/grf_cc.c | 1 + sys/arch/amiga/dev/grf_cl.c | 1 + sys/arch/amiga/dev/grf_cv.c | 1 + sys/arch/amiga/dev/grf_cv3d.c | 1 + sys/arch/amiga/dev/grf_et.c | 1 + sys/arch/amiga/dev/grf_rh.c | 1 + sys/arch/amiga/dev/grf_rt.c | 1 + sys/arch/amiga/dev/grf_ul.c | 1 + sys/arch/amigappc/amigappc/autoconf.c | 1 + sys/arch/arm/iomd/iomdiic.c | 1 + sys/arch/atari/atari/autoconf.c | 1 + sys/arch/atari/dev/ite_cc.c | 1 + sys/arch/atari/dev/ite_et.c | 1 + sys/arch/dreamcast/dev/maple/maple.c | 1 + sys/arch/mips/mips/cpu_subr.c | 1 + sys/ddb/db_autoconf.c | 1 + sys/dev/sbus/esp_sbus.c | 1 + sys/dev/wscons/wsmux.c | 1 + sys/kern/kern_pmf.c | 1 + sys/kern/subr_autoconf.c | 1 + sys/kern/subr_device.c | 1 + sys/rump/librump/rumpkern/rump.c | 1 + sys/sys/device.h | 69 +--------- sys/sys/device_impl.h | 183 ++++++++++++++++++++++++++ 25 files changed, 211 insertions(+), 64 deletions(-) create mode 100644 sys/sys/device_impl.h diff --git a/sys/arch/amiga/amiga/autoconf.c b/sys/arch/amiga/amiga/autoconf.c index 3f548fd68bdd..d59e6c7eb7f8 100644 --- a/sys/arch/amiga/amiga/autoconf.c +++ b/sys/arch/amiga/amiga/autoconf.c @@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.120 2021/08/07 16:18:41 thorpej Exp $ #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_cc.c b/sys/arch/amiga/dev/grf_cc.c index f12724264900..aecc72ec818f 100644 --- a/sys/arch/amiga/dev/grf_cc.c +++ b/sys/arch/amiga/dev/grf_cc.c @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_cc.c,v 1.43 2021/08/07 16:18:41 thorpej Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_cl.c b/sys/arch/amiga/dev/grf_cl.c index 5f9b129ef4ea..ade94ccd3ee5 100644 --- a/sys/arch/amiga/dev/grf_cl.c +++ b/sys/arch/amiga/dev/grf_cl.c @@ -78,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_cl.c,v 1.54 2021/12/26 16:08:19 andvar Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include diff --git a/sys/arch/amiga/dev/grf_cv.c b/sys/arch/amiga/dev/grf_cv.c index 7a3d60e1d63f..373a63fe9438 100644 --- a/sys/arch/amiga/dev/grf_cv.c +++ b/sys/arch/amiga/dev/grf_cv.c @@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1.63 2022/01/01 11:45:37 msaitoh Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_cv3d.c b/sys/arch/amiga/dev/grf_cv3d.c index f42ca5ad334e..f7bbd4360d8d 100644 --- a/sys/arch/amiga/dev/grf_cv3d.c +++ b/sys/arch/amiga/dev/grf_cv3d.c @@ -81,6 +81,7 @@ Note: IO Regbase is needed for wakeup of the board otherwise use #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_et.c b/sys/arch/amiga/dev/grf_et.c index f41f3229435a..2219b99d4b26 100644 --- a/sys/arch/amiga/dev/grf_et.c +++ b/sys/arch/amiga/dev/grf_et.c @@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1.39 2021/12/26 16:08:19 andvar Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include diff --git a/sys/arch/amiga/dev/grf_rh.c b/sys/arch/amiga/dev/grf_rh.c index 99dbbf5dc2cf..ca67fdf1c5a3 100644 --- a/sys/arch/amiga/dev/grf_rh.c +++ b/sys/arch/amiga/dev/grf_rh.c @@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_rh.c,v 1.60 2021/08/09 21:13:05 andvar Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_rt.c b/sys/arch/amiga/dev/grf_rt.c index e5b2db788f15..8d7cf71e374c 100644 --- a/sys/arch/amiga/dev/grf_rt.c +++ b/sys/arch/amiga/dev/grf_rt.c @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_rt.c,v 1.60 2021/08/07 16:18:41 thorpej Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/amiga/dev/grf_ul.c b/sys/arch/amiga/dev/grf_ul.c index 2e9eed2b0164..3cba97c339ac 100644 --- a/sys/arch/amiga/dev/grf_ul.c +++ b/sys/arch/amiga/dev/grf_ul.c @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_ul.c,v 1.53 2021/08/07 16:18:41 thorpej Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include diff --git a/sys/arch/amigappc/amigappc/autoconf.c b/sys/arch/amigappc/amigappc/autoconf.c index decf6df0677a..c7520f77dab6 100644 --- a/sys/arch/amigappc/amigappc/autoconf.c +++ b/sys/arch/amigappc/amigappc/autoconf.c @@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2021/08/07 16:18:42 thorpej Exp $") #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/arm/iomd/iomdiic.c b/sys/arch/arm/iomd/iomdiic.c index 483619edb032..9dd8c8a855cd 100644 --- a/sys/arch/arm/iomd/iomdiic.c +++ b/sys/arch/arm/iomd/iomdiic.c @@ -37,6 +37,7 @@ #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/atari/atari/autoconf.c b/sys/arch/atari/atari/autoconf.c index 5ed2c9964932..ec1d8ed58c31 100644 --- a/sys/arch/atari/atari/autoconf.c +++ b/sys/arch/atari/atari/autoconf.c @@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.71 2021/08/07 16:18:46 thorpej Exp $" #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/atari/dev/ite_cc.c b/sys/arch/atari/dev/ite_cc.c index 7bd1b2f85261..27d45b6f3516 100644 --- a/sys/arch/atari/dev/ite_cc.c +++ b/sys/arch/atari/dev/ite_cc.c @@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ite_cc.c,v 1.43 2021/08/07 16:18:46 thorpej Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/atari/dev/ite_et.c b/sys/arch/atari/dev/ite_et.c index 8841f8253b2b..5ab3944c9fda 100644 --- a/sys/arch/atari/dev/ite_et.c +++ b/sys/arch/atari/dev/ite_et.c @@ -34,6 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: ite_et.c,v 1.34 2021/08/07 16:18:46 thorpej Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include diff --git a/sys/arch/dreamcast/dev/maple/maple.c b/sys/arch/dreamcast/dev/maple/maple.c index 87abe5527c7e..4c1cb97f23bd 100644 --- a/sys/arch/dreamcast/dev/maple/maple.c +++ b/sys/arch/dreamcast/dev/maple/maple.c @@ -66,6 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.55 2021/08/07 16:18:48 thorpej Exp $"); #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/arch/mips/mips/cpu_subr.c b/sys/arch/mips/mips/cpu_subr.c index 26376373eec8..9fa342e24256 100644 --- a/sys/arch/mips/mips/cpu_subr.c +++ b/sys/arch/mips/mips/cpu_subr.c @@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.60 2022/03/03 06:27:41 riastradh Exp #include #include #include +#include /* XXX autoconf abuse */ #include #include #include diff --git a/sys/ddb/db_autoconf.c b/sys/ddb/db_autoconf.c index 0a0ca58eb9d6..f894b851cc0b 100644 --- a/sys/ddb/db_autoconf.c +++ b/sys/ddb/db_autoconf.c @@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_autoconf.c,v 1.2 2018/03/05 07:47:21 mlelstv Exp #include #include +#include #include diff --git a/sys/dev/sbus/esp_sbus.c b/sys/dev/sbus/esp_sbus.c index 122836b143db..114d52b59b8e 100644 --- a/sys/dev/sbus/esp_sbus.c +++ b/sys/dev/sbus/esp_sbus.c @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: esp_sbus.c,v 1.56 2021/02/23 07:13:53 mrg Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include #include diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c index 890e9b9486fa..cbf11d607d02 100644 --- a/sys/dev/wscons/wsmux.c +++ b/sys/dev/wscons/wsmux.c @@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.65 2021/11/10 16:57:39 msaitoh Exp $"); #include #include #include +#include /* XXX autoconf abuse */ #include "opt_wsdisplay_compat.h" diff --git a/sys/kern/kern_pmf.c b/sys/kern/kern_pmf.c index d47939a5a631..119bd0645df5 100644 --- a/sys/kern/kern_pmf.c +++ b/sys/kern/kern_pmf.c @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.47 2021/07/01 22:08:13 blymn Exp $"); #include #include #include +#include #include #include #include diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 5c1c865785f8..8683ccdbd9e1 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.296 2022/03/12 19:26:33 riastrad #include #include +#include #include #include #include diff --git a/sys/kern/subr_device.c b/sys/kern/subr_device.c index 412d0353db8b..2e9aa0b93f8c 100644 --- a/sys/kern/subr_device.c +++ b/sys/kern/subr_device.c @@ -31,6 +31,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_device.c,v 1.12 2022/03/03 06:25:46 riastradh E #include #include +#include #include #include diff --git a/sys/rump/librump/rumpkern/rump.c b/sys/rump/librump/rumpkern/rump.c index c36015ed3445..12dff1c95fbd 100644 --- a/sys/rump/librump/rumpkern/rump.c +++ b/sys/rump/librump/rumpkern/rump.c @@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.353 2021/01/17 22:32:25 chs Exp $"); #include #include #include +#include #include #include #include diff --git a/sys/sys/device.h b/sys/sys/device.h index cfd324a1ac2d..87d1de5511e3 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -255,72 +255,13 @@ struct devhandle_impl { /* Max size of a device external name (including terminating NUL) */ #define DEVICE_XNAME_SIZE 16 -struct device { - devhandle_t dv_handle; /* this device's handle; - new device_t's get INVALID */ - devclass_t dv_class; /* this device's classification */ - TAILQ_ENTRY(device) dv_list; /* entry on list of all devices */ - cfdata_t dv_cfdata; /* config data that found us - (NULL if pseudo-device) */ - cfdriver_t dv_cfdriver; /* our cfdriver */ - cfattach_t dv_cfattach; /* our cfattach */ - int dv_unit; /* device unit number */ - /* external name (name + unit) */ - char dv_xname[DEVICE_XNAME_SIZE]; - device_t dv_parent; /* pointer to parent device - (NULL if pseudo- or root node) */ - int dv_depth; /* number of parents until root */ - int dv_flags; /* misc. flags; see below */ - void *dv_private; /* this device's private storage */ - int *dv_locators; /* our actual locators (optional) */ - prop_dictionary_t dv_properties;/* properties dictionary */ - struct localcount *dv_localcount;/* reference count */ - - int dv_pending; /* config_pending count */ - TAILQ_ENTRY(device) dv_pending_list; - - struct lwp *dv_attaching; /* thread not yet finished in attach */ - struct lwp *dv_detaching; /* detach lock (config_misc_lock/cv) */ - bool dv_detached; /* config_misc_lock */ - - size_t dv_activity_count; - void (**dv_activity_handlers)(device_t, devactive_t); - - bool (*dv_driver_suspend)(device_t, const pmf_qual_t *); - bool (*dv_driver_resume)(device_t, const pmf_qual_t *); - bool (*dv_driver_shutdown)(device_t, int); - bool (*dv_driver_child_register)(device_t); - - void *dv_bus_private; - bool (*dv_bus_suspend)(device_t, const pmf_qual_t *); - bool (*dv_bus_resume)(device_t, const pmf_qual_t *); - bool (*dv_bus_shutdown)(device_t, int); - void (*dv_bus_deregister)(device_t); - - void *dv_class_private; - bool (*dv_class_suspend)(device_t, const pmf_qual_t *); - bool (*dv_class_resume)(device_t, const pmf_qual_t *); - void (*dv_class_deregister)(device_t); - - devgen_t dv_add_gen, - dv_del_gen; - - struct device_lock dv_lock; - const device_suspensor_t - *dv_bus_suspensors[DEVICE_SUSPENSORS_MAX], - *dv_driver_suspensors[DEVICE_SUSPENSORS_MAX], - *dv_class_suspensors[DEVICE_SUSPENSORS_MAX]; - struct device_garbage dv_garbage; -}; +struct device; -/* dv_flags */ -#define DVF_ACTIVE 0x0001 /* device is activated */ +/* + * struct cfattach::ca_flags (must not overlap with device_impl.h + * struct device::dv_flags for now) + */ #define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */ -#define DVF_POWER_HANDLERS 0x0004 /* device has suspend/resume support */ -#define DVF_CLASS_SUSPENDED 0x0008 /* device class suspend was called */ -#define DVF_DRIVER_SUSPENDED 0x0010 /* device driver suspend was called */ -#define DVF_BUS_SUSPENDED 0x0020 /* device bus suspend was called */ -#define DVF_ATTACH_INPROGRESS 0x0040 /* device attach is in progress */ #define DVF_DETACH_SHUTDOWN 0x0080 /* device detaches safely at shutdown */ #ifdef _KERNEL diff --git a/sys/sys/device_impl.h b/sys/sys/device_impl.h new file mode 100644 index 000000000000..9bc395845a89 --- /dev/null +++ b/sys/sys/device_impl.h @@ -0,0 +1,183 @@ +/* $NetBSD$ */ + +/* + * Copyright (c) 2022 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1996, 2000 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )-- + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratories. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)device.h 8.2 (Berkeley) 2/17/94 + */ + +#ifndef _SYS_DEVICE_IMPL_H_ +#define _SYS_DEVICE_IMPL_H_ + +/* + * Private autoconf-internal device structures. + * + * DO NOT USE outside autoconf internals. + */ + +#include + +struct device { + devhandle_t dv_handle; /* this device's handle; + new device_t's get INVALID */ + devclass_t dv_class; /* this device's classification */ + TAILQ_ENTRY(device) dv_list; /* entry on list of all devices */ + cfdata_t dv_cfdata; /* config data that found us + (NULL if pseudo-device) */ + cfdriver_t dv_cfdriver; /* our cfdriver */ + cfattach_t dv_cfattach; /* our cfattach */ + int dv_unit; /* device unit number */ + /* external name (name + unit) */ + char dv_xname[DEVICE_XNAME_SIZE]; + device_t dv_parent; /* pointer to parent device + (NULL if pseudo- or root node) */ + int dv_depth; /* number of parents until root */ + int dv_flags; /* misc. flags; see below */ + void *dv_private; /* this device's private storage */ + int *dv_locators; /* our actual locators (optional) */ + prop_dictionary_t dv_properties;/* properties dictionary */ + struct localcount *dv_localcount;/* reference count */ + + int dv_pending; /* config_pending count */ + TAILQ_ENTRY(device) dv_pending_list; + + struct lwp *dv_attaching; /* thread not yet finished in attach */ + struct lwp *dv_detaching; /* detach lock (config_misc_lock/cv) */ + bool dv_detached; /* config_misc_lock */ + + size_t dv_activity_count; + void (**dv_activity_handlers)(device_t, devactive_t); + + bool (*dv_driver_suspend)(device_t, const pmf_qual_t *); + bool (*dv_driver_resume)(device_t, const pmf_qual_t *); + bool (*dv_driver_shutdown)(device_t, int); + bool (*dv_driver_child_register)(device_t); + + void *dv_bus_private; + bool (*dv_bus_suspend)(device_t, const pmf_qual_t *); + bool (*dv_bus_resume)(device_t, const pmf_qual_t *); + bool (*dv_bus_shutdown)(device_t, int); + void (*dv_bus_deregister)(device_t); + + void *dv_class_private; + bool (*dv_class_suspend)(device_t, const pmf_qual_t *); + bool (*dv_class_resume)(device_t, const pmf_qual_t *); + void (*dv_class_deregister)(device_t); + + devgen_t dv_add_gen, + dv_del_gen; + + struct device_lock dv_lock; + const device_suspensor_t + *dv_bus_suspensors[DEVICE_SUSPENSORS_MAX], + *dv_driver_suspensors[DEVICE_SUSPENSORS_MAX], + *dv_class_suspensors[DEVICE_SUSPENSORS_MAX]; + struct device_garbage dv_garbage; +}; + +/* + * struct device::dv_flags (must not overlap with device.h struct + * cfattach::ca_flags for now) + */ +#define DVF_ACTIVE 0x0001 /* device is activated */ +#define DVF_POWER_HANDLERS 0x0004 /* device has suspend/resume support */ +#define DVF_CLASS_SUSPENDED 0x0008 /* device class suspend was called */ +#define DVF_DRIVER_SUSPENDED 0x0010 /* device driver suspend was called */ +#define DVF_BUS_SUSPENDED 0x0020 /* device bus suspend was called */ +#define DVF_ATTACH_INPROGRESS 0x0040 /* device attach is in progress */ + +#endif /* _SYS_DEVICE_IMPL_H_ */