On Thursday 20 September 2001 08:54, S. Ancelot wrote:
> > > > 2. on the PCI board, I use , I would like to remap I/O pci to
> > > > have direct memory access from user space programs directly.
> > > > is it possible and how ?
> > >
> > > Nice Linux specific feature: Use "ioperm()" to gain access to the
> > > ports you need. Then use port instructions (or macros) right in
> > > your code, as if you were running in kernel space - or under DOS.
> > > :-)
>
> ??????????
> Are you sure what means driver ??? A hardware can't be accessed from
> two different places, example : what would happen if 2 programs write
> into LPT ports at the same time !!! I agree this may work for simple
> hardware, but not for intelligent hardware.

On the contrary, you're probably using a "driver" that does it that way 
right now; the X server. (It *can* use kernel drivers for certain things, 
but doesn't have to. Older versions of XFree86 didn't have kernel drivers 
at all.)


> I will ask my question another way :
> How to write the mmap implementation of a linux driver , to access  I/O
> memory of a hardware from user/space for read access ?

Ok, so we're not talking about *ports*, but memory mapped I/O. :-)

Anyway, there's an internal kernel function remap_page_range() that's 
used by various drivers to map the DMA buffer to user space - study some 
driver code to see how it's used. You'll also need mem_map_reserve() in 
order to get remap_page_range() to work.

Or, as someone mentioned already (and as the aforementioned XFree86 does 
it, AFAIK) - use mmap() on /dev/mem from user space.


> > Wait.. but how can one do DMA this way?  Won't the whole virtual,
> > swappable, transient nature of user memory basically cause problems
> > when trying to use DMA? Or am I misunderstanding the question?
> >
> > > Do note that this is *direct* port access! There's no driver or
> > > anything involved, so you have to be carefull not to run into
> > > synchronization problems if you share the ports with some kernel
> > > driver, or multiple threads or processes.
> > >
> > > (If you end up in such a scenario, I'd suggest adding some ioctl()s
> > > for your applications to use instead of direct port access. That's
> > > what I do for our old ISA card with write-only "control bit"
> > > registers that various "drivers" need to fiddle with; the driver
> > > shadows the registers with internal backup variables and an Amiga
> > > style "setbits/clearbits" interface.)
>
> OK, but that was ISA board.

Yes, but ports are still ports, and the problems are the same.


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> [EMAIL PROTECTED] -'

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to