From 449a241079c349bf49cf42ed32bd5ca258c4a351 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Mon, 16 Feb 2009 15:50:06 +0000 Subject: Store conditionally extended cpuid family/model values in seperate variables in struct cpu_info instead of duplicating the process of extracting it from the signature. Discussed with several, 'just do it' weingart@, ok mikeb@ --- sys/arch/amd64/amd64/cacheinfo.c | 14 +++----------- sys/arch/amd64/amd64/identcpu.c | 9 ++++++++- sys/arch/amd64/include/cpu.h | 4 +++- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'sys') diff --git a/sys/arch/amd64/amd64/cacheinfo.c b/sys/arch/amd64/amd64/cacheinfo.c index 18b9b9562cb..197a91c452a 100644 --- a/sys/arch/amd64/amd64/cacheinfo.c +++ b/sys/arch/amd64/amd64/cacheinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cacheinfo.c,v 1.4 2008/06/26 05:42:09 ray Exp $ */ +/* $OpenBSD: cacheinfo.c,v 1.5 2009/02/16 15:50:05 jsg Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -156,8 +156,8 @@ amd_cpu_cacheinfo(struct cpu_info *ci) u_int descs[4]; u_int lfunc; - family = (ci->ci_signature >> 8) & 15; - model = CPUID2MODEL(ci->ci_signature); + family = ci->ci_family; + model = ci->ci_model; /* * K5 model 0 has none of this info. @@ -165,14 +165,6 @@ amd_cpu_cacheinfo(struct cpu_info *ci) if (family == 5 && model == 0) return; - /* - * Get extended values for K8 and up. - */ - if (family == 0xf) { - family += (ci->ci_signature >> 20) & 0xff; - model += (ci->ci_signature >> 16) & 0xf; - } - /* * Determine the largest extended function value. */ diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 458facb5da9..3c2cb00ad54 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.15 2008/06/13 00:00:45 jsg Exp $ */ +/* $OpenBSD: identcpu.c,v 1.16 2009/02/16 15:50:05 jsg Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -190,6 +190,13 @@ identifycpu(struct cpu_info *ci) if (cpu_model[0] == 0) strlcpy(cpu_model, "Opteron or Athlon 64", sizeof(cpu_model)); + ci->ci_family = (ci->ci_signature >> 8) & 0x0f; + ci->ci_model = (ci->ci_signature >> 4) & 0x0f; + if (ci->ci_family == 0x6 || ci->ci_family == 0xf) { + ci->ci_family += (ci->ci_signature >> 20) & 0xff; + ci->ci_model += ((ci->ci_signature >> 16) & 0x0f) << 4; + } + last_tsc = rdtsc(); delay(100000); ci->ci_tsc_freq = (rdtsc() - last_tsc) * 10; diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index 4320592dd16..ff9507bff77 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.40 2009/02/13 20:47:05 andreas Exp $ */ +/* $OpenBSD: cpu.h,v 1.41 2009/02/16 15:50:05 jsg Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -98,6 +98,8 @@ struct cpu_info { u_int32_t ci_feature_flags; u_int32_t ci_feature_eflags; u_int32_t ci_signature; + u_int32_t ci_family; + u_int32_t ci_model; u_int64_t ci_tsc_freq; struct cpu_functions *ci_func; -- cgit v1.2.3