From patchwork Thu Jan 7 07:38:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 59265 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp393394lbb; Wed, 6 Jan 2016 23:42:30 -0800 (PST) X-Received: by 10.140.133.144 with SMTP id 138mr143853546qhf.0.1452152550878; Wed, 06 Jan 2016 23:42:30 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w14si12358695qha.93.2016.01.06.23.42.30; Wed, 06 Jan 2016 23:42:30 -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 7C20061C8F; Thu, 7 Jan 2016 07:42:30 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=RgPJFVEq; 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 2F0C561C98; Thu, 7 Jan 2016 07:40:13 +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 8A06A61CA5; Thu, 7 Jan 2016 07:40:09 +0000 (UTC) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by lists.linaro.org (Postfix) with ESMTPS id 25C8361CA5 for ; Thu, 7 Jan 2016 07:39:00 +0000 (UTC) Received: by mail-pa0-f46.google.com with SMTP id qh10so1756686pab.2 for ; Wed, 06 Jan 2016 23:39:00 -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=ZJKPBIVxx9o+RBB9jnjtAHgN4wliZXme23ideSS6EaM=; b=RgPJFVEqhE39l1B7gz6c1b0uoHpQAyr7HS5da4773/kP8VSNVwJJGqAouwm88HM0Mg TOsubTjtqu7VaZLqR4EfPdk5iW6Oh/27bxYoe6Lx7Q19vVm+SRGfGtvSGN3CSSCDghWE iMxdx54fwNH5FrmRsHWwnG4PUPMH5GRu/CXdQ= 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=ZJKPBIVxx9o+RBB9jnjtAHgN4wliZXme23ideSS6EaM=; b=ZqFiApWjeUReF8oOcZ0VPXnlo0opn+WGfEWEhzqhH/dEoFoLwULBE6HTRI7IRFb2C0 RT0m4eIhodXqAh9f8EszmWzdDFZa9KuQNu67u3yXCBOgikwz+5X+m9Z0j7+H3rQWBaMF pbFzp23DZE+T98T3CZ1MNamaVgq2OJiYE5kwWRliFkhjld8H2rHFpIsrSYNt+d6RsjIJ AOZkQyF9B6783kKWe94WGLO2JIL1X14FQITYXq03UtcwGLZ9yiZczhcOmlv11Ycs5TYq doazmn4wgpE+HLEGYo0OVnTbzw3NZsIiwxClWZJmB+9gw13LoCwBAZYwNR957qs0z5SI h+UQ== X-Gm-Message-State: ALoCoQmp1JnFpWHFOMtGG3pxuaESv7iIOKhAPkHp0Pc2v0TVGpcr5uWHSnd4/e15d6wcc4hoKKl03RN/s8mCIVDMh4NJeW31AA== X-Received: by 10.66.122.72 with SMTP id lq8mr148046841pab.1.1452152339507; Wed, 06 Jan 2016 23:38:59 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id tb8sm150067484pab.22.2016.01.06.23.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jan 2016 23:38:59 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Thu, 7 Jan 2016 15:38:26 +0800 Message-Id: <1452152313-27276-6-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452152313-27276-1-git-send-email-hongbo.zhang@linaro.org> References: <1452152313-27276-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v4 API-NEXT 05/12] linux-generic: sysinfo: move MIPS 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 MIPS system info codes into the newly added MIPS specific platform file. Signed-off-by: Hongbo Zhang --- platform/linux-generic/Makefile.am | 1 + .../linux-generic/arch/mips64/odp_sysinfo_parse.c | 54 ++++++++++++++++++++++ platform/linux-generic/odp_system_info.c | 47 ------------------- 3 files changed, 55 insertions(+), 47 deletions(-) create mode 100644 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index f19a858..bb0faf0 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -164,6 +164,7 @@ __LIB__libodp_la_SOURCES = \ EXTRA_DIST = \ arch/linux/odp_cpu_cycles.c \ arch/mips64/odp_cpu_cycles.c \ + arch/mips64/odp_sysinfo_parse.c \ arch/x86/odp_cpu_cycles.c \ arch/x86/odp_sysinfo_parse.c diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c new file mode 100644 index 0000000..9cedc4f --- /dev/null +++ b/platform/linux-generic/arch/mips64/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, "BogoMIPS"); + + if (pos) { + sscanf(pos, "BogoMIPS : %lf", &mhz); + count--; + } + } + + if (!model) { + pos = strstr(str, "cpu model"); + + 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--; + } + } + } + + /* bogomips seems to be 2x freq */ + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.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 fc5ee3b..8a151eb 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -122,53 +122,6 @@ static uint64_t odp_cpu_hz_current(int id ODP_UNUSED) return -1; } -#elif defined __OCTEON__ - -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, "BogoMIPS"); - - if (pos) { - sscanf(pos, "BogoMIPS : %lf", &mhz); - count--; - } - } - - if (!model) { - pos = strstr(str, "cpu model"); - - 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--; - } - } - } - - /* bogomips seems to be 2x freq */ - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.0); - - return 0; -} - -static uint64_t odp_cpu_hz_current(int id ODP_UNUSED) -{ - return -1; -} - #elif defined __powerpc__ static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) {