26
26
27
27
/* -------------------------------- Handle Manager Module ---------------------------- */
28
28
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"
29
+ /*
30
+ * The Handle Manager module generates and exposes a unique
31
+ * identifier (handle) per handle memory (handle_mem) it receives.
32
+ * You can use the exposed handle identifier to relate to the "registered"
34
33
* handle memory.
35
34
*
36
- * Users can:
37
- * - Ask for a unique handle identifier for a given handle memory [handle_create]
35
+ * You can:
36
+ * - Ask for a unique handle identifier for a given handle memory [` handle_create`].
38
37
* - 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]
38
+ * handle identifier [` handle_get_mem`].
39
+ * - Remove a handle from the handle manager module [` handle_destroy`].
41
40
*
42
41
* 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
42
+ * Handle generation is done exclusively.
43
+ * Once you have a handle, you can remove or get its memory non-exclusively.
44
+ * The assumption is that only one context is dealing with a handle after it is
47
45
* generated.
48
46
*/
49
47
@@ -61,9 +59,9 @@ extern "C" {
61
59
62
60
#define PSA_HANDLE_MGR_INVALID_FRIEND_OWNER 0 // Denoting invalid friend or invalid owner
63
61
64
- // Handles manager pool indexes must be in range 0 - 0x7FFF.
65
- // The reason for this limitation is that the index is stored in the upper 16 bits of a handle,
66
- // and the most significant bit must be zero to keep handles non negative.
62
+ // Handle manager pool indexes must be in range 0 - 0x7FFF.
63
+ // This is because the index is stored in the upper 16 bits of a handle,
64
+ // and the most significant bit must be zero to keep handles non- negative.
67
65
#define PSA_HANDLE_MGR_MAX_HANDLES_NUM 0x8000
68
66
69
67
@@ -72,19 +70,19 @@ extern "C" {
72
70
73
71
typedef struct psa_handle_item_t {
74
72
75
- psa_handle_t handle ; /* The user exposed handle [unique identifier] */
76
- int32_t handle_owner ; /* The partition id of the handle creator - allowed to get_mem() / destroy() */
77
- int32_t handle_friend ; /* The partition id of a "friend" partition - allowed to get_mem() */
78
- void * handle_mem ; /* Points to memory allocated by the user */
73
+ psa_handle_t handle ; /* The user- exposed handle [unique identifier]. */
74
+ int32_t handle_owner ; /* The partition ID of the handle creator. Allowed to get_mem() / destroy(). */
75
+ int32_t handle_friend ; /* The partition ID of a "friend" partition. Allowed to get_mem(). */
76
+ void * handle_mem ; /* Points to memory allocated by the use.r */
79
77
80
78
} psa_handle_item_t ;
81
79
82
80
83
81
typedef struct psa_handle_manager_t {
84
82
85
- uint32_t handle_generator ; /* A counter supplying handle numbers */
86
- uint32_t pool_size ; /* The maximum number of handles that pool can contain */
87
- psa_handle_item_t * handles_pool ; /* Holding couples of handles and their memory "blocks" */
83
+ uint32_t handle_generator ; /* A counter supplying handle numbers. */
84
+ uint32_t pool_size ; /* The maximum number of handles that pool can contain. */
85
+ psa_handle_item_t * handles_pool ; /* Holds couples of handles and their memory "blocks". */
88
86
89
87
} psa_handle_manager_t ;
90
88
@@ -111,43 +109,43 @@ handles_pool
111
109
112
110
113
111
/*
114
- * @brief create unique handle identifier
112
+ * @brief Create unique handle identifier
115
113
*
116
- * This function generates a unique handle identifier, and " couples" it with the received handle memory.
114
+ * This function generates a unique handle identifier, and ** couples** it with the received handle memory.
117
115
* If there is no vacant space for the new handle, the function fails.
118
116
*
119
117
* @note This function is expected to pass since it is always coupled with memory pool allocation of the same size.
120
118
* In case memory pool allocation fails, this function should not be called.
121
- * This function will panic on non vacant space use case .
119
+ * This function will panic in the case of non- vacant space use.
122
120
*
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
121
+ * @param[in] handle_mgr A pointer to the handle manager object.
122
+ * @param[in] handle_mem A pointer to a pre-allocated handle memory for which to get a handle identifier.
123
+ * @param[in] friend_pid The partition ID allowed to ` get_mem()` and ` destroy()` in addition to the handle owner.
124
+ * Use ` PSA_HANDLE_MGR_INVALID_FRIEND_OWNER` to denote that there is no friend partition.
125
+ * @return The created handle identifier
128
126
*/
129
127
psa_handle_t psa_hndl_mgr_handle_create (psa_handle_manager_t * handle_mgr , void * handle_mem , int32_t friend_pid );
130
128
131
129
132
130
/*
133
- * @brief remove a handle from the handle manager.
131
+ * @brief Remove a handle from the handle manager.
134
132
*
135
- * @param handle_mgr A pointer to the handle manager object
136
- * @param handle The handle to be removed
133
+ * @param handle_mgr A pointer to the handle manager object.
134
+ * @param handle The handle to be removed.
137
135
*/
138
136
void psa_hndl_mgr_handle_destroy (psa_handle_manager_t * handle_mgr , psa_handle_t handle );
139
137
140
138
141
139
/*
142
- * @brief dereference handle
140
+ * @brief De-reference handle
143
141
*
144
142
* This function retrieves the pointer associated with the input <handle>.
145
143
*
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
144
+ * @note This function will panic if caller is not allowed to de-reference the memory,
145
+ * or handler does not correspond to a valid existing handle.
148
146
*
149
147
* @param handle_mgr A pointer to the handle manager object.
150
- * @param handle The handle for which we request the corresponding memory handle.
148
+ * @param handle The handle for which you request the corresponding memory handle.
151
149
* @return void* A pointer to the memory corresponding to the handle.
152
150
*/
153
151
void * psa_hndl_mgr_handle_get_mem (psa_handle_manager_t * handle_mgr , psa_handle_t handle );
0 commit comments