diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/CMakeLists.txt | 4 | ||||
-rw-r--r-- | protocols/default.h | 6 | ||||
-rw-r--r-- | protocols/property.c | 42 | ||||
-rw-r--r-- | protocols/property.h | 16 | ||||
-rw-r--r-- | protocols/software.h | 8 |
5 files changed, 67 insertions, 9 deletions
diff --git a/protocols/CMakeLists.txt b/protocols/CMakeLists.txt index 6c72698..e66ce3a 100644 --- a/protocols/CMakeLists.txt +++ b/protocols/CMakeLists.txt @@ -8,6 +8,6 @@ include_directories( ${UTHASH_INCLUDE_DIRS} ) -set(HEADERS ${HEADERS} default.h software.h) +set(HEADERS ${HEADERS} default.h software.h property.h) -add_library(protocols STATIC default.c software.c) +add_library(protocols STATIC default.c software.c property.c) diff --git a/protocols/default.h b/protocols/default.h index c3e6d06..829b65d 100644 --- a/protocols/default.h +++ b/protocols/default.h @@ -1,5 +1,5 @@ -#ifndef _PCILIB_DEFAULT_H -#define _PCILIB_DEFAULT_H +#ifndef _PCILIB_PROTOCOL_DEFAULT_H +#define _PCILIB_PROTOCOL_DEFAULT_H #include "pcilib.h" #include "version.h" @@ -13,4 +13,4 @@ const pcilib_register_protocol_api_description_t pcilib_default_protocol_api = { PCILIB_VERSION, NULL, NULL, pcilib_default_read, pcilib_default_write }; #endif /* _PCILIB_EXPORT_C */ -#endif /* _PCILIB_DEFAULT_H */ +#endif /* _PCILIB_PROTOCOL_DEFAULT_H */ diff --git a/protocols/property.c b/protocols/property.c new file mode 100644 index 0000000..0c7cf5d --- /dev/null +++ b/protocols/property.c @@ -0,0 +1,42 @@ +#include <sys/time.h> +#include <arpa/inet.h> +#include <assert.h> + +#include "pci.h" +#include "tools.h" +#include "model.h" +#include "error.h" + + +int pcilib_property_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *regval) { + int err; + + pcilib_view_t view = addr; + pcilib_value_t val = {0}; + + if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)) + return PCILIB_ERROR_INVALID_ARGUMENT; + + err = pcilib_get_property(ctx, ctx->views[view]->name, &val); + if (err) return err; + + *regval = pcilib_get_value_as_register_value(ctx, &val, &err); + + return err; +} + + +int pcilib_property_registers_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t regval) { + int err; + + pcilib_view_t view = addr; + pcilib_value_t val = {0}; + + if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)) + return PCILIB_ERROR_INVALID_ARGUMENT; + + err = pcilib_set_value_from_register_value(ctx, &val, regval); + if (err) return err; + + return pcilib_set_property(ctx, ctx->views[view]->name, &val); +} diff --git a/protocols/property.h b/protocols/property.h new file mode 100644 index 0000000..3d3eb63 --- /dev/null +++ b/protocols/property.h @@ -0,0 +1,16 @@ +#ifndef _PCILIB_PROTOCOL_PROPERTY_H +#define _PCILIB_PROTOCOL_PROPERTY_H + +#include "pcilib.h" +#include "version.h" +#include "model.h" + +int pcilib_property_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *value); +int pcilib_property_registers_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t value); + +#ifdef _PCILIB_EXPORT_C +const pcilib_register_protocol_api_description_t pcilib_property_protocol_api = + { PCILIB_VERSION, NULL, NULL, pcilib_property_registers_read, pcilib_property_registers_write }; +#endif /* _PCILIB_EXPORT_C */ + +#endif /* _PCILIB_PROTOCOL_PROPERTY_H */ diff --git a/protocols/software.h b/protocols/software.h index 484e344..27ab86e 100644 --- a/protocols/software.h +++ b/protocols/software.h @@ -3,8 +3,8 @@ * @brief header file for implementation of the protocol with software registers allocated in the kernel space, for parameters sharing between concurrent pcitool instances */ -#ifndef _PCILIB_SOFTWARE_H -#define _PCILIB_SOFTWARE_H +#ifndef _PCILIB_PROTOCOL_SOFTWARE_H +#define _PCILIB_PROTOCOL_SOFTWARE_H #include "pcilib.h" #include "version.h" @@ -51,8 +51,8 @@ int pcilib_software_registers_write(pcilib_t *ctx,pcilib_register_bank_context_t /** * software protocol addition to the protocol api. */ -const pcilib_register_protocol_api_description_t pcilib_register_software_protocol_api = +const pcilib_register_protocol_api_description_t pcilib_software_protocol_api = { PCILIB_VERSION, pcilib_software_registers_open, pcilib_software_registers_close,pcilib_software_registers_read, pcilib_software_registers_write }; /**< we add there the protocol to the list of possible protocols*/ #endif /* _PCILIB_EXPORT_C */ -#endif /* _PCILIB_SOFTWARE_H */ +#endif /* _PCILIB_PROTOCOL_SOFTWARE_H */ |