[Cbe-oss-dev] [PATCH] libspe2: Add missing runtime error macros

Kazunori Asayama asayama at sm.sony.co.jp
Tue Apr 10 23:48:25 EST 2007


Some runtime error macros defined in spec are missing in the current
implimentation of libspe2. Here is a patch to add the definitions.

OK to apply ?

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>

Index: libspe2-public/libspe2-types.h
===================================================================
--- libspe2-public.orig/libspe2-types.h
+++ libspe2-public/libspe2-types.h
@@ -192,6 +192,25 @@ enum ps_area { SPE_MSSYNC_AREA, SPE_MFC_
 #define SPE_CALLBACK_ERROR		6
 
 /**
+ * Runtime errors
+ */
+#define SPE_SPU_STOPPED_BY_STOP     0x02 /* INTERNAL USE ONLY */
+#define SPE_SPU_HALT                0x04
+#define SPE_SPU_WAITING_ON_CHANNEL  0x08 /* INTERNAL USE ONLY */
+#define SPE_SPU_SINGLE_STEP         0x10
+#define SPE_SPU_INVALID_INSTR       0x20
+#define SPE_SPU_INVALID_CHANNEL     0x40
+
+/**
+ * Runtime exceptions
+ */
+#define SPE_DMA_ALIGNMENT               0x0008
+/* #define SPE_SPE_ERROR                   0x0010 */
+#define SPE_DMA_SEGMENTATION            0x0020
+#define SPE_DMA_STORAGE                 0x0040
+/* #define SPE_INVALID_DMA                 0x0800 */
+
+/**
  * SIGSPE maps to SIGURG 
  */
 #define SIGSPE SIGURG
Index: libspe2-public/spebase/run.c
===================================================================
--- libspe2-public.orig/spebase/run.c
+++ libspe2-public/spebase/run.c
@@ -187,7 +187,7 @@ int _base_spe_context_run(spe_context_pt
 		 *   0x20   SPU has tried to execute an invalid instruction.
 		 *   0x40   SPU has tried to access an invalid channel. 
 		 */
-		else if (ret & 0x02) { /*Test for stop&signal*/
+		else if (ret & SPE_SPU_STOPPED_BY_STOP) { /*Test for stop&signal*/
 			/* Stop&Signals are broken down into tree groups
 			 * 1. SPE library calls 
 			 * 2. SPE user defined Stop&Signals
@@ -256,14 +256,14 @@ int _base_spe_context_run(spe_context_pt
 				errno = 0;
 			}
 
-		} else if (ret & 0x04) { /*Test for halt*/
+		} else if (ret & SPE_SPU_HALT) { /*Test for halt*/
 			//   0x04   SPU was stopped by halt.
 			DEBUG_PRINTF("0x04   SPU was stopped by halt.%d\n", ret);
 			stopinfo->stop_reason = SPE_RUNTIME_ERROR;
-			stopinfo->result.spe_runtime_error = 0x04;
+			stopinfo->result.spe_runtime_error = SPE_SPU_HALT;
 			errno = EFAULT;
 			return -1;
-		} else if (ret & 0x08) { /*Test for wait on channel*/
+		} else if (ret & SPE_SPU_WAITING_ON_CHANNEL) { /*Test for wait on channel*/
 			//   0x08   SPU is waiting for a channel.
 			DEBUG_PRINTF("0x04   SPU is waiting on channel. %d\n", ret);
 			stopinfo->stop_reason = SPE_RUNTIME_EXCEPTION;
@@ -271,18 +271,18 @@ int _base_spe_context_run(spe_context_pt
 			stopinfo->spu_status = -1;
 			errno = EIO;
 			return -1;
-		} else if (ret & 0x20) { /*Test for invalid instr.*/
+		} else if (ret & SPE_SPU_INVALID_INSTR) { /*Test for invalid instr.*/
 		    //   0x20   SPU has tried to execute an invalid instruction.
 		    DEBUG_PRINTF("0x20   SPU has tried to execute an invalid instruction.%d\n", ret);
 		    stopinfo->stop_reason = SPE_RUNTIME_ERROR;
-		    stopinfo->result.spe_runtime_error = 0x20;
+		    stopinfo->result.spe_runtime_error = SPE_SPU_INVALID_INSTR;
 		    errno = EFAULT;
 			return -1;
-		} else if (ret & 0x40) { /*Test for invalid channel*/
+		} else if (ret & SPE_SPU_INVALID_CHANNEL) { /*Test for invalid channel*/
 	    //   0x40   SPU has tried to access an invalid channel.
 			DEBUG_PRINTF("0x40   SPU has tried to access an invalid channel.%d\n", ret);
 			stopinfo->stop_reason = SPE_RUNTIME_ERROR;
-			stopinfo->result.spe_runtime_error = 0x40;
+			stopinfo->result.spe_runtime_error = SPE_SPU_INVALID_CHANNEL;
 			errno = EFAULT;
 			return -1;
 		} else { /*ERROR - SPE Stopped without a specific reason*/



More information about the cbe-oss-dev mailing list