Home | History | Annotate | Line # | Download | only in dev
cons.h revision 1.20.2.4
      1  1.20.2.4    skrll /*	$NetBSD: cons.h,v 1.20.2.4 2005/02/04 11:45:09 skrll Exp $	*/
      2       1.6      cgd 
      3       1.1      cgd /*
      4       1.5      cgd  * Copyright (c) 1990, 1993
      5       1.5      cgd  *	The Regents of the University of California.  All rights reserved.
      6       1.1      cgd  *
      7       1.1      cgd  * This code is derived from software contributed to Berkeley by
      8       1.1      cgd  * the Systems Programming Group of the University of Utah Computer
      9       1.1      cgd  * Science Department.
     10       1.1      cgd  *
     11       1.1      cgd  * Redistribution and use in source and binary forms, with or without
     12       1.1      cgd  * modification, are permitted provided that the following conditions
     13       1.1      cgd  * are met:
     14       1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     15       1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     16       1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     18       1.1      cgd  *    documentation and/or other materials provided with the distribution.
     19  1.20.2.1    skrll  * 3. Neither the name of the University nor the names of its contributors
     20  1.20.2.1    skrll  *    may be used to endorse or promote products derived from this software
     21  1.20.2.1    skrll  *    without specific prior written permission.
     22  1.20.2.1    skrll  *
     23  1.20.2.1    skrll  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.20.2.1    skrll  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.20.2.1    skrll  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.20.2.1    skrll  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.20.2.1    skrll  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.20.2.1    skrll  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.20.2.1    skrll  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.20.2.1    skrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.20.2.1    skrll  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.20.2.1    skrll  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.20.2.1    skrll  * SUCH DAMAGE.
     34  1.20.2.1    skrll  *
     35  1.20.2.1    skrll  * from: Utah $Hdr: cons.h 1.6 92/01/21$
     36  1.20.2.1    skrll  *
     37  1.20.2.1    skrll  *	@(#)cons.h	8.1 (Berkeley) 6/10/93
     38  1.20.2.1    skrll  */
     39  1.20.2.1    skrll 
     40  1.20.2.1    skrll /*
     41  1.20.2.1    skrll  * Copyright (c) 1988 University of Utah.
     42  1.20.2.1    skrll  *
     43  1.20.2.1    skrll  * This code is derived from software contributed to Berkeley by
     44  1.20.2.1    skrll  * the Systems Programming Group of the University of Utah Computer
     45  1.20.2.1    skrll  * Science Department.
     46  1.20.2.1    skrll  *
     47  1.20.2.1    skrll  * Redistribution and use in source and binary forms, with or without
     48  1.20.2.1    skrll  * modification, are permitted provided that the following conditions
     49  1.20.2.1    skrll  * are met:
     50  1.20.2.1    skrll  * 1. Redistributions of source code must retain the above copyright
     51  1.20.2.1    skrll  *    notice, this list of conditions and the following disclaimer.
     52  1.20.2.1    skrll  * 2. Redistributions in binary form must reproduce the above copyright
     53  1.20.2.1    skrll  *    notice, this list of conditions and the following disclaimer in the
     54  1.20.2.1    skrll  *    documentation and/or other materials provided with the distribution.
     55       1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     56       1.1      cgd  *    must display the following acknowledgement:
     57       1.1      cgd  *	This product includes software developed by the University of
     58       1.1      cgd  *	California, Berkeley and its contributors.
     59       1.1      cgd  * 4. Neither the name of the University nor the names of its contributors
     60       1.1      cgd  *    may be used to endorse or promote products derived from this software
     61       1.1      cgd  *    without specific prior written permission.
     62       1.1      cgd  *
     63       1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     64       1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     65       1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     66       1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     67       1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     68       1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     69       1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     70       1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     71       1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     72       1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     73       1.1      cgd  * SUCH DAMAGE.
     74       1.1      cgd  *
     75       1.5      cgd  * from: Utah $Hdr: cons.h 1.6 92/01/21$
     76       1.5      cgd  *
     77       1.5      cgd  *	@(#)cons.h	8.1 (Berkeley) 6/10/93
     78       1.1      cgd  */
     79       1.1      cgd 
     80      1.16   simonb #ifndef _SYS_DEV_CONS_H_
     81      1.16   simonb #define _SYS_DEV_CONS_H_
     82      1.16   simonb 
     83       1.1      cgd struct consdev {
     84      1.10  mycroft 	void	(*cn_probe)	/* probe hardware and fill in consdev info */
     85  1.20.2.4    skrll 		   (struct consdev *);
     86      1.10  mycroft 	void	(*cn_init)	/* turn on as console */
     87  1.20.2.4    skrll 		   (struct consdev *);
     88      1.10  mycroft 	int	(*cn_getc)	/* kernel getchar interface */
     89  1.20.2.4    skrll 		   (dev_t);
     90      1.10  mycroft 	void	(*cn_putc)	/* kernel putchar interface */
     91  1.20.2.4    skrll 		   (dev_t, int);
     92      1.10  mycroft 	void	(*cn_pollc)	/* turn on and off polling */
     93  1.20.2.4    skrll 		   (dev_t, int);
     94      1.17  thorpej 	void	(*cn_bell)	/* ring bell */
     95  1.20.2.4    skrll 		   (dev_t, u_int, u_int, u_int);
     96      1.20     matt 	void	(*cn_halt)	/* stop device */
     97  1.20.2.4    skrll 		   (dev_t);
     98      1.20     matt 	void	(*cn_flush)	/* flush output */
     99  1.20.2.4    skrll 		   (dev_t);
    100       1.1      cgd 	dev_t	cn_dev;		/* major/minor of device */
    101      1.11      gwr 	int	cn_pri;		/* pecking order; the higher the better */
    102       1.1      cgd };
    103       1.1      cgd 
    104       1.1      cgd /* values for cn_pri - reflect our policy for console selection */
    105       1.1      cgd #define	CN_DEAD		0	/* device doesn't exist */
    106  1.20.2.1    skrll #define CN_NULL		1	/* noop console */
    107  1.20.2.1    skrll #define CN_NORMAL	2	/* device exists but is nothing special */
    108  1.20.2.1    skrll #define CN_INTERNAL	3	/* "internal" bit-mapped display */
    109  1.20.2.1    skrll #define CN_REMOTE	4	/* serial interface with remote bit set */
    110       1.1      cgd 
    111       1.9      jtc #ifdef _KERNEL
    112      1.10  mycroft 
    113       1.1      cgd extern	struct consdev constab[];
    114       1.1      cgd extern	struct consdev *cn_tab;
    115       1.8      cgd 
    116  1.20.2.4    skrll void	cninit(void);
    117  1.20.2.4    skrll int	cngetc(void);
    118  1.20.2.4    skrll int	cngetsn(char *, int);
    119  1.20.2.4    skrll void	cnputc(int);
    120  1.20.2.4    skrll void	cnpollc(int);
    121  1.20.2.4    skrll void	cnbell(u_int, u_int, u_int);
    122  1.20.2.4    skrll void	cnflush(void);
    123  1.20.2.4    skrll void	cnhalt(void);
    124  1.20.2.4    skrll void	cnrint(void);
    125  1.20.2.4    skrll void	nullcnprobe(struct consdev *);
    126  1.20.2.4    skrll void	nullcninit(struct consdev *);
    127  1.20.2.4    skrll void	nullcnpollc(dev_t, int);
    128  1.20.2.4    skrll void	nullconsattach(int);
    129      1.10  mycroft 
    130      1.10  mycroft /* console-specific types */
    131  1.20.2.4    skrll #define	dev_type_cnprobe(n)	void n(struct consdev *)
    132  1.20.2.4    skrll #define	dev_type_cninit(n)	void n(struct consdev *)
    133  1.20.2.4    skrll #define	dev_type_cngetc(n)	int n(dev_t)
    134  1.20.2.4    skrll #define	dev_type_cnputc(n)	void n(dev_t, int)
    135  1.20.2.4    skrll #define	dev_type_cnpollc(n)	void n(dev_t, int)
    136  1.20.2.4    skrll #define	dev_type_cnbell(n)	void n(dev_t, u_int, u_int, u_int);
    137  1.20.2.4    skrll #define	dev_type_cnhalt(n)	void n(dev_t)
    138  1.20.2.4    skrll #define	dev_type_cnflush(n)	void n(dev_t)
    139      1.10  mycroft 
    140      1.19  gehenna #define	dev_decl(n,t)		__CONCAT(dev_type_,t)(__CONCAT(n,t))
    141      1.19  gehenna #define	dev_init(n,t)		__CONCAT(n,t)
    142      1.19  gehenna 
    143      1.10  mycroft #define	cons_decl(n) \
    144      1.10  mycroft 	dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
    145      1.20     matt 	dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell); \
    146      1.20     matt 	dev_decl(n,cnflush); dev_decl(n,cnhalt);
    147      1.10  mycroft 
    148      1.10  mycroft #define	cons_init(n) { \
    149      1.19  gehenna 	dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
    150      1.19  gehenna 	dev_init(n,cnputc), dev_init(n,cnpollc) }
    151      1.17  thorpej 
    152      1.17  thorpej #define	cons_init_bell(n) { \
    153      1.19  gehenna 	dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
    154      1.19  gehenna 	dev_init(n,cnputc), dev_init(n,cnpollc), dev_init(n,cnbell) }
    155      1.20     matt 
    156      1.20     matt #define	cons_init_halt(n) { \
    157      1.20     matt 	dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
    158      1.20     matt 	dev_init(n,cnputc), dev_init(n,cnpollc), 0,	             \
    159      1.20     matt 	dev_init(n,cnhalt) }
    160      1.10  mycroft 
    161       1.1      cgd #endif
    162      1.16   simonb 
    163      1.16   simonb #endif /* _SYS_DEV_CONS_H_ */
    164