Home | History | Annotate | Line # | Download | only in dev
cons.h revision 1.26
      1  1.26     cube /*	$NetBSD: cons.h,v 1.26 2007/01/13 18:39:35 cube 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.21      agc  *
      7  1.21      agc  * This code is derived from software contributed to Berkeley by
      8  1.21      agc  * the Systems Programming Group of the University of Utah Computer
      9  1.21      agc  * Science Department.
     10  1.21      agc  *
     11  1.21      agc  * Redistribution and use in source and binary forms, with or without
     12  1.21      agc  * modification, are permitted provided that the following conditions
     13  1.21      agc  * are met:
     14  1.21      agc  * 1. Redistributions of source code must retain the above copyright
     15  1.21      agc  *    notice, this list of conditions and the following disclaimer.
     16  1.21      agc  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.21      agc  *    notice, this list of conditions and the following disclaimer in the
     18  1.21      agc  *    documentation and/or other materials provided with the distribution.
     19  1.21      agc  * 3. Neither the name of the University nor the names of its contributors
     20  1.21      agc  *    may be used to endorse or promote products derived from this software
     21  1.21      agc  *    without specific prior written permission.
     22  1.21      agc  *
     23  1.21      agc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.21      agc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.21      agc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.21      agc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.21      agc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.21      agc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.21      agc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.21      agc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.21      agc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.21      agc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.21      agc  * SUCH DAMAGE.
     34  1.21      agc  *
     35  1.21      agc  * from: Utah $Hdr: cons.h 1.6 92/01/21$
     36  1.21      agc  *
     37  1.21      agc  *	@(#)cons.h	8.1 (Berkeley) 6/10/93
     38  1.21      agc  */
     39  1.21      agc 
     40  1.21      agc /*
     41  1.21      agc  * Copyright (c) 1988 University of Utah.
     42   1.1      cgd  *
     43   1.1      cgd  * This code is derived from software contributed to Berkeley by
     44   1.1      cgd  * the Systems Programming Group of the University of Utah Computer
     45   1.1      cgd  * Science Department.
     46   1.1      cgd  *
     47   1.1      cgd  * Redistribution and use in source and binary forms, with or without
     48   1.1      cgd  * modification, are permitted provided that the following conditions
     49   1.1      cgd  * are met:
     50   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     51   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     52   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     53   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     54   1.1      cgd  *    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.23    perry 		   (struct consdev *);
     86  1.10  mycroft 	void	(*cn_init)	/* turn on as console */
     87  1.23    perry 		   (struct consdev *);
     88  1.10  mycroft 	int	(*cn_getc)	/* kernel getchar interface */
     89  1.23    perry 		   (dev_t);
     90  1.10  mycroft 	void	(*cn_putc)	/* kernel putchar interface */
     91  1.23    perry 		   (dev_t, int);
     92  1.10  mycroft 	void	(*cn_pollc)	/* turn on and off polling */
     93  1.23    perry 		   (dev_t, int);
     94  1.17  thorpej 	void	(*cn_bell)	/* ring bell */
     95  1.23    perry 		   (dev_t, u_int, u_int, u_int);
     96  1.20     matt 	void	(*cn_halt)	/* stop device */
     97  1.23    perry 		   (dev_t);
     98  1.20     matt 	void	(*cn_flush)	/* flush output */
     99  1.23    perry 		   (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.22      cdi #define CN_NULL		1	/* noop console */
    107  1.22      cdi #define CN_NORMAL	2	/* device exists but is nothing special */
    108  1.22      cdi #define CN_INTERNAL	3	/* "internal" bit-mapped display */
    109  1.22      cdi #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.23    perry void	cninit(void);
    117  1.23    perry int	cngetc(void);
    118  1.23    perry int	cngetsn(char *, int);
    119  1.23    perry void	cnputc(int);
    120  1.23    perry void	cnpollc(int);
    121  1.23    perry void	cnbell(u_int, u_int, u_int);
    122  1.23    perry void	cnflush(void);
    123  1.23    perry void	cnhalt(void);
    124  1.23    perry void	cnrint(void);
    125  1.23    perry void	nullcnprobe(struct consdev *);
    126  1.23    perry void	nullcninit(struct consdev *);
    127  1.23    perry void	nullcnpollc(dev_t, int);
    128  1.23    perry void	nullconsattach(int);
    129  1.10  mycroft 
    130  1.10  mycroft /* console-specific types */
    131  1.23    perry #define	dev_type_cnprobe(n)	void n(struct consdev *)
    132  1.23    perry #define	dev_type_cninit(n)	void n(struct consdev *)
    133  1.23    perry #define	dev_type_cngetc(n)	int n(dev_t)
    134  1.23    perry #define	dev_type_cnputc(n)	void n(dev_t, int)
    135  1.23    perry #define	dev_type_cnpollc(n)	void n(dev_t, int)
    136  1.25      uwe #define	dev_type_cnbell(n)	void n(dev_t, u_int, u_int, u_int)
    137  1.23    perry #define	dev_type_cnhalt(n)	void n(dev_t)
    138  1.23    perry #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.26     cube 	dev_init(n,cnputc), dev_init(n,cnpollc), NULL, NULL, NULL, \
    151  1.26     cube 	0, 0 }
    152  1.17  thorpej 
    153  1.17  thorpej #define	cons_init_bell(n) { \
    154  1.19  gehenna 	dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
    155  1.19  gehenna 	dev_init(n,cnputc), dev_init(n,cnpollc), dev_init(n,cnbell) }
    156  1.20     matt 
    157  1.20     matt #define	cons_init_halt(n) { \
    158  1.20     matt 	dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
    159  1.20     matt 	dev_init(n,cnputc), dev_init(n,cnpollc), 0,	             \
    160  1.20     matt 	dev_init(n,cnhalt) }
    161  1.10  mycroft 
    162   1.1      cgd #endif
    163  1.16   simonb 
    164  1.16   simonb #endif /* _SYS_DEV_CONS_H_ */
    165