mmap in kernel module



Hi, i'm newby in kernel programming.

I need to directly address a device in the memory, but i can't use
open, mmap and munmap.


What i actually need to do is the following (from application point of
view):
"""
mem = open("/dev/mem", O_RDWR | O_SYNC);
base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, mem,
EBI_BASE & ~MAP_MASK);
munmap(base, MAP_SIZE);
cs_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, mem,
CS_BASE & ~MAP_MASK);
"""
MAP_SIZE, MAP_SHARED, CS_BASE, EBI_BASE and MAP_MASK are predifinied
consts which define addresses, masks and offsets.


How can i do this in the device_open method?


Please help.


thanks in advance

.



Relevant Pages

  • Re: How mmap spends memory
    ... I'm actually interested how does mmap() - munmap() works. ... When you mmapyou are assigning a segment of your process's virtual ... memory segment so that it can be used for other purposes. ...
    (comp.unix.programmer)
  • Re: How mmap spends memory
    ... I'm actually interested how does mmap() - munmap() works. ... I used the mmaptechnique to map file at a time into memory ... munmap that 20 MB then your memory usage will not grow, ...
    (comp.unix.programmer)
  • mmap in kernel module
    ... I need to directly address a device in the memory, ... open, mmap and munmap. ... consts which define addresses, masks and offsets. ...
    (comp.os.linux.development.system)
  • Re: FAQ 5.29 How can I read in an entire file all at once?
    ... PS> Are you sure you want to read the entire file and store it in memory? ... PS> you mmap the file, you can virtually load the entire file into a string ... entities and are best loaded into a scalar. ... mmap always needs virtual ram allocated ...
    (comp.lang.perl.misc)
  • Re: [PATCH 1/2]: Fix BUG in cancel_dirty_pages on XFS
    ... will see _none_ of the write because the mmap write occurred during ... inode in the buffered I/O *writeback* path, we have to stop pages being ... filesystems in both locking and the way it treats the page cache. ... No, but the data _in memory_ will, and now when the direct read ...
    (Linux-Kernel)