From 7356cb9627e941e66dbd90b6cc670a8427c88c5e Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 28 Apr 2015 06:09:21 +0200 Subject: Initial support for event engines --- pcilib/bank.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'pcilib/bank.c') 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); -- cgit v1.2.3