From 5a7bcf11b8e3168900a75e7cbf3b1e18f424d271 Mon Sep 17 00:00:00 2001 From: zilio nicolas Date: Tue, 7 Jul 2015 14:03:39 +0200 Subject: some modif --- pcilib/bar.c | 1 + pcilib/pci.c | 7 +++++++ pcilib/register.c | 12 +++++++++++- pcilib/xml.c | 8 ++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'pcilib') diff --git a/pcilib/bar.c b/pcilib/bar.c index ce04f6d..2c7a8d4 100644 --- a/pcilib/bar.c +++ b/pcilib/bar.c @@ -120,6 +120,7 @@ void pcilib_unmap_bar(pcilib_t *ctx, pcilib_bar_t bar, void *data) { } int pcilib_map_register_space(pcilib_t *ctx) { + printf("mapping\n"); int err; pcilib_register_bank_t i; diff --git a/pcilib/pci.c b/pcilib/pci.c index 5312922..76bd59f 100644 --- a/pcilib/pci.c +++ b/pcilib/pci.c @@ -294,6 +294,7 @@ int pcilib_map_data_space(pcilib_t *ctx, uintptr_t addr) { char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr) { if (bar == PCILIB_BAR_DETECT) { + printf("bar = PCILIB_BAR_DETECT\n"); // First checking the default register bar size_t offset = addr - ctx->board_info.bar_start[ctx->reg_bar]; if ((addr > ctx->board_info.bar_start[ctx->reg_bar])&&(offset < ctx->board_info.bar_length[ctx->reg_bar])) { @@ -308,6 +309,7 @@ char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t // Otherwise trying to detect bar = pcilib_detect_bar(ctx, addr, 1); if (bar != PCILIB_BAR_INVALID) { + printf("bar pas ainvalid\n"); size_t offset = addr - ctx->board_info.bar_start[bar]; if ((offset < ctx->board_info.bar_length[bar])&&(ctx->bar_space[bar])) { if (!ctx->bar_space[bar]) { @@ -318,16 +320,21 @@ char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t } } } else { + printf("bar internal :%i\n",bar); + // printf("bar invalid\n"); if (!ctx->bar_space[bar]) { pcilib_error("The requested bar (%i) is not mapped", bar); return NULL; } if (addr < ctx->board_info.bar_length[bar]) { + printf("path1\n"); + // printf("apres: %s\n",ctx->bar_space[bar] + addr); return ctx->bar_space[bar] + addr + (ctx->board_info.bar_start[bar] & ctx->page_mask); } if ((addr >= ctx->board_info.bar_start[bar])&&(addr < (ctx->board_info.bar_start[bar] + ctx->board_info.bar_length[ctx->reg_bar]))) { + printf("path2\n"); return ctx->bar_space[bar] + (addr - ctx->board_info.bar_start[bar]) + (ctx->board_info.bar_start[bar] & ctx->page_mask); } } diff --git a/pcilib/register.c b/pcilib/register.c index 347bf7c..5909991 100644 --- a/pcilib/register.c +++ b/pcilib/register.c @@ -91,16 +91,22 @@ static int pcilib_read_register_space_internal(pcilib_t *ctx, pcilib_register_ba for (i = 0; i < n; i++) { err = bapi->read(ctx, bctx, addr + i * access, buf + i); + printf("buf +i: %i \n",buf[i]); + if(err) printf("err internal 1: %i\n",err); if (err) break; } if ((bits > 0)&&(!err)) { pcilib_register_value_t val = 0; err = bapi->read(ctx, bctx, addr + n * access, &val); - + val = (val >> offset)&BIT_MASK(bits); + printf("val : %i\n",val); memcpy(buf + n, &val, sizeof(pcilib_register_value_t)); + if(err) printf("err internal 2: %i\n",err); } + printf("err internal 3: %i\n",err); + printf("buf internal: %i\n",buf[0]); return err; } @@ -143,14 +149,18 @@ int pcilib_read_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_regi pcilib_error("Big-endian byte order support is not implemented"); return PCILIB_ERROR_NOTSUPPORTED; } else { + printf("bits: %i, n %lu\n",bits, n); res = 0; if (bits) ++n; for (i = 0; i < n; i++) { + printf("res: %i buf[i]: %i\n",res,buf[i]); res |= buf[i] << (i * b->access); + printf("res: %i \n",res); } } *value = res; + printf("value : %i\n",*value); return err; } diff --git a/pcilib/xml.c b/pcilib/xml.c index a9be502..205b563 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -306,8 +306,12 @@ void pcilib_xml_create_bank(pcilib_register_bank_description_t *mybank,xmlChar* if(strcmp((char*)bar,"0")==0){ mybank->bar=PCILIB_BAR0; - }else if(strcmp((char*)bar,"ipecamera_register")==0){ + }else if(strcmp((char*)bar,"1")==0){ mybank->bar=PCILIB_BAR1; + }else if(strcmp((char*)bar,"no_bar")==0){ + mybank->bar=PCILIB_BAR_NOBAR; + }else{ + mybank->bar=PCILIB_BAR_INVALID; } mybank->bar=(pcilib_bar_t)strtol((char*)bar,&ptr,0); @@ -336,7 +340,7 @@ void pcilib_xml_create_bank(pcilib_register_bank_description_t *mybank,xmlChar* }else if(strcmp((char*)endianess,"host")==0){ mybank->endianess=PCILIB_HOST_ENDIAN; } - + mybank->format=(char*)format; mybank->raw_endianess=mybank->endianess; mybank->name=(char*)name; -- cgit v1.2.3