diff options
author | Hongbo Zhang <hongbo.zhang@linaro.org> | 2016-01-27 16:56:07 +0800 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2016-02-08 20:45:23 +0300 |
commit | bebe820347c503516cf0f53c22d334241211a515 (patch) | |
tree | 2edfa25e8d8770853404096f7f2ad6c079656323 /platform/linux-generic/arch/mips64/odp_sysinfo_parse.c | |
parent | 1600aac0d24658455c7bceab013b4383d24e85a9 (diff) |
linux-generic: sysinfo: move MIPS system info codes to its plarform file
This patch moves the MIPS system info codes into the newly added MIPS
specific platform file.
Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/arch/mips64/odp_sysinfo_parse.c')
-rw-r--r-- | platform/linux-generic/arch/mips64/odp_sysinfo_parse.c | 53 |
1 files changed, 53 insertions, 0 deletions
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 000000000..264ab28aa --- /dev/null +++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c @@ -0,0 +1,53 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <odp_internal.h> +#include <string.h> + +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) + if (sscanf(pos, "BogoMIPS : %lf", &mhz) == 1) + 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; +} |