summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-04-27 01:54:44 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-04-27 01:54:44 +0200
commit8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4 (patch)
tree30c74c76115279cdc15437a07fabd8347ac1fdfd
parentdcd8ad63316eac672492bc18112bbbb52811c3fc (diff)
downloadpcitool-8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4.tar.gz
pcitool-8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4.tar.bz2
pcitool-8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4.tar.xz
pcitool-8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4.zip
Further adjustments to get ready for independent event plugins
-rw-r--r--.bzrignore2
-rw-r--r--CMakeLists.txt39
-rw-r--r--dma/ipe.h4
-rw-r--r--dma/nwl.h4
-rw-r--r--dma/nwl_engine.c6
-rw-r--r--dma/nwl_private.h2
-rw-r--r--pcilib/CMakeLists.txt6
-rw-r--r--pcilib/config.h.in3
-rw-r--r--pcilib/dma.h4
-rw-r--r--pcilib/error.c2
-rw-r--r--pcilib/event.h3
-rw-r--r--pcilib/export.c (renamed from pcilib/config.c)7
-rw-r--r--pcilib/export.h (renamed from pcilib/config.h)6
-rw-r--r--pcilib/model.h4
-rw-r--r--pcilib/pci.h3
-rw-r--r--pcitool.pc.in12
-rw-r--r--protocols/default.h4
17 files changed, 87 insertions, 24 deletions
diff --git a/.bzrignore b/.bzrignore
index a4a8059..371cdfe 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -26,3 +26,5 @@ apps/heb_strip_bad_values
apps/check_counter
apps/lorenzo_ipedma_test
pci
+pcitool.pc
+config.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index faed5aa..e6313d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
project(pcitool)
-set(PCILIB_VERSION "0.1.0")
-set(PCILIB_ABI_VERSION "1")
+set(PCILIB_VERSION "0.2.0")
+set(PCILIB_ABI_VERSION "2")
cmake_minimum_required(VERSION 2.6)
@@ -30,6 +30,41 @@ set_target_properties(pcilib PROPERTIES
SOVERSION ${PCILIB_ABI_VERSION}
)
+set(TARNAME "pcitool")
+set(PACKAGE_VERSION ${PCILIB_VERSION})
+set(PACKAGE_NAME "${TARNAME}")
+set(PACKAGE_TARNAME "${TARNAME}")
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
+if(NOT DEFINED BIN_INSTALL_DIR)
+ set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+endif(NOT DEFINED BIN_INSTALL_DIR)
+if(NOT DEFINED LIB_INSTALL_DIR)
+ set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+endif(NOT DEFINED LIB_INSTALL_DIR)
+if(NOT DEFINED INCLUDE_INSTALL_DIR)
+ set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
+endif(NOT DEFINED INCLUDE_INSTALL_DIR)
+
+if(NOT DEFINED DATA_INSTALL_DIR)
+ set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share")
+endif(NOT DEFINED DATA_INSTALL_DIR)
+
+if(NOT DEFINED LOCALE_INSTALL_DIR)
+ set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale")
+endif(NOT DEFINED LOCALE_INSTALL_DIR)
+
+set(PCILIB_PLUGIN_DIR "${LIB_INSTALL_DIR}/pcilib")
+set(PCILIB_DATA_DIR "${DATA_INSTALL_DIR}/pcilib")
+set(PCILIB_MODEL_DIR "${PCILIB_DATA_DIR}/models")
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcitool.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pcitool.pc)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcilib/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcilib/config.h)
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/pcitool.pc
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+)
diff --git a/dma/ipe.h b/dma/ipe.h
index c647954..aa42f40 100644
--- a/dma/ipe.h
+++ b/dma/ipe.h
@@ -17,7 +17,7 @@ int dma_ipe_stop(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_
int dma_ipe_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, pcilib_dma_callback_t cb, void *cbattr);
double dma_ipe_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction);
-#ifdef _PCILIB_CONFIG_C
+#ifdef _PCILIB_EXPORT_C
static const pcilib_dma_api_description_t ipe_dma_api = {
dma_ipe_init,
dma_ipe_free,
@@ -79,7 +79,7 @@ static const pcilib_register_description_t ipe_dma_registers[] = {
{0x0060, 0, 32, 0, 0x00000000, PCILIB_REGISTER_RW , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "update_thresh", "Update threshold of progress register"},
{0, 0, 0, 0, 0x00000000, 0, 0, 0, NULL, NULL}
};
-#endif /* _PCILIB_CONFIG_C */
+#endif /* _PCILIB_EXPORT_C */
#endif /* _PCILIB_DMA_IPE_H */
diff --git a/dma/nwl.h b/dma/nwl.h
index 3d6e988..fceef4d 100644
--- a/dma/nwl.h
+++ b/dma/nwl.h
@@ -20,7 +20,7 @@ int dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma,
int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, pcilib_dma_callback_t cb, void *cbattr);
double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction);
-#ifdef _PCILIB_CONFIG_C
+#ifdef _PCILIB_EXPORT_C
static const pcilib_dma_api_description_t nwl_dma_api = {
dma_nwl_init,
dma_nwl_free,
@@ -75,7 +75,7 @@ static pcilib_register_description_t nwl_dma_registers[] = {
{0, 0, 0, 0, 0x00000000, 0, 0, 0, NULL, NULL}
};
-#endif /* _PCILIB_CONFIG_C */
+#endif /* _PCILIB_EXPORT_C */
#ifdef _PCILIB_DMA_NWL_C
// DMA Engine Registers
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index a437948..6930533 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -93,7 +93,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
do {
nwl_read_register(val, ctx, base, REG_DMA_ENG_CTRL_STATUS);
gettimeofday(&cur, NULL);
- } while ((val & (DMA_ENG_STATE_MASK|DMA_ENG_USER_RESET))&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_REGISTER_TIMEOUT));
+ } while ((val & (DMA_ENG_STATE_MASK|DMA_ENG_USER_RESET))&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_NWL_REGISTER_TIMEOUT));
if (val & (DMA_ENG_STATE_MASK|DMA_ENG_USER_RESET)) {
pcilib_error("Timeout during reset of DMA engine %i", ectx->desc->addr);
@@ -110,7 +110,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
do {
nwl_read_register(val, ctx, base, REG_DMA_ENG_CTRL_STATUS);
gettimeofday(&cur, NULL);
- } while ((val & DMA_ENG_RESET)&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_REGISTER_TIMEOUT));
+ } while ((val & DMA_ENG_RESET)&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_NWL_REGISTER_TIMEOUT));
if (val & DMA_ENG_RESET) {
pcilib_error("Timeout during reset of DMA engine %i", ectx->desc->addr);
@@ -183,7 +183,7 @@ int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
do {
nwl_read_register(val, ctx, base, REG_DMA_ENG_CTRL_STATUS);
gettimeofday(&cur, NULL);
- } while ((val & (DMA_ENG_RUNNING))&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_REGISTER_TIMEOUT));
+ } while ((val & (DMA_ENG_RUNNING))&&(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < PCILIB_NWL_REGISTER_TIMEOUT));
if (ectx->ring) {
ring_pa = pcilib_kmem_get_pa(ctx->dmactx.pcilib, ectx->ring);
diff --git a/dma/nwl_private.h b/dma/nwl_private.h
index 934fa04..1d60169 100644
--- a/dma/nwl_private.h
+++ b/dma/nwl_private.h
@@ -15,6 +15,8 @@ typedef struct pcilib_nwl_engine_context_s pcilib_nwl_engine_context_t;
#define PCILIB_NWL_DMA_DESCRIPTOR_SIZE 64 // in bytes
#define PCILIB_NWL_DMA_PAGES 256 // 1024
+#define PCILIB_NWL_REGISTER_TIMEOUT 10000 /**< us */
+
//#define DEBUG_HARDWARE
//#define DEBUG_NWL
diff --git a/pcilib/CMakeLists.txt b/pcilib/CMakeLists.txt
index c5297ab..df3dcd9 100644
--- a/pcilib/CMakeLists.txt
+++ b/pcilib/CMakeLists.txt
@@ -3,8 +3,8 @@ include_directories(
${CMAKE_SOURCE_DIR}/pcilib
)
-set(HEADERS pcilib.h pci.h config.h model.h bank.h register.h kmem.h irq.h dma.h event.h tools.h error.h)
-add_library(pcilib SHARED pci.c config.c model.c bank.c register.c kmem.c irq.c dma.c event.c tools.c error.c)
+set(HEADERS pcilib.h pci.h export.h model.h bank.h register.h kmem.h irq.h dma.h event.h tools.h error.h config.h)
+add_library(pcilib SHARED pci.c export.c model.c bank.c register.c kmem.c irq.c dma.c event.c tools.c error.c)
target_link_libraries(pcilib dma protocols ${CMAKE_THREAD_LIBS_INIT} ${UFODECODE_LIBRARIES} )
add_dependencies(pcilib dma protocols)
@@ -16,6 +16,6 @@ install(FILES pcilib.h
DESTINATION include
)
-install(FILES bank.h register.h dma.h event.h model.h error.h tools.h config.h
+install(FILES bank.h register.h dma.h event.h model.h error.h tools.h export.h
DESTINATION include/pcilib
)
diff --git a/pcilib/config.h.in b/pcilib/config.h.in
new file mode 100644
index 0000000..653fa56
--- /dev/null
+++ b/pcilib/config.h.in
@@ -0,0 +1,3 @@
+#cmakedefine PCILIB_PLUGIN_DIR "${PCILIB_PLUGIN_DIR}"
+#cmakedefine PCILIB_DATA_DIR "${PCILIB_DATA_DIR}"
+#cmakedefine PCILIB_MODEL_DIR "${PCILIB_MODEL_DIR}"
diff --git a/pcilib/dma.h b/pcilib/dma.h
index 83bc0fd..c6e240e 100644
--- a/pcilib/dma.h
+++ b/pcilib/dma.h
@@ -1,6 +1,10 @@
#ifndef _PCILIB_DMA_H
#define _PCILIB_DMA_H
+#include <pcilib.h>
+#include <pcilib/bank.h>
+#include <pcilib/register.h>
+
#define PCILIB_DMA_BUFFER_INVALID ((size_t)-1)
typedef struct {
diff --git a/pcilib/error.c b/pcilib/error.c
index f242209..9df7d9d 100644
--- a/pcilib/error.c
+++ b/pcilib/error.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include "config.h"
+#include "export.h"
#include "error.h"
void pcilib_print_error(const char *msg, ...) {
diff --git a/pcilib/event.h b/pcilib/event.h
index 93f659c..7ab3aae 100644
--- a/pcilib/event.h
+++ b/pcilib/event.h
@@ -2,6 +2,9 @@
#define _PCILIB_EVENT_H
#include <pcilib.h>
+#include <pcilib/dma.h>
+
+#define PCILIB_EVENT_INTERFACE_VERSION 0
typedef struct {
size_t max_events;
diff --git a/pcilib/config.c b/pcilib/export.c
index 21a0e53..2027870 100644
--- a/pcilib/config.c
+++ b/pcilib/export.c
@@ -1,9 +1,9 @@
-#define _PCILIB_CONFIG_C
+#define _PCILIB_EXPORT_C
#include <stdio.h>
#include "error.h"
-#include "config.h"
+#include "export.h"
#include "protocols/default.h"
@@ -20,12 +20,13 @@ const pcilib_register_protocol_description_t pcilib_protocols[] = {
#include "dma/nwl.h"
#include "dma/ipe.h"
-
+/*
const pcilib_dma_description_t pcilib_ipedma =
{ &ipe_dma_api, ipe_dma_banks, ipe_dma_registers, ipe_dma_engines, NULL, NULL, "ipedma", "DMA engine developed by M. Caselle" };
const pcilib_dma_description_t pcilib_nwldma =
{ &nwl_dma_api, nwl_dma_banks, nwl_dma_registers, NULL, NULL, NULL, "nwldma", "North West Logic DMA Engine" };
+*/
const pcilib_dma_description_t pcilib_dma[] = {
{ &ipe_dma_api, ipe_dma_banks, ipe_dma_registers, ipe_dma_engines, NULL, NULL, "ipedma", "DMA engine developed by M. Caselle" },
diff --git a/pcilib/config.h b/pcilib/export.h
index 710bff8..e2e6eca 100644
--- a/pcilib/config.h
+++ b/pcilib/export.h
@@ -1,5 +1,5 @@
-#ifndef _PCILIB_CONFIG_H
-#define _PCILIB_CONFIG_H
+#ifndef _PCILIB_EXPORT_H
+#define _PCILIB_EXPORT_H
#include <pcilib/register.h>
@@ -14,4 +14,4 @@ extern const pcilib_register_protocol_api_description_t pcilib_default_protocol_
extern const pcilib_dma_description_t pcilib_ipedma;
extern const pcilib_dma_description_t pcilib_nwldma;
-#endif /* _PCILIB_CONFIG_H */
+#endif /* _PCILIB_EXPORT_H */
diff --git a/pcilib/model.h b/pcilib/model.h
index 0b18c59..a12ea1a 100644
--- a/pcilib/model.h
+++ b/pcilib/model.h
@@ -5,9 +5,11 @@
#include <pcilib/register.h>
#include <pcilib/dma.h>
#include <pcilib/event.h>
-#include <pcilib/config.h>
+#include <pcilib/export.h>
typedef struct {
+ const unsigned int interface_version;
+
const pcilib_event_api_description_t *api;
const pcilib_dma_description_t *dma;
diff --git a/pcilib/pci.h b/pcilib/pci.h
index fe2ff8a..2e2b509 100644
--- a/pcilib/pci.h
+++ b/pcilib/pci.h
@@ -6,7 +6,6 @@
#define PCILIB_TRIGGER_TIMEOUT 100000 /**< us */
#define PCILIB_DMA_TIMEOUT 10000 /**< us */
#define PCILIB_DMA_SKIP_TIMEOUT 1000000 /**< us */
-#define PCILIB_REGISTER_TIMEOUT 10000 /**< us */
#define PCILIB_MAX_BARS 6 /**< this is defined by PCI specification */
#define PCILIB_DEFAULT_REGISTER_SPACE 1024 /**< number of registers to allocate on init */
#define PCILIB_MAX_REGISTER_BANKS 32 /**< maximum number of register banks to allocate space for */
@@ -24,7 +23,7 @@
#include "dma.h"
#include "event.h"
#include "model.h"
-#include "config.h"
+#include "export.h"
struct pcilib_s {
int handle; /**< file handle of device */
diff --git a/pcitool.pc.in b/pcitool.pc.in
new file mode 100644
index 0000000..7261c5f
--- /dev/null
+++ b/pcitool.pc.in
@@ -0,0 +1,12 @@
+prefix=${CMAKE_INSTALL_PREFIX}
+exec_prefix=${BIN_INSTALL_DIR}
+libdir=${LIB_INSTALL_DIR}
+includedir=${INCLUDE_INSTALL_DIR}
+plugindir=${PCILIB_PLUGIN_DIR}
+modeldir=${PCILIB_MODEL_DIR}
+
+Name: ${TARNAME}
+Description: User-space library to handle PCIe-devices
+Version: ${PACKAGE_VERSION}
+Libs: -L${LIB_INSTALL_DIR} -lpcilib
+Cflags: -I${INCLUDE_INSTALL_DIR}
diff --git a/protocols/default.h b/protocols/default.h
index f535550..6201176 100644
--- a/protocols/default.h
+++ b/protocols/default.h
@@ -7,9 +7,9 @@
int pcilib_default_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *value);
int pcilib_default_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t value);
-#ifdef _PCILIB_CONFIG_C
+#ifdef _PCILIB_EXPORT_C
const pcilib_register_protocol_api_description_t pcilib_default_protocol_api =
{ NULL, NULL, pcilib_default_read, pcilib_default_write };
-#endif /* _PCILIB_CONFIG_C */
+#endif /* _PCILIB_EXPORT_C */
#endif /* _PCILIB_DEFAULT_H */