Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Sep 2009 15:14:15 GMT
From:      Justin Hibbits <jrh29@alumni.cwru.edu>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   powerpc/139154: Patch for Altivec sysctl
Message-ID:  <200909261514.n8QFEFGK065301@www.freebsd.org>
Resent-Message-ID: <200909261520.n8QFK28T073290@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         139154
>Category:       powerpc
>Synopsis:       Patch for Altivec sysctl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ppc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 26 15:20:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Justin Hibbits
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD narn.knownspace 9.0-CURRENT FreeBSD 9.0-CURRENT #24 r197331M: Sun Sep 20 22:08:18 EDT 2009     root@narn.knownspace:/usr/obj/usr/src/sys/NARN  powerpc
>Description:
The attached patch adds a 'machdep.altivec' sysctl, similar to OpenBSD's.  This is necessary for ports that use altivec conditionally, including x264, the inspiration for this patch.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: powerpc/cpu.c
===================================================================
--- powerpc/cpu.c	(revision 197331)
+++ powerpc/cpu.c	(working copy)
@@ -67,6 +67,7 @@
 #include <sys/sysctl.h>
 
 #include <machine/bus.h>
+#include <machine/cpu.h>
 #include <machine/hid.h>
 #include <machine/md_var.h>
 #include <machine/spr.h>
@@ -110,7 +111,9 @@
 };
 
 static char model[64];
+static int ppc_altivec;
 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, "");
+SYSCTL_INT(_machdep, CPU_ALTIVEC, altivec, CTLFLAG_RD, &ppc_altivec, 0, "");
 
 register_t	l2cr_config = 0;
 register_t	l3cr_config = 0;
@@ -288,6 +291,24 @@
 			break;
 	}
 
+	switch (vers) {
+		case MPC7400:
+		case MPC7450:
+		case MPC7455:
+		case MPC7457:
+		case MPC7447A:
+		case MPC7448:
+		case MPC7410:
+		case IBM970:
+		case IBM970FX:
+		case IBM970MP:
+		case IBM970GX:
+			ppc_altivec=1;
+			break;
+		default:
+			ppc_altivec=0;
+	}
+
 	printf("cpu%d: HID0 %b\n", cpuid, hid0, bitmask);
 }
 
Index: include/cpu.h
===================================================================
--- include/cpu.h	(revision 197331)
+++ include/cpu.h	(working copy)
@@ -49,6 +49,7 @@
  * CTL_MACHDEP definitions.
  */
 #define	CPU_CACHELINE	1
+#define	CPU_ALTIVEC		2
 
 static __inline u_int64_t
 get_cyclecount(void)


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909261514.n8QFEFGK065301>