diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2019-09-04 08:20:30 -0400 |
---|---|---|
committer | Felipe Franciosi <felipe@nutanix.com> | 2019-09-05 16:45:35 +0100 |
commit | 73f280c124e69f9d8c46181208194a01d0f330d2 (patch) | |
tree | 5a4bd289facb17611e2c8bfeb5310fa677cee21d /README.md | |
parent | 209c7c4daa3f8cdfe0070d4d5ccd602f56f43cb6 (diff) | |
download | libvfio-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.md | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -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 =========== |