Procházet zdrojové kódy

RTX5: enhanced events EvrRtxSemaphoreAcquired/EvrRtxSemaphoreReleased (added available tokens)

Robert Rostohar před 7 roky
rodič
revize
328e215ce5

+ 4 - 2
CMSIS/DoxyGen/RTOS2/src/rtx_evr.txt

@@ -1340,12 +1340,13 @@ The event \b SemaphoreAcquireTimeout is generated when wait for semaphore to bec
 */
 
 /**
-\fn void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id)
+\fn void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id, uint32_t tokens)
 \details
 The event \b SemaphoreAcquired is generated when the function \ref osSemaphoreAcquire successfully acquires the semaphore token.
 
 \b Value in the Event Recorder shows:
   - \b semaphore_id : semaphore ID.
+  - \b tokens : available tokens.
 */
 
 /**
@@ -1367,12 +1368,13 @@ The event \b SemaphoreRelease is generated when the function \ref osSemaphoreRel
 */
 
 /**
-\fn void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id)
+\fn void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id, uint32_t tokens)
 \details
 The event \b SemaphoreReleased is generated when the function \ref osSemaphoreRelease successfully releases the semaphore token.
 
 \b Value in the Event Recorder shows:
   - \b semaphore_id : semaphore ID.
+  - \b tokens : available tokens.
 */
 
 /**

+ 6 - 4
CMSIS/RTOS2/RTX/Include/rtx_evr.h

@@ -1370,11 +1370,12 @@ extern void EvrRtxSemaphoreAcquireTimeout (osSemaphoreId_t semaphore_id);
 /**
   \brief  Event on successful semaphore acquire (Op)
   \param[in]  semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
+  \param[in]  tokens        number of available tokens.
 */
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRED_DISABLE))
-extern void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id);
+extern void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id, uint32_t tokens);
 #else
-#define EvrRtxSemaphoreAcquired(semaphore_id)
+#define EvrRtxSemaphoreAcquired(semaphore_id, tokens)
 #endif
 
 /**
@@ -1400,11 +1401,12 @@ extern void EvrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id);
 /**
   \brief  Event on successful semaphore release (Op)
   \param[in]  semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
+  \param[in]  tokens        number of available tokens.
 */
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_RELEASED_DISABLE))
-extern void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id);
+extern void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id, uint32_t tokens);
 #else
-#define EvrRtxSemaphoreReleased(semaphore_id)
+#define EvrRtxSemaphoreReleased(semaphore_id, tokens)
 #endif
 
 /**

+ 2 - 2
CMSIS/RTOS2/RTX/RTX5.scvd

@@ -1619,10 +1619,10 @@
     <event id="0xF600 + 0x06" level="API"    property="SemaphoreAcquire"        value="semaphore_id=%x[val1], timeout=%d[val2]" info="osSemaphoreAcquire function was called."/>
     <event id="0xF600 + 0x07" level="Op"     property="SemaphoreAcquirePending" value="semaphore_id=%x[val1], timeout=%d[val2]" info="Semaphore object acquire is pending."/>
     <event id="0xF600 + 0x08" level="Op"     property="SemaphoreAcquireTimeout" value="semaphore_id=%x[val1]" info="Semaphore object acquire timed out."/>
-    <event id="0xF600 + 0x09" level="Op"     property="SemaphoreAcquired"       value="semaphore_id=%x[val1]" info="Semaphore object was acquired."/>
+    <event id="0xF600 + 0x09" level="Op"     property="SemaphoreAcquired"       value="semaphore_id=%x[val1], tokens=%d[val2]" info="Semaphore object was acquired."/>
     <event id="0xF600 + 0x0A" level="Op"     property="SemaphoreNotAcquired"    value="semaphore_id=%x[val1]" info="Semaphore object was not acquired."/>
     <event id="0xF600 + 0x0B" level="API"    property="SemaphoreRelease"        value="semaphore_id=%x[val1]" info="osSemaphoreRelease function was called."/>
-    <event id="0xF600 + 0x0C" level="Op"     property="SemaphoreReleased"       value="semaphore_id=%x[val1]" info="Semaphore object was released."/>
+    <event id="0xF600 + 0x0C" level="Op"     property="SemaphoreReleased"       value="semaphore_id=%x[val1], tokens=%d[val2]" info="Semaphore object was released."/>
     <event id="0xF600 + 0x0D" level="API"    property="SemaphoreGetCount"       value="semaphore_id=%x[val1], count=%d[val2]" info="osSemaphoreGetCount function was called and current number of available tokens was retrieved."/>
     <event id="0xF600 + 0x0E" level="API"    property="SemaphoreDelete"         value="semaphore_id=%x[val1]" info="osSemaphoreDelete function was called."/>
     <event id="0xF600 + 0x0F" level="Op"     property="SemaphoreDestroyed"      value="semaphore_id=%x[val1]" info="Semaphore object was deleted."/>

+ 6 - 4
CMSIS/RTOS2/RTX/Source/rtx_evr.c

@@ -1528,11 +1528,12 @@ __WEAK void EvrRtxSemaphoreAcquireTimeout (osSemaphoreId_t semaphore_id) {
 #endif
 
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRED_DISABLE))
-__WEAK void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id) {
+__WEAK void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id, uint32_t tokens) {
 #if defined(RTE_Compiler_EventRecorder)
-  (void)EventRecord2(EvtRtxSemaphoreAcquired, (uint32_t)semaphore_id, 0U);
+  (void)EventRecord2(EvtRtxSemaphoreAcquired, (uint32_t)semaphore_id, tokens);
 #else
   (void)semaphore_id;
+  (void)tokens;
 #endif
 }
 #endif
@@ -1558,11 +1559,12 @@ __WEAK void EvrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
 #endif
 
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_RELEASED_DISABLE))
-__WEAK void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id) {
+__WEAK void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id, uint32_t tokens) {
 #if defined(RTE_Compiler_EventRecorder)
-  (void)EventRecord2(EvtRtxSemaphoreReleased, (uint32_t)semaphore_id, 0U);
+  (void)EventRecord2(EvtRtxSemaphoreReleased, (uint32_t)semaphore_id, tokens);
 #else
   (void)semaphore_id;
+  (void)tokens;
 #endif
 }
 #endif

+ 7 - 7
CMSIS/RTOS2/RTX/Source/rtx_semaphore.c

@@ -117,7 +117,7 @@ static void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) {
       // Wakeup waiting Thread with highest Priority
       thread = osRtxThreadListGet(osRtxObject(semaphore));
       osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE);
-      EvrRtxSemaphoreAcquired(semaphore);
+      EvrRtxSemaphoreAcquired(semaphore, semaphore->tokens);
     }
   }
 }
@@ -239,7 +239,7 @@ static osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t
 
   // Try to acquire token
   if (SemaphoreTokenDecrement(semaphore) != 0U) {
-    EvrRtxSemaphoreAcquired(semaphore);
+    EvrRtxSemaphoreAcquired(semaphore, semaphore->tokens);
     status = osOK;
   } else {
     // No token available
@@ -277,16 +277,16 @@ static osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
 
   // Check if Thread is waiting for a token
   if (semaphore->thread_list != NULL) {
-    EvrRtxSemaphoreReleased(semaphore);
+    EvrRtxSemaphoreReleased(semaphore, semaphore->tokens);
     // Wakeup waiting Thread with highest Priority
     thread = osRtxThreadListGet(osRtxObject(semaphore));
     osRtxThreadWaitExit(thread, (uint32_t)osOK, TRUE);
-    EvrRtxSemaphoreAcquired(semaphore);
+    EvrRtxSemaphoreAcquired(semaphore, semaphore->tokens);
     status = osOK;
   } else {
     // Try to release token
     if (SemaphoreTokenIncrement(semaphore) != 0U) {
-      EvrRtxSemaphoreReleased(semaphore);
+      EvrRtxSemaphoreReleased(semaphore, semaphore->tokens);
       status = osOK;
     } else {
       EvrRtxSemaphoreError(semaphore, osRtxErrorSemaphoreCountLimit);
@@ -385,7 +385,7 @@ osStatus_t isrRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeou
 
   // Try to acquire token
   if (SemaphoreTokenDecrement(semaphore) != 0U) {
-    EvrRtxSemaphoreAcquired(semaphore);
+    EvrRtxSemaphoreAcquired(semaphore, semaphore->tokens);
     status = osOK;
   } else {
     // No token available
@@ -414,7 +414,7 @@ osStatus_t isrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
   if (SemaphoreTokenIncrement(semaphore) != 0U) {
     // Register post ISR processing
     osRtxPostProcess(osRtxObject(semaphore));
-    EvrRtxSemaphoreReleased(semaphore);
+    EvrRtxSemaphoreReleased(semaphore, semaphore->tokens);
     status = osOK;
   } else {
     EvrRtxSemaphoreError(semaphore, osRtxErrorSemaphoreCountLimit);