maccons.c revision 1.10 1 1.10 rin /* $NetBSD: maccons.c,v 1.10 2019/07/26 10:48:44 rin Exp $ */
2 1.2 scottr
3 1.2 scottr /*
4 1.2 scottr * Copyright (C) 1999 Scott Reynolds. All rights reserved.
5 1.2 scottr *
6 1.2 scottr * Redistribution and use in source and binary forms, with or without
7 1.2 scottr * modification, are permitted provided that the following conditions
8 1.2 scottr * are met:
9 1.2 scottr * 1. Redistributions of source code must retain the above copyright
10 1.2 scottr * notice, this list of conditions and the following disclaimer.
11 1.2 scottr * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 scottr * notice, this list of conditions and the following disclaimer in the
13 1.2 scottr * documentation and/or other materials provided with the distribution.
14 1.2 scottr * 3. The name of the author may not be used to endorse or promote products
15 1.2 scottr * derived from this software without specific prior written permission.
16 1.2 scottr *
17 1.2 scottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.2 scottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.2 scottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.2 scottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.2 scottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.2 scottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.2 scottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.2 scottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.2 scottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 1.2 scottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.2 scottr */
28 1.4 lukem
29 1.4 lukem #include <sys/cdefs.h>
30 1.10 rin __KERNEL_RCSID(0, "$NetBSD: maccons.c,v 1.10 2019/07/26 10:48:44 rin Exp $");
31 1.2 scottr
32 1.10 rin #include "genfb.h"
33 1.10 rin #include "macfb.h"
34 1.2 scottr #include "wsdisplay.h"
35 1.2 scottr #include "wskbd.h"
36 1.2 scottr #include "zsc.h"
37 1.2 scottr
38 1.10 rin #if (NGENFB + NMACFB) > 1
39 1.10 rin #error "genfb(4) and macfb(4) cannot be enabled at the same time"
40 1.10 rin #endif
41 1.10 rin
42 1.2 scottr #include <sys/param.h>
43 1.2 scottr #include <sys/systm.h>
44 1.2 scottr #include <sys/conf.h>
45 1.2 scottr
46 1.2 scottr #include <machine/autoconf.h>
47 1.2 scottr #include <machine/cpu.h>
48 1.10 rin #include <machine/video.h>
49 1.2 scottr
50 1.2 scottr #include <dev/cons.h>
51 1.10 rin #include <dev/wscons/wsdisplayvar.h>
52 1.2 scottr #include <dev/wscons/wskbdvar.h>
53 1.10 rin #if NGENFB > 0
54 1.10 rin #include <dev/wsfb/genfbvar.h>
55 1.10 rin #endif
56 1.10 rin
57 1.10 rin #include <mac68k/dev/akbdvar.h>
58 1.10 rin #if NMACFB > 0
59 1.2 scottr #include <mac68k/dev/macfbvar.h>
60 1.10 rin #endif
61 1.2 scottr
62 1.5 chs void maccnprobe(struct consdev *);
63 1.5 chs void maccninit(struct consdev *);
64 1.5 chs int maccngetc(dev_t);
65 1.5 chs void maccnputc(dev_t, int);
66 1.5 chs void maccnpollc(dev_t, int);
67 1.2 scottr
68 1.2 scottr static int maccons_initted = (-1);
69 1.2 scottr
70 1.2 scottr void
71 1.2 scottr maccnprobe(struct consdev *cp)
72 1.2 scottr {
73 1.2 scottr #if NWSDISPLAY > 0
74 1.3 gehenna extern const struct cdevsw wsdisplay_cdevsw;
75 1.2 scottr int maj, unit;
76 1.2 scottr #endif
77 1.2 scottr
78 1.2 scottr cp->cn_dev = NODEV;
79 1.2 scottr cp->cn_pri = CN_NORMAL;
80 1.2 scottr
81 1.2 scottr #if NWSDISPLAY > 0
82 1.2 scottr unit = 0;
83 1.3 gehenna maj = cdevsw_lookup_major(&wsdisplay_cdevsw);
84 1.3 gehenna if (maj != -1) {
85 1.2 scottr cp->cn_pri = CN_INTERNAL;
86 1.2 scottr cp->cn_dev = makedev(maj, unit);
87 1.2 scottr }
88 1.2 scottr #endif
89 1.2 scottr }
90 1.2 scottr
91 1.2 scottr void
92 1.2 scottr maccninit(struct consdev *cp)
93 1.2 scottr {
94 1.2 scottr /*
95 1.2 scottr * XXX evil hack; see consinit() for an explanation.
96 1.2 scottr * note: maccons_initted is initialized to (-1).
97 1.2 scottr */
98 1.2 scottr if (++maccons_initted > 0) {
99 1.10 rin #if NMACFB > 0
100 1.8 jmmv macfb_cnattach(mac68k_video.mv_phys);
101 1.10 rin #elif NGENFB > 0
102 1.10 rin genfb_cnattach();
103 1.10 rin #endif
104 1.2 scottr akbd_cnattach();
105 1.2 scottr }
106 1.2 scottr }
107 1.2 scottr
108 1.2 scottr int
109 1.2 scottr maccngetc (dev_t dev)
110 1.2 scottr {
111 1.2 scottr #if NWSKBD > 0
112 1.2 scottr if (maccons_initted > 0)
113 1.2 scottr return wskbd_cngetc(dev);
114 1.2 scottr #endif
115 1.2 scottr return 0;
116 1.2 scottr }
117 1.2 scottr
118 1.2 scottr void
119 1.2 scottr maccnputc(dev_t dev, int c)
120 1.2 scottr {
121 1.2 scottr #if NZSC > 0
122 1.2 scottr extern dev_t mac68k_zsdev;
123 1.5 chs extern int zscnputc(dev_t, int);
124 1.2 scottr #endif
125 1.2 scottr
126 1.2 scottr #if NWSDISPLAY > 0
127 1.2 scottr if (maccons_initted > 0)
128 1.2 scottr wsdisplay_cnputc(dev,c);
129 1.2 scottr #endif
130 1.2 scottr #if NZSC > 0
131 1.2 scottr if (mac68k_machine.serial_boot_echo)
132 1.2 scottr zscnputc(mac68k_zsdev, c);
133 1.2 scottr #endif
134 1.2 scottr }
135 1.2 scottr
136 1.2 scottr void
137 1.2 scottr maccnpollc(dev_t dev, int on)
138 1.2 scottr {
139 1.2 scottr #if NWSKBD > 0
140 1.2 scottr if (maccons_initted > 0)
141 1.2 scottr wskbd_cnpollc(dev,on);
142 1.2 scottr #endif
143 1.2 scottr }
144