cbus_dma.c (131817) | cbus_dma.c (135262) |
---|---|
1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 16 unchanged lines hidden (view full) --- 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: @(#)isa.c 7.2 (Berkeley) 5/13/91 | 1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 16 unchanged lines hidden (view full) --- 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: @(#)isa.c 7.2 (Berkeley) 5/13/91 |
33 * $FreeBSD: head/sys/pc98/cbus/cbus_dma.c 131817 2004-07-08 13:48:49Z nyan $ | 33 * $FreeBSD: head/sys/pc98/cbus/cbus_dma.c 135262 2004-09-15 12:09:50Z phk $ |
34 */ 35 36/* 37 * code to manage AT bus 38 * 39 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com): 40 * Fixed uninitialized variable problem and added code to deal 41 * with DMA page boundaries in isa_dmarangecheck(). Fixed word --- 76 unchanged lines hidden (view full) --- 118static int dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 }; 119#else 120static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 121#endif 122 123/* 124 * Setup a DMA channel's bounce buffer. 125 */ | 34 */ 35 36/* 37 * code to manage AT bus 38 * 39 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com): 40 * Fixed uninitialized variable problem and added code to deal 41 * with DMA page boundaries in isa_dmarangecheck(). Fixed word --- 76 unchanged lines hidden (view full) --- 118static int dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 }; 119#else 120static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 121#endif 122 123/* 124 * Setup a DMA channel's bounce buffer. 125 */ |
126void 127isa_dmainit(chan, bouncebufsize) 128 int chan; 129 u_int bouncebufsize; | 126int 127isa_dma_init(int chan, u_int bouncebufsize, int flag) |
130{ 131 void *buf; 132 133#ifndef PC98 134 /* | 128{ 129 void *buf; 130 131#ifndef PC98 132 /* |
135 * If a DMA channel is shared, both drivers have to call isa_dmainit | 133 * If a DMA channel is shared, both drivers have to call isa_dma_init |
136 * since they don't know that the other driver will do it. 137 * Just return if we're already set up good. 138 * XXX: this only works if they agree on the bouncebuf size. This 139 * XXX: is typically the case since they are multiple instances of 140 * XXX: the same driver. 141 */ 142 if (dma_bouncebuf[chan] != NULL) | 134 * since they don't know that the other driver will do it. 135 * Just return if we're already set up good. 136 * XXX: this only works if they agree on the bouncebuf size. This 137 * XXX: is typically the case since they are multiple instances of 138 * XXX: the same driver. 139 */ 140 if (dma_bouncebuf[chan] != NULL) |
143 return; | 141 return (0); |
144#endif 145 146#ifdef DIAGNOSTIC 147 if (chan & ~VALID_DMA_MASK) | 142#endif 143 144#ifdef DIAGNOSTIC 145 if (chan & ~VALID_DMA_MASK) |
148 panic("isa_dmainit: channel out of range"); | 146 panic("isa_dma_init: channel out of range"); |
149#ifdef PC98 150 if (dma_bouncebuf[chan] != NULL) | 147#ifdef PC98 148 if (dma_bouncebuf[chan] != NULL) |
151 panic("isa_dmainit: impossible request"); | 149 panic("isa_dma_init: impossible request"); |
152#endif 153#endif 154 155 dma_bouncebufsize[chan] = bouncebufsize; 156 157 /* Try malloc() first. It works better if it works. */ | 150#endif 151#endif 152 153 dma_bouncebufsize[chan] = bouncebufsize; 154 155 /* Try malloc() first. It works better if it works. */ |
158 buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT); | 156 buf = malloc(bouncebufsize, M_DEVBUF, flag); |
159 if (buf != NULL) { 160 if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { 161 dma_bouncebuf[chan] = buf; | 157 if (buf != NULL) { 158 if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { 159 dma_bouncebuf[chan] = buf; |
162 return; | 160 return (0); |
163 } 164 free(buf, M_DEVBUF); 165 } | 161 } 162 free(buf, M_DEVBUF); 163 } |
166 buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful, | 164 buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful, |
167 1ul, chan & 4 ? 0x20000ul : 0x10000ul); 168 if (buf == NULL) | 165 1ul, chan & 4 ? 0x20000ul : 0x10000ul); 166 if (buf == NULL) |
169 printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize); 170 else 171 dma_bouncebuf[chan] = buf; | 167 return (ENOMEM); 168 dma_bouncebuf[chan] = buf; 169 return (0); |
172} 173 174/* 175 * Register a DMA channel's usage. Usually called from a device driver 176 * in open() or during its initialization. 177 */ 178int 179isa_dma_acquire(chan) --- 456 unchanged lines hidden --- | 170} 171 172/* 173 * Register a DMA channel's usage. Usually called from a device driver 174 * in open() or during its initialization. 175 */ 176int 177isa_dma_acquire(chan) --- 456 unchanged lines hidden --- |