Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you can find a lot of documentation about the kmalloc + mmap part. However, I am not sure that you can kmalloc so much memory in a contiguous way, and have it always at the same place. Sure, if everything is always the same, then you might get a constant address. However, each time you change the kernel code, you will get a different address, so I would not go with the kmalloc solution.</p> <p>I think you should reserve some memory at boot time, ie reserve some physical memory so that is is not touched by the kernel. Then you can ioremap this memory which will give you a kernel virtual address, and then you can mmap it and write a nice device driver.</p> <p>This take us back to <a href="http://lwn.net/Kernel/LDD3/" rel="noreferrer">linux device drivers</a> in PDF format. Have a look at chapter 15, it is describing this technique on page 443</p> <p>Edit : ioremap and mmap. I think this might be easier to debug doing things in two step : first get the ioremap right, and test it using a character device operation, ie read/write. Once you know you can safely have access to the whole ioremapped memory using read / write, then you try to mmap the whole ioremapped range.</p> <p>And if you get in trouble may be post another question about mmaping</p> <p>Edit : remap_pfn_range ioremap returns a virtual_adress, which you must convert to a pfn for remap_pfn_ranges. Now, I don't understand exactly what a pfn (Page Frame Number) is, but I think you can get one calling</p> <pre><code>virt_to_phys(pt) &gt;&gt; PAGE_SHIFT </code></pre> <p>This probably is not the Right Way (tm) to do it, but you should try it</p> <p>You should also check that FOO_MEM_OFFSET is the physical address of your RAM block. Ie before anything happens with the mmu, your memory is available at 0 in the memory map of your processor.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload