1 /* $NetBSD: isadma_machdep.c,v 1.16 2012/09/21 14:21:58 matt Exp $ */ 2 3 #define ISA_DMA_STATS 4 5 /*- 6 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to The NetBSD Foundation 10 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 11 * NASA Ames Research Center. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <sys/cdefs.h> 36 __KERNEL_RCSID(0, "$NetBSD: isadma_machdep.c,v 1.16 2012/09/21 14:21:58 matt Exp $"); 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 #define ISA_DMA_BOUNCE_THRESHOLD (16 * 1024 * 1024) 64 65 struct arm32_dma_range *footbridge_isa_dma_ranges; 66 int footbridge_isa_dma_nranges; 67 68 /* 69 * Entry points for ISA DMA. These are mostly wrappers around 70 * the generic functions that understand how to deal with bounce 71 * buffers, if necessary. 72 */ 73 struct arm32_bus_dma_tag isa_bus_dma_tag = { 74 _BUS_DMAMAP_FUNCS, 75 _BUS_DMAMEM_FUNCS, 76 _BUS_DMATAG_FUNCS, 77 }; 78 79 /* 80 * Initialize ISA DMA. 81 */ 82 void 83 isa_dma_init(void) 84 { 85 86 isa_bus_dma_tag._ranges = footbridge_isa_dma_ranges; 87 isa_bus_dma_tag._nranges = footbridge_isa_dma_nranges; 88 } 89