]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/bus_private.h
This commit was generated by cvs2svn to compensate for changes in r66494,
[FreeBSD/FreeBSD.git] / sys / sys / bus_private.h
1 /*-
2  * Copyright (c) 1997,1998 Doug Rabson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _SYS_BUS_PRIVATE_H_
30 #define _SYS_BUS_PRIVATE_H_
31
32 #include <sys/bus.h>
33
34 /*
35  * Used to attach drivers to devclasses.
36  */
37 typedef struct driverlink *driverlink_t;
38 struct driverlink {
39     driver_t            *driver;
40     TAILQ_ENTRY(driverlink) link; /* list of drivers in devclass */
41 };
42
43 /*
44  * Forward declarations
45  */
46 typedef TAILQ_HEAD(devclass_list, devclass) devclass_list_t;
47 typedef TAILQ_HEAD(driver_list, driverlink) driver_list_t;
48 typedef TAILQ_HEAD(device_list, device) device_list_t;
49
50 struct devclass {
51     TAILQ_ENTRY(devclass) link;
52     driver_list_t       drivers; /* bus devclasses store drivers for bus */
53     char                *name;
54     device_t            *devices; /* array of devices indexed by unit */
55     int                 maxunit; /* size of devices array */
56 };
57
58 /*
59  * Resources from config(8).
60  */
61 typedef enum {
62     RES_INT, RES_STRING, RES_LONG
63 } resource_type;
64
65 struct config_resource {
66     char                *name;
67     resource_type       type;
68     union {
69         long            longval;
70         int             intval;
71         char*           stringval;
72     } u;
73 };
74
75 struct config_device {
76     char                *name;  /* e.g. "lpt", "wdc" etc */
77     int                 unit;
78     int                 resource_count;
79     struct config_resource      *resources;
80 };
81
82 /*
83  * Implementation of device.
84  */
85 struct device {
86     /*
87      * A device is a kernel object. The first field must be the
88      * current ops table for the object.
89      */
90     KOBJ_FIELDS;
91
92     /*
93      * Device hierarchy.
94      */
95     TAILQ_ENTRY(device) link;   /* list of devices in parent */
96     device_t            parent;
97     device_list_t       children; /* list of subordinate devices */
98
99     /*
100      * Details of this device.
101      */
102     driver_t            *driver;
103     devclass_t          devclass; /* device class which we are in */
104     int                 unit;
105     char*               nameunit; /* name+unit e.g. foodev0 */
106     char*               desc;   /* driver specific description */
107     int                 busy;   /* count of calls to device_busy() */
108     device_state_t      state;
109     u_int32_t           devflags; /* api level flags for device_get_flags() */
110     u_short             flags;
111 #define DF_ENABLED      1       /* device should be probed/attached */
112 #define DF_FIXEDCLASS   2       /* devclass specified at create time */
113 #define DF_WILDCARD     4       /* unit was originally wildcard */
114 #define DF_DESCMALLOCED 8       /* description was malloced */
115 #define DF_QUIET        16      /* don't print verbose attach message */
116 #define DF_DONENOMATCH  32      /* don't execute DEVICE_NOMATCH again */
117 #define DF_EXTERNALSOFTC 64     /* softc not allocated by us */
118     u_char              order;  /* order from device_add_child_ordered() */
119     u_char              pad;
120 #ifdef DEVICE_SYSCTLS
121     struct sysctl_oid   oid[4];
122     struct sysctl_oid_list oidlist[1];
123 #endif
124     void                *ivars;
125     void                *softc;
126 };
127
128 struct device_op_desc {
129     unsigned int        offset; /* offset in driver ops */
130     struct method*      method; /* internal method implementation */
131     devop_t             deflt;  /* default implementation */
132     const char*         name;   /* unique name (for registration) */
133 };
134
135 #endif /* !_SYS_BUS_PRIVATE_H_ */