This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

readl writel: how do they work?

There are two executables readl and writel which can be used to write arm register on linux (I am working with DM365 and montavista).

I wonder how these work in the user space since they don't need an external module to be loaded, maybe there is an internal module already available.

I am going to write a kernel module but the existence of these two functions make me suppose that maybe there is already something I can use. 

Maybe they use the memory mapped register opening the  /dev/mem ? Is it possible to have some more detail, or possibly the souce code of the two functions?

Thank you.

  • Hi Peregrinus,

    There are two executables readl and writel which can be used to write arm register on linux (I am working with DM365 and montavista).

    I wonder how these work in the user space since they don't need an external module to be loaded, maybe there is an internal module already available.

    I am going to write a kernel module but the existence of these two functions make me suppose that maybe there is already something I can use. 

    Maybe they use the memory mapped register opening the  /dev/mem ? Is it possible to have some more detail, or possibly the souce code of the two functions?

    Its not so difficult, as it looks to be, you need to open /dev/mem obtain the fd and MMAP the given address,

    and perform read write depending  on your need.

    I have attached the source.5811.regreadwrite.c

    Thx,

    --Prabhakar Lad

  • It works!!

    As I suspected the solution was simpler than writing a device driver. 

    Thank you very much Prabhakar.