[Cbe-oss-dev] [PATCH 11/28]MARS/base: rename defines

Yuji Mano yuji.mano at am.sony.com
Fri Feb 6 13:31:26 EST 2009


This renames the workload bits macros to add WORKLOAD_* prefix in preparation
for another patch that adds a new set of BLOCK_* bit definitions.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 base/src/common/workload_internal_types.h |   29 ++++++++---------
 base/src/host/lib/workload_queue.c        |   32 ++++++++++---------
 base/src/mpu/kernel/kernel.c              |   49 +++++++++++++++---------------
 3 files changed, 56 insertions(+), 54 deletions(-)

--- a/base/src/common/workload_internal_types.h
+++ b/base/src/common/workload_internal_types.h
@@ -73,8 +73,9 @@
 
 #define MARS_WORKLOAD_QUEUE_FLAG_NONE		0x0	/* no flag set */
 #define MARS_WORKLOAD_QUEUE_FLAG_EXIT		0x1	/* exit flag */
+
 /*
- * MARS workload queue block bits
+ * MARS workload queue block workload bits (64-bits)
  * ------------------------------------------------------------------
  * |[63...60]|[59....52]|[51....33]|[  32  ]|[31.....16]|[15......0]|
  * ------------------------------------------------------------------
@@ -83,19 +84,17 @@
  * |  STATE  | PRIORITY | RESERVED | SIGNAL |  WAIT_ID  |  COUNTER  |
  * ------------------------------------------------------------------
  */
-#define MARS_BITS_SIZE				64
-
-#define MARS_BITS_SHIFT_STATE			60
-#define MARS_BITS_SHIFT_PRIORITY		52
-#define MARS_BITS_SHIFT_SIGNAL			32
-#define MARS_BITS_SHIFT_WAIT_ID			16
-#define MARS_BITS_SHIFT_COUNTER			0
-
-#define MARS_BITS_MASK_STATE			0xf000000000000000ULL
-#define MARS_BITS_MASK_PRIORITY			0x0ff0000000000000ULL
-#define MARS_BITS_MASK_SIGNAL			0x0000000100000000ULL
-#define MARS_BITS_MASK_WAIT_ID			0x00000000ffff0000ULL
-#define MARS_BITS_MASK_COUNTER			0x000000000000ffffULL
+#define MARS_BITS_SHIFT_WORKLOAD_STATE		60
+#define MARS_BITS_SHIFT_WORKLOAD_PRIORITY	52
+#define MARS_BITS_SHIFT_WORKLOAD_SIGNAL		32
+#define MARS_BITS_SHIFT_WORKLOAD_WAIT_ID	16
+#define MARS_BITS_SHIFT_WORKLOAD_COUNTER	0
+
+#define MARS_BITS_MASK_WORKLOAD_STATE		0xf000000000000000ULL
+#define MARS_BITS_MASK_WORKLOAD_PRIORITY	0x0ff0000000000000ULL
+#define MARS_BITS_MASK_WORKLOAD_SIGNAL		0x0000000100000000ULL
+#define MARS_BITS_MASK_WORKLOAD_WAIT_ID		0x00000000ffff0000ULL
+#define MARS_BITS_MASK_WORKLOAD_COUNTER		0x000000000000ffffULL
 
 #define MARS_BITS_GET(bits, name)  \
 	((*(bits) & MARS_BITS_MASK_##name) >> MARS_BITS_SHIFT_##name)
@@ -104,7 +103,7 @@
 	(*bits) = ((*(bits) & ~MARS_BITS_MASK_##name) | \
 		((uint64_t)(val) << MARS_BITS_SHIFT_##name))
 
-#define MARS_HOST_SIGNAL_EXIT			0
+#define MARS_HOST_SIGNAL_EXIT			0x0	/* host exit flag */
 
 /* 128 byte workload queue header structure */
 struct mars_workload_queue_header {
--- a/base/src/host/lib/workload_queue.c
+++ b/base/src/host/lib/workload_queue.c
@@ -99,7 +99,7 @@ static void init_blocks(uint64_t queue_e
 	struct mars_workload_queue_block *queue_block;
 
 	/* create initial bit pattern of workload queue blocks */
-	MARS_BITS_SET(&bits, STATE, MARS_WORKLOAD_STATE_NONE);
+	MARS_BITS_SET(&bits, WORKLOAD_STATE, MARS_WORKLOAD_STATE_NONE);
 
 	/* other bits are set by mars_workload_queue_schedule_begin properly */
 
@@ -164,7 +164,7 @@ static int is_block_empty(uint64_t block
 
 	/* check status */
 	for (index = 0; index < MARS_WORKLOAD_PER_BLOCK; index++) {
-		if (MARS_BITS_GET(&block->bits[index], STATE) !=
+		if (MARS_BITS_GET(&block->bits[index], WORKLOAD_STATE) !=
 		    MARS_WORKLOAD_STATE_NONE)
 			return MARS_ERROR_STATE;
 	}
@@ -238,8 +238,10 @@ static int alloc_block(uint64_t block_ea
 	/* check status */
 	for (index = 0; index < MARS_WORKLOAD_PER_BLOCK; index++) {
 		uint64_t bits = block->bits[index];
-		if (MARS_BITS_GET(&bits, STATE) == MARS_WORKLOAD_STATE_NONE) {
-			MARS_BITS_SET(&bits, STATE, MARS_WORKLOAD_STATE_ADDING);
+		if (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
+		    MARS_WORKLOAD_STATE_NONE) {
+			MARS_BITS_SET(&bits, WORKLOAD_STATE,
+				      MARS_WORKLOAD_STATE_ADDING);
 			mars_ea_put_uint64(get_block_bits_ea(block_ea, index),
 					   bits);
 			ret = index;
@@ -357,17 +359,17 @@ static int change_bits(struct mars_conte
 
 static int check_state_bits(uint64_t bits, uint64_t state)
 {
-	return (MARS_BITS_GET(&bits, STATE) == state);
+	return (MARS_BITS_GET(&bits, WORKLOAD_STATE) == state);
 }
 
 static int check_state_bits_not(uint64_t bits, uint64_t state)
 {
-	return (MARS_BITS_GET(&bits, STATE) != state);
+	return (MARS_BITS_GET(&bits, WORKLOAD_STATE) != state);
 }
 
 static uint64_t set_state_bits(uint64_t bits, uint64_t state)
 {
-	MARS_BITS_SET(&bits, STATE, state);
+	MARS_BITS_SET(&bits, WORKLOAD_STATE, state);
 
 	return bits;
 }
@@ -435,11 +437,11 @@ int mars_workload_queue_remove_cancel(st
 static uint64_t set_schedule_bits(uint64_t bits, uint64_t priority)
 {
 	/* set the info bits inside queue block for this workload */
-	MARS_BITS_SET(&bits, STATE, MARS_WORKLOAD_STATE_SCHEDULING);
-	MARS_BITS_SET(&bits, PRIORITY, priority);
-	MARS_BITS_SET(&bits, COUNTER, MARS_WORKLOAD_COUNTER_MIN);
-	MARS_BITS_SET(&bits, SIGNAL, MARS_WORKLOAD_SIGNAL_OFF);
-	MARS_BITS_SET(&bits, WAIT_ID, MARS_WORKLOAD_ID_NONE);
+	MARS_BITS_SET(&bits, WORKLOAD_STATE, MARS_WORKLOAD_STATE_SCHEDULING);
+	MARS_BITS_SET(&bits, WORKLOAD_PRIORITY, priority);
+	MARS_BITS_SET(&bits, WORKLOAD_COUNTER, MARS_WORKLOAD_COUNTER_MIN);
+	MARS_BITS_SET(&bits, WORKLOAD_SIGNAL, MARS_WORKLOAD_SIGNAL_OFF);
+	MARS_BITS_SET(&bits, WORKLOAD_WAIT_ID, MARS_WORKLOAD_ID_NONE);
 
 	return bits;
 }
@@ -476,10 +478,10 @@ static int is_workload_finished(uint32_t
 {
 	(void)param;
 
-	/* this function assumes 'STATE' is stored in upper 32bits */
+	/* this function assumes 'WORKLOAD_STATE' is stored in upper 32 bits */
 	uint64_t bits = (uint64_t)upper << 32;
 
-	switch (MARS_BITS_GET(&bits, STATE)) {
+	switch (MARS_BITS_GET(&bits, WORKLOAD_STATE)) {
 	case MARS_WORKLOAD_STATE_FINISHED:
 		return MARS_SUCCESS;
 	case MARS_WORKLOAD_STATE_NONE:
@@ -553,7 +555,7 @@ int mars_workload_queue_try_wait(struct 
 
 static uint64_t set_signal_bits(uint64_t bits, uint64_t signal)
 {
-	MARS_BITS_SET(&bits, SIGNAL, signal);
+	MARS_BITS_SET(&bits, WORKLOAD_SIGNAL, signal);
 
 	return bits;
 }
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -224,22 +224,22 @@ static int workload_query(uint16_t id, i
 
 	switch (query) {
 	case MARS_QUERY_IS_INITIALIZED:
-		return (MARS_BITS_GET(&bits, STATE) !=
+		return (MARS_BITS_GET(&bits, WORKLOAD_STATE) !=
 			MARS_WORKLOAD_STATE_NONE);
 	case MARS_QUERY_IS_READY:
-		return (MARS_BITS_GET(&bits, STATE) ==
+		return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
 			MARS_WORKLOAD_STATE_READY);
 	case MARS_QUERY_IS_WAITING:
-		return (MARS_BITS_GET(&bits, STATE) ==
+		return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
 			MARS_WORKLOAD_STATE_WAITING);
 	case MARS_QUERY_IS_RUNNING:
-		return (MARS_BITS_GET(&bits, STATE) ==
+		return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
 			MARS_WORKLOAD_STATE_RUNNING);
 	case MARS_QUERY_IS_FINISHED:
-		return (MARS_BITS_GET(&bits, STATE) ==
+		return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
 			MARS_WORKLOAD_STATE_FINISHED);
 	case MARS_QUERY_IS_SIGNAL_SET:
-		return (MARS_BITS_GET(&bits, SIGNAL) ==
+		return (MARS_BITS_GET(&bits, WORKLOAD_SIGNAL) ==
 			MARS_WORKLOAD_SIGNAL_ON);
 	}
 
@@ -298,7 +298,7 @@ static int change_bits(uint16_t id,
 
 static int check_state_bits(uint64_t bits, uint64_t state)
 {
-	return (MARS_BITS_GET(&bits, STATE) == state);
+	return (MARS_BITS_GET(&bits, WORKLOAD_STATE) == state);
 }
 
 static int check_state_bits_not(uint64_t bits, uint64_t state)
@@ -308,7 +308,7 @@ static int check_state_bits_not(uint64_t
 
 static uint64_t set_state_bits(uint64_t bits, uint64_t state)
 {
-	MARS_BITS_SET(&bits, STATE, state);
+	MARS_BITS_SET(&bits, WORKLOAD_STATE, state);
 
 	return bits;
 }
@@ -326,7 +326,7 @@ static int change_state(uint16_t id,
 
 static uint64_t set_wait_id_bits(uint64_t bits, uint64_t id)
 {
-	MARS_BITS_SET(&bits, WAIT_ID, id);
+	MARS_BITS_SET(&bits, WORKLOAD_WAIT_ID, id);
 
 	return bits;
 }
@@ -352,7 +352,7 @@ static int workload_wait_reset(void)
 
 static uint64_t set_signal_bits(uint64_t bits, uint64_t signal)
 {
-	MARS_BITS_SET(&bits, SIGNAL, signal);
+	MARS_BITS_SET(&bits, WORKLOAD_SIGNAL, signal);
 
 	return bits;
 }
@@ -379,11 +379,11 @@ static int workload_signal_reset(void)
 static uint64_t set_schedule_bits(uint64_t bits, uint64_t priority)
 {
 	/* set the info bits inside queue block for this workload */
-	MARS_BITS_SET(&bits, STATE, MARS_WORKLOAD_STATE_SCHEDULING);
-	MARS_BITS_SET(&bits, PRIORITY, priority);
-	MARS_BITS_SET(&bits, COUNTER, MARS_WORKLOAD_COUNTER_MIN);
-	MARS_BITS_SET(&bits, SIGNAL, MARS_WORKLOAD_SIGNAL_OFF);
-	MARS_BITS_SET(&bits, WAIT_ID, MARS_WORKLOAD_ID_NONE);
+	MARS_BITS_SET(&bits, WORKLOAD_STATE, MARS_WORKLOAD_STATE_SCHEDULING);
+	MARS_BITS_SET(&bits, WORKLOAD_PRIORITY, priority);
+	MARS_BITS_SET(&bits, WORKLOAD_COUNTER, MARS_WORKLOAD_COUNTER_MIN);
+	MARS_BITS_SET(&bits, WORKLOAD_SIGNAL, MARS_WORKLOAD_SIGNAL_OFF);
+	MARS_BITS_SET(&bits, WORKLOAD_WAIT_ID, MARS_WORKLOAD_ID_NONE);
 
 	return bits;
 }
@@ -512,7 +512,8 @@ static int search_block(int block)
 
 			/* increment wait counter without overflowing */
 			if (counter < MARS_WORKLOAD_COUNTER_MAX)
-				MARS_BITS_SET(bits, COUNTER, counter + 1);
+				MARS_BITS_SET(bits, WORKLOAD_COUNTER,
+					      counter + 1);
 		/* found workload in waiting state */
 		} else if (state == MARS_WORKLOAD_STATE_WAITING) {
 			/* waiting for workload to finish so check status */
@@ -540,21 +541,21 @@ static int search_block(int block)
 				/* get state of workload its waiting for */
 				wait_state =
 					MARS_BITS_GET(&p_wait_block->bits[id],
-						      STATE);
+						      WORKLOAD_STATE);
 
 				/* check if workload is finished and reset */
 				if (wait_state ==
 				    MARS_WORKLOAD_STATE_FINISHED) {
-					MARS_BITS_SET(bits, WAIT_ID,
+					MARS_BITS_SET(bits, WORKLOAD_WAIT_ID,
 						MARS_WORKLOAD_ID_NONE);
-					MARS_BITS_SET(bits, STATE,
+					MARS_BITS_SET(bits, WORKLOAD_STATE,
 						MARS_WORKLOAD_STATE_READY);
 				}
 			/* waiting for signal so check signal bit and reset */
 			} else if (signal == MARS_WORKLOAD_SIGNAL_ON) {
-				MARS_BITS_SET(bits, SIGNAL,
+				MARS_BITS_SET(bits, WORKLOAD_SIGNAL,
 					      MARS_WORKLOAD_SIGNAL_OFF);
-				MARS_BITS_SET(bits, STATE,
+				MARS_BITS_SET(bits, WORKLOAD_STATE,
 					      MARS_WORKLOAD_STATE_READY);
 			}
 		}
@@ -575,11 +576,11 @@ static int reserve_block(int block)
 	index = search_block(block);
 	if (index >= 0) {
 		/* update the current state of the workload */
-		MARS_BITS_SET(&queue_block.bits[index], STATE,
+		MARS_BITS_SET(&queue_block.bits[index], WORKLOAD_STATE,
 			      MARS_WORKLOAD_STATE_RUNNING);
 
 		/* reset the counter for reserved workload */
-		MARS_BITS_SET(&queue_block.bits[index], COUNTER,
+		MARS_BITS_SET(&queue_block.bits[index], WORKLOAD_COUNTER,
 			      MARS_WORKLOAD_COUNTER_MIN);
 	}
 
@@ -605,7 +606,7 @@ static void release_block(int block, int
 	mars_mutex_lock_get(block_ea, (struct mars_mutex *)&queue_block);
 
 	/* update current workload state in workload queue block */
-	MARS_BITS_SET(&queue_block.bits[index], STATE, workload_state);
+	MARS_BITS_SET(&queue_block.bits[index], WORKLOAD_STATE, workload_state);
 
 	mars_mutex_unlock_put(block_ea, (struct mars_mutex *)&queue_block);
 







More information about the cbe-oss-dev mailing list