[Cbe-oss-dev] [PATCH 03/10]MARS: Task event flag api fix

Yuji Mano yuji.mano at am.sony.com
Fri Oct 3 04:31:21 EST 2008


This changes the task event flag API for wait and try_wait so that the caller
can request to get the bit pattern returned upon the event release.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 include/host/mars/mars_task_event_flag.h |   10 ++++++----
 include/mpu/mars/mars_task_event_flag.h  |   16 ++++++++--------
 src/host/lib/mars_task_event_flag.c      |   20 ++++++++++++--------
 src/mpu/lib/mars_task_event_flag.c       |   29 ++++++++++++++++-------------
 4 files changed, 42 insertions(+), 33 deletions(-)

--- a/include/host/mars/mars_task_event_flag.h
+++ b/include/host/mars/mars_task_event_flag.h
@@ -107,6 +107,7 @@ int mars_task_event_flag_set(struct mars
  * \param[in] event_flag	- pointer to initialized event flag instance
  * \param[in] mask		- bit mask to test event flag bits against
  * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
  * \return
  *	MARS_SUCCESS		- successfully received event
  * \n	MARS_ERROR_NULL		- null pointer specified
@@ -116,8 +117,8 @@ int mars_task_event_flag_set(struct mars
  * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
  */
 int mars_task_event_flag_wait(struct mars_task_event_flag *event_flag,
-				uint32_t mask,
-				uint8_t mask_mode);
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
 
 /**
  * \ingroup group_mars_task_event_flag
@@ -126,6 +127,7 @@ int mars_task_event_flag_wait(struct mar
  * \param[in] event_flag	- pointer to initialized event flag instance
  * \param[in] mask		- bit mask to test event flag bits against
  * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
  * \return
  *	MARS_SUCCESS		- successfully received event
  * \n	MARS_ERROR_NULL		- null pointer specified
@@ -135,8 +137,8 @@ int mars_task_event_flag_wait(struct mar
  * \n	MARS_ERROR_BUSY		- event not yet received
  */
 int mars_task_event_flag_try_wait(struct mars_task_event_flag *event_flag,
-				uint32_t mask,
-				uint8_t mask_mode);
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
 
 #if defined(__cplusplus)
 }
--- a/include/mpu/mars/mars_task_event_flag.h
+++ b/include/mpu/mars/mars_task_event_flag.h
@@ -78,8 +78,7 @@ int mars_task_event_flag_initialize(uint
  * \n	MARS_ERROR_NULL		- ea is 0\n
  * \n	MARS_ERROR_ALIGN	- ea not aligned properly
  */
-int mars_task_event_flag_clear(uint64_t event_flag_ea,
-				uint32_t bits);
+int mars_task_event_flag_clear(uint64_t event_flag_ea, uint32_t bits);
 
 /**
  * \ingroup group_mars_task_event_flag
@@ -93,8 +92,7 @@ int mars_task_event_flag_clear(uint64_t 
  * \n	MARS_ERROR_ALIGN	- ea not aligned properly
  * \n	MARS_ERROR_STATE	- invalid direction
  */
-int mars_task_event_flag_set(uint64_t event_flag_ea,
-				uint32_t bits);
+int mars_task_event_flag_set(uint64_t event_flag_ea, uint32_t bits);
 
 /**
  * \ingroup group_mars_task_event_flag
@@ -103,6 +101,7 @@ int mars_task_event_flag_set(uint64_t ev
  * \param[in] event_flag_ea	- ea of initialized event flag instance
  * \param[in] mask		- bit mask to test event flag bits against
  * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
  * \return
  *	MARS_SUCCESS		- successfully received event
  * \n	MARS_ERROR_NULL		- ea is 0
@@ -113,8 +112,8 @@ int mars_task_event_flag_set(uint64_t ev
  * \n	MARS_ERROR_FORMAT	- no context save area specified
  */
 int mars_task_event_flag_wait(uint64_t event_flag_ea,
-				uint32_t mask,
-				uint8_t mask_mode);
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
 
 /**
  * \ingroup group_mars_task_event_flag
@@ -123,6 +122,7 @@ int mars_task_event_flag_wait(uint64_t e
  * \param[in] event_flag_ea	- ea of initialized event flag instance
  * \param[in] mask		- bit mask to test event flag bits against
  * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
  * \return
  *	MARS_SUCCESS		- successfully received event
  * \n	MARS_ERROR_NULL		- ea is 0
@@ -132,8 +132,8 @@ int mars_task_event_flag_wait(uint64_t e
  * \n	MARS_ERROR_BUSY		- event not yet received
  */
 int mars_task_event_flag_try_wait(uint64_t event_flag_ea,
-				uint32_t mask,
-				uint8_t mask_mode);
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
 
 #if defined(__cplusplus)
 }
--- a/src/host/lib/mars_task_event_flag.c
+++ b/src/host/lib/mars_task_event_flag.c
@@ -130,10 +130,6 @@ int mars_task_event_flag_set(struct mars
 			break;
 		}
 
-		/* clear event if clear mode is auto */
-		if (event_flag->clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
-			event_flag->bits &= ~event_flag->wait_mask[i];
-
 		/* signal the task to go to ready state */
 		ret = workload_queue_signal_send(mars->workload_queue,
 			event_flag->wait_id[i]);
@@ -159,8 +155,8 @@ int mars_task_event_flag_set(struct mars
 }
 
 int mars_task_event_flag_wait(struct mars_task_event_flag *event_flag,
-				uint32_t mask,
-				uint8_t mask_mode)
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
 {
 	MARS_CHECK_RET(event_flag, MARS_ERROR_NULL);
 	MARS_CHECK_RET(event_flag->direction ==
@@ -193,6 +189,10 @@ int mars_task_event_flag_wait(struct mar
 		break;
 	}
 
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag->bits;
+
 	/* clear event if clear mode is auto */
 	if (event_flag->clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
 		event_flag->bits &= ~mask;
@@ -203,8 +203,8 @@ int mars_task_event_flag_wait(struct mar
 }
 
 int mars_task_event_flag_try_wait(struct mars_task_event_flag *event_flag,
-				uint32_t mask,
-				uint8_t mask_mode)
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
 {
 	MARS_CHECK_RET(event_flag, MARS_ERROR_NULL);
 	MARS_CHECK_RET(event_flag->direction ==
@@ -233,6 +233,10 @@ int mars_task_event_flag_try_wait(struct
 		break;
 	}
 
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag->bits;
+
 	/* clear event if clear mode is auto */
 	if (event_flag->clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
 		event_flag->bits &= ~mask;
--- a/src/mpu/lib/mars_task_event_flag.c
+++ b/src/mpu/lib/mars_task_event_flag.c
@@ -75,8 +75,7 @@ int mars_task_event_flag_initialize(uint
 	return MARS_SUCCESS;
 }
 
-int mars_task_event_flag_clear(uint64_t event_flag_ea,
-				uint32_t bits)
+int mars_task_event_flag_clear(uint64_t event_flag_ea, uint32_t bits)
 {
 	MARS_CHECK_RET(event_flag_ea, MARS_ERROR_NULL);
 	MARS_CHECK_RET((event_flag_ea & MARS_TASK_EVENT_FLAG_ALIGN_MASK) == 0,
@@ -92,8 +91,7 @@ int mars_task_event_flag_clear(uint64_t 
 	return MARS_SUCCESS;
 }
 
-int mars_task_event_flag_set(uint64_t event_flag_ea,
-				uint32_t bits)
+int mars_task_event_flag_set(uint64_t event_flag_ea, uint32_t bits)
 {
 	MARS_CHECK_RET(event_flag_ea, MARS_ERROR_NULL);
 	MARS_CHECK_RET((event_flag_ea & MARS_TASK_EVENT_FLAG_ALIGN_MASK) == 0,
@@ -132,10 +130,6 @@ int mars_task_event_flag_set(uint64_t ev
 			break;
 		}
 
-		/* clear event if clear mode is auto */
-		if (event_flag.clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
-			event_flag.bits &= ~event_flag.wait_mask[i];
-
 		/* signal the waiting tasks */
 		mars_signal_send(event_flag.wait_id[i]);
 
@@ -159,8 +153,8 @@ int mars_task_event_flag_set(uint64_t ev
 }
 
 int mars_task_event_flag_wait(uint64_t event_flag_ea,
-				uint32_t mask,
-				uint8_t mask_mode)
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
 {
 	MARS_CHECK_RET(event_flag_ea, MARS_ERROR_NULL);
 	MARS_CHECK_RET(mask_mode == MARS_TASK_EVENT_FLAG_MASK_OR ||
@@ -223,9 +217,14 @@ int mars_task_event_flag_wait(uint64_t e
 		/* wait for signal */
 		mars_signal_wait();
 
-		return MARS_SUCCESS;
+		mars_mutex_lock_get(event_flag_ea,
+				(struct mars_mutex *)&event_flag);
 	}
 
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag.bits;
+
 	/* clear event if clear mode is auto */
 	if (event_flag.clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
 		event_flag.bits &= ~mask;
@@ -236,8 +235,8 @@ int mars_task_event_flag_wait(uint64_t e
 }
 
 int mars_task_event_flag_try_wait(uint64_t event_flag_ea,
-				uint32_t mask,
-				uint8_t mask_mode)
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
 {
 	MARS_CHECK_RET(event_flag_ea, MARS_ERROR_NULL);
 	MARS_CHECK_RET(mask_mode == MARS_TASK_EVENT_FLAG_MASK_OR ||
@@ -274,6 +273,10 @@ int mars_task_event_flag_try_wait(uint64
 		break;
 	}
 
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag.bits;
+
 	/* clear event if clear mode is auto */
 	if (event_flag.clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
 		event_flag.bits &= ~mask;






More information about the cbe-oss-dev mailing list