diff mbox

[API-NEXTv5,3/6] linux-gen: drv: shm: adding pool allocator

Message ID 1483456215-40789-4-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Jan. 3, 2017, 3:10 p.m. UTC
Adding functions to create memory pools and allocate / free memory from
the created pools.
These functions calls their _ishm conterpart, of course.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/drv_shm.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

-- 
2.7.4
diff mbox

Patch

diff --git a/platform/linux-generic/drv_shm.c b/platform/linux-generic/drv_shm.c
index 9b2560d..c8e4d0b 100644
--- a/platform/linux-generic/drv_shm.c
+++ b/platform/linux-generic/drv_shm.c
@@ -8,6 +8,7 @@ 
 #include <odp/api/std_types.h>
 #include <odp/drv/shm.h>
 #include <_ishm_internal.h>
+#include <_ishmpool_internal.h>
 
 static inline uint32_t from_handle(odpdrv_shm_t shm)
 {
@@ -100,3 +101,46 @@  int odpdrv_shm_print_all(const char *title)
 {
 	return _odp_ishm_status(title);
 }
+
+odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name,
+					 odpdrv_shm_pool_param_t *param)
+{
+	int flags;
+
+	/* force unique address for all ODP threads */
+	flags = ODPDRV_SHM_SINGLE_VA;
+	return (odpdrv_shm_pool_t)_odp_ishm_pool_create(pool_name,
+							param->pool_size,
+							param->min_alloc,
+							param->max_alloc,
+							flags);
+}
+
+int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool)
+{
+	return _odp_ishm_pool_destroy((_odp_ishm_pool_t *)(void*)pool);
+}
+
+odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name)
+{
+	return (odpdrv_shm_pool_t)_odp_ishm_pool_lookup(name);
+}
+
+void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size)
+{
+	return _odp_ishm_pool_alloc((_odp_ishm_pool_t *)(void*)pool, size);
+}
+
+void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr)
+{
+	(void)_odp_ishm_pool_free((_odp_ishm_pool_t *)(void*)pool, addr);
+}
+
+int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool)
+{
+	return _odp_ishm_pool_status(title, (_odp_ishm_pool_t *)(void*)pool);
+}
+
+/**
+ * @}
+ */