Subversion Repositories HelenOS-historic

Rev

Rev 1302 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1302 Rev 1307
Line 23... Line 23...
23
struct pci_access *pci_alloc(void)
23
struct pci_access *pci_alloc(void)
24
{
24
{
25
    struct pci_access *a = malloc(sizeof(struct pci_access));
25
    struct pci_access *a = malloc(sizeof(struct pci_access));
26
    int i;
26
    int i;
27
 
27
 
-
 
28
    if (!a)
-
 
29
        return NULL;
-
 
30
       
28
    bzero(a, sizeof(*a));
31
    bzero(a, sizeof(*a));
29
    for (i = 0; i < PCI_ACCESS_MAX; i++)
32
    for (i = 0; i < PCI_ACCESS_MAX; i++)
30
        if (pci_methods[i] && pci_methods[i]->config)
33
        if (pci_methods[i] && pci_methods[i]->config)
31
            pci_methods[i]->config(a);
34
            pci_methods[i]->config(a);
32
    return a;
35
    return a;
Line 35... Line 38...
35
void *pci_malloc(struct pci_access *a, int size)
38
void *pci_malloc(struct pci_access *a, int size)
36
{
39
{
37
    void *x = malloc(size);
40
    void *x = malloc(size);
38
 
41
 
39
    if (!x)
42
    if (!x)
40
        a->error("Out of memory (allocation of %d bytes failed)",
43
        a->error("Out of memory (allocation of %d bytes failed)", size);
41
             size);
-
 
42
    return x;
44
    return x;
43
}
45
}
44
 
46
 
45
void pci_mfree(void *x)
47
void pci_mfree(void *x)
46
{
48
{
Line 216... Line 218...
216
 
218
 
217
static inline int
219
static inline int
218
pci_write_data(struct pci_dev *d, void *buf, int pos, int len)
220
pci_write_data(struct pci_dev *d, void *buf, int pos, int len)
219
{
221
{
220
    if (pos & (len - 1))
222
    if (pos & (len - 1))
221
        d->access->error("Unaligned write: pos=%02x,len=%d", pos,
223
        d->access->error("Unaligned write: pos=%02x,len=%d", pos, len);
222
                 len);
-
 
223
    if (pos + len <= d->cache_len)
224
    if (pos + len <= d->cache_len)
224
        memcpy(d->cache + pos, buf, len);
225
        memcpy(d->cache + pos, buf, len);
225
    return d->methods->write(d, pos, buf, len);
226
    return d->methods->write(d, pos, buf, len);
226
}
227
}
227
 
228
 
Line 243... Line 244...
243
}
244
}
244
 
245
 
245
int pci_write_block(struct pci_dev *d, int pos, byte * buf, int len)
246
int pci_write_block(struct pci_dev *d, int pos, byte * buf, int len)
246
{
247
{
247
    if (pos < d->cache_len) {
248
    if (pos < d->cache_len) {
248
        int l =
-
 
249
            (pos + len >=
-
 
250
             d->cache_len) ? (d->cache_len - pos) : len;
249
        int l = (pos + len >= d->cache_len) ? (d->cache_len - pos) : len;
251
        memcpy(d->cache + pos, buf, l);
250
        memcpy(d->cache + pos, buf, l);
252
    }
251
    }
253
    return d->methods->write(d, pos, buf, len);
252
    return d->methods->write(d, pos, buf, len);
254
}
253
}
255
 
254
 
Line 258... Line 257...
258
    if (flags & PCI_FILL_RESCAN) {
257
    if (flags & PCI_FILL_RESCAN) {
259
        flags &= ~PCI_FILL_RESCAN;
258
        flags &= ~PCI_FILL_RESCAN;
260
        d->known_fields = 0;
259
        d->known_fields = 0;
261
    }
260
    }
262
    if (flags & ~d->known_fields)
261
    if (flags & ~d->known_fields)
263
        d->known_fields |=
-
 
264
            d->methods->fill_info(d, flags & ~d->known_fields);
262
        d->known_fields |= d->methods->fill_info(d, flags & ~d->known_fields);
265
    return d->known_fields;
263
    return d->known_fields;
266
}
264
}
267
 
265
 
268
void pci_setup_cache(struct pci_dev *d, byte * cache, int len)
266
void pci_setup_cache(struct pci_dev *d, byte * cache, int len)
269
{
267
{