summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-05-02 14:45:42 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-05-02 14:45:42 +0200
commit5387063faa68d774e2f586e6d8284520f3cde12f (patch)
treec849a07034fe0ba9880fdf8db27972925f93c75a /pcilib
parent92b8fe6e949f08308d237e87441e066a19a9eda6 (diff)
downloadpcitool-5387063faa68d774e2f586e6d8284520f3cde12f.tar.gz
pcitool-5387063faa68d774e2f586e6d8284520f3cde12f.tar.bz2
pcitool-5387063faa68d774e2f586e6d8284520f3cde12f.tar.xz
pcitool-5387063faa68d774e2f586e6d8284520f3cde12f.zip
Include version information in all API descriptions
Diffstat (limited to 'pcilib')
-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
8 files changed, 30 insertions, 5 deletions
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 */