diff options
-rw-r--r-- | cli.c | 9 | ||||
-rw-r--r-- | ipecamera/model.h | 6 | ||||
-rw-r--r-- | pcilib.h | 3 | ||||
-rw-r--r-- | register.c | 10 |
4 files changed, 22 insertions, 6 deletions
@@ -1537,7 +1537,14 @@ int main(int argc, char **argv) { if ((start >= ranges[i].start)&&(start <= ranges[i].end)) break; // register access in plain mode - if (ranges[i].start != ranges[i].end) ++mode; + if (ranges[i].start != ranges[i].end) { + pcilib_register_bank_t regbank = pcilib_find_bank_by_addr(handle, ranges[i].bank); + if (regbank == PCILIB_REGISTER_BANK_INVALID) Error("Configuration error: register bank specified in the address range is not found"); + + bank = model_info->banks[regbank].name; + start += ranges[i].addr_shift; + ++mode; + } } } else { if (pcilib_find_register(handle, bank, addr) == PCILIB_REGISTER_INVALID) { diff --git a/ipecamera/model.h b/ipecamera/model.h index 2dec30a..91f68ed 100644 --- a/ipecamera/model.h +++ b/ipecamera/model.h @@ -72,7 +72,7 @@ pcilib_register_description_t ipecamera_registers[] = { {112, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "adc_resolution", ""}, {115, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "special_115", ""}, /*{126, 0, 16, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "temp", ""},*/ -{0, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_input", ""}, +{0x00, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_input", ""}, {0x10, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_output", ""}, {0x20, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_clk_speed", ""}, {0x30, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "firmware_version", ""}, @@ -88,7 +88,9 @@ pcilib_register_description_t ipecamera_registers[] = { }; pcilib_register_range_t ipecamera_register_ranges[] = { - {0, 128, PCILIB_REGISTER_BANK0}, {0, 0, 0} + {0, 128, PCILIB_REGISTER_BANK0, 0}, + {0x9000, 0x9FFF, PCILIB_REGISTER_BANK1, -0x9000}, + {0, 0, 0, 0} }; pcilib_event_description_t ipecamera_events[] = { @@ -146,7 +146,8 @@ typedef struct { typedef struct { uintptr_t start; uintptr_t end; - pcilib_register_bank_t bank; + pcilib_register_bank_addr_t bank; + long addr_shift; } pcilib_register_range_t; typedef struct { @@ -145,7 +145,10 @@ static int pcilib_read_register_space_internal(pcilib_t *ctx, pcilib_register_ba assert(bits < 8 * sizeof(pcilib_register_value_t)); if (((addr + n) > b->size)||(((addr + n) == b->size)&&(bits))) { - pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); + if ((b->format)&&(strchr(b->format, 'x'))) + pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); + else + pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); return PCILIB_ERROR_OUTOFRANGE; } @@ -250,7 +253,10 @@ static int pcilib_write_register_space_internal(pcilib_t *ctx, pcilib_register_b assert(bits < 8 * sizeof(pcilib_register_value_t)); if (((addr + n) > b->size)||(((addr + n) == b->size)&&(bits))) { - pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); + if ((b->format)&&(strchr(b->format, 'x'))) + pcilib_error("Accessing register (%u regs at addr 0x%x) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); + else + pcilib_error("Accessing register (%u regs at addr %u) out of register space (%u registers total)", bits?(n+1):n, addr, b->size); return PCILIB_ERROR_OUTOFRANGE; } |