|
@@ -102,7 +102,7 @@ struct lowl_pci_handle {
|
|
|
off_t baroff[6];
|
|
off_t baroff[6];
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef USE_LOWL_PCI_MMAP
|
|
#ifdef USE_LOWL_PCI_MMAP
|
|
|
- uint32_t *bar[6];
|
|
|
|
|
|
|
+ volatile uint32_t *bar[6];
|
|
|
size_t barsz[6];
|
|
size_t barsz[6];
|
|
|
#endif
|
|
#endif
|
|
|
};
|
|
};
|
|
@@ -113,20 +113,24 @@ void lowl_pci_close_mmap(struct lowl_pci_handle * const lph)
|
|
|
{
|
|
{
|
|
|
for (int i = 0; i < 6; ++i)
|
|
for (int i = 0; i < 6; ++i)
|
|
|
if (lph->bar[i])
|
|
if (lph->bar[i])
|
|
|
- munmap(lph->bar[i], lph->barsz[i]);
|
|
|
|
|
|
|
+ munmap((void*)lph->bar[i], lph->barsz[i]);
|
|
|
free(lph);
|
|
free(lph);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static
|
|
static
|
|
|
const uint32_t *lowl_pci_get_words_mmap(struct lowl_pci_handle * const lph, void * const buf, const size_t words, const int bar, const off_t offset)
|
|
const uint32_t *lowl_pci_get_words_mmap(struct lowl_pci_handle * const lph, void * const buf, const size_t words, const int bar, const off_t offset)
|
|
|
{
|
|
{
|
|
|
- return &lph->bar[bar][offset];
|
|
|
|
|
|
|
+ volatile uint32_t *src = &lph->bar[bar][offset];
|
|
|
|
|
+ uint32_t *dest = buf;
|
|
|
|
|
+ for (int i = 0; i < words; ++i)
|
|
|
|
|
+ *(dest++) = *(src++);
|
|
|
|
|
+ return buf;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static
|
|
static
|
|
|
bool lowl_pci_set_words_mmap(struct lowl_pci_handle * const lph, const uint32_t *buf, const size_t words, const int bar, const off_t offset)
|
|
bool lowl_pci_set_words_mmap(struct lowl_pci_handle * const lph, const uint32_t *buf, const size_t words, const int bar, const off_t offset)
|
|
|
{
|
|
{
|
|
|
- uint32_t *dest = &lph->bar[bar][offset];
|
|
|
|
|
|
|
+ volatile uint32_t *dest = &lph->bar[bar][offset];
|
|
|
for (int i = 0; i < words; ++i)
|
|
for (int i = 0; i < words; ++i)
|
|
|
*(dest++) = *(buf++);
|
|
*(dest++) = *(buf++);
|
|
|
return true;
|
|
return true;
|
|
@@ -242,7 +246,7 @@ struct lowl_pci_handle *lowl_pci_open_uio(const char * const path, const struct
|
|
|
err:
|
|
err:
|
|
|
for (int i = 0; i < 6; ++i)
|
|
for (int i = 0; i < 6; ++i)
|
|
|
if (lph->bar[i])
|
|
if (lph->bar[i])
|
|
|
- munmap(lph->bar[i], lph->barsz[i]);
|
|
|
|
|
|
|
+ munmap((void*)lph->bar[i], lph->barsz[i]);
|
|
|
free(lph);
|
|
free(lph);
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
@@ -396,7 +400,7 @@ struct lowl_pci_handle *lowl_pci_open_vfio(const char * const path, const struct
|
|
|
err:
|
|
err:
|
|
|
for (int i = 0; i < 6; ++i)
|
|
for (int i = 0; i < 6; ++i)
|
|
|
if (lph->bar[i])
|
|
if (lph->bar[i])
|
|
|
- munmap(lph->bar[i], lph->barsz[i]);
|
|
|
|
|
|
|
+ munmap((void*)lph->bar[i], lph->barsz[i]);
|
|
|
if (device != -1)
|
|
if (device != -1)
|
|
|
close(device);
|
|
close(device);
|
|
|
if (group != -1)
|
|
if (group != -1)
|