Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/arch/sparc64 Pull up following revision(s) (requested...
details: https://anonhg.NetBSD.org/src/rev/adc5421c71dc
branches: netbsd-7
changeset: 798702:adc5421c71dc
user: martin <martin%NetBSD.org@localhost>
date: Sat Dec 13 19:29:28 2014 +0000
description:
Pull up following revision(s) (requested by nakayama in ticket #318):
sys/arch/sparc64/include/psl.h: revision 1.54
sys/arch/sparc64/include/psl.h: revision 1.55
sys/arch/sparc64/sparc64/cpu.c: revision 1.121
Make getver() into a constant function since Version Register (%ver)
is read only and its value is constant.
This change reduces multipule %ver reads to one in the functions
which uses a number of CPU_IS_* macros.
Use GETVER_CPU_* macros.
diffstat:
sys/arch/sparc64/include/psl.h | 22 ++++++++++++++++++++--
sys/arch/sparc64/sparc64/cpu.c | 16 ++++++----------
2 files changed, 26 insertions(+), 12 deletions(-)
diffs (118 lines):
diff -r ea9774251741 -r adc5421c71dc sys/arch/sparc64/include/psl.h
--- a/sys/arch/sparc64/include/psl.h Sat Dec 13 19:23:09 2014 +0000
+++ b/sys/arch/sparc64/include/psl.h Sat Dec 13 19:29:28 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: psl.h,v 1.53 2013/08/18 09:31:38 martin Exp $ */
+/* $NetBSD: psl.h,v 1.53.4.1 2014/12/13 19:29:28 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -287,6 +287,13 @@
/*
* Inlines for manipulating privileged and ancillary state registers
*/
+#define SPARC64_RDCONST_DEF(rd, name, reg, type) \
+static __inline __constfunc type get##name(void) \
+{ \
+ type _val; \
+ __asm(#rd " %" #reg ",%0" : "=r" (_val)); \
+ return _val; \
+}
#define SPARC64_RD_DEF(rd, name, reg, type) \
static __inline type get##name(void) \
{ \
@@ -301,9 +308,19 @@
}
#ifdef __arch64__
+#define SPARC64_RDCONST64_DEF(rd, name, reg) \
+ SPARC64_RDCONST_DEF(rd, name, reg, uint64_t)
#define SPARC64_RD64_DEF(rd, name, reg) SPARC64_RD_DEF(rd, name, reg, uint64_t)
#define SPARC64_WR64_DEF(wr, name, reg) SPARC64_WR_DEF(wr, name, reg, uint64_t)
#else
+#define SPARC64_RDCONST64_DEF(rd, name, reg) \
+static __inline __constfunc uint64_t get##name(void) \
+{ \
+ uint32_t _hi, _lo; \
+ __asm(#rd " %" #reg ",%0; srl %0,0,%1; srlx %0,32,%0" \
+ : "=r" (_hi), "=r" (_lo)); \
+ return ((uint64_t)_hi << 32) | _lo; \
+}
#define SPARC64_RD64_DEF(rd, name, reg) \
static __inline uint64_t get##name(void) \
{ \
@@ -345,13 +362,14 @@
SPARC64_WRPR_DEF(cwp, %cwp, int) /* setcwp() */
/* Version Register (PR 31) */
-SPARC64_RDPR64_DEF(ver, %ver) /* getver() */
+SPARC64_RDCONST64_DEF(rdpr, ver, %ver) /* getver() */
/* System Tick Register (ASR 24) */
SPARC64_RDASR64_DEF(stick, STICK) /* getstick() */
SPARC64_WRASR64_DEF(stick, STICK) /* setstick() */
/* Some simple macros to check the cpu type. */
+#define GETVER_CPU_MASK() ((getver() & VER_MASK) >> VER_MASK_SHIFT)
#define GETVER_CPU_IMPL() ((getver() & VER_IMPL) >> VER_IMPL_SHIFT)
#define GETVER_CPU_MANUF() ((getver() & VER_MANUF) >> VER_MANUF_SHIFT)
#define CPU_IS_SPITFIRE() (GETVER_CPU_IMPL() == IMPL_SPITFIRE)
diff -r ea9774251741 -r adc5421c71dc sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c Sat Dec 13 19:23:09 2014 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c Sat Dec 13 19:29:28 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.116 2014/07/25 18:29:45 nakayama Exp $ */
+/* $NetBSD: cpu.c,v 1.116.2.1 2014/12/13 19:29:28 martin Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.116 2014/07/25 18:29:45 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.116.2.1 2014/12/13 19:29:28 martin Exp $");
#include "opt_multiprocessor.h"
@@ -284,7 +284,6 @@
struct cpu_info *ci;
const char *sep;
register int i, l;
- uint64_t ver;
int bigcache, cachesize;
char buf[100];
int totalsize = 0;
@@ -349,11 +348,10 @@
aprint_normal(": %s, CPU id %d\n", buf, ci->ci_cpuid);
aprint_naive("\n");
if (CPU_ISSUN4U || CPU_ISSUN4US) {
- ver = getver();
aprint_normal_dev(dev, "manuf %x, impl %x, mask %x\n",
- (u_int)((ver & VER_MANUF) >> VER_MANUF_SHIFT),
- (u_int)((ver & VER_IMPL) >> VER_IMPL_SHIFT),
- (u_int)((ver & VER_MASK) >> VER_MASK_SHIFT));
+ (u_int)GETVER_CPU_MANUF(),
+ (u_int)GETVER_CPU_IMPL(),
+ (u_int)GETVER_CPU_MASK());
}
if (ci->ci_system_clockrate[0] != 0) {
@@ -495,7 +493,6 @@
cpu_myid(void)
{
char buf[32];
- int impl;
#ifdef SUN4V
if (CPU_ISSUN4V) {
@@ -507,8 +504,7 @@
if (OF_getprop(findroot(), "name", buf, sizeof(buf)) > 0 &&
strcmp(buf, "SUNW,Ultra-Enterprise-10000") == 0)
return lduwa(0x1fff40000d0UL, ASI_PHYS_NON_CACHED);
- impl = (getver() & VER_IMPL) >> VER_IMPL_SHIFT;
- switch (impl) {
+ switch (GETVER_CPU_IMPL()) {
case IMPL_OLYMPUS_C:
case IMPL_JUPITER:
return CPU_JUPITERID;
Home |
Main Index |
Thread Index |
Old Index