From owner-svn-src-all@FreeBSD.ORG Wed Dec 23 06:52:12 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F07A61065693; Wed, 23 Dec 2009 06:52:12 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF2BC8FC1B; Wed, 23 Dec 2009 06:52:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBN6qCU9088829; Wed, 23 Dec 2009 06:52:12 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBN6qCRa088827; Wed, 23 Dec 2009 06:52:12 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200912230652.nBN6qCRa088827@svn.freebsd.org> From: Marcel Moolenaar Date: Wed, 23 Dec 2009 06:52:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200891 - head/sys/sparc64/sparc64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2009 06:52:13 -0000 Author: marcel Date: Wed Dec 23 06:52:12 2009 New Revision: 200891 URL: http://svn.freebsd.org/changeset/base/200891 Log: Calculate the average CPU clock frequency and export that through the hw.freq.cpu sysctl variable. This can be used by ports that need to know "the" CPU frequency. Modified: head/sys/sparc64/sparc64/identcpu.c Modified: head/sys/sparc64/sparc64/identcpu.c ============================================================================== --- head/sys/sparc64/sparc64/identcpu.c Wed Dec 23 05:15:40 2009 (r200890) +++ head/sys/sparc64/sparc64/identcpu.c Wed Dec 23 06:52:12 2009 (r200891) @@ -27,6 +27,13 @@ static char cpu_model[128]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model"); +SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, ""); + +static u_int cpu_count; +static u_int cpu_freq; +SYSCTL_UINT(_hw_freq, OID_AUTO, cpu, CTLFLAG_RD, &cpu_freq, 0, + "CPU clock frequency"); + int cpu_impl; void @@ -104,4 +111,11 @@ cpu_identify(u_long vers, u_int freq, u_ printf(" mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers), VER_MAXTL(vers), VER_MAXWIN(vers)); } + + /* + * Calculate the average CPU frequency. + */ + freq = (freq + 500000ul) / 1000000ul; + cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1); + cpu_count++; }