From owner-freebsd-hackers Tue Mar 11 07:29:17 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA12102 for hackers-outgoing; Tue, 11 Mar 1997 07:29:17 -0800 (PST) Received: from bacall.lodgenet.com (bacall.lodgenet.com [205.138.147.242]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id HAA12077 for ; Tue, 11 Mar 1997 07:29:05 -0800 (PST) Received: (from mail@localhost) by bacall.lodgenet.com (8.6.12/8.6.12) id JAA09829; Tue, 11 Mar 1997 09:26:17 -0600 Received: from garbo.lodgenet.com(204.124.123.250) by bacall via smap (V1.3) id sma009821; Tue Mar 11 09:26:12 1997 Received: from jake.lodgenet.com (jake.lodgenet.com [10.0.11.30]) by garbo.lodgenet.com (8.6.12/8.6.9) with ESMTP id JAA13874; Tue, 11 Mar 1997 09:27:56 -0600 Received: from jake.lodgenet.com (localhost [127.0.0.1]) by jake.lodgenet.com (8.8.5/8.6.12) with ESMTP id JAA13632; Tue, 11 Mar 1997 09:28:37 -0600 (CST) Message-Id: <199703111528.JAA13632@jake.lodgenet.com> X-Mailer: exmh version 2.0beta 12/23/96 To: Emmanuel.Duros@sophia.inria.fr cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Pb using DMA - Physical addressing In-reply-to: Your message of "Tue, 11 Mar 1997 15:27:30 +0100." <199703111427.PAA05582@chouette.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 11 Mar 1997 09:28:37 -0600 From: "Eric L. Hernes" Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Emmanuel Duros writes: > >Hi, > >I am currently writing a device driver (isa bus) for a communication >card (satellite reception/emission cards) that uses DMA transfers. > >I have got a peace of code that works fine under DOS but as I insert it >into the freebsd device driver code nothing happens. > >I think the problem comes from the mapping of virtual addresses into >physical addresses (?). Unfortunately I have not found much >documentation on this... > >-------- FreeBSD [ a bunch of inb/outb code omitted ] isa_dma{_acquire,_release,start,done} are your friends, have a look at sys/i386/isa/isa.c basically, you just call isa_dma_acquire(chan) somewhere in your driver open. Then, make a call like isa_dmastart(B_WRITE, bufferp, count, channel); or isa_dmastart(B_READ, bufferp, count, channel); to start the transfer... then isa_dmadone(B_READ, bufferp, count, channel); to handle any bounce-buffer cases for the 16M isa limitation. bufferp is the kvm (kernel virtual) address of your buffer. You can do most, if not all, of your driver development without concern for virtual/physical mappings, iff you use the kernel support functions. Otherwise kvtop() will translate a kernel virt. to a physical address. >One last question, is it possible to develop in the user space >applications that would handle dma transfers ? In fact, I am a bit fed >up with rebooting my PC every time I recompile the kernel ! > I'm pretty sure that DMA from userspace isn't real easy. Drivers that are mostly inb/outb, are fairly simple from userspace. I've had limited success with the lkm stuff, then you can at least modload, and modunload your driver. It's a bit faster that rebooting, but you don't get a symbol table :( Depending on the complexity of the driver, I'll sometimes make an lkm to test chunks of the it, then statically link the thing in for debugging with ddb/gdb >Emmanuel > >+--------------------------------------------------------------------+ >|Emmanuel Duros | Emmanuel.Duros@sophia.inria.fr| >|INRIA Sophia Antipolis | Projet RODEO | >|2004, Route des Lucioles BP 93 | Phone : +33 04 93 65 79 42 | >|06902 Sophia Antipolis CEDEX France | Fax : +33 04 93 65 77 65 | >+--------------------------------------------------------------------+ > eric. -- erich@lodgenet.com http://rrnet.com/~erich erich@rrnet.com