[Gllug] Writing my own system call

James Courtier-Dutton james.dutton at gmail.com
Sun Jun 19 00:55:01 UTC 2011


On 15 June 2011 11:49, Adrian McMenamin <adrian at newgolddream.dyndns.info> wrote:
> I need to know the physical address of memory allocated from the heap in
> user space (this is for research, not because I am suggesting this is a
> sensible thing for anyone in the real world to be able to do) - I am
> researching/confirming phases of memory locality in the kernel.
>
> As far as I can see the only way I will be able to do this is to write my
> own system call handle the return from __pa().
>
> But, just to check - anyone know of a simpler way?

You need to create your own device driver.
You can then load this as a module. Use code in the module to create a
file in /dev
You can then open the file, and do ioctl to it to retrieve the
information you need.
Probably only about 20 lines of code.

Just look in the kernel source for a device driver and modify it to your needs.

You will need the ioctl call to do this so that the kernel knows the
context of which user space program is making the ioctl request and
use this to convert virtual to physical correctly.

The device driver will only have to support open, ioctl, close  function calls.

Kind Regards

James
--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list