@@ -143,6 +143,111 @@ kstatus_t mgr_mm_shm_declare_user(shmh_t shm, taskh_t task)
143143 return status ;
144144}
145145
146+ /**
147+ * @fn get base address of the given SHM
148+ *
149+ * @param[in] shm: Shared memory handle that identify the SHM
150+ * @param[out] base: base address of the SHM returned when found
151+ */
152+ kstatus_t mgr_mm_shm_get_baseaddr (shmh_t shm , size_t * base )
153+ {
154+ kstatus_t status = K_ERROR_INVPARAM ;
155+ kshmh_t const * kshm = shmh_to_kshmh (& shm );
156+
157+ /*@ assert \valid_read(kshm); */
158+
159+ if (unlikely (mgr_mm_configured () == SECURE_FALSE )) {
160+ status = K_ERROR_BADSTATE ;
161+ goto end ;
162+ }
163+ if (unlikely (base == NULL )) {
164+ goto end ;
165+ }
166+ /*@ assert \valid(base); */
167+ /* check that id exsits */
168+ if (unlikely (kshm -> id >= SHM_LIST_SIZE )) {
169+ goto end ;
170+ }
171+ /* check that handle matches */
172+ if (unlikely (shm_table [kshm -> id ].handle != shm )) {
173+ goto end ;
174+ }
175+ * base = shm_table [kshm -> id ].meta -> baseaddr ;
176+ status = K_STATUS_OKAY ;
177+ end :
178+ return status ;
179+ }
180+
181+ /**
182+ * @fn get size in bytes of the given SHM
183+ *
184+ * @param[in] shm: Shared memory handle that identify the SHM
185+ * @param[out] size: length in bytes of the SHM returned when found
186+ */
187+ kstatus_t mgr_mm_shm_get_size (shmh_t shm , size_t * size )
188+ {
189+ kstatus_t status = K_ERROR_INVPARAM ;
190+ kshmh_t const * kshm = shmh_to_kshmh (& shm );
191+
192+ /*@ assert \valid_read(kshm); */
193+
194+ if (unlikely (mgr_mm_configured () == SECURE_FALSE )) {
195+ status = K_ERROR_BADSTATE ;
196+ goto end ;
197+ }
198+ if (unlikely (size == NULL )) {
199+ goto end ;
200+ }
201+ /*@ assert \valid(size); */
202+ /* check that id exsits */
203+ if (unlikely (kshm -> id >= SHM_LIST_SIZE )) {
204+ goto end ;
205+ }
206+ /* check that handle matches */
207+ if (unlikely (shm_table [kshm -> id ].handle != shm )) {
208+ goto end ;
209+ }
210+ * size = shm_table [kshm -> id ].meta -> size ;
211+ status = K_STATUS_OKAY ;
212+ end :
213+ return status ;
214+ }
215+
216+ /**
217+ * @fn get label defined in DTS for the given SHM
218+ *
219+ * @param[in] shm: Shared memory handle that identify the SHM
220+ * @param[out] label: identifier of the SHM as declared in the DTS, returned when found
221+ */
222+ kstatus_t mgr_mm_shm_get_label (shmh_t shm , uint32_t * label )
223+ {
224+ kstatus_t status = K_ERROR_INVPARAM ;
225+ kshmh_t const * kshm = shmh_to_kshmh (& shm );
226+
227+ /*@ assert \valid_read(kshm); */
228+
229+ if (unlikely (mgr_mm_configured () == SECURE_FALSE )) {
230+ status = K_ERROR_BADSTATE ;
231+ goto end ;
232+ }
233+ if (unlikely (label == NULL )) {
234+ goto end ;
235+ }
236+ /*@ assert \valid(label); */
237+ /* check that id exsits */
238+ if (unlikely (kshm -> id >= SHM_LIST_SIZE )) {
239+ goto end ;
240+ }
241+ /* check that handle matches */
242+ if (unlikely (shm_table [kshm -> id ].handle != shm )) {
243+ goto end ;
244+ }
245+ * label = shm_table [kshm -> id ].meta -> shm_label ;
246+ status = K_STATUS_OKAY ;
247+ end :
248+ return status ;
249+ }
250+
146251/**
147252 * @brief specify if the given SHM can be mapped by owner or user
148253 *
0 commit comments