devfs - Change make_dev_covering to use dev_ops
[dragonfly.git] / sys / sys / conf.h
CommitLineData
984263bc
MD
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)conf.h 8.5 (Berkeley) 1/9/95
39 * $FreeBSD: src/sys/sys/conf.h,v 1.103.2.6 2002/03/11 01:14:55 dd Exp $
0e9b9130 40 * $DragonFly: src/sys/sys/conf.h,v 1.18 2007/05/09 00:53:35 dillon Exp $
984263bc
MD
41 */
42
43#ifndef _SYS_CONF_H_
44#define _SYS_CONF_H_
45
028066b1
MD
46#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
47
48#ifndef _SYS_QUEUE_H_
984263bc 49#include <sys/queue.h>
028066b1
MD
50#endif
51#ifndef _SYS_TIME_H_
d8869c1b 52#include <sys/time.h>
028066b1
MD
53#endif
54#ifndef _SYS_BIOTRACK_H_
81b5c339 55#include <sys/biotrack.h>
028066b1 56#endif
ce81f184
MD
57#ifndef _SYS_SYSREF_H_
58#include <sys/sysref.h>
59#endif
984263bc
MD
60
61#define SPECNAMELEN 15
62
63struct tty;
64struct disk;
65struct vnode;
fef8985e 66struct dev_ops;
984263bc 67
0de08e6d 68struct cdev {
984263bc 69 u_int si_flags;
cd29885a 70 __uint64_t si_inode;
4062d050
MD
71 uid_t si_uid;
72 gid_t si_gid;
cd29885a 73 int si_perms;
cd65363e 74 TAILQ_ENTRY(cdev) link;
0e9b9130
MD
75 int si_uminor;
76 int si_umajor;
0de08e6d 77 LIST_ENTRY(cdev) si_hash;
984263bc
MD
78 SLIST_HEAD(, vnode) si_hlist;
79 char si_name[SPECNAMELEN + 1];
fabb8ceb
MD
80 void *si_drv1;
81 void *si_drv2;
fef8985e 82 struct dev_ops *si_ops; /* device operations vector */
b17f0c0d 83 struct dev_ops *si_bops; /* backing devops vector */
984263bc 84 int si_iosize_max; /* maximum I/O size (for physio &al) */
ce81f184 85 struct sysref si_sysref;
984263bc
MD
86 union {
87 struct {
88 struct tty *__sit_tty;
89 } __si_tty;
90 struct {
91 struct disk *__sid_disk;
92 struct mount *__sid_mountpoint;
93 int __sid_bsize_phys; /* min physical block size */
94 int __sid_bsize_best; /* optimal block size */
95 } __si_disk;
96 } __si_u;
81b5c339
MD
97 struct bio_track si_track_read;
98 struct bio_track si_track_write;
d8869c1b
MD
99 time_t si_lastread; /* time_second */
100 time_t si_lastwrite; /* time_second */
984263bc
MD
101};
102
028066b1 103#define SI_UNUSED01 0x0001
e4c9c0c8 104#define SI_HASHED 0x0002 /* in (maj,min) hash table */
4062d050 105#define SI_OVERRIDE 0x0004 /* override uid, gid, and perms */
a13d2b31 106#define SI_INTERCEPTED 0x0008 /* device ops was intercepted */
cd29885a 107#define SI_DEVFS_LINKED 0x0010
aec8eea4 108#define SI_REPROBE_TEST 0x0020
fabb8ceb 109
984263bc
MD
110#define si_tty __si_u.__si_tty.__sit_tty
111#define si_disk __si_u.__si_disk.__sid_disk
112#define si_mountpoint __si_u.__si_disk.__sid_mountpoint
113#define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
114#define si_bsize_best __si_u.__si_disk.__sid_bsize_best
115
e4c9c0c8 116#define CDEVSW_ALL_MINORS 0 /* mask of 0 always matches 0 */
984263bc
MD
117
118/*
119 * Special device management
120 */
121#define SPECHSZ 64
122#define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
123
124/*
125 * Definitions of device driver entry switches
126 */
127
128struct buf;
81b5c339 129struct bio;
984263bc
MD
130struct proc;
131struct uio;
132struct knote;
fef8985e 133struct ucred;
984263bc 134
41c20dac 135struct thread;
335dda38 136
b13267a5 137typedef int l_open_t (struct cdev *dev, struct tty *tp);
335dda38
MD
138typedef int l_close_t (struct tty *tp, int flag);
139typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
140typedef int l_write_t (struct tty *tp, struct uio *uio, int flag);
fef8985e
MD
141typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, int flag,
142 struct ucred *cred);
335dda38
MD
143typedef int l_rint_t (int c, struct tty *tp);
144typedef int l_start_t (struct tty *tp);
145typedef int l_modem_t (struct tty *tp, int flag);
984263bc
MD
146
147/*
984263bc
MD
148 * Line discipline switch table
149 */
150struct linesw {
151 l_open_t *l_open;
152 l_close_t *l_close;
153 l_read_t *l_read;
154 l_write_t *l_write;
155 l_ioctl_t *l_ioctl;
156 l_rint_t *l_rint;
157 l_start_t *l_start;
158 l_modem_t *l_modem;
159 u_char l_hotchar;
160};
161
162#ifdef _KERNEL
163extern struct linesw linesw[];
164extern int nlinesw;
165
335dda38
MD
166int ldisc_register (int , struct linesw *);
167void ldisc_deregister (int);
984263bc
MD
168#define LDISC_LOAD -1 /* Loadable line discipline */
169#endif
170
171/*
172 * Swap device table
173 */
174struct swdevt {
175 udev_t sw_dev; /* For quasibogus swapdev reporting */
176 int sw_flags;
177 int sw_nblks;
178 struct vnode *sw_vp;
b13267a5 179 struct cdev *sw_device;
984263bc
MD
180};
181#define SW_FREED 0x01
182#define SW_SEQUENTIAL 0x02
183#define sw_freed sw_flags /* XXX compat */
184
185#ifdef _KERNEL
984263bc 186
984263bc
MD
187l_ioctl_t l_nullioctl;
188l_read_t l_noread;
189l_write_t l_nowrite;
190
191struct module;
192
193struct devsw_module_data {
194 int (*chainevh)(struct module *, int, void *); /* next handler */
195 void *chainarg; /* arg for next event handler */
196 /* Do not initialize fields hereafter */
197};
198
199#define DEV_MODULE(name, evh, arg) \
200static moduledata_t name##_mod = { \
201 #name, \
202 evh, \
203 arg \
204}; \
205DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
206
b13267a5 207int count_dev (cdev_t dev);
b13267a5
MD
208void destroy_dev (cdev_t dev);
209void release_dev (cdev_t dev);
0e9b9130 210cdev_t get_dev (int x, int y);
b13267a5
MD
211cdev_t reference_dev (cdev_t dev);
212struct dev_ops *devsw (cdev_t dev);
213const char *devtoname (cdev_t dev);
214void freedev (cdev_t dev);
215int iszerodev (cdev_t dev);
216
b13267a5 217int lminor (cdev_t dev);
335dda38 218void setconf (void);
b13267a5
MD
219cdev_t kgetdiskbyname(const char *name);
220int dev_is_good(cdev_t dev);
984263bc
MD
221
222/*
223 * XXX: This included for when DEVFS resurfaces
224 */
225
226#define UID_ROOT 0
227#define UID_BIN 3
228#define UID_UUCP 66
229
230#define GID_WHEEL 0
231#define GID_KMEM 2
deea7076 232#define GID_TTY 4
984263bc
MD
233#define GID_OPERATOR 5
234#define GID_BIN 7
235#define GID_GAMES 13
236#define GID_DIALER 68
237
238#endif /* _KERNEL */
028066b1 239#endif /* _KERNEL || _KERNEL_STRUCTURES */
984263bc
MD
240
241#endif /* !_SYS_CONF_H_ */