/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/pci.c

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-08 01:15:51 UTC
  • Revision ID: csa@suren.me-20160308011551-z7qvf08s6daer4l2
Support XML configuration of device models

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
            pcilib_add_register_ranges(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, model_info->ranges);
87
87
    }
88
88
 
89
 
    // Load XML registers
90
 
 
91
 
    // Check for all installed models
92
 
    // memcpy(&ctx->model_info, model, sizeof(pcilib_model_description_t));
93
 
    // how we reconcile the banks from event model and dma description? The banks specified in the DMA description should override corresponding banks of events...
94
 
 
95
 
 
96
89
    if (!model_info) {
97
90
        if ((model)&&(strcasecmp(model, "pci"))/*&&(no xml)*/)
98
91
            return PCILIB_ERROR_NOTFOUND;
108
101
pcilib_t *pcilib_open(const char *device, const char *model) {
109
102
    int err, xmlerr;
110
103
    pcilib_t *ctx = malloc(sizeof(pcilib_t));
 
104
    const pcilib_board_info_t *board_info;
111
105
    const pcilib_driver_version_t *drv_version;
112
106
        
113
107
    if (!model)
138
132
            return ctx;
139
133
        }
140
134
 
 
135
        board_info = pcilib_get_board_info(ctx);
 
136
        if (!board_info) {
 
137
            pcilib_error("Failed to enumerate PCI device");
 
138
            pcilib_close(ctx);
 
139
            return NULL;
 
140
        }
 
141
 
 
142
            // Check if model is specified in the XML configuration
 
143
        if (!model)
 
144
            model = pcilib_detect_xml_model(ctx, board_info->vendor_id, board_info->device_id);
 
145
 
141
146
        err = pcilib_init_locking(ctx);
142
147
        if (err) {
143
148
            pcilib_error("Error (%i) initializing locking subsystem", err);
151
156
            pcilib_free_py(ctx);
152
157
        }
153
158
 
 
159
 
154
160
        ctx->alloc_reg = PCILIB_DEFAULT_REGISTER_SPACE;
155
161
        ctx->alloc_views = PCILIB_DEFAULT_VIEW_SPACE;
156
162
        ctx->alloc_units = PCILIB_DEFAULT_UNIT_SPACE;
179
185
 
180
186
        err = pcilib_detect_model(ctx, model);
181
187
        if ((err)&&(err != PCILIB_ERROR_NOTFOUND)) {
182
 
            const pcilib_board_info_t *board_info = pcilib_get_board_info(ctx);
183
 
            if (board_info)
184
 
                pcilib_error("Error (%i) configuring model %s (%x:%x)", err, (model?model:""), board_info->vendor_id, board_info->device_id);
185
 
            else
186
 
                pcilib_error("Error (%i) configuring model %s", err, (model?model:""));
 
188
            pcilib_error("Error (%i) configuring model %s (%x:%x)", err, (model?model:""), board_info->vendor_id, board_info->device_id);
187
189
            pcilib_close(ctx);
188
190
            return NULL;
189
191
        }