Home | History | Annotate | Line # | Download | only in dev
com_mainbus.c revision 1.8
      1  1.8      cdi /*	$NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $	*/
      2  1.1    soren 
      3  1.1    soren /*
      4  1.1    soren  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
      5  1.1    soren  *
      6  1.1    soren  * Redistribution and use in source and binary forms, with or without
      7  1.1    soren  * modification, are permitted provided that the following conditions
      8  1.1    soren  * are met:
      9  1.1    soren  * 1. Redistributions of source code must retain the above copyright
     10  1.1    soren  *    notice, this list of conditions, and the following disclaimer.
     11  1.1    soren  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1    soren  *    notice, this list of conditions and the following disclaimer in the
     13  1.1    soren  *    documentation and/or other materials provided with the distribution.
     14  1.1    soren  *
     15  1.1    soren  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.1    soren  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.1    soren  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.1    soren  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.1    soren  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.1    soren  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.1    soren  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1    soren  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.1    soren  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.1    soren  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.1    soren  * SUCH DAMAGE.
     26  1.1    soren  */
     27  1.6    lukem 
     28  1.6    lukem #include <sys/cdefs.h>
     29  1.8      cdi __KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $");
     30  1.1    soren 
     31  1.1    soren #include <sys/param.h>
     32  1.1    soren #include <sys/systm.h>
     33  1.1    soren #include <sys/ioctl.h>
     34  1.1    soren #include <sys/select.h>
     35  1.1    soren #include <sys/tty.h>
     36  1.1    soren #include <sys/proc.h>
     37  1.1    soren #include <sys/user.h>
     38  1.1    soren #include <sys/conf.h>
     39  1.1    soren #include <sys/file.h>
     40  1.1    soren #include <sys/uio.h>
     41  1.1    soren #include <sys/kernel.h>
     42  1.1    soren #include <sys/syslog.h>
     43  1.1    soren #include <sys/types.h>
     44  1.1    soren #include <sys/device.h>
     45  1.1    soren 
     46  1.1    soren #include <machine/autoconf.h>
     47  1.1    soren #include <machine/intr.h>
     48  1.1    soren #include <machine/bus.h>
     49  1.8      cdi #include <machine/nvram.h>
     50  1.1    soren 
     51  1.1    soren #include <dev/ic/comreg.h>
     52  1.1    soren #include <dev/ic/comvar.h>
     53  1.1    soren 
     54  1.1    soren 
     55  1.8      cdi extern int console_present;
     56  1.8      cdi 
     57  1.1    soren struct com_mainbus_softc {
     58  1.1    soren 	struct com_softc sc_com;
     59  1.1    soren 	void *sc_ih;
     60  1.1    soren };
     61  1.1    soren 
     62  1.1    soren static int	com_mainbus_probe(struct device *, struct cfdata *, void *);
     63  1.1    soren static void	com_mainbus_attach(struct device *, struct device *, void *);
     64  1.1    soren 
     65  1.5  thorpej CFATTACH_DECL(com_mainbus, sizeof(struct com_mainbus_softc),
     66  1.5  thorpej     com_mainbus_probe, com_mainbus_attach, NULL, NULL);
     67  1.1    soren 
     68  1.1    soren int
     69  1.1    soren com_mainbus_probe(parent, match, aux)
     70  1.1    soren 	struct device *parent;
     71  1.1    soren 	struct cfdata *match;
     72  1.1    soren 	void *aux;
     73  1.1    soren {
     74  1.1    soren 
     75  1.8      cdi 	return (console_present != 0);
     76  1.1    soren }
     77  1.1    soren 
     78  1.1    soren struct com_softc *com0; /* XXX */
     79  1.1    soren 
     80  1.1    soren void
     81  1.1    soren com_mainbus_attach(parent, self, aux)
     82  1.1    soren 	struct device *parent;
     83  1.1    soren 	struct device *self;
     84  1.1    soren 	void *aux;
     85  1.1    soren {
     86  1.1    soren 	struct com_mainbus_softc *msc = (void *)self;
     87  1.1    soren 	struct com_softc *sc = &msc->sc_com;
     88  1.1    soren 	struct mainbus_attach_args *maa = aux;
     89  1.1    soren 
     90  1.1    soren 	sc->sc_ioh = maa->ma_ioh;
     91  1.1    soren 	sc->sc_iot = maa->ma_iot;
     92  1.1    soren 	sc->sc_iobase = maa->ma_addr;
     93  1.1    soren 
     94  1.1    soren 	sc->sc_frequency = COM_FREQ * 10;
     95  1.1    soren 
     96  1.1    soren 	/* XXX console check */
     97  1.1    soren 	/* XXX map */
     98  1.1    soren 
     99  1.1    soren 	com_attach_subr(sc);
    100  1.1    soren 
    101  1.2    soren 	cpu_intr_establish(maa->ma_level, IPL_SERIAL, comintr, sc);
    102  1.2    soren 
    103  1.1    soren 	return;
    104  1.1    soren }
    105