Home | History | Annotate | Line # | Download | only in dev
hil_intio.c revision 1.3.64.1
      1  1.3.64.1   martin /*	$NetBSD: hil_intio.c,v 1.3.64.1 2020/12/28 20:02:30 martin Exp $	*/
      2       1.1  tsutsui /*	$OpenBSD: hil_intio.c,v 1.8 2007/01/06 20:10:57 miod Exp $	*/
      3       1.1  tsutsui 
      4       1.1  tsutsui /*
      5       1.1  tsutsui  * Copyright (c) 2005, Miodrag Vallat.
      6       1.1  tsutsui  * All rights reserved.
      7       1.1  tsutsui  *
      8       1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
      9       1.1  tsutsui  * modification, are permitted provided that the following conditions
     10       1.1  tsutsui  * are met:
     11       1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     12       1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     13       1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     15       1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     16       1.1  tsutsui  *
     17       1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18       1.1  tsutsui  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19       1.1  tsutsui  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     20       1.1  tsutsui  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     21       1.1  tsutsui  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22       1.1  tsutsui  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     23       1.1  tsutsui  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24       1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     25       1.1  tsutsui  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     26       1.1  tsutsui  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27       1.1  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     28       1.1  tsutsui  *
     29       1.1  tsutsui  */
     30       1.1  tsutsui 
     31  1.3.64.1   martin #include "wsdisplay.h"
     32  1.3.64.1   martin 
     33       1.1  tsutsui #include <sys/param.h>
     34       1.1  tsutsui #include <sys/systm.h>
     35       1.1  tsutsui #include <sys/device.h>
     36       1.1  tsutsui #include <sys/conf.h>
     37       1.1  tsutsui #include <sys/bus.h>
     38       1.1  tsutsui #include <sys/cpu.h>
     39       1.1  tsutsui 
     40       1.1  tsutsui #include <machine/intr.h>
     41       1.1  tsutsui 
     42       1.1  tsutsui #include <dev/cons.h>
     43  1.3.64.1   martin #if NWSDISPLAY > 0
     44  1.3.64.1   martin #include <dev/wscons/wsdisplayvar.h>
     45  1.3.64.1   martin #endif
     46       1.1  tsutsui 
     47       1.1  tsutsui #include <hp300/dev/intiovar.h>
     48       1.1  tsutsui 
     49       1.1  tsutsui #include <machine/hil_machdep.h>
     50       1.1  tsutsui #include <dev/hil/hilvar.h>
     51       1.1  tsutsui 
     52       1.2  tsutsui static int	hil_intio_match(device_t, cfdata_t, void *);
     53       1.2  tsutsui static void	hil_intio_attach(device_t, device_t, void *);
     54       1.1  tsutsui 
     55       1.1  tsutsui CFATTACH_DECL_NEW(hil_intio, sizeof(struct hil_softc),
     56       1.1  tsutsui     hil_intio_match, hil_intio_attach, NULL, NULL);
     57       1.1  tsutsui 
     58       1.1  tsutsui int
     59       1.1  tsutsui hil_intio_match(device_t parent, cfdata_t cf, void *aux)
     60       1.1  tsutsui {
     61       1.1  tsutsui 	struct intio_attach_args *ia = aux;
     62       1.1  tsutsui 	static int hil_matched = 0;
     63       1.1  tsutsui 
     64       1.1  tsutsui 	if (strcmp("hil", ia->ia_modname) != 0)
     65       1.1  tsutsui 		return 0;
     66       1.1  tsutsui 
     67       1.1  tsutsui 	/* Allow only one instance. */
     68       1.1  tsutsui 	if (hil_matched != 0)
     69       1.2  tsutsui 		return 0;
     70       1.1  tsutsui 
     71       1.1  tsutsui 	if (badaddr((void *)ia->ia_addr))	/* should not happen! */
     72       1.2  tsutsui 		return 0;
     73       1.1  tsutsui 
     74       1.2  tsutsui 	return 1;
     75       1.1  tsutsui }
     76       1.1  tsutsui 
     77       1.1  tsutsui int hil_is_console = -1;	/* undecided */
     78       1.1  tsutsui 
     79       1.1  tsutsui void
     80       1.1  tsutsui hil_intio_attach(device_t parent, device_t self, void *aux)
     81       1.1  tsutsui {
     82       1.1  tsutsui 	struct hil_softc *sc = device_private(self);
     83       1.1  tsutsui 	struct intio_attach_args *ia = aux;
     84       1.1  tsutsui 
     85       1.1  tsutsui 	sc->sc_dev = self;
     86       1.1  tsutsui 	sc->sc_bst = ia->ia_bst;
     87       1.1  tsutsui 	if (bus_space_map(sc->sc_bst, ia->ia_iobase,
     88       1.1  tsutsui 	    HILMAPSIZE, 0, &sc->sc_bsh) != 0) {
     89       1.2  tsutsui 		aprint_error(": couldn't map hil controller\n");
     90       1.1  tsutsui 		return;
     91       1.1  tsutsui 	}
     92       1.1  tsutsui 
     93       1.1  tsutsui 	/*
     94       1.1  tsutsui 	 * Check that the configured console device is a wsdisplay.
     95       1.1  tsutsui 	 */
     96  1.3.64.1   martin #if NWSDISPLAY > 0
     97  1.3.64.1   martin 	if (cn_tab->cn_putc != wsdisplay_cnputc)
     98  1.3.64.1   martin #endif
     99  1.3.64.1   martin 	{
    100       1.3  tsutsui 		hil_is_console = 0;
    101  1.3.64.1   martin 	}
    102       1.1  tsutsui 
    103       1.1  tsutsui 	hil_attach(sc, &hil_is_console);
    104       1.1  tsutsui 	intr_establish(hil_intr, sc, ia->ia_ipl, IPL_TTY);
    105       1.1  tsutsui 
    106       1.1  tsutsui 	config_interrupts(self, hil_attach_deferred);
    107       1.1  tsutsui }
    108