Memory mapped peripherals

bridged with qdn.public.newuser
Post Reply
Matt Boothe

Memory mapped peripherals

Post by Matt Boothe » Fri Jan 16, 2004 3:41 pm

My Power PC based custom hardware will have several memory mapped
peripherals. I have a few questions about this topic:

* The BSP I am using sets up the chip selects for all memory mapped
peripherals in the IPL. I plan to follow this example. Any reason to set
up the chip selects somewhere other than the IPL?

* Once I have the peripherals mapped into the memory map, can applications
directly access the peripheral? Doing so would require that the application
be able to address a physical memory location instead of a virtual one. I
don't know if applications can do this or not. If they can't do I need to
write a resource to sit between the application and the peripheral?

I am RTFM'ing as fast as I can, but if anyone can help me get my head on
straight about this topic or point me at the documentation that will help me
understand this topic I'd be most appreciative.

James MacMillan

Re: Memory mapped peripherals

Post by James MacMillan » Fri Jan 16, 2004 3:41 pm

Matt Boothe wrote:
* Once I have the peripherals mapped into the memory map, can applications
directly access the peripheral? Doing so would require that the application
be able to address a physical memory location instead of a virtual one. I
don't know if applications can do this or not. If they can't do I need to
write a resource to sit between the application and the peripheral?
Yes, this is possible to do in an application. What you need is to map
a section of physical memory into the virtual memory map. The mmap*
functions are the ones which you should read up on. I suspect that
mmap_device_memory() would be the best fit for your situation.

Note: Using the mmap functions requires that you have I/O privileges.
See the caveats section at the bottom of the mmap* functions' help
viewer docs for more details. As a side-effect, your application will
have to be run with root privileges (like all QNX hardware drivers).

--
James

Dave Green

Re: Memory mapped peripherals

Post by Dave Green » Fri Jan 16, 2004 5:03 pm

Matt Boothe <embeddedmatt@yahoo.com> wrote:
My Power PC based custom hardware will have several memory mapped
peripherals. I have a few questions about this topic:

* The BSP I am using sets up the chip selects for all memory mapped
peripherals in the IPL. I plan to follow this example. Any reason to set
up the chip selects somewhere other than the IPL?
Setting up the chip selects in the IPL is fine, as long as the IPL will be
the only code booting the board. Some boards have the ability to remap the
reset vector (via a jumper or switch), enabling two different primary loaders,
such as a ROM Monitor, and a native QNX IPL. In this case, if the ROM Monitor
and the IPL are setting chip selects up differently, the startup module and
runtime applications may have difficulty accessing devices, in which case
it might be better to set up the chip selects later, in startup. But, if the IPL
will be the only code booting this board, then setting up chip selects there
is fine. Or, just have the IPL set them up exactly like the ROM Monitor does.
* Once I have the peripherals mapped into the memory map, can applications
directly access the peripheral? Doing so would require that the application
be able to address a physical memory location instead of a virtual one. I
don't know if applications can do this or not. If they can't do I need to
write a resource to sit between the application and the peripheral?
They can't be accessed directly, but library calls (mmap_device_memory() and
mmap_device_io() ) exist to create a virtual pointer to a physical device.
I am RTFM'ing as fast as I can, but if anyone can help me get my head on
straight about this topic or point me at the documentation that will help me
understand this topic I'd be most appreciative.
http://www.qnx.com/developer/docs/momen ... ce_io.html
http://www.qnx.com/developer/docs/momen ... emory.html

--

David Green (dgreen@qnx.com)
QNX Software Systems Ltd.
http://www.qnx.com

Matt Boothe

Re: Memory mapped peripherals

Post by Matt Boothe » Fri Jan 16, 2004 9:29 pm

Thanks Dave and James. That looks like exactly what I need.

Post Reply

Return to “qdn.public.newuser”