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