FreeBSD/Linux Kernel Cross Reference
sys/sys/device.h
1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
9 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
12 * California, Lawrence Berkeley Laboratory.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by the University of
25 * California, Berkeley and its contributors.
26 * 4. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * @(#)device.h 8.2 (Berkeley) 2/17/94
43 * $FreeBSD: src/sys/sys/device.h,v 1.4.4.3 1999/09/05 08:22:06 peter Exp $
44 */
45
46 #ifndef _SYS_DEVICE_H_
47 #define _SYS_DEVICE_H_
48
49 #include <sys/queue.h>
50 /*
51 * Minimal device structures.
52 * Note that all ``system'' device types are listed here.
53 */
54 enum devclass {
55 DV_DULL, /* generic, no special info */
56 DV_CPU, /* CPU (carries resource utilization) */
57 DV_DISK, /* disk drive (label, etc) */
58 DV_IFNET, /* network interface */
59 DV_TAPE, /* tape device */
60 DV_TTY /* serial line interface (?) */
61 };
62
63 struct device {
64 enum devclass dv_class; /* this device's classification */
65 struct device *dv_next; /* next in list of all */
66 struct cfdata *dv_cfdata; /* config data that found us */
67 int dv_unit; /* device unit number */
68 char dv_xname[16]; /* external name (name + unit) */
69 struct device *dv_parent; /* pointer to parent device */
70 };
71
72 /* `event' counters (use zero or more per device instance, as needed) */
73 struct evcnt {
74 struct evcnt *ev_next; /* linked list */
75 struct device *ev_dev; /* associated device */
76 int ev_count; /* how many have occurred */
77 char ev_name[8]; /* what to call them (systat display) */
78 };
79
80 /*
81 * Configuration data (i.e., data placed in ioconf.c).
82 */
83 struct cfdata {
84 struct cfdriver *cf_driver; /* config driver */
85 short cf_unit; /* unit number */
86 short cf_fstate; /* finding state (below) */
87 int *cf_loc; /* locators (machine dependent) */
88 int cf_flags; /* flags from config */
89 short *cf_parents; /* potential parents */
90 void (**cf_ivstubs) __P((void));
91 /* config-generated vectors, if any */
92 };
93 #define FSTATE_NOTFOUND 0 /* has not been found */
94 #define FSTATE_FOUND 1 /* has been found */
95 #define FSTATE_STAR 2 /* duplicable */
96
97 typedef int (*cfmatch_t) __P((struct device *, struct cfdata *, void *));
98
99 /*
100 * `configuration' driver (what the machine-independent autoconf uses).
101 * As devices are found, they are applied against all the potential matches.
102 * The one with the best match is taken, and a device structure (plus any
103 * other data desired) is allocated. Pointers to these are placed into
104 * an array of pointers. The array itself must be dynamic since devices
105 * can be found long after the machine is up and running.
106 */
107 struct cfdriver {
108 void **cd_devs; /* devices found */
109 char *cd_name; /* device name */
110 cfmatch_t cd_match; /* returns a match level */
111 void (*cd_attach) __P((struct device *, struct device *, void *));
112 enum devclass cd_class; /* device classification */
113 size_t cd_devsize; /* size of dev data (for malloc) */
114 void *cd_aux; /* additional driver, if any */
115 int cd_ndevs; /* size of cd_devs array */
116 };
117
118 struct intr_config_hook {
119 TAILQ_ENTRY(intr_config_hook) ich_links;
120 void (*ich_func) __P((void *arg));
121 void *ich_arg;
122 };
123
124 /*
125 * Configuration printing functions, and their return codes. The second
126 * argument is NULL if the device was configured; otherwise it is the name
127 * of the parent device. The return value is ignored if the device was
128 * configured, so most functions can return UNCONF unconditionally.
129 */
130 typedef int (*cfprint_t) __P((void *, char *));
131 #define QUIET 0 /* print nothing */
132 #define UNCONF 1 /* print " not configured\n" */
133 #define UNSUPP 2 /* print " not supported\n" */
134
135 /*
136 * Pseudo-device attach information (function + number of pseudo-devs).
137 */
138 struct pdevinit {
139 void (*pdev_attach) __P((int));
140 int pdev_count;
141 };
142
143 extern struct device *alldevs; /* head of list of all devices */
144 extern struct evcnt *allevents; /* head of list of all events */
145
146 struct cfdata *config_search __P((cfmatch_t, struct device *, void *));
147 struct cfdata *config_rootsearch __P((cfmatch_t, char *, void *));
148 int config_found __P((struct device *, void *, cfprint_t));
149 int config_rootfound __P((char *, void *));
150 void config_attach __P((struct device *, struct cfdata *, void *, cfprint_t));
151 void evcnt_attach __P((struct device *, const char *, struct evcnt *));
152 int config_intrhook_establish __P((struct intr_config_hook *hook));
153 void config_intrhook_disestablish __P((struct intr_config_hook *hook));
154 #endif /* !_SYS_DEVICE_H_ */
Cache object: 29baecb95cdd18011945687ab8fe6035
|