cons.h revision 1.28 1 1.28 riastrad /* $NetBSD: cons.h,v 1.28 2022/08/28 09:52:43 riastradh 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.28 riastrad #include <sys/types.h>
45 1.28 riastrad
46 1.1 cgd struct consdev {
47 1.10 mycroft void (*cn_probe) /* probe hardware and fill in consdev info */
48 1.23 perry (struct consdev *);
49 1.10 mycroft void (*cn_init) /* turn on as console */
50 1.23 perry (struct consdev *);
51 1.10 mycroft int (*cn_getc) /* kernel getchar interface */
52 1.23 perry (dev_t);
53 1.10 mycroft void (*cn_putc) /* kernel putchar interface */
54 1.23 perry (dev_t, int);
55 1.10 mycroft void (*cn_pollc) /* turn on and off polling */
56 1.23 perry (dev_t, int);
57 1.17 thorpej void (*cn_bell) /* ring bell */
58 1.23 perry (dev_t, u_int, u_int, u_int);
59 1.20 matt void (*cn_halt) /* stop device */
60 1.23 perry (dev_t);
61 1.20 matt void (*cn_flush) /* flush output */
62 1.23 perry (dev_t);
63 1.1 cgd dev_t cn_dev; /* major/minor of device */
64 1.11 gwr int cn_pri; /* pecking order; the higher the better */
65 1.1 cgd };
66 1.1 cgd
67 1.1 cgd /* values for cn_pri - reflect our policy for console selection */
68 1.1 cgd #define CN_DEAD 0 /* device doesn't exist */
69 1.22 cdi #define CN_NULL 1 /* noop console */
70 1.22 cdi #define CN_NORMAL 2 /* device exists but is nothing special */
71 1.22 cdi #define CN_INTERNAL 3 /* "internal" bit-mapped display */
72 1.22 cdi #define CN_REMOTE 4 /* serial interface with remote bit set */
73 1.1 cgd
74 1.9 jtc #ifdef _KERNEL
75 1.10 mycroft
76 1.1 cgd extern struct consdev constab[];
77 1.1 cgd extern struct consdev *cn_tab;
78 1.8 cgd
79 1.23 perry void cninit(void);
80 1.23 perry int cngetc(void);
81 1.23 perry int cngetsn(char *, int);
82 1.23 perry void cnputc(int);
83 1.23 perry void cnpollc(int);
84 1.23 perry void cnbell(u_int, u_int, u_int);
85 1.23 perry void cnflush(void);
86 1.23 perry void cnhalt(void);
87 1.23 perry void cnrint(void);
88 1.23 perry void nullcnprobe(struct consdev *);
89 1.23 perry void nullcninit(struct consdev *);
90 1.23 perry void nullcnpollc(dev_t, int);
91 1.23 perry void nullconsattach(int);
92 1.10 mycroft
93 1.10 mycroft /* console-specific types */
94 1.23 perry #define dev_type_cnprobe(n) void n(struct consdev *)
95 1.23 perry #define dev_type_cninit(n) void n(struct consdev *)
96 1.23 perry #define dev_type_cngetc(n) int n(dev_t)
97 1.23 perry #define dev_type_cnputc(n) void n(dev_t, int)
98 1.23 perry #define dev_type_cnpollc(n) void n(dev_t, int)
99 1.25 uwe #define dev_type_cnbell(n) void n(dev_t, u_int, u_int, u_int)
100 1.23 perry #define dev_type_cnhalt(n) void n(dev_t)
101 1.23 perry #define dev_type_cnflush(n) void n(dev_t)
102 1.10 mycroft
103 1.19 gehenna #define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t))
104 1.19 gehenna #define dev_init(n,t) __CONCAT(n,t)
105 1.19 gehenna
106 1.10 mycroft #define cons_decl(n) \
107 1.10 mycroft dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
108 1.20 matt dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell); \
109 1.20 matt dev_decl(n,cnflush); dev_decl(n,cnhalt);
110 1.10 mycroft
111 1.10 mycroft #define cons_init(n) { \
112 1.19 gehenna dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
113 1.26 cube dev_init(n,cnputc), dev_init(n,cnpollc), NULL, NULL, NULL, \
114 1.26 cube 0, 0 }
115 1.17 thorpej
116 1.17 thorpej #define cons_init_bell(n) { \
117 1.19 gehenna dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
118 1.19 gehenna dev_init(n,cnputc), dev_init(n,cnpollc), dev_init(n,cnbell) }
119 1.20 matt
120 1.20 matt #define cons_init_halt(n) { \
121 1.20 matt dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \
122 1.20 matt dev_init(n,cnputc), dev_init(n,cnpollc), 0, \
123 1.20 matt dev_init(n,cnhalt) }
124 1.10 mycroft
125 1.1 cgd #endif
126 1.16 simonb
127 1.16 simonb #endif /* _SYS_DEV_CONS_H_ */
128