Armand Ciejak
|
using mmap() to get contiguous memory > 4kB
|
Armand Ciejak
12/14/2007 7:59 AM
post3762
|
using mmap() to get contiguous memory > 4kB
I'm currently working on a PCI driver on the following platform:
- QNX 6.3.0 SP3
- mpc8349
- mpc8349mds BSP
I need to allocate some buffers to be used for DMA transfers. then I need contiguous memory. I want to know if the
system is able to provide me the amount of contiguous memory I requested. To do that I use the allocate_dma_buffer()
function (see bellow).
My problem is that the system seems not to be able to give me more the 4kB of contiguous memory. Maybe I misunderstood
something? Am I donig anything wrong?
Thanks for helping,
Armand
int allocate_dma_buffer( size_t const length,
void ** const buffer_ptr,
off_t * const buffer_paddr)
{
size_t contiguous_length;
//----- allocate physically contiguous memory -----
*buffer_ptr = mmap( NULL,
length,
PROT_READ|PROT_WRITE|PROT_NOCACHE,
MAP_PHYS|MAP_ANON,
NOFD,
0 );
if( MAP_FAILED == *buffer_ptr )
{
printf("mmap() FAILED: %s\n", strerror(errno) );
return -1;
}
//----- get physical address -----
if( -1 == mem_offset( *buffer_ptr,
NOFD,
length,
buffer_paddr,
&contiguous_length ) )
{
printf("mem_offset() FAILED: %s\n", strerror(errno) );
return -1;
}
// mem_offset() always returns with contiguous_length set to 4096
if( length > contiguous_length )
{
printf("mem_offset() FAILED to get physical address for the complete buffer\n");
return -1;
}
return 0;
}
|
|
|