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