[API-NEXT,PATCHv2,2/3] linux-gen: drv: functions to query for physical addresses

Message ID 1478876743-35846-3-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard Nov. 11, 2016, 3:05 p.m.
The capability "phys_addr" is introduced and tells whether physical
address queries are available.
The function odpdrv_virt_to_phys() is added to query for physical address
(from virtual address)

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

---
 platform/linux-generic/drv_shm.c                        | 12 ++++++++++++
 platform/linux-generic/include/_ishmphy_internal.h      |  3 ++-
 platform/linux-generic/include/odp/drv/plat/shm_types.h |  3 +++
 3 files changed, 17 insertions(+), 1 deletion(-)

-- 
2.7.4

Patch

diff --git a/platform/linux-generic/drv_shm.c b/platform/linux-generic/drv_shm.c
index 9b2560d..6005f69 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 <_ishmphy_internal.h>
 
 static inline uint32_t from_handle(odpdrv_shm_t shm)
 {
@@ -24,6 +25,7 @@  int odpdrv_shm_capability(odpdrv_shm_capability_t *capa)
 	capa->max_blocks = ODPDRV_CONFIG_SHM_BLOCKS;
 	capa->max_size = 0;
 	capa->max_align = 0;
+	capa->phys_addr = _odp_ishmphy_can_virt_to_phys();
 
 	return 0;
 }
@@ -100,3 +102,13 @@  int odpdrv_shm_print_all(const char *title)
 {
 	return _odp_ishm_status(title);
 }
+
+odpdrv_phys_addr_t odpdrv_virt_to_phys(const void *addr)
+{
+	return (odpdrv_phys_addr_t)_odp_ishmphy_virt_to_phys(addr);
+}
+
+void odpdrv_memmap_print(void *addr, uint64_t len)
+{
+	_odp_ishmphy_memmap_print(addr, len);
+}
diff --git a/platform/linux-generic/include/_ishmphy_internal.h b/platform/linux-generic/include/_ishmphy_internal.h
index c8752c0..00a5f8e 100644
--- a/platform/linux-generic/include/_ishmphy_internal.h
+++ b/platform/linux-generic/include/_ishmphy_internal.h
@@ -12,8 +12,9 @@  extern "C" {
 #endif
 
 #include <stdint.h>
+#include <odp/drv/shm.h>
 
-typedef uint64_t phys_addr_t; /* Physical address definition. */
+typedef odpdrv_phys_addr_t phys_addr_t; /* Physical address definition. */
 #define PHYS_ADDR_INVALID ((phys_addr_t)-1)
 
 void *_odp_ishmphy_book_va(uintptr_t len, intptr_t align);
diff --git a/platform/linux-generic/include/odp/drv/plat/shm_types.h b/platform/linux-generic/include/odp/drv/plat/shm_types.h
index c48eeca..a54d806 100644
--- a/platform/linux-generic/include/odp/drv/plat/shm_types.h
+++ b/platform/linux-generic/include/odp/drv/plat/shm_types.h
@@ -29,6 +29,9 @@  typedef ODPDRV_HANDLE_T(odpdrv_shm_t);
 
 #define ODPDRV_SHM_INVALID _odpdrv_cast_scalar(odpdrv_shm_t, 0)
 
+/* a physical address: */
+typedef uint64_t odpdrv_phys_addr_t;
+
 /** Get printable format of odpdrv_shm_t */
 static inline uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl)
 {