diff mbox

[API-NEXT,RFC,05/31] linux-generic: shmem: retrieving DMA map desriptor

Message ID 1452285014-60320-6-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard Jan. 8, 2016, 8:29 p.m. UTC
Linux-generic implementation of the function returning a DMA mapping
descriptor for an allocated shared memory block.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 platform/linux-generic/odp_shared_memory.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index ab48dda..6ef89c8 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -13,6 +13,7 @@ 
 #include <odp/align.h>
 #include <odp/system_info.h>
 #include <odp/debug.h>
+#include <odp_dma_internal.h>
 #include <odp_debug_internal.h>
 #include <odp_align_internal.h>
 #include <odp/config.h>
@@ -363,6 +364,31 @@  int odp_shm_info(odp_shm_t shm, odp_shm_info_t *info)
 	return 0;
 }
 
+odp_dma_map_t odp_shm_get_dma_map(odp_shm_t shm)
+{
+	odp_shm_block_t *block;
+	uint32_t i;
+	dma_map_t *dma_map;
+
+	i = from_handle(shm);
+
+	if (i > (ODP_CONFIG_SHM_BLOCKS - 1))
+		return ODP_DMA_REGION_INVALID;
+
+	block = &odp_shm_tbl->block[i];
+	if (!(block->flags & ODP_SHM_DMA))
+		return ODP_DMA_REGION_INVALID;
+
+	dma_map = _odp_dma_map_alloc();
+	if (odp_unlikely(dma_map == NULL))
+		return ODP_DMA_REGION_INVALID;
+
+	dma_map->addr     = block->addr;
+	dma_map->dma_addr = (odp_dma_addr_t)block->addr;
+	dma_map->size     = block->size;
+
+	return (odp_dma_map_t)dma_map;
+}
 
 void odp_shm_print_all(void)
 {