Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Virtual to Physical address issue : (2 Items)
   
Virtual to Physical address issue  
Hello All.

Working on porting SDIO driver on to QNX. I am using DMA for reading and writing data basically for DMA iam using 4 
bytes  for transfer meaning 
i need to read an integer value using DMA by passing integer address for DMA.

How is this done.

I have an integer variable int value; 

For DMA i get the physical address of this address value 

mem_offset64(&vaue, NOFD, 1, &offset, 0)

This physical address is used for DMA.  Problem i see is iam not able to get any value from the controller later using 
mmap for 4 bytes allocation i got the adress same address was used for DMA which was successful. 

Later i used volatile int value which also didn't give the right physical address for successful DMA.

Is there a way where i can get right physical address for address of value which will result in successful DMA.

Regards
Kaushik
RE: Virtual to Physical address issue  
Hi Roy,

using simple variables for DMA usually will not work. For hardware I/O, you need to make sure that the memory region 
used is not cached, otherwise changes in RAM may remain invisible to the CPU. Also, for DMA you must ensure that the 
memory region is physically contiguous. To allocate and get access to some DMA-safe memory, do something like:
   volatile int  *ptr;
   off64_t  offset;
   int  value;

   ptr = mmap(NULL, sizeof *ptr, PROT_READ|PROT_WRITE|PROT_NOCACHE, MAP_PHYS|MAP_ANON, NOFD, 0);
   if(MAP_FAILED == ptr) {
      perror("mmap()");
      exit(EXIT_FAILURE);
   }

   mem_offset64(ptr, NOFD, 1, &offset, 0);
   /* Pass <offset> to DMA controller */
   /* Initiate DMA */
   /* Wait for DMA finished */
   value = *ptr;

   ...
When finished doing DMA, call
   munmap(ptr, sizeof *ptr);

Regards,
Thomas

-----Original Message-----
From: Roy Jose [mailto:community-noreply@qnx.com] 
Sent: Montag, 17. Februar 2014 09:48
To: ostech-core_os
Subject: Virtual to Physical address issue

Hello All.

Working on porting SDIO driver on to QNX. I am using DMA for reading and writing data basically for DMA iam using 4 
bytes  for transfer meaning i need to read an integer value using DMA by passing integer address for DMA.

How is this done.

I have an integer variable int value; 

For DMA i get the physical address of this address value 

mem_offset64(&vaue, NOFD, 1, &offset, 0)

This physical address is used for DMA.  Problem i see is iam not able to get any value from the controller later using 
mmap for 4 bytes allocation i got the adress same address was used for DMA which was successful. 

Later i used volatile int value which also didn't give the right physical address for successful DMA.

Is there a way where i can get right physical address for address of value which will result in successful DMA.

Regards
Kaushik



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post108837
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com