Skip to content

Commit 6edc81d

Browse files
authored
Merge pull request #8873 from kfnta/psa_spm_docs
PSA-SPM documentation follow-up
2 parents e02a8ab + 6ae3501 commit 6edc81d

File tree

9 files changed

+61
-206
lines changed

9 files changed

+61
-206
lines changed

components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.h

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,22 @@
2626

2727
/* -------------------------------- Handle Manager Module ---------------------------- */
2828

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"
3433
* handle memory.
3534
*
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`].
3837
* - 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`].
4140
*
4241
* 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
4745
* generated.
4846
*/
4947

@@ -61,9 +59,9 @@ extern "C" {
6159

6260
#define PSA_HANDLE_MGR_INVALID_FRIEND_OWNER 0 // Denoting invalid friend or invalid owner
6361

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.
6765
#define PSA_HANDLE_MGR_MAX_HANDLES_NUM 0x8000
6866

6967

@@ -72,19 +70,19 @@ extern "C" {
7270

7371
typedef struct psa_handle_item_t {
7472

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 */
7977

8078
} psa_handle_item_t;
8179

8280

8381
typedef struct psa_handle_manager_t {
8482

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". */
8886

8987
} psa_handle_manager_t;
9088

@@ -111,43 +109,43 @@ handles_pool
111109

112110

113111
/*
114-
* @brief create unique handle identifier
112+
* @brief Create unique handle identifier
115113
*
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.
117115
* If there is no vacant space for the new handle, the function fails.
118116
*
119117
* @note This function is expected to pass since it is always coupled with memory pool allocation of the same size.
120118
* 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.
122120
*
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
128126
*/
129127
psa_handle_t psa_hndl_mgr_handle_create(psa_handle_manager_t *handle_mgr, void *handle_mem, int32_t friend_pid);
130128

131129

132130
/*
133-
* @brief remove a handle from the handle manager.
131+
* @brief Remove a handle from the handle manager.
134132
*
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.
137135
*/
138136
void psa_hndl_mgr_handle_destroy(psa_handle_manager_t *handle_mgr, psa_handle_t handle);
139137

140138

141139
/*
142-
* @brief dereference handle
140+
* @brief De-reference handle
143141
*
144142
* This function retrieves the pointer associated with the input <handle>.
145143
*
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.
148146
*
149147
* @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.
151149
* @return void* A pointer to the memory corresponding to the handle.
152150
*/
153151
void *psa_hndl_mgr_handle_get_mem(psa_handle_manager_t *handle_mgr, psa_handle_t handle);

components/TARGET_PSA/spm/COMPONENT_SPE/spm_internal.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ typedef struct spm_ipc_channel {
110110
struct spm_partition *src_partition; /* Pointer to the Partition which connects to the Root of Trust Service.*/
111111
spm_rot_service_t *dst_rot_service; /* Pointer to the connected Root of Trust Service.*/
112112
void *rhandle; /* Reverse handle to be used for this channel.*/
113-
void *msg_ptr; /* message data sent from user */
114-
struct spm_ipc_channel *next; /* Next channel in the chain */
113+
void *msg_ptr; /* Message data sent from user. */
114+
struct spm_ipc_channel *next; /* Next channel in the chain.*/
115115
uint8_t msg_type; /* The message type.*/
116116
uint8_t state; /* The current processing state of the channel.*/
117-
uint8_t is_dropped;
117+
uint8_t is_dropped; /* Indicates whether the channel has been dropped by the partition.*/
118118
} spm_ipc_channel_t;
119119

120120
/*
@@ -127,7 +127,7 @@ typedef struct spm_active_msg {
127127
} spm_active_msg_t;
128128

129129
/*
130-
* Structure containing resources and attributes of a Secure Partition.
130+
* Structure containing resources and attributes of a secure partition.
131131
*/
132132
typedef struct spm_partition {
133133
const int32_t partition_id; /* The Partition ID.*/
@@ -136,7 +136,7 @@ typedef struct spm_partition {
136136
const uint32_t flags_interrupts; /* Mask of all the IRQs & doorbell which the partition supports.*/
137137
spm_rot_service_t *rot_services; /* Array of the Partition's Root of Trust Services.*/
138138
const uint32_t rot_services_count; /* Number of the Partition's Root of Trust Services.*/
139-
const uint32_t *extern_sids; /* Array of Root of Trust Service IDs which the partition can connect to.*/
139+
const uint32_t *extern_sids; /* Array of Root of Trust Service IDs that the partition can connect to.*/
140140
const uint32_t extern_sids_count; /* Number of Root of Trust Services which the partition can connect to.*/
141141
osMutexId_t mutex; /* Mutex for all rot_service's queues operations. */
142142
spm_signal_to_irq_mapper_t irq_mapper; /* a function which maps signal to irq number*/
@@ -171,19 +171,19 @@ const mem_region_t *get_mem_regions(int32_t partition_id, uint32_t *region_count
171171
// Platform dependent APIs
172172

173173
/*
174-
* Validates a memory block is accessable from a specific partition
174+
* Validates that a memory block accessible from a specific partition
175175
*
176-
* @param[in] ptr pointer to the beggining of the memory block.
177-
* @param[in] size size of the memory block in bytes.
178-
* @param[in] accessing_partition which partition is trying to access the memory.
179-
* @return true if the entire memory block is accessable from given partition.
176+
* @param[in] ptr - Pointer to the beggining of the memory block.
177+
* @param[in] size - Size of the memory block in bytes.
178+
* @param[in] accessing_partition - Which partition is trying to access the memory.
179+
* @return `true` if the entire memory block is accessable from given partition.
180180
*/
181181
bool is_buffer_accessible(const void *ptr, size_t size, spm_partition_t *accessing_partition);
182182

183183
/**
184184
* Alerts NSPE that a proccess (connect or call) has ended.
185185
*
186-
* @param[in] completion_sem_id semaphore id in NSPE.
186+
* @param[in] completion_sem_id - semaphore id in NSPE.
187187
*/
188188
void nspe_done(osSemaphoreId_t completion_sem_id);
189189

components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C" {
3535
#endif
3636

3737
/** @addtogroup RoT-Service-API
38-
* The C interface for a Root of Trust Service in a partition.
38+
* The C interface for a root of trust (RoT) Service in a partition.
3939
* @{
4040
*/
4141

@@ -75,8 +75,8 @@ int32_t psa_identity(psa_handle_t msg_handle);
7575
/**
7676
* Get the message that corresponds to a given signal.
7777
*
78-
* @param[in] signum an asserted signal returned from psa_wait().
79-
* @param[out] msg pointer to a psa_msg structure.
78+
* @param[in] signum An asserted signal returned from psa_wait().
79+
* @param[out] msg Pointer to a psa_msg structure.
8080
*/
8181
void psa_get(psa_signal_t signum, psa_msg_t *msg);
8282

components/TARGET_PSA/spm/doc/INTRO.md

Lines changed: 0 additions & 117 deletions
This file was deleted.

components/TARGET_PSA/spm/doc/README.md

Lines changed: 0 additions & 23 deletions
This file was deleted.
Binary file not shown.

doxyfile_options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,8 @@ PREDEFINED = DOXYGEN_ONLY \
20992099
DEVICE_SPISLAVE \
21002100
DEVICE_QSPI \
21012101
DEVICE_STORAGE \
2102+
COMPONENT_SPE \
2103+
COMPONENT_SPM_MAILBOX \
21022104
"MBED_DEPRECATED_SINCE(d, m)=" \
21032105
"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=" \
21042106
"MBED_DEPRECATED(s)="

doxygen_options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"SEARCH_INCLUDES": "YES",
77
"INCLUDE_PATH": "",
88
"INCLUDE_FILE_PATTERNS": "",
9-
"PREDEFINED": "DOXYGEN_ONLY DEVICE_ANALOGIN DEVICE_ANALOGOUT DEVICE_CAN DEVICE_CRC DEVICE_ETHERNET DEVICE_EMAC DEVICE_FLASH DEVICE_I2C DEVICE_I2CSLAVE DEVICE_I2C_ASYNCH DEVICE_INTERRUPTIN DEVICE_ITM DEVICE_LPTICKER DEVICE_MPU DEVICE_PORTIN DEVICE_PORTINOUT DEVICE_PORTOUT DEVICE_PWMOUT DEVICE_RTC DEVICE_TRNG DEVICE_SERIAL DEVICE_SERIAL_ASYNCH DEVICE_SERIAL_FC DEVICE_SLEEP DEVICE_SPI DEVICE_SPI_ASYNCH DEVICE_SPISLAVE DEVICE_QSPI DEVICE_STORAGE \"MBED_DEPRECATED_SINCE(f, g)=\" \"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=\" \"MBED_DEPRECATED(s)=\"",
9+
"PREDEFINED": "DOXYGEN_ONLY DEVICE_ANALOGIN DEVICE_ANALOGOUT DEVICE_CAN DEVICE_CRC DEVICE_ETHERNET DEVICE_EMAC DEVICE_FLASH DEVICE_I2C DEVICE_I2CSLAVE DEVICE_I2C_ASYNCH DEVICE_INTERRUPTIN DEVICE_ITM DEVICE_LPTICKER DEVICE_MPU DEVICE_PORTIN DEVICE_PORTINOUT DEVICE_PORTOUT DEVICE_PWMOUT DEVICE_RTC DEVICE_TRNG DEVICE_SERIAL DEVICE_SERIAL_ASYNCH DEVICE_SERIAL_FC DEVICE_SLEEP DEVICE_SPI DEVICE_SPI_ASYNCH DEVICE_SPISLAVE DEVICE_QSPI DEVICE_STORAGE COMPONENT_SPE COMPONENT_SPM_MAILBOX \"MBED_DEPRECATED_SINCE(f, g)=\" \"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=\" \"MBED_DEPRECATED(s)=\"",
1010
"EXPAND_AS_DEFINED": "",
1111
"SKIP_FUNCTION_MACROS": "NO",
1212
"STRIP_CODE_COMMENTS": "NO",

0 commit comments

Comments
 (0)