summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--CMakeLists.txt8
-rw-r--r--cmake/version.cmake12
-rw-r--r--dma/ipe.h2
-rw-r--r--dma/nwl.h2
-rw-r--r--pcilib/CMakeLists.txt4
-rw-r--r--pcilib/bank.h2
-rw-r--r--pcilib/dma.h2
-rw-r--r--pcilib/event.h5
-rw-r--r--pcilib/model.h3
-rw-r--r--pcilib/pcilib.h2
-rw-r--r--pcilib/plugin.c2
-rw-r--r--pcilib/version.h.in15
-rw-r--r--pcitool/cli.c10
-rw-r--r--protocols/default.h3
15 files changed, 65 insertions, 8 deletions
diff --git a/.bzrignore b/.bzrignore
index a32f269..5f9fdaa 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -28,3 +28,4 @@ apps/lorenzo_ipedma_test
pcitool.pc
config.h
pcitool/pci
+version.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d73596b..aa64112 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 2.6)
set(DISABLE_PCITOOL FALSE CACHE BOOL "Build only the library")
+#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
@@ -19,6 +20,10 @@ endif (NOT DISABLE_PCITOOL)
add_definitions("-fPIC --std=c99 -Wall -O2 -gdwarf-2 -g3")
#add_definitions("-fPIC --std=c99 -Wall -O2")
+include(cmake/version.cmake)
+VERSION_TO_VARS(${PCILIB_VERSION} PCILIB_VERSION_MAJOR PCILIB_VERSION_MINOR PCILIB_VERSION_MICRO)
+
+
add_subdirectory(dma)
add_subdirectory(protocols)
add_subdirectory(pcilib)
@@ -64,8 +69,11 @@ set(PCILIB_DEBUG_DIR "." CACHE PATH "Directory to write debug information")
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)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcilib/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcilib/version.h)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pcitool.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
)
+
+message("-- Configured pcitool ${PCILIB_VERSION_MAJOR}.${PCILIB_VERSION_MINOR}.${PCILIB_VERSION_MICRO} with public ABI ${PCILIB_ABI_VERSION}")
diff --git a/cmake/version.cmake b/cmake/version.cmake
new file mode 100644
index 0000000..9023aef
--- /dev/null
+++ b/cmake/version.cmake
@@ -0,0 +1,12 @@
+SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+")
+
+MACRO(VERSION_TO_VARS version major minor patch)
+ IF(${version} MATCHES ${VERSION_REGEX})
+ STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ${major} "${version}")
+ STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ${minor} "${version}")
+ STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ${patch} "${version}")
+ ELSE(${version} MATCHES ${VERSION_REGEX})
+ MESSAGE("MACRO(VERSION_TO_VARS ${version} ${major} ${minor} ${patch}")
+ MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.")
+ ENDIF(${version} MATCHES ${VERSION_REGEX})
+ENDMACRO(VERSION_TO_VARS)
diff --git a/dma/ipe.h b/dma/ipe.h
index aa42f40..6e05fe1 100644
--- a/dma/ipe.h
+++ b/dma/ipe.h
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "pcilib.h"
+#include "version.h"
//#define PCILIB_NWL_MODIFICATION_IPECAMERA 0x100
@@ -19,6 +20,7 @@ double dma_ipe_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
#ifdef _PCILIB_EXPORT_C
static const pcilib_dma_api_description_t ipe_dma_api = {
+ PCILIB_VERSION,
dma_ipe_init,
dma_ipe_free,
dma_ipe_get_status,
diff --git a/dma/nwl.h b/dma/nwl.h
index fceef4d..bf955f3 100644
--- a/dma/nwl.h
+++ b/dma/nwl.h
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "pcilib.h"
+#include "version.h"
pcilib_dma_context_t *dma_nwl_init(pcilib_t *ctx, const char *model, const void *arg);
void dma_nwl_free(pcilib_dma_context_t *vctx);
@@ -22,6 +23,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
#ifdef _PCILIB_EXPORT_C
static const pcilib_dma_api_description_t nwl_dma_api = {
+ PCILIB_VERSION,
dma_nwl_init,
dma_nwl_free,
dma_nwl_get_status,
diff --git a/pcilib/CMakeLists.txt b/pcilib/CMakeLists.txt
index b1b56bf..eb86762 100644
--- a/pcilib/CMakeLists.txt
+++ b/pcilib/CMakeLists.txt
@@ -3,7 +3,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/pcilib
)
-set(HEADERS pcilib.h pci.h export.h model.h bank.h register.h kmem.h irq.h dma.h event.h plugin.h tools.h error.h debug.h config.h)
+set(HEADERS pcilib.h pci.h export.h model.h bank.h register.h kmem.h irq.h dma.h event.h plugin.h tools.h error.h debug.h version.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 plugin.c tools.c error.c debug.c)
target_link_libraries(pcilib dma protocols ${CMAKE_THREAD_LIBS_INIT} ${UFODECODE_LIBRARIES} ${CMAKE_DL_LIBS})
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 debug.h tools.h export.h
+install(FILES bank.h register.h dma.h event.h model.h error.h debug.h tools.h export.h version.h
DESTINATION include/pcilib
)
diff --git a/pcilib/bank.h b/pcilib/bank.h
index 995d38f..943c389 100644
--- a/pcilib/bank.h
+++ b/pcilib/bank.h
@@ -25,6 +25,8 @@ typedef uint8_t pcilib_register_protocol_addr_t; /**< Type holding the protoc
typedef struct pcilib_register_bank_context_s pcilib_register_bank_context_t;
typedef struct {
+ pcilib_version_t version;
+
pcilib_register_bank_context_t *(*init)(pcilib_t *ctx, pcilib_register_bank_t bank, const char *model, const void *args); /**< Optional API call to initialize bank context */
void (*free)(pcilib_register_bank_context_t *ctx); /**< Optional API call to cleanup bank context */
int (*read)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t *value); /**< Read from register, mandatory for RO/RW registers */
diff --git a/pcilib/dma.h b/pcilib/dma.h
index c6e240e..85eb943 100644
--- a/pcilib/dma.h
+++ b/pcilib/dma.h
@@ -49,6 +49,8 @@ typedef struct {
} pcilib_dma_context_t;
typedef struct {
+ pcilib_version_t version;
+
pcilib_dma_context_t *(*init)(pcilib_t *ctx, const char *model, const void *arg);
void (*free)(pcilib_dma_context_t *ctx);
diff --git a/pcilib/event.h b/pcilib/event.h
index 7ab3aae..ca7c27f 100644
--- a/pcilib/event.h
+++ b/pcilib/event.h
@@ -2,9 +2,10 @@
#define _PCILIB_EVENT_H
#include <pcilib.h>
+#include <pcilib/version.h>
#include <pcilib/dma.h>
-#define PCILIB_EVENT_INTERFACE_VERSION 0
+#define PCILIB_EVENT_INTERFACE_VERSION PCILIB_VERSION
typedef struct {
size_t max_events;
@@ -68,6 +69,8 @@ typedef enum {
*/
typedef struct {
+ pcilib_version_t version;
+
pcilib_context_t *(*init)(pcilib_t *ctx);
void (*free)(pcilib_context_t *ctx);
diff --git a/pcilib/model.h b/pcilib/model.h
index a12ea1a..ab55adc 100644
--- a/pcilib/model.h
+++ b/pcilib/model.h
@@ -7,8 +7,9 @@
#include <pcilib/event.h>
#include <pcilib/export.h>
+
typedef struct {
- const unsigned int interface_version;
+ const pcilib_version_t interface_version;
const pcilib_event_api_description_t *api;
const pcilib_dma_description_t *dma;
diff --git a/pcilib/pcilib.h b/pcilib/pcilib.h
index f5853d3..6d241c6 100644
--- a/pcilib/pcilib.h
+++ b/pcilib/pcilib.h
@@ -9,6 +9,8 @@
typedef struct pcilib_s pcilib_t;
typedef struct pcilib_event_context_s pcilib_context_t;
+typedef uint32_t pcilib_version_t;
+
typedef uint8_t pcilib_bar_t; /**< Type holding the PCI Bar number */
typedef uint16_t pcilib_register_t; /**< Type holding the register position within the field listing registers in the model */
typedef uint32_t pcilib_register_addr_t; /**< Type holding the register address within address-space of BARs */
diff --git a/pcilib/plugin.c b/pcilib/plugin.c
index 12dbf1d..3202e95 100644
--- a/pcilib/plugin.c
+++ b/pcilib/plugin.c
@@ -53,7 +53,7 @@ const pcilib_model_description_t *pcilib_get_plugin_model(pcilib_t *pcilib, void
model_info = ((const pcilib_model_description_t *(*)(pcilib_t *pcilib, unsigned short vendor_id, unsigned short device_id, const char *model))get_model)(pcilib, vendor_id, device_id, model);
if (!model_info) return model_info;
- if (model_info->interface_version != PCILIB_EVENT_INTERFACE_VERSION) {
+ if ((PCILIB_VERSION_GET_MAJOR(model_info->interface_version) != PCILIB_VERSION_MAJOR)||(PCILIB_VERSION_GET_MINOR(model_info->interface_version) != PCILIB_VERSION_MINOR)) {
pcilib_warning("Plugin %s exposes outdated interface version (%lu), pcitool supports (%lu)", model_info->name, model_info->interface_version, PCILIB_EVENT_INTERFACE_VERSION);
return NULL;
}
diff --git a/pcilib/version.h.in b/pcilib/version.h.in
new file mode 100644
index 0000000..6eb3b20
--- /dev/null
+++ b/pcilib/version.h.in
@@ -0,0 +1,15 @@
+#ifndef _PCILIB_VERSION_H
+#define _PCILIB_VERSION_H
+
+#define PCILIB_VERSION_MAJOR ${PCILIB_VERSION_MAJOR}
+#define PCILIB_VERSION_MINOR ${PCILIB_VERSION_MINOR}
+#define PCILIB_VERSION_MICRO ${PCILIB_VERSION_MICRO}
+
+#define PCILIB_MAKE_VERSION(major, minor, micro) ((major<<16)|(minor<<8)|(micro))
+#define PCILIB_VERSION_GET_MAJOR(version) ((version>>16)&&0xFF)
+#define PCILIB_VERSION_GET_MINOR(version) ((version>>8)&&0xFF)
+#define PCILIB_VERSION_GET_MICRO(version) ((version)&&0xFF)
+
+#define PCILIB_VERSION PCILIB_MAKE_VERSION(PCILIB_VERSION_MAJOR, PCILIB_VERSION_MINOR, PCILIB_VERSION_MICRO)
+
+#endif /* _PCILIB_VERSION_H */
diff --git a/pcitool/cli.c b/pcitool/cli.c
index a8f1e35..75249f1 100644
--- a/pcitool/cli.c
+++ b/pcitool/cli.c
@@ -550,8 +550,14 @@ void Info(pcilib_t *handle, const pcilib_model_description_t *model_info) {
info = pcilib_get_plugin_model(handle, plugin, 0, 0, NULL);
if (info) {
printf(" %s\n", entry->d_name);
- for (j = 0; info[j].name; j++)
- printf(" %-12s - %s\n", info[j].name, info[j].description?info[j].description:"");
+ for (j = 0; info[j].name; j++) {
+ pcilib_version_t version = info[j].api->version;
+ printf(" %-12s %u.%u.%u - %s\n", info[j].name,
+ PCILIB_VERSION_GET_MAJOR(version),
+ PCILIB_VERSION_GET_MINOR(version),
+ PCILIB_VERSION_GET_MICRO(version),
+ info[j].description?info[j].description:"");
+ }
}
pcilib_plugin_close(plugin);
} else {
diff --git a/protocols/default.h b/protocols/default.h
index 6201176..c3e6d06 100644
--- a/protocols/default.h
+++ b/protocols/default.h
@@ -2,6 +2,7 @@
#define _PCILIB_DEFAULT_H
#include "pcilib.h"
+#include "version.h"
#include "model.h"
int pcilib_default_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *value);
@@ -9,7 +10,7 @@ int pcilib_default_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pc
#ifdef _PCILIB_EXPORT_C
const pcilib_register_protocol_api_description_t pcilib_default_protocol_api =
- { NULL, NULL, pcilib_default_read, pcilib_default_write };
+ { PCILIB_VERSION, NULL, NULL, pcilib_default_read, pcilib_default_write };
#endif /* _PCILIB_EXPORT_C */
#endif /* _PCILIB_DEFAULT_H */