isa_dma.c (146214) | isa_dma.c (199104) |
---|---|
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 146214 2005-05-14 10:14:56Z nyan $"); | 36__FBSDID("$FreeBSD: head/sys/i386/isa/isa_dma.c 199104 2009-11-09 20:29:10Z rdivacky $"); |
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 --- 19 unchanged lines hidden (view full) --- 64static int isa_dmarangecheck(caddr_t va, u_int length, int chan); 65 66static caddr_t dma_bouncebuf[8]; 67static u_int dma_bouncebufsize[8]; 68static u_int8_t dma_bounced = 0; 69static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */ 70static u_int8_t dma_inuse = 0; /* User for acquire/release */ 71static u_int8_t dma_auto_mode = 0; | 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 --- 19 unchanged lines hidden (view full) --- 64static int isa_dmarangecheck(caddr_t va, u_int length, int chan); 65 66static caddr_t dma_bouncebuf[8]; 67static u_int dma_bouncebufsize[8]; 68static u_int8_t dma_bounced = 0; 69static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */ 70static u_int8_t dma_inuse = 0; /* User for acquire/release */ 71static u_int8_t dma_auto_mode = 0; |
72static struct mtx isa_dma_lock; 73MTX_SYSINIT(isa_dma_lock, &isa_dma_lock, "isa DMA lock", MTX_DEF); |
|
72 73#define VALID_DMA_MASK (7) 74 75/* high byte of address is stored in this port for i-th dma channel */ 76static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 77 78/* 79 * Setup a DMA channel's bounce buffer. 80 */ 81int 82isa_dma_init(int chan, u_int bouncebufsize, int flag) 83{ 84 void *buf; | 74 75#define VALID_DMA_MASK (7) 76 77/* high byte of address is stored in this port for i-th dma channel */ 78static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; 79 80/* 81 * Setup a DMA channel's bounce buffer. 82 */ 83int 84isa_dma_init(int chan, u_int bouncebufsize, int flag) 85{ 86 void *buf; |
87 int contig; |
|
85 | 88 |
86 /* 87 * If a DMA channel is shared, both drivers have to call isa_dma_init 88 * since they don't know that the other driver will do it. 89 * Just return if we're already set up good. 90 * XXX: this only works if they agree on the bouncebuf size. This 91 * XXX: is typically the case since they are multiple instances of 92 * XXX: the same driver. 93 */ 94 if (dma_bouncebuf[chan] != NULL) 95 return (0); 96 | |
97#ifdef DIAGNOSTIC 98 if (chan & ~VALID_DMA_MASK) 99 panic("isa_dma_init: channel out of range"); 100#endif 101 | 89#ifdef DIAGNOSTIC 90 if (chan & ~VALID_DMA_MASK) 91 panic("isa_dma_init: channel out of range"); 92#endif 93 |
102 dma_bouncebufsize[chan] = bouncebufsize; | |
103 104 /* Try malloc() first. It works better if it works. */ 105 buf = malloc(bouncebufsize, M_DEVBUF, flag); 106 if (buf != NULL) { | 94 95 /* Try malloc() first. It works better if it works. */ 96 buf = malloc(bouncebufsize, M_DEVBUF, flag); 97 if (buf != NULL) { |
107 if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { 108 dma_bouncebuf[chan] = buf; 109 return (0); | 98 if (isa_dmarangecheck(buf, bouncebufsize, chan) != 0) { 99 free(buf, M_DEVBUF); 100 buf = NULL; |
110 } | 101 } |
111 free(buf, M_DEVBUF); | 102 contig = 0; |
112 } | 103 } |
113 buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful, | 104 105 if (buf == NULL) { 106 buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful, |
114 1ul, chan & 4 ? 0x20000ul : 0x10000ul); | 107 1ul, chan & 4 ? 0x20000ul : 0x10000ul); |
108 contig = 1; 109 } 110 |
|
115 if (buf == NULL) 116 return (ENOMEM); | 111 if (buf == NULL) 112 return (ENOMEM); |
113 114 mtx_lock(&isa_dma_lock); 115 /* 116 * If a DMA channel is shared, both drivers have to call isa_dma_init 117 * since they don't know that the other driver will do it. 118 * Just return if we're already set up good. 119 * XXX: this only works if they agree on the bouncebuf size. This 120 * XXX: is typically the case since they are multiple instances of 121 * XXX: the same driver. 122 */ 123 if (dma_bouncebuf[chan] != NULL) { 124 if (contig) 125 contigfree(buf, bouncebufsize, M_DEVBUF); 126 else 127 free(buf, M_DEVBUF); 128 mtx_unlock(&isa_dma_lock); 129 return (0); 130 } 131 132 dma_bouncebufsize[chan] = bouncebufsize; |
|
117 dma_bouncebuf[chan] = buf; | 133 dma_bouncebuf[chan] = buf; |
134 135 mtx_unlock(&isa_dma_lock); 136 |
|
118 return (0); 119} 120 121/* 122 * Register a DMA channel's usage. Usually called from a device driver 123 * in open() or during its initialization. 124 */ 125int 126isa_dma_acquire(chan) 127 int chan; 128{ 129#ifdef DIAGNOSTIC 130 if (chan & ~VALID_DMA_MASK) 131 panic("isa_dma_acquire: channel out of range"); 132#endif 133 | 137 return (0); 138} 139 140/* 141 * Register a DMA channel's usage. Usually called from a device driver 142 * in open() or during its initialization. 143 */ 144int 145isa_dma_acquire(chan) 146 int chan; 147{ 148#ifdef DIAGNOSTIC 149 if (chan & ~VALID_DMA_MASK) 150 panic("isa_dma_acquire: channel out of range"); 151#endif 152 |
153 mtx_lock(&isa_dma_lock); |
|
134 if (dma_inuse & (1 << chan)) { 135 printf("isa_dma_acquire: channel %d already in use\n", chan); | 154 if (dma_inuse & (1 << chan)) { 155 printf("isa_dma_acquire: channel %d already in use\n", chan); |
156 mtx_unlock(&isa_dma_lock); |
|
136 return (EBUSY); 137 } 138 dma_inuse |= (1 << chan); 139 dma_auto_mode &= ~(1 << chan); | 157 return (EBUSY); 158 } 159 dma_inuse |= (1 << chan); 160 dma_auto_mode &= ~(1 << chan); |
161 mtx_unlock(&isa_dma_lock); |
|
140 141 return (0); 142} 143 144/* 145 * Unregister a DMA channel's usage. Usually called from a device driver 146 * during close() or during its shutdown. 147 */ 148void 149isa_dma_release(chan) 150 int chan; 151{ 152#ifdef DIAGNOSTIC 153 if (chan & ~VALID_DMA_MASK) 154 panic("isa_dma_release: channel out of range"); 155 | 162 163 return (0); 164} 165 166/* 167 * Unregister a DMA channel's usage. Usually called from a device driver 168 * during close() or during its shutdown. 169 */ 170void 171isa_dma_release(chan) 172 int chan; 173{ 174#ifdef DIAGNOSTIC 175 if (chan & ~VALID_DMA_MASK) 176 panic("isa_dma_release: channel out of range"); 177 |
178 mtx_lock(&isa_dma_lock); |
|
156 if ((dma_inuse & (1 << chan)) == 0) 157 printf("isa_dma_release: channel %d not in use\n", chan); | 179 if ((dma_inuse & (1 << chan)) == 0) 180 printf("isa_dma_release: channel %d not in use\n", chan); |
181#else 182 mtx_lock(&isa_dma_lock); |
|
158#endif 159 160 if (dma_busy & (1 << chan)) { 161 dma_busy &= ~(1 << chan); 162 /* 163 * XXX We should also do "dma_bounced &= (1 << chan);" 164 * because we are acting on behalf of isa_dmadone() which 165 * was not called to end the last DMA operation. This does 166 * not matter now, but it may in the future. 167 */ 168 } 169 170 dma_inuse &= ~(1 << chan); 171 dma_auto_mode &= ~(1 << chan); | 183#endif 184 185 if (dma_busy & (1 << chan)) { 186 dma_busy &= ~(1 << chan); 187 /* 188 * XXX We should also do "dma_bounced &= (1 << chan);" 189 * because we are acting on behalf of isa_dmadone() which 190 * was not called to end the last DMA operation. This does 191 * not matter now, but it may in the future. 192 */ 193 } 194 195 dma_inuse &= ~(1 << chan); 196 dma_auto_mode &= ~(1 << chan); |
197 198 mtx_unlock(&isa_dma_lock); |
|
172} 173 174/* 175 * isa_dmacascade(): program 8237 DMA controller channel to accept 176 * external dma control by a board. 177 */ 178void 179isa_dmacascade(chan) 180 int chan; 181{ 182#ifdef DIAGNOSTIC 183 if (chan & ~VALID_DMA_MASK) 184 panic("isa_dmacascade: channel out of range"); 185#endif 186 | 199} 200 201/* 202 * isa_dmacascade(): program 8237 DMA controller channel to accept 203 * external dma control by a board. 204 */ 205void 206isa_dmacascade(chan) 207 int chan; 208{ 209#ifdef DIAGNOSTIC 210 if (chan & ~VALID_DMA_MASK) 211 panic("isa_dmacascade: channel out of range"); 212#endif 213 |
214 mtx_lock(&isa_dma_lock); |
|
187 /* set dma channel mode, and set dma channel mode */ 188 if ((chan & 4) == 0) { 189 outb(DMA1_MODE, DMA37MD_CASCADE | chan); 190 outb(DMA1_SMSK, chan); 191 } else { 192 outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3)); 193 outb(DMA2_SMSK, chan & 3); 194 } | 215 /* set dma channel mode, and set dma channel mode */ 216 if ((chan & 4) == 0) { 217 outb(DMA1_MODE, DMA37MD_CASCADE | chan); 218 outb(DMA1_SMSK, chan); 219 } else { 220 outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3)); 221 outb(DMA2_SMSK, chan & 3); 222 } |
223 mtx_unlock(&isa_dma_lock); |
|
195} 196 197/* 198 * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment 199 * problems by using a bounce buffer. 200 */ 201void 202isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan) 203{ 204 vm_paddr_t phys; 205 int waport; 206 caddr_t newaddr; | 224} 225 226/* 227 * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment 228 * problems by using a bounce buffer. 229 */ 230void 231isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan) 232{ 233 vm_paddr_t phys; 234 int waport; 235 caddr_t newaddr; |
236 int dma_range_checked; |
|
207 | 237 |
208 GIANT_REQUIRED; | 238 /* translate to physical */ 239 phys = pmap_extract(kernel_pmap, (vm_offset_t)addr); 240 dma_range_checked = isa_dmarangecheck(addr, nbytes, chan); |
209 210#ifdef DIAGNOSTIC 211 if (chan & ~VALID_DMA_MASK) 212 panic("isa_dmastart: channel out of range"); 213 214 if ((chan < 4 && nbytes > (1<<16)) 215 || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1))) 216 panic("isa_dmastart: impossible request"); 217 | 241 242#ifdef DIAGNOSTIC 243 if (chan & ~VALID_DMA_MASK) 244 panic("isa_dmastart: channel out of range"); 245 246 if ((chan < 4 && nbytes > (1<<16)) 247 || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1))) 248 panic("isa_dmastart: impossible request"); 249 |
250 mtx_lock(&isa_dma_lock); |
|
218 if ((dma_inuse & (1 << chan)) == 0) 219 printf("isa_dmastart: channel %d not acquired\n", chan); | 251 if ((dma_inuse & (1 << chan)) == 0) 252 printf("isa_dmastart: channel %d not acquired\n", chan); |
253#else 254 mtx_lock(&isa_dma_lock); |
|
220#endif 221 222#if 0 223 /* 224 * XXX This should be checked, but drivers like ad1848 only call 225 * isa_dmastart() once because they use Auto DMA mode. If we 226 * leave this in, drivers that do this will print this continuously. 227 */ 228 if (dma_busy & (1 << chan)) 229 printf("isa_dmastart: channel %d busy\n", chan); 230#endif 231 232 dma_busy |= (1 << chan); 233 | 255#endif 256 257#if 0 258 /* 259 * XXX This should be checked, but drivers like ad1848 only call 260 * isa_dmastart() once because they use Auto DMA mode. If we 261 * leave this in, drivers that do this will print this continuously. 262 */ 263 if (dma_busy & (1 << chan)) 264 printf("isa_dmastart: channel %d busy\n", chan); 265#endif 266 267 dma_busy |= (1 << chan); 268 |
234 if (isa_dmarangecheck(addr, nbytes, chan)) { | 269 if (dma_range_checked) { |
235 if (dma_bouncebuf[chan] == NULL 236 || dma_bouncebufsize[chan] < nbytes) 237 panic("isa_dmastart: bad bounce buffer"); 238 dma_bounced |= (1 << chan); 239 newaddr = dma_bouncebuf[chan]; 240 241 /* copy bounce buffer on write */ 242 if (!(flags & ISADMA_READ)) 243 bcopy(addr, newaddr, nbytes); 244 addr = newaddr; 245 } 246 | 270 if (dma_bouncebuf[chan] == NULL 271 || dma_bouncebufsize[chan] < nbytes) 272 panic("isa_dmastart: bad bounce buffer"); 273 dma_bounced |= (1 << chan); 274 newaddr = dma_bouncebuf[chan]; 275 276 /* copy bounce buffer on write */ 277 if (!(flags & ISADMA_READ)) 278 bcopy(addr, newaddr, nbytes); 279 addr = newaddr; 280 } 281 |
247 /* translate to physical */ 248 phys = pmap_extract(kernel_pmap, (vm_offset_t)addr); 249 | |
250 if (flags & ISADMA_RAW) { 251 dma_auto_mode |= (1 << chan); 252 } else { 253 dma_auto_mode &= ~(1 << chan); 254 } 255 256 if ((chan & 4) == 0) { 257 /* --- 58 unchanged lines hidden (view full) --- 316 /* send count */ 317 nbytes >>= 1; 318 outb(waport + 2, --nbytes); 319 outb(waport + 2, nbytes>>8); 320 321 /* unmask channel */ 322 outb(DMA2_SMSK, chan & 3); 323 } | 282 if (flags & ISADMA_RAW) { 283 dma_auto_mode |= (1 << chan); 284 } else { 285 dma_auto_mode &= ~(1 << chan); 286 } 287 288 if ((chan & 4) == 0) { 289 /* --- 58 unchanged lines hidden (view full) --- 348 /* send count */ 349 nbytes >>= 1; 350 outb(waport + 2, --nbytes); 351 outb(waport + 2, nbytes>>8); 352 353 /* unmask channel */ 354 outb(DMA2_SMSK, chan & 3); 355 } |
356 mtx_unlock(&isa_dma_lock); |
|
324} 325 326void 327isa_dmadone(int flags, caddr_t addr, int nbytes, int chan) 328{ 329#ifdef DIAGNOSTIC 330 if (chan & ~VALID_DMA_MASK) 331 panic("isa_dmadone: channel out of range"); 332 333 if ((dma_inuse & (1 << chan)) == 0) 334 printf("isa_dmadone: channel %d not acquired\n", chan); 335#endif 336 | 357} 358 359void 360isa_dmadone(int flags, caddr_t addr, int nbytes, int chan) 361{ 362#ifdef DIAGNOSTIC 363 if (chan & ~VALID_DMA_MASK) 364 panic("isa_dmadone: channel out of range"); 365 366 if ((dma_inuse & (1 << chan)) == 0) 367 printf("isa_dmadone: channel %d not acquired\n", chan); 368#endif 369 |
370 mtx_lock(&isa_dma_lock); |
|
337 if (((dma_busy & (1 << chan)) == 0) && 338 (dma_auto_mode & (1 << chan)) == 0 ) 339 printf("isa_dmadone: channel %d not busy\n", chan); 340 341 if ((dma_auto_mode & (1 << chan)) == 0) 342 outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4); 343 344 if (dma_bounced & (1 << chan)) { 345 /* copy bounce buffer on read */ 346 if (flags & ISADMA_READ) 347 bcopy(dma_bouncebuf[chan], addr, nbytes); 348 349 dma_bounced &= ~(1 << chan); 350 } 351 dma_busy &= ~(1 << chan); | 371 if (((dma_busy & (1 << chan)) == 0) && 372 (dma_auto_mode & (1 << chan)) == 0 ) 373 printf("isa_dmadone: channel %d not busy\n", chan); 374 375 if ((dma_auto_mode & (1 << chan)) == 0) 376 outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4); 377 378 if (dma_bounced & (1 << chan)) { 379 /* copy bounce buffer on read */ 380 if (flags & ISADMA_READ) 381 bcopy(dma_bouncebuf[chan], addr, nbytes); 382 383 dma_bounced &= ~(1 << chan); 384 } 385 dma_busy &= ~(1 << chan); |
386 mtx_unlock(&isa_dma_lock); |
|
352} 353 354/* 355 * Check for problems with the address range of a DMA transfer 356 * (non-contiguous physical pages, outside of bus address space, 357 * crossing DMA page boundaries). 358 * Return true if special handling needed. 359 */ 360 361static int 362isa_dmarangecheck(caddr_t va, u_int length, int chan) 363{ 364 vm_paddr_t phys, priorpage = 0; 365 vm_offset_t endva; 366 u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1); 367 | 387} 388 389/* 390 * Check for problems with the address range of a DMA transfer 391 * (non-contiguous physical pages, outside of bus address space, 392 * crossing DMA page boundaries). 393 * Return true if special handling needed. 394 */ 395 396static int 397isa_dmarangecheck(caddr_t va, u_int length, int chan) 398{ 399 vm_paddr_t phys, priorpage = 0; 400 vm_offset_t endva; 401 u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1); 402 |
368 GIANT_REQUIRED; 369 | |
370 endva = (vm_offset_t)round_page((vm_offset_t)va + length); 371 for (; va < (caddr_t) endva ; va += PAGE_SIZE) { 372 phys = trunc_page(pmap_extract(kernel_pmap, (vm_offset_t)va)); 373#define ISARAM_END RAM_END 374 if (phys == 0) 375 panic("isa_dmacheck: no physical page present"); 376 if (phys >= ISARAM_END) 377 return (1); --- 36 unchanged lines hidden (view full) --- 414 * corresponding pair. 415 * 416 * In any other case, low1 and high1 can be considered to be correct. 417 * 418 * The function returns the number of bytes remaining in the transfer, 419 * or -1 if the channel requested is not active. 420 * 421 */ | 403 endva = (vm_offset_t)round_page((vm_offset_t)va + length); 404 for (; va < (caddr_t) endva ; va += PAGE_SIZE) { 405 phys = trunc_page(pmap_extract(kernel_pmap, (vm_offset_t)va)); 406#define ISARAM_END RAM_END 407 if (phys == 0) 408 panic("isa_dmacheck: no physical page present"); 409 if (phys >= ISARAM_END) 410 return (1); --- 36 unchanged lines hidden (view full) --- 447 * corresponding pair. 448 * 449 * In any other case, low1 and high1 can be considered to be correct. 450 * 451 * The function returns the number of bytes remaining in the transfer, 452 * or -1 if the channel requested is not active. 453 * 454 */ |
422int 423isa_dmastatus(int chan) | 455static int 456isa_dmastatus_locked(int chan) |
424{ 425 u_long cnt = 0; 426 int ffport, waport; 427 u_long low1, high1, low2, high2; 428 | 457{ 458 u_long cnt = 0; 459 int ffport, waport; 460 u_long low1, high1, low2, high2; 461 |
462 mtx_assert(&isa_dma_lock, MA_OWNED); 463 |
|
429 /* channel active? */ 430 if ((dma_inuse & (1 << chan)) == 0) { 431 printf("isa_dmastatus: channel %d not active\n", chan); 432 return(-1); 433 } 434 /* channel busy? */ 435 436 if (((dma_busy & (1 << chan)) == 0) && --- 29 unchanged lines hidden (view full) --- 466 cnt = (low2 + (high2 << 8) + 1) & 0xffff; 467 } 468 469 if (chan >= 4) /* high channels move words */ 470 cnt *= 2; 471 return(cnt); 472} 473 | 464 /* channel active? */ 465 if ((dma_inuse & (1 << chan)) == 0) { 466 printf("isa_dmastatus: channel %d not active\n", chan); 467 return(-1); 468 } 469 /* channel busy? */ 470 471 if (((dma_busy & (1 << chan)) == 0) && --- 29 unchanged lines hidden (view full) --- 501 cnt = (low2 + (high2 << 8) + 1) & 0xffff; 502 } 503 504 if (chan >= 4) /* high channels move words */ 505 cnt *= 2; 506 return(cnt); 507} 508 |
509int 510isa_dmastatus(int chan) 511{ 512 int status; 513 514 mtx_lock(&isa_dma_lock); 515 status = isa_dmastatus_locked(chan); 516 mtx_unlock(&isa_dma_lock); 517 518 return (status); 519} 520 |
|
474/* 475 * Reached terminal count yet ? 476 */ 477int 478isa_dmatc(int chan) 479{ 480 481 if (chan < 4) 482 return(inb(DMA1_STATUS) & (1 << chan)); 483 else 484 return(inb(DMA2_STATUS) & (1 << (chan & 3))); 485} 486 487/* 488 * Stop a DMA transfer currently in progress. 489 */ 490int 491isa_dmastop(int chan) 492{ | 521/* 522 * Reached terminal count yet ? 523 */ 524int 525isa_dmatc(int chan) 526{ 527 528 if (chan < 4) 529 return(inb(DMA1_STATUS) & (1 << chan)); 530 else 531 return(inb(DMA2_STATUS) & (1 << (chan & 3))); 532} 533 534/* 535 * Stop a DMA transfer currently in progress. 536 */ 537int 538isa_dmastop(int chan) 539{ |
540 int status; 541 542 mtx_lock(&isa_dma_lock); |
|
493 if ((dma_inuse & (1 << chan)) == 0) 494 printf("isa_dmastop: channel %d not acquired\n", chan); 495 496 if (((dma_busy & (1 << chan)) == 0) && 497 ((dma_auto_mode & (1 << chan)) == 0)) { 498 printf("chan %d not busy\n", chan); | 543 if ((dma_inuse & (1 << chan)) == 0) 544 printf("isa_dmastop: channel %d not acquired\n", chan); 545 546 if (((dma_busy & (1 << chan)) == 0) && 547 ((dma_auto_mode & (1 << chan)) == 0)) { 548 printf("chan %d not busy\n", chan); |
549 mtx_unlock(&isa_dma_lock); |
|
499 return -2 ; 500 } 501 502 if ((chan & 4) == 0) { 503 outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */); 504 } else { 505 outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */); 506 } | 550 return -2 ; 551 } 552 553 if ((chan & 4) == 0) { 554 outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */); 555 } else { 556 outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */); 557 } |
507 return(isa_dmastatus(chan)); | 558 559 status = isa_dmastatus_locked(chan); 560 561 mtx_unlock(&isa_dma_lock); 562 563 return (status); |
508} 509 510/* 511 * Attach to the ISA PnP descriptor for the AT DMA controller 512 */ 513static struct isa_pnp_id atdma_ids[] = { 514 { 0x0002d041 /* PNP0200 */, "AT DMA controller" }, 515 { 0 } --- 39 unchanged lines hidden --- | 564} 565 566/* 567 * Attach to the ISA PnP descriptor for the AT DMA controller 568 */ 569static struct isa_pnp_id atdma_ids[] = { 570 { 0x0002d041 /* PNP0200 */, "AT DMA controller" }, 571 { 0 } --- 39 unchanged lines hidden --- |