summaryrefslogtreecommitdiffstats
path: root/pcilib/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r--pcilib/pci.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index ca17931..3a0073b 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -26,6 +26,7 @@
#include "model.h"
#include "plugin.h"
#include "bar.h"
+#include "xml.h"
#include "locking.h"
static int pcilib_detect_model(pcilib_t *ctx, const char *model) {
@@ -108,7 +109,7 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
int err;
size_t i;
pcilib_t *ctx = malloc(sizeof(pcilib_t));
-
+
if (!model)
model = getenv("PCILIB_MODEL");
@@ -171,7 +172,9 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
if (!ctx->model)
ctx->model = strdup(model?model:"pci");
-
+
+ pcilib_init_xml(ctx);
+
ctx->model_info.registers = ctx->registers;
ctx->model_info.banks = ctx->banks;
ctx->model_info.protocols = ctx->protocols;
@@ -183,6 +186,7 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
pcilib_close(ctx);
return NULL;
}
+
err = pcilib_init_event_engine(ctx);
if (err) {
@@ -278,6 +282,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])) {
@@ -292,6 +297,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]) {
@@ -302,16 +308,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);
}
}