xref: /netbsd-src/sys/arch/shark/isa/isadma_machdep.c (revision aef5eb5f59cdfe8314f1b5f78ac04eb144e44010)
1 /*	$NetBSD: isadma_machdep.c,v 1.17 2012/09/21 14:21:58 matt Exp $	*/
2 
3 /*-
4  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
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.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
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.
19  *
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.
31  */
32 
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: isadma_machdep.c,v 1.17 2012/09/21 14:21:58 matt Exp $");
35 
36 #define ISA_DMA_STATS
37 
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/syslog.h>
41 #include <sys/device.h>
42 #include <sys/malloc.h>
43 #include <sys/proc.h>
44 #include <sys/mbuf.h>
45 
46 #define _ARM32_BUS_DMA_PRIVATE
47 #include <sys/bus.h>
48 
49 #include <dev/isa/isareg.h>
50 #include <dev/isa/isavar.h>
51 
52 #include <uvm/uvm_extern.h>
53 
54 /*
55  * ISA has a 24-bit address limitation, so at most it has a 16M
56  * DMA range.  However, some platforms have a more limited range,
57  * e.g. the Shark NC.  On these systems, we are provided with
58  * a set of DMA ranges.  The pmap module is aware of these ranges
59  * and places DMA-safe memory for them onto an alternate free list
60  * so that they are protected from being used to service page faults,
61  * etc. (unless we've run out of memory elsewhere).
62  */
63 extern struct arm32_dma_range *shark_isa_dma_ranges;
64 extern int shark_isa_dma_nranges;
65 
66 /*
67  * Entry points for ISA DMA.  These are mostly wrappers around
68  * the generic functions that understand how to deal with bounce
69  * buffers, if necessary.
70  */
71 struct arm32_bus_dma_tag isa_bus_dma_tag = {
72 	_BUS_DMAMAP_FUNCS,
73 	_BUS_DMAMEM_FUNCS,
74 	_BUS_DMATAG_FUNCS,
75 };
76 
77 /*
78  * Initialize ISA DMA.
79  */
80 void
81 isa_dma_init(void)
82 {
83 
84 	isa_bus_dma_tag._ranges = shark_isa_dma_ranges;
85 	isa_bus_dma_tag._nranges = shark_isa_dma_nranges;
86 }
87