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