Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - create cpu_{g, s}etmodel() and hide cpu_model from dir...
details: https://anonhg.NetBSD.org/src/rev/f25973eabc2c
branches: trunk
changeset: 328051:f25973eabc2c
user: christos <christos%NetBSD.org@localhost>
date: Mon Mar 24 20:07:40 2014 +0000
description:
- create cpu_{g,s}etmodel() and hide cpu_model from direct access.
diffstat:
sys/kern/init_sysctl.c | 7 ++++---
sys/kern/kern_cpu.c | 25 +++++++++++++++++++++++--
sys/sys/cpu.h | 4 +++-
sys/sys/systm.h | 3 +--
4 files changed, 31 insertions(+), 8 deletions(-)
diffs (123 lines):
diff -r 08a0518713ee -r f25973eabc2c sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c Mon Mar 24 20:06:31 2014 +0000
+++ b/sys/kern/init_sysctl.c Mon Mar 24 20:07:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl.c,v 1.201 2014/02/25 18:30:11 pooka Exp $ */
+/* $NetBSD: init_sysctl.c,v 1.202 2014/03/24 20:07:41 christos Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.201 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.202 2014/03/24 20:07:41 christos Exp $");
#include "opt_sysv.h"
#include "opt_compat_netbsd.h"
@@ -635,6 +635,7 @@
{
u_int u;
u_quad_t q;
+ const char *model = cpu_getmodel();
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
@@ -646,7 +647,7 @@
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "model",
SYSCTL_DESCR("Machine model"),
- NULL, 0, cpu_model, 0,
+ NULL, 0, __UNCONST(model), 0,
CTL_HW, HW_MODEL, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
diff -r 08a0518713ee -r f25973eabc2c sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c Mon Mar 24 20:06:31 2014 +0000
+++ b/sys/kern/kern_cpu.c Mon Mar 24 20:07:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_cpu.c,v 1.63 2014/03/16 05:20:30 dholland Exp $ */
+/* $NetBSD: kern_cpu.c,v 1.64 2014/03/24 20:07:41 christos Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2012 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.63 2014/03/16 05:20:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.64 2014/03/24 20:07:41 christos Exp $");
#include "opt_cpu_ucode.h"
#include "opt_compat_netbsd.h"
@@ -127,6 +127,9 @@
kcpuset_t * kcpuset_attached __read_mostly = NULL;
kcpuset_t * kcpuset_running __read_mostly = NULL;
+
+static char cpu_model[128];
+
/*
* mi_cpu_init: early initialisation of MI CPU related structures.
*
@@ -475,6 +478,24 @@
return 0;
}
+int
+cpu_setmodel(const char *fmt, ...)
+{
+ int len;
+ va_list ap;
+
+ va_start(ap, fmt);
+ len = snprintf(cpu_model, sizeof(cpu_model), fmt, ap);
+ va_end(ap);
+ return len;
+}
+
+const char *
+cpu_getmodel(void)
+{
+ return cpu_model;
+}
+
#ifdef __HAVE_INTR_CONTROL
static void
cpu_xc_intr(struct cpu_info *ci)
diff -r 08a0518713ee -r f25973eabc2c sys/sys/cpu.h
--- a/sys/sys/cpu.h Mon Mar 24 20:06:31 2014 +0000
+++ b/sys/sys/cpu.h Mon Mar 24 20:07:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.39 2013/11/25 03:06:08 christos Exp $ */
+/* $NetBSD: cpu.h,v 1.40 2014/03/24 20:07:40 christos Exp $ */
/*-
* Copyright (c) 2007 YAMAMOTO Takashi,
@@ -79,6 +79,8 @@
struct lwp *cpu_switchto(struct lwp *, struct lwp *, bool);
struct cpu_info *cpu_lookup(u_int);
+int cpu_setmodel(const char *fmt, ...) __printflike(1, 2);
+const char *cpu_getmodel(void);
int cpu_setstate(struct cpu_info *, bool);
int cpu_setintr(struct cpu_info *, bool);
bool cpu_intr_p(void);
diff -r 08a0518713ee -r f25973eabc2c sys/sys/systm.h
--- a/sys/sys/systm.h Mon Mar 24 20:06:31 2014 +0000
+++ b/sys/sys/systm.h Mon Mar 24 20:07:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.260 2014/02/01 09:04:57 matt Exp $ */
+/* $NetBSD: systm.h,v 1.261 2014/03/24 20:07:40 christos Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -67,7 +67,6 @@
extern int doing_shutdown; /* shutting down */
extern const char copyright[]; /* system copyright */
-extern char cpu_model[]; /* machine/cpu model name */
extern char machine[]; /* machine type */
extern char machine_arch[]; /* machine architecture */
extern const char osrelease[]; /* short system version */
Home |
Main Index |
Thread Index |
Old Index