diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-02-09 22:15:53 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-02-09 22:15:53 +0000 |
commit | 5922525fffe16dbb4a91697f743c9b0a53093934 (patch) | |
tree | bcd9428c8978c8194f0736d280e076d70ded09a8 /sys | |
parent | c8ab9aefe725cade4bf24a8178be5cf9dc66400f (diff) |
repair cpu dmesg print a bit
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/cacheinfo.c | 30 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 74 | ||||
-rw-r--r-- | sys/arch/amd64/include/cpu.h | 3 | ||||
-rw-r--r-- | sys/arch/amd64/include/specialreg.h | 20 |
4 files changed, 84 insertions, 43 deletions
diff --git a/sys/arch/amd64/amd64/cacheinfo.c b/sys/arch/amd64/amd64/cacheinfo.c index 813825c4d44..f54b77f0fad 100644 --- a/sys/arch/amd64/amd64/cacheinfo.c +++ b/sys/arch/amd64/amd64/cacheinfo.c @@ -19,14 +19,16 @@ print_cache_config(struct cpu_info *ci, int cache_tag, char *name, char *sep) printf("%s: ", ci->ci_dev->dv_xname); else printf("%s", sep); - if (name != NULL) - printf("%s ", name); - if (cai->cai_string != NULL) { + if (cai->cai_string != NULL) printf("%s ", cai->cai_string); - } else { - printf("%d %db/line ", cai->cai_totalsize, cai->cai_linesize); - } + else if (cai->cai_totalsize >= 1024*1024) + printf("%dMB %db/line ", cai->cai_totalsize / 1024 / 1024, + cai->cai_linesize); + else + printf("%dKB %db/line ", cai->cai_totalsize / 1024, + cai->cai_linesize); + switch (cai->cai_associativity) { case 0: printf("disabled"); @@ -41,6 +43,10 @@ print_cache_config(struct cpu_info *ci, int cache_tag, char *name, char *sep) printf("%d-way", cai->cai_associativity); break; } + + if (name != NULL) + printf(" %s", name); + return ", "; } @@ -62,7 +68,12 @@ print_tlb_config(struct cpu_info *ci, int cache_tag, char *name, char *sep) if (cai->cai_string != NULL) { printf("%s", cai->cai_string); } else { - printf("%d %d entries ", cai->cai_totalsize, cai->cai_linesize); + if (cai->cai_linesize >= 1024*1024) + printf("%d %dMB entries ", cai->cai_totalsize, + cai->cai_linesize / 1024 / 1024); + else + printf("%d %dKB entries ", cai->cai_totalsize, + cai->cai_linesize / 1024); switch (cai->cai_associativity) { case 0: printf("disabled"); @@ -210,15 +221,14 @@ x86_print_cacheinfo(struct cpu_info *ci) { char *sep; + sep = NULL; if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 || ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) { sep = print_cache_config(ci, CAI_ICACHE, "I-cache", NULL); sep = print_cache_config(ci, CAI_DCACHE, "D-cache", sep); - if (sep != NULL) - printf("\n"); } if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) { - sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", NULL); + sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", sep); if (sep != NULL) printf("\n"); } diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 6535b5e768c..b2fd81a6a74 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.1 2004/01/28 01:39:38 mickey Exp $ */ +/* $OpenBSD: identcpu.c,v 1.2 2004/02/09 22:15:52 mickey Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -44,16 +44,60 @@ /* sysctl wants this. */ char cpu_model[48]; +const struct { + u_int32_t bit; + char str[8]; +} cpu_cpuid_features[] = { + { CPUID_FPU, "FPU" }, + { CPUID_VME, "VME" }, + { CPUID_DE, "DE" }, + { CPUID_PSE, "PSE" }, + { CPUID_TSC, "TSC" }, + { CPUID_MSR, "MSR" }, + { CPUID_PAE, "PAE" }, + { CPUID_MCE, "MCE" }, + { CPUID_CX8, "CX8" }, + { CPUID_APIC, "APIC" }, + { CPUID_SEP, "SEP" }, + { CPUID_MTRR, "MTRR" }, + { CPUID_PGE, "PGE" }, + { CPUID_MCA, "MCA" }, + { CPUID_CMOV, "CMOV" }, + { CPUID_PAT, "PAT" }, + { CPUID_PSE36, "PSE36" }, + { CPUID_PN, "PN" }, + { CPUID_CFLUSH, "CFLUSH" }, + { CPUID_DS, "DS" }, + { CPUID_ACPI, "ACPI" }, + { CPUID_MMX, "MMX" }, + { CPUID_FXSR, "FXSR" }, + { CPUID_SSE, "SSE" }, + { CPUID_SSE2, "SSE2" }, + { CPUID_SS, "SS" }, + { CPUID_HTT, "HTT" }, + { CPUID_TM, "TM" }, + { CPUID_IA64, "IA64" }, + { CPUID_SBF, "SBF" } +}, cpu_ecpuid_features[] = { + { CPUID_MPC, "MPC" }, + { CPUID_NXE, "NXE" }, + { CPUID_MMXX, "MMXX" }, + { CPUID_FFXSR, "FFXSR" }, + { CPUID_LONG, "LONG" }, + { CPUID_3DNOW2, "3DNOW2" }, + { CPUID_3DNOW, "3DNOW" } +}; + void identifycpu(struct cpu_info *ci) { u_int64_t last_tsc; u_int32_t dummy, val; u_int32_t brand[12]; + int i, max; CPUID(1, ci->ci_signature, val, dummy, ci->ci_feature_flags); - CPUID(0x80000001, dummy, dummy, dummy, val); - ci->ci_feature_flags |= val; + CPUID(0x80000001, dummy, dummy, dummy, ci->ci_feature_eflags); CPUID(0x80000002, brand[0], brand[1], brand[2], brand[3]); CPUID(0x80000003, brand[4], brand[5], brand[6], brand[7]); @@ -74,20 +118,18 @@ identifycpu(struct cpu_info *ci) if (ci->ci_tsc_freq != 0) printf(", %lu.%02lu MHz", (ci->ci_tsc_freq + 4999) / 1000000, ((ci->ci_tsc_freq + 4999) / 10000) % 100); - printf("\n"); - if ((ci->ci_feature_flags & CPUID_MASK1) != 0) { - printf("%s: features: %b\n", ci->ci_dev->dv_xname, - ci->ci_feature_flags, CPUID_FLAGS1); - } - if ((ci->ci_feature_flags & CPUID_MASK2) != 0) { - printf("%s: features: %b\n", ci->ci_dev->dv_xname, - ci->ci_feature_flags, CPUID_EXT_FLAGS2); - } - if ((ci->ci_feature_flags & CPUID_MASK3) != 0) { - printf("%s: features: %b\n", ci->ci_dev->dv_xname, - ci->ci_feature_flags, CPUID_EXT_FLAGS3); - } + printf("\n%s: ", ci->ci_dev->dv_xname); + + max = sizeof(cpu_cpuid_features) / sizeof(cpu_cpuid_features[0]); + for (i = 0; i < max; i++) + if (ci->ci_feature_flags & cpu_cpuid_features[i].bit) + printf("%s%s", i? "," : "", cpu_cpuid_features[i].str); + max = sizeof(cpu_ecpuid_features) / sizeof(cpu_ecpuid_features[0]); + for (i = 0; i < max; i++) + if (ci->ci_feature_eflags & cpu_ecpuid_features[i].bit) + printf(",%s", cpu_ecpuid_features[i].str); + printf("\n"); x86_print_cacheinfo(ci); diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index 44e4a446ccb..e749254cf9e 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */ +/* $OpenBSD: cpu.h,v 1.2 2004/02/09 22:15:52 mickey Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -92,6 +92,7 @@ struct cpu_info { u_int32_t ci_ipis; u_int32_t ci_feature_flags; + u_int32_t ci_feature_eflags; u_int32_t ci_signature; u_int64_t ci_tsc_freq; diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h index ef6db41a1fc..89bf2b88495 100644 --- a/sys/arch/amd64/include/specialreg.h +++ b/sys/arch/amd64/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */ +/* $OpenBSD: specialreg.h,v 1.2 2004/02/09 22:15:52 mickey Exp $ */ /* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ /* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */ @@ -117,7 +117,7 @@ #define CPUID_DS 0x00200000 /* Debug Store */ #define CPUID_ACPI 0x00400000 /* ACPI performance modulation regs */ #define CPUID_MMX 0x00800000 /* MMX supported */ -#define CPUID_FXSR 0x01000000 /* fast FP/MMX save/restore */ +#define CPUID_FXSR 0x01000000 /* FP/MMX save/restore */ #define CPUID_SSE 0x02000000 /* streaming SIMD extensions */ #define CPUID_SSE2 0x04000000 /* streaming SIMD extensions #2 */ #define CPUID_SS 0x08000000 /* self-snoop */ @@ -126,15 +126,6 @@ #define CPUID_IA64 0x40000000 /* IA-64 architecture */ #define CPUID_SBF 0x80000000 /* signal break on FERR */ -#define CPUID_FLAGS1 "\20\1FPU\2VME\3DE\4PSE\5TSC\6MSR\7PAE" \ - "\10MCE\11CX8\12APIC\13B10\14SEP\15MTRR" -#define CPUID_MASK1 0x00001fff -#define CPUID_FLAGS2 "\20\16PGE\17MCA\20CMOV\21PAT\22PSE36\23PN\24CFLUSH" \ - "\25B20\26DS\27ACPI\30MMX" -#define CPUID_MASK2 0x00ffe000 -#define CPUID_FLAGS3 "\20\31FXSR\32SSE\33SSE2\34SS\35HTT\36TM\37IA64\40SBF" -#define CPUID_MASK3 0xff000000 - /* * AMD/VIA processor specific flags. */ @@ -142,14 +133,11 @@ #define CPUID_MPC 0x00080000 /* Multiprocessing Capable */ #define CPUID_NXE 0x00100000 /* No-Execute Extension */ #define CPUID_MMXX 0x00400000 /* AMD MMX Extensions */ +#define CPUID_FFXSR 0x02000000 /* fast FP/MMX save/restore */ +#define CPUID_LONG 0x20000000 /* long mode */ #define CPUID_3DNOW2 0x40000000 /* 3DNow! Instruction Extension */ #define CPUID_3DNOW 0x80000000 /* 3DNow! Instructions */ -#define CPUID_EXT_FLAGS2 "\20\16PGE\17MCA\20CMOV\21PAT\22PSE36\23PN" \ - "\24MPC\25NXE\26B21\27MMXX\30MMX" -#define CPUID_EXT_FLAGS3 "\20\31FXSR\32SSE\33SSE2\34B27\35B28\36LONG" \ - "\0373DNOW2\0403DNOW" - #define CPUID2FAMILY(cpuid) (((cpuid) >> 8) & 15) #define CPUID2MODEL(cpuid) (((cpuid) >> 4) & 15) #define CPUID2STEPPING(cpuid) ((cpuid) & 15) |