From: "André Hentschel" Subject: [PATCH 21/23] ntdll: Add proper reporting of CPU information for PPC64 systems Message-Id: <20210131173433.114385-22-nerv@dawncrow.de> Date: Sun, 31 Jan 2021 18:34:31 +0100 In-Reply-To: <20210131173433.114385-1-nerv@dawncrow.de> References: <20210131173433.114385-1-nerv@dawncrow.de> From: Timothy Pearson Signed-off-by: André Hentschel --- dlls/ntdll/unix/system.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index f208dd915cc..3e5398c0cd4 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -469,7 +469,47 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) { +#ifdef linux + char line[512]; + char *s, *value; + FILE *f = fopen("/proc/cpuinfo", "r"); + if (f) + { + while (fgets(line, sizeof(line), f) != NULL) + { + /* NOTE: the ':' is the only character we can rely on */ + if (!(value = strchr(line,':'))) + continue; + /* terminate the valuename */ + s = value - 1; + while ((s >= line) && isspace(*s)) s--; + *(s + 1) = '\0'; + /* and strip leading spaces from value */ + value += 1; + while (isspace(*value)) value++; + if ((s = strchr(value,'\n'))) + *s='\0'; + if (!strcasecmp(line, "cpu")) + { + if (isdigit(value[5])) + info->Level = atoi(value+5); + continue; + } + if (!strcasecmp(line, "revision")) + { + if (isdigit(value[0])) + info->Revision = (atof(value) * 100); + continue; + } + } + fclose(f); + } +#else FIXME("CPU Feature detection not implemented.\n"); +#endif + info->Level = max(info->Level, 8); /* Default to POWER8 if unable to detect CPU series */ + info->Architecture = PROCESSOR_ARCHITECTURE_PPC64; + } #endif /* End architecture specific feature detection for CPUs */ -- 2.25.1