diff options
-rw-r--r-- | pcilib/kmem.c | 28 | ||||
-rw-r--r-- | pcilib/kmem.h | 6 | ||||
-rw-r--r-- | pcitool/cli.c | 2 |
3 files changed, 25 insertions, 11 deletions
diff --git a/pcilib/kmem.c b/pcilib/kmem.c index 4e240c3..cb3c58c 100644 --- a/pcilib/kmem.c +++ b/pcilib/kmem.c @@ -276,6 +276,8 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type memcpy(&kbuf->buf.addr, &kbuf->buf.blocks[0], sizeof(pcilib_kmem_addr_t)); } + kbuf->buf.type = type; + kbuf->buf.use = use; kbuf->buf.reused = reused|(persistent?PCILIB_KMEM_REUSE_PERSISTENT:0)|(hardware?PCILIB_KMEM_REUSE_HARDWARE:0); kbuf->prev = NULL; @@ -331,15 +333,25 @@ int pcilib_kmem_sync_block(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_s kmem_sync_t ks; pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k; - ks.dir = dir; - ks.handle.handle_id = kbuf->buf.blocks[block].handle_id; - ks.handle.pa = kbuf->buf.blocks[block].pa; - ret = ioctl(ctx->handle, PCIDRIVER_IOC_KMEM_SYNC, &ks); - if (ret) { - pcilib_error("PCIDRIVER_IOC_KMEM_SYNC ioctl have failed"); - return PCILIB_ERROR_FAILED; + switch (kbuf->buf.type) { + case PCILIB_KMEM_TYPE_DMA_S2C_PAGE: + case PCILIB_KMEM_TYPE_DMA_C2S_PAGE: + case PCILIB_KMEM_TYPE_REGION_S2C: + case PCILIB_KMEM_TYPE_REGION_C2S: + ks.dir = dir; + ks.handle.handle_id = kbuf->buf.blocks[block].handle_id; + ks.handle.pa = kbuf->buf.blocks[block].pa; + + ret = ioctl(ctx->handle, PCIDRIVER_IOC_KMEM_SYNC, &ks); + if (ret) { + pcilib_error("PCIDRIVER_IOC_KMEM_SYNC ioctl have failed"); + return PCILIB_ERROR_FAILED; + } + break; + default: + ; } - + return 0; } diff --git a/pcilib/kmem.h b/pcilib/kmem.h index 3dff625..eb7e4ff 100644 --- a/pcilib/kmem.h +++ b/pcilib/kmem.h @@ -65,12 +65,12 @@ typedef enum { typedef struct { int handle_id; pcilib_kmem_reuse_state_t reused; - + uintptr_t pa; // uintptr_t va; void *ua; size_t size; - + size_t alignment_offset; size_t mmap_offset; } pcilib_kmem_addr_t; @@ -83,6 +83,8 @@ typedef struct { typedef struct { pcilib_kmem_addr_t addr; + pcilib_kmem_type_t type; + pcilib_kmem_use_t use; pcilib_kmem_reuse_state_t reused; size_t n_blocks; diff --git a/pcitool/cli.c b/pcitool/cli.c index c175c31..4d5d3d5 100644 --- a/pcitool/cli.c +++ b/pcitool/cli.c @@ -2547,7 +2547,7 @@ int ListKMEM(pcilib_t *handle, const char *device) { printf("Locks "); break; case PCILIB_KMEM_USE_USER: - printf("User %04x ", uses[i].use&0xFFFF); + printf("User %04x ", uses[i].use&0xFFFF); break; default: printf (" "); |