FreeBSD/Linux Kernel Cross Reference
sys/dev/cons.h
1 /* $NetBSD: cons.h,v 1.22 2003/10/17 18:16:43 cdi 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_NULL 1 /* noop console */
107 #define CN_NORMAL 2 /* device exists but is nothing special */
108 #define CN_INTERNAL 3 /* "internal" bit-mapped display */
109 #define CN_REMOTE 4 /* serial interface with remote bit set */
110
111 #ifdef _KERNEL
112
113 extern struct consdev constab[];
114 extern struct consdev *cn_tab;
115
116 void cninit __P((void));
117 int cngetc __P((void));
118 int cngetsn __P((char *, int));
119 void cnputc __P((int));
120 void cnpollc __P((int));
121 void cnbell __P((u_int, u_int, u_int));
122 void cnflush __P((void));
123 void cnhalt __P((void));
124 void cnrint __P((void));
125 void nullcnprobe __P((struct consdev *));
126 void nullcninit __P((struct consdev *));
127 void nullcnpollc __P((dev_t, int));
128 void nullconsattach __P((int));
129
130 /* console-specific types */
131 #define dev_type_cnprobe(n) void n __P((struct consdev *))
132 #define dev_type_cninit(n) void n __P((struct consdev *))
133 #define dev_type_cngetc(n) int n __P((dev_t))
134 #define dev_type_cnputc(n) void n __P((dev_t, int))
135 #define dev_type_cnpollc(n) void n __P((dev_t, int))
136 #define dev_type_cnbell(n) void n __P((dev_t, u_int, u_int, u_int));
137 #define dev_type_cnhalt(n) void n __P((dev_t))
138 #define dev_type_cnflush(n) void n __P((dev_t))
139
140 #define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t))
141 #define dev_init(n,t) __CONCAT(n,t)
142
143 #define cons_decl(n) \
144 dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
145 dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell); \
146 dev_decl(n,cnflush); dev_decl(n,cnhalt);
147
148 #define cons_init(n) { \
149 dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
150 dev_init(n,cnputc), dev_init(n,cnpollc) }
151
152 #define cons_init_bell(n) { \
153 dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
154 dev_init(n,cnputc), dev_init(n,cnpollc), dev_init(n,cnbell) }
155
156 #define cons_init_halt(n) { \
157 dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
158 dev_init(n,cnputc), dev_init(n,cnpollc), 0, \
159 dev_init(n,cnhalt) }
160
161 #endif
162
163 #endif /* _SYS_DEV_CONS_H_ */
Cache object: cf6da717dbac5e45f4cd8bbe4910e88f
|