From patchwork Mon Feb 15 22:45:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Lock X-Patchwork-Id: 45444 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C314EB7080 for ; Tue, 16 Feb 2010 09:54:58 +1100 (EST) Received: from localhost ([127.0.0.1]:47266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh9qB-0001UK-Fw for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 17:54:55 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh9pd-0001Tr-H7 for qemu-devel@nongnu.org; Mon, 15 Feb 2010 17:54:21 -0500 Received: from [199.232.76.173] (port=54266 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh9pd-0001Tj-5b for qemu-devel@nongnu.org; Mon, 15 Feb 2010 17:54:21 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nh9pb-00050R-8D for qemu-devel@nongnu.org; Mon, 15 Feb 2010 17:54:20 -0500 Received: from gelbbaer.kn-bremen.de ([78.46.108.116]:46455 helo=smtp.kn-bremen.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh9pa-0004yq-SG for qemu-devel@nongnu.org; Mon, 15 Feb 2010 17:54:19 -0500 Received: by smtp.kn-bremen.de (Postfix, from userid 10) id 5D9651E00766; Mon, 15 Feb 2010 23:54:17 +0100 (CET) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.3/8.14.3) with ESMTP id o1FMj7GY030011; Mon, 15 Feb 2010 23:45:07 +0100 (CET) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.3/8.14.3/Submit) id o1FMj7SV030010; Mon, 15 Feb 2010 23:45:07 +0100 (CET) (envelope-from nox) From: Juergen Lock Date: Mon, 15 Feb 2010 23:45:06 +0100 To: malc Subject: Re: [Qemu-devel] [PATCH 1/3] Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation. Message-ID: <20100215224506.GB29604@triton8.kn-bremen.de> References: <20100214201056.GA97858@triton8.kn-bremen.de> <20100214201209.GA97896@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Juergen Lock , qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Mon, Feb 15, 2010 at 06:15:41AM +0300, malc wrote: > On Sun, 14 Feb 2010, Juergen Lock wrote: > > > Submitted by: Andreas Tobler > > > > Signed-off-by: Juergen Lock > > > > --- a/cache-utils.c > > +++ b/cache-utils.c > > @@ -57,6 +57,23 @@ > > } > > #endif > > > > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) > > +#include > > +#include > > +#include > > + > > +static void ppc_init_cacheline_sizes(void) > > +{ > > + size_t len = 4; > > + unsigned cacheline; > > + > > + sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0); > > Error handling missing. Mmh I suspect thats a sysctl that simply can't fail but of course checking still doesn't hurt: Submitted by: Andreas Tobler Signed-off-by: Juergen Lock --- a/cache-utils.c +++ b/cache-utils.c @@ -57,6 +57,27 @@ static void ppc_init_cacheline_sizes(voi } #endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include +#include +#include + +static void ppc_init_cacheline_sizes(void) +{ + size_t len = 4; + unsigned cacheline; + + if (sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0)) { + fprintf(stderr, "sysctlbyname machdep.cacheline_size failed: %s\n", + strerror(errno)); + exit(1); + } + + qemu_cache_conf.dcache_bsize = cacheline; + qemu_cache_conf.icache_bsize = cacheline; +} +#endif + #ifdef __linux__ void qemu_cache_utils_init(char **envp) {