27
27
/* -------------------------------- Handle Manager Module ---------------------------- */
28
28
29
29
/*
30
- * The Handle Manager module generates and exposes a unique handle
31
- * identifier (handle) per handle memory (handle_mem) it receives from the user .
32
- * Then users can use the exposed handle identifier to relate to the "registered"
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"
33
33
* handle memory.
34
34
*
35
- * Users can:
36
- * - 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`].
37
37
* - Ask for a pointer to the handle memory corresponding to a
38
- * handle identifier [handle_get_mem]
39
- * - 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`].
40
40
*
41
41
* Note:
42
42
* Handle generation is done exclusively.
43
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 was
44
+ * The assumption is that only one context is dealing with a handle after it is
45
45
* generated.
46
46
*/
47
47
@@ -59,9 +59,9 @@ extern "C" {
59
59
60
60
#define PSA_HANDLE_MGR_INVALID_FRIEND_OWNER 0 // Denoting invalid friend or invalid owner
61
61
62
- // Handles manager pool indexes must be in range 0 - 0x7FFF.
63
- // The reason for this limitation is that 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.
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.
65
65
#define PSA_HANDLE_MGR_MAX_HANDLES_NUM 0x8000
66
66
67
67
@@ -70,19 +70,19 @@ extern "C" {
70
70
71
71
typedef struct psa_handle_item_t {
72
72
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 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 */
77
77
78
78
} psa_handle_item_t ;
79
79
80
80
81
81
typedef struct psa_handle_manager_t {
82
82
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 ; /* 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". */
86
86
87
87
} psa_handle_manager_t ;
88
88
@@ -109,40 +109,40 @@ handles_pool
109
109
110
110
111
111
/*
112
- * @brief create unique handle identifier
112
+ * @brief Create unique handle identifier
113
113
*
114
114
* This function generates a unique handle identifier, and **couples** it with the received handle memory.
115
115
* If there is no vacant space for the new handle, the function fails.
116
116
*
117
117
* @note This function is expected to pass since it is always coupled with memory pool allocation of the same size.
118
118
* In case memory pool allocation fails, this function should not be called.
119
- * This function will panic on non vacant space use case .
119
+ * This function will panic in the case of non- vacant space use.
120
120
*
121
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 to get a handle identifier for
123
- * @param[in] friend_pid The partition ID which is allowed to `get_mem()` and `destroy()` in addition to the handle owner.
124
- * Use PSA_HANDLE_MGR_INVALID_FRIEND_OWNER to denote there is no friend partition.
125
- * @return The created handle identifier
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
126
126
*/
127
127
psa_handle_t psa_hndl_mgr_handle_create (psa_handle_manager_t * handle_mgr , void * handle_mem , int32_t friend_pid );
128
128
129
129
130
130
/*
131
- * @brief remove a handle from the handle manager.
131
+ * @brief Remove a handle from the handle manager.
132
132
*
133
- * @param handle_mgr A pointer to the handle manager object
134
- * @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.
135
135
*/
136
136
void psa_hndl_mgr_handle_destroy (psa_handle_manager_t * handle_mgr , psa_handle_t handle );
137
137
138
138
139
139
/*
140
- * @brief dereference handle
140
+ * @brief De-reference handle
141
141
*
142
142
* This function retrieves the pointer associated with the input <handle>.
143
143
*
144
- * @note This function will panic in case caller not allowed to dereference the memory
145
- * 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.
146
146
*
147
147
* @param handle_mgr A pointer to the handle manager object.
148
148
* @param handle The handle for which you request the corresponding memory handle.
0 commit comments