Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Libump
Commits
80c4e66f
Commit
80c4e66f
authored
Nov 29, 2015
by
Martin Ostertag
Browse files
added support to retrieve the physical address of an memory block
parent
ec068062
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/ump_arch.c
View file @
80c4e66f
...
...
@@ -181,6 +181,21 @@ unsigned long ump_arch_size_get(ump_secure_id secure_id)
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
)
{
...
...
src/ump_arch.h
View file @
80c4e66f
...
...
@@ -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. */
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. */
void
ump_arch_reference_release
(
ump_secure_id
secure_id
);
...
...
src/ump_frontend.c
View file @
80c4e66f
...
...
@@ -75,7 +75,8 @@ UMP_API_EXPORT ump_handle ump_handle_create_from_secure_id(ump_secure_id secure_
mem
->
size
=
size
;
mem
->
cookie
=
cookie
;
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_DEBUG_ASSERT
(
NULL
!=
mem
->
ref_lock
,
(
"Failed to initialize lock
\n
"
));
mem
->
ref_count
=
1
;
...
...
@@ -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
)
{
...
...
src/ump_internal.h
View file @
80c4e66f
...
...
@@ -51,6 +51,7 @@ typedef struct ump_mem
for the memory that this handle reveals. */
unsigned
long
cookie
;
/**< cookie for use in arch_unmap calls */
ump_cache_enabled
is_cached
;
void
*
phys_address
;
}
ump_mem
;
#ifdef __cplusplus
...
...
src/ump_ioctl.h
View file @
80c4e66f
...
...
@@ -54,6 +54,7 @@ extern "C"
#define UMP_IOC_UNLOCK _IOW(UMP_IOCTL_NR, _UMP_IOC_UNLOCK, _ump_uk_unlock_s)
#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
}
#endif
...
...
src/ump_ref_drv.c
View file @
80c4e66f
...
...
@@ -152,6 +152,7 @@ static ump_handle ump_ref_drv_allocate_internal(unsigned long size, ump_alloc_co
mem
->
size
=
allocated_size
;
mem
->
cookie
=
cookie
;
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_DEBUG_ASSERT
(
NULL
!=
mem
->
ref_lock
,
(
"Failed to initialize lock
\n
"
));
...
...
src/ump_uk_types.h
View file @
80c4e66f
...
...
@@ -56,6 +56,7 @@ typedef enum
_UMP_IOC_SWITCH_HW_USAGE
,
_UMP_IOC_LOCK
,
_UMP_IOC_UNLOCK
,
_UMP_IOC_PHYS_ADDR_GET
,
#endif
/* UNIFIED_MEMORY_PROVIDER_VERSION */
}
_ump_uk_functions
;
...
...
@@ -201,6 +202,16 @@ typedef struct _ump_uk_unlock_s
}
_ump_uk_unlock_s
;
#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
}
#endif
...
...
src/ump_uku.c
View file @
80c4e66f
...
...
@@ -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
);
}
_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
)
{
...
...
src/ump_uku.h
View file @
80c4e66f
...
...
@@ -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_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
);
#if UNIFIED_MEMORY_PROVIDER_VERSION > 2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment