Revamp the bus_space(9) implementation:
. use a structure for the tag instead of an integer constant, . add bus_space_{peek,poke}_N() (and G/C `badaddr()'), . fix a few drivers which have dependencies on the implementation.
This commit is contained in:
parent
a70c48655b
commit
7d191ffe77
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clmpcc_pcctwo.c,v 1.5 2000/09/06 19:51:43 scw Exp $ */
|
||||
/* $NetBSD: clmpcc_pcctwo.c,v 1.6 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -181,19 +181,10 @@ clmpcc_pcctwo_consiackhook(sc, which)
|
|||
struct clmpcc_softc *sc;
|
||||
int which;
|
||||
{
|
||||
bus_space_tag_t bust;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
volatile u_char foo;
|
||||
|
||||
/*
|
||||
* We need to fake the tag and handle since 'sys_pcctwo' will
|
||||
* be NULL during early system startup...
|
||||
*/
|
||||
bust = MVME68K_INTIO_BUS_SPACE;
|
||||
bush = (bus_space_tag_t) & (intiobase[MAINBUS_PCCTWO_OFFSET +
|
||||
PCCTWO_REG_OFF]);
|
||||
|
||||
switch (which) {
|
||||
case CLMPCC_IACK_MODEM:
|
||||
offset = PCC2REG_SCC_MODEM_PIACK;
|
||||
|
@ -214,7 +205,14 @@ clmpcc_pcctwo_consiackhook(sc, which)
|
|||
#endif
|
||||
}
|
||||
|
||||
foo = bus_space_read_1(bust, bush, offset);
|
||||
/*
|
||||
* We need to fake the tag and handle since 'sys_pcctwo' will
|
||||
* be NULL during early system startup...
|
||||
*/
|
||||
bush = (bus_space_handle_t) & (intiobase[MAINBUS_PCCTWO_OFFSET +
|
||||
PCCTWO_REG_OFF]);
|
||||
|
||||
foo = bus_space_read_1(&_mainbus_space_tag, bush, offset);
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,8 +253,9 @@ clmpcccninit(cp)
|
|||
{
|
||||
static struct clmpcc_softc cons_sc;
|
||||
|
||||
cons_sc.sc_iot = MVME68K_INTIO_BUS_SPACE;
|
||||
bus_space_map(cons_sc.sc_iot, MAINBUS_PCCTWO_OFFSET + PCCTWO_SCC_OFF,
|
||||
cons_sc.sc_iot = &_mainbus_space_tag;
|
||||
bus_space_map(&_mainbus_space_tag,
|
||||
intiobase_phys + MAINBUS_PCCTWO_OFFSET + PCCTWO_SCC_OFF,
|
||||
PCC2REG_SIZE, 0, &cons_sc.sc_ioh);
|
||||
cons_sc.sc_clk = 20000000;
|
||||
cons_sc.sc_byteswap = CLMPCC_BYTESWAP_LOW;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mainbus.c,v 1.4 2000/11/20 19:35:29 scw Exp $ */
|
||||
/* $NetBSD: mainbus.c,v 1.5 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -46,8 +46,10 @@
|
|||
#include <sys/device.h>
|
||||
|
||||
#define _MVME68K_BUS_DMA_PRIVATE
|
||||
#define _MVME68K_BUS_SPACE_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#undef _MVME68K_BUS_DMA_PRIVATE
|
||||
#undef _MVME68K_BUS_SPACE_PRIVATE
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <mvme68k/dev/mainbus.h>
|
||||
|
@ -57,13 +59,8 @@ void mainbus_attach __P((struct device *, struct device *, void *));
|
|||
int mainbus_match __P((struct device *, struct cfdata *, void *));
|
||||
int mainbus_print __P((void *, const char *));
|
||||
|
||||
struct mainbus_softc {
|
||||
struct device sc_dev;
|
||||
struct mvme68k_bus_dma_tag sc_dmat;
|
||||
};
|
||||
|
||||
struct cfattach mainbus_ca = {
|
||||
sizeof(struct mainbus_softc), mainbus_match, mainbus_attach
|
||||
sizeof(struct device), mainbus_match, mainbus_attach
|
||||
};
|
||||
|
||||
|
||||
|
@ -87,6 +84,37 @@ static struct mainbus_devices mainbusdevs_1x7[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct mvme68k_bus_dma_tag _mainbus_dma_tag = {
|
||||
NULL,
|
||||
_bus_dmamap_create,
|
||||
_bus_dmamap_destroy,
|
||||
_bus_dmamap_load_direct,
|
||||
_bus_dmamap_load_mbuf_direct,
|
||||
_bus_dmamap_load_uio_direct,
|
||||
_bus_dmamap_load_raw_direct,
|
||||
_bus_dmamap_unload,
|
||||
NULL, /* Set up at run-time */
|
||||
_bus_dmamem_alloc,
|
||||
_bus_dmamem_free,
|
||||
_bus_dmamem_map,
|
||||
_bus_dmamem_unmap,
|
||||
_bus_dmamem_mmap
|
||||
};
|
||||
|
||||
struct mvme68k_bus_space_tag _mainbus_space_tag = {
|
||||
NULL,
|
||||
_bus_space_map,
|
||||
_bus_space_unmap,
|
||||
_bus_space_peek_1,
|
||||
_bus_space_peek_2,
|
||||
_bus_space_peek_4,
|
||||
_bus_space_poke_1,
|
||||
_bus_space_poke_2,
|
||||
_bus_space_poke_4
|
||||
};
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
mainbus_match(parent, cf, args)
|
||||
|
@ -109,31 +137,10 @@ mainbus_attach(parent, self, args)
|
|||
struct device *self;
|
||||
void *args;
|
||||
{
|
||||
struct mainbus_softc *sc;
|
||||
struct mainbus_attach_args ma;
|
||||
struct mainbus_devices *devices;
|
||||
int i;
|
||||
|
||||
sc = (struct mainbus_softc *) self;
|
||||
|
||||
/*
|
||||
* Initialise the mainbus Bus DMA tag.
|
||||
*/
|
||||
sc->sc_dmat._cookie = sc;
|
||||
sc->sc_dmat._dmamap_create = _bus_dmamap_create;
|
||||
sc->sc_dmat._dmamap_destroy = _bus_dmamap_destroy;
|
||||
sc->sc_dmat._dmamap_load = _bus_dmamap_load_direct;
|
||||
sc->sc_dmat._dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
|
||||
sc->sc_dmat._dmamap_load_uio = _bus_dmamap_load_uio_direct;
|
||||
sc->sc_dmat._dmamap_load_raw = _bus_dmamap_load_raw_direct;
|
||||
sc->sc_dmat._dmamap_unload = _bus_dmamap_unload;
|
||||
sc->sc_dmat._dmamap_sync = _bus_dmamap_sync;
|
||||
sc->sc_dmat._dmamem_alloc = _bus_dmamem_alloc;
|
||||
sc->sc_dmat._dmamem_free = _bus_dmamem_free;
|
||||
sc->sc_dmat._dmamem_map = _bus_dmamem_map;
|
||||
sc->sc_dmat._dmamem_unmap = _bus_dmamem_unmap;
|
||||
sc->sc_dmat._dmamem_mmap = _bus_dmamem_mmap;
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
|
@ -143,6 +150,7 @@ mainbus_attach(parent, self, args)
|
|||
#ifdef MVME147
|
||||
case MVME_147:
|
||||
devices = mainbusdevs_147;
|
||||
_mainbus_dma_tag._dmamap_sync = _bus_dmamap_sync_030;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -152,6 +160,7 @@ mainbus_attach(parent, self, args)
|
|||
case MVME_172:
|
||||
case MVME_177:
|
||||
devices = mainbusdevs_1x7;
|
||||
_mainbus_dma_tag._dmamap_sync = _bus_dmamap_sync_0460;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -161,9 +170,9 @@ mainbus_attach(parent, self, args)
|
|||
|
||||
for (i = 0; devices[i].md_name != NULL; ++i) {
|
||||
ma.ma_name = devices[i].md_name;
|
||||
ma.ma_dmat = &sc->sc_dmat;
|
||||
ma.ma_bust = MVME68K_INTIO_BUS_SPACE;
|
||||
ma.ma_offset = devices[i].md_offset;
|
||||
ma.ma_dmat = &_mainbus_dma_tag;
|
||||
ma.ma_bust = &_mainbus_space_tag;
|
||||
ma.ma_offset = devices[i].md_offset + intiobase_phys;
|
||||
|
||||
(void) config_found(self, &ma, mainbus_print);
|
||||
}
|
||||
|
@ -181,7 +190,7 @@ mainbus_print(aux, cp)
|
|||
if (cp)
|
||||
printf("%s at %s", ma->ma_name, cp);
|
||||
|
||||
printf(" offset 0x%lx", ma->ma_offset);
|
||||
printf(" offset 0x%lx", ma->ma_offset - intiobase_phys);
|
||||
|
||||
return (UNCONF);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mainbus.h,v 1.2 2000/03/18 22:33:03 scw Exp $ */
|
||||
/* $NetBSD: mainbus.h,v 1.3 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -57,4 +57,7 @@ struct mainbus_attach_args {
|
|||
#define MAINBUS_VMETWO_OFFSET 0x0000u
|
||||
#define MAINBUS_PCCTWO_OFFSET 0x2000u
|
||||
|
||||
extern struct mvme68k_bus_space_tag _mainbus_space_tag;
|
||||
extern struct mvme68k_bus_dma_tag _mainbus_dma_tag;
|
||||
|
||||
#endif /* _MVME68K_MAINBUS_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mvmebus.c,v 1.5 2000/09/19 19:35:52 scw Exp $ */
|
||||
/* $NetBSD: mvmebus.c,v 1.6 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -282,13 +282,13 @@ mvmebus_map(vsc, vmeaddr, len, am, datasize, swap, tag, handle, resc)
|
|||
if (paddr == 0)
|
||||
return (ENOMEM);
|
||||
|
||||
rv = bus_space_map(MVME68K_VME_BUS_SPACE, paddr, len, 0, handle);
|
||||
rv = bus_space_map(sc->sc_bust, paddr, len, 0, handle);
|
||||
if (rv != 0)
|
||||
return (rv);
|
||||
|
||||
/* Allocate space for the resource tag */
|
||||
if ((mr = malloc(sizeof(*mr), M_DEVBUF, M_NOWAIT)) == NULL) {
|
||||
bus_space_unmap(MVME68K_VME_BUS_SPACE, *handle, len);
|
||||
bus_space_unmap(sc->sc_bust, *handle, len);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ mvmebus_map(vsc, vmeaddr, len, am, datasize, swap, tag, handle, resc)
|
|||
mr->mr_handle = *handle;
|
||||
mr->mr_range = i;
|
||||
|
||||
*tag = MVME68K_VME_BUS_SPACE;
|
||||
*tag = sc->sc_bust;
|
||||
*resc = (vme_mapresc_t *) mr;
|
||||
|
||||
return (0);
|
||||
|
@ -312,9 +312,10 @@ mvmebus_unmap(vsc, resc)
|
|||
void *vsc;
|
||||
vme_mapresc_t resc;
|
||||
{
|
||||
struct mvmebus_softc *sc = vsc;
|
||||
struct mvmebus_mapresc *mr = (struct mvmebus_mapresc *) resc;
|
||||
|
||||
bus_space_unmap(MVME68K_VME_BUS_SPACE, mr->mr_handle, mr->mr_size);
|
||||
bus_space_unmap(sc->sc_bust, mr->mr_handle, mr->mr_size);
|
||||
|
||||
free(mr, M_DEVBUF);
|
||||
}
|
||||
|
@ -332,6 +333,7 @@ mvmebus_probe(vsc, vmeaddr, len, am, datasize, callback, arg)
|
|||
bus_space_tag_t tag;
|
||||
bus_space_handle_t handle;
|
||||
vme_mapresc_t resc;
|
||||
vme_size_t offs;
|
||||
int rv;
|
||||
|
||||
/* Get a temporary mapping to the VMEbus range */
|
||||
|
@ -342,14 +344,25 @@ mvmebus_probe(vsc, vmeaddr, len, am, datasize, callback, arg)
|
|||
|
||||
if (callback)
|
||||
rv = (*callback) (arg, tag, handle);
|
||||
else {
|
||||
/*
|
||||
* FIXME: Using badaddr() in this way may cause several
|
||||
* accesses to each VMEbus address. Also, using 'handle' in
|
||||
* this way is a bit presumptuous...
|
||||
*/
|
||||
rv = badaddr((caddr_t) handle, (int) len) ? EIO : 0;
|
||||
}
|
||||
else
|
||||
for (offs = 0; offs < len && rv == 0;) {
|
||||
switch (datasize) {
|
||||
case VME_D8:
|
||||
rv = bus_space_peek_1(tag, handle, offs, NULL);
|
||||
offs += 1;
|
||||
break;
|
||||
|
||||
case VME_D16:
|
||||
rv = bus_space_peek_2(tag, handle, offs, NULL);
|
||||
offs += 2;
|
||||
break;
|
||||
|
||||
case VME_D32:
|
||||
rv = bus_space_peek_4(tag, handle, offs, NULL);
|
||||
offs += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mvmebus_unmap(vsc, resc);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcc.c,v 1.14 2000/08/20 21:51:31 scw Exp $ */
|
||||
/* $NetBSD: pcc.c,v 1.15 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -211,6 +211,7 @@ pccattach(parent, self, args)
|
|||
/*
|
||||
* Attach configured children.
|
||||
*/
|
||||
npa._pa_base = ma->ma_offset;
|
||||
for (i = 0; pcc_devices[i].pcc_name != NULL; ++i) {
|
||||
/*
|
||||
* Note that IPL is filled in by match function.
|
||||
|
@ -238,7 +239,7 @@ pccprint(aux, cp)
|
|||
if (cp)
|
||||
printf("%s at %s", pa->pa_name, cp);
|
||||
|
||||
printf(" offset 0x%lx", pa->pa_offset);
|
||||
printf(" offset 0x%lx", pa->pa_offset - pa->_pa_base);
|
||||
if (pa->pa_ipl != -1)
|
||||
printf(" ipl %d", pa->pa_ipl);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcctwo.c,v 1.5 2000/11/20 19:35:29 scw Exp $ */
|
||||
/* $NetBSD: pcctwo.c,v 1.6 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -261,6 +261,7 @@ pcctwoattach(parent, self, args)
|
|||
/*
|
||||
* Attach configured children.
|
||||
*/
|
||||
npa._pa_base = ma->ma_offset;
|
||||
while (pd->pcc_name != NULL) {
|
||||
/*
|
||||
* Note that IPL is filled in by match function.
|
||||
|
@ -289,7 +290,7 @@ pcctwoprint(aux, cp)
|
|||
if (cp)
|
||||
printf("%s at %s", pa->pa_name, cp);
|
||||
|
||||
printf(" offset 0x%lx", pa->pa_offset);
|
||||
printf(" offset 0x%lx", pa->pa_offset - pa->_pa_base);
|
||||
if (pa->pa_ipl != -1)
|
||||
printf(" ipl %d", pa->pa_ipl);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcctwovar.h,v 1.3 2000/09/06 19:51:44 scw Exp $ */
|
||||
/* $NetBSD: pcctwovar.h,v 1.4 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -48,6 +48,8 @@ struct pcctwo_attach_args {
|
|||
bus_dma_tag_t pa_dmat; /* DMA tag */
|
||||
bus_space_tag_t pa_bust; /* Bus tag */
|
||||
bus_addr_t pa_offset; /* Offset with 'Bus tag' bus space */
|
||||
|
||||
bus_addr_t _pa_base;
|
||||
};
|
||||
|
||||
/* Shorthand for locators. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pccvar.h,v 1.6 2000/08/20 21:51:31 scw Exp $ */
|
||||
/* $NetBSD: pccvar.h,v 1.7 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -48,6 +48,8 @@ struct pcc_attach_args {
|
|||
bus_dma_tag_t pa_dmat;
|
||||
bus_space_tag_t pa_bust;
|
||||
bus_addr_t pa_offset;
|
||||
|
||||
bus_addr_t _pa_base;
|
||||
};
|
||||
|
||||
/* Shorthand for locators. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: zs_pcc.c,v 1.10 2000/09/06 19:51:44 scw Exp $ */
|
||||
/* $NetBSD: zs_pcc.c,v 1.11 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
|
@ -191,11 +191,11 @@ void
|
|||
zsc_pcccninit(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
bus_space_tag_t bust = MVME68K_INTIO_BUS_SPACE;
|
||||
bus_space_handle_t bush;
|
||||
struct zsdevice zs;
|
||||
|
||||
bus_space_map(bust, MAINBUS_PCC_OFFSET + PCC_ZS0_OFF, 4, 0, &bush);
|
||||
bus_space_map(&_mainbus_space_tag,
|
||||
intiobase_phys + MAINBUS_PCC_OFFSET + PCC_ZS0_OFF, 4, 0, &bush);
|
||||
|
||||
/* XXX: This is a gross hack. I need to bus-space zs.c ... */
|
||||
zs.zs_chan_b.zc_csr = (volatile u_char *) bush;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: zs_pcctwo.c,v 1.2 2000/11/20 19:35:29 scw Exp $ */
|
||||
/* $NetBSD: zs_pcctwo.c,v 1.3 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -172,11 +172,11 @@ void
|
|||
zsc_pcctwocninit(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
bus_space_tag_t bust = MVME68K_INTIO_BUS_SPACE;
|
||||
bus_space_handle_t bush;
|
||||
struct zsdevice zs;
|
||||
|
||||
bus_space_map(bust, MAINBUS_PCCTWO_OFFSET + MCCHIP_ZS0_OFF, 8, 0,&bush);
|
||||
bus_space_map(&_mainbus_space_tag,
|
||||
intiobase_phys + MAINBUS_PCCTWO_OFFSET + MCCHIP_ZS0_OFF, 8, 0,&bush);
|
||||
|
||||
/* XXX: This is a gross hack. I need to bus-space zs.c ... */
|
||||
zs.zs_chan_b.zc_csr = (volatile u_char *) bush + 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bus_dma.h,v 1.5 2000/08/20 17:07:43 scw Exp $ */
|
||||
/* $NetBSD: bus_dma.h,v 1.6 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*
|
||||
* This file was extracted from from next68k/include/bus.h
|
||||
|
@ -236,9 +236,6 @@ void _bus_dmamap_sync_030 __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
|
|||
bus_size_t, int));
|
||||
void _bus_dmamap_sync_0460 __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
|
||||
bus_size_t, int));
|
||||
/* Set to the appropriate function in machdep.c */
|
||||
extern void (*_bus_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
|
||||
bus_size_t, int);
|
||||
|
||||
int _bus_dmamem_alloc_common __P((bus_dma_tag_t,
|
||||
bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, bus_size_t,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.h,v 1.20 2000/11/20 19:35:29 scw Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.21 2000/11/24 09:36:41 scw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
|
@ -189,7 +189,6 @@ extern u_char mvme_ea[6];
|
|||
struct frame;
|
||||
void doboot __P((int))
|
||||
__attribute__((__noreturn__));
|
||||
int badaddr __P((caddr_t, int));
|
||||
int nmihand __P((void *));
|
||||
void mvme68k_abort __P((const char *));
|
||||
void physaccess __P((caddr_t, caddr_t, int, int));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bus_space.c,v 1.3 2000/11/16 19:12:20 scw Exp $ */
|
||||
/* $NetBSD: bus_space.c,v 1.4 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -47,15 +47,31 @@
|
|||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/pte.h>
|
||||
#define _MVME68K_BUS_DMA_PRIVATE /* For _bus_dmamem_map/_bus_dmamem_unmap */
|
||||
#define _MVME68K_BUS_DMA_PRIVATE /* For _bus_dmamem_map/_bus_dmamem_unmap */
|
||||
#define _MVME68K_BUS_SPACE_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#undef _MVME68K_BUS_DMA_PRIVATE
|
||||
#undef _MVME68K_BUS_SPACE_PRIVATE
|
||||
|
||||
static void peek1(void *, void *);
|
||||
static void peek2(void *, void *);
|
||||
static void peek4(void *, void *);
|
||||
static void poke1(void *, u_int);
|
||||
static void poke2(void *, u_int);
|
||||
static void poke4(void *, u_int);
|
||||
static int do_peek(void (*)(void *, void *), void *, void *);
|
||||
static int do_poke(void (*)(void *, u_int), void *, u_int);
|
||||
|
||||
/*
|
||||
* Used in locore.s/trap.c to determine if faults are being trapped.
|
||||
*/
|
||||
label_t *nofault;
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
bus_space_map(bust, addr, size, flags, bushp)
|
||||
bus_space_tag_t bust;
|
||||
_bus_space_map(cookie, addr, size, flags, bushp)
|
||||
void *cookie;
|
||||
bus_addr_t addr;
|
||||
bus_size_t size;
|
||||
int flags;
|
||||
|
@ -63,31 +79,30 @@ bus_space_map(bust, addr, size, flags, bushp)
|
|||
{
|
||||
bus_dma_segment_t seg;
|
||||
caddr_t va;
|
||||
int rv;
|
||||
|
||||
if ( bust == MVME68K_INTIO_BUS_SPACE ) {
|
||||
if (addr >= intiobase_phys && addr < intiotop_phys) {
|
||||
#ifdef DEBUG
|
||||
if ((addr + size) >= intiotop_phys)
|
||||
panic("mvme68k_bus_space_map: Invalid INTIO range!");
|
||||
#endif
|
||||
/*
|
||||
* Intio space is direct-mapped in pmap_bootstrap(); just
|
||||
* do the translation.
|
||||
*/
|
||||
if ( &(intiobase[addr + size]) >= intiolimit )
|
||||
return (EINVAL);
|
||||
|
||||
addr -= intiobase_phys;
|
||||
*bushp = (bus_space_handle_t) &(intiobase[addr]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ( bust != MVME68K_VME_BUS_SPACE )
|
||||
panic("bus_space_map: bad space tag");
|
||||
|
||||
seg._ds_cpuaddr = m68k_trunc_page(addr);
|
||||
/*
|
||||
* Otherwise, set up a VM mapping for the requested address range
|
||||
*/
|
||||
seg.ds_addr = seg._ds_cpuaddr = m68k_trunc_page(addr);
|
||||
seg.ds_len = m68k_round_page(size);
|
||||
|
||||
rv = _bus_dmamem_map(NULL, &seg, 1, seg.ds_len, &va,
|
||||
flags | BUS_DMA_COHERENT);
|
||||
|
||||
if ( rv != 0 )
|
||||
return rv;
|
||||
if (_bus_dmamem_map(NULL, &seg, 1, seg.ds_len, &va,
|
||||
flags | BUS_DMA_COHERENT))
|
||||
return EIO;
|
||||
|
||||
/*
|
||||
* The handle is really the virtual address we just mapped
|
||||
|
@ -97,25 +112,188 @@ bus_space_map(bust, addr, size, flags, bushp)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
bus_space_unmap(bust, bush, size)
|
||||
bus_space_tag_t bust;
|
||||
_bus_space_unmap(cookie, bush, size)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t size;
|
||||
{
|
||||
if ( bust == MVME68K_INTIO_BUS_SPACE ) {
|
||||
/*
|
||||
* Intio space is direct-mapped in pmap_bootstrap(); nothing
|
||||
* to do
|
||||
*/
|
||||
/* Nothing to do for INTIO space */
|
||||
if ((char *)bush >= intiobase && (char *)bush < intiolimit)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( bust != MVME68K_VME_BUS_SPACE )
|
||||
panic("bus_space_unmap: bad space tag");
|
||||
|
||||
bush = m68k_trunc_page(bush);
|
||||
size = m68k_round_page(size);
|
||||
|
||||
_bus_dmamem_unmap(NULL, (caddr_t) bush, size);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_peek_1(cookie, bush, offset, valuep)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int8_t *valuep;
|
||||
{
|
||||
u_int8_t v;
|
||||
|
||||
if (valuep == NULL)
|
||||
valuep = &v;
|
||||
|
||||
return (do_peek(&peek1, (void *)(bush + offset), (void *)valuep));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_peek_2(cookie, bush, offset, valuep)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int16_t *valuep;
|
||||
{
|
||||
u_int16_t v;
|
||||
|
||||
if (valuep == NULL)
|
||||
valuep = &v;
|
||||
|
||||
return (do_peek(&peek2, (void *)(bush + offset), (void *)valuep));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_peek_4(cookie, bush, offset, valuep)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int32_t *valuep;
|
||||
{
|
||||
u_int32_t v;
|
||||
|
||||
if (valuep == NULL)
|
||||
valuep = &v;
|
||||
|
||||
return (do_peek(&peek4, (void *)(bush + offset), (void *)valuep));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_poke_1(cookie, bush, offset, value)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int8_t value;
|
||||
{
|
||||
return (do_poke(&poke1, (void *)(bush + offset), (u_int)value));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_poke_2(cookie, bush, offset, value)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int16_t value;
|
||||
{
|
||||
return (do_poke(&poke2, (void *)(bush + offset), (u_int)value));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
_bus_space_poke_4(cookie, bush, offset, value)
|
||||
void *cookie;
|
||||
bus_space_handle_t bush;
|
||||
bus_size_t offset;
|
||||
u_int32_t value;
|
||||
{
|
||||
return (do_poke(&poke4, (void *)(bush + offset), (u_int)value));
|
||||
}
|
||||
|
||||
static void
|
||||
peek1(addr, vp)
|
||||
void *addr;
|
||||
void *vp;
|
||||
{
|
||||
*((u_int8_t *)vp) = *((u_int8_t *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
peek2(addr, vp)
|
||||
void *addr;
|
||||
void *vp;
|
||||
{
|
||||
*((u_int16_t *)vp) = *((u_int16_t *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
peek4(addr, vp)
|
||||
void *addr;
|
||||
void *vp;
|
||||
{
|
||||
*((u_int32_t *)vp) = *((u_int32_t *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
poke1(addr, value)
|
||||
void *addr;
|
||||
u_int value;
|
||||
{
|
||||
*((u_int8_t *)addr) = value;
|
||||
}
|
||||
|
||||
static void
|
||||
poke2(addr, value)
|
||||
void *addr;
|
||||
u_int value;
|
||||
{
|
||||
*((u_int16_t *)addr) = value;
|
||||
}
|
||||
|
||||
static void
|
||||
poke4(addr, value)
|
||||
void *addr;
|
||||
u_int value;
|
||||
{
|
||||
*((u_int32_t *)addr) = value;
|
||||
}
|
||||
|
||||
static int
|
||||
do_peek(peekfn, addr, valuep)
|
||||
void (*peekfn)(void *, void *);
|
||||
void *addr;
|
||||
void *valuep;
|
||||
{
|
||||
label_t faultbuf;
|
||||
|
||||
nofault = &faultbuf;
|
||||
if (setjmp(&faultbuf)) {
|
||||
nofault = NULL;
|
||||
return (1);
|
||||
}
|
||||
|
||||
(*peekfn)(addr, valuep);
|
||||
|
||||
nofault = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
do_poke(pokefn, addr, value)
|
||||
void (*pokefn)(void *, u_int);
|
||||
void *addr;
|
||||
u_int value;
|
||||
{
|
||||
label_t faultbuf;
|
||||
|
||||
nofault = &faultbuf;
|
||||
if (setjmp(&faultbuf)) {
|
||||
nofault = NULL;
|
||||
return (1);
|
||||
}
|
||||
|
||||
(*pokefn)(addr, value);
|
||||
|
||||
nofault = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.75 2000/11/20 19:35:30 scw Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.76 2000/11/24 09:36:40 scw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
|
@ -278,18 +278,14 @@ mvme68k_init()
|
|||
void
|
||||
mvme147_init()
|
||||
{
|
||||
bus_space_tag_t bt = MVME68K_INTIO_BUS_SPACE;
|
||||
bus_space_tag_t bt = &_mainbus_space_tag;
|
||||
bus_space_handle_t bh;
|
||||
|
||||
/*
|
||||
* Set up the correct bus dma map sync function for the '147
|
||||
*/
|
||||
_bus_dmamap_sync = _bus_dmamap_sync_030;
|
||||
|
||||
/*
|
||||
* Set up a temporary mapping to the PCC's registers
|
||||
*/
|
||||
bus_space_map(bt, MAINBUS_PCC_OFFSET + PCC_REG_OFF, PCCREG_SIZE, 0, &bh);
|
||||
bus_space_map(bt, intiobase_phys + MAINBUS_PCC_OFFSET + PCC_REG_OFF,
|
||||
PCCREG_SIZE, 0, &bh);
|
||||
|
||||
/*
|
||||
* calibrate delay() using the 6.25 usec counter.
|
||||
|
@ -326,18 +322,13 @@ mvme147_init()
|
|||
void
|
||||
mvme1xx_init()
|
||||
{
|
||||
bus_space_tag_t bt = MVME68K_INTIO_BUS_SPACE;
|
||||
bus_space_tag_t bt = &_mainbus_space_tag;
|
||||
bus_space_handle_t bh;
|
||||
|
||||
/*
|
||||
* Set up the correct bus dma map sync function
|
||||
*/
|
||||
_bus_dmamap_sync = _bus_dmamap_sync_0460;
|
||||
|
||||
/*
|
||||
* Set up a temporary mapping to the PCCChip2's registers
|
||||
*/
|
||||
bus_space_map(bt, MAINBUS_PCCTWO_OFFSET + PCCTWO_REG_OFF,
|
||||
bus_space_map(bt, intiobase_phys + MAINBUS_PCCTWO_OFFSET + PCCTWO_REG_OFF,
|
||||
PCC2REG_SIZE, 0, &bh);
|
||||
|
||||
bus_space_write_1(bt, bh, PCC2REG_TIMER1_ICSR, 0);
|
||||
|
@ -1143,46 +1134,6 @@ straytrap(pc, evec)
|
|||
evec & 0xFFF, pc);
|
||||
}
|
||||
|
||||
int *nofault;
|
||||
|
||||
int
|
||||
badaddr(addr, nbytes)
|
||||
caddr_t addr;
|
||||
int nbytes;
|
||||
{
|
||||
int i;
|
||||
label_t faultbuf;
|
||||
|
||||
#ifdef lint
|
||||
i = *addr; if (i) return (0);
|
||||
#endif
|
||||
|
||||
nofault = (int *) &faultbuf;
|
||||
if (setjmp((label_t *)nofault)) {
|
||||
nofault = (int *) 0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
switch (nbytes) {
|
||||
case 1:
|
||||
i = *(volatile char *)addr;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
i = *(volatile short *)addr;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
i = *(volatile int *)addr;
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("badaddr: bad request");
|
||||
}
|
||||
nofault = (int *) 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* XXX wrapper for locore.s; used only my level 7 autovector */
|
||||
void
|
||||
nmintr(frame)
|
||||
|
|
Loading…
Reference in New Issue