VME bus code

This commit is contained in:
leo 1997-03-03 12:20:57 +00:00
parent c0b46da054
commit 485c62188c
4 changed files with 337 additions and 0 deletions

133
sys/arch/atari/vme/vme.c Normal file
View File

@ -0,0 +1,133 @@
/* $NetBSD: vme.c,v 1.1.1.1 1997/03/03 12:20:57 leo Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <machine/intr.h>
#include <atari/vme/vmevar.h>
int vmematch __P((struct device *, struct cfdata *, void *));
void vmeattach __P((struct device *, struct device *, void *));
int vmeprint __P((void *, const char *));
struct cfattach vme_ca = {
sizeof(struct vme_softc), vmematch, vmeattach
};
struct cfdriver vme_cd = {
NULL, "vme", DV_DULL
};
int vmesearch __P((struct device *, struct cfdata *, void *));
int
vmematch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct vmebus_attach_args *vba = aux;
if (strcmp(vba->vba_busname, cf->cf_driver->cd_name))
return (0);
return (1);
}
void
vmeattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct vme_softc *sc = (struct vme_softc *)self;
struct vmebus_attach_args *vba = aux;
printf("\n");
sc->sc_iot = vba->vba_iot;
sc->sc_memt = vba->vba_memt;
sc->sc_vc = vba->vba_vc;
config_search(vmesearch, self, NULL);
}
int
vmeprint(aux, vme)
void *aux;
const char *vme;
{
struct vme_attach_args *va = aux;
if (va->va_iosize)
printf(" port 0x%x", va->va_iobase);
if (va->va_iosize > 1)
printf("-0x%x", va->va_iobase + va->va_iosize - 1);
if (va->va_msize)
printf(" iomem 0x%x", va->va_maddr);
if (va->va_msize > 1)
printf("-0x%x", va->va_maddr + va->va_msize - 1);
if (va->va_irq != IRQUNK)
printf(" irq %d", va->va_irq);
return (UNCONF);
}
int
vmesearch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct vme_softc *sc = (struct vme_softc *)parent;
struct vme_attach_args va;
va.va_iot = sc->sc_iot;
va.va_memt = sc->sc_memt;
va.va_vc = sc->sc_vc;
va.va_iobase = cf->cf_iobase;
va.va_iosize = cf->cf_iosize;
va.va_maddr = cf->cf_maddr;
va.va_msize = cf->cf_msize;
va.va_irq = cf->cf_irq;
if ((*cf->cf_attach->ca_match)(parent, cf, &va) > 0)
config_attach(parent, cf, &va, vmeprint);
return (0);
}

View File

@ -0,0 +1,102 @@
/* $NetBSD: vme_machdep.c,v 1.1.1.1 1997/03/03 12:20:57 leo Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/iomap.h>
#include <machine/mfp.h>
#include <atari/atari/device.h>
#include <atari/vme/vmevar.h>
static int vmebusprint __P((void *auxp, const char *));
static int vmebusmatch __P((struct device *, struct cfdata *, void *));
static void vmebusattach __P((struct device *, struct device *, void *));
struct cfattach vmebus_ca = {
sizeof(struct device), vmebusmatch, vmebusattach
};
struct cfdriver vmebus_cd = {
NULL, "vmebus", DV_DULL
};
int
vmebusmatch(pdp, cfp, auxp)
struct device *pdp;
struct cfdata *cfp;
void *auxp;
{
if(atari_realconfig == 0)
return (0);
if (strcmp((char *)auxp, "vmebus") || cfp->cf_unit != 0)
return(0);
return(machineid & ATARI_FALCON ? 0 : 1);
}
void
vmebusattach(pdp, dp, auxp)
struct device *pdp, *dp;
void *auxp;
{
struct vmebus_attach_args vba;
vba.vba_busname = "vme";
vba.vba_iot = 0;
vba.vba_memt = 0;
printf("\n");
config_found(dp, &vba, vmebusprint);
}
int
vmebusprint(auxp, name)
void *auxp;
const char *name;
{
if(name == NULL)
return(UNCONF);
return(QUIET);
}

View File

@ -0,0 +1,6 @@
#ifndef _ATARI_VME_MACHDEP_H_
#define _ATARI_VME_MACHDEP_H_
typedef void *vme_chipset_tag_t;
#endif /* _ATARI_VME_MACHDEP_H_ */

View File

@ -0,0 +1,96 @@
/* $NetBSD: vmevar.h,v 1.1.1.1 1997/03/03 12:20:57 leo Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Definitions for VME autoconfiguration.
*/
#include <machine/bus.h>
/*
* Structures and definitions needed by the machine-dependent header.
*/
struct vmebus_attach_args;
#include <atari/vme/vme_machdep.h>
/*
* VME bus attach arguments
*/
struct vmebus_attach_args {
char *vba_busname; /* XXX should be common */
bus_space_tag_t vba_iot; /* vme i/o space tag */
bus_space_tag_t vba_memt; /* vme mem space tag */
vme_chipset_tag_t vba_vc;
};
/*
* VME driver attach arguments
*/
struct vme_attach_args {
bus_space_tag_t va_iot; /* vme i/o space tag */
bus_space_tag_t va_memt; /* vme mem space tag */
vme_chipset_tag_t va_vc;
int va_iobase; /* base i/o address */
int va_iosize; /* span of ports used */
int va_irq; /* interrupt request */
int va_maddr; /* physical i/o mem addr */
u_int va_msize; /* size of i/o memory */
void *va_aux; /* driver specific */
};
#define IOBASEUNK -1 /* i/o address is unknown */
#define IRQUNK -1 /* interrupt request line is unknown */
#define MADDRUNK -1 /* shared memory address is unknown */
#define cf_iobase cf_loc[0]
#define cf_iosize cf_loc[1]
#define cf_maddr cf_loc[2]
#define cf_msize cf_loc[3]
#define cf_irq cf_loc[4]
/*
* VME master bus
*/
struct vme_softc {
struct device sc_dev; /* base device */
bus_space_tag_t sc_iot; /* vme io space tag */
bus_space_tag_t sc_memt; /* vme mem space tag */
vme_chipset_tag_t sc_vc;
};