Commit 80c4e66f authored by Martin Ostertag's avatar Martin Ostertag
Browse files

added support to retrieve the physical address of an memory block

parent ec068062
...@@ -181,6 +181,21 @@ unsigned long ump_arch_size_get(ump_secure_id secure_id) ...@@ -181,6 +181,21 @@ unsigned long ump_arch_size_get(ump_secure_id secure_id)
return 0; return 0;
} }
void *ump_arch_phys_address(ump_secure_id secure_id)
{
_ump_uk_phys_addr_get_s dd_phys_addr_call_arg;
dd_phys_addr_call_arg.ctx = ump_uk_ctx;
dd_phys_addr_call_arg.secure_id = secure_id;
dd_phys_addr_call_arg.phys_addr = 0;
if (_UMP_OSU_ERR_OK == _ump_uku_phys_addr_get( &dd_phys_addr_call_arg ) )
{
return dd_phys_addr_call_arg.phys_addr;
}
return 0;
}
void ump_arch_reference_release(ump_secure_id secure_id) void ump_arch_reference_release(ump_secure_id secure_id)
{ {
......
...@@ -45,6 +45,9 @@ ump_secure_id ump_arch_allocate(unsigned long * size, ump_alloc_constraints cons ...@@ -45,6 +45,9 @@ ump_secure_id ump_arch_allocate(unsigned long * size, ump_alloc_constraints cons
/** Query size of specified UMP memory, in bytes. */ /** Query size of specified UMP memory, in bytes. */
unsigned long ump_arch_size_get(ump_secure_id secure_id); unsigned long ump_arch_size_get(ump_secure_id secure_id);
/** Query physical address of specified UMP memory. */
void* ump_arch_phys_address_get(ump_secure_id secure_id);
/** Release a reference from specified UMP memory. */ /** Release a reference from specified UMP memory. */
void ump_arch_reference_release(ump_secure_id secure_id); void ump_arch_reference_release(ump_secure_id secure_id);
......
...@@ -75,7 +75,8 @@ UMP_API_EXPORT ump_handle ump_handle_create_from_secure_id(ump_secure_id secure_ ...@@ -75,7 +75,8 @@ UMP_API_EXPORT ump_handle ump_handle_create_from_secure_id(ump_secure_id secure_
mem->size = size; mem->size = size;
mem->cookie = cookie; mem->cookie = cookie;
mem->is_cached = 1; /* Is set to actually check in the ump_cpu_msync_now() function */ mem->is_cached = 1; /* Is set to actually check in the ump_cpu_msync_now() function */
mem->phys_address = ump_arch_phys_address(secure_id);
_ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0); _ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0);
UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n")); UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n"));
mem->ref_count = 1; mem->ref_count = 1;
...@@ -138,6 +139,17 @@ UMP_API_EXPORT void ump_write(ump_handle dsth, unsigned long offset, const void ...@@ -138,6 +139,17 @@ UMP_API_EXPORT void ump_write(ump_handle dsth, unsigned long offset, const void
} }
UMP_API_EXPORT void* ump_phys_address_get(ump_handle memh)
{
ump_mem * mem = (ump_mem*)memh;
UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != mem->secure_id, ("Secure ID is inavlid"));
UMP_DEBUG_ASSERT(0 < mem->ref_count, ("Reference count too low"));
UMP_DEBUG_ASSERT(0 < mem->size, ("Memory size of passed handle too low"));
return mem->phys_address;
}
UMP_API_EXPORT void* ump_mapped_pointer_get(ump_handle memh) UMP_API_EXPORT void* ump_mapped_pointer_get(ump_handle memh)
{ {
......
...@@ -51,6 +51,7 @@ typedef struct ump_mem ...@@ -51,6 +51,7 @@ typedef struct ump_mem
for the memory that this handle reveals. */ for the memory that this handle reveals. */
unsigned long cookie; /**< cookie for use in arch_unmap calls */ unsigned long cookie; /**< cookie for use in arch_unmap calls */
ump_cache_enabled is_cached; ump_cache_enabled is_cached;
void *phys_address;
} ump_mem; } ump_mem;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -54,6 +54,7 @@ extern "C" ...@@ -54,6 +54,7 @@ extern "C"
#define UMP_IOC_UNLOCK _IOW(UMP_IOCTL_NR, _UMP_IOC_UNLOCK, _ump_uk_unlock_s) #define UMP_IOC_UNLOCK _IOW(UMP_IOCTL_NR, _UMP_IOC_UNLOCK, _ump_uk_unlock_s)
#endif /* UNIFIED_MEMORY_PROVIDER_VERSION */ #endif /* UNIFIED_MEMORY_PROVIDER_VERSION */
#define UMP_IOC_PHYS_ADDR_GET _IOWR(UMP_IOCTL_NR, _UMP_IOC_PHYS_ADDR_GET, _ump_uk_phys_addr_get_s)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -152,6 +152,7 @@ static ump_handle ump_ref_drv_allocate_internal(unsigned long size, ump_alloc_co ...@@ -152,6 +152,7 @@ static ump_handle ump_ref_drv_allocate_internal(unsigned long size, ump_alloc_co
mem->size = allocated_size; mem->size = allocated_size;
mem->cookie = cookie; mem->cookie = cookie;
mem->is_cached = 1; /* Default to ON, is disabled later if not */ mem->is_cached = 1; /* Default to ON, is disabled later if not */
mem->phys_address = ump_arch_phys_address(secure_id);
_ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0); _ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0);
UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n")); UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n"));
......
...@@ -56,6 +56,7 @@ typedef enum ...@@ -56,6 +56,7 @@ typedef enum
_UMP_IOC_SWITCH_HW_USAGE, _UMP_IOC_SWITCH_HW_USAGE,
_UMP_IOC_LOCK, _UMP_IOC_LOCK,
_UMP_IOC_UNLOCK, _UMP_IOC_UNLOCK,
_UMP_IOC_PHYS_ADDR_GET,
#endif /* UNIFIED_MEMORY_PROVIDER_VERSION */ #endif /* UNIFIED_MEMORY_PROVIDER_VERSION */
}_ump_uk_functions; }_ump_uk_functions;
...@@ -201,6 +202,16 @@ typedef struct _ump_uk_unlock_s ...@@ -201,6 +202,16 @@ typedef struct _ump_uk_unlock_s
} _ump_uk_unlock_s; } _ump_uk_unlock_s;
#endif /* UNIFIED_MEMORY_PROVIDER_VERSION */ #endif /* UNIFIED_MEMORY_PROVIDER_VERSION */
/**
* PHYS_ADDR_GET ([in] u32 secure_id, [out]phys_addr )
*/
typedef struct _ump_uk_phys_addr_get_s
{
void *ctx; /**< [in,out] user-kernel context (trashed on output) */
u32 secure_id; /**< Input to DD */
void *phys_addr; /**< Returned physical address; output */
} _ump_uk_phys_addr_get_s;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -118,6 +118,10 @@ _ump_osu_errcode_t _ump_uku_size_get(_ump_uk_size_get_s *args) ...@@ -118,6 +118,10 @@ _ump_osu_errcode_t _ump_uku_size_get(_ump_uk_size_get_s *args)
return ump_driver_ioctl(args->ctx, UMP_IOC_SIZE_GET, args); return ump_driver_ioctl(args->ctx, UMP_IOC_SIZE_GET, args);
} }
_ump_osu_errcode_t _ump_uku_phys_addr_get( _ump_uk_phys_addr_get_s *args )
{
return ump_driver_ioctl(args->ctx, UMP_IOC_PHYS_ADDR_GET, args);
}
void _ump_uku_msynch(_ump_uk_msync_s *args) void _ump_uku_msynch(_ump_uk_msync_s *args)
{ {
......
...@@ -41,6 +41,8 @@ _ump_osu_errcode_t _ump_uku_release( _ump_uk_release_s *args ); ...@@ -41,6 +41,8 @@ _ump_osu_errcode_t _ump_uku_release( _ump_uk_release_s *args );
_ump_osu_errcode_t _ump_uku_size_get( _ump_uk_size_get_s *args ); _ump_osu_errcode_t _ump_uku_size_get( _ump_uk_size_get_s *args );
_ump_osu_errcode_t _ump_uku_phys_addr_get( _ump_uk_phys_addr_get_s *args );
_ump_osu_errcode_t _ump_uku_get_api_version( _ump_uk_api_version_s *args ); _ump_osu_errcode_t _ump_uku_get_api_version( _ump_uk_api_version_s *args );
#if UNIFIED_MEMORY_PROVIDER_VERSION > 2 #if UNIFIED_MEMORY_PROVIDER_VERSION > 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment