Get correct cache information for earlier VIA C3 models.

Mostly from PR kern/26689 submitted by Michael van Elst.
This commit is contained in:
briggs 2004-08-17 15:27:46 +00:00
parent c6736a59b3
commit 4634c8ef35
2 changed files with 22 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cacheinfo.h,v 1.2 2004/08/08 05:16:16 briggs Exp $ */
/* $NetBSD: cacheinfo.h,v 1.3 2004/08/17 15:27:46 briggs Exp $ */
#ifndef _X86_CACHEINFO_H
#define _X86_CACHEINFO_H
@ -144,10 +144,16 @@ void x86_print_cacheinfo(struct cpu_info *);
#define VIA_L1_EDX_IC_LPT(x) (((x) >> 8) & 0xff)
#define VIA_L1_EDX_IC_LS(x) ( (x) & 0xff)
/* L2 Cache */
#define VIA_L2_ECX_C_SIZE(x) ((((x) >> 16) & 0xffff) * 1024)
#define VIA_L2_ECX_C_ASSOC(x) (((x) >> 12) & 0xf)
#define VIA_L2_ECX_C_LPT(x) (((x) >> 8) & 0xf)
/* L2 Cache (pre-Nehemiah) */
#define VIA_L2_ECX_C_SIZE(x) ((((x) >> 24) & 0xff) * 1024)
#define VIA_L2_ECX_C_ASSOC(x) (((x) >> 16) & 0xff)
#define VIA_L2_ECX_C_LPT(x) (((x) >> 8) & 0xff)
#define VIA_L2_ECX_C_LS(x) ( (x) & 0xff)
/* L2 Cache (Nehemiah and newer) */
#define VIA_L2N_ECX_C_SIZE(x) ((((x) >> 16) & 0xffff) * 1024)
#define VIA_L2N_ECX_C_ASSOC(x) (((x) >> 12) & 0xf)
#define VIA_L2N_ECX_C_LPT(x) (((x) >> 8) & 0xf)
#define VIA_L2N_ECX_C_LS(x) ( (x) & 0xff)
#endif /* _X86_CACHEINFO_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: cacheinfo.c,v 1.5 2004/08/08 05:16:16 briggs Exp $ */
/* $NetBSD: cacheinfo.c,v 1.6 2004/08/17 15:27:46 briggs Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cacheinfo.c,v 1.5 2004/08/08 05:16:16 briggs Exp $");
__KERNEL_RCSID(0, "$NetBSD: cacheinfo.c,v 1.6 2004/08/17 15:27:46 briggs Exp $");
#include <sys/types.h>
#include <sys/systm.h>
@ -318,9 +318,15 @@ via_cpu_cacheinfo(struct cpu_info *ci)
CPUID(0x80000006, descs[0], descs[1], descs[2], descs[3]);
cai = &ci->ci_cinfo[CAI_L2CACHE];
cai->cai_totalsize = VIA_L2_ECX_C_SIZE(descs[2]);
cai->cai_associativity = VIA_L2_ECX_C_ASSOC(descs[2]);
cai->cai_linesize = VIA_L2_ECX_C_LS(descs[2]);
if (model >= 9) {
cai->cai_totalsize = VIA_L2N_ECX_C_SIZE(descs[2]);
cai->cai_associativity = VIA_L2N_ECX_C_ASSOC(descs[2]);
cai->cai_linesize = VIA_L2N_ECX_C_LS(descs[2]);
} else {
cai->cai_totalsize = VIA_L2_ECX_C_SIZE(descs[2]);
cai->cai_associativity = VIA_L2_ECX_C_ASSOC(descs[2]);
cai->cai_linesize = VIA_L2_ECX_C_LS(descs[2]);
}
}
void