Browse Source

Initial Commit

Timo Dritschler 3 years ago
commit
6f75101fdd
2 changed files with 44 additions and 0 deletions
  1. 13 0
      CMakeLists.txt
  2. 31 0
      ethernetBridge.c

+ 13 - 0
CMakeLists.txt

@@ -0,0 +1,13 @@
+# File to generate the makefile.
+# Uses src, include and build folders.
+
+project(KaptureEthernetBridge C)
+
+cmake_minimum_required(VERSION 2.6)
+find_package(PkgConfig)
+pkg_check_modules(PCILIB pcitool REQUIRED)
+
+#include_directories(include)
+
+add_executable(ethernetBridge ethernetBridge.c)
+target_link_libraries(ethernetBridge pcilib)

+ 31 - 0
ethernetBridge.c

@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <pcilib.h>
+#include <pcilib/bar.h>
+
+
+int main(int argc, char *argv[]) {
+    pcilib_t *pci;
+
+    pci = pcilib_open("/dev/fpga0", PCILIB_MODEL_DETECT);
+    if (!pci) {
+        printf("pcilib_open failed\n");
+        exit(-1);
+    }
+
+    volatile void *bar = pcilib_resolve_bar_address(pci, PCILIB_BAR0, 0);
+    if (!bar) {
+        printf("Failed to map PCI BAR for access\n");
+        pcilib_close(pci);
+        exit(-1);
+    }
+
+
+    printf("All went well\n");
+    pcilib_close(pci);
+    return 0;
+}
+
+
+