/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/pci.c

  • Committer: zilio nicolas
  • Date: 2015-09-04 18:31:14 UTC
  • mto: This revision was merged to the branch mainline in revision 303.
  • Revision ID: nicolas.zilio@kit.edu-20150904183114-ggzdquen086c033r
end of modifications

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//#define PCILIB_FILE_IO
2
2
#define _XOPEN_SOURCE 700
3
3
#define _BSD_SOURCE
4
 
#define _DEFAULT_SOURCE
5
4
#define _POSIX_C_SOURCE 200809L
6
5
 
7
6
#include <stdio.h>
173
172
        if (!ctx->model)
174
173
            ctx->model = strdup(model?model:"pci");
175
174
        
176
 
        pcilib_init_xml(ctx);
 
175
        pcilib_init_xml(ctx, ctx->model);
177
176
        
178
177
        ctx->model_info.registers = ctx->registers;
179
178
        ctx->model_info.banks = ctx->banks;
282
281
        
283
282
char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr) {
284
283
    if (bar == PCILIB_BAR_DETECT) {
285
 
      printf("bar = PCILIB_BAR_DETECT\n");
286
284
            // First checking the default register bar
287
285
        size_t offset = addr - ctx->board_info.bar_start[ctx->reg_bar];
288
286
        if ((addr > ctx->board_info.bar_start[ctx->reg_bar])&&(offset < ctx->board_info.bar_length[ctx->reg_bar])) {
297
295
            // Otherwise trying to detect
298
296
        bar = pcilib_detect_bar(ctx, addr, 1);
299
297
        if (bar != PCILIB_BAR_INVALID) {
300
 
          printf("bar pas ainvalid\n");
301
298
            size_t offset = addr - ctx->board_info.bar_start[bar];
302
299
            if ((offset < ctx->board_info.bar_length[bar])&&(ctx->bar_space[bar])) {
303
300
                if (!ctx->bar_space[bar]) {
308
305
            }
309
306
        }
310
307
    } else {
311
 
        printf("bar internal :%i\n",bar);
312
 
        //      printf("bar invalid\n");
313
308
        if (!ctx->bar_space[bar]) {
314
309
            pcilib_error("The requested bar (%i) is not mapped", bar);
315
310
            return NULL;
316
311
        }
317
312
        
318
313
        if (addr < ctx->board_info.bar_length[bar]) {
319
 
          printf("path1\n");
320
 
          // printf("apres: %s\n",ctx->bar_space[bar] + addr);
321
314
            return ctx->bar_space[bar] + addr + (ctx->board_info.bar_start[bar] & ctx->page_mask);
322
315
        }
323
316
        
324
317
        if ((addr >= ctx->board_info.bar_start[bar])&&(addr < (ctx->board_info.bar_start[bar] + ctx->board_info.bar_length[ctx->reg_bar]))) {
325
 
          printf("path2\n");
326
318
            return ctx->bar_space[bar] + (addr - ctx->board_info.bar_start[bar]) + (ctx->board_info.bar_start[bar] & ctx->page_mask);
327
319
        }
328
320
    }