mmap in kernel module - Linux

This is a discussion on mmap in kernel module - Linux ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: mmap in kernel module

  1. 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


  2. Re: mmap in kernel module

    I don't know abt it.
    But Linux driver programming by rubini 'll be helpful for you.

    Thanks,
    Deepak.
    pierre wrote:
    > 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



+ Reply to Thread