Jianwei Gao
02/12/2008 3:31 PM
post4970
|
There is a shared memory object (NVRAM, ~24Mbytes) on my target board. I tried to map a block of NVRAM memory as my DMA
buffer as below,
fd = shm_open(shm_buff_name, O_RDWR, 0);
vaddr = mmap(NULL, 0x20000, PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED, fd, shm_buff_off);
mem_offset64(vaddr, NOFD, 0x20000, &paddr, NULL);
The 'shm_buff_off' is the offset inside the NVRAM, where I want to allocate memory from.
When ‘shm_buff_off’ was changed, for example, from 0x100000 to 0x200000, the ‘vaddr’ was changed accordingly.
However, the ‘paddr’ was always same. What is possible reason?
Thanks,
|
|
|
Mario Charest
02/13/2008 8:54 AM
post4998
|
> There is a shared memory object (NVRAM, ~24Mbytes) on my target board. I tried
> to map a block of NVRAM memory as my DMA buffer as below,
>
> fd = shm_open(shm_buff_name, O_RDWR, 0);
> vaddr = mmap(NULL, 0x20000, PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED
> , fd, shm_buff_off);
> mem_offset64(vaddr, NOFD, 0x20000, &paddr, NULL);
>
> The 'shm_buff_off' is the offset inside the NVRAM, where I want to allocate
> memory from.
>
> When ‘shm_buff_off’ was changed, for example, from 0x100000 to 0x200000, the
> ‘vaddr’ was changed accordingly. However, the ‘paddr’ was always same.
> What is possible reason?
>
Is it possible you got them reversed, because it's more likely vaddr wouldn't have changed, it's a virtual address.
> Thanks,
>
>
>
|
|
|
Jianwei Gao
02/13/2008 2:45 PM
post5007
|
I tested it again. I found that both of vaddr and paddr are same for different offset. Below is my test code,
vaddr = mmap(NULL, 0x20000, PROT_READ|PROT_WRITE|PROT_NOCACHE, MAP_SHARED, fd, shm_buff_off);
if (vaddr != MAP_FAILED) {
int config_len;
if (mem_offset64(vaddr, NOFD, 0x20000, &paddr, &config_len) != -1) {
printf("Memory available 0x%x, vaddr 0x%x, paddr 0x%x ", config_len, (uint32_t)vaddr, paddr);
}
}
Moreover, the 'config_len' is always 0x1000. I am not sure if it is correct. However, the allocated DMA buffer works
fine.
|
|
|
Brian Stecher
02/13/2008 3:19 PM
post5011
|
On Wed, Feb 13, 2008 at 02:45:16PM -0500, Jianwei Gao wrote:
> I tested it again. I found that both of vaddr and paddr are same for
different offset. Below is my test code,
What version of the OS are you using? There's PR 28536 if you're using
6.3.0 or earlier - if you were using shm_ctl(...,SHM_CTL_PHYS,...), the
mmap()
didn't add the offset parm to the base address of the object properly.
The bug got fixed in 6.3.2.
--
Brian Stecher (bstecher@qnx.com) QNX Software Systems
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8
|
|
|
Jianwei Gao
02/14/2008 9:33 AM
post5029
|
Thanks a lot. The OS version is 6.3.0.
|
|
|
|