From patchwork Wed Jan 20 09:20:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 60021 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3068453lbb; Wed, 20 Jan 2016 01:40:51 -0800 (PST) X-Received: by 10.55.25.70 with SMTP id k67mr43368938qkh.86.1453282851207; Wed, 20 Jan 2016 01:40:51 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x145si42837697qka.105.2016.01.20.01.40.50; Wed, 20 Jan 2016 01:40:51 -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 8CC2E61736; Wed, 20 Jan 2016 09:40:50 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=aNvoCxnf; 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_H2,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 CDA176179E; Wed, 20 Jan 2016 09:36:41 +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 B0F2161786; Wed, 20 Jan 2016 09:36:34 +0000 (UTC) Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by lists.linaro.org (Postfix) with ESMTPS id 801266177C for ; Wed, 20 Jan 2016 09:35:36 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id q63so2089892pfb.1 for ; Wed, 20 Jan 2016 01:35:36 -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=l/fWirOaJ2AXJ5kaM9zx0l/YiBb9G6li0+FyA+cF6qE=; b=aNvoCxnfSohfeJrLIWs5cW++KjONrmHHWSU0uboZfiYXNB56nqlp7kzv2dX2ct9rc8 uJwWjj9naz3EI8N/+kXQ8EQ7NqK7Wx2pyYaa1ab+id8Rl+P2Y+gi/Pvab3vDaXGOLvMu d7/b7y7temdS07sUtvB4/MBmteAZwwXAlYq/I= 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=l/fWirOaJ2AXJ5kaM9zx0l/YiBb9G6li0+FyA+cF6qE=; b=QLEImj23wOh9jqTGUL0Q0mzBPT3x8XO9HpFIBF0gTmbJBnxaroKJrJdsAXNJmj0wBb qmr8qwqSvmLQl26DELroSGpG86RqkvwHILN50qGbfWDghZMlb1fCrpmljCzpaIQcmOnJ 48SbN4g144R1C5YjXo9sc0q3GFSoaEcfokPZH3iGiGpkQdByj9K1cwZa6H+6lPoKAv3p WoywhtBHRAE6kjmWnZWo5tvEMEa5Js/0UjAYg3QhR8M3ZtdPQJ9crobSipyxXz+x73hf YHc0wP11svk27aEf6Q8zk3/9/myCzqB2thxKGG4RK92nfLJTzHU4qLx9DQXGIm6MZFbk cbBg== X-Gm-Message-State: ALoCoQnbC0cxhLSIk1RtVb6Rq2pXiheLuCd4TU8Ur6jPPJj9w39KPXN/3XfzAtPA/BLlISz67d35q7LfqmIL5UbRxR1K6v2QUA== X-Received: by 10.98.87.81 with SMTP id l78mr51121299pfb.101.1453282535859; Wed, 20 Jan 2016 01:35:35 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id xz6sm47592797pab.42.2016.01.20.01.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 01:35:35 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Wed, 20 Jan 2016 17:20:57 +0800 Message-Id: <1453281662-31499-8-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453281662-31499-1-git-send-email-hongbo.zhang@linaro.org> References: <1453281662-31499-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v7 API-NEXT 07/12] 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 + platform/linux-generic/arch/powerpc/odp/cpu_arch.h | 1 + platform/linux-generic/arch/powerpc/odp_cpu_arch.c | 1 + .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 52 +++++++++++++++++++++ platform/linux-generic/odp_system_info.c | 53 ---------------------- 6 files changed, 57 insertions(+), 53 deletions(-) create mode 120000 platform/linux-generic/arch/powerpc/odp/cpu_arch.h create mode 120000 platform/linux-generic/arch/powerpc/odp_cpu_arch.c create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c diff --git a/configure.ac b/configure.ac index 7e1678a..962ce93 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 b737135..21cde8a 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -167,6 +167,8 @@ EXTRA_DIST = \ arch/linux/odp_sysinfo_parse.c \ arch/mips64/odp_cpu_arch.c \ arch/mips64/odp_sysinfo_parse.c \ + arch/powerpc/odp_cpu_cycles.c \ + arch/powerpc/odp_sysinfo_parse.c \ arch/x86/odp_cpu_arch.c \ arch/x86/odp_sysinfo_parse.c diff --git a/platform/linux-generic/arch/powerpc/odp/cpu_arch.h b/platform/linux-generic/arch/powerpc/odp/cpu_arch.h new file mode 120000 index 0000000..0617d7f --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp/cpu_arch.h @@ -0,0 +1 @@ +../../linux/odp/cpu_arch.h \ No newline at end of file diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c new file mode 120000 index 0000000..c5fe400 --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c @@ -0,0 +1 @@ +../linux/odp_cpu_arch.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..fe13f40 --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c @@ -0,0 +1,52 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#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) + if (sscanf(pos, "clock : %lf", &mhz) == 1) + 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 27dad03..e4992b5 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -104,59 +104,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__