Support shared Decstation 3100 and Decsystem 5100 baseboard devices

using a virtual "ibus" for  baseboard devices.
This commit is contained in:
jonathan 1998-04-19 02:52:45 +00:00
parent 53c671e26c
commit d4a24f85d6
5 changed files with 522 additions and 0 deletions

135
sys/arch/pmax/ibus/ibus.c Normal file
View File

@ -0,0 +1,135 @@
/* $NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
/*
* Copyright (c) 1998 Jonathan Stone. 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 Jonathan Stone for
* the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <pmax/ibus/ibusvar.h>
#include <pmax/pmax/pmaxtype.h>
static int ibusmatch __P((struct device *, struct cfdata *, void *));
static void ibusattach __P((struct device *, struct device *, void *));
int ibusprint __P((void *, const char *));
struct ibus_softc {
struct device ibd_dev;
int ibd_ndevs;
struct ibus_attach_args *ibd_devs;
ibus_intr_establish_t (*ibd_establish);
ibus_intr_disestablish_t (*ibd_disestablish);
};
struct cfattach ibus_ca = {
sizeof(struct ibus_softc), ibusmatch, ibusattach
};
extern struct cfdriver ibus_cd;
static int
ibusmatch(parent, cfdata, aux)
struct device *parent;
struct cfdata *cfdata;
void *aux;
{
struct ibus_dev_attach_args *ibd = (struct ibus_dev_attach_args *)aux;
if (strcmp(ibd->ibd_busname, "ibus") != 0) {
return 0;
}
if (systype != DS_PMAX && systype != DS_MIPSMATE && systype != DS_3MAX)
return (0);
return(1);
}
static void
ibusattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct ibus_softc *sc = (struct ibus_softc *)self;
struct ibus_dev_attach_args* ibd_args = aux;
struct ibus_attach_args *child;
int i;
printf("\n");
sc->ibd_ndevs = ibd_args->ibd_ndevs;
sc->ibd_devs = ibd_args->ibd_devs;
sc->ibd_establish = ibd_args->ibd_establish;
sc->ibd_disestablish = ibd_args->ibd_disestablish;
for (i = 0; i < sc->ibd_ndevs; i++) {
child = &sc->ibd_devs[i];
config_found(self, child, ibusprint);
}
}
int
ibusprint(aux, pnp)
void *aux;
const char *pnp;
{
if (pnp)
return (QUIET);
return (UNCONF);
}
void
ibus_intr_establish(cookie, level, handler, arg)
void * cookie;
int level;
int (*handler) __P((intr_arg_t));
intr_arg_t arg;
{
((struct ibus_softc*)ibus_cd.cd_devs[0])->
ibd_establish(cookie, level, handler, arg);
}
void
ibus_intr_disestablish(ia)
struct ibus_attach_args *ia;
{
((struct ibus_softc*)ibus_cd.cd_devs[0])->ibd_disestablish(ia);
}

View File

@ -0,0 +1,121 @@
/* $NetBSD: ibus_3100.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
/*
* Copyright (c) 1998 Jonathan Stone. 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 Jonathan Stone for
* the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ibus_3100.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#include <pmax/ibus/ibusvar.h>
#include <pmax/pmax/kn01.h>
#include <pmax/pmax/clockreg.h>
#include <pmax/pmax/pmaxtype.h>
int dec_3100_ibusdev_match
__P((struct device *, struct cfdata *, void *));
void dec_3100_ibusdev_attach
__P((struct device *, struct device *, void *));
extern struct cfattach kn01bus_ca;
struct cfattach kn01bus_ca = {
sizeof(struct device), dec_3100_ibusdev_match, dec_3100_ibusdev_attach
};
extern ibus_intr_establish_t dec_3100_intr_establish;
extern ibus_intr_disestablish_t dec_3100_intr_disestablish;
#define KV(x) ((tc_addr_t)MIPS_PHYS_TO_KSEG1(x))
static struct ibus_attach_args kn01_devs[] = {
/* name slot addr intpri */
{ "pm", 0, KV(KN01_PHYS_FBUF_START), 3, },
{ "dc", 1, KV(KN01_SYS_DZ), 2, },
{ "lance", 2, KV(KN01_SYS_LANCE), 1, },
{ "sii", 3, KV(KN01_SYS_SII), 0, },
{ "mc146818", 4, KV(KN01_SYS_CLOCK), 16, },
{ "dc", 5, KV(0x15000000), 4, },
{ "dc", 6, KV(0x15200000), 5, },
#ifdef notyet
/*
* XXX Ultrix configures at 0x86400400. the first 0x400 byte are
* used for NVRAM state??
*/
{ "nvram", 7, KV(0x86400000), -1, },
#endif
};
int kn01_attached = 0;
int
dec_3100_ibusdev_match(parent, cfdata, aux)
struct device *parent;
struct cfdata *cfdata;
void *aux;
{
if (kn01_attached)
return 0;
if (systype != DS_PMAX)
return (0);
return(1);
}
void
dec_3100_ibusdev_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct ibus_dev_attach_args ibd;
kn01_attached = 1;
ibd.ibd_busname = "ibus";
ibd.ibd_devs = kn01_devs;
ibd.ibd_ndevs = sizeof(kn01_devs) / sizeof(kn01_devs[0]);
ibd.ibd_establish = dec_3100_intr_establish;
ibd.ibd_disestablish = dec_3100_intr_disestablish;
config_found(self, &ibd, ibusprint); /* XXX*/
}

View File

@ -0,0 +1,121 @@
/* $NetBSD: ibus_5100.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
/* $NetBSD: ibus_5100.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
/*
* Copyright (c) 1998 Jonathan Stone. 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 Jonathan Stone for
* the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ibus_5100.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#include <pmax/ibus/ibusvar.h>
#include <pmax/pmax/kn01.h>
#include <pmax/pmax/clockreg.h>
#include <pmax/pmax/pmaxtype.h>
int dec_5100_ibusdev_match
__P((struct device *, struct cfdata *, void *));
void dec_5100_ibusdev_attach
__P((struct device *, struct device *, void *));
extern struct cfattach kn01bus_ca;
struct cfattach kn230bus_ca = {
sizeof(struct device), dec_5100_ibusdev_match, dec_5100_ibusdev_attach
};
extern ibus_intr_establish_t dec_5100_intr_establish;
extern ibus_intr_disestablish_t dec_5100_intr_disestablish;
#define KV(x) ((tc_addr_t)MIPS_PHYS_TO_KSEG1(x))
static struct ibus_attach_args kn230_devs[] = {
/* name slot addr cookie */
#if 0 /* Be sure to avoid memory fault probing for pm */
{ "pm", 0, KV(KN01_PHYS_FBUF_START), 3, },
#endif
{ "dc", 1, KV(KN01_SYS_DZ), 1, },
{ "lance", 2, KV(KN01_SYS_LANCE), 2, },
{ "sii", 3, KV(KN01_SYS_SII), 3, },
{ "mc146818", 4, KV(KN01_SYS_CLOCK), 4, },
{ "dc", 5, KV(0x15000000), 5, },
{ "dc", 6, KV(0x15200000), 6, },
#ifdef notyet
/*
* XXX Ultrix configures at 0x86400400. the first 0x400 byte are
* used for NVRAM state??
*/
{ "nvram", 7, KV(0x86400000), -1, },
#endif
};
int
dec_5100_ibusdev_match(parent, cfdata, aux)
struct device *parent;
struct cfdata *cfdata;
void *aux;
{
if (systype == DS_MIPSMATE)
return (1);
return(0);
}
void
dec_5100_ibusdev_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct ibus_dev_attach_args ibd;
printf("\n");
ibd.ibd_busname = "ibus";
ibd.ibd_devs = kn230_devs;
ibd.ibd_ndevs = sizeof(kn230_devs) / sizeof(kn230_devs[0]);
ibd.ibd_establish = dec_5100_intr_establish;
ibd.ibd_disestablish = dec_5100_intr_disestablish;
config_found(self, &ibd, ibusprint); /* XXX*/
}

View File

@ -0,0 +1,54 @@
/* $NetBSD: ibusvar.h,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
#ifndef __IBUSVAR_H
#define __IBUSVAR_H
void config_ibus __P((struct device *mb, void *,
int printfn __P((void *, const char *)) )); /* XXX */
/*
* function types for interrupt establish/diestablish
*/
struct ibus_attach_args;
typedef (ibus_intr_establish_t) __P((void * cookie, int level,
int (*handler) __P((intr_arg_t)), intr_arg_t arg));
typedef (ibus_intr_disestablish_t) __P((struct ibus_attach_args *));
/*
* Arguments used to attach a ibus "device" to its parent
*/
struct ibus_dev_attach_args {
const char *ibd_busname; /* XXX should be common */
#ifdef notyet
bus_space_tag_t iba_memt;
#endif
ibus_intr_establish_t (*ibd_establish);
ibus_intr_disestablish_t (*ibd_disestablish);
int ibd_ndevs;
struct ibus_attach_args *ibd_devs;
};
/*
* Arguments used to attach devices to an ibus
*/
struct ibus_attach_args {
char *ia_name; /* Device name. */
int ia_slot; /* Device slot (table entry). */
tc_addr_t ia_addr; /* Device address. */
int ia_cookie; /* Device interrupt "priority" */
};
/*
* interrrupt estalish functions.
* These call up to system-specific code to
* recompute spl levels.
*/
void ibus_intr_establish __P((void * cookie, int level,
int (*handler) __P((intr_arg_t)), intr_arg_t arg));
void ibus_intr_disestablish __P((struct ibus_attach_args *));
int ibusprint __P((void *aux, const char *pnp));
#endif /* __IBUSVAR_H */

View File

@ -0,0 +1,91 @@
/* $NetBSD: mcclock_ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mcclock_ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <dev/dec/clockvar.h>
#include <dev/dec/mcclockvar.h>
#include <dev/ic/mc146818reg.h>
#include <pmax/ibus/ibusvar.h>
#include <pmax/dev/mcclock_decvar.h>
int mcclock_ibus_match __P((struct device *, struct cfdata *, void *));
void mcclock_ibus_attach __P((struct device *, struct device *, void *));
struct cfattach mcclock_ibus_ca = {
sizeof (struct mcclock_dec_softc),
(void *)mcclock_ibus_match, mcclock_ibus_attach,
};
int
mcclock_ibus_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct ibus_attach_args *ia = aux;
#define CFNAME(cf) ((cf)->dv_cfdata->cf_driver->cd_name)
if (strcmp(CFNAME(parent), "ibus") != 0)
return 0;
if (strcmp("mc146818", ia->ia_name) != 0)
return (0);
if (badaddr((void*)ia->ia_addr, sizeof(u_int32_t)))
return (0);
return (1);
}
void
mcclock_ibus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct ibus_attach_args *ia =aux;
struct mcclock_dec_softc *sc = (struct mcclock_dec_softc *)self;
sc->sc_dp = (struct mcclock_dec_clockdatum*)ia->ia_addr;
/* Attach MI driver, using busfns with TC-style register padding */
mcclock_attach(&sc->sc_mcclock, &mcclock_dec_busfns);
}