Home | History | Annotate | Line # | Download | only in vsa
vsbus.c revision 1.12
      1 /*	$NetBSD: vsbus.c,v 1.12 1998/08/10 14:47:17 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 #ifdef notyet
    154 	/*
    155 	 * Check for mass storage devices. This is tricky :-/
    156 	 * VS2K always has both MFM and SCSI.
    157 	 * VS3100 has either MFM/SCSI, SCSI/SCSI or neither of them.
    158 	 * The device registers are at different places for them all.
    159 	 */
    160 	if (vax_boardtype == VAX_BTYP_410) {
    161 		va.va_type = inr_dc;
    162 		config_found(self, &va, vsbus_print);
    163 		va.va_type = 0x200C0080;
    164 		config_found(self, &va, vsbus_print);
    165 		return;
    166 	}
    167 
    168 	if ((vax_confdata & KA420_CFG_STCMSK) == KA420_CFG_NONE)
    169 		return; /* No ctlrs */
    170 
    171 	/* Ok, we have at least one scsi ctlr */
    172 	va.va_type = 0x200C0080;
    173 	config_found(self, &va, vsbus_print);
    174 
    175 	/* The last one is MFM or SCSI */
    176 	if ((vax_confdata & KA420_CFG_STCMSK) == KA420_CFG_RB) {
    177 		va.va_type = inr_dc;
    178 		config_found(self, &va, vsbus_print);
    179 	} else {
    180 		va.va_type = 0x200C0180;
    181 		config_found(self, &va, vsbus_print);
    182 	}
    183 #endif
    184 }
    185 
    186 static	void stray __P((int));
    187 
    188 static void
    189 stray(arg)
    190 	int arg;
    191 {
    192 	printf("stray interrupt nr %d.\n", arg);
    193 }
    194 
    195 static int inrs[] = {IVEC_DC, IVEC_SC, IVEC_VS, IVEC_VF,
    196 		IVEC_NS, IVEC_NP, IVEC_ST, IVEC_SR};
    197 
    198 void
    199 vsbus_intr_setup(sc)
    200 	struct vsbus_softc *sc;
    201 {
    202 	extern struct ivec_dsp idsptch;		/* subr.s */
    203 	void **scbP = (void*)scb;
    204 	int i;
    205 
    206 	vs_cpu->vc_intmsk = 0;		/* disable all interrupts */
    207 	vs_cpu->vc_intclr = 0xFF;	/* clear all old interrupts */
    208 
    209 	for (i = 0; i < VSBUS_MAXINTR; i++) {
    210 		bcopy(&idsptch, &sc->sc_dsp[i], sizeof(struct ivec_dsp));
    211 		sc->sc_dsp[i].hoppaddr = stray;
    212 		sc->sc_dsp[i].pushlarg = i;
    213 		scbP[inrs[i]/4] = &sc->sc_dsp[i];
    214 	}
    215 }
    216 
    217 void
    218 vsbus_intr_attach(nr, func, arg)
    219 	int nr;
    220 	void (*func)(int);
    221 	int arg;
    222 {
    223 	struct vsbus_softc *sc = vsbus_cd.cd_devs[0];
    224 
    225 	sc->sc_dsp[nr].hoppaddr = func;
    226 	sc->sc_dsp[nr].pushlarg = arg;
    227 }
    228 
    229 void
    230 vsbus_intr_enable(nr)
    231 	int nr;
    232 {
    233 	vs_cpu->vc_intclr = (1<<nr);
    234 	vs_cpu->vc_intmsk |= (1<<nr);
    235 }
    236 
    237 void
    238 vsbus_intr_disable(nr)
    239 	int nr;
    240 {
    241 	vs_cpu->vc_intmsk = vs_cpu->vc_intmsk & ~(1<<nr);
    242 }
    243 
    244 #ifdef notyet
    245 /*
    246  * Allocate/free DMA pages and other bus resources.
    247  * VS2000: All DMA and register access must be exclusive.
    248  * VS3100: DMA area may be accessed by anyone anytime.
    249  *   MFM/SCSI: Don't touch reg's while DMA is active.
    250  *   SCSI/SCSI: Legal to touch any register anytime.
    251  */
    252 
    253 
    254 #endif
    255