[Cbe-oss-dev] [PATCH][RFC]libspe2: add SPE_CPU_TYPE query to spe_cpu_info_get

D. Herrendoerfer d.herrendoerfer at herrendoerfer.name
Fri Sep 19 22:15:22 EST 2008


This patch adds the SPE_CPU_TYPE query to the
spe_cpu_info_get() function. The list of EDP
capable CPUs is quite short, if anyone has 
more information about PVR values please send them
to me.

Signed-off-by: D.Herrendoerfer <herrend at de.ibm.com>

Index: libspe2/spebase/info.h
===================================================================
--- libspe2/spebase/info.h	(revision 133)
+++ libspe2/spebase/info.h	(working copy)
@@ -27,5 +27,12 @@
 int _base_spe_count_physical_cpus(int cpu_node);
 int _base_spe_count_physical_spes(int cpu_node);
 int _base_spe_count_usable_spes(int cpu_node);
+int _base_spe_read_cpu_type(int cpu_node);
+
+/* Here is a list of edp capable PVRs
+ * Known non-EDP are: 0x0070 0501 ( PS3, QS20, QS21 )
+ * Known EPD capable: 0x0070 3000 ( QS22 )
+ */
+unsigned long pvr_list_edp[] = {0x00703000, 0};
 
 #endif
Index: libspe2/spebase/info.c
===================================================================
--- libspe2/spebase/info.c	(revision 133)
+++ libspe2/spebase/info.c	(working copy)
@@ -103,6 +103,24 @@ int _base_spe_count_physical_spes(int cp
 	return ret;
 }
 
+/* Since there are no mixed-type CPU systems at this time the cpu node
+ * is currently ignored, and a result is generated that returns the 
+ * feature set of the currently running CPU.
+ */
+int _base_spe_read_cpu_type(int cpu_node)
+{
+	unsigned long pvr;
+	int i=0;
+	
+	asm volatile ("mfpvr    %0" : "=r"(pvr));
+	
+	while (pvr_list_edp[i] != 0) {
+		if (pvr_list_edp[i++] == pvr)
+			return SPE_CPU_IS_CELLEDP;
+	}
+	
+	return SPE_CPU_IS_CELLBE;
+}
 
 int _base_spe_cpu_info_get(int info_requested, int cpu_node) {
 	int ret = 0;
@@ -118,6 +136,9 @@ int _base_spe_cpu_info_get(int info_requ
 	case SPE_COUNT_USABLE_SPES:
 		ret = _base_spe_count_usable_spes(cpu_node);
 		break;
+	case SPE_CPU_TYPE:
+		ret = (_base_spe_read_cpu_type(cpu_node) == 0);
+		break;
 	default:
 		errno = EINVAL;
 		ret = -1;
Index: libspe2/libspe2-types.h
===================================================================
--- libspe2/libspe2-types.h	(revision 133)
+++ libspe2/libspe2-types.h	(working copy)
@@ -262,10 +262,13 @@ enum ps_area { SPE_MSSYNC_AREA, SPE_MFC_
 #define SPE_CALLBACK_UPDATE          2
 
 
-
 #define SPE_COUNT_PHYSICAL_CPU_NODES 1
 #define SPE_COUNT_PHYSICAL_SPES      2
 #define SPE_COUNT_USABLE_SPES        3
+#define SPE_CPU_TYPE                 4
+
+#define SPE_CPU_IS_CELLBE            1
+#define SPE_CPU_IS_CELLEDP           2
 
 /**
  * Signal Targets 






More information about the cbe-oss-dev mailing list