Physical Memory from Virtual Memory

I need to be able to allocate memory in a driver and have a hardware
component directly access that memory. The hardware needs a physical
address. Is there a method by which this can be accomplished, without
reserving a certain amount of RAM during the startup code for this purpose?

Issam

Look at drives samples in DDKs. The mem_offset() function does that if
memory serves me.

  • igor

Issam Haddad wrote:

I need to be able to allocate memory in a driver and have a hardware
component directly access that memory. The hardware needs a physical
address. Is there a method by which this can be accomplished, without
reserving a certain amount of RAM during the startup code for this purpose?

Issam

Issam Haddad <ihaddad@asurent.com> wrote:

I need to be able to allocate memory in a driver and have a hardware
component directly access that memory. The hardware needs a physical
address. Is there a method by which this can be accomplished, without
reserving a certain amount of RAM during the startup code for this purpose?

Couple of ways. You can mmap() physical ram directly or you can use
shm_open() and shm_ctrl() and then mmap().

chris

cdm@qnx.com > “The faster I go, the behinder I get.”

Chris McKillop – Lewis Carroll –
Software Engineer, QSSL
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Thanks.

“Chris McKillop” <cdm@qnx.com> wrote in message
news:9kmkmd$qf8$2@nntp.qnx.com

Issam Haddad <> ihaddad@asurent.com> > wrote:

I need to be able to allocate memory in a driver and have a hardware
component directly access that memory. The hardware needs a physical
address. Is there a method by which this can be accomplished, without
reserving a certain amount of RAM during the startup code for this
purpose?


Couple of ways. You can mmap() physical ram directly or you can use
shm_open() and shm_ctrl() and then mmap().

chris

cdm@qnx.com > “The faster I go, the behinder I get.”
Chris McKillop – Lewis Carroll –
Software Engineer, QSSL

Issam Haddad <ihaddad@asurent.com> wrote:

I need to be able to allocate memory in a driver and have a hardware
component directly access that memory. The hardware needs a physical
address. Is there a method by which this can be accomplished, without
reserving a certain amount of RAM during the startup code for this purpose?

Take a look at the notes on getting DMA safe memory in mmap(), in particular
the combination of MAP_PHYS|MAP_ANON to allocate some physical memory,
then call mem_offset() to get the physical address of your memory.

-David

QNX Training Services
dagibbs@qnx.com