more of a Linux quesiton but mcp8548 related

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

more of a Linux quesiton but mcp8548 related

1,789 Views
jah
Contributor I
Reference: any generic linux in a PowerPC FreeScale8548 hardware DMA environment.  this is more of a Linux kernel programming issue but thought to post here.


Question:  what methods are available to move a kmalloc created 128K size buffer from kernel land to user land.  i am looking to effectively translate the kernel's start of buffer address to the user land.

the buffer is initially loaded or transmitted by DMA hardware in the kernel but needs to be make available to the user memory environment.

my impression is copy_from_user() will work on value and therefore this routine must copy the value of each word to the different memory systems using cpu cycles.

thanks!
0 Kudos
1 Reply

536 Views
PaoloTreffilett
Contributor II
Hi jah,
just some hints:
when you allocate the buffer you can forward the address to the user application via the copy_to_user().
In the user application you can open the /dev/mem device and map via mmap() the memory area of the kernel buffer.
So you can think to have two address, the physical address and the user space address and you know the offset between the two address. Each time you must use a location in the kernel buffer you can translate it to a user space address using this offset.

Here some C lines of code on how to open the /dev/mem device and how to map a buffer positioned in BaseBufPhyAddr

...
DevMemFD = open("/dev/mem", O_RDWR);
BaseBufVirtAdd    = mmap(NULL, Size, PROT_READ | PROT_WRITE, MAP_SHARED, DevMemFD, BaseBufPhyAddr);
...

Paolo
p.s. I allocate the kernel buffer via dma_alloc_coherent() function, and the right address to map is the physical address not the virtual kernel address



Message Edited by Paolo Treffiletti on 2007-09-21 09:29 AM

Message Edited by Paolo Treffiletti on 2007-09-21 09:41 AM
0 Kudos