Home | History | Annotate | Line # | Download | only in dev
maccons.c revision 1.3
      1  1.3  gehenna /*	$NetBSD: maccons.c,v 1.3 2002/09/06 13:18:43 gehenna 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 static int	maccons_initted = (-1);
     53  1.2   scottr 
     54  1.2   scottr /* From Booter via locore */
     55  1.2   scottr extern u_int32_t	mac68k_vidphys;
     56  1.2   scottr 
     57  1.2   scottr void
     58  1.2   scottr maccnprobe(struct consdev *cp)
     59  1.2   scottr {
     60  1.2   scottr #if NWSDISPLAY > 0
     61  1.3  gehenna 	extern const struct cdevsw wsdisplay_cdevsw;
     62  1.2   scottr 	int     maj, unit;
     63  1.2   scottr #endif
     64  1.2   scottr 
     65  1.2   scottr 	cp->cn_dev = NODEV;
     66  1.2   scottr 	cp->cn_pri = CN_NORMAL;
     67  1.2   scottr 
     68  1.2   scottr #if NWSDISPLAY > 0
     69  1.2   scottr 	unit = 0;
     70  1.3  gehenna 	maj = cdevsw_lookup_major(&wsdisplay_cdevsw);
     71  1.3  gehenna 	if (maj != -1) {
     72  1.2   scottr 		cp->cn_pri = CN_INTERNAL;
     73  1.2   scottr 		cp->cn_dev = makedev(maj, unit);
     74  1.2   scottr 	}
     75  1.2   scottr #endif
     76  1.2   scottr }
     77  1.2   scottr 
     78  1.2   scottr void
     79  1.2   scottr maccninit(struct consdev *cp)
     80  1.2   scottr {
     81  1.2   scottr 	/*
     82  1.2   scottr 	 * XXX evil hack; see consinit() for an explanation.
     83  1.2   scottr 	 * note:  maccons_initted is initialized to (-1).
     84  1.2   scottr 	 */
     85  1.2   scottr 	if (++maccons_initted > 0) {
     86  1.2   scottr 		macfb_cnattach(mac68k_vidphys);
     87  1.2   scottr 		akbd_cnattach();
     88  1.2   scottr 	}
     89  1.2   scottr }
     90  1.2   scottr 
     91  1.2   scottr int
     92  1.2   scottr maccngetc (dev_t dev)
     93  1.2   scottr {
     94  1.2   scottr #if NWSKBD > 0
     95  1.2   scottr 	if (maccons_initted > 0)
     96  1.2   scottr 		return wskbd_cngetc(dev);
     97  1.2   scottr #endif
     98  1.2   scottr 	return 0;
     99  1.2   scottr }
    100  1.2   scottr 
    101  1.2   scottr void
    102  1.2   scottr maccnputc(dev_t dev, int c)
    103  1.2   scottr {
    104  1.2   scottr #if NZSC > 0
    105  1.2   scottr 	extern dev_t mac68k_zsdev;
    106  1.2   scottr 	extern int zscnputc __P((dev_t dev, int c));
    107  1.2   scottr #endif
    108  1.2   scottr 
    109  1.2   scottr #if NWSDISPLAY > 0
    110  1.2   scottr 	if (maccons_initted > 0)
    111  1.2   scottr 		wsdisplay_cnputc(dev,c);
    112  1.2   scottr #endif
    113  1.2   scottr #if NZSC > 0
    114  1.2   scottr         if (mac68k_machine.serial_boot_echo)
    115  1.2   scottr                 zscnputc(mac68k_zsdev, c);
    116  1.2   scottr #endif
    117  1.2   scottr }
    118  1.2   scottr 
    119  1.2   scottr void
    120  1.2   scottr maccnpollc(dev_t dev, int on)
    121  1.2   scottr {
    122  1.2   scottr #if NWSKBD > 0
    123  1.2   scottr 	if (maccons_initted > 0)
    124  1.2   scottr 		wskbd_cnpollc(dev,on);
    125  1.2   scottr #endif
    126  1.2   scottr }
    127