/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/bank.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:
78
78
 
79
79
 
80
80
int pcilib_add_register_banks(pcilib_t *ctx, size_t n, const pcilib_register_bank_description_t *banks) {
81
 
        // DS: What we are doing if bank exists? 
 
81
        // DS: Override existing banks 
82
82
        
83
83
    if (!n) {
84
84
        for (n = 0; banks[n].access; n++);
87
87
    if ((ctx->num_banks + n + 1) > PCILIB_MAX_REGISTER_BANKS)
88
88
        return PCILIB_ERROR_TOOBIG;
89
89
        
90
 
    memset(ctx->banks + ctx->num_banks + n, 0, sizeof(pcilib_register_bank_description_t));
91
90
    memcpy(ctx->banks + ctx->num_banks, banks, n * sizeof(pcilib_register_bank_description_t));
92
91
    ctx->num_banks += n;
93
92
 
101
100
    return 0;
102
101
}
103
102
 
 
103
int pcilib_add_register_protocols(pcilib_t *ctx, size_t n, const pcilib_register_protocol_description_t *protocols) {
 
104
        // DS: Override existing banks 
 
105
        
 
106
    if (!n) {
 
107
        for (n = 0; protocols[n].api; n++);
 
108
    }
 
109
 
 
110
    if ((ctx->num_protocols + n + 1) > PCILIB_MAX_REGISTER_PROTOCOLS)
 
111
        return PCILIB_ERROR_TOOBIG;
 
112
        
 
113
    memcpy(ctx->protocols + ctx->num_protocols, protocols, n * sizeof(pcilib_register_protocol_description_t));
 
114
    ctx->num_protocols += n;
 
115
 
 
116
    return 0;
 
117
}
 
118
 
 
119
 
 
120
int pcilib_add_register_ranges(pcilib_t *ctx, size_t n, const pcilib_register_range_t *ranges) {
 
121
        // DS: Override existing banks 
 
122
        
 
123
    if (!n) {
 
124
        for (n = 0; ranges[n].end; n++);
 
125
    }
 
126
 
 
127
    if ((ctx->num_ranges + n + 1) > PCILIB_MAX_REGISTER_RANGES)
 
128
        return PCILIB_ERROR_TOOBIG;
 
129
        
 
130
    memcpy(ctx->ranges + ctx->num_ranges, ranges, n * sizeof(pcilib_register_range_t));
 
131
    ctx->num_ranges += n;
 
132
 
 
133
    return 0;
 
134
}
 
135
 
104
136
pcilib_register_bank_t pcilib_find_register_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank) {
105
137
    pcilib_register_bank_t i;
106
138
    const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);