isadma_machdep.c revision 1.17 1 1.17 skrll /* $NetBSD: isadma_machdep.c,v 1.17 2022/09/27 06:36:41 skrll Exp $ */
2 1.1 chris
3 1.1 chris #define ISA_DMA_STATS
4 1.1 chris
5 1.1 chris /*-
6 1.1 chris * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
7 1.1 chris * All rights reserved.
8 1.1 chris *
9 1.1 chris * This code is derived from software contributed to The NetBSD Foundation
10 1.1 chris * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
11 1.1 chris * NASA Ames Research Center.
12 1.1 chris *
13 1.1 chris * Redistribution and use in source and binary forms, with or without
14 1.1 chris * modification, are permitted provided that the following conditions
15 1.1 chris * are met:
16 1.1 chris * 1. Redistributions of source code must retain the above copyright
17 1.1 chris * notice, this list of conditions and the following disclaimer.
18 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright
19 1.1 chris * notice, this list of conditions and the following disclaimer in the
20 1.1 chris * documentation and/or other materials provided with the distribution.
21 1.1 chris *
22 1.1 chris * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 1.1 chris * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 1.1 chris * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 1.1 chris * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 1.1 chris * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 1.1 chris * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 1.1 chris * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 1.1 chris * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 1.1 chris * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 1.1 chris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 chris * POSSIBILITY OF SUCH DAMAGE.
33 1.1 chris */
34 1.4 chris
35 1.4 chris #include <sys/cdefs.h>
36 1.17 skrll __KERNEL_RCSID(0, "$NetBSD: isadma_machdep.c,v 1.17 2022/09/27 06:36:41 skrll Exp $");
37 1.1 chris
38 1.1 chris #include <sys/param.h>
39 1.1 chris #include <sys/systm.h>
40 1.1 chris #include <sys/syslog.h>
41 1.1 chris #include <sys/device.h>
42 1.1 chris #include <sys/proc.h>
43 1.1 chris #include <sys/mbuf.h>
44 1.1 chris
45 1.1 chris #define _ARM32_BUS_DMA_PRIVATE
46 1.14 dyoung #include <sys/bus.h>
47 1.1 chris
48 1.1 chris #include <dev/isa/isareg.h>
49 1.1 chris #include <dev/isa/isavar.h>
50 1.1 chris
51 1.1 chris #include <uvm/uvm_extern.h>
52 1.1 chris
53 1.1 chris /*
54 1.1 chris * ISA has a 24-bit address limitation, so at most it has a 16M
55 1.1 chris * DMA range. However, some platforms have a more limited range,
56 1.1 chris * e.g. the Shark NC. On these systems, we are provided with
57 1.1 chris * a set of DMA ranges. The pmap module is aware of these ranges
58 1.1 chris * and places DMA-safe memory for them onto an alternate free list
59 1.1 chris * so that they are protected from being used to service page faults,
60 1.1 chris * etc. (unless we've run out of memory elsewhere).
61 1.1 chris */
62 1.1 chris #define ISA_DMA_BOUNCE_THRESHOLD (16 * 1024 * 1024)
63 1.2 thorpej
64 1.2 thorpej struct arm32_dma_range *footbridge_isa_dma_ranges;
65 1.2 thorpej int footbridge_isa_dma_nranges;
66 1.1 chris
67 1.1 chris /*
68 1.1 chris * Entry points for ISA DMA. These are mostly wrappers around
69 1.1 chris * the generic functions that understand how to deal with bounce
70 1.1 chris * buffers, if necessary.
71 1.1 chris */
72 1.1 chris struct arm32_bus_dma_tag isa_bus_dma_tag = {
73 1.16 matt _BUS_DMAMAP_FUNCS,
74 1.16 matt _BUS_DMAMEM_FUNCS,
75 1.16 matt _BUS_DMATAG_FUNCS,
76 1.1 chris };
77 1.1 chris
78 1.1 chris /*
79 1.1 chris * Initialize ISA DMA.
80 1.1 chris */
81 1.1 chris void
82 1.13 cegger isa_dma_init(void)
83 1.1 chris {
84 1.1 chris
85 1.2 thorpej isa_bus_dma_tag._ranges = footbridge_isa_dma_ranges;
86 1.2 thorpej isa_bus_dma_tag._nranges = footbridge_isa_dma_nranges;
87 1.1 chris }
88