Deleted Added
full compact
isa_dma.c (79008) isa_dma.c (79224)
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

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * 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

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)isa.c 7.2 (Berkeley) 5/13/91
37 * $FreeBSD: head/sys/i386/isa/isa_dma.c 79008 2001-06-30 05:29:11Z imp $
37 * $FreeBSD: head/sys/i386/isa/isa_dma.c 79224 2001-07-04 16:20:28Z dillon $
38 */
39
40/*
41 * code to manage AT bus
42 *
43 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
44 * Fixed uninitialized variable problem and added code to deal
45 * with DMA page boundaries in isa_dmarangecheck(). Fixed word
46 * mode DMA count compution and reorganized DMA setup code in
47 * isa_dmastart()
48 */
49
50#include <sys/param.h>
51#include <sys/systm.h>
52#include <sys/bus.h>
53#include <sys/kernel.h>
54#include <sys/malloc.h>
55#include <sys/lock.h>
38 */
39
40/*
41 * code to manage AT bus
42 *
43 * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
44 * Fixed uninitialized variable problem and added code to deal
45 * with DMA page boundaries in isa_dmarangecheck(). Fixed word
46 * mode DMA count compution and reorganized DMA setup code in
47 * isa_dmastart()
48 */
49
50#include <sys/param.h>
51#include <sys/systm.h>
52#include <sys/bus.h>
53#include <sys/kernel.h>
54#include <sys/malloc.h>
55#include <sys/lock.h>
56#include <sys/proc.h>
56#include <sys/mutex.h>
57#include <sys/module.h>
58#include <vm/vm.h>
59#include <vm/vm_param.h>
60#include <vm/pmap.h>
61#include <i386/isa/isa.h>
62#include <dev/ic/i8237.h>
63#include <isa/isavar.h>

--- 147 unchanged lines hidden (view full) ---

211 */
212void
213isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
214{
215 vm_offset_t phys;
216 int waport;
217 caddr_t newaddr;
218
57#include <sys/mutex.h>
58#include <sys/module.h>
59#include <vm/vm.h>
60#include <vm/vm_param.h>
61#include <vm/pmap.h>
62#include <i386/isa/isa.h>
63#include <dev/ic/i8237.h>
64#include <isa/isavar.h>

--- 147 unchanged lines hidden (view full) ---

212 */
213void
214isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
215{
216 vm_offset_t phys;
217 int waport;
218 caddr_t newaddr;
219
220 GIANT_REQUIRED;
221
219#ifdef DIAGNOSTIC
220 if (chan & ~VALID_DMA_MASK)
221 panic("isa_dmastart: channel out of range");
222
223 if ((chan < 4 && nbytes > (1<<16))
224 || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
225 panic("isa_dmastart: impossible request");
226

--- 22 unchanged lines hidden (view full) ---

249
250 /* copy bounce buffer on write */
251 if (!(flags & ISADMA_READ))
252 bcopy(addr, newaddr, nbytes);
253 addr = newaddr;
254 }
255
256 /* translate to physical */
222#ifdef DIAGNOSTIC
223 if (chan & ~VALID_DMA_MASK)
224 panic("isa_dmastart: channel out of range");
225
226 if ((chan < 4 && nbytes > (1<<16))
227 || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
228 panic("isa_dmastart: impossible request");
229

--- 22 unchanged lines hidden (view full) ---

252
253 /* copy bounce buffer on write */
254 if (!(flags & ISADMA_READ))
255 bcopy(addr, newaddr, nbytes);
256 addr = newaddr;
257 }
258
259 /* translate to physical */
257 mtx_lock(&vm_mtx); /*
258 * XXX: need to hold for longer period to
259 * ensure that mappings don't change
260 */
261 phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
260 phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
262 mtx_unlock(&vm_mtx);
263
264 if (flags & ISADMA_RAW) {
265 dma_auto_mode |= (1 << chan);
266 } else {
267 dma_auto_mode &= ~(1 << chan);
268 }
269
270 if ((chan & 4) == 0) {

--- 102 unchanged lines hidden (view full) ---

373 */
374
375static int
376isa_dmarangecheck(caddr_t va, u_int length, int chan)
377{
378 vm_offset_t phys, priorpage = 0, endva;
379 u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
380
261
262 if (flags & ISADMA_RAW) {
263 dma_auto_mode |= (1 << chan);
264 } else {
265 dma_auto_mode &= ~(1 << chan);
266 }
267
268 if ((chan & 4) == 0) {

--- 102 unchanged lines hidden (view full) ---

371 */
372
373static int
374isa_dmarangecheck(caddr_t va, u_int length, int chan)
375{
376 vm_offset_t phys, priorpage = 0, endva;
377 u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
378
379 GIANT_REQUIRED;
380
381 endva = (vm_offset_t)round_page((vm_offset_t)va + length);
382 for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
381 endva = (vm_offset_t)round_page((vm_offset_t)va + length);
382 for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
383 mtx_lock(&vm_mtx);
384 phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
383 phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
385 mtx_unlock(&vm_mtx);
386#define ISARAM_END RAM_END
387 if (phys == 0)
388 panic("isa_dmacheck: no physical page present");
389 if (phys >= ISARAM_END)
390 return (1);
391 if (priorpage) {
392 if (priorpage + PAGE_SIZE != phys)
393 return (1);

--- 160 unchanged lines hidden ---
384#define ISARAM_END RAM_END
385 if (phys == 0)
386 panic("isa_dmacheck: no physical page present");
387 if (phys >= ISARAM_END)
388 return (1);
389 if (priorpage) {
390 if (priorpage + PAGE_SIZE != phys)
391 return (1);

--- 160 unchanged lines hidden ---