2012-10-27 21:17:22 +04:00
|
|
|
/* $NetBSD: vme_machdep.c,v 1.68 2012/10/27 17:18:11 chs Exp $ */
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
/*-
|
1998-02-04 08:12:46 +03:00
|
|
|
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
1998-01-25 19:06:25 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Paul Kranenburg.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-07-15 04:04:39 +04:00
|
|
|
#include <sys/cdefs.h>
|
2012-10-27 21:17:22 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.68 2012/10/27 17:18:11 chs Exp $");
|
2003-07-15 04:04:39 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
#include <sys/param.h>
|
1998-08-21 00:46:59 +04:00
|
|
|
#include <sys/extent.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
1999-06-30 19:18:58 +04:00
|
|
|
#include <sys/errno.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
2000-06-29 11:40:05 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
#define _SPARC_BUS_DMA_PRIVATE
|
2011-07-01 22:41:51 +04:00
|
|
|
#include <sys/bus.h>
|
1998-03-21 23:30:49 +03:00
|
|
|
#include <sparc/sparc/iommuvar.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/oldmon.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/ctlreg.h>
|
2011-01-14 05:06:22 +03:00
|
|
|
#include <machine/pcb.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
#include <dev/vme/vmereg.h>
|
1998-01-25 19:06:25 +03:00
|
|
|
#include <dev/vme/vmevar.h>
|
|
|
|
|
|
|
|
#include <sparc/sparc/asm.h>
|
|
|
|
#include <sparc/sparc/vaddrs.h>
|
|
|
|
#include <sparc/sparc/cpuvar.h>
|
|
|
|
#include <sparc/dev/vmereg.h>
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
struct sparcvme_softc {
|
1998-04-08 00:21:55 +04:00
|
|
|
bus_space_tag_t sc_bustag;
|
1998-07-30 22:54:06 +04:00
|
|
|
bus_dma_tag_t sc_dmatag;
|
1998-01-25 19:06:25 +03:00
|
|
|
struct vmebusreg *sc_reg; /* VME control registers */
|
|
|
|
struct vmebusvec *sc_vec; /* VME interrupt vector */
|
|
|
|
struct rom_range *sc_range; /* ROM range property */
|
|
|
|
int sc_nrange;
|
2005-11-16 03:49:02 +03:00
|
|
|
volatile uint32_t *sc_ioctags; /* VME IO-cache tag registers */
|
|
|
|
volatile uint32_t *sc_iocflush;/* VME IO-cache flush registers */
|
|
|
|
int (*sc_vmeintr)(void *);
|
1998-01-25 19:06:25 +03:00
|
|
|
};
|
1999-06-30 19:18:58 +04:00
|
|
|
struct sparcvme_softc *sparcvme_sc;/*XXX*/
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
/* autoconfiguration driver */
|
2009-09-20 20:18:21 +04:00
|
|
|
static int vmematch_iommu(device_t, cfdata_t, void *);
|
|
|
|
static void vmeattach_iommu(device_t, device_t, void *);
|
|
|
|
static int vmematch_mainbus(device_t, cfdata_t, void *);
|
|
|
|
static void vmeattach_mainbus(device_t, device_t, void *);
|
1998-01-25 19:06:25 +03:00
|
|
|
#if defined(SUN4)
|
2005-11-16 03:49:02 +03:00
|
|
|
int vmeintr4(void *);
|
1998-01-25 19:06:25 +03:00
|
|
|
#endif
|
|
|
|
#if defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
int vmeintr4m(void *);
|
|
|
|
static int sparc_vme_error(void);
|
1999-02-08 03:13:20 +03:00
|
|
|
#endif
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int sparc_vme_probe(void *, vme_addr_t, vme_size_t,
|
2000-06-27 13:05:23 +04:00
|
|
|
vme_am_t, vme_datasize_t,
|
2005-11-16 03:49:02 +03:00
|
|
|
int (*)(void *,
|
|
|
|
bus_space_tag_t, bus_space_handle_t),
|
|
|
|
void *);
|
|
|
|
static int sparc_vme_map(void *, vme_addr_t, vme_size_t, vme_am_t,
|
|
|
|
vme_datasize_t, vme_swap_t,
|
|
|
|
bus_space_tag_t *, bus_space_handle_t *,
|
|
|
|
vme_mapresc_t *);
|
|
|
|
static void sparc_vme_unmap(void *, vme_mapresc_t);
|
|
|
|
static int sparc_vme_intr_map(void *, int, int, vme_intr_handle_t *);
|
|
|
|
static const struct evcnt *sparc_vme_intr_evcnt(void *, vme_intr_handle_t);
|
|
|
|
static void * sparc_vme_intr_establish(void *, vme_intr_handle_t, int,
|
|
|
|
int (*)(void *), void *);
|
|
|
|
static void sparc_vme_intr_disestablish(void *, void *);
|
|
|
|
|
|
|
|
static int vmebus_translate(struct sparcvme_softc *, vme_am_t,
|
|
|
|
vme_addr_t, bus_addr_t *);
|
2004-06-27 20:08:42 +04:00
|
|
|
#ifdef notyet
|
1998-01-25 19:06:25 +03:00
|
|
|
#if defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static void sparc_vme_iommu_barrier(bus_space_tag_t, bus_space_handle_t,
|
|
|
|
bus_size_t, bus_size_t, int);
|
1998-04-08 00:21:55 +04:00
|
|
|
|
2004-06-27 20:08:42 +04:00
|
|
|
#endif /* SUN4M */
|
1998-01-25 19:06:25 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DMA functions.
|
|
|
|
*/
|
2003-08-01 16:19:50 +04:00
|
|
|
#if defined(SUN4) || defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static void sparc_vct_dmamap_destroy(void *, bus_dmamap_t);
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif
|
2000-06-25 17:07:34 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
#if defined(SUN4)
|
2005-11-16 03:49:02 +03:00
|
|
|
static int sparc_vct4_dmamap_create(void *, vme_size_t, vme_am_t,
|
2000-06-25 17:07:34 +04:00
|
|
|
vme_datasize_t, vme_swap_t, int, vme_size_t, vme_addr_t,
|
2005-11-16 03:49:02 +03:00
|
|
|
int, bus_dmamap_t *);
|
|
|
|
static int sparc_vme4_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
|
|
|
|
bus_size_t, struct proc *, int);
|
|
|
|
static void sparc_vme4_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
|
|
|
|
static void sparc_vme4_dmamap_sync(bus_dma_tag_t, bus_dmamap_t,
|
|
|
|
bus_addr_t, bus_size_t, int);
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif /* SUN4 */
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
#if defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static int sparc_vct_iommu_dmamap_create(void *, vme_size_t, vme_am_t,
|
2000-06-25 17:07:34 +04:00
|
|
|
vme_datasize_t, vme_swap_t, int, vme_size_t, vme_addr_t,
|
2005-11-16 03:49:02 +03:00
|
|
|
int, bus_dmamap_t *);
|
|
|
|
static int sparc_vme_iommu_dmamap_create(bus_dma_tag_t, bus_size_t,
|
|
|
|
int, bus_size_t, bus_size_t, int, bus_dmamap_t *);
|
|
|
|
|
|
|
|
static int sparc_vme_iommu_dmamap_load(bus_dma_tag_t, bus_dmamap_t,
|
|
|
|
void *, bus_size_t, struct proc *, int);
|
|
|
|
static void sparc_vme_iommu_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
|
|
|
|
static void sparc_vme_iommu_dmamap_sync(bus_dma_tag_t, bus_dmamap_t,
|
|
|
|
bus_addr_t, bus_size_t, int);
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif /* SUN4M */
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2003-08-01 16:19:50 +04:00
|
|
|
#if defined(SUN4) || defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static int sparc_vme_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *,
|
2007-03-04 08:59:00 +03:00
|
|
|
int, size_t, void **, int);
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif
|
|
|
|
|
1998-07-31 02:29:34 +04:00
|
|
|
#if 0
|
2005-11-16 03:49:02 +03:00
|
|
|
static void sparc_vme_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
|
2007-03-04 08:59:00 +03:00
|
|
|
static void sparc_vme_dmamem_unmap(bus_dma_tag_t, void *, size_t);
|
2005-11-16 03:49:02 +03:00
|
|
|
static paddr_t sparc_vme_dmamem_mmap(bus_dma_tag_t,
|
|
|
|
bus_dma_segment_t *, int, off_t, int, int);
|
1998-01-25 19:06:25 +03:00
|
|
|
#endif
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
int sparc_vme_mmap_cookie(vme_addr_t, vme_am_t, bus_space_handle_t *);
|
1999-06-30 19:18:58 +04:00
|
|
|
|
2011-07-18 04:31:13 +04:00
|
|
|
CFATTACH_DECL_NEW(vme_mainbus, sizeof(struct sparcvme_softc),
|
2002-10-02 20:02:08 +04:00
|
|
|
vmematch_mainbus, vmeattach_mainbus, NULL, NULL);
|
1998-03-21 23:30:49 +03:00
|
|
|
|
2011-07-18 04:31:13 +04:00
|
|
|
CFATTACH_DECL_NEW(vme_iommu, sizeof(struct sparcvme_softc),
|
2002-10-02 20:02:08 +04:00
|
|
|
vmematch_iommu, vmeattach_iommu, NULL, NULL);
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2004-12-13 05:14:13 +03:00
|
|
|
static int vme_attached;
|
|
|
|
|
2012-07-29 04:04:05 +04:00
|
|
|
extern int (*vmeerr_handler)(void);
|
1998-09-19 20:45:43 +04:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
#define VMEMOD_D32 0x40 /* ??? */
|
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
/* If the PROM does not provide the `ranges' property, we make up our own */
|
|
|
|
struct rom_range vmebus_translations[] = {
|
1999-06-30 19:18:58 +04:00
|
|
|
#define _DS (VME_AM_MBO | VME_AM_SUPER | VME_AM_DATA)
|
|
|
|
{ VME_AM_A16|_DS, 0, PMAP_VME16, 0xffff0000, 0 },
|
|
|
|
{ VME_AM_A24|_DS, 0, PMAP_VME16, 0xff000000, 0 },
|
|
|
|
{ VME_AM_A32|_DS, 0, PMAP_VME16, 0x00000000, 0 },
|
|
|
|
{ VME_AM_A16|VMEMOD_D32|_DS, 0, PMAP_VME32, 0xffff0000, 0 },
|
|
|
|
{ VME_AM_A24|VMEMOD_D32|_DS, 0, PMAP_VME32, 0xff000000, 0 },
|
|
|
|
{ VME_AM_A32|VMEMOD_D32|_DS, 0, PMAP_VME32, 0x00000000, 0 }
|
1998-04-08 00:21:55 +04:00
|
|
|
#undef _DS
|
|
|
|
};
|
|
|
|
|
1998-08-23 14:05:53 +04:00
|
|
|
/*
|
2000-06-27 13:05:23 +04:00
|
|
|
* The VME bus logic on sun4 machines maps DMA requests in the first MB
|
|
|
|
* of VME space to the last MB of DVMA space. `vme_dvmamap' is used
|
|
|
|
* for DVMA space allocations. The DMA addresses returned by
|
|
|
|
* bus_dmamap_load*() must be relocated by -VME4_DVMA_BASE.
|
1998-08-23 14:05:53 +04:00
|
|
|
*/
|
1998-08-21 00:46:59 +04:00
|
|
|
struct extent *vme_dvmamap;
|
|
|
|
|
2000-06-27 13:05:23 +04:00
|
|
|
/*
|
|
|
|
* The VME hardware on the sun4m IOMMU maps the first 8MB of 32-bit
|
|
|
|
* VME space to the last 8MB of DVMA space and the first 1MB of
|
|
|
|
* 24-bit VME space to the first 1MB of the last 8MB of DVMA space
|
|
|
|
* (thus 24-bit VME space overlaps the first 1MB of of 32-bit space).
|
|
|
|
* The following constants define subregions in the IOMMU DVMA map
|
|
|
|
* for VME DVMA allocations. The DMA addresses returned by
|
|
|
|
* bus_dmamap_load*() must be relocated by -VME_IOMMU_DVMA_BASE.
|
|
|
|
*/
|
|
|
|
#define VME_IOMMU_DVMA_BASE 0xff800000
|
|
|
|
#define VME_IOMMU_DVMA_AM24_BASE VME_IOMMU_DVMA_BASE
|
|
|
|
#define VME_IOMMU_DVMA_AM24_END 0xff900000
|
|
|
|
#define VME_IOMMU_DVMA_AM32_BASE VME_IOMMU_DVMA_BASE
|
|
|
|
#define VME_IOMMU_DVMA_AM32_END IOMMU_DVMA_END
|
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
struct vme_chipset_tag sparc_vme_chipset_tag = {
|
|
|
|
NULL,
|
|
|
|
sparc_vme_map,
|
|
|
|
sparc_vme_unmap,
|
1999-06-30 19:18:58 +04:00
|
|
|
sparc_vme_probe,
|
1998-01-25 19:06:25 +03:00
|
|
|
sparc_vme_intr_map,
|
2000-06-04 23:14:14 +04:00
|
|
|
sparc_vme_intr_evcnt,
|
1998-01-25 19:06:25 +03:00
|
|
|
sparc_vme_intr_establish,
|
|
|
|
sparc_vme_intr_disestablish,
|
1999-06-30 19:18:58 +04:00
|
|
|
0, 0, 0 /* bus specific DMA stuff */
|
1998-01-25 19:06:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(SUN4)
|
|
|
|
struct sparc_bus_dma_tag sparc_vme4_dma_tag = {
|
|
|
|
NULL, /* cookie */
|
|
|
|
_bus_dmamap_create,
|
|
|
|
_bus_dmamap_destroy,
|
|
|
|
sparc_vme4_dmamap_load,
|
|
|
|
_bus_dmamap_load_mbuf,
|
|
|
|
_bus_dmamap_load_uio,
|
|
|
|
_bus_dmamap_load_raw,
|
|
|
|
sparc_vme4_dmamap_unload,
|
|
|
|
sparc_vme4_dmamap_sync,
|
|
|
|
|
2000-05-10 02:39:35 +04:00
|
|
|
_bus_dmamem_alloc,
|
|
|
|
_bus_dmamem_free,
|
1998-07-31 02:29:34 +04:00
|
|
|
sparc_vme_dmamem_map,
|
1998-01-25 19:06:25 +03:00
|
|
|
_bus_dmamem_unmap,
|
|
|
|
_bus_dmamem_mmap
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SUN4M)
|
2000-06-27 13:05:23 +04:00
|
|
|
struct sparc_bus_dma_tag sparc_vme_iommu_dma_tag = {
|
1998-01-25 19:06:25 +03:00
|
|
|
NULL, /* cookie */
|
2000-06-27 13:05:23 +04:00
|
|
|
sparc_vme_iommu_dmamap_create,
|
1998-01-25 19:06:25 +03:00
|
|
|
_bus_dmamap_destroy,
|
2000-06-27 13:05:23 +04:00
|
|
|
sparc_vme_iommu_dmamap_load,
|
1998-01-25 19:06:25 +03:00
|
|
|
_bus_dmamap_load_mbuf,
|
|
|
|
_bus_dmamap_load_uio,
|
|
|
|
_bus_dmamap_load_raw,
|
2000-06-27 13:05:23 +04:00
|
|
|
sparc_vme_iommu_dmamap_unload,
|
|
|
|
sparc_vme_iommu_dmamap_sync,
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2000-05-10 02:39:35 +04:00
|
|
|
_bus_dmamem_alloc,
|
|
|
|
_bus_dmamem_free,
|
1998-07-31 02:29:34 +04:00
|
|
|
sparc_vme_dmamem_map,
|
1998-01-25 19:06:25 +03:00
|
|
|
_bus_dmamem_unmap,
|
|
|
|
_bus_dmamem_mmap
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
2009-09-20 20:18:21 +04:00
|
|
|
vmematch_mainbus(device_t parent, cfdata_t cf, void *aux)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1999-01-15 03:26:24 +03:00
|
|
|
struct mainbus_attach_args *ma = aux;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2004-12-13 05:14:13 +03:00
|
|
|
if (!CPU_ISSUN4 || vme_attached)
|
1998-01-25 19:06:25 +03:00
|
|
|
return (0);
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
return (strcmp("vme", ma->ma_name) == 0);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
2009-09-20 20:18:21 +04:00
|
|
|
vmematch_iommu(device_t parent, cfdata_t cf, void *aux)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1999-01-15 03:26:24 +03:00
|
|
|
struct iommu_attach_args *ia = aux;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2004-12-13 05:14:13 +03:00
|
|
|
if (vme_attached)
|
|
|
|
return 0;
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
return (strcmp("vme", ia->iom_name) == 0);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
1998-03-21 23:30:49 +03:00
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
2009-09-20 20:18:21 +04:00
|
|
|
vmeattach_mainbus(device_t parent, device_t self, void *aux)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1998-03-21 23:30:49 +03:00
|
|
|
#if defined(SUN4)
|
|
|
|
struct mainbus_attach_args *ma = aux;
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = device_private(self);
|
1999-06-30 19:18:58 +04:00
|
|
|
struct vmebus_attach_args vba;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2004-12-13 05:14:13 +03:00
|
|
|
vme_attached = 1;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
sc->sc_bustag = ma->ma_bustag;
|
1998-07-30 22:54:06 +04:00
|
|
|
sc->sc_dmatag = ma->ma_dmatag;
|
1998-04-08 00:21:55 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
/* VME interrupt entry point */
|
|
|
|
sc->sc_vmeintr = vmeintr4;
|
|
|
|
|
2009-09-20 20:18:21 +04:00
|
|
|
/*XXX*/ sparc_vme_chipset_tag.cookie = sc;
|
2000-06-25 17:07:34 +04:00
|
|
|
/*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct4_dmamap_create;
|
|
|
|
/*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy;
|
2009-09-20 20:18:21 +04:00
|
|
|
/*XXX*/ sparc_vme4_dma_tag._cookie = sc;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
vba.va_vct = &sparc_vme_chipset_tag;
|
|
|
|
vba.va_bdt = &sparc_vme4_dma_tag;
|
|
|
|
vba.va_slaveconfig = 0;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
/* Fall back to our own `range' construction */
|
|
|
|
sc->sc_range = vmebus_translations;
|
|
|
|
sc->sc_nrange =
|
|
|
|
sizeof(vmebus_translations)/sizeof(vmebus_translations[0]);
|
|
|
|
|
1998-08-23 14:05:53 +04:00
|
|
|
vme_dvmamap = extent_create("vmedvma", VME4_DVMA_BASE, VME4_DVMA_END,
|
2012-01-27 22:52:47 +04:00
|
|
|
0, 0, EX_NOWAIT);
|
1998-08-23 14:05:53 +04:00
|
|
|
if (vme_dvmamap == NULL)
|
|
|
|
panic("vme: unable to allocate DVMA map");
|
1998-08-21 00:46:59 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
printf("\n");
|
1999-06-30 19:18:58 +04:00
|
|
|
(void)config_found(self, &vba, 0);
|
1998-03-21 23:30:49 +03:00
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
#endif /* SUN4 */
|
1998-01-25 19:06:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sun4m vmebus */
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
2012-10-27 21:17:22 +04:00
|
|
|
vmeattach_iommu(device_t parent, device_t self, void *aux)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1998-03-21 23:30:49 +03:00
|
|
|
#if defined(SUN4M)
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = device_private(self);
|
1998-03-21 23:30:49 +03:00
|
|
|
struct iommu_attach_args *ia = aux;
|
1999-06-30 19:18:58 +04:00
|
|
|
struct vmebus_attach_args vba;
|
1998-03-21 23:30:49 +03:00
|
|
|
bus_space_handle_t bh;
|
|
|
|
int node;
|
1998-01-25 19:06:25 +03:00
|
|
|
int cline;
|
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
sc->sc_bustag = ia->iom_bustag;
|
1998-07-30 22:54:06 +04:00
|
|
|
sc->sc_dmatag = ia->iom_dmatag;
|
1998-04-08 00:21:55 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
/* VME interrupt entry point */
|
|
|
|
sc->sc_vmeintr = vmeintr4m;
|
|
|
|
|
2009-09-20 20:18:21 +04:00
|
|
|
/*XXX*/ sparc_vme_chipset_tag.cookie = sc;
|
2000-06-27 13:05:23 +04:00
|
|
|
/*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct_iommu_dmamap_create;
|
2000-06-25 17:07:34 +04:00
|
|
|
/*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy;
|
2009-09-20 20:18:21 +04:00
|
|
|
/*XXX*/ sparc_vme_iommu_dma_tag._cookie = sc;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
vba.va_vct = &sparc_vme_chipset_tag;
|
2000-06-27 13:05:23 +04:00
|
|
|
vba.va_bdt = &sparc_vme_iommu_dma_tag;
|
1999-06-30 19:18:58 +04:00
|
|
|
vba.va_slaveconfig = 0;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1998-03-21 23:30:49 +03:00
|
|
|
node = ia->iom_node;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
/*
|
|
|
|
* Map VME control space
|
|
|
|
*/
|
1998-09-19 20:45:43 +04:00
|
|
|
if (ia->iom_nreg < 2) {
|
2009-09-20 20:18:21 +04:00
|
|
|
printf("%s: only %d register sets\n", device_xname(self),
|
1998-09-19 20:45:43 +04:00
|
|
|
ia->iom_nreg);
|
1998-03-21 23:30:49 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
if (bus_space_map(ia->iom_bustag,
|
2002-08-23 06:53:10 +04:00
|
|
|
(bus_addr_t) BUS_ADDR(ia->iom_reg[0].oa_space,
|
|
|
|
ia->iom_reg[0].oa_base),
|
|
|
|
(bus_size_t)ia->iom_reg[0].oa_size,
|
1998-04-08 00:21:55 +04:00
|
|
|
BUS_SPACE_MAP_LINEAR,
|
2002-03-11 19:27:01 +03:00
|
|
|
&bh) != 0) {
|
2009-09-20 20:18:21 +04:00
|
|
|
panic("%s: can't map vmebusreg", device_xname(self));
|
1998-03-21 23:30:49 +03:00
|
|
|
}
|
|
|
|
sc->sc_reg = (struct vmebusreg *)bh;
|
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
if (bus_space_map(ia->iom_bustag,
|
2002-08-23 06:53:10 +04:00
|
|
|
(bus_addr_t) BUS_ADDR(ia->iom_reg[1].oa_space,
|
|
|
|
ia->iom_reg[1].oa_base),
|
|
|
|
(bus_size_t)ia->iom_reg[1].oa_size,
|
1998-04-08 00:21:55 +04:00
|
|
|
BUS_SPACE_MAP_LINEAR,
|
2002-03-11 19:27:01 +03:00
|
|
|
&bh) != 0) {
|
2009-09-20 20:18:21 +04:00
|
|
|
panic("%s: can't map vmebusvec", device_xname(self));
|
1998-03-21 23:30:49 +03:00
|
|
|
}
|
|
|
|
sc->sc_vec = (struct vmebusvec *)bh;
|
|
|
|
|
1998-04-08 00:21:55 +04:00
|
|
|
/*
|
|
|
|
* Map VME IO cache tags and flush control.
|
|
|
|
*/
|
2002-03-11 19:27:01 +03:00
|
|
|
if (bus_space_map(ia->iom_bustag,
|
|
|
|
(bus_addr_t) BUS_ADDR(
|
2002-08-23 06:53:10 +04:00
|
|
|
ia->iom_reg[1].oa_space,
|
|
|
|
ia->iom_reg[1].oa_base + VME_IOC_TAGOFFSET),
|
1998-04-08 00:21:55 +04:00
|
|
|
VME_IOC_SIZE,
|
|
|
|
BUS_SPACE_MAP_LINEAR,
|
2002-03-11 19:27:01 +03:00
|
|
|
&bh) != 0) {
|
2009-09-20 20:18:21 +04:00
|
|
|
panic("%s: can't map IOC tags", device_xname(self));
|
1998-03-21 23:30:49 +03:00
|
|
|
}
|
2005-11-16 03:49:02 +03:00
|
|
|
sc->sc_ioctags = (uint32_t *)bh;
|
1998-03-21 23:30:49 +03:00
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
if (bus_space_map(ia->iom_bustag,
|
|
|
|
(bus_addr_t) BUS_ADDR(
|
2002-08-23 06:53:10 +04:00
|
|
|
ia->iom_reg[1].oa_space,
|
|
|
|
ia->iom_reg[1].oa_base + VME_IOC_FLUSHOFFSET),
|
1998-04-08 00:21:55 +04:00
|
|
|
VME_IOC_SIZE,
|
|
|
|
BUS_SPACE_MAP_LINEAR,
|
2002-03-11 19:27:01 +03:00
|
|
|
&bh) != 0) {
|
2009-09-20 20:18:21 +04:00
|
|
|
panic("%s: can't map IOC flush registers", device_xname(self));
|
1998-03-21 23:30:49 +03:00
|
|
|
}
|
2005-11-16 03:49:02 +03:00
|
|
|
sc->sc_iocflush = (uint32_t *)bh;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get "range" property.
|
|
|
|
*/
|
2004-03-17 20:04:58 +03:00
|
|
|
if (prom_getprop(node, "ranges", sizeof(struct rom_range),
|
2003-08-27 19:59:49 +04:00
|
|
|
&sc->sc_nrange, &sc->sc_range) != 0) {
|
2009-09-20 20:18:21 +04:00
|
|
|
panic("%s: can't get ranges property", device_xname(self));
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
sparcvme_sc = sc;
|
1998-09-19 20:45:43 +04:00
|
|
|
vmeerr_handler = sparc_vme_error;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Invalidate all IO-cache entries.
|
|
|
|
*/
|
|
|
|
for (cline = VME_IOC_SIZE/VME_IOC_LINESZ; cline > 0;) {
|
|
|
|
sc->sc_ioctags[--cline] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable IO-cache */
|
|
|
|
sc->sc_reg->vmebus_cr |= VMEBUS_CR_C;
|
|
|
|
|
|
|
|
printf(": version 0x%x\n",
|
|
|
|
sc->sc_reg->vmebus_cr & VMEBUS_CR_IMPL);
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
(void)config_found(self, &vba, 0);
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif /* SUN4M */
|
1998-03-21 23:30:49 +03:00
|
|
|
}
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-02-08 03:13:20 +03:00
|
|
|
#if defined(SUN4M)
|
|
|
|
static int
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vme_error(void)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1999-06-30 19:18:58 +04:00
|
|
|
struct sparcvme_softc *sc = sparcvme_sc;
|
2005-11-16 03:49:02 +03:00
|
|
|
uint32_t afsr, afpa;
|
1998-09-19 20:45:43 +04:00
|
|
|
char bits[64];
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
afsr = sc->sc_reg->vmebus_afsr;
|
1998-09-19 20:45:43 +04:00
|
|
|
afpa = sc->sc_reg->vmebus_afar;
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(bits, sizeof(bits), VMEBUS_AFSR_BITS, afsr);
|
|
|
|
printf("VME error:\n\tAFSR %s\n", bits);
|
1998-09-19 20:45:43 +04:00
|
|
|
printf("\taddress: 0x%x%x\n", afsr, afpa);
|
|
|
|
return (0);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
1999-02-08 03:13:20 +03:00
|
|
|
#endif
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
vmebus_translate(struct sparcvme_softc *sc, vme_am_t mod, vme_addr_t addr,
|
|
|
|
bus_addr_t *bap)
|
1998-04-08 00:21:55 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sc->sc_nrange; i++) {
|
2002-03-11 19:27:01 +03:00
|
|
|
struct rom_range *rp = &sc->sc_range[i];
|
1998-04-08 00:21:55 +04:00
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
if (rp->cspace != mod)
|
1998-04-08 00:21:55 +04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* We've found the connection to the parent bus */
|
2002-03-11 19:27:01 +03:00
|
|
|
*bap = BUS_ADDR(rp->pspace, rp->poffset + addr);
|
1998-04-08 00:21:55 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
struct vmeprobe_myarg {
|
2005-11-16 03:49:02 +03:00
|
|
|
int (*cb)(void *, bus_space_tag_t, bus_space_handle_t);
|
1999-06-30 19:18:58 +04:00
|
|
|
void *cbarg;
|
|
|
|
bus_space_tag_t tag;
|
|
|
|
int res; /* backwards */
|
|
|
|
};
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int vmeprobe_mycb(void *, void *);
|
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
static int
|
2005-11-16 03:49:02 +03:00
|
|
|
vmeprobe_mycb(void *bh, void *arg)
|
1999-06-30 19:18:58 +04:00
|
|
|
{
|
|
|
|
struct vmeprobe_myarg *a = arg;
|
|
|
|
|
|
|
|
a->res = (*a->cb)(a->cbarg, a->tag, (bus_space_handle_t)bh);
|
|
|
|
return (!a->res);
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme_probe(void *cookie, vme_addr_t addr, vme_size_t len, vme_am_t mod,
|
|
|
|
vme_datasize_t datasize,
|
|
|
|
int (*callback)(void *, bus_space_tag_t, bus_space_handle_t),
|
|
|
|
void *arg)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
1998-04-08 00:21:55 +04:00
|
|
|
bus_addr_t paddr;
|
1999-06-30 19:18:58 +04:00
|
|
|
bus_size_t size;
|
|
|
|
struct vmeprobe_myarg myarg;
|
|
|
|
int res, i;
|
1998-04-08 00:21:55 +04:00
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
if (vmebus_translate(sc, mod, addr, &paddr) != 0)
|
1999-06-30 19:18:58 +04:00
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
size = (datasize == VME_D8 ? 1 : (datasize == VME_D16 ? 2 : 4));
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
myarg.cb = callback;
|
|
|
|
myarg.cbarg = arg;
|
|
|
|
myarg.tag = sc->sc_bustag;
|
|
|
|
myarg.res = 0;
|
2002-03-11 19:27:01 +03:00
|
|
|
res = bus_space_probe(sc->sc_bustag, paddr, size, 0,
|
1999-06-30 19:18:58 +04:00
|
|
|
0, vmeprobe_mycb, &myarg);
|
|
|
|
return (res ? 0 : (myarg.res ? myarg.res : EIO));
|
|
|
|
}
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
for (i = 0; i < len / size; i++) {
|
|
|
|
myarg.res = 0;
|
2002-03-11 19:27:01 +03:00
|
|
|
res = bus_space_probe(sc->sc_bustag, paddr, size, 0,
|
1999-06-30 19:18:58 +04:00
|
|
|
0, 0, 0);
|
|
|
|
if (res == 0)
|
|
|
|
return (EIO);
|
|
|
|
paddr += size;
|
|
|
|
}
|
|
|
|
return (0);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme_map(void *cookie, vme_addr_t addr, vme_size_t size, vme_am_t mod,
|
|
|
|
vme_datasize_t datasize, vme_swap_t swap,
|
|
|
|
bus_space_tag_t *tp, bus_space_handle_t *hp, vme_mapresc_t *rp)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
1998-04-08 00:21:55 +04:00
|
|
|
bus_addr_t paddr;
|
|
|
|
int error;
|
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
error = vmebus_translate(sc, mod, addr, &paddr);
|
1998-04-08 00:21:55 +04:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1999-06-30 19:18:58 +04:00
|
|
|
*tp = sc->sc_bustag;
|
2002-03-11 19:27:01 +03:00
|
|
|
return (bus_space_map(sc->sc_bustag, paddr, size, 0, hp));
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vme_mmap_cookie(vme_addr_t addr, vme_am_t mod, bus_space_handle_t *hp)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1999-06-30 19:18:58 +04:00
|
|
|
struct sparcvme_softc *sc = sparcvme_sc;
|
1998-04-08 00:21:55 +04:00
|
|
|
bus_addr_t paddr;
|
|
|
|
int error;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2002-03-11 19:27:01 +03:00
|
|
|
error = vmebus_translate(sc, mod, addr, &paddr);
|
1998-04-08 00:21:55 +04:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
return (bus_space_mmap(sc->sc_bustag, paddr, 0,
|
2001-09-25 03:49:31 +04:00
|
|
|
0/*prot is ignored*/, 0));
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2004-06-27 20:08:42 +04:00
|
|
|
#ifdef notyet
|
1998-01-25 19:06:25 +03:00
|
|
|
#if defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme_iommu_barrier(bus_space_tag_t t, bus_space_handle_t h,
|
|
|
|
bus_size_t offset, bus_size_t size.
|
|
|
|
int flags)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct vmebusreg *vbp = t->cookie;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
/* Read async fault status to flush write-buffers */
|
|
|
|
(*(volatile int *)&vbp->vmebus_afsr);
|
|
|
|
}
|
2004-06-27 20:08:42 +04:00
|
|
|
#endif /* SUN4M */
|
1998-01-25 19:06:25 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VME Interrupt Priority Level to sparc Processor Interrupt Level.
|
|
|
|
*/
|
|
|
|
static int vme_ipl_to_pil[] = {
|
|
|
|
0,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
7,
|
|
|
|
9,
|
|
|
|
11,
|
|
|
|
13
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All VME device interrupts go through vmeintr(). This function reads
|
|
|
|
* the VME vector from the bus, then dispatches the device interrupt
|
|
|
|
* handler. All handlers for devices that map to the same Processor
|
|
|
|
* Interrupt Level (according to the table above) are on a linked list
|
|
|
|
* of `sparc_vme_intr_handle' structures. The head of which is passed
|
|
|
|
* down as the argument to `vmeintr(void *arg)'.
|
|
|
|
*/
|
|
|
|
struct sparc_vme_intr_handle {
|
|
|
|
struct intrhand ih;
|
|
|
|
struct sparc_vme_intr_handle *next;
|
|
|
|
int vec; /* VME interrupt vector */
|
|
|
|
int pri; /* VME interrupt priority */
|
1999-06-30 19:18:58 +04:00
|
|
|
struct sparcvme_softc *sc;/*XXX*/
|
1998-01-25 19:06:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(SUN4)
|
|
|
|
int
|
2005-11-16 03:49:02 +03:00
|
|
|
vmeintr4(void *arg)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
|
|
|
struct sparc_vme_intr_handle *ihp = (vme_intr_handle_t)arg;
|
|
|
|
int level, vec;
|
2000-07-05 02:22:56 +04:00
|
|
|
int rv = 0;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
level = (ihp->pri << 1) | 1;
|
|
|
|
|
2007-03-04 08:59:00 +03:00
|
|
|
vec = ldcontrolb((void *)(AC_VMEINTVEC | level));
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
if (vec == -1) {
|
2000-07-05 02:22:56 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/*
|
|
|
|
* This seems to happen only with the i82586 based
|
|
|
|
* `ie1' boards.
|
|
|
|
*/
|
|
|
|
printf("vme: spurious interrupt at VME level %d\n", ihp->pri);
|
|
|
|
#endif
|
|
|
|
return (1); /* XXX - pretend we handled it, for now */
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (; ihp; ihp = ihp->next)
|
2002-12-06 19:04:11 +03:00
|
|
|
if (ihp->vec == vec && ihp->ih.ih_fun) {
|
|
|
|
splx(ihp->ih.ih_classipl);
|
2000-07-05 02:22:56 +04:00
|
|
|
rv |= (ihp->ih.ih_fun)(ihp->ih.ih_arg);
|
2002-12-06 19:04:11 +03:00
|
|
|
}
|
2000-07-05 02:22:56 +04:00
|
|
|
|
|
|
|
return (rv);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SUN4M)
|
|
|
|
int
|
2005-11-16 03:49:02 +03:00
|
|
|
vmeintr4m(void *arg)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
|
|
|
struct sparc_vme_intr_handle *ihp = (vme_intr_handle_t)arg;
|
|
|
|
int level, vec;
|
2000-07-05 02:22:56 +04:00
|
|
|
int rv = 0;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
level = (ihp->pri << 1) | 1;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
int pending;
|
|
|
|
|
|
|
|
/* Flush VME <=> Sbus write buffers */
|
|
|
|
(*(volatile int *)&ihp->sc->sc_reg->vmebus_afsr);
|
|
|
|
|
|
|
|
pending = *((int*)ICR_SI_PEND);
|
|
|
|
if ((pending & SINTR_VME(ihp->pri)) == 0) {
|
|
|
|
printf("vmeintr: non pending at pri %x(p 0x%x)\n",
|
|
|
|
ihp->pri, pending);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
/* Why gives this a bus timeout sometimes? */
|
|
|
|
vec = ihp->sc->sc_vec->vmebusvec[level];
|
|
|
|
#else
|
|
|
|
/* so, arrange to catch the fault... */
|
|
|
|
{
|
2005-11-16 03:49:02 +03:00
|
|
|
extern int fkbyte(volatile char *, struct pcb *);
|
2005-06-04 08:59:18 +04:00
|
|
|
volatile char *addr = &ihp->sc->sc_vec->vmebusvec[level];
|
1998-01-25 19:06:25 +03:00
|
|
|
struct pcb *xpcb;
|
2011-01-14 05:06:22 +03:00
|
|
|
void *saveonfault;
|
1998-01-25 19:06:25 +03:00
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
|
2009-11-21 07:16:51 +03:00
|
|
|
xpcb = lwp_getpcb(curlwp);
|
2011-01-14 05:06:22 +03:00
|
|
|
saveonfault = xpcb->pcb_onfault;
|
1998-01-25 19:06:25 +03:00
|
|
|
vec = fkbyte(addr, xpcb);
|
2011-01-14 05:06:22 +03:00
|
|
|
xpcb->pcb_onfault = saveonfault;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (vec == -1) {
|
2000-07-05 02:22:56 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/*
|
|
|
|
* This seems to happen only with the i82586 based
|
|
|
|
* `ie1' boards.
|
|
|
|
*/
|
|
|
|
printf("vme: spurious interrupt at VME level %d\n", ihp->pri);
|
|
|
|
printf(" ICR_SI_PEND=0x%x; VME AFSR=0x%x; VME AFAR=0x%x\n",
|
1998-01-25 19:06:25 +03:00
|
|
|
*((int*)ICR_SI_PEND),
|
|
|
|
ihp->sc->sc_reg->vmebus_afsr,
|
|
|
|
ihp->sc->sc_reg->vmebus_afar);
|
2000-07-05 02:22:56 +04:00
|
|
|
#endif
|
1998-09-19 20:45:43 +04:00
|
|
|
return (1); /* XXX - pretend we handled it, for now */
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (; ihp; ihp = ihp->next)
|
2002-12-06 19:04:11 +03:00
|
|
|
if (ihp->vec == vec && ihp->ih.ih_fun) {
|
|
|
|
splx(ihp->ih.ih_classipl);
|
2000-07-05 02:22:56 +04:00
|
|
|
rv |= (ihp->ih.ih_fun)(ihp->ih.ih_arg);
|
2002-12-06 19:04:11 +03:00
|
|
|
}
|
2000-07-05 02:22:56 +04:00
|
|
|
|
|
|
|
return (rv);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
2005-11-16 03:49:02 +03:00
|
|
|
#endif /* SUN4M */
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme_intr_map(void *cookie, int level, int vec,
|
|
|
|
vme_intr_handle_t *ihp)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
|
|
|
struct sparc_vme_intr_handle *ih;
|
|
|
|
|
|
|
|
ih = (vme_intr_handle_t)
|
|
|
|
malloc(sizeof(struct sparc_vme_intr_handle), M_DEVBUF, M_NOWAIT);
|
1999-06-30 19:18:58 +04:00
|
|
|
ih->pri = level;
|
1998-01-25 19:06:25 +03:00
|
|
|
ih->vec = vec;
|
|
|
|
ih->sc = cookie;/*XXX*/
|
|
|
|
*ihp = ih;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static const struct evcnt *
|
|
|
|
sparc_vme_intr_evcnt(void *cookie, vme_intr_handle_t vih)
|
2000-06-04 23:14:14 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/* XXX for now, no evcnt parent reported */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void *
|
|
|
|
sparc_vme_intr_establish(void *cookie, vme_intr_handle_t vih, int level,
|
|
|
|
int (*func)(void *), void *arg)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
1998-01-25 19:06:25 +03:00
|
|
|
struct sparc_vme_intr_handle *svih =
|
|
|
|
(struct sparc_vme_intr_handle *)vih;
|
|
|
|
struct intrhand *ih;
|
2002-12-06 19:04:11 +03:00
|
|
|
int pil;
|
1999-06-30 19:18:58 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
/* Translate VME priority to processor IPL */
|
2002-12-06 19:04:11 +03:00
|
|
|
pil = vme_ipl_to_pil[svih->pri];
|
|
|
|
|
|
|
|
if (level < pil)
|
|
|
|
panic("vme_intr_establish: class lvl (%d) < pil (%d)\n",
|
|
|
|
level, pil);
|
1998-01-25 19:06:25 +03:00
|
|
|
|
|
|
|
svih->ih.ih_fun = func;
|
|
|
|
svih->ih.ih_arg = arg;
|
2002-12-06 19:04:11 +03:00
|
|
|
svih->ih.ih_classipl = level; /* note: used slightly differently
|
|
|
|
than in intr.c (no shift) */
|
1998-01-25 19:06:25 +03:00
|
|
|
svih->next = NULL;
|
|
|
|
|
|
|
|
/* ensure the interrupt subsystem will call us at this level */
|
2002-12-06 19:04:11 +03:00
|
|
|
for (ih = intrhand[pil]; ih != NULL; ih = ih->ih_next)
|
1998-01-25 19:06:25 +03:00
|
|
|
if (ih->ih_fun == sc->sc_vmeintr)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ih == NULL) {
|
2008-12-19 21:49:37 +03:00
|
|
|
ih = malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT|M_ZERO);
|
1998-01-25 19:06:25 +03:00
|
|
|
if (ih == NULL)
|
|
|
|
panic("vme_addirq");
|
|
|
|
ih->ih_fun = sc->sc_vmeintr;
|
|
|
|
ih->ih_arg = vih;
|
2010-01-04 02:03:20 +03:00
|
|
|
intr_establish(pil, 0, ih, NULL, false);
|
1998-01-25 19:06:25 +03:00
|
|
|
} else {
|
|
|
|
svih->next = (vme_intr_handle_t)ih->ih_arg;
|
|
|
|
ih->ih_arg = vih;
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme_unmap(void *cookie, vme_mapresc_t resc)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2005-11-16 03:49:02 +03:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
/* Not implemented */
|
|
|
|
panic("sparc_vme_unmap");
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme_intr_disestablish(void *cookie, void *a)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2005-11-16 03:49:02 +03:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
/* Not implemented */
|
|
|
|
panic("sparc_vme_intr_disestablish");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VME DMA functions.
|
|
|
|
*/
|
|
|
|
|
2003-08-01 16:19:50 +04:00
|
|
|
#if defined(SUN4) || defined(SUN4M)
|
2000-06-25 17:07:34 +04:00
|
|
|
static void
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vct_dmamap_destroy(void *cookie, bus_dmamap_t map)
|
2000-06-25 17:07:34 +04:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
2005-11-16 03:49:02 +03:00
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
bus_dmamap_destroy(sc->sc_dmatag, map);
|
|
|
|
}
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif
|
2000-06-25 17:07:34 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
#if defined(SUN4)
|
2000-06-25 17:07:34 +04:00
|
|
|
static int
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vct4_dmamap_create(void *cookie, vme_size_t size, vme_am_t am,
|
|
|
|
vme_datasize_t datasize, vme_swap_t swap,
|
|
|
|
int nsegments, vme_size_t maxsegsz,
|
|
|
|
vme_addr_t boundary, int flags,
|
|
|
|
bus_dmamap_t *dmamp)
|
2000-06-25 17:07:34 +04:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
2000-06-25 17:07:34 +04:00
|
|
|
|
|
|
|
/* Allocate a base map through parent bus ops */
|
|
|
|
return (bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz,
|
|
|
|
boundary, flags, dmamp));
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme4_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map,
|
|
|
|
void *buf, bus_size_t buflen,
|
|
|
|
struct proc *p, int flags)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2000-06-18 23:30:21 +04:00
|
|
|
bus_addr_t dva;
|
1998-08-21 00:46:59 +04:00
|
|
|
bus_size_t sgsize;
|
2003-08-27 19:59:49 +04:00
|
|
|
u_long ldva;
|
2000-06-18 23:30:21 +04:00
|
|
|
vaddr_t va, voff;
|
1998-08-21 00:46:59 +04:00
|
|
|
pmap_t pmap;
|
|
|
|
int pagesz = PAGE_SIZE;
|
1998-01-25 19:06:25 +03:00
|
|
|
int error;
|
|
|
|
|
2002-12-16 19:59:09 +03:00
|
|
|
cache_flush(buf, buflen); /* XXX - move to bus_dma_sync */
|
2000-06-18 23:30:21 +04:00
|
|
|
|
|
|
|
va = (vaddr_t)buf;
|
|
|
|
voff = va & (pagesz - 1);
|
|
|
|
va &= -pagesz;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate an integral number of pages from DVMA space
|
|
|
|
* covering the passed buffer.
|
|
|
|
*/
|
|
|
|
sgsize = (buflen + voff + pagesz - 1) & -pagesz;
|
|
|
|
error = extent_alloc(vme_dvmamap, sgsize, pagesz,
|
1998-08-21 00:46:59 +04:00
|
|
|
map->_dm_boundary,
|
|
|
|
(flags & BUS_DMA_NOWAIT) == 0
|
|
|
|
? EX_WAITOK
|
|
|
|
: EX_NOWAIT,
|
2003-08-27 19:59:49 +04:00
|
|
|
&ldva);
|
1998-01-25 19:06:25 +03:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
2003-08-27 19:59:49 +04:00
|
|
|
dva = (bus_addr_t)ldva;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
1998-08-21 00:46:59 +04:00
|
|
|
map->dm_mapsize = buflen;
|
|
|
|
map->dm_nsegs = 1;
|
2000-06-18 23:30:21 +04:00
|
|
|
/* Adjust DVMA address to VME view */
|
|
|
|
map->dm_segs[0].ds_addr = dva + voff - VME4_DVMA_BASE;
|
1998-08-21 00:46:59 +04:00
|
|
|
map->dm_segs[0].ds_len = buflen;
|
2000-06-18 23:30:21 +04:00
|
|
|
map->dm_segs[0]._ds_sgsize = sgsize;
|
1998-08-21 00:46:59 +04:00
|
|
|
|
|
|
|
pmap = (p == NULL) ? pmap_kernel() : p->p_vmspace->vm_map.pmap;
|
|
|
|
|
2000-06-18 23:30:21 +04:00
|
|
|
for (; sgsize != 0; ) {
|
1998-08-21 00:46:59 +04:00
|
|
|
paddr_t pa;
|
|
|
|
/*
|
|
|
|
* Get the physical address for this page.
|
|
|
|
*/
|
2000-06-18 23:30:21 +04:00
|
|
|
(void) pmap_extract(pmap, va, &pa);
|
1998-08-21 00:46:59 +04:00
|
|
|
|
|
|
|
#ifdef notyet
|
|
|
|
if (have_iocache)
|
2000-06-18 23:30:21 +04:00
|
|
|
pa |= PG_IOC;
|
1998-08-21 00:46:59 +04:00
|
|
|
#endif
|
2000-06-18 23:30:21 +04:00
|
|
|
pmap_enter(pmap_kernel(), dva,
|
|
|
|
pa | PMAP_NC,
|
|
|
|
VM_PROT_READ|VM_PROT_WRITE, PMAP_WIRED);
|
1998-08-21 00:46:59 +04:00
|
|
|
|
2000-06-18 23:30:21 +04:00
|
|
|
dva += pagesz;
|
|
|
|
va += pagesz;
|
|
|
|
sgsize -= pagesz;
|
1998-08-21 00:46:59 +04:00
|
|
|
}
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
1998-08-21 00:46:59 +04:00
|
|
|
|
1998-01-25 19:06:25 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme4_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2000-05-10 02:39:35 +04:00
|
|
|
bus_dma_segment_t *segs = map->dm_segs;
|
|
|
|
int nsegs = map->dm_nsegs;
|
|
|
|
bus_addr_t dva;
|
1998-08-21 00:46:59 +04:00
|
|
|
bus_size_t len;
|
2000-06-18 23:30:21 +04:00
|
|
|
int i, s, error;
|
1998-07-30 22:54:06 +04:00
|
|
|
|
2000-05-10 02:39:35 +04:00
|
|
|
for (i = 0; i < nsegs; i++) {
|
|
|
|
/* Go from VME to CPU view */
|
|
|
|
dva = segs[i].ds_addr + VME4_DVMA_BASE;
|
2000-06-18 23:30:21 +04:00
|
|
|
dva &= -PAGE_SIZE;
|
|
|
|
len = segs[i]._ds_sgsize;
|
1998-08-21 00:46:59 +04:00
|
|
|
|
2000-05-10 02:39:35 +04:00
|
|
|
/* Remove double-mapping in DVMA space */
|
|
|
|
pmap_remove(pmap_kernel(), dva, dva + len);
|
1998-08-21 00:46:59 +04:00
|
|
|
|
2000-05-10 02:39:35 +04:00
|
|
|
/* Release DVMA space */
|
2000-06-18 23:30:21 +04:00
|
|
|
s = splhigh();
|
|
|
|
error = extent_free(vme_dvmamap, dva, len, EX_NOWAIT);
|
|
|
|
splx(s);
|
|
|
|
if (error != 0)
|
2000-05-10 02:39:35 +04:00
|
|
|
printf("warning: %ld of DVMA space lost\n", len);
|
|
|
|
}
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
1998-08-21 00:46:59 +04:00
|
|
|
|
|
|
|
/* Mark the mappings as invalid. */
|
|
|
|
map->dm_mapsize = 0;
|
|
|
|
map->dm_nsegs = 0;
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme4_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map,
|
|
|
|
bus_addr_t offset, bus_size_t len, int ops)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1998-02-04 04:57:27 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Should perform cache flushes as necessary (e.g. 4/200 W/B).
|
1998-08-21 00:46:59 +04:00
|
|
|
* Currently the cache is flushed in bus_dma_load()...
|
1998-02-04 04:57:27 +03:00
|
|
|
*/
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
#endif /* SUN4 */
|
|
|
|
|
|
|
|
#if defined(SUN4M)
|
|
|
|
static int
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vme_iommu_dmamap_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)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2000-06-25 17:07:34 +04:00
|
|
|
|
2000-06-27 13:05:23 +04:00
|
|
|
printf("sparc_vme_dmamap_create: please use `vme_dmamap_create'\n");
|
2000-06-25 17:07:34 +04:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-11-16 03:49:02 +03:00
|
|
|
sparc_vct_iommu_dmamap_create(void *cookie, vme_size_t size, vme_am_t am,
|
|
|
|
vme_datasize_t datasize, vme_swap_t swap,
|
|
|
|
int nsegments, vme_size_t maxsegsz,
|
|
|
|
vme_addr_t boundary, int flags,
|
|
|
|
bus_dmamap_t *dmamp)
|
2000-06-25 17:07:34 +04:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = cookie;
|
2000-06-25 17:07:34 +04:00
|
|
|
bus_dmamap_t map;
|
1998-08-21 00:46:59 +04:00
|
|
|
int error;
|
1998-01-25 19:06:25 +03:00
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
/* Allocate a base map through parent bus ops */
|
1998-08-21 00:46:59 +04:00
|
|
|
error = bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz,
|
2000-06-25 17:07:34 +04:00
|
|
|
boundary, flags, &map);
|
1998-08-21 00:46:59 +04:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
/*
|
|
|
|
* Each I/O cache line maps to a 8K section of VME DVMA space, so
|
|
|
|
* we must ensure that DVMA alloctions are always 8K aligned.
|
|
|
|
*/
|
|
|
|
map->_dm_align = VME_IOC_PAGESZ;
|
|
|
|
|
|
|
|
/* Set map region based on Address Modifier */
|
|
|
|
switch ((am & VME_AM_ADRSIZEMASK)) {
|
|
|
|
case VME_AM_A16:
|
|
|
|
case VME_AM_A24:
|
|
|
|
/* 1 MB of DVMA space */
|
2000-06-27 13:05:23 +04:00
|
|
|
map->_dm_ex_start = VME_IOMMU_DVMA_AM24_BASE;
|
|
|
|
map->_dm_ex_end = VME_IOMMU_DVMA_AM24_END;
|
2000-06-25 17:07:34 +04:00
|
|
|
break;
|
|
|
|
case VME_AM_A32:
|
|
|
|
/* 8 MB of DVMA space */
|
2000-06-27 13:05:23 +04:00
|
|
|
map->_dm_ex_start = VME_IOMMU_DVMA_AM32_BASE;
|
|
|
|
map->_dm_ex_end = VME_IOMMU_DVMA_AM32_END;
|
2000-06-25 17:07:34 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-08-21 00:46:59 +04:00
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
*dmamp = map;
|
1998-08-21 00:46:59 +04:00
|
|
|
return (0);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme_iommu_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map,
|
|
|
|
void *buf, bus_size_t buflen,
|
|
|
|
struct proc *p, int flags)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = t->_cookie;
|
2005-11-16 03:49:02 +03:00
|
|
|
volatile uint32_t *ioctags;
|
1998-01-25 19:06:25 +03:00
|
|
|
int error;
|
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
/* Round request to a multiple of the I/O cache size */
|
2000-05-10 02:39:35 +04:00
|
|
|
buflen = (buflen + VME_IOC_PAGESZ - 1) & -VME_IOC_PAGESZ;
|
1998-07-30 22:54:06 +04:00
|
|
|
error = bus_dmamap_load(sc->sc_dmatag, map, buf, buflen, p, flags);
|
1998-01-25 19:06:25 +03:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
/* Allocate I/O cache entries for this range */
|
1998-01-25 19:06:25 +03:00
|
|
|
ioctags = sc->sc_ioctags + VME_IOC_LINE(map->dm_segs[0].ds_addr);
|
2000-06-25 17:07:34 +04:00
|
|
|
while (buflen > 0) {
|
1998-01-25 19:06:25 +03:00
|
|
|
*ioctags = VME_IOC_IC | VME_IOC_W;
|
|
|
|
ioctags += VME_IOC_LINESZ/sizeof(*ioctags);
|
|
|
|
buflen -= VME_IOC_PAGESZ;
|
|
|
|
}
|
2000-06-27 13:05:23 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Adjust DVMA address to VME view.
|
|
|
|
* Note: the DVMA base address is the same for all
|
|
|
|
* VME address spaces.
|
|
|
|
*/
|
|
|
|
map->dm_segs[0].ds_addr -= VME_IOMMU_DVMA_BASE;
|
1998-01-25 19:06:25 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme_iommu_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = t->_cookie;
|
2005-11-16 03:49:02 +03:00
|
|
|
volatile uint32_t *flushregs;
|
1998-01-25 19:06:25 +03:00
|
|
|
int len;
|
|
|
|
|
2000-06-27 13:05:23 +04:00
|
|
|
/* Go from VME to CPU view */
|
|
|
|
map->dm_segs[0].ds_addr += VME_IOMMU_DVMA_BASE;
|
|
|
|
|
2000-06-25 17:07:34 +04:00
|
|
|
/* Flush VME I/O cache */
|
|
|
|
len = map->dm_segs[0]._ds_sgsize;
|
1998-01-25 19:06:25 +03:00
|
|
|
flushregs = sc->sc_iocflush + VME_IOC_LINE(map->dm_segs[0].ds_addr);
|
2000-06-25 17:07:34 +04:00
|
|
|
while (len > 0) {
|
1998-01-25 19:06:25 +03:00
|
|
|
*flushregs = 0;
|
|
|
|
flushregs += VME_IOC_LINESZ/sizeof(*flushregs);
|
|
|
|
len -= VME_IOC_PAGESZ;
|
|
|
|
}
|
2000-06-25 17:07:34 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start a read from `tag space' which will not complete until
|
|
|
|
* all cache flushes have finished
|
|
|
|
*/
|
1998-01-25 19:06:25 +03:00
|
|
|
(*sc->sc_ioctags);
|
|
|
|
|
1998-07-30 22:54:06 +04:00
|
|
|
bus_dmamap_unload(sc->sc_dmatag, map);
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-16 03:49:02 +03:00
|
|
|
static void
|
|
|
|
sparc_vme_iommu_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map,
|
|
|
|
bus_addr_t offset, bus_size_t len, int ops)
|
1998-01-25 19:06:25 +03:00
|
|
|
{
|
1998-02-04 04:57:27 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Should perform cache flushes as necessary.
|
|
|
|
*/
|
1998-01-25 19:06:25 +03:00
|
|
|
}
|
|
|
|
#endif /* SUN4M */
|
1998-08-23 14:40:38 +04:00
|
|
|
|
2003-08-01 16:19:50 +04:00
|
|
|
#if defined(SUN4) || defined(SUN4M)
|
2005-11-16 03:49:02 +03:00
|
|
|
static int
|
|
|
|
sparc_vme_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
2007-03-04 08:59:00 +03:00
|
|
|
size_t size, void **kvap, int flags)
|
1998-08-23 14:40:38 +04:00
|
|
|
{
|
2009-09-20 20:18:21 +04:00
|
|
|
struct sparcvme_softc *sc = t->_cookie;
|
1998-08-23 14:40:38 +04:00
|
|
|
|
|
|
|
return (bus_dmamem_map(sc->sc_dmatag, segs, nsegs, size, kvap, flags));
|
|
|
|
}
|
2003-08-01 16:19:50 +04:00
|
|
|
#endif /* SUN4 || SUN4M */
|