/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/register.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-22 13:57:59 UTC
  • Revision ID: csa@suren.me-20151022135759-nqs5wowy38tvbw09
Documentation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
        return PCILIB_ERROR_NOTSUPPORTED;
175
175
    }
176
176
 
177
 
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) space_size = ctx->num_views;
 
177
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) space_size = ctx->num_views * access;
178
178
    else space_size = b->size;
179
179
 
180
 
    if (((addr + n) > space_size)||(((addr + n) == space_size)&&(bits))) {
 
180
    if (((addr + n * access) > space_size)||(((addr + n * access) == space_size)&&(bits))) {
181
181
        if ((b->format)&&(strchr(b->format, 'x')))
182
 
            pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u registers total)", bits?(n+1):n, addr, space_size);
 
182
            pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u %u-bit registers total)", bits?(n+1):n, addr, space_size / access, access * 8);
183
183
        else 
184
 
            pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, space_size);
 
184
            pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u %u-bit registers total)", bits?(n+1):n, addr, space_size / access, access * 8);
185
185
        return PCILIB_ERROR_OUTOFRANGE;
186
186
    }
187
187
 
285
285
}
286
286
 
287
287
 
288
 
static int pcilib_write_register_space_internal(pcilib_t *ctx, pcilib_register_bank_t bank, pcilib_register_addr_t addr, size_t n, pcilib_register_size_t offset, pcilib_register_size_t bits, pcilib_register_value_t rwmask, pcilib_register_value_t *buf) {
 
288
static int pcilib_write_register_space_internal(pcilib_t *ctx, pcilib_register_bank_t bank, pcilib_register_addr_t addr, size_t n, pcilib_register_size_t offset, pcilib_register_size_t bits, pcilib_register_value_t rwmask, const pcilib_register_value_t *buf) {
289
289
    int err;
290
290
 
291
291
    size_t i;
304
304
        return PCILIB_ERROR_NOTSUPPORTED;
305
305
    }
306
306
 
307
 
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) space_size = ctx->num_views;
 
307
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) space_size = ctx->num_views * access;
308
308
    else space_size = b->size;
309
309
 
310
 
    if (((addr + n) > space_size)||(((addr + n) == space_size)&&(bits))) {
 
310
    if (((addr + n * access) > space_size)||(((addr + n * access) == space_size)&&(bits))) {
311
311
        if ((b->format)&&(strchr(b->format, 'x')))
312
 
            pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u registers total)", bits?(n+1):n, addr, space_size);
 
312
            pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u %u-bit registers total)", bits?(n+1):n, addr, space_size / access, access * 8);
313
313
        else 
314
 
            pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, space_size);
 
314
            pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u %u-bit registers total)", bits?(n+1):n, addr, space_size / access, access * 8);
315
315
        return PCILIB_ERROR_OUTOFRANGE;
316
316
    }
317
317
 
364
364
    return err;
365
365
}
366
366
 
367
 
int pcilib_write_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf) {
 
367
int pcilib_write_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, const pcilib_register_value_t *buf) {
368
368
    pcilib_register_bank_t bank_id = pcilib_find_register_bank(ctx, bank);
369
369
    if (bank_id == PCILIB_REGISTER_BANK_INVALID) {
370
370
        if (bank) pcilib_error("Invalid register bank is specified (%s)", bank);