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