diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-10-19 15:58:46 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-10-19 15:58:46 +0200 |
commit | 55255f2ce3a2234850249efcabd9ba32d0a89a9c (patch) | |
tree | 586d075665bebbb698e3a84eee6595f47401997f /protocols/property.c | |
parent | 87ef1499bfcaa0ea2a58cb6d3c327162507f6ac8 (diff) | |
download | pcitool-55255f2ce3a2234850249efcabd9ba32d0a89a9c.tar.gz pcitool-55255f2ce3a2234850249efcabd9ba32d0a89a9c.tar.bz2 pcitool-55255f2ce3a2234850249efcabd9ba32d0a89a9c.tar.xz pcitool-55255f2ce3a2234850249efcabd9ba32d0a89a9c.zip |
Support computed (property-based) registers
Diffstat (limited to 'protocols/property.c')
-rw-r--r-- | protocols/property.c | 42 |
1 files changed, 42 insertions, 0 deletions
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); +} |