Home | History | Annotate | Line # | Download | only in dev
maccons.c revision 1.5
      1  1.5      chs /*	$NetBSD: maccons.c,v 1.5 2005/01/15 16:00:59 chs 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.5      chs __KERNEL_RCSID(0, "$NetBSD: maccons.c,v 1.5 2005/01/15 16:00:59 chs 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.2   scottr #include <dev/cons.h>
     44  1.2   scottr #include <dev/wscons/wskbdvar.h>
     45  1.2   scottr #include <dev/wscons/wsdisplayvar.h>
     46  1.2   scottr #include <mac68k/dev/macfbvar.h>
     47  1.2   scottr #include <mac68k/dev/akbdvar.h>
     48  1.2   scottr 
     49  1.5      chs void maccnprobe(struct consdev *);
     50  1.5      chs void maccninit(struct consdev *);
     51  1.5      chs int maccngetc(dev_t);
     52  1.5      chs void maccnputc(dev_t, int);
     53  1.5      chs void maccnpollc(dev_t, int);
     54  1.2   scottr 
     55  1.2   scottr static int	maccons_initted = (-1);
     56  1.2   scottr 
     57  1.2   scottr /* From Booter via locore */
     58  1.2   scottr extern u_int32_t	mac68k_vidphys;
     59  1.2   scottr 
     60  1.2   scottr void
     61  1.2   scottr maccnprobe(struct consdev *cp)
     62  1.2   scottr {
     63  1.2   scottr #if NWSDISPLAY > 0
     64  1.3  gehenna 	extern const struct cdevsw wsdisplay_cdevsw;
     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.3  gehenna 	maj = cdevsw_lookup_major(&wsdisplay_cdevsw);
     74  1.3  gehenna 	if (maj != -1) {
     75  1.2   scottr 		cp->cn_pri = CN_INTERNAL;
     76  1.2   scottr 		cp->cn_dev = makedev(maj, unit);
     77  1.2   scottr 	}
     78  1.2   scottr #endif
     79  1.2   scottr }
     80  1.2   scottr 
     81  1.2   scottr void
     82  1.2   scottr maccninit(struct consdev *cp)
     83  1.2   scottr {
     84  1.2   scottr 	/*
     85  1.2   scottr 	 * XXX evil hack; see consinit() for an explanation.
     86  1.2   scottr 	 * note:  maccons_initted is initialized to (-1).
     87  1.2   scottr 	 */
     88  1.2   scottr 	if (++maccons_initted > 0) {
     89  1.2   scottr 		macfb_cnattach(mac68k_vidphys);
     90  1.2   scottr 		akbd_cnattach();
     91  1.2   scottr 	}
     92  1.2   scottr }
     93  1.2   scottr 
     94  1.2   scottr int
     95  1.2   scottr maccngetc (dev_t dev)
     96  1.2   scottr {
     97  1.2   scottr #if NWSKBD > 0
     98  1.2   scottr 	if (maccons_initted > 0)
     99  1.2   scottr 		return wskbd_cngetc(dev);
    100  1.2   scottr #endif
    101  1.2   scottr 	return 0;
    102  1.2   scottr }
    103  1.2   scottr 
    104  1.2   scottr void
    105  1.2   scottr maccnputc(dev_t dev, int c)
    106  1.2   scottr {
    107  1.2   scottr #if NZSC > 0
    108  1.2   scottr 	extern dev_t mac68k_zsdev;
    109  1.5      chs 	extern int zscnputc(dev_t, int);
    110  1.2   scottr #endif
    111  1.2   scottr 
    112  1.2   scottr #if NWSDISPLAY > 0
    113  1.2   scottr 	if (maccons_initted > 0)
    114  1.2   scottr 		wsdisplay_cnputc(dev,c);
    115  1.2   scottr #endif
    116  1.2   scottr #if NZSC > 0
    117  1.2   scottr         if (mac68k_machine.serial_boot_echo)
    118  1.2   scottr                 zscnputc(mac68k_zsdev, c);
    119  1.2   scottr #endif
    120  1.2   scottr }
    121  1.2   scottr 
    122  1.2   scottr void
    123  1.2   scottr maccnpollc(dev_t dev, int on)
    124  1.2   scottr {
    125  1.2   scottr #if NWSKBD > 0
    126  1.2   scottr 	if (maccons_initted > 0)
    127  1.2   scottr 		wskbd_cnpollc(dev,on);
    128  1.2   scottr #endif
    129  1.2   scottr }
    130