diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-04-28 06:09:21 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-04-28 06:09:21 +0200 |
commit | 7356cb9627e941e66dbd90b6cc670a8427c88c5e (patch) | |
tree | 2849fd936a65b3bdfbd77968a588ac6338790022 /pcilib/bank.c | |
parent | 8d3ad26d8331c43659d0d4e77e8a50fbc3cfc1e4 (diff) | |
download | pcitool-7356cb9627e941e66dbd90b6cc670a8427c88c5e.tar.gz pcitool-7356cb9627e941e66dbd90b6cc670a8427c88c5e.tar.bz2 pcitool-7356cb9627e941e66dbd90b6cc670a8427c88c5e.tar.xz pcitool-7356cb9627e941e66dbd90b6cc670a8427c88c5e.zip |
Initial support for event engines
Diffstat (limited to 'pcilib/bank.c')
-rw-r--r-- | pcilib/bank.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/pcilib/bank.c b/pcilib/bank.c index 91bd161..dbbb427 100644 --- a/pcilib/bank.c +++ b/pcilib/bank.c @@ -78,7 +78,7 @@ void pcilib_free_register_banks(pcilib_t *ctx) { int pcilib_add_register_banks(pcilib_t *ctx, size_t n, const pcilib_register_bank_description_t *banks) { - // DS: What we are doing if bank exists? + // DS: Override existing banks if (!n) { for (n = 0; banks[n].access; n++); @@ -87,7 +87,6 @@ int pcilib_add_register_banks(pcilib_t *ctx, size_t n, const pcilib_register_ban if ((ctx->num_banks + n + 1) > PCILIB_MAX_REGISTER_BANKS) return PCILIB_ERROR_TOOBIG; - memset(ctx->banks + ctx->num_banks + n, 0, sizeof(pcilib_register_bank_description_t)); memcpy(ctx->banks + ctx->num_banks, banks, n * sizeof(pcilib_register_bank_description_t)); ctx->num_banks += n; @@ -101,6 +100,39 @@ int pcilib_add_register_banks(pcilib_t *ctx, size_t n, const pcilib_register_ban return 0; } +int pcilib_add_register_protocols(pcilib_t *ctx, size_t n, const pcilib_register_protocol_description_t *protocols) { + // DS: Override existing banks + + if (!n) { + for (n = 0; protocols[n].api; n++); + } + + if ((ctx->num_protocols + n + 1) > PCILIB_MAX_REGISTER_PROTOCOLS) + return PCILIB_ERROR_TOOBIG; + + memcpy(ctx->protocols + ctx->num_protocols, protocols, n * sizeof(pcilib_register_protocol_description_t)); + ctx->num_protocols += n; + + return 0; +} + + +int pcilib_add_register_ranges(pcilib_t *ctx, size_t n, const pcilib_register_range_t *ranges) { + // DS: Override existing banks + + if (!n) { + for (n = 0; ranges[n].end; n++); + } + + if ((ctx->num_ranges + n + 1) > PCILIB_MAX_REGISTER_RANGES) + return PCILIB_ERROR_TOOBIG; + + memcpy(ctx->ranges + ctx->num_ranges, ranges, n * sizeof(pcilib_register_range_t)); + ctx->num_ranges += n; + + return 0; +} + pcilib_register_bank_t pcilib_find_register_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank) { pcilib_register_bank_t i; const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx); |