Date: Tue, 11 Mar 1997 09:28:37 -0600 From: "Eric L. Hernes" <erich@lodgenet.com> To: Emmanuel.Duros@sophia.inria.fr Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Pb using DMA - Physical addressing Message-ID: <199703111528.JAA13632@jake.lodgenet.com> In-Reply-To: Your message of "Tue, 11 Mar 1997 15:27:30 %2B0100." <199703111427.PAA05582@chouette.inria.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703111528.JAA13632>