Home | History | Annotate | Line # | Download | only in vsa
vsbus.c revision 1.13
      1 /*	$NetBSD: vsbus.c,v 1.13 1998/12/06 14:33:54 ragge Exp $ */
      2 /*
      3  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to Ludd by Bertram Barth.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed at Ludd, University of
     19  *	Lule}, Sweden and its contributors.
     20  * 4. The name of the author may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #include <sys/param.h>
     36 #include <sys/systm.h>
     37 #include <sys/buf.h>
     38 #include <sys/conf.h>
     39 #include <sys/file.h>
     40 #include <sys/ioctl.h>
     41 #include <sys/proc.h>
     42 #include <sys/user.h>
     43 #include <sys/map.h>
     44 #include <sys/device.h>
     45 #include <sys/dkstat.h>
     46 #include <sys/disklabel.h>
     47 #include <sys/syslog.h>
     48 #include <sys/stat.h>
     49 
     50 #include <machine/pte.h>
     51 #include <machine/sid.h>
     52 #include <machine/scb.h>
     53 #include <machine/cpu.h>
     54 #include <machine/trap.h>
     55 #include <machine/nexus.h>
     56 
     57 #include <machine/uvax.h>
     58 #include <machine/ka410.h>
     59 #include <machine/ka420.h>
     60 #include <machine/ka43.h>
     61 
     62 #include <machine/vsbus.h>
     63 
     64 #include "ioconf.h"
     65 
     66 int	vsbus_match	__P((struct device *, struct cfdata *, void *));
     67 void	vsbus_attach	__P((struct device *, struct device *, void *));
     68 int	vsbus_print	__P((void *, const char *));
     69 
     70 void	ka410_attach	__P((struct device *, struct device *, void *));
     71 void	ka43_attach	__P((struct device *, struct device *, void *));
     72 
     73 #define VSBUS_MAXINTR	8
     74 
     75 struct	vsbus_softc {
     76 	struct	device sc_dev;
     77 	struct	ivec_dsp sc_dsp[VSBUS_MAXINTR];
     78 };
     79 
     80 struct	cfattach vsbus_ca = {
     81 	sizeof(struct vsbus_softc), vsbus_match, vsbus_attach
     82 };
     83 
     84 void	vsbus_intr_setup __P((struct vsbus_softc *));
     85 
     86 #define VSBUS_MAXDEVS	8
     87 
     88 int
     89 vsbus_print(aux, name)
     90 	void *aux;
     91 	const char *name;
     92 {
     93 	struct vsbus_attach_args *va = aux;
     94 
     95 	if (name) {
     96 		printf ("device %d at %s", va->va_type, name);
     97 		return (UNSUPP);
     98 	}
     99 	return (UNCONF);
    100 }
    101 
    102 int
    103 vsbus_match(parent, cf, aux)
    104 	struct	device	*parent;
    105 	struct cfdata	*cf;
    106 	void	*aux;
    107 {
    108 	struct bp_conf *bp = aux;
    109 
    110 	if (strcmp(bp->type, "vsbus"))
    111 		return 0;
    112 	/*
    113 	 * on machines which can have it, the vsbus is always there
    114 	 */
    115 	if ((vax_bustype & VAX_VSBUS) == 0)
    116 		return (0);
    117 
    118 	return (1);
    119 }
    120 
    121 void
    122 vsbus_attach(parent, self, aux)
    123 	struct	device	*parent, *self;
    124 	void	*aux;
    125 {
    126 	struct	vsbus_softc *sc = (void *)self;
    127 	struct	vsbus_attach_args va;
    128 
    129 	printf("\n");
    130 	/*
    131 	 * first setup interrupt-table, so that devices can register
    132 	 * their interrupt-routines...
    133 	 */
    134 	vsbus_intr_setup(sc);
    135 
    136 	/*
    137 	 * now check for all possible devices on this "bus"
    138 	 */
    139 	/* Always have network */
    140 	va.va_type = inr_ni;
    141 	config_found(self, &va, vsbus_print);
    142 
    143 	/* Always have serial line */
    144 	va.va_type = inr_sr;
    145 	config_found(self, &va, vsbus_print);
    146 
    147 	/* If sm_addr is set, a monochrome graphics adapter is found */
    148 	/* XXX ckeck for color adapter */
    149 	if (sm_addr) {
    150 		va.va_type = inr_vf;
    151 		config_found(self, &va, vsbus_print);
    152 	}
    153 
    154 	/* XXX - Avoid searching for SCSI on 4000/60 */
    155 	if (vax_boardtype == VAX_BTYP_46)
    156 		return;
    157 
    158 	/*
    159 	 * Check for mass storage devices. This is tricky :-/
    160 	 * VS2K always has both MFM and SCSI.
    161 	 * VS3100 has either MFM/SCSI, SCSI/SCSI or neither of them.
    162 	 * The device registers are at different places for them all.
    163 	 */
    164 	if (vax_boardtype == VAX_BTYP_410) {
    165 #ifdef notyet
    166 		va.va_type = inr_dc;
    167 		config_found(self, &va, vsbus_print);
    168 #endif
    169 		va.va_type = 0x200C0080;
    170 		config_found(self, &va, vsbus_print);
    171 		return;
    172 	}
    173 
    174 	if ((vax_confdata & KA420_CFG_STCMSK) == KA420_CFG_NONE)
    175 		return; /* No ctlrs */
    176 
    177 	/* Ok, we have at least one scsi ctlr */
    178 	va.va_type = 0x200C0080;
    179 	config_found(self, &va, vsbus_print);
    180 
    181 #ifdef notyet
    182 	/* The last one is MFM or SCSI */
    183 	if ((vax_confdata & KA420_CFG_STCMSK) == KA420_CFG_RB) {
    184 		va.va_type = inr_dc;
    185 		config_found(self, &va, vsbus_print);
    186 	} else {
    187 		va.va_type = 0x200C0180;
    188 		config_found(self, &va, vsbus_print);
    189 	}
    190 #endif
    191 }
    192 
    193 static	void stray __P((int));
    194 
    195 static void
    196 stray(arg)
    197 	int arg;
    198 {
    199 	printf("stray interrupt nr %d.\n", arg);
    200 }
    201 
    202 static int inrs[] = {IVEC_DC, IVEC_SC, IVEC_VS, IVEC_VF,
    203 		IVEC_NS, IVEC_NP, IVEC_ST, IVEC_SR};
    204 
    205 void
    206 vsbus_intr_setup(sc)
    207 	struct vsbus_softc *sc;
    208 {
    209 	extern struct ivec_dsp idsptch;		/* subr.s */
    210 	void **scbP = (void*)scb;
    211 	int i;
    212 
    213 	vs_cpu->vc_intmsk = 0;		/* disable all interrupts */
    214 	vs_cpu->vc_intclr = 0xFF;	/* clear all old interrupts */
    215 
    216 	for (i = 0; i < VSBUS_MAXINTR; i++) {
    217 		bcopy(&idsptch, &sc->sc_dsp[i], sizeof(struct ivec_dsp));
    218 		sc->sc_dsp[i].hoppaddr = stray;
    219 		sc->sc_dsp[i].pushlarg = i;
    220 		scbP[inrs[i]/4] = &sc->sc_dsp[i];
    221 	}
    222 }
    223 
    224 void
    225 vsbus_intr_attach(nr, func, arg)
    226 	int nr;
    227 	void (*func)(int);
    228 	int arg;
    229 {
    230 	struct vsbus_softc *sc = vsbus_cd.cd_devs[0];
    231 
    232 	sc->sc_dsp[nr].hoppaddr = func;
    233 	sc->sc_dsp[nr].pushlarg = arg;
    234 }
    235 
    236 void
    237 vsbus_intr_enable(nr)
    238 	int nr;
    239 {
    240 	vs_cpu->vc_intclr = (1<<nr);
    241 	vs_cpu->vc_intmsk |= (1<<nr);
    242 }
    243 
    244 void
    245 vsbus_intr_disable(nr)
    246 	int nr;
    247 {
    248 	vs_cpu->vc_intmsk = vs_cpu->vc_intmsk & ~(1<<nr);
    249 }
    250 
    251 #ifdef notyet
    252 /*
    253  * Allocate/free DMA pages and other bus resources.
    254  * VS2000: All DMA and register access must be exclusive.
    255  * VS3100: DMA area may be accessed by anyone anytime.
    256  *   MFM/SCSI: Don't touch reg's while DMA is active.
    257  *   SCSI/SCSI: Legal to touch any register anytime.
    258  */
    259 
    260 
    261 #endif
    262