From e1265fa32837f457ee2c2fa259d12c9545af4bbf Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Mon, 27 Apr 2015 02:28:57 +0200 Subject: First stand-alone ipecamera implementation --- apps/pio_test.c | 96 --------------------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 apps/pio_test.c (limited to 'apps/pio_test.c') diff --git a/apps/pio_test.c b/apps/pio_test.c deleted file mode 100644 index 84439ee..0000000 --- a/apps/pio_test.c +++ /dev/null @@ -1,96 +0,0 @@ -#define _BSD_SOURCE -#define _POSIX_C_SOURCE 199309L -#include -#include -#include -#include -#include -#include -#include - -#include "pcilib.h" -#include "irq.h" -#include "kmem.h" - -#define DEVICE "/dev/fpga0" -//#define REALTIME - -#define BAR PCILIB_BAR0 -#define BITS 32 -#define MASK ((1ll << BITS) - 1) - - -#define WR(addr, value) { *(uint32_t*)(bar + addr) = value; } -#define RD(addr, value) { value = *(uint32_t*)(bar + addr); } - -unsigned long long bits[BITS]; - -int main(int argc, char *argv[]) { - uint32_t i, j; - pcilib_t *pci; - uint32_t reg, value, diff, errors; - void* volatile bar; - - unsigned long long attempts = 0, failures = 0; - - if (argc < 2) { - printf("Usage: %s \n", argv[0]); - exit(0); - } - - if (sscanf(argv[1], "%x", ®) != 1) { - printf("Can't parse register %s\n", argv[1]); - exit(1); - } - -#ifdef REALTIME - pid_t pid; - struct sched_param sched = {0}; - - pid = getpid(); - sched.sched_priority = sched_get_priority_min(SCHED_FIFO); - if (sched_setscheduler(pid, SCHED_FIFO, &sched)) - printf("Warning: not able to get real-time priority\n"); -#endif /* REALTIME */ - - pci = pcilib_open(DEVICE, PCILIB_MODEL_DETECT); - if (!pci) { - printf("pcilib_open\n"); - exit(1); - } - - bar = pcilib_map_bar(pci, BAR); - if (!bar) { - pcilib_close(pci); - printf("map bar\n"); - exit(1); - } - - for (i = 0; 1; i++) { - WR(reg, (i%MASK)); - RD(reg, value); - - attempts++; - if (value != (i%MASK)) { - failures++; - - diff = value ^ (i%MASK); - for (errors = 0, j = 0; j < BITS; j++) - if (diff&(1<