PageRenderTime 50ms CodeModel.GetById 9ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 1ms

/sys/conf.h

http://rtems-atapi.googlecode.com/
C++ Header | 255 lines | 166 code | 34 blank | 55 comment | 0 complexity | a3ed8353a795aacc92c3f2280cd3a7a4 MD5 | raw file
  1/*	$NetBSD: conf.h,v 1.131.8.1 2009/06/23 06:56:51 snj Exp $	*/
  2
  3/*-
  4 * Copyright (c) 1990, 1993
  5 *	The Regents of the University of California.  All rights reserved.
  6 * (c) UNIX System Laboratories, Inc.
  7 * All or some portions of this file are derived from material licensed
  8 * to the University of California by American Telephone and Telegraph
  9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
 10 * the permission of UNIX System Laboratories, Inc.
 11 *
 12 * Redistribution and use in source and binary forms, with or without
 13 * modification, are permitted provided that the following conditions
 14 * are met:
 15 * 1. Redistributions of source code must retain the above copyright
 16 *    notice, this list of conditions and the following disclaimer.
 17 * 2. Redistributions in binary form must reproduce the above copyright
 18 *    notice, this list of conditions and the following disclaimer in the
 19 *    documentation and/or other materials provided with the distribution.
 20 * 3. Neither the name of the University nor the names of its contributors
 21 *    may be used to endorse or promote products derived from this software
 22 *    without specific prior written permission.
 23 *
 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 27 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 34 * SUCH DAMAGE.
 35 *
 36 *	@(#)conf.h	8.5 (Berkeley) 1/9/95
 37 */
 38
 39#ifndef _SYS_CONF_H_
 40#define _SYS_CONF_H_
 41
 42/*from kern/sys_generic.c -cdcs*/ 
 43int seltrue(__unused dev_t dev, __unused int flag, __unused struct proc *p); /*Return 0;*/
 44int enodev(void); /*Return ENODEV;*/
 45
 46/*
 47 * Definitions of device driver entry switches
 48 */
 49
 50#include <rtems/bsd/sys/queue.h>
 51
 52struct buf;
 53struct knote;
 54struct lwp;
 55struct tty;
 56struct uio;
 57struct vnode;
 58
 59/*
 60 * Types for d_type
 61 */
 62#define D_OTHER		0x0000
 63#define	D_TAPE		0x0001
 64#define	D_DISK		0x0002
 65#define	D_TTY		0x0003
 66#define	D_TYPEMASK	0x00ff
 67#define	D_MPSAFE	0x0100
 68#define	D_NEGOFFSAFE	0x0200
 69
 70/*
 71 * Block device switch table
 72 */
 73struct bdevsw {
 74	int		(*d_open)(dev_t, int, int, struct lwp *);
 75	int		(*d_close)(dev_t, int, int, struct lwp *);
 76	void		(*d_strategy)(struct buf *);
 77	int		(*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
 78	int		(*d_dump)(dev_t, daddr_t, void *, size_t);
 79	int		(*d_psize)(dev_t);
 80	int		d_flag;
 81};
 82
 83/*
 84 * Character device switch table
 85 */
 86struct cdevsw {
 87	int		(*d_open)(dev_t, int, int, struct lwp *);
 88	int		(*d_close)(dev_t, int, int, struct lwp *);
 89	int		(*d_read)(dev_t, struct uio *, int);
 90	int		(*d_write)(dev_t, struct uio *, int);
 91	int		(*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
 92	void		(*d_stop)(struct tty *, int);
 93	struct tty *	(*d_tty)(dev_t);
 94	int		(*d_poll)(dev_t, int, struct lwp *);
 95	paddr_t		(*d_mmap)(dev_t, off_t, int);
 96	int		(*d_kqfilter)(dev_t, struct knote *);
 97	int		d_flag;
 98};
 99
100#ifdef _KERNEL
101
102int devsw_attach(const char *, const struct bdevsw *, int *,
103		 const struct cdevsw *, int *);
104int devsw_detach(const struct bdevsw *, const struct cdevsw *);
105const struct bdevsw *bdevsw_lookup(dev_t);
106const struct cdevsw *cdevsw_lookup(dev_t);
107int bdevsw_lookup_major(const struct bdevsw *);
108int cdevsw_lookup_major(const struct cdevsw *);
109
110#define	dev_type_open(n)	int n (dev_t, int, int, struct lwp *)
111#define	dev_type_close(n)	int n (dev_t, int, int, struct lwp *)
112#define	dev_type_read(n)	int n (dev_t, struct uio *, int)
113#define	dev_type_write(n)	int n (dev_t, struct uio *, int)
114#define	dev_type_ioctl(n) \
115		int n (dev_t, u_long, void *, int, struct lwp *)
116#define	dev_type_stop(n)	void n (struct tty *, int)
117#define	dev_type_tty(n)		struct tty * n (dev_t)
118#define	dev_type_poll(n)	int n (dev_t, int, struct lwp *)
119#define	dev_type_mmap(n)	paddr_t n (dev_t, off_t, int)
120#define	dev_type_strategy(n)	void n (struct buf *)
121#define	dev_type_dump(n)	int n (dev_t, daddr_t, void *, size_t)
122#define	dev_type_size(n)	int n (dev_t)
123#define	dev_type_kqfilter(n)	int n (dev_t, struct knote *)
124
125#define	noopen		((dev_type_open((*)))enodev)
126#define	noclose		((dev_type_close((*)))enodev)
127#define	noread		((dev_type_read((*)))enodev)
128#define	nowrite		((dev_type_write((*)))enodev)
129#define	noioctl		((dev_type_ioctl((*)))enodev)
130#define	nostop		((dev_type_stop((*)))enodev)
131#define	notty		NULL
132#define	nopoll		seltrue
133#define	nommap		((dev_type_mmap((*)))enodev)
134#define	nodump		((dev_type_dump((*)))enodev)
135#define	nosize		NULL
136#define	nokqfilter	seltrue_kqfilter
137
138#define	nullopen	((dev_type_open((*)))nullop)
139#define	nullclose	((dev_type_close((*)))nullop)
140#define	nullread	((dev_type_read((*)))nullop)
141#define	nullwrite	((dev_type_write((*)))nullop)
142#define	nullioctl	((dev_type_ioctl((*)))nullop)
143#define	nullstop	((dev_type_stop((*)))nullop)
144#define	nullpoll	((dev_type_poll((*)))nullop)
145#define	nullmmap	((dev_type_mmap((*)))nullop)
146#define	nulldump	((dev_type_dump((*)))nullop)
147#define	nullkqfilter	((dev_type_kqfilter((*)))eopnotsupp)
148
149/* device access wrappers. */
150
151dev_type_open(bdev_open);
152dev_type_close(bdev_close);
153dev_type_strategy(bdev_strategy);
154dev_type_ioctl(bdev_ioctl);
155dev_type_dump(bdev_dump);
156
157dev_type_open(cdev_open);
158dev_type_close(cdev_close);
159dev_type_read(cdev_read);
160dev_type_write(cdev_write);
161dev_type_ioctl(cdev_ioctl);
162dev_type_stop(cdev_stop);
163dev_type_tty(cdev_tty);
164dev_type_poll(cdev_poll);
165dev_type_mmap(cdev_mmap);
166dev_type_kqfilter(cdev_kqfilter);
167
168int	cdev_type(dev_t);
169int	bdev_type(dev_t);
170
171/* symbolic sleep message strings */
172extern	const char devopn[], devio[], devwait[], devin[], devout[];
173extern	const char devioc[], devcls[];
174
175#endif /* _KERNEL */ 
176
177/*
178 * Line discipline switch table
179 */
180struct linesw {
181	const char *l_name;	/* Linesw name */
182
183	LIST_ENTRY(linesw) l_list;
184	u_int	l_refcnt;	/* locked by ttyldisc_list_slock */
185	int	l_no;		/* legacy discipline number (for TIOCGETD) */
186
187	int	(*l_open)	(dev_t, struct tty *);
188	int	(*l_close)	(struct tty *, int);
189	int	(*l_read)	(struct tty *, struct uio *, int);
190	int	(*l_write)	(struct tty *, struct uio *, int);
191	int	(*l_ioctl)	(struct tty *, u_long, void *, int,
192				    struct lwp *);
193	int	(*l_rint)	(int, struct tty *);
194	int	(*l_start)	(struct tty *);
195	int	(*l_modem)	(struct tty *, int);
196	int	(*l_poll)	(struct tty *, int, struct lwp *);
197};
198
199#ifdef _KERNEL
200void	       ttyldisc_init(void);
201int	       ttyldisc_attach(struct linesw *);
202int	       ttyldisc_detach(struct linesw *);
203struct linesw *ttyldisc_lookup(const char *);
204struct linesw *ttyldisc_lookup_bynum(int);
205struct linesw *ttyldisc_default(void);
206void	       ttyldisc_release(struct linesw *);
207
208/* For those defining their own line disciplines: */
209#define	ttynodisc ((int (*)(dev_t, struct tty *))enodev)
210#define	ttyerrclose ((int (*)(struct tty *, int))enodev)
211#define	ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
212#define	ttyerrinput ((int (*)(int, struct tty *))enodev)
213#define	ttyerrstart ((int (*)(struct tty *))enodev)
214
215int	ttyerrpoll (struct tty *, int, struct lwp *);
216int	ttynullioctl(struct tty *, u_long, void *, int, struct lwp *);
217
218int	iskmemdev(dev_t);
219int	seltrue_kqfilter(dev_t, struct knote *);
220#endif
221
222#ifdef _KERNEL
223
224#define	DEV_MEM		0	/* minor device 0 is physical memory */
225#define	DEV_KMEM	1	/* minor device 1 is kernel memory */
226#define	DEV_NULL	2	/* minor device 2 is EOF/rathole */
227#ifdef COMPAT_16
228#define	_DEV_ZERO_oARM	3	/* reserved: old ARM /dev/zero minor */
229#endif
230#define	DEV_ZERO	12	/* minor device 12 is '\0'/rathole */
231
232#endif /* _KERNEL */
233
234struct devsw_conv {
235	const char *d_name;
236	int d_bmajor;
237	int d_cmajor;
238};
239
240#ifdef _KERNEL
241void devsw_init(void);
242const char *devsw_blk2name(int);
243int devsw_name2blk(const char *, char *, size_t);
244int devsw_name2chr(const char *, char *, size_t);
245dev_t devsw_chr2blk(dev_t);
246dev_t devsw_blk2chr(dev_t);
247#endif /* _KERNEL */
248
249#ifdef _KERNEL
250struct	device;
251void	setroot(struct device *, int);
252void	swapconf(void);
253#endif /* _KERNEL */
254
255#endif /* !_SYS_CONF_H_ */