/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 pcitool/cli.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-28 04:09:21 UTC
  • Revision ID: csa@suren.me-20150428040921-fjyahuk824lihv1i
Initial support for event engines

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <dirent.h>
21
21
#include <pthread.h>
22
22
#include <signal.h>
 
23
#include <dlfcn.h>
23
24
 
24
25
#include <getopt.h>
25
26
 
29
30
#include "pcitool/formaters.h"
30
31
 
31
32
#include "pci.h"
 
33
#include "plugin.h"
 
34
#include "config.h"
32
35
#include "tools.h"
33
36
#include "kmem.h"
34
37
#include "error.h"
508
511
}
509
512
 
510
513
void Info(pcilib_t *handle, const pcilib_model_description_t *model_info) {
 
514
    int i, j;
 
515
    DIR *dir;
 
516
    void *plugin;
 
517
    const char *path;
 
518
    struct dirent *entry;
 
519
    const pcilib_model_description_t *info = NULL;
511
520
    const pcilib_board_info_t *board_info = pcilib_get_board_info(handle);
512
521
 
 
522
    path = getenv("PCILIB_PLUGIN_DIR");
 
523
    if (!path) path = PCILIB_PLUGIN_DIR;
 
524
 
513
525
    printf("Vendor: %x, Device: %x, Bus: %x, Slot: %x, Function: %x\n", board_info->vendor_id, board_info->device_id, board_info->bus, board_info->slot, board_info->func);
514
526
    printf(" Interrupt - Pin: %i, Line: %i\n", board_info->interrupt_pin, board_info->interrupt_line);
 
527
 
515
528
    List(handle, model_info, (char*)-1, 0);
 
529
 
 
530
    printf("\n");
 
531
    printf("Available models:\n");
 
532
 
 
533
    dir = opendir(path);
 
534
    if (dir) {
 
535
        while ((entry = readdir(dir))) {
 
536
            const char *suffix = strstr(entry->d_name, ".so");
 
537
            if ((!suffix)||(strlen(suffix) != 3)) continue;
 
538
 
 
539
            plugin = pcilib_plugin_load(entry->d_name);
 
540
            if (plugin) {
 
541
                info = pcilib_get_plugin_model(handle, plugin, 0, 0, NULL);
 
542
                if (info) {
 
543
                    printf(" %s => ", entry->d_name);
 
544
                    for (j = 0; info[j].name; j++)
 
545
                        printf("%s ", info[j].name);
 
546
                    printf("\n");
 
547
                }
 
548
                pcilib_plugin_close(plugin);
 
549
            } else {
 
550
                const char *msg = dlerror();
 
551
                if (msg) 
 
552
                    printf(" %s: %s\n", entry->d_name, msg);
 
553
            }
 
554
        }
 
555
        closedir(dir);
 
556
    }
 
557
 
 
558
    printf(" DMA => ");
 
559
    for (i = 0; pcilib_dma[i].api; i++)
 
560
        printf("%s ", pcilib_dma[i].name);
 
561
    printf("\n");
 
562
    printf(" XML =>\n");
 
563
    printf(" Plain => pci\n\n");
 
564
 
516
565
}
517
566
 
518
567