Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/i386 Provide information for all the cpus not ...
details: https://anonhg.NetBSD.org/src/rev/70e62d632ace
branches: trunk
changeset: 574410:70e62d632ace
user: christos <christos%NetBSD.org@localhost>
date: Sun Feb 27 22:33:20 2005 +0000
description:
Provide information for all the cpus not just the first one. This is
important because sysctl(_SC_NPROCESSORS_CONF) depends on it to get
the number of processors in the system.
diffstat:
sys/arch/i386/i386/procfs_machdep.c | 65 +++++++++++++++++++++++++++---------
1 files changed, 49 insertions(+), 16 deletions(-)
diffs (134 lines):
diff -r 45ca1af6b596 -r 70e62d632ace sys/arch/i386/i386/procfs_machdep.c
--- a/sys/arch/i386/i386/procfs_machdep.c Sun Feb 27 22:29:50 2005 +0000
+++ b/sys/arch/i386/i386/procfs_machdep.c Sun Feb 27 22:33:20 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_machdep.c,v 1.19 2004/04/06 20:37:07 wiz Exp $ */
+/* $NetBSD: procfs_machdep.c,v 1.20 2005/02/27 22:33:20 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.19 2004/04/06 20:37:07 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.20 2005/02/27 22:33:20 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,6 +66,7 @@
"fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "31"
};
+static int procfs_getonecpu(int, struct cpu_info *, char *, int *);
/*
* Linux-style /proc/cpuinfo.
@@ -76,13 +77,43 @@
int
procfs_getcpuinfstr(char *buf, int *len)
{
+ struct cpu_info *ci;
+ CPU_INFO_ITERATOR cii;
+ int i = 0, used = *len, total = *len;
+
+ *len = 0;
+ for (CPU_INFO_FOREACH(cii, ci)) {
+ if (procfs_getonecpu(i++, ci, buf, &used) == 0) {
+ *len += used;
+ total = 0;
+ break;
+ }
+ total -= used;
+ if (total > 0) {
+ buf += used;
+ *buf++ = '\n';
+ *len += used + 1;
+ used = --total;
+ if (used == 0)
+ break;
+ } else {
+ *len += used;
+ break;
+ }
+ }
+ return total == 0 ? -1 : 0;
+}
+
+static int
+procfs_getonecpu(int cpu, struct cpu_info *ci, char *buf, int *len)
+{
int left, l, i;
char featurebuf[256], *p;
p = featurebuf;
left = sizeof featurebuf;
for (i = 0; i < 32; i++) {
- if (cpu_feature & (1 << i)) {
+ if (ci->ci_feature_flags & (1 << i)) {
l = snprintf(p, left, "%s ", i386_features[i]);
left -= l;
p += l;
@@ -100,12 +131,12 @@
"model\t\t: %d\n"
"model name\t: %s\n"
"stepping\t: ",
- 0,
- (char *)cpu_info_list->ci_vendor,
- cpu_info_list->ci_cpuid_level >= 0 ?
- ((cpu_info_list->ci_signature >> 8) & 15) : cpu_class + 3,
- cpu_info_list->ci_cpuid_level >= 0 ?
- ((cpu_info_list->ci_signature >> 4) & 15) : 0,
+ cpu,
+ (char *)ci->ci_vendor,
+ ci->ci_cpuid_level >= 0 ?
+ ((ci->ci_signature >> 8) & 15) : cpu_class + 3,
+ ci->ci_cpuid_level >= 0 ?
+ ((ci->ci_signature >> 4) & 15) : 0,
cpu_model
);
@@ -114,8 +145,8 @@
if (left <= 0)
return 0;
- if (cpu_info_list->ci_cpuid_level >= 0)
- l = snprintf(p, left, "%d\n", cpu_info_list->ci_signature & 15);
+ if (ci->ci_cpuid_level >= 0)
+ l = snprintf(p, left, "%d\n", ci->ci_signature & 15);
else
l = snprintf(p, left, "unknown\n");
@@ -125,11 +156,11 @@
return 0;
- if (cpu_info_list->ci_tsc_freq != 0) {
+ if (ci->ci_tsc_freq != 0) {
u_int64_t freq, fraq;
- freq = (cpu_info_list->ci_tsc_freq + 4999) / 1000000;
- fraq = ((cpu_info_list->ci_tsc_freq + 4999) / 10000) % 100;
+ freq = (ci->ci_tsc_freq + 4999) / 1000000;
+ fraq = ((ci->ci_tsc_freq + 4999) / 10000) % 100;
l = snprintf(p, left, "cpu MHz\t\t: %qd.%qd\n",
freq, fraq);
} else
@@ -150,13 +181,15 @@
i386_fpu_fdivbug ? "yes" : "no",
i386_fpu_present ? "yes" : "no",
i386_fpu_exception ? "yes" : "no",
- cpu_info_list->ci_cpuid_level,
+ ci->ci_cpuid_level,
(rcr0() & CR0_WP) ? "yes" : "no",
featurebuf);
+ if (l > left)
+ return 0;
*len = (p + l) - buf;
- return 0;
+ return 1;
}
#ifdef __HAVE_PROCFS_MACHDEP
Home |
Main Index |
Thread Index |
Old Index