Module Name: src Committed By: christos Date: Mon Mar 24 20:07:41 UTC 2014
Modified Files: src/sys/kern: init_sysctl.c kern_cpu.c src/sys/sys: cpu.h systm.h Log Message: - create cpu_{g,s}etmodel() and hide cpu_model from direct access. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/kern/init_sysctl.c cvs rdiff -u -r1.63 -r1.64 src/sys/kern/kern_cpu.c cvs rdiff -u -r1.39 -r1.40 src/sys/sys/cpu.h cvs rdiff -u -r1.260 -r1.261 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/init_sysctl.c diff -u src/sys/kern/init_sysctl.c:1.201 src/sys/kern/init_sysctl.c:1.202 --- src/sys/kern/init_sysctl.c:1.201 Tue Feb 25 13:30:11 2014 +++ src/sys/kern/init_sysctl.c Mon Mar 24 16:07:41 2014 @@ -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 @@ SYSCTL_SETUP(sysctl_hw_setup, "sysctl hw { u_int u; u_quad_t q; + const char *model = cpu_getmodel(); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT, @@ -646,7 +647,7 @@ SYSCTL_SETUP(sysctl_hw_setup, "sysctl hw 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, Index: src/sys/kern/kern_cpu.c diff -u src/sys/kern/kern_cpu.c:1.63 src/sys/kern/kern_cpu.c:1.64 --- src/sys/kern/kern_cpu.c:1.63 Sun Mar 16 01:20:30 2014 +++ src/sys/kern/kern_cpu.c Mon Mar 24 16:07:41 2014 @@ -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 @@ struct cpu_info **cpu_infos __read_most 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 @@ cpu_setstate(struct cpu_info *ci, bool o 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) Index: src/sys/sys/cpu.h diff -u src/sys/sys/cpu.h:1.39 src/sys/sys/cpu.h:1.40 --- src/sys/sys/cpu.h:1.39 Sun Nov 24 22:06:08 2013 +++ src/sys/sys/cpu.h Mon Mar 24 16:07:40 2014 @@ -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 @@ void cpu_offline_md(void); 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); Index: src/sys/sys/systm.h diff -u src/sys/sys/systm.h:1.260 src/sys/sys/systm.h:1.261 --- src/sys/sys/systm.h:1.260 Sat Feb 1 04:04:57 2014 +++ src/sys/sys/systm.h Mon Mar 24 16:07:40 2014 @@ -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 const char *panicstr; /* panic me 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 */