Forum Discussion
Altera_Forum
Honored Contributor
12 years agoHi,
--- Quote Start --- With the non-mmu nios2 our design defined sdram regions that we utilized for buffers in our custom device driver. **** device driver sharedMem = kmalloc( SHARED_MEMSIZE, GFP_USER ); if ( sharedMem == NULL) { res = -ENOMEM; exit; } else { sharedMemVertAddr = ioremap( sharedMem, SHARED_MEMSIZE ); } **** end device driver So, in my user space code I have an ioctl that I call to get the address - "sharedMemAddr" from the driver then I do my: memcpy( sharedMemAddr, (const void *)&sharedMem, sizeof(sharedMem) ); FOR THE MMU system I get -- "SEGV" FOR THE non-MMU system the scheme works GREAT! What do I need to do to get the MMU system to allow this type of "memcpy?" --- Quote End --- The MMU always checks the memory access of user code and protects your kernel from destructions. In this case, 'sharedMemAddr' has a kernel space address, so the SEGV means that your MMU and kernel are working well. To access the kernel space from your user application side, you must get the permission and virtual address from your kernel. In general, the function 'mmap' is used for this purpose. http://man7.org/linux/man-pages/man2/mmap.2.html Kazu