[PATCH 3/3] Add proper reporting of CPU information for ppc64 systems

Timothy Pearson tpearson at raptorengineering.com
Tue Feb 26 04:04:50 CST 2019


---
 dlls/ntdll/nt.c              | 38 ++++++++++++++++++++++++++++++++++++
 dlls/setupapi/fakedll.c      |  2 ++
 programs/wineboot/wineboot.c | 33 +++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 792c7f06e1..2d43d8a7db 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -1140,7 +1140,45 @@ static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
 
 static inline 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;
 }
 
diff --git a/dlls/setupapi/fakedll.c b/dlls/setupapi/fakedll.c
index 8c68a50346..87be2b51dd 100644
--- a/dlls/setupapi/fakedll.c
+++ b/dlls/setupapi/fakedll.c
@@ -719,6 +719,8 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
     static const char current_arch[] = "arm";
 #elif defined __aarch64__
     static const char current_arch[] = "arm64";
+#elif defined __powerpc64__
+    static const char current_arch[] = "ppc64";
 #else
     static const char current_arch[] = "none";
 #endif
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index b85a3b6b6e..41ad61ff37 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -277,11 +277,16 @@ static void create_hardware_registry_keys(void)
     static const WCHAR ProcessorNameStringW[] = {'P','r','o','c','e','s','s','o','r','N','a','m','e','S','t','r','i','n','g',0};
     static const WCHAR SysidW[] = {'A','T',' ','c','o','m','p','a','t','i','b','l','e',0};
     static const WCHAR ARMSysidW[] = {'A','R','M',' ','p','r','o','c','e','s','s','o','r',' ','f','a','m','i','l','y',0};
+    static const WCHAR PPCSysidW[] = {'P','o','w','e','r','P','C',' ','p','r','o','c','e','s','s','o','r',' ','f','a','m','i','l','y',0};
     static const WCHAR mhzKeyW[] = {'~','M','H','z',0};
     static const WCHAR VendorIdentifierW[] = {'V','e','n','d','o','r','I','d','e','n','t','i','f','i','e','r',0};
     static const WCHAR PercentDW[] = {'%','d',0};
     static const WCHAR ARMCpuDescrW[]  = {'A','R','M',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
                                           ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
+    static const WCHAR PPCCpuDescrW[]  = {'P','o','w','e','r','P','C',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
+                                          ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
+    static const WCHAR PPC64CpuDescrW[]  = {'P','o','w','e','r','P','C','6','4',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
+                                          ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
     static const WCHAR x86W[] = {'x','8','6',0};
     static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
     static const WCHAR amd64W[] = {'A','M','D','6','4',0};
@@ -310,6 +315,13 @@ static void create_hardware_registry_keys(void)
         sprintfW( id, ARMCpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
         break;
 
+    case PROCESSOR_ARCHITECTURE_PPC:
+        sprintfW( id, PPCCpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
+        break;
+    case PROCESSOR_ARCHITECTURE_PPC64:
+        sprintfW( id, PPC64CpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
+        break;
+
     case PROCESSOR_ARCHITECTURE_AMD64:
         get_identifier( id, !strcmpW(vendorid, authenticamdW) ? amd64W : intel64W );
         break;
@@ -334,6 +346,11 @@ static void create_hardware_registry_keys(void)
         set_reg_value( system_key, IdentifierW, ARMSysidW );
         break;
 
+    case PROCESSOR_ARCHITECTURE_PPC:
+    case PROCESSOR_ARCHITECTURE_PPC64:
+        set_reg_value( system_key, IdentifierW, PPCSysidW );
+        break;
+
     case PROCESSOR_ARCHITECTURE_INTEL:
     case PROCESSOR_ARCHITECTURE_AMD64:
     default:
@@ -411,6 +428,7 @@ static void create_environment_registry_keys( void )
     static const WCHAR intel64W[]  = {'I','n','t','e','l','6','4',0};
     static const WCHAR amd64W[]    = {'A','M','D','6','4',0};
     static const WCHAR authenticamdW[] = {'A','u','t','h','e','n','t','i','c','A','M','D',0};
+    static const WCHAR ppc64W[]    = {'P','o','w','e','r','P','C','6','4',0};
     static const WCHAR commaW[]    = {',',' ',0};
     static const WCHAR ProcIdW[]   = {'P','R','O','C','E','S','S','O','R','_','I','D','E','N','T','I','F','I','E','R',0};
     static const WCHAR ProcLvlW[]  = {'P','R','O','C','E','S','S','O','R','_','L','E','V','E','L',0};
@@ -419,6 +437,10 @@ static void create_environment_registry_keys( void )
     static const WCHAR Percent04XW[] = {'%','0','4','x',0};
     static const WCHAR ARMCpuDescrW[]  = {'A','R','M',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
                                           ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
+    static const WCHAR PPCCpuDescrW[]  = {'P','o','w','e','r','P','C',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
+                                          ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
+    static const WCHAR PPC64CpuDescrW[]  = {'P','o','w','e','r','P','C','6','4',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d',
+                                          ' ','R','e','v','i','s','i','o','n',' ','%','d',0};
     HKEY env_key;
     SYSTEM_CPU_INFORMATION sci;
     WCHAR buffer[60], vendorid[13];
@@ -439,6 +461,10 @@ static void create_environment_registry_keys( void )
         parch = !strcmpW(vendorid, authenticamdW) ? amd64W : intel64W;
         break;
 
+    case PROCESSOR_ARCHITECTURE_PPC64:
+        arch = parch = ppc64W;
+        break;
+
     case PROCESSOR_ARCHITECTURE_INTEL:
     default:
         arch = parch = x86W;
@@ -453,6 +479,13 @@ static void create_environment_registry_keys( void )
         sprintfW( buffer, ARMCpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
         break;
 
+    case PROCESSOR_ARCHITECTURE_PPC:
+        sprintfW( buffer, PPCCpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
+        break;
+    case PROCESSOR_ARCHITECTURE_PPC64:
+        sprintfW( buffer, PPC64CpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) );
+        break;
+
     case PROCESSOR_ARCHITECTURE_AMD64:
     case PROCESSOR_ARCHITECTURE_INTEL:
     default:
-- 
2.20.1




More information about the wine-devel mailing list