sketch uio

This commit is contained in:
Ciro Santilli
2017-08-05 12:32:24 +01:00
parent 1f4f7faeba
commit 83411a0597
7 changed files with 84 additions and 3 deletions

View File

@@ -50,6 +50,12 @@ Often abbreviated to BDF.
- device: maps to one slot
- function: https://stackoverflow.com/questions/19223394/what-is-the-function-number-in-pci/44735372#44735372
Sometimes a fourth number is also added, e.g.:
0000:00:04.0
TODO is that the domain?
Class: pure magic: https://www-s.acm.illinois.edu/sigops/2007/roll_your_own/7.c.1.html
TODO: does it have any side effects? Set in the edu device at:
@@ -279,6 +285,7 @@ static int pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
* - https://stackoverflow.com/questions/17913679/how-to-instantiate-and-use-a-dma-driver-linux-module
* - https://stackoverflow.com/questions/5539375/linux-kernel-device-driver-to-dma-from-a-device-into-user-space-memory
* - RPI userland /dev/mem https://github.com/Wallacoloo/Raspberry-Pi-DMA-Example
* - https://stackoverflow.com/questions/34188369/easiest-way-to-use-dma-in-linux
*/
{
dma_addr_t dma_handle_from, dma_handle_to;

View File

@@ -5,6 +5,7 @@ Adapted from: https://github.com/dwks/pagemap/blob/8a25747bc79d6080c8b94eac80807
- https://stackoverflow.com/questions/17021214/how-to-decode-proc-pid-pagemap-entries-in-linux/45126141#45126141
- https://stackoverflow.com/questions/5748492/is-there-any-api-for-determining-the-physical-address-from-virtual-address-in-li
- https://stackoverflow.com/questions/6284810/proc-pid-pagemaps-and-proc-pid-maps-linux/45500208#45500208
Dump the page map of a given process PID.

View File

@@ -0,0 +1,46 @@
/*
Adapted from: https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
modprobe uio_pdrv_genirq
TODO get working.
Handle interrupts from userland and print a message to stdout.
*/
#define _XOPEN_SOURCE 700
#include <fcntl.h> /* open */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h> /* write */
int main(int argc, char **argv)
{
char *dev;
if (argc < 2) {
}
int fd = open("/dev/uio", O_RDWR);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
while (1) {
uint32_t info = 1;
size_t nb = write(fd, &info, sizeof(info));
if (nb < sizeof(info)) {
perror("write");
close(fd);
exit(EXIT_FAILURE);
}
nb = read(fd, &info, sizeof(info));
if (nb == sizeof(info)) {
printf("Interrupt #%u\n", info);
}
}
close(fd);
exit(EXIT_SUCCESS);
}