1 /* $NetBSD: isadma_machdep.c,v 1.18 2023/12/20 15:34:45 thorpej 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.18 2023/12/20 15:34:45 thorpej 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/proc.h> 43 #include <sys/mbuf.h> 44 45 #define _ARM32_BUS_DMA_PRIVATE 46 #include <sys/bus.h> 47 48 #include <dev/isa/isareg.h> 49 #include <dev/isa/isavar.h> 50 51 #include <uvm/uvm_extern.h> 52 53 /* 54 * ISA has a 24-bit address limitation, so at most it has a 16M 55 * DMA range. However, some platforms have a more limited range, 56 * e.g. the Shark NC. On these systems, we are provided with 57 * a set of DMA ranges. The pmap module is aware of these ranges 58 * and places DMA-safe memory for them onto an alternate free list 59 * so that they are protected from being used to service page faults, 60 * etc. (unless we've run out of memory elsewhere). 61 */ 62 extern struct arm32_dma_range *shark_isa_dma_ranges; 63 extern int shark_isa_dma_nranges; 64 65 /* 66 * Entry points for ISA DMA. These are mostly wrappers around 67 * the generic functions that understand how to deal with bounce 68 * buffers, if necessary. 69 */ 70 struct arm32_bus_dma_tag isa_bus_dma_tag = { 71 _BUS_DMAMAP_FUNCS, 72 _BUS_DMAMEM_FUNCS, 73 _BUS_DMATAG_FUNCS, 74 }; 75 76 /* 77 * Initialize ISA DMA. 78 */ 79 void 80 isa_dma_init(void) 81 { 82 83 isa_bus_dma_tag._ranges = shark_isa_dma_ranges; 84 isa_bus_dma_tag._nranges = shark_isa_dma_nranges; 85 } 86