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