mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 04:24:26 +01:00
mmap: move doc to README
This commit is contained in:
38
README.adoc
38
README.adoc
@@ -3442,6 +3442,44 @@ Bibliography:
|
||||
* https://stackoverflow.com/questions/2264384/how-do-i-use-ioctl-to-manipulate-my-kernel-module/44613896#44613896
|
||||
* https://askubuntu.com/questions/54239/problem-with-ioctl-in-a-simple-kernel-module/926675#926675
|
||||
|
||||
==== mmap
|
||||
|
||||
In guest:
|
||||
|
||||
....
|
||||
/mmap.sh
|
||||
echo $?
|
||||
....
|
||||
|
||||
Outcome: the test passes:
|
||||
|
||||
....
|
||||
0
|
||||
....
|
||||
|
||||
Sources:
|
||||
|
||||
* link:kernel_module/mmap.c[]
|
||||
* link:kernel_module/user/mmap.c[]
|
||||
* link:rootfs_overlay/mmap.sh[]
|
||||
|
||||
The `mmap` system call allows us to share memory between user and kernel space without copying.
|
||||
|
||||
In this example, we make a tiny 4 byte kernel buffer available to user-space, and we then modify it on userspace, and check that the kernel can see the modification.
|
||||
|
||||
`mmap`, like most more complex <<file-operations>>, does not work with <<debugfs>> as of 4.9, so we use a <<procfs>> file for it.
|
||||
|
||||
Example adapted from: https://coherentmusings.wordpress.com/2014/06/10/implementing-mmap-for-transferring-data-from-user-space-to-kernel-space/
|
||||
|
||||
Bibliography:
|
||||
|
||||
* https://stackoverflow.com/questions/10760479/mmap-kernel-buffer-to-user-space/10770582#10770582
|
||||
* https://stackoverflow.com/questions/1623008/allocating-memory-for-user-space-from-kernel-thread
|
||||
* https://stackoverflow.com/questions/6967933/mmap-mapping-in-user-space-a-kernel-buffer-allocated-with-kmalloc
|
||||
* https://github.com/jeremytrimble/ezdma
|
||||
* https://github.com/simonjhall/dma
|
||||
* https://github.com/ikwzm/udmabuf
|
||||
|
||||
==== Character devices
|
||||
|
||||
In guest:
|
||||
|
||||
Reference in New Issue
Block a user