[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: [rtl] mmap of kernel memory
On Thu, 9 Apr 1998, Jens Michaelsen wrote:
> As the shared memory mechanism described for RtLinuX is medium flexible
> only, I wondered
> if it would be possible to add the shared memory to something like rt_fifo.
>
> I took some code from ./driver/sound/soundcard.c
>
> My first try:
>
> char * mem;
>
> init_module() /* OK */
> {mem=kmalloc(1024,GFPxx); return 0; }
>
> cleanup() /* OK */
> {kfree(mem);}
>
> my_read() /* OK */
> {put_usr();}
>
> my_write() /* OK */
> {get_usr()}
>
> my_mmap() /* says OK but doesNT work */
> {remap_page_range();}
>
> failed. I only get zeros in my application that does the mmap() to the
> device.
> Read or write works fine, also using a real file for mmap in application
> works fine too.
>
> Any mechanism knowledge around?
This is unfortunately proper behavior for your program. It is impossible
to mmap memory which was allocated with kmalloc(). mmap() will ALWAYS
return page full of zeros.
You may try to do it other way around - allocate memory in user process
and them pass it to the kernel module.
Oleg.
--- [rtl] ---
For more information on Real-Time Linux see:
http://rtlinux.cs.nmt.edu/