Hi All,
I want to allocate a block of continuous memory as video work buffer for DMA usage. But I always get failure in converting the virtual address to physical one with return -1, and physical address always zero.
Can anyone give me some clues on this issue?
my code:
{
unsigned int ptr = NULL, phys_addr = NULL;
int ret = 0;
size = (size + 0x3FF) & (~0x3FF);
ptr = mmap( 0, size,
PROT_READ|PROT_WRITE|PROT_NOCACHE,
MAP_PHYS|MAP_ANON,
NOFD,
0 );
if (ptr == MAP_FAILED)
{
printf("memory allocation failed\n");
return (void *)NULL;
}
else
{
ret = mem_offset(ptr, NOFD, 1, &phys_addr, 0);
printf("RET:%d vitual memory 0x%x, physical from 0x%x to 0x%x\n", ret, ptr, phys_addr, phys_addr + size);
return (void *)phys_addr;
}
}
BR
-Ray