Rewrite bus stuff with method table in the bus tags.
This commit is contained in:
parent
be010c72ef
commit
1d1d5c87af
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.hpcmips,v 1.61 2001/09/17 17:03:44 uch Exp $
|
||||
# $NetBSD: files.hpcmips,v 1.62 2001/11/18 08:19:39 takemura Exp $
|
||||
|
||||
# maxpartitions must be first item in files.${ARCH}.
|
||||
maxpartitions 8
|
||||
|
@ -53,6 +53,7 @@ file arch/mips/mips/fp.S softfloat
|
|||
file arch/hpcmips/hpcmips/autoconf.c
|
||||
file arch/hpcmips/hpcmips/bus_dma.c
|
||||
file arch/hpcmips/hpcmips/bus_space.c
|
||||
file arch/hpcmips/hpcmips/bus_space_notimpl.c
|
||||
file arch/hpcmips/hpcmips/conf.c
|
||||
file arch/hpcmips/hpcmips/interrupt.c
|
||||
file arch/hpcmips/hpcmips/machdep.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: plumohci.c,v 1.4 2001/09/15 12:47:06 uch Exp $ */
|
||||
/* $NetBSD: plumohci.c,v 1.5 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 UCHIYAMA Yasushi
|
||||
|
@ -45,8 +45,8 @@
|
|||
#include <sys/mbuf.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#define _HPCMIPS_BUS_DMA_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_dma_hpcmips.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
|
@ -75,21 +75,26 @@ int __plumohci_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *,
|
|||
int, size_t, caddr_t *, int);
|
||||
void __plumohci_dmamem_unmap(bus_dma_tag_t, caddr_t, size_t);
|
||||
|
||||
struct hpcmips_bus_dma_tag plumohci_bus_dma_tag = {
|
||||
_bus_dmamap_create,
|
||||
_bus_dmamap_destroy,
|
||||
_bus_dmamap_load,
|
||||
_bus_dmamap_load_mbuf,
|
||||
_bus_dmamap_load_uio,
|
||||
_bus_dmamap_load_raw,
|
||||
_bus_dmamap_unload,
|
||||
__plumohci_dmamap_sync,
|
||||
__plumohci_dmamem_alloc,
|
||||
__plumohci_dmamem_free,
|
||||
__plumohci_dmamem_map,
|
||||
__plumohci_dmamem_unmap,
|
||||
_bus_dmamem_mmap,
|
||||
NULL
|
||||
struct bus_dma_tag_hpcmips plumohci_bus_dma_tag = {
|
||||
{
|
||||
NULL,
|
||||
{
|
||||
_hpcmips_bd_map_create,
|
||||
_hpcmips_bd_map_destroy,
|
||||
_hpcmips_bd_map_load,
|
||||
_hpcmips_bd_map_load_mbuf,
|
||||
_hpcmips_bd_map_load_uio,
|
||||
_hpcmips_bd_map_load_raw,
|
||||
_hpcmips_bd_map_unload,
|
||||
__plumohci_dmamap_sync,
|
||||
__plumohci_dmamem_alloc,
|
||||
__plumohci_dmamem_free,
|
||||
__plumohci_dmamem_map,
|
||||
__plumohci_dmamem_unmap,
|
||||
_hpcmips_bd_mem_mmap,
|
||||
},
|
||||
},
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct plumohci_shm {
|
||||
|
@ -128,8 +133,8 @@ plumohci_attach(struct device *parent, struct device *self, void *aux)
|
|||
usbd_status r;
|
||||
|
||||
sc->sc.iot = pa->pa_iot;
|
||||
sc->sc.sc_bus.dmatag = &plumohci_bus_dma_tag;
|
||||
sc->sc.sc_bus.dmatag->_dmamap_chipset_v = sc;
|
||||
sc->sc.sc_bus.dmatag = &plumohci_bus_dma_tag.bdt;
|
||||
plumohci_bus_dma_tag._dmamap_chipset_v = sc;
|
||||
|
||||
/* Map I/O space */
|
||||
if (bus_space_map(sc->sc.iot, PLUM_OHCI_REGBASE, OHCI_PAGE_SIZE,
|
||||
|
@ -199,9 +204,10 @@ plumohci_intr(void *arg)
|
|||
*/
|
||||
|
||||
void
|
||||
__plumohci_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
||||
__plumohci_dmamap_sync(bus_dma_tag_t tx, bus_dmamap_t map, bus_addr_t offset,
|
||||
bus_size_t len, int ops)
|
||||
{
|
||||
struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
|
||||
struct plumohci_softc *sc = t->_dmamap_chipset_v;
|
||||
|
||||
/*
|
||||
|
@ -212,10 +218,11 @@ __plumohci_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
}
|
||||
|
||||
int
|
||||
__plumohci_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
||||
bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
|
||||
int flags)
|
||||
__plumohci_dmamem_alloc(bus_dma_tag_t tx, bus_size_t size,
|
||||
bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs,
|
||||
int nsegs, int *rsegs, int flags)
|
||||
{
|
||||
struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
|
||||
struct plumohci_softc *sc = t->_dmamap_chipset_v;
|
||||
struct plumohci_shm *ps;
|
||||
bus_space_handle_t bsh;
|
||||
|
@ -254,8 +261,9 @@ __plumohci_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
|||
}
|
||||
|
||||
void
|
||||
__plumohci_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
||||
__plumohci_dmamem_free(bus_dma_tag_t tx, bus_dma_segment_t *segs, int nsegs)
|
||||
{
|
||||
struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
|
||||
struct plumohci_softc *sc = t->_dmamap_chipset_v;
|
||||
struct plumohci_shm *ps;
|
||||
|
||||
|
@ -276,9 +284,10 @@ __plumohci_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
|||
}
|
||||
|
||||
int
|
||||
__plumohci_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
__plumohci_dmamem_map(bus_dma_tag_t tx, bus_dma_segment_t *segs, int nsegs,
|
||||
size_t size, caddr_t *kvap, int flags)
|
||||
{
|
||||
struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
|
||||
struct plumohci_softc *sc = t->_dmamap_chipset_v;
|
||||
struct plumohci_shm *ps;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: plumpcmcia.c,v 1.7 2001/09/15 12:47:06 uch Exp $ */
|
||||
/* $NetBSD: plumpcmcia.c,v 1.8 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
|
||||
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/config_hook.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#include <dev/pcmcia/pcmciareg.h>
|
||||
#include <dev/pcmcia/pcmciavar.h>
|
||||
|
@ -373,7 +374,8 @@ plumpcmcia_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
|
|||
|
||||
pcmhp->memt = ph->ph_memt;
|
||||
/* Address offset from MEM area base */
|
||||
pcmhp->addr = pcmhp->memh - ph->ph_membase - ph->ph_memt->t_base;
|
||||
pcmhp->addr = pcmhp->memh - ph->ph_membase -
|
||||
((struct bus_space_tag_hpcmips*)ph->ph_memt)->base;
|
||||
pcmhp->size = size;
|
||||
pcmhp->realsize = realsize;
|
||||
|
||||
|
@ -531,7 +533,7 @@ plumpcmcia_chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start,
|
|||
}
|
||||
/* Address offset from IO area base */
|
||||
pcihp->addr = pcihp->ioh - ph->ph_iobase -
|
||||
ph->ph_iot->t_base;
|
||||
((struct bus_space_tag_hpcmips*)ph->ph_iot)->base;
|
||||
pcihp->flags = PCMCIA_IO_ALLOCATED;
|
||||
DPRINTF(("(allocated) %#x+%#x\n", (unsigned)pcihp->addr,
|
||||
(unsigned)size));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bus_dma.c,v 1.13 2001/11/14 18:15:18 thorpej Exp $ */
|
||||
/* $NetBSD: bus_dma.c,v 1.14 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -45,10 +45,10 @@
|
|||
#include <uvm/uvm_extern.h>
|
||||
#include <mips/cache.h>
|
||||
|
||||
#define _HPCMIPS_BUS_DMA_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_dma_hpcmips.h>
|
||||
|
||||
static int _bus_dmamap_load_buffer(bus_dmamap_t, void *, bus_size_t,
|
||||
static int _hpcmips_bd_map_load_buffer(bus_dmamap_t, void *, bus_size_t,
|
||||
struct proc *, int, vaddr_t *, int *, int);
|
||||
|
||||
paddr_t kvtophys(vaddr_t); /* XXX */
|
||||
|
@ -56,21 +56,26 @@ paddr_t kvtophys(vaddr_t); /* XXX */
|
|||
/*
|
||||
* The default DMA tag for all busses on the hpcmips
|
||||
*/
|
||||
struct hpcmips_bus_dma_tag hpcmips_default_bus_dma_tag = {
|
||||
_bus_dmamap_create,
|
||||
_bus_dmamap_destroy,
|
||||
_bus_dmamap_load,
|
||||
_bus_dmamap_load_mbuf,
|
||||
_bus_dmamap_load_uio,
|
||||
_bus_dmamap_load_raw,
|
||||
_bus_dmamap_unload,
|
||||
_bus_dmamap_sync,
|
||||
_bus_dmamem_alloc,
|
||||
_bus_dmamem_free,
|
||||
_bus_dmamem_map,
|
||||
_bus_dmamem_unmap,
|
||||
_bus_dmamem_mmap,
|
||||
NULL
|
||||
struct bus_dma_tag_hpcmips hpcmips_default_bus_dma_tag = {
|
||||
{
|
||||
NULL,
|
||||
{
|
||||
_hpcmips_bd_map_create,
|
||||
_hpcmips_bd_map_destroy,
|
||||
_hpcmips_bd_map_load,
|
||||
_hpcmips_bd_map_load_mbuf,
|
||||
_hpcmips_bd_map_load_uio,
|
||||
_hpcmips_bd_map_load_raw,
|
||||
_hpcmips_bd_map_unload,
|
||||
_hpcmips_bd_map_sync,
|
||||
_hpcmips_bd_mem_alloc,
|
||||
_hpcmips_bd_mem_free,
|
||||
_hpcmips_bd_mem_map,
|
||||
_hpcmips_bd_mem_unmap,
|
||||
_hpcmips_bd_mem_mmap,
|
||||
},
|
||||
},
|
||||
NULL,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -78,42 +83,43 @@ struct hpcmips_bus_dma_tag hpcmips_default_bus_dma_tag = {
|
|||
* DMA map creation functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
||||
_hpcmips_bd_map_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
||||
bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
|
||||
{
|
||||
struct hpcmips_bus_dmamap *map;
|
||||
struct bus_dmamap_hpcmips *map;
|
||||
void *mapstore;
|
||||
size_t mapsize;
|
||||
|
||||
/*
|
||||
* Allcoate and initialize the DMA map. The end of the map
|
||||
* is a variable-sized array of segments, so we allocate enough
|
||||
* has two variable-sized array of segments, so we allocate enough
|
||||
* room for them in one shot.
|
||||
*
|
||||
* Note we don't preserve the WAITOK or NOWAIT flags. Preservation
|
||||
* of ALLOCNOW notifes others that we've reserved these resources,
|
||||
* and they are not to be freed.
|
||||
*
|
||||
* The bus_dmamap_t includes one bus_dma_segment_t, hence
|
||||
* the (nsegments - 1).
|
||||
*/
|
||||
mapsize = sizeof(struct hpcmips_bus_dmamap) +
|
||||
(sizeof(bus_dma_segment_t) * (nsegments - 1));
|
||||
mapsize = sizeof(struct bus_dmamap_hpcmips) +
|
||||
sizeof(struct bus_dma_segment_hpcmips) * (nsegments - 1) +
|
||||
sizeof(bus_dma_segment_t) * nsegments;
|
||||
if ((mapstore = malloc(mapsize, M_DMAMAP,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
bzero(mapstore, mapsize);
|
||||
map = (struct hpcmips_bus_dmamap *)mapstore;
|
||||
map = (struct bus_dmamap_hpcmips *)mapstore;
|
||||
map->_dm_size = size;
|
||||
map->_dm_segcnt = nsegments;
|
||||
map->_dm_maxsegsz = maxsegsz;
|
||||
map->_dm_boundary = boundary;
|
||||
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
|
||||
map->dm_mapsize = 0; /* no valid mappings */
|
||||
map->dm_nsegs = 0;
|
||||
map->bdm.dm_mapsize = 0; /* no valid mappings */
|
||||
map->bdm.dm_nsegs = 0;
|
||||
map->bdm.dm_segs = (bus_dma_segment_t *)((char *)mapstore +
|
||||
sizeof(struct bus_dmamap_hpcmips) +
|
||||
sizeof(struct bus_dma_segment_hpcmips) * (nsegments - 1));
|
||||
|
||||
*dmamp = map;
|
||||
*dmamp = &map->bdm;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -122,7 +128,7 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
|||
* DMA map destruction functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
|
||||
_hpcmips_bd_map_destroy(bus_dma_tag_t t, bus_dmamap_t map)
|
||||
{
|
||||
|
||||
free(map, M_DMAMAP);
|
||||
|
@ -135,9 +141,10 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
|
|||
* first indicates if this is the first invocation of this function.
|
||||
*/
|
||||
static int
|
||||
_bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
|
||||
_hpcmips_bd_map_load_buffer(bus_dmamap_t mapx, void *buf, bus_size_t buflen,
|
||||
struct proc *p, int flags, vaddr_t *lastaddrp, int *segp, int first)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
bus_size_t sgsize;
|
||||
bus_addr_t curaddr, lastaddr, baddr, bmask;
|
||||
vaddr_t vaddr = (vaddr_t)buf;
|
||||
|
@ -177,24 +184,24 @@ _bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
|
|||
* the previous segment if possible.
|
||||
*/
|
||||
if (first) {
|
||||
map->dm_segs[seg].ds_addr = curaddr;
|
||||
map->dm_segs[seg].ds_len = sgsize;
|
||||
map->dm_segs[seg]._ds_vaddr = vaddr;
|
||||
map->bdm.dm_segs[seg].ds_addr = curaddr;
|
||||
map->bdm.dm_segs[seg].ds_len = sgsize;
|
||||
map->_dm_segs[seg]._ds_vaddr = vaddr;
|
||||
first = 0;
|
||||
} else {
|
||||
if (curaddr == lastaddr &&
|
||||
(map->dm_segs[seg].ds_len + sgsize) <=
|
||||
(map->bdm.dm_segs[seg].ds_len + sgsize) <=
|
||||
map->_dm_maxsegsz &&
|
||||
(map->_dm_boundary == 0 ||
|
||||
(map->dm_segs[seg].ds_addr & bmask) ==
|
||||
(map->bdm.dm_segs[seg].ds_addr & bmask) ==
|
||||
(curaddr & bmask)))
|
||||
map->dm_segs[seg].ds_len += sgsize;
|
||||
map->bdm.dm_segs[seg].ds_len += sgsize;
|
||||
else {
|
||||
if (++seg >= map->_dm_segcnt)
|
||||
break;
|
||||
map->dm_segs[seg].ds_addr = curaddr;
|
||||
map->dm_segs[seg].ds_len = sgsize;
|
||||
map->dm_segs[seg]._ds_vaddr = vaddr;
|
||||
map->bdm.dm_segs[seg].ds_addr = curaddr;
|
||||
map->bdm.dm_segs[seg].ds_len = sgsize;
|
||||
map->_dm_segs[seg]._ds_vaddr = vaddr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,27 +227,28 @@ _bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
|
|||
* buffer.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
||||
_hpcmips_bd_map_load(bus_dma_tag_t t, bus_dmamap_t mapx, void *buf,
|
||||
bus_size_t buflen, struct proc *p, int flags)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
vaddr_t lastaddr;
|
||||
int seg, error;
|
||||
|
||||
/*
|
||||
* Make sure that on error condition we return "no valid mappings".
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
map->bdm.dm_mapsize = 0;
|
||||
map->bdm.dm_nsegs = 0;
|
||||
|
||||
if (buflen > map->_dm_size)
|
||||
return (EINVAL);
|
||||
|
||||
seg = 0;
|
||||
error = _bus_dmamap_load_buffer(map, buf, buflen,
|
||||
error = _hpcmips_bd_map_load_buffer(mapx, buf, buflen,
|
||||
p, flags, &lastaddr, &seg, 1);
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = buflen;
|
||||
map->dm_nsegs = seg + 1;
|
||||
map->bdm.dm_mapsize = buflen;
|
||||
map->bdm.dm_nsegs = seg + 1;
|
||||
|
||||
/*
|
||||
* For linear buffers, we support marking the mapping
|
||||
|
@ -256,12 +264,13 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
|||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for mbufs.
|
||||
* Like _hpcmips_bd_map_load(), but for mbufs.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
|
||||
_hpcmips_bd_map_load_mbuf(bus_dma_tag_t t, bus_dmamap_t mapx, struct mbuf *m0,
|
||||
int flags)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
vaddr_t lastaddr;
|
||||
int seg, error, first;
|
||||
struct mbuf *m;
|
||||
|
@ -269,12 +278,12 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
|
|||
/*
|
||||
* Make sure that on error condition we return "no valid mappings."
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
map->bdm.dm_mapsize = 0;
|
||||
map->bdm.dm_nsegs = 0;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((m0->m_flags & M_PKTHDR) == 0)
|
||||
panic("_bus_dmamap_load_mbuf: no packet header");
|
||||
panic("_hpcmips_bd_map_load_mbuf: no packet header");
|
||||
#endif
|
||||
|
||||
if (m0->m_pkthdr.len > map->_dm_size)
|
||||
|
@ -284,24 +293,25 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
|
|||
seg = 0;
|
||||
error = 0;
|
||||
for (m = m0; m != NULL && error == 0; m = m->m_next) {
|
||||
error = _bus_dmamap_load_buffer(map,
|
||||
error = _hpcmips_bd_map_load_buffer(mapx,
|
||||
m->m_data, m->m_len, NULL, flags, &lastaddr, &seg, first);
|
||||
first = 0;
|
||||
}
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = m0->m_pkthdr.len;
|
||||
map->dm_nsegs = seg + 1;
|
||||
map->bdm.dm_mapsize = m0->m_pkthdr.len;
|
||||
map->bdm.dm_nsegs = seg + 1;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for uios.
|
||||
* Like _hpcmips_bd_map_load(), but for uios.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
|
||||
_hpcmips_bd_map_load_uio(bus_dma_tag_t t, bus_dmamap_t mapx, struct uio *uio,
|
||||
int flags)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
vaddr_t lastaddr;
|
||||
int seg, i, error, first;
|
||||
bus_size_t minlen, resid;
|
||||
|
@ -312,8 +322,8 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
|
|||
/*
|
||||
* Make sure that on error condition we return "no valid mappings."
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
map->bdm.dm_mapsize = 0;
|
||||
map->bdm.dm_nsegs = 0;
|
||||
|
||||
resid = uio->uio_resid;
|
||||
iov = uio->uio_iov;
|
||||
|
@ -322,7 +332,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
|
|||
p = uio->uio_procp;
|
||||
#ifdef DIAGNOSTIC
|
||||
if (p == NULL)
|
||||
panic("_bus_dmamap_load_uio: USERSPACE but no proc");
|
||||
panic("_hpcmips_bd_map_load_uio: USERSPACE but no proc");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -337,28 +347,28 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
|
|||
minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len;
|
||||
addr = (caddr_t)iov[i].iov_base;
|
||||
|
||||
error = _bus_dmamap_load_buffer(map, addr, minlen,
|
||||
error = _hpcmips_bd_map_load_buffer(mapx, addr, minlen,
|
||||
p, flags, &lastaddr, &seg, first);
|
||||
first = 0;
|
||||
|
||||
resid -= minlen;
|
||||
}
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = uio->uio_resid;
|
||||
map->dm_nsegs = seg + 1;
|
||||
map->bdm.dm_mapsize = uio->uio_resid;
|
||||
map->bdm.dm_nsegs = seg + 1;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for raw memory.
|
||||
* Like _hpcmips_bd_map_load(), but for raw memory.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
|
||||
_hpcmips_bd_map_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
|
||||
bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
|
||||
{
|
||||
|
||||
panic("_bus_dmamap_load_raw: not implemented");
|
||||
panic("_hpcmips_bd_map_load_raw: not implemented");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -366,15 +376,16 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
|
|||
* chipset-specific DMA map unload functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
|
||||
_hpcmips_bd_map_unload(bus_dma_tag_t t, bus_dmamap_t mapx)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
|
||||
/*
|
||||
* No resources to free; just mark the mappings as
|
||||
* invalid.
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
map->bdm.dm_mapsize = 0;
|
||||
map->bdm.dm_nsegs = 0;
|
||||
map->_dm_flags &= ~HPCMIPS_DMAMAP_COHERENT;
|
||||
}
|
||||
|
||||
|
@ -383,9 +394,10 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
|
|||
* by chipset-specific DMA map synchronization functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
||||
_hpcmips_bd_map_sync(bus_dma_tag_t t, bus_dmamap_t mapx, bus_addr_t offset,
|
||||
bus_size_t len, int ops)
|
||||
{
|
||||
struct bus_dmamap_hpcmips *map = (struct bus_dmamap_hpcmips *)mapx;
|
||||
bus_size_t minlen;
|
||||
bus_addr_t addr;
|
||||
int i;
|
||||
|
@ -395,14 +407,14 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
*/
|
||||
if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 &&
|
||||
(ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0)
|
||||
panic("_bus_dmamap_sync: mix PRE and POST");
|
||||
panic("_hpcmips_bd_map_sync: mix PRE and POST");
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (offset >= map->dm_mapsize)
|
||||
panic("_bus_dmamap_sync: bad offset %lu (map size is %lu)",
|
||||
offset, map->dm_mapsize);
|
||||
if (len == 0 || (offset + len) > map->dm_mapsize)
|
||||
panic("_bus_dmamap_sync: bad length");
|
||||
if (offset >= map->bdm.dm_mapsize)
|
||||
panic("_hpcmips_bd_map_sync: bad offset %lu (map size is %lu)",
|
||||
offset, map->bdm.dm_mapsize);
|
||||
if (len == 0 || (offset + len) > map->bdm.dm_mapsize)
|
||||
panic("_hpcmips_bd_map_sync: bad length");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -446,10 +458,10 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
* do the same loop, instead using the virtual address stashed
|
||||
* away in the segments when the map was loaded.
|
||||
*/
|
||||
for (i = 0; i < map->dm_nsegs && len != 0; i++) {
|
||||
for (i = 0; i < map->bdm.dm_nsegs && len != 0; i++) {
|
||||
/* Find the beginning segment. */
|
||||
if (offset >= map->dm_segs[i].ds_len) {
|
||||
offset -= map->dm_segs[i].ds_len;
|
||||
if (offset >= map->bdm.dm_segs[i].ds_len) {
|
||||
offset -= map->bdm.dm_segs[i].ds_len;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -458,16 +470,16 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
* each segment until we have exhausted the
|
||||
* length.
|
||||
*/
|
||||
minlen = len < map->dm_segs[i].ds_len - offset ?
|
||||
len : map->dm_segs[i].ds_len - offset;
|
||||
minlen = len < map->bdm.dm_segs[i].ds_len - offset ?
|
||||
len : map->bdm.dm_segs[i].ds_len - offset;
|
||||
|
||||
if (CPUISMIPS3)
|
||||
addr = map->dm_segs[i]._ds_vaddr;
|
||||
addr = map->_dm_segs[i]._ds_vaddr;
|
||||
else
|
||||
addr = map->dm_segs[i].ds_addr;
|
||||
addr = map->bdm.dm_segs[i].ds_addr;
|
||||
|
||||
#ifdef BUS_DMA_DEBUG
|
||||
printf("bus_dmamap_sync: flushing segment %d "
|
||||
printf("_hpcmips_bd_map_sync: flushing segment %d "
|
||||
"(0x%lx..0x%lx) ...", i, addr + offset,
|
||||
addr + offset + minlen - 1);
|
||||
#endif
|
||||
|
@ -478,7 +490,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
* We can't have a TLB miss; use KSEG0.
|
||||
*/
|
||||
mips_dcache_wbinv_range(
|
||||
MIPS_PHYS_TO_KSEG0(map->dm_segs[i].ds_addr + offset),
|
||||
MIPS_PHYS_TO_KSEG0(map->bdm.dm_segs[i].ds_addr
|
||||
+ offset),
|
||||
minlen);
|
||||
}
|
||||
#ifdef BUS_DMA_DEBUG
|
||||
|
@ -494,7 +507,7 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
|||
* by bus-specific DMA memory allocation functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
||||
_hpcmips_bd_mem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
||||
bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
|
||||
int flags)
|
||||
{
|
||||
|
@ -535,7 +548,7 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
|||
if (curaddr < avail_start || curaddr >= high) {
|
||||
printf("uvm_pglistalloc returned non-sensical"
|
||||
" address 0x%lx\n", curaddr);
|
||||
panic("_bus_dmamem_alloc");
|
||||
panic("_hpcmips_bd_mem_alloc");
|
||||
}
|
||||
#endif
|
||||
if (curaddr == (lastaddr + PAGE_SIZE))
|
||||
|
@ -558,7 +571,7 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
|||
* bus-specific DMA memory free functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
||||
_hpcmips_bd_mem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
||||
{
|
||||
struct vm_page *m;
|
||||
bus_addr_t addr;
|
||||
|
@ -586,7 +599,7 @@ _bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
|||
* bus-specific DMA memory map functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
_hpcmips_bd_mem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
size_t size, caddr_t *kvap, int flags)
|
||||
{
|
||||
vaddr_t va;
|
||||
|
@ -619,7 +632,7 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
|||
addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
|
||||
addr += NBPG, va += NBPG, size -= NBPG) {
|
||||
if (size == 0)
|
||||
panic("_bus_dmamem_map: size botch");
|
||||
panic("_hpcmips_bd_mem_map: size botch");
|
||||
pmap_enter(pmap_kernel(), va, addr,
|
||||
VM_PROT_READ | VM_PROT_WRITE,
|
||||
VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
|
||||
|
@ -637,12 +650,12 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
|||
* bus-specific DMA memory unmapping functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
|
||||
_hpcmips_bd_mem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
|
||||
{
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((u_long)kva & PGOFSET)
|
||||
panic("_bus_dmamem_unmap");
|
||||
panic("_hpcmips_bd_mem_unmap");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -662,7 +675,7 @@ _bus_dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
|
|||
* bus-specific DMA mmap(2)'ing functions.
|
||||
*/
|
||||
paddr_t
|
||||
_bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
_hpcmips_bd_mem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
off_t off, int prot, int flags)
|
||||
{
|
||||
int i;
|
||||
|
@ -670,11 +683,11 @@ _bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
|||
for (i = 0; i < nsegs; i++) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (off & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: offset unaligned");
|
||||
panic("_hpcmips_bd_mem_mmap: offset unaligned");
|
||||
if (segs[i].ds_addr & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: segment unaligned");
|
||||
panic("_hpcmips_bd_mem_mmap: segment unaligned");
|
||||
if (segs[i].ds_len & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: segment size not multiple"
|
||||
panic("_hpcmips_bd_mem_mmap: segment size not multiple"
|
||||
" of page size");
|
||||
#endif
|
||||
if (off >= segs[i].ds_len) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bus_space.c,v 1.14 2001/11/14 18:15:18 thorpej Exp $ */
|
||||
/* $NetBSD: bus_space.c,v 1.15 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <mips/cache.h>
|
||||
#include <mips/pte.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#ifdef BUS_SPACE_DEBUG
|
||||
#define DPRINTF(arg) printf arg
|
||||
|
@ -56,27 +57,104 @@
|
|||
|
||||
#define MAX_BUSSPACE_TAG 10
|
||||
|
||||
static struct hpcmips_bus_space __bus_space[MAX_BUSSPACE_TAG];
|
||||
static int __bus_space_index;
|
||||
static struct hpcmips_bus_space __sys_bus_space;
|
||||
static bus_space_tag_t __sys_bus_space_tag;
|
||||
/* proto types */
|
||||
bus_space_handle_t __hpcmips_cacheable(struct bus_space_tag_hpcmips*,
|
||||
bus_addr_t, bus_size_t, int);
|
||||
bus_space_protos(_);
|
||||
bus_space_protos(bs_notimpl);
|
||||
|
||||
bus_space_handle_t __hpcmips_cacheable(bus_space_tag_t, bus_addr_t, bus_size_t,
|
||||
int);
|
||||
/* variables */
|
||||
static struct bus_space_tag_hpcmips __bus_space[MAX_BUSSPACE_TAG];
|
||||
static int __bus_space_index;
|
||||
static struct bus_space_tag_hpcmips __sys_bus_space = {
|
||||
{
|
||||
NULL,
|
||||
{
|
||||
/* mapping/unmapping */
|
||||
__bs_map,
|
||||
__bs_unmap,
|
||||
__bs_subregion,
|
||||
|
||||
/* allocation/deallocation */
|
||||
__bs_alloc,
|
||||
__bs_free,
|
||||
|
||||
/* get kernel virtual address */
|
||||
bs_notimpl_bs_vaddr, /* there is no linear mapping */
|
||||
|
||||
/* Mmap bus space for user */
|
||||
bs_notimpl_bs_mmap,
|
||||
|
||||
/* barrier */
|
||||
__bs_barrier,
|
||||
|
||||
/* read (single) */
|
||||
__bs_r_1,
|
||||
__bs_r_2,
|
||||
__bs_r_4,
|
||||
bs_notimpl_bs_r_8,
|
||||
|
||||
/* read multiple */
|
||||
__bs_rm_1,
|
||||
__bs_rm_2,
|
||||
__bs_rm_4,
|
||||
bs_notimpl_bs_rm_8,
|
||||
|
||||
/* read region */
|
||||
__bs_rr_1,
|
||||
__bs_rr_2,
|
||||
__bs_rr_4,
|
||||
bs_notimpl_bs_rr_8,
|
||||
|
||||
/* write (single) */
|
||||
__bs_w_1,
|
||||
__bs_w_2,
|
||||
__bs_w_4,
|
||||
bs_notimpl_bs_w_8,
|
||||
|
||||
/* write multiple */
|
||||
__bs_wm_1,
|
||||
__bs_wm_2,
|
||||
__bs_wm_4,
|
||||
bs_notimpl_bs_wm_8,
|
||||
|
||||
/* write region */
|
||||
__bs_wr_1,
|
||||
__bs_wr_2,
|
||||
__bs_wr_4,
|
||||
bs_notimpl_bs_wr_8,
|
||||
|
||||
/* set multi */
|
||||
__bs_sm_1,
|
||||
__bs_sm_2,
|
||||
__bs_sm_4,
|
||||
bs_notimpl_bs_sm_8,
|
||||
|
||||
/* set region */
|
||||
__bs_sr_1,
|
||||
__bs_sr_2,
|
||||
__bs_sr_4,
|
||||
bs_notimpl_bs_sr_8,
|
||||
|
||||
/* copy */
|
||||
__bs_c_1,
|
||||
__bs_c_2,
|
||||
__bs_c_4,
|
||||
bs_notimpl_bs_c_8,
|
||||
},
|
||||
},
|
||||
|
||||
"whole bus space", /* bus name */
|
||||
0, /* extent base */
|
||||
0xffffffff, /* extent size */
|
||||
NULL, /* pointer for extent structure */
|
||||
};
|
||||
static bus_space_tag_t __sys_bus_space_tag = &__sys_bus_space.bst;
|
||||
|
||||
bus_space_tag_t
|
||||
hpcmips_system_bus_space()
|
||||
{
|
||||
|
||||
if (__sys_bus_space_tag != 0)
|
||||
return (__sys_bus_space_tag);
|
||||
|
||||
strcpy(__sys_bus_space.t_name, "whole bus space");
|
||||
__sys_bus_space.t_base = 0x0;
|
||||
__sys_bus_space.t_size = 0xffffffff;
|
||||
__sys_bus_space.t_extent = 0; /* No extent for bootstraping */
|
||||
__sys_bus_space_tag = &__sys_bus_space;
|
||||
|
||||
return (__sys_bus_space_tag);
|
||||
}
|
||||
|
||||
|
@ -88,32 +166,41 @@ hpcmips_alloc_bus_space_tag()
|
|||
if (__bus_space_index >= MAX_BUSSPACE_TAG) {
|
||||
panic("hpcmips_internal_alloc_bus_space_tag: tag full.");
|
||||
}
|
||||
t = &__bus_space[__bus_space_index++];
|
||||
t = &__bus_space[__bus_space_index++].bst;
|
||||
|
||||
return (t);
|
||||
}
|
||||
|
||||
void
|
||||
hpcmips_init_bus_space_extent(bus_space_tag_t t)
|
||||
hpcmips_init_bus_space(bus_space_tag_t tx, bus_space_tag_t basetag,
|
||||
char *name, u_int32_t base, u_int32_t size)
|
||||
{
|
||||
struct bus_space_tag_hpcmips *t = (struct bus_space_tag_hpcmips *)tx;
|
||||
u_int32_t pa, endpa;
|
||||
vaddr_t va;
|
||||
|
||||
if (basetag != NULL)
|
||||
memcpy(t, basetag, sizeof(struct bus_space_tag_hpcmips));
|
||||
strncpy(t->name, name, sizeof(t->name));
|
||||
t->name[sizeof(t->name) - 1] = '\0';
|
||||
t->base = base;
|
||||
t->size = size;
|
||||
|
||||
/*
|
||||
* If request physical address is greater than 512MByte,
|
||||
* mapping it to kseg2.
|
||||
*/
|
||||
if (t->t_base >= 0x20000000) {
|
||||
pa = mips_trunc_page(t->t_base);
|
||||
endpa = mips_round_page(t->t_base + t->t_size);
|
||||
if (t->base >= 0x20000000) {
|
||||
pa = mips_trunc_page(t->base);
|
||||
endpa = mips_round_page(t->base + t->size);
|
||||
|
||||
if (!(va = uvm_km_valloc(kernel_map, endpa - pa))) {
|
||||
panic("hpcmips_init_bus_space_extent:"
|
||||
"can't allocate kernel virtual");
|
||||
}
|
||||
DPRINTF(("pa:0x%08x -> kv:0x%08x+0x%08x",
|
||||
(unsigned int)t->t_base, (unsigned int)va, t->t_size));
|
||||
t->t_base = va; /* kseg2 addr */
|
||||
(unsigned int)t->base, (unsigned int)va, t->size));
|
||||
t->base = va; /* kseg2 addr */
|
||||
|
||||
for (; pa < endpa; pa += NBPG, va += NBPG) {
|
||||
pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
|
||||
|
@ -121,24 +208,24 @@ hpcmips_init_bus_space_extent(bus_space_tag_t t)
|
|||
pmap_update(pmap_kernel());
|
||||
}
|
||||
|
||||
t->t_extent = (void*)extent_create(t->t_name, t->t_base,
|
||||
t->t_base + t->t_size, M_DEVBUF,
|
||||
t->extent = (void*)extent_create(t->name, t->base,
|
||||
t->base + t->size, M_DEVBUF,
|
||||
0, 0, EX_NOWAIT);
|
||||
if (!t->t_extent) {
|
||||
if (!t->extent) {
|
||||
panic("hpcmips_init_bus_space_extent:"
|
||||
"unable to allocate %s map", t->t_name);
|
||||
"unable to allocate %s map", t->name);
|
||||
}
|
||||
}
|
||||
|
||||
bus_space_handle_t
|
||||
__hpcmips_cacheable(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
|
||||
int cacheable)
|
||||
__hpcmips_cacheable(struct bus_space_tag_hpcmips *t, bus_addr_t bpa,
|
||||
bus_size_t size, int cacheable)
|
||||
{
|
||||
vaddr_t va, endva;
|
||||
pt_entry_t *pte;
|
||||
u_int32_t opte, npte;
|
||||
|
||||
if (t->t_base >= MIPS_KSEG2_START) {
|
||||
if (t->base >= MIPS_KSEG2_START) {
|
||||
va = mips_trunc_page(bpa);
|
||||
endva = mips_round_page(bpa + size);
|
||||
npte = CPUISMIPS3 ? MIPS3_PG_UNCACHED : MIPS1_PG_N;
|
||||
|
@ -167,19 +254,20 @@ __hpcmips_cacheable(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
|
|||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
__bs_map(bus_space_tag_t tx, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
struct bus_space_tag_hpcmips *t = (struct bus_space_tag_hpcmips *)tx;
|
||||
int err;
|
||||
int cacheable = flags & BUS_SPACE_MAP_CACHEABLE;
|
||||
|
||||
if (!t->t_extent) { /* Before autoconfiguration, can't use extent */
|
||||
if (!t->extent) { /* Before autoconfiguration, can't use extent */
|
||||
DPRINTF(("bus_space_map: map temporary region:"
|
||||
"0x%08x-0x%08x\n", bpa, bpa+size));
|
||||
bpa += t->t_base;
|
||||
bpa += t->base;
|
||||
} else {
|
||||
bpa += t->t_base;
|
||||
if ((err = extent_alloc_region(t->t_extent, bpa, size,
|
||||
bpa += t->base;
|
||||
if ((err = extent_alloc_region(t->extent, bpa, size,
|
||||
EX_NOWAIT|EX_MALLOCOK))) {
|
||||
return (err);
|
||||
}
|
||||
|
@ -187,27 +275,63 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
|
|||
*bshp = __hpcmips_cacheable(t, bpa, size, cacheable);
|
||||
|
||||
DPRINTF(("\tbus_space_map:%#x(%#x)+%#x\n",
|
||||
bpa, bpa - t->t_base, size));
|
||||
bpa, bpa - t->base, size));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
__bs_unmap(bus_space_tag_t tx, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
struct bus_space_tag_hpcmips *t = (struct bus_space_tag_hpcmips *)tx;
|
||||
int err;
|
||||
u_int32_t addr;
|
||||
|
||||
if (!t->extent) {
|
||||
return; /* Before autoconfiguration, can't use extent */
|
||||
}
|
||||
|
||||
if (t->base < MIPS_KSEG2_START) {
|
||||
addr = MIPS_KSEG1_TO_PHYS(bsh);
|
||||
} else {
|
||||
addr = bsh;
|
||||
}
|
||||
|
||||
if ((err = extent_free(t->extent, addr, size, EX_NOWAIT))) {
|
||||
DPRINTF(("warning: %#x-%#x of %s space lost\n",
|
||||
bsh, bsh+size, t->name));
|
||||
}
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
__bs_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
|
||||
{
|
||||
|
||||
*nbshp = bsh + offset;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
|
||||
__bs_alloc(bus_space_tag_t tx, bus_addr_t rstart, bus_addr_t rend,
|
||||
bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
|
||||
bus_addr_t *bpap, bus_space_handle_t *bshp)
|
||||
{
|
||||
struct bus_space_tag_hpcmips *t = (struct bus_space_tag_hpcmips *)tx;
|
||||
int cacheable = flags & BUS_SPACE_MAP_CACHEABLE;
|
||||
u_long bpa;
|
||||
int err;
|
||||
|
||||
if (!t->t_extent)
|
||||
if (!t->extent)
|
||||
panic("bus_space_alloc: no extent");
|
||||
|
||||
rstart += t->t_base;
|
||||
rend += t->t_base;
|
||||
if ((err = extent_alloc_subregion(t->t_extent, rstart, rend, size,
|
||||
rstart += t->base;
|
||||
rend += t->base;
|
||||
if ((err = extent_alloc_subregion(t->extent, rstart, rend, size,
|
||||
alignment, boundary, EX_FAST|EX_NOWAIT|EX_MALLOCOK, &bpa))) {
|
||||
return (err);
|
||||
}
|
||||
|
@ -219,48 +343,252 @@ bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
|
|||
}
|
||||
|
||||
DPRINTF(("\tbus_space_alloc:%#x(%#x)+%#x\n", (unsigned)bpa,
|
||||
(unsigned)(bpa - t->t_base), size));
|
||||
(unsigned)(bpa - t->base), size));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
__bs_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
/* bus_space_unmap() does all that we need to do. */
|
||||
bus_space_unmap(t, bsh, size);
|
||||
}
|
||||
|
||||
void
|
||||
bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
__bs_barrier(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
bus_size_t len, int flags)
|
||||
{
|
||||
int err;
|
||||
u_int32_t addr;
|
||||
wbflush();
|
||||
}
|
||||
|
||||
if (!t->t_extent) {
|
||||
return; /* Before autoconfiguration, can't use extent */
|
||||
}
|
||||
u_int8_t
|
||||
__bs_r_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset)
|
||||
{
|
||||
wbflush();
|
||||
return (*(volatile u_int8_t *)(bsh + offset));
|
||||
}
|
||||
|
||||
if (t->t_base < MIPS_KSEG2_START) {
|
||||
addr = MIPS_KSEG1_TO_PHYS(bsh);
|
||||
} else {
|
||||
addr = bsh;
|
||||
}
|
||||
u_int16_t
|
||||
__bs_r_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset)
|
||||
{
|
||||
wbflush();
|
||||
return (*(volatile u_int16_t *)(bsh + offset));
|
||||
}
|
||||
|
||||
if ((err = extent_free(t->t_extent, addr, size, EX_NOWAIT))) {
|
||||
DPRINTF(("warning: %#x-%#x of %s space lost\n",
|
||||
bsh, bsh+size, t->t_name));
|
||||
u_int32_t
|
||||
__bs_r_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset)
|
||||
{
|
||||
wbflush();
|
||||
return (*(volatile u_int32_t *)(bsh + offset));
|
||||
}
|
||||
|
||||
void
|
||||
__bs_rm_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int8_t *addr, bus_size_t count) {
|
||||
while (count--)
|
||||
*addr++ = bus_space_read_1(t, bsh, offset);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_rm_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int16_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
*addr++ = bus_space_read_2(t, bsh, offset);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_rm_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int32_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
*addr++ = bus_space_read_4(t, bsh, offset);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_rr_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int8_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
*addr++ = bus_space_read_1(t, bsh, offset);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
|
||||
void
|
||||
__bs_rr_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int16_t *addr, bus_size_t count)
|
||||
{
|
||||
|
||||
*nbshp = bsh + offset;
|
||||
|
||||
return (0);
|
||||
while (count--) {
|
||||
*addr++ = bus_space_read_2(t, bsh, offset);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_rr_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int32_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
*addr++ = bus_space_read_4(t, bsh, offset);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_w_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int8_t value)
|
||||
{
|
||||
*(volatile u_int8_t *)(bsh + offset) = value;
|
||||
wbflush();
|
||||
}
|
||||
|
||||
void
|
||||
__bs_w_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int16_t value)
|
||||
{
|
||||
*(volatile u_int16_t *)(bsh + offset) = value;
|
||||
wbflush();
|
||||
}
|
||||
|
||||
void
|
||||
__bs_w_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
u_int32_t value)
|
||||
{
|
||||
*(volatile u_int32_t *)(bsh + offset) = value;
|
||||
wbflush();
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wm_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int8_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_1(t, bsh, offset, *addr++);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wm_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int16_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_2(t, bsh, offset, *addr++);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wm_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int32_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_4(t, bsh, offset, *addr++);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wr_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int8_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_1(t, bsh, offset, *addr++);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wr_2(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int16_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_2(t, bsh, offset, *addr++);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_wr_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
const u_int32_t *addr, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_4(t, bsh, offset, *addr++);
|
||||
offset += sizeof(*addr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_sm_1(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int8_t value, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_1(t, bsh, offset, value);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_sm_2(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int16_t value, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_2(t, bsh, offset, value);
|
||||
}
|
||||
|
||||
void
|
||||
__bs_sm_4(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int32_t value, bus_size_t count)
|
||||
{
|
||||
while (count--)
|
||||
bus_space_write_4(t, bsh, offset, value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__bs_sr_1(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int8_t value, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_1(t, bsh, offset, value);
|
||||
offset += (value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_sr_2(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int16_t value, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_2(t, bsh, offset, value);
|
||||
offset += (value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__bs_sr_4(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int32_t value, bus_size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
bus_space_write_4(t, bsh, offset, value);
|
||||
offset += (value);
|
||||
}
|
||||
}
|
||||
|
||||
#define __bs_c_n(n) \
|
||||
void __CONCAT(__bs_c_,n)(bus_space_tag_t t, bus_space_handle_t h1, \
|
||||
bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) \
|
||||
{ \
|
||||
bus_size_t o; \
|
||||
\
|
||||
if ((h1 + o1) >= (h2 + o2)) { \
|
||||
/* src after dest: copy forward */ \
|
||||
for (o = 0; c != 0; c--, o += n) \
|
||||
__CONCAT(bus_space_write_,n)(t, h2, o2 + o, \
|
||||
__CONCAT(bus_space_read_,n)(t, h1, o1 + o));\
|
||||
} else { \
|
||||
/* dest after src: copy backwards */ \
|
||||
for (o = (c - 1) * n; c != 0; c--, o -= n) \
|
||||
__CONCAT(bus_space_write_,n)(t, h2, o2 + o, \
|
||||
__CONCAT(bus_space_read_,n)(t, h1, o1 + o));\
|
||||
} \
|
||||
}
|
||||
|
||||
__bs_c_n(1)
|
||||
__bs_c_n(2)
|
||||
__bs_c_n(4)
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/* $NetBSD: bus_space_notimpl.c,v 1.1 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 TAKEMRUA Shin. 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. Neither the name of the project 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 REGENTS 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/cdefs.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
bus_space_protos(bs_notimpl);
|
||||
|
||||
#define C(a,b) __CONCAT(a,b)
|
||||
#define __NOTIMPL(f) C(C(bs_,f),_proto)(bs_notimpl) \
|
||||
{ panic("%s isn't implemented\n", __FUNCTION__); }
|
||||
|
||||
__NOTIMPL(map)
|
||||
__NOTIMPL(unmap)
|
||||
__NOTIMPL(subregion)
|
||||
__NOTIMPL(alloc)
|
||||
__NOTIMPL(free)
|
||||
__NOTIMPL(vaddr)
|
||||
__NOTIMPL(mmap)
|
||||
__NOTIMPL(barrier)
|
||||
__NOTIMPL(r_1)
|
||||
__NOTIMPL(r_2)
|
||||
__NOTIMPL(r_4)
|
||||
__NOTIMPL(r_8)
|
||||
__NOTIMPL(rm_1)
|
||||
__NOTIMPL(rm_2)
|
||||
__NOTIMPL(rm_4)
|
||||
__NOTIMPL(rm_8)
|
||||
__NOTIMPL(rr_1)
|
||||
__NOTIMPL(rr_2)
|
||||
__NOTIMPL(rr_4)
|
||||
__NOTIMPL(rr_8)
|
||||
__NOTIMPL(w_1)
|
||||
__NOTIMPL(w_2)
|
||||
__NOTIMPL(w_4)
|
||||
__NOTIMPL(w_8)
|
||||
__NOTIMPL(wm_1)
|
||||
__NOTIMPL(wm_2)
|
||||
__NOTIMPL(wm_4)
|
||||
__NOTIMPL(wm_8)
|
||||
__NOTIMPL(wr_1)
|
||||
__NOTIMPL(wr_2)
|
||||
__NOTIMPL(wr_4)
|
||||
__NOTIMPL(wr_8)
|
||||
#ifdef __BUS_SPACE_HAS_STREAM_REAL_METHODS
|
||||
__NOTIMPL(rs_1)
|
||||
__NOTIMPL(rs_2)
|
||||
__NOTIMPL(rs_4)
|
||||
__NOTIMPL(rs_8)
|
||||
__NOTIMPL(rms_1)
|
||||
__NOTIMPL(rms_2)
|
||||
__NOTIMPL(rms_4)
|
||||
__NOTIMPL(rms_8)
|
||||
__NOTIMPL(rrs_1)
|
||||
__NOTIMPL(rrs_2)
|
||||
__NOTIMPL(rrs_4)
|
||||
__NOTIMPL(rrs_8)
|
||||
__NOTIMPL(ws_1)
|
||||
__NOTIMPL(ws_2)
|
||||
__NOTIMPL(ws_4)
|
||||
__NOTIMPL(ws_8)
|
||||
__NOTIMPL(wms_1)
|
||||
__NOTIMPL(wms_2)
|
||||
__NOTIMPL(wms_4)
|
||||
__NOTIMPL(wms_8)
|
||||
__NOTIMPL(wrs_1)
|
||||
__NOTIMPL(wrs_2)
|
||||
__NOTIMPL(wrs_4)
|
||||
__NOTIMPL(wrs_8)
|
||||
#endif /* __BUS_SPACE_HAS_STREAM_REAL_METHODS */
|
||||
__NOTIMPL(sm_1)
|
||||
__NOTIMPL(sm_2)
|
||||
__NOTIMPL(sm_4)
|
||||
__NOTIMPL(sm_8)
|
||||
__NOTIMPL(sr_1)
|
||||
__NOTIMPL(sr_2)
|
||||
__NOTIMPL(sr_4)
|
||||
__NOTIMPL(sr_8)
|
||||
__NOTIMPL(c_1)
|
||||
__NOTIMPL(c_2)
|
||||
__NOTIMPL(c_4)
|
||||
__NOTIMPL(c_8)
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mainbus.c,v 1.14 2001/09/17 17:03:45 uch Exp $ */
|
||||
/* $NetBSD: mainbus.c,v 1.15 2001/11/18 08:19:39 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include <machine/bus.h>
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/platid.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#include "locators.h"
|
||||
|
||||
|
@ -82,9 +83,9 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
printf("\n");
|
||||
|
||||
/* default dumb bus_space */
|
||||
/* system bus_space */
|
||||
ma.ma_iot = hpcmips_system_bus_space();
|
||||
hpcmips_init_bus_space_extent(ma.ma_iot);
|
||||
hpcmips_init_bus_space(ma.ma_iot, NULL, "main bus", 0, 0xffffffff);
|
||||
|
||||
/* search and attach devices in order */
|
||||
for (i = 0; i < sizeof(devnames) / sizeof(devnames[0]); i++) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,76 @@
|
|||
/* $NetBSD: bus_dma_hpcmips.h,v 1.1 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 TAKEMRUA Shin. 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. Neither the name of the project 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BUS_DMA_HPCMIPS_H_
|
||||
#define _BUS_DMA_HPCMIPS_H_
|
||||
|
||||
#define HPCMIPS_DMAMAP_COHERENT 0x100 /* no cache flush necessary on sync */
|
||||
|
||||
/*
|
||||
* bus_dma_segment
|
||||
*
|
||||
* Describes a single contiguous DMA transaction. Values
|
||||
* are suitable for programming into DMA registers.
|
||||
*/
|
||||
struct bus_dma_segment_hpcmips {
|
||||
bus_addr_t _ds_vaddr; /* virtual address, 0 if invalid */
|
||||
};
|
||||
|
||||
/*
|
||||
* bus_dma_tag
|
||||
*
|
||||
* A machine-dependent opaque type describing the implementation of
|
||||
* DMA for a given bus.
|
||||
*/
|
||||
struct bus_dma_tag_hpcmips {
|
||||
struct bus_dma_tag bdt;
|
||||
void *_dmamap_chipset_v;
|
||||
};
|
||||
|
||||
/*
|
||||
* bus_dmamap
|
||||
*
|
||||
* Describes a DMA mapping.
|
||||
*/
|
||||
struct bus_dmamap_hpcmips {
|
||||
struct bus_dmamap bdm;
|
||||
bus_size_t _dm_size; /* largest DMA transfer mappable */
|
||||
int _dm_segcnt; /* number of segs this map can map */
|
||||
bus_size_t _dm_maxsegsz; /* largest possible segment */
|
||||
bus_size_t _dm_boundary; /* don't cross this */
|
||||
int _dm_flags; /* misc. flags */
|
||||
struct bus_dma_segment_hpcmips _dm_segs[1];
|
||||
};
|
||||
|
||||
extern struct bus_dma_tag_hpcmips hpcmips_default_bus_dma_tag;
|
||||
bus_dma_protos(_hpcmips)
|
||||
|
||||
#endif /* _BUS_DMA_HPCMIPS_H_ */
|
|
@ -0,0 +1,70 @@
|
|||
/* $NetBSD: bus_machdep.h,v 1.1 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _HPCMIPS_BUS_H_
|
||||
#define _HPCMIPS_BUS_H_
|
||||
|
||||
#ifdef BUS_SPACE_DEBUG
|
||||
#include <sys/systm.h> /* for printf() prototype */
|
||||
/*
|
||||
* Macros for checking the aligned-ness of pointers passed to bus
|
||||
* space ops. Strict alignment is required by the MIPS architecture,
|
||||
* and a trap will occur if unaligned access is performed. These
|
||||
* may aid in the debugging of a broken device driver by displaying
|
||||
* useful information about the problem.
|
||||
*/
|
||||
#define __BUS_SPACE_ALIGNED_ADDRESS(p, t) \
|
||||
((((u_long)(p)) & (sizeof(t)-1)) == 0)
|
||||
|
||||
#define __BUS_SPACE_ADDRESS_SANITY(p, t, d) \
|
||||
({ \
|
||||
if (__BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \
|
||||
printf("%s 0x%lx not aligned to %d bytes %s:%d\n", \
|
||||
d, (u_long)(p), sizeof(t), __FILE__, __LINE__); \
|
||||
} \
|
||||
(void) 0; \
|
||||
})
|
||||
|
||||
#define BUS_SPACE_ALIGNED_POINTER(p, t) __BUS_SPACE_ALIGNED_ADDRESS(p, t)
|
||||
#else
|
||||
#define __BUS_SPACE_ADDRESS_SANITY(p,t,d) (void) 0
|
||||
#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
|
||||
#endif /* BUS_SPACE_DEBUG */
|
||||
|
||||
#endif /* _HPCMIPS_BUS_H_ */
|
|
@ -0,0 +1,56 @@
|
|||
/* $NetBSD: bus_space_hpcmips.h,v 1.1 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 TAKEMRUA Shin. 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. Neither the name of the project 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BUS_SPACE_HPCMIPS_H_
|
||||
#define _BUS_SPACE_HPCMIPS_H_
|
||||
|
||||
/*
|
||||
* bus_space_tag
|
||||
*
|
||||
* bus space tag structure
|
||||
*/
|
||||
struct bus_space_tag_hpcmips {
|
||||
struct bus_space_tag bst;
|
||||
char name[16]; /* bus name */
|
||||
u_int32_t base; /* extent base */
|
||||
u_int32_t size; /* extent size */
|
||||
void *extent; /* pointer for extent structure */
|
||||
};
|
||||
|
||||
/*
|
||||
* Hpcmips unique methods
|
||||
*/
|
||||
bus_space_tag_t hpcmips_system_bus_space(void);
|
||||
void hpcmips_init_bus_space(bus_space_tag_t, bus_space_tag_t,
|
||||
char *, u_int32_t, u_int32_t);
|
||||
bus_space_tag_t hpcmips_alloc_bus_space_tag(void);
|
||||
|
||||
#endif /* _BUS_SPACE_HPCMIPS_H_ */
|
|
@ -0,0 +1,43 @@
|
|||
/* $NetBSD: bus_types.h,v 1.1 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 TAKEMRUA Shin. 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. Neither the name of the project 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HPCMIPS_BUS_TYPES_H_
|
||||
#define _HPCMIPS_BUS_TYPES_H_
|
||||
|
||||
#include <mips/locore.h>
|
||||
|
||||
#define __BUS_SPACE_HAS_STREAM_METHODS
|
||||
|
||||
typedef u_long bus_addr_t;
|
||||
typedef u_long bus_size_t;
|
||||
typedef u_long bus_space_handle_t;
|
||||
|
||||
#endif /* _HPCMIPS_BUS_TYPES_H_ */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: isa_machdep.c,v 1.17 2001/10/24 04:09:23 shin Exp $ */
|
||||
/* $NetBSD: isa_machdep.c,v 1.18 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -41,13 +41,14 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/isa/isareg.h>
|
||||
|
||||
#include <machine/platid.h>
|
||||
#include <machine/platid_mask.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#include <dev/hpc/hpciovar.h>
|
||||
|
||||
|
@ -142,6 +143,7 @@ vrisabattach(struct device *parent, struct device *self, void *aux)
|
|||
struct hpcio_attach_args *haa = aux;
|
||||
struct vrisab_softc *sc = (void*)self;
|
||||
struct isabus_attach_args iba;
|
||||
struct bus_space_tag_hpcmips *iot, *memt;
|
||||
bus_addr_t offset;
|
||||
int i;
|
||||
|
||||
|
@ -154,21 +156,15 @@ vrisabattach(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
/* Allocate ISA memory space */
|
||||
iba.iba_memt = hpcmips_alloc_bus_space_tag();
|
||||
strcpy(iba.iba_memt->t_name, "ISA mem");
|
||||
offset = sc->sc_dev.dv_cfdata->cf_loc[VRISABIFCF_ISAMEMOFFSET];
|
||||
iba.iba_memt->t_base = VR_ISA_MEM_BASE + offset;
|
||||
iba.iba_memt->t_size = VR_ISA_MEM_SIZE - offset;
|
||||
hpcmips_init_bus_space_extent(iba.iba_memt);
|
||||
hpcmips_init_bus_space(iba.iba_memt, haa->haa_iot, "ISA mem",
|
||||
VR_ISA_MEM_BASE + offset, VR_ISA_MEM_SIZE - offset);
|
||||
|
||||
/* Allocate ISA port space */
|
||||
iba.iba_iot = hpcmips_alloc_bus_space_tag();
|
||||
strcpy(iba.iba_iot->t_name, "ISA port");
|
||||
/* Platform dependent setting. */
|
||||
offset = sc->sc_dev.dv_cfdata->cf_loc[VRISABIFCF_ISAPORTOFFSET];
|
||||
iba.iba_iot->t_base = VR_ISA_PORT_BASE + offset;
|
||||
iba.iba_iot->t_size = VR_ISA_PORT_SIZE - offset;
|
||||
|
||||
hpcmips_init_bus_space_extent(iba.iba_iot);
|
||||
hpcmips_init_bus_space(iba.iba_iot, haa->haa_iot, "ISA port",
|
||||
VR_ISA_PORT_BASE + offset, VR_ISA_PORT_SIZE - offset);
|
||||
|
||||
#ifdef DEBUG_FIND_PCIC
|
||||
#warning DEBUG_FIND_PCIC
|
||||
|
@ -177,9 +173,11 @@ vrisabattach(struct device *parent, struct device *self, void *aux)
|
|||
/* Initialize ISA IRQ <-> GPIO mapping */
|
||||
for (i = 0; i < INTR_NIRQS; i++)
|
||||
sc->sc_intr_map[i] = -1;
|
||||
iot = (struct bus_space_tag_hpcmips *)iba.iba_iot;
|
||||
memt = (struct bus_space_tag_hpcmips *)iba.iba_memt;
|
||||
printf(": ISA port %#x-%#x mem %#x-%#x\n",
|
||||
iba.iba_iot->t_base, iba.iba_iot->t_base + iba.iba_iot->t_size,
|
||||
iba.iba_memt->t_base, iba.iba_memt->t_base + iba.iba_memt->t_size);
|
||||
iot->base, iot->base + iot->size,
|
||||
memt->base, memt->base + memt->size);
|
||||
config_found(self, &iba, vrisabprint);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: txcsbus.c,v 1.5 2001/06/14 11:09:56 uch Exp $ */
|
||||
/* $NetBSD: txcsbus.c,v 1.6 2001/11/18 08:19:40 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -41,8 +41,9 @@
|
|||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#include <machine/platid.h>
|
||||
#include <machine/platid_mask.h>
|
||||
|
@ -253,10 +254,8 @@ __txcsbus_alloc_cstag(struct txcsbus_softc *sc, struct cs_handle *csh)
|
|||
|
||||
iot = hpcmips_alloc_bus_space_tag();
|
||||
sc->sc_cst[cs] = iot;
|
||||
|
||||
iot->t_base = __csmap[cs].cs_addr;
|
||||
iot->t_size = __csmap[cs].cs_size;
|
||||
strcpy(iot->t_name , __csmap[cs].cs_name);
|
||||
hpcmips_init_bus_space(iot, hpcmips_system_bus_space(),
|
||||
__csmap[cs].cs_name, __csmap[cs].cs_addr, __csmap[cs].cs_size);
|
||||
|
||||
/* CS bus-width (configurationable) */
|
||||
switch (width) {
|
||||
|
@ -341,8 +340,6 @@ __txcsbus_alloc_cstag(struct txcsbus_softc *sc, struct cs_handle *csh)
|
|||
"not allowed", cs);
|
||||
}
|
||||
}
|
||||
|
||||
hpcmips_init_bus_space_extent(iot);
|
||||
|
||||
return (iot);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vr.c,v 1.31 2001/09/23 14:32:53 uch Exp $ */
|
||||
/* $NetBSD: vr.c,v 1.32 2001/11/18 08:19:41 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999-2001
|
||||
|
@ -45,8 +45,9 @@
|
|||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/sysconf.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bootinfo.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_space_hpcmips.h>
|
||||
|
||||
#include <dev/hpc/hpckbdvar.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue