diff options
author | Vasilii Chernov <vchernov@inr.ru> | 2016-03-02 10:28:04 +0100 |
---|---|---|
committer | Vasilii Chernov <vchernov@inr.ru> | 2016-03-02 10:28:04 +0100 |
commit | 8e7c95957ee73d6c11ef28f7c0e2319a11103783 (patch) | |
tree | 83df220932b3d88e071eda4c756e485dd48d50e9 /pcilib/kmem.c | |
parent | 8719b84a95805d109e21c20f05a0164315e1b38a (diff) | |
parent | 867bddcf7be374221a04b7ae89f93a5f5d703ee6 (diff) | |
download | pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.gz pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.bz2 pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.xz pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.zip |
Merge with http://ufo.kit.edu/ufo/log/csa/pcitool 362 revision
Diffstat (limited to 'pcilib/kmem.c')
-rw-r--r-- | pcilib/kmem.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/pcilib/kmem.c b/pcilib/kmem.c index cb3c58c..b103126 100644 --- a/pcilib/kmem.c +++ b/pcilib/kmem.c @@ -157,6 +157,7 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type kbuf->buf.blocks[i].handle_id = kh.handle_id; kbuf->buf.blocks[i].pa = kh.pa; + kbuf->buf.blocks[i].ba = kh.ba; kbuf->buf.blocks[i].size = kh.size; if (!i) reused = (kh.flags&KMEM_FLAG_REUSED)?PCILIB_TRISTATE_YES:PCILIB_TRISTATE_NO; @@ -210,7 +211,12 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type if ((kh.align)&&((kh.type&PCILIB_KMEM_TYPE_MASK) != PCILIB_KMEM_TYPE_PAGE)) { - if (kh.pa % kh.align) kbuf->buf.blocks[i].alignment_offset = kh.align - kh.pa % kh.align; + // Physical or bus address here? + if (kh.ba) { + if (kh.ba % kh.align) kbuf->buf.blocks[i].alignment_offset = kh.align - kh.ba % kh.align; + } else { + if (kh.pa % kh.align) kbuf->buf.blocks[i].alignment_offset = kh.align - kh.pa % kh.align; + } kbuf->buf.blocks[i].size -= kh.align; } @@ -355,7 +361,7 @@ int pcilib_kmem_sync_block(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_s return 0; } -void *pcilib_kmem_get_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k) { +void* volatile pcilib_kmem_get_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k) { pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k; return kbuf->buf.addr.ua + kbuf->buf.addr.alignment_offset + kbuf->buf.addr.mmap_offset; } @@ -367,10 +373,14 @@ uintptr_t pcilib_kmem_get_pa(pcilib_t *ctx, pcilib_kmem_handle_t *k) { uintptr_t pcilib_kmem_get_ba(pcilib_t *ctx, pcilib_kmem_handle_t *k) { pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k; - return kbuf->buf.addr.pa + kbuf->buf.addr.alignment_offset; + + if (kbuf->buf.addr.ba) + return kbuf->buf.addr.ba + kbuf->buf.addr.alignment_offset; + + return 0; } -void *pcilib_kmem_get_block_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block) { +void* volatile pcilib_kmem_get_block_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block) { pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k; return kbuf->buf.blocks[block].ua + kbuf->buf.blocks[block].alignment_offset + kbuf->buf.blocks[block].mmap_offset; } @@ -382,7 +392,11 @@ uintptr_t pcilib_kmem_get_block_pa(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_ uintptr_t pcilib_kmem_get_block_ba(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block) { pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k; - return kbuf->buf.blocks[block].pa + kbuf->buf.blocks[block].alignment_offset; + + if (kbuf->buf.blocks[block].ba) + return kbuf->buf.blocks[block].ba + kbuf->buf.blocks[block].alignment_offset; + + return 0; } size_t pcilib_kmem_get_block_size(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block) { |