summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-14 12:10:36 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-14 12:10:36 +0100
commit6f7f9467f76b21d418de8a4dafeac1ec4516e8d5 (patch)
tree16e1bce1646d7c5d91b8ed29e7836bdebf8d98a0
parentb26046f5a83a3933a99166762de03bf8e7a48d76 (diff)
parent625e502a76fe43808a1a054641b59b7a839855cf (diff)
downloadipecamera-6f7f9467f76b21d418de8a4dafeac1ec4516e8d5.tar.gz
ipecamera-6f7f9467f76b21d418de8a4dafeac1ec4516e8d5.tar.bz2
ipecamera-6f7f9467f76b21d418de8a4dafeac1ec4516e8d5.tar.xz
ipecamera-6f7f9467f76b21d418de8a4dafeac1ec4516e8d5.zip
Merge changes
-rw-r--r--cli.c2
-rw-r--r--pci.c29
-rw-r--r--pci.h1
-rw-r--r--pcilib.h4
4 files changed, 23 insertions, 13 deletions
diff --git a/cli.c b/cli.c
index 0bf6193..6301a01 100644
--- a/cli.c
+++ b/cli.c
@@ -452,7 +452,7 @@ int ReadRegisterRange(pcilib_t *handle, pcilib_model_t model, const char *bank,
}
if (i%numbers_per_line == 0) printf("%4lx: ", addr + i);
- printf("%0*lx", access * 2, buf[i]);
+ printf("%0*lx", access * 2, (unsigned long)buf[i]);
}
printf("\n\n");
}
diff --git a/pci.c b/pci.c
index 4919cbc..1ee99ce 100644
--- a/pci.c
+++ b/pci.c
@@ -202,7 +202,8 @@ int pcilib_write(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, v
static pcilib_register_bank_t pcilib_find_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank) {
pcilib_register_bank_t i;
- pcilib_register_bank_description_t *banks = pcilib_model[ctx->model].banks;
+ pcilib_model_t model = pcilib_get_model(ctx);
+ pcilib_register_bank_description_t *banks = pcilib_model[model].banks;
for (i = 0; banks[i].access; i++)
if (banks[i].addr == bank) return i;
@@ -225,7 +226,8 @@ pcilib_register_bank_t pcilib_find_bank(pcilib_t *ctx, const char *bank) {
unsigned long addr;
if (!bank) {
- pcilib_register_bank_description_t *banks = pcilib_model[ctx->model].banks;
+ pcilib_model_t model = pcilib_get_model(ctx);
+ pcilib_register_bank_description_t *banks = pcilib_model[model].banks;
if ((banks)&&(banks[0].access)) return (pcilib_register_bank_t)0;
return -1;
}
@@ -255,7 +257,7 @@ pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const ch
return -1;
}
- bank_addr = pcilib_model[ctx->model].banks[bank_id].addr;
+ bank_addr = pcilib_model[model].banks[bank_id].addr;
}
for (i = 0; registers[i].bits; i++) {
@@ -269,7 +271,8 @@ pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const ch
static int pcilib_map_register_space(pcilib_t *ctx) {
if (!ctx->reg_space) {
- pcilib_register_bank_description_t *banks = pcilib_model[ctx->model].banks;
+ pcilib_model_t model = pcilib_get_model(ctx);
+ pcilib_register_bank_description_t *banks = pcilib_model[model].banks;
if ((banks)&&(banks[0].access)) {
void *reg_space;
@@ -327,7 +330,8 @@ static int pcilib_read_register_space_internal(pcilib_t *ctx, pcilib_register_ba
int rest;
size_t i;
- pcilib_register_bank_description_t *b = pcilib_model[ctx->model].banks + bank;
+ pcilib_model_t model = pcilib_get_model(ctx);
+ pcilib_register_bank_description_t *b = pcilib_model[model].banks + bank;
assert(bits < 8 * sizeof(pcilib_register_value_t));
@@ -372,9 +376,10 @@ int pcilib_read_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_regi
pcilib_register_value_t res;
pcilib_register_description_t *r;
pcilib_register_bank_description_t *b;
+ pcilib_model_t model = pcilib_get_model(ctx);
- r = pcilib_model[ctx->model].registers + reg;
- b = pcilib_model[ctx->model].banks + r->bank;
+ r = pcilib_model[model].registers + reg;
+ b = pcilib_model[model].banks + r->bank;
n = r->bits / b->access;
bits = r->bits % b->access;
@@ -412,7 +417,7 @@ int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, p
return pcilib_read_register_by_id(ctx, reg, value);
// registers[reg].bank
-// printf("%li %li", sizeof(pcilib_model[ctx->model].banks), sizeof(pcilib_register_bank_description_t));
+// printf("%li %li", sizeof(pcilib_model[model].banks), sizeof(pcilib_register_bank_description_t));
}
@@ -421,7 +426,8 @@ static int pcilib_write_register_space_internal(pcilib_t *ctx, pcilib_register_b
int rest;
size_t i;
- pcilib_register_bank_description_t *b = pcilib_model[ctx->model].banks + bank;
+ pcilib_model_t model = pcilib_get_model(ctx);
+ pcilib_register_bank_description_t *b = pcilib_model[model].banks + bank;
assert(bits < 8 * sizeof(pcilib_register_value_t));
@@ -467,9 +473,10 @@ int pcilib_write_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_reg
pcilib_register_value_t res;
pcilib_register_description_t *r;
pcilib_register_bank_description_t *b;
+ pcilib_model_t model = pcilib_get_model(ctx);
- r = pcilib_model[ctx->model].registers + reg;
- b = pcilib_model[ctx->model].banks + r->bank;
+ r = pcilib_model[model].registers + reg;
+ b = pcilib_model[model].banks + r->bank;
n = r->bits / b->access;
bits = r->bits % b->access;
diff --git a/pci.h b/pci.h
index 74699cd..7da0a11 100644
--- a/pci.h
+++ b/pci.h
@@ -29,7 +29,6 @@ pcilib_protocol_description_t pcilib_protocol[3] = {
extern void (*pcilib_error)(const char *msg, ...);
extern void (*pcilib_warning)(const char *msg, ...);
-extern pcilib_model_description_t pcilib_model[];
extern pcilib_protocol_description_t pcilib_protocol[];
#endif /* _PCILIB_PCI_C */
diff --git a/pcilib.h b/pcilib.h
index 7541c80..b1288a8 100644
--- a/pcilib.h
+++ b/pcilib.h
@@ -99,6 +99,10 @@ typedef struct {
pcilib_register_range_t *ranges;
} pcilib_model_description_t;
+#ifndef _PCILIB_PCI_C
+extern pcilib_model_description_t pcilib_model[];
+#endif /* ! _PCILIB_PCI_C */
+
int pcilib_set_error_handler(void (*err)(const char *msg, ...));
pcilib_model_t pcilib_get_model(pcilib_t *ctx);