1 /* $NetBSD: a12c_dma.c,v 1.5 2009/03/14 14:45:53 dsl Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Stub version -- drivers used on the A12 (primarily ade) were adapted
35 * for NetBSD prior to the availability of bus_dma.
36 * They employ ad-hoc support for the required sram
37 * bounce buffers and are not in the NetBSD source
38 * tree. When a bus_dma if_de is available, this
39 * module will need to be completed! I certainly
40 * would not mind committing if_ade, but it doesn't
41 * have any lasting value.
44 #include "opt_avalon_a12.h" /* Config options headers */
45 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
47 __KERNEL_RCSID(0, "$NetBSD: a12c_dma.c,v 1.5 2009/03/14 14:45:53 dsl Exp $");
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/kernel.h>
52 #include <sys/device.h>
53 #include <sys/malloc.h>
55 #include <uvm/uvm_extern.h>
57 #define _ALPHA_BUS_DMA_PRIVATE
58 #include <machine/bus.h>
60 #include <dev/pci/pcireg.h>
61 #include <dev/pci/pcivar.h>
62 #include <alpha/pci/a12creg.h>
63 #include <alpha/pci/a12cvar.h>
65 #define A12C_DMA() /* Generate ctags(1) key */
67 bus_dma_tag_t
a12c_dma_get_tag(bus_dma_tag_t
, alpha_bus_t
);
70 int a12c_bus_dmamap_load_direct(bus_dma_tag_t
, bus_dmamap_t
, void *,
71 bus_size_t
, struct proc
*, int);
73 int a12c_bus_dmamap_load_mbuf_direct(bus_dma_tag_t
, bus_dmamap_t
,
76 int a12c_bus_dmamap_load_uio_direct(bus_dma_tag_t
, bus_dmamap_t
,
79 int a12c_bus_dmamap_load_raw_direct(bus_dma_tag_t
, bus_dmamap_t
,
80 bus_dma_segment_t
*, int, bus_size_t
, int);
83 a12c_dma_init(struct a12c_config
*ccp
)
88 * Return the bus dma tag to be used for the specified bus type.
92 a12c_dma_get_tag(bus_dma_tag_t t
, alpha_bus_t bustype
)
97 * Load a A12C direct-mapped DMA map with a linear buffer.
100 a12c_bus_dmamap_load_direct(bus_dma_tag_t t
, bus_dmamap_t map
, void *buf
, bus_size_t buflen
, struct proc
*p
, int flags
)
105 return (_bus_dmamap_load_direct_common(t
, map
, buf
, buflen
, p
,
106 flags
, A12C_DIRECT_MAPPED_BASE
));
110 * Load a A12C direct-mapped DMA map with an mbuf chain.
113 a12c_bus_dmamap_load_mbuf_direct(bus_dma_tag_t t
, bus_dmamap_t map
, struct mbuf
*m
, int flags
)
118 return (_bus_dmamap_load_mbuf_direct_common(t
, map
, m
,
119 flags
, A12C_DIRECT_MAPPED_BASE
));
123 * Load a A12C direct-mapped DMA map with a uio.
126 a12c_bus_dmamap_load_uio_direct(bus_dma_tag_t t
, bus_dmamap_t map
, struct uio
*uio
, int flags
)
131 return (_bus_dmamap_load_uio_direct_common(t
, map
, uio
,
132 flags
, A12C_DIRECT_MAPPED_BASE
));
136 * Load a A12C direct-mapped DMA map with raw memory.
139 a12c_bus_dmamap_load_raw_direct(bus_dma_tag_t t
, bus_dmamap_t map
, bus_dma_segment_t
*segs
, int nsegs
, bus_size_t size
, int flags
)
144 return (_bus_dmamap_load_raw_direct_common(t
, map
, segs
, nsegs
,
145 size
, flags
, A12C_DIRECT_MAPPED_BASE
));