0

I know that this question was asked but I still could not extract any useful answer. I would be thankful if one can provide not too much complicated answer since my linux background isn't so deep. The reason I need to work with physically contiguous frames in userspace is that I'm working with hardware device and I'm simulating this device's driver in userspace, while there is a thin layer of driver which I should use. One of the simplest suggestions I got was to allocate in the kernel layer of the driver using get_free_pages and then somehow using mmap to make this memory usable in the userspace. Can you please elaborate and explain this suggestion? or of course propose any other (simple) solutions?

Thank you

Hanna Khalil
  • 975
  • 1
  • 10
  • 28
  • There are pretty number of examples for implement `mmap`. What **exactly** you have failed to undestand with it? – Tsyvarev Apr 24 '16 at 19:01
  • use kzalloc/kmalloc to allocate continuous physical memory (or ioremap to map io) and use mmap to map it to the user. see simple example here: http://blog.discoversdk.com/using-mmap-to-map-kernel-buffer-to-user-space-example/ – Liran Ben Haim Apr 24 '16 at 20:42
  • @SamProtsenko: The question your refers operates with **user space only** means, but given question explicitely tells about **kernel driver** which could be written. – Tsyvarev Apr 26 '16 at 09:24
  • @Tsyvarev Ah, correct. The pitfalls of reading only titles :) Taking my vote to close back. – Sam Protsenko Apr 26 '16 at 11:55

1 Answers1

0

If you are allowed to you a patch then bigphysarea may provide physically contiguous pages.

http://atlas.web.cern.ch/Atlas/project/kernels/www/bigphysarea-README

Tectrendz
  • 1,354
  • 2
  • 17
  • 36