Skip to content

Commit 6045b9f

Browse files
committed
uio: move docs for this disgraceful failed example to README
1 parent 839271e commit 6045b9f

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed

README.adoc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,6 +4858,48 @@ But in part because it is dying, I didn't spend much effort to integrate it into
48584858

48594859
Maybe some brave soul will send a pull request one day.
48604860

4861+
=== UIO
4862+
4863+
UIO is a kernel subsystem that allows to do certain types of driver operations from userland.
4864+
4865+
This would be awesome to improve debugability and safety of kernel modules.
4866+
4867+
VFIO looks like a newer and better UIO replacement, but there do not exist any examples of how to use it: https://stackoverflow.com/questions/49309162/interfacing-with-qemu-edu-device-via-userspace-i-o-uio-linux-driver
4868+
4869+
TODO get something interesting working. I currently don't understand the behaviour very well.
4870+
4871+
TODO how to ACK interrupts? How to ensure that every interrupt gets handled separately?
4872+
4873+
TODO how to write to registers. Currently using `/dev/mem` and `lspci`.
4874+
4875+
This example should handle interrupts from userland and print a message to stdout:
4876+
4877+
....
4878+
/uio_read.sh
4879+
....
4880+
4881+
TODO: what is the expected behaviour? I should have documented this when I wrote this stuff, and I'm that lazy right now that I'm in the middle of a refactor :-)
4882+
4883+
Sources:
4884+
4885+
* link:kernel_module/user/uio_read.c[]
4886+
* link:rootfs_overlay/uio_read.sh[]
4887+
4888+
Bibliography:
4889+
4890+
* https://stackoverflow.com/questions/15286772/userspace-vs-kernel-space-driver
4891+
* https://01.org/linuxgraphics/gfx-docs/drm/driver-api/uio-howto.html
4892+
* https://stackoverflow.com/questions/7986260/linux-interrupt-handling-in-user-space
4893+
* https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
4894+
* https://github.com/bmartini/zynq-axis/blob/65a3a448fda1f0ea4977adfba899eb487201853d/dev/axis.c
4895+
* https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
4896+
* http://nairobi-embedded.org/uio_example.html that website has QEMU examples for everything as usual. The example has a kernel-side which creates the memory mappings and is used by the user.
4897+
* https://stackoverflow.com/questions/49309162/interfacing-with-qemu-edu-device-via-userspace-i-o-uio-linux-driver
4898+
* userland driver stability questions:
4899+
** https://stackoverflow.com/questions/8030758/getting-kernel-version-from-linux-kernel-module-at-runtime/45430233#45430233
4900+
** https://stackoverflow.com/questions/37098482/how-to-build-a-linux-kernel-module-so-that-it-is-compatible-with-all-kernel-rele/45429681#45429681
4901+
** https://liquidat.wordpress.com/2007/07/21/linux-kernel-2623-to-have-stable-userspace-driver-api/
4902+
48614903
=== Linux kernel interactive stuff
48624904

48634905
[[fbcon]]

kernel_module/user/uio_read.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
/*
2-
TODO get working. Currently I don't understand the behaviour.
3-
4-
TODO how to ACK interrupts? How to ensure that every interrupt gets handled separately?
5-
6-
TODO write to registers. Currently using /dev/mem and lspci.
7-
8-
Handle interrupts from userland and print a message to stdout.
9-
10-
- Userland driver
11-
- https://stackoverflow.com/questions/15286772/userspace-vs-kernel-space-driver
12-
- https://01.org/linuxgraphics/gfx-docs/drm/driver-api/uio-howto.html
13-
- https://stackoverflow.com/questions/7986260/linux-interrupt-handling-in-user-space
14-
- https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
15-
- https://github.com/bmartini/zynq-axis/blob/65a3a448fda1f0ea4977adfba899eb487201853d/dev/axis.c
16-
- https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
17-
- http://nairobi-embedded.org/uio_example.html that website has QEMU examples for everything as usual. The example has a kernel-side which creates the memory mappings and is used by the user.
18-
- https://stackoverflow.com/questions/49309162/interfacing-with-qemu-edu-device-via-userspace-i-o-uio-linux-driver
19-
20-
Userland driver stability questions:
21-
22-
- https://stackoverflow.com/questions/8030758/getting-kernel-version-from-linux-kernel-module-at-runtime/45430233#45430233
23-
- https://stackoverflow.com/questions/37098482/how-to-build-a-linux-kernel-module-so-that-it-is-compatible-with-all-kernel-rele/45429681#45429681
24-
- https://liquidat.wordpress.com/2007/07/21/linux-kernel-2623-to-have-stable-userspace-driver-api/
25-
26-
VFIO looks like the newer UIO replacement, but there are no examples out there anywhere:
27-
28-
- https://stackoverflow.com/questions/49309162/interfacing-with-qemu-edu-device-via-userspace-i-o-uio-linux-driver
29-
*/
1+
/* https://github.com/cirosantilli/linux-kernel-module-cheat#uio */
302

313
#if 1
324

rootfs_overlay/uio_read.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
2-
set -ex
2+
# https://github.com/cirosantilli/linux-kernel-module-cheat#uio
3+
set -e
34
modprobe uio_pci_generic
45
# pci_min device
56
echo '1234 11e9' > /sys/bus/pci/drivers/uio_pci_generic/new_id
@@ -13,3 +14,4 @@ devmem "0x${base}" w 0x12345678
1314
devmem "0x$(($base + 4))" w 0x12345678
1415
devmem "0x${base}" w 0x12345678
1516
devmem "0x$(($base + 4))" w 0x12345678
17+
modprobe -r uio_pci_generic

0 commit comments

Comments
 (0)