Change the kernel dev_t, representing a pointer to a specinfo structure,
[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 $
b13267a5 40 * $DragonFly: src/sys/sys/conf.h,v 1.14 2006/09/10 01:26:40 dillon Exp $
984263bc
MD
41 */
42
43#ifndef _SYS_CONF_H_
44#define _SYS_CONF_H_
45
46#include <sys/queue.h>
d8869c1b 47#include <sys/time.h>
81b5c339 48#include <sys/biotrack.h>
984263bc
MD
49
50#define SPECNAMELEN 15
51
52struct tty;
53struct disk;
54struct vnode;
fef8985e 55struct dev_ops;
984263bc 56
0de08e6d 57struct cdev {
984263bc 58 u_int si_flags;
984263bc 59 udev_t si_udev;
0de08e6d 60 LIST_ENTRY(cdev) si_hash;
984263bc
MD
61 SLIST_HEAD(, vnode) si_hlist;
62 char si_name[SPECNAMELEN + 1];
fabb8ceb
MD
63 void *si_drv1;
64 void *si_drv2;
fef8985e 65 struct dev_ops *si_ops; /* device operations vector */
984263bc 66 int si_iosize_max; /* maximum I/O size (for physio &al) */
e4c9c0c8 67 int si_refs;
984263bc
MD
68 union {
69 struct {
70 struct tty *__sit_tty;
71 } __si_tty;
72 struct {
73 struct disk *__sid_disk;
74 struct mount *__sid_mountpoint;
75 int __sid_bsize_phys; /* min physical block size */
76 int __sid_bsize_best; /* optimal block size */
77 } __si_disk;
78 } __si_u;
81b5c339
MD
79 struct bio_track si_track_read;
80 struct bio_track si_track_write;
d8869c1b
MD
81 time_t si_lastread; /* time_second */
82 time_t si_lastwrite; /* time_second */
984263bc
MD
83};
84
fabb8ceb 85#define SI_STASHED 0x0001 /* created in stashed storage */
e4c9c0c8
MD
86#define SI_HASHED 0x0002 /* in (maj,min) hash table */
87#define SI_ADHOC 0x0004 /* created via make_adhoc_dev() or udev2dev() */
fabb8ceb 88
984263bc
MD
89#define si_tty __si_u.__si_tty.__sit_tty
90#define si_disk __si_u.__si_disk.__sid_disk
91#define si_mountpoint __si_u.__si_disk.__sid_mountpoint
92#define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
93#define si_bsize_best __si_u.__si_disk.__sid_bsize_best
94
e4c9c0c8 95#define CDEVSW_ALL_MINORS 0 /* mask of 0 always matches 0 */
984263bc
MD
96
97/*
98 * Special device management
99 */
100#define SPECHSZ 64
101#define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
102
103/*
104 * Definitions of device driver entry switches
105 */
106
107struct buf;
81b5c339 108struct bio;
984263bc
MD
109struct proc;
110struct uio;
111struct knote;
fef8985e 112struct ucred;
984263bc 113
41c20dac 114struct thread;
335dda38 115
b13267a5 116typedef int l_open_t (struct cdev *dev, struct tty *tp);
335dda38
MD
117typedef int l_close_t (struct tty *tp, int flag);
118typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
119typedef int l_write_t (struct tty *tp, struct uio *uio, int flag);
fef8985e
MD
120typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, int flag,
121 struct ucred *cred);
335dda38
MD
122typedef int l_rint_t (int c, struct tty *tp);
123typedef int l_start_t (struct tty *tp);
124typedef int l_modem_t (struct tty *tp, int flag);
984263bc 125
984263bc
MD
126/*
127 * Line discipline switch table
128 */
129struct linesw {
130 l_open_t *l_open;
131 l_close_t *l_close;
132 l_read_t *l_read;
133 l_write_t *l_write;
134 l_ioctl_t *l_ioctl;
135 l_rint_t *l_rint;
136 l_start_t *l_start;
137 l_modem_t *l_modem;
138 u_char l_hotchar;
139};
140
141#ifdef _KERNEL
142extern struct linesw linesw[];
143extern int nlinesw;
144
335dda38
MD
145int ldisc_register (int , struct linesw *);
146void ldisc_deregister (int);
984263bc
MD
147#define LDISC_LOAD -1 /* Loadable line discipline */
148#endif
149
150/*
151 * Swap device table
152 */
153struct swdevt {
154 udev_t sw_dev; /* For quasibogus swapdev reporting */
155 int sw_flags;
156 int sw_nblks;
157 struct vnode *sw_vp;
b13267a5 158 struct cdev *sw_device;
984263bc
MD
159};
160#define SW_FREED 0x01
161#define SW_SEQUENTIAL 0x02
162#define sw_freed sw_flags /* XXX compat */
163
164#ifdef _KERNEL
984263bc
MD
165
166#define NUMCDEVSW 256
167
984263bc
MD
168l_ioctl_t l_nullioctl;
169l_read_t l_noread;
170l_write_t l_nowrite;
171
172struct module;
173
174struct devsw_module_data {
175 int (*chainevh)(struct module *, int, void *); /* next handler */
176 void *chainarg; /* arg for next event handler */
177 /* Do not initialize fields hereafter */
178};
179
180#define DEV_MODULE(name, evh, arg) \
181static moduledata_t name##_mod = { \
182 #name, \
183 evh, \
184 arg \
185}; \
186DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
187
b13267a5 188int count_dev (cdev_t dev);
e4c9c0c8 189int count_udev (udev_t dev);
b13267a5
MD
190void destroy_dev (cdev_t dev);
191void release_dev (cdev_t dev);
192cdev_t reference_dev (cdev_t dev);
193struct dev_ops *devsw (cdev_t dev);
194const char *devtoname (cdev_t dev);
195void freedev (cdev_t dev);
196int iszerodev (cdev_t dev);
197
198cdev_t make_sub_dev (cdev_t dev, int minor);
199int lminor (cdev_t dev);
335dda38 200void setconf (void);
b13267a5
MD
201cdev_t kgetdiskbyname(const char *name);
202int dev_is_good(cdev_t dev);
984263bc
MD
203
204/*
205 * XXX: This included for when DEVFS resurfaces
206 */
207
208#define UID_ROOT 0
209#define UID_BIN 3
210#define UID_UUCP 66
211
212#define GID_WHEEL 0
213#define GID_KMEM 2
214#define GID_OPERATOR 5
215#define GID_BIN 7
216#define GID_GAMES 13
217#define GID_DIALER 68
218
219#endif /* _KERNEL */
220
221#endif /* !_SYS_CONF_H_ */