Converted to (mostly) MI code.

This commit is contained in:
ragge 1999-08-04 19:12:22 +00:00
parent bebf926694
commit 1aa825ae03
3 changed files with 75 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bi.c,v 1.12 1999/07/12 13:42:24 ragge Exp $ */
/* $NetBSD: bi.c,v 1.13 1999/08/04 19:12:22 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -41,24 +41,16 @@
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <machine/mtpr.h>
#include <machine/nexus.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <arch/vax/bi/bireg.h>
#include <arch/vax/bi/bivar.h>
#include <dev/bi/bireg.h>
#include <dev/bi/bivar.h>
static int bi_match __P((struct device *, struct cfdata *, void *));
static void bi_attach __P((struct device *, struct device *, void*));
static int bi_print __P((void *, const char *));
struct cfattach bi_ca = {
sizeof(struct bi_softc), bi_match, bi_attach
};
struct bi_list bi_list[] = {
{BIDT_MS820, 1, "ms820"},
{BIDT_DRB32, 0, "drb32"},
@ -87,65 +79,61 @@ bi_print(aux, name)
struct bi_list *bl;
for (bl = &bi_list[0]; bl->bl_nr; bl++)
if (bl->bl_nr == ba->ba_node->biic.bi_dtype)
if (bl->bl_nr == bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0))
break;
if (name) {
if (bl->bl_nr == 0)
printf("unknown device 0x%x",
ba->ba_node->biic.bi_dtype);
bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0));
else
printf(bl->bl_name);
printf(" at %s", name);
}
printf(" node %d", ba->ba_nodenr);
#ifdef DEBUG
if (ba->ba_node->biic.bi_sadr && ba->ba_node->biic.bi_eadr)
printf(" [sadr %lx eadr %lx]", ba->ba_node->biic.bi_sadr,
ba->ba_node->biic.bi_eadr);
if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
printf(" [sadr %x eadr %x]",
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
#endif
return bl->bl_havedriver ? UNCONF : UNSUPP;
}
int
bi_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct bp_conf *bp = aux;
if (strcmp(bp->type, "bi"))
return 0;
return 1;
}
static int lastiv = 0;
void
bi_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
bi_attach(sc)
struct bi_softc *sc;
{
struct bp_conf *bp = aux;
struct bi_softc *bi = (void *)self;
struct bi_node *binode;
struct bi_attach_args ba;
int nodenr;
printf("\n");
bi->bi_base = (struct bi_node *)bp->bp_addr;
ba.ba_intcpu = 1 << mastercpu;
#define NODEPGS (sizeof(struct bi_node) / VAX_NBPG)
ba.ba_iot = sc->sc_iot;
ba.ba_busnr = sc->sc_busnr;
/*
* Interrupt numbers. All vectors from 256-512 are free, use
* them for BI devices and just count them up.
* Above 512 are only interrupt vectors for unibus devices.
* Is it realistic with more than 64 BI devices???
*/
for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
binode = (struct bi_node *)vax_map_physmem(
(paddr_t)(bi->bi_base + nodenr), NODEPGS);
if (badaddr((caddr_t)binode, 4)) {
vax_unmap_physmem((vaddr_t)binode, NODEPGS);
if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
NODESIZE, 0, &ba.ba_ioh)) {
printf("bi_attach: bus_space_map failed, node %d\n",
nodenr);
return;
}
if (badaddr((caddr_t)ba.ba_ioh, 4)) {
bus_space_unmap(sc->sc_iot, ba.ba_ioh, NODESIZE);
} else {
ba.ba_node = binode;
ba.ba_nodenr = nodenr;
ba.ba_busnr = 0; /* XXX */
config_found(self, &ba, bi_print);
ba.ba_ivec = 256 + lastiv;
lastiv += 4;
config_found(&sc->sc_dev, &ba, bi_print);
}
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bireg.h,v 1.5 1999/07/12 13:42:42 ragge Exp $ */
/* $NetBSD: bireg.h,v 1.6 1999/08/04 19:12:22 ragge Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@ -44,7 +44,8 @@
/*
* BI node addresses
*/
#define BI_NODE(node) (0x2000 * (node))
#define NODESIZE 0x2000 /* Size of one BI node */
#define BI_NODE(node) (NODESIZE * (node))
#define BI_BASE(bi,nod) ((0x20000000 + (bi) * 0x2000000) + BI_NODE(nod))
#define MAXNBI 16 /* Spec says there can be 16 anyway */
#define NNODEBI 16 /* 16 nodes per BI */
@ -55,7 +56,10 @@
* These are followed with interface-specific registers.
*
* NB: This structure does NOT include the four GPRs (not anymore!)
*
* 990712: The structs not used anymore due to conversion to bus.h.
*/
#ifdef notdef
struct biiregs {
u_short bi_dtype; /* device type */
u_short bi_revs; /* revisions */
@ -97,6 +101,22 @@ struct bi_cpu {
u_long bi_xxx[63]; /* pad */
u_long bi_rxcd; /* receive console data register */
};
#endif
#define BIREG_DTYPE 0x00
#define BIREG_VAXBICSR 0x04
#define BIREG_BER 0x08
#define BIREG_EINTRCSR 0x0c
#define BIREG_INTRDES 0x10
#define BIREG_IPINTRMSK 0x14
#define BIREG_FIPSDES 0x18
#define BIREG_IPINTRSRC 0x1c
#define BIREG_SADR 0x20
#define BIREG_EADR 0x24
#define BIREG_BCICSR 0x28
#define BIREG_WSTAT 0x2c
#define BIREG_FIPSCMD 0x30
#define BIREG_UINTRCSR 0x40
/* device types */
#define BIDT_MS820 0x0001 /* MS820 memory board */

View File

@ -1,6 +1,6 @@
/* $NetBSD: bivar.h,v 1.3 1999/07/12 13:42:55 ragge Exp $ */
/* $NetBSD: bivar.h,v 1.4 1999/08/04 19:12:22 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1996, 1999 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,18 +36,25 @@
* per-BI-adapter state.
*/
struct bi_softc {
struct device bi_dev;
struct bi_node *bi_base;
struct device sc_dev;
bus_space_tag_t sc_iot; /* Space tag for the BI bus */
bus_dma_tag_t sc_dmat;
bus_addr_t sc_addr; /* Address base address for this bus */
int sc_busnr; /* (Physical) number of this bus */
int sc_lastiv; /* last available interrupt vector */
};
/*
* Struct used for autoconfiguration; attaching of BI nodes.
*/
struct bi_attach_args {
struct bi_node *ba_node;
bus_space_tag_t ba_iot;
bus_space_handle_t ba_ioh; /* Base address for this node */
bus_dma_tag_t ba_dmat;
int ba_busnr;
int ba_nodenr;
int ba_intcpu; /* Mask of which cpus to interrupt */
int ba_ivec; /* Interrupt vector to use */
};
/*
@ -55,6 +62,9 @@ struct bi_attach_args {
*/
struct bi_list {
u_short bl_nr; /* Unit ID# */
u_short bl_havedriver; /* Have device driver */
u_short bl_havedriver; /* Have device driver (informal) */
char *bl_name; /* DEC name */
};
/* Prototype */
void bi_attach __P((struct bi_softc *));