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