Skip to content

Commit 1a33ae5

Browse files
Alexander ZilberkantOren Cohen
authored andcommitted
Handle manager documentation fix
Move function description to header files Note: it is not in Doxygen format since it is an internal module and Doxygen should not be generated for it
1 parent f771a5a commit 1a33ae5

File tree

2 files changed

+61
-63
lines changed

2 files changed

+61
-63
lines changed

components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.c

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,15 @@
2929
#include <stdlib.h>
3030

3131

32-
3332
/* ------------------------------------ Definitions ---------------------------------- */
3433

3534
#define PSA_HANDLE_MGR_HANDLE_INDEX_POS 16
3635
#define PSA_HANDLE_MGR_HANDLE_INDEX_MSK 0xFFFF
3736

3837

39-
40-
/* -------------------------------- Handle Manager Module ---------------------------- */
41-
42-
/* The Handle Manager Module manages handles.
43-
*
44-
* It basically generates and exposes a unique handle identifier [handle] per
45-
* handle memory [handle_mem] it receives from the user.
46-
* Then users can use the exposed handle identifier to relate to the "registered"
47-
* handle memory.
48-
*
49-
* Users can:
50-
* - Ask for a unique handle identifier for a given handle memory [handle_create]
51-
* - Ask for a pointer to the handle memory corresponding to a
52-
* handle identifier [handle_get_mem]
53-
* - Remove a handle from the handle manager module [handle_destroy]
54-
*
55-
* Note:
56-
* Handles generation is done exclusively.
57-
* Once we got a handle, removing a handle or getting its memory can be
58-
* done non-exclusive.
59-
* The assumption is that only one context is dealing with a handle after it was
60-
* generated.
61-
*/
62-
6338
/* ------------------------------------- Functions ----------------------------------- */
6439

65-
/**********************************************************************************************************************************
66-
* Function : psa_hndl_mgr_handle_create
67-
*
68-
* Description: This function generates a unique handle identifier, and "couples" it with the received handle memory.
69-
* If there is no vacant space for the new handle, the function fails.
70-
*
71-
* Note: This function is expected to pass since it is always coupled with memory pool allocation of the same size.
72-
* In case memory pool allocation fails, this function should not be called.
73-
* This function will panic on non vacant space use case.
74-
*
75-
* Parameters : handle_mgr - [IN] A pointer to the handle manager object
76-
* handle_mem - [IN] A pointer to a pre-allocated handle memory to get a handle identifier for
77-
* friend_pid - [IN] The partition id which is allowed to get_mem() and destroy() in addition to the handle owner.
78-
* Use PSA_HANDLE_MGR_INVALID_FRIEND_OWNER to denote there is no friend partition.
79-
*
80-
* Return : The created handle identifier
81-
*********************************************************************************************************************************/
40+
8241
psa_handle_t psa_hndl_mgr_handle_create(psa_handle_manager_t *handle_mgr, void *handle_mem, int32_t friend_pid)
8342
{
8443
// Make sanity checks on arguments
@@ -137,16 +96,6 @@ psa_handle_t psa_hndl_mgr_handle_create(psa_handle_manager_t *handle_mgr, void *
13796
}
13897

13998

140-
/**********************************************************************************************************************************
141-
* Function : psa_hndl_mgr_handle_destroy
142-
*
143-
* Description: This function removes a handle from the handle manager.
144-
*
145-
* Parameters : handle_mgr - [IN] A pointer to the handle manager object
146-
* handle - [IN] The handle to be removed
147-
*
148-
* Return : Void
149-
*********************************************************************************************************************************/
15099
void psa_hndl_mgr_handle_destroy(psa_handle_manager_t *handle_mgr, psa_handle_t handle)
151100
{
152101
// Make sanity checks on arguments
@@ -180,17 +129,6 @@ void psa_hndl_mgr_handle_destroy(psa_handle_manager_t *handle_mgr, psa_handle_t
180129
}
181130

182131

183-
/**********************************************************************************************************************************
184-
* Function : psa_hndl_mgr_handle_get_mem
185-
*
186-
* Description: This function looks for the handle memory corresponding to <handle>.
187-
* If it is not found in the expected index in the handles pool, the function fails.
188-
*
189-
* Parameters : handle_mgr - [IN] A pointer to the handle manager object.
190-
* handle - [IN] The handle for which we request the corresponding memory handle.
191-
*
192-
* Return : A pointer to the memory corresponding to the handle.
193-
*********************************************************************************************************************************/
194132
void *psa_hndl_mgr_handle_get_mem(psa_handle_manager_t *handle_mgr, psa_handle_t handle)
195133
{
196134
SPM_ASSERT(handle_mgr != NULL);

components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,28 @@
2424

2525
#include <stdint.h>
2626

27+
/* -------------------------------- Handle Manager Module ---------------------------- */
2728

29+
/* The Handle Manager Module manages handles.
30+
*
31+
* It basically generates and exposes a unique handle identifier [handle] per
32+
* handle memory [handle_mem] it receives from the user.
33+
* Then users can use the exposed handle identifier to relate to the "registered"
34+
* handle memory.
35+
*
36+
* Users can:
37+
* - Ask for a unique handle identifier for a given handle memory [handle_create]
38+
* - Ask for a pointer to the handle memory corresponding to a
39+
* handle identifier [handle_get_mem]
40+
* - Remove a handle from the handle manager module [handle_destroy]
41+
*
42+
* Note:
43+
* Handles generation is done exclusively.
44+
* Once we got a handle, removing a handle or getting its memory can be
45+
* done non-exclusive.
46+
* The assumption is that only one context is dealing with a handle after it was
47+
* generated.
48+
*/
2849

2950
/* --------------------------------- extern "C" wrapper ------------------------------ */
3051

@@ -88,8 +109,47 @@ handles_pool
88109

89110
/* ------------------------------------- Functions ----------------------------------- */
90111

112+
113+
/*
114+
* @brief create unique handle identifier
115+
*
116+
* This function generates a unique handle identifier, and "couples" it with the received handle memory.
117+
* If there is no vacant space for the new handle, the function fails.
118+
*
119+
* @note This function is expected to pass since it is always coupled with memory pool allocation of the same size.
120+
* In case memory pool allocation fails, this function should not be called.
121+
* This function will panic on non vacant space use case.
122+
*
123+
* @param[in] handle_mgr A pointer to the handle manager object
124+
* @param[in] handle_mem A pointer to a pre-allocated handle memory to get a handle identifier for
125+
* @param[in] friend_pid The partition id which is allowed to get_mem() and destroy() in addition to the handle owner.
126+
* Use PSA_HANDLE_MGR_INVALID_FRIEND_OWNER to denote there is no friend partition.
127+
* @return The created handle identifier
128+
*/
91129
psa_handle_t psa_hndl_mgr_handle_create(psa_handle_manager_t *handle_mgr, void *handle_mem, int32_t friend_pid);
130+
131+
132+
/*
133+
* @brief remove a handle from the handle manager.
134+
*
135+
* @param handle_mgr A pointer to the handle manager object
136+
* @param handle The handle to be removed
137+
*/
92138
void psa_hndl_mgr_handle_destroy(psa_handle_manager_t *handle_mgr, psa_handle_t handle);
139+
140+
141+
/*
142+
* @brief dereference handle
143+
*
144+
* This function retrieves the pointer associated with the input <handle>.
145+
*
146+
* @note This function will panic in case caller not allowed to dereference the memory
147+
* or handler does not correspond to a valid existing handle
148+
*
149+
* @param handle_mgr A pointer to the handle manager object.
150+
* @param handle The handle for which we request the corresponding memory handle.
151+
* @return void* A pointer to the memory corresponding to the handle.
152+
*/
93153
void *psa_hndl_mgr_handle_get_mem(psa_handle_manager_t *handle_mgr, psa_handle_t handle);
94154

95155

0 commit comments

Comments
 (0)