isa_dma.c (131647) | isa_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 --- 19 unchanged lines hidden (view full) --- 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 */ 34 35#include <sys/cdefs.h> | 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 --- 19 unchanged lines hidden (view full) --- 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 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/i386/isa/isa_dma.c 131647 2004-07-05 20:37:42Z phk $"); | 36__FBSDID("$FreeBSD: head/sys/i386/isa/isa_dma.c 135262 2004-09-15 12:09:50Z phk $"); |
37 38/* 39 * code to manage AT bus 40 * 41 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com): 42 * Fixed uninitialized variable problem and added code to deal 43 * with DMA page boundaries in isa_dmarangecheck(). Fixed word 44 * mode DMA count compution and reorganized DMA setup code in --- 44 unchanged lines hidden (view full) --- 89#define VALID_DMA_MASK (7) 90 91/* high byte of address is stored in this port for i-th dma channel */ 92static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 93 94/* 95 * Setup a DMA channel's bounce buffer. 96 */ | 37 38/* 39 * code to manage AT bus 40 * 41 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com): 42 * Fixed uninitialized variable problem and added code to deal 43 * with DMA page boundaries in isa_dmarangecheck(). Fixed word 44 * mode DMA count compution and reorganized DMA setup code in --- 44 unchanged lines hidden (view full) --- 89#define VALID_DMA_MASK (7) 90 91/* high byte of address is stored in this port for i-th dma channel */ 92static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 93 94/* 95 * Setup a DMA channel's bounce buffer. 96 */ |
97void 98isa_dmainit(chan, bouncebufsize) 99 int chan; 100 u_int bouncebufsize; | 97int 98isa_dma_init(int chan, u_int bouncebufsize, int flag) |
101{ 102 void *buf; 103 104 /* | 99{ 100 void *buf; 101 102 /* |
105 * If a DMA channel is shared, both drivers have to call isa_dmainit | 103 * If a DMA channel is shared, both drivers have to call isa_dma_init |
106 * since they don't know that the other driver will do it. 107 * Just return if we're already set up good. 108 * XXX: this only works if they agree on the bouncebuf size. This 109 * XXX: is typically the case since they are multiple instances of 110 * XXX: the same driver. 111 */ 112 if (dma_bouncebuf[chan] != NULL) | 104 * since they don't know that the other driver will do it. 105 * Just return if we're already set up good. 106 * XXX: this only works if they agree on the bouncebuf size. This 107 * XXX: is typically the case since they are multiple instances of 108 * XXX: the same driver. 109 */ 110 if (dma_bouncebuf[chan] != NULL) |
113 return; | 111 return (0); |
114 115#ifdef DIAGNOSTIC 116 if (chan & ~VALID_DMA_MASK) | 112 113#ifdef DIAGNOSTIC 114 if (chan & ~VALID_DMA_MASK) |
117 panic("isa_dmainit: channel out of range"); | 115 panic("isa_dma_init: channel out of range"); |
118#endif 119 120 dma_bouncebufsize[chan] = bouncebufsize; 121 122 /* Try malloc() first. It works better if it works. */ | 116#endif 117 118 dma_bouncebufsize[chan] = bouncebufsize; 119 120 /* Try malloc() first. It works better if it works. */ |
123 buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT); | 121 buf = malloc(bouncebufsize, M_DEVBUF, flag); |
124 if (buf != NULL) { 125 if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { 126 dma_bouncebuf[chan] = buf; | 122 if (buf != NULL) { 123 if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { 124 dma_bouncebuf[chan] = buf; |
127 return; | 125 return (0); |
128 } 129 free(buf, M_DEVBUF); 130 } | 126 } 127 free(buf, M_DEVBUF); 128 } |
131 buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful, | 129 buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful, |
132 1ul, chan & 4 ? 0x20000ul : 0x10000ul); 133 if (buf == NULL) | 130 1ul, chan & 4 ? 0x20000ul : 0x10000ul); 131 if (buf == NULL) |
134 printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize); 135 else 136 dma_bouncebuf[chan] = buf; | 132 return (ENOMEM); 133 dma_bouncebuf[chan] = buf; 134 return (0); |
137} 138 139/* 140 * Register a DMA channel's usage. Usually called from a device driver 141 * in open() or during its initialization. 142 */ 143int 144isa_dma_acquire(chan) --- 415 unchanged lines hidden --- | 135} 136 137/* 138 * Register a DMA channel's usage. Usually called from a device driver 139 * in open() or during its initialization. 140 */ 141int 142isa_dma_acquire(chan) --- 415 unchanged lines hidden --- |