maccons.c revision 1.8 1 1.8 jmmv /* $NetBSD: maccons.c,v 1.8 2007/08/29 16:09:31 jmmv 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.8 jmmv __KERNEL_RCSID(0, "$NetBSD: maccons.c,v 1.8 2007/08/29 16:09:31 jmmv Exp $");
31 1.2 scottr
32 1.2 scottr #include "wsdisplay.h"
33 1.2 scottr #include "wskbd.h"
34 1.2 scottr #include "zsc.h"
35 1.2 scottr
36 1.2 scottr #include <sys/param.h>
37 1.2 scottr #include <sys/systm.h>
38 1.2 scottr #include <sys/conf.h>
39 1.2 scottr
40 1.2 scottr #include <machine/autoconf.h>
41 1.2 scottr #include <machine/cpu.h>
42 1.2 scottr
43 1.7 jmmv #include <machine/video.h>
44 1.2 scottr #include <dev/cons.h>
45 1.2 scottr #include <dev/wscons/wskbdvar.h>
46 1.2 scottr #include <dev/wscons/wsdisplayvar.h>
47 1.2 scottr #include <mac68k/dev/macfbvar.h>
48 1.2 scottr #include <mac68k/dev/akbdvar.h>
49 1.2 scottr
50 1.5 chs void maccnprobe(struct consdev *);
51 1.5 chs void maccninit(struct consdev *);
52 1.5 chs int maccngetc(dev_t);
53 1.5 chs void maccnputc(dev_t, int);
54 1.5 chs void maccnpollc(dev_t, int);
55 1.2 scottr
56 1.2 scottr static int maccons_initted = (-1);
57 1.2 scottr
58 1.2 scottr void
59 1.2 scottr maccnprobe(struct consdev *cp)
60 1.2 scottr {
61 1.2 scottr #if NWSDISPLAY > 0
62 1.3 gehenna extern const struct cdevsw wsdisplay_cdevsw;
63 1.2 scottr int maj, unit;
64 1.2 scottr #endif
65 1.2 scottr
66 1.2 scottr cp->cn_dev = NODEV;
67 1.2 scottr cp->cn_pri = CN_NORMAL;
68 1.2 scottr
69 1.2 scottr #if NWSDISPLAY > 0
70 1.2 scottr unit = 0;
71 1.3 gehenna maj = cdevsw_lookup_major(&wsdisplay_cdevsw);
72 1.3 gehenna if (maj != -1) {
73 1.2 scottr cp->cn_pri = CN_INTERNAL;
74 1.2 scottr cp->cn_dev = makedev(maj, unit);
75 1.2 scottr }
76 1.2 scottr #endif
77 1.2 scottr }
78 1.2 scottr
79 1.2 scottr void
80 1.2 scottr maccninit(struct consdev *cp)
81 1.2 scottr {
82 1.2 scottr /*
83 1.2 scottr * XXX evil hack; see consinit() for an explanation.
84 1.2 scottr * note: maccons_initted is initialized to (-1).
85 1.2 scottr */
86 1.2 scottr if (++maccons_initted > 0) {
87 1.8 jmmv macfb_cnattach(mac68k_video.mv_phys);
88 1.2 scottr akbd_cnattach();
89 1.2 scottr }
90 1.2 scottr }
91 1.2 scottr
92 1.2 scottr int
93 1.2 scottr maccngetc (dev_t dev)
94 1.2 scottr {
95 1.2 scottr #if NWSKBD > 0
96 1.2 scottr if (maccons_initted > 0)
97 1.2 scottr return wskbd_cngetc(dev);
98 1.2 scottr #endif
99 1.2 scottr return 0;
100 1.2 scottr }
101 1.2 scottr
102 1.2 scottr void
103 1.2 scottr maccnputc(dev_t dev, int c)
104 1.2 scottr {
105 1.2 scottr #if NZSC > 0
106 1.2 scottr extern dev_t mac68k_zsdev;
107 1.5 chs extern int zscnputc(dev_t, int);
108 1.2 scottr #endif
109 1.2 scottr
110 1.2 scottr #if NWSDISPLAY > 0
111 1.2 scottr if (maccons_initted > 0)
112 1.2 scottr wsdisplay_cnputc(dev,c);
113 1.2 scottr #endif
114 1.2 scottr #if NZSC > 0
115 1.2 scottr if (mac68k_machine.serial_boot_echo)
116 1.2 scottr zscnputc(mac68k_zsdev, c);
117 1.2 scottr #endif
118 1.2 scottr }
119 1.2 scottr
120 1.2 scottr void
121 1.2 scottr maccnpollc(dev_t dev, int on)
122 1.2 scottr {
123 1.2 scottr #if NWSKBD > 0
124 1.2 scottr if (maccons_initted > 0)
125 1.2 scottr wskbd_cnpollc(dev,on);
126 1.2 scottr #endif
127 1.2 scottr }
128