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

.