aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2019-09-04 08:20:30 -0400
committerFelipe Franciosi <felipe@nutanix.com>2019-09-05 16:45:35 +0100
commit73f280c124e69f9d8c46181208194a01d0f330d2 (patch)
tree5a4bd289facb17611e2c8bfeb5310fa677cee21d /README.md
parent209c7c4daa3f8cdfe0070d4d5ccd602f56f43cb6 (diff)
downloadlibvfio-user-73f280c124e69f9d8c46181208194a01d0f330d2.zip
libvfio-user-73f280c124e69f9d8c46181208194a01d0f330d2.tar.gz
libvfio-user-73f280c124e69f9d8c46181208194a01d0f330d2.tar.bz2
introduce gpio sample
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 37 insertions, 1 deletions
diff --git a/README.md b/README.md
index b744c26..c14775e 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ Running QEMU
To pass the device to QEMU add the following options:
- -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/00000000-0000-0000-0000-000000000000
+ -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/<UUID>
-object memory-backend-file,id=ram-node0,prealloc=yes,mem-path=mem,share=yes,size=1073741824 -numa node,nodeid=0,cpus=0,memdev=ram-node0
Guest RAM must be shared (share=yes) otherwise libmuser won't be able to do DMA
@@ -108,6 +108,42 @@ accessed by libmuser must be allocate MAP_SHARED. Registering memory for DMA
that has not been allocated with MAP_SHARED is ignored and any attempts to
access that memory will result in an error.
+Example
+=======
+
+samples/gpio-pci-idio-16.c implements a tiny part of the PCI-IDIO-16 GPIO
+(https://www.accesio.com/?p=/pci/pci_idio_16.html). In this sample it's a simple
+device that toggles the input every 3 times it's read.
+
+Running gpio-pci-idio-16
+------------------------
+
+First, follow the instructions to build and load muser.
+
+Then, start the gpio-pci-idio-16 device emulation:
+
+ # echo 00000000-0000-0000-0000-000000000000 > /sys/class/muser/muser/mdev_supported_types/muser-1/create
+ # build/dbg/samples/gpio-pci-idio-16 00000000-0000-0000-0000-000000000000
+
+Finally, start the VM adding the command line explained earlier and then
+execute:
+
+ # insmod gpio-pci-idio-16.ko
+ # cat /sys/class/gpio/gpiochip480/base > /sys/class/gpio/export
+ # for ((i=0;i<12;i++)); do cat /sys/class/gpio/OUT0/value; done
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+
Future Work
===========