From patchwork Tue Dec 29 10:31:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 59047 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2197802lbb; Tue, 29 Dec 2015 02:37:24 -0800 (PST) X-Received: by 10.140.176.130 with SMTP id w124mr80493593qhw.59.1451385444122; Tue, 29 Dec 2015 02:37:24 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m6si69609500qki.10.2015.12.29.02.37.23; Tue, 29 Dec 2015 02:37:24 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 985EC616BD; Tue, 29 Dec 2015 10:37:23 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=TWkWLMOo; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id ADC7F616F8; Tue, 29 Dec 2015 10:33:32 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9E793616C5; Tue, 29 Dec 2015 10:33:26 +0000 (UTC) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by lists.linaro.org (Postfix) with ESMTPS id 2FDF0616C5 for ; Tue, 29 Dec 2015 10:31:50 +0000 (UTC) Received: by mail-pa0-f42.google.com with SMTP id uo6so100711280pac.1 for ; Tue, 29 Dec 2015 02:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=60vzLnVFzlnI4Vaa5dJgs81v3RshSevb4RvZchQIWME=; b=TWkWLMOooyBuyDdxf1pg7qh5u9P7GZVeYQlBuVo9r6mMmo2yJggz1KXwAkRgr3o2oO UOVK0o0mgSALkWHPEZKZr0azwjCItJazuL608NTLD4htJbL+hMgsXxxjm2r1Kc7InRO7 ZGp+R63HTHZ+CdeyjIlixNdaD5o/qU4gEyGJQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=60vzLnVFzlnI4Vaa5dJgs81v3RshSevb4RvZchQIWME=; b=bBcLD9kSOBC1rRsUymLNhxHPvlMocUnG7a8k4UwyA1p9dFo3l/yJdmZxRwGUXQZ9U7 YmnmRbZlu29abHFPSVmYPO9NGVB8WpDL9Usg2UL0ph4IhFnopAajt2HtaWxhWWB5ZOot WbrcHnHJNApSodTi4qqSFVgGlf+Rv5j6Z3t2A0a1iLLCh5AVzNhjPev6RXKPo4qJSkb+ mH21xzx0I3KTAhCvsUaB5fVHxrTIKg7ZdGMY85OnvihOmW3U8R/Z1sg8ypvI5BtZJWdG 7cx/G85WitHYCJ12vFXx2xgLMjDEPpViRy111yGQawPW3gk+D5NpGElf0KEnomSqZL/w t8Hg== X-Gm-Message-State: ALoCoQnpOX8nz0uARcOu9mCCAxZIkhKFncNqqn5B5jG3+ciOmAp80W1cHPPwFi426RT6Amz9TvrAad7rSfzgCKVi55TxF/jggQ== X-Received: by 10.66.192.42 with SMTP id hd10mr83625596pac.111.1451385109580; Tue, 29 Dec 2015 02:31:49 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 7sm82291757pfb.62.2015.12.29.02.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 02:31:49 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Tue, 29 Dec 2015 18:31:18 +0800 Message-Id: <1451385082-8364-8-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1451385082-8364-1-git-send-email-hongbo.zhang@linaro.org> References: <1451385082-8364-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 API-NEXT 07/11] linux-generic: sysinfo: move PowerPC system info codes to its plarform file X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Hongbo Zhang This patch moves the PowerPC system info codes into the newly added PowerPC specific platform file. This patch also creates syslink to arch/linux/odp_cpu_cycles.c for PowerPC. Signed-off-by: Hongbo Zhang --- configure.ac | 1 + platform/linux-generic/Makefile.am | 2 + .../linux-generic/arch/powerpc/odp_cpu_cycles.c | 1 + .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 54 ++++++++++++++++++++++ platform/linux-generic/odp_system_info.c | 53 --------------------- 5 files changed, 58 insertions(+), 53 deletions(-) create mode 120000 platform/linux-generic/arch/powerpc/odp_cpu_cycles.c create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c diff --git a/configure.ac b/configure.ac index 4f89f03..6440643 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,7 @@ AX_VALGRIND_CHECK AS_CASE([$host], [x86*], [ARCH=x86], [mips64*], [ARCH=mips64], + [powerpc*], [ARCH=powerpc], [ARCH=linux] ) AC_SUBST([ARCH]) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 9bc96ff..57584ac 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -166,6 +166,8 @@ EXTRA_DIST = \ arch/linux/odp_sysinfo_parse.c \ arch/mips64/odp_cpu_cycles.c \ arch/mips64/odp_sysinfo_parse.c \ + arch/powerpc/odp_cpu_cycles.c \ + arch/powerpc/odp_sysinfo_parse.c \ arch/x86/odp_cpu_cycles.c \ arch/x86/odp_sysinfo_parse.c diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_cycles.c b/platform/linux-generic/arch/powerpc/odp_cpu_cycles.c new file mode 120000 index 0000000..612e100 --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp_cpu_cycles.c @@ -0,0 +1 @@ +platform/linux-generic/arch/linux/odp_cpu_cycles.c \ No newline at end of file diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c new file mode 100644 index 0000000..8d9a8eb --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c @@ -0,0 +1,54 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) +{ + char str[1024]; + char *pos; + double mhz = 0.0; + int model = 0; + int count = 2; + + while (fgets(str, sizeof(str), file) != NULL && count > 0) { + if (!mhz) { + pos = strstr(str, "clock"); + + if (pos) { + sscanf(pos, "clock : %lf", &mhz); + count--; + } + } + + if (!model) { + pos = strstr(str, "cpu"); + + if (pos) { + int len; + + pos = strchr(str, ':'); + strncpy(sysinfo->model_str[0], pos + 2, + sizeof(sysinfo->model_str[0])); + len = strlen(sysinfo->model_str[0]); + sysinfo->model_str[0][len - 1] = 0; + model = 1; + count--; + } + } + + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); + } + + return 0; +} + +uint64_t odp_cpu_hz_current(int id ODP_UNUSED) +{ + return -1; +} diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 158a6b9..cc84081 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -105,59 +105,6 @@ static int huge_page_size(void) } - -/* - * HW specific /proc/cpuinfo file parsing - */ -#if defined __powerpc__ -static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) -{ - char str[1024]; - char *pos; - double mhz = 0.0; - int model = 0; - int count = 2; - - while (fgets(str, sizeof(str), file) != NULL && count > 0) { - if (!mhz) { - pos = strstr(str, "clock"); - - if (pos) { - sscanf(pos, "clock : %lf", &mhz); - count--; - } - } - - if (!model) { - pos = strstr(str, "cpu"); - - if (pos) { - int len; - pos = strchr(str, ':'); - strncpy(sysinfo->model_str[0], pos + 2, - sizeof(sysinfo->model_str[0])); - len = strlen(sysinfo->model_str[0]); - sysinfo->model_str[0][len - 1] = 0; - model = 1; - count--; - } - } - - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); - } - - - return 0; -} - -static uint64_t odp_cpu_hz_current(int id ODP_UNUSED) -{ - return -1; -} - -#endif - - #if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ defined __powerpc__