4 * Copyright 1995,1997 Morten Welinder
5 * Copyright 1997 Marcus Meissner
16 static BYTE PF[64] = {0,};
18 /***********************************************************************
19 * GetSystemInfo [KERNELL32.404]
21 VOID WINAPI GetSystemInfo(LPSYSTEM_INFO si)
24 static SYSTEM_INFO cachedsi;
29 memcpy(si,&cachedsi,sizeof(*si));
32 memset(PF,0,sizeof(PF));
34 /* choose sensible defaults ...
35 * FIXME: perhaps overrideable with precompiler flags?
37 cachedsi.u.x.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
38 cachedsi.dwPageSize = VIRTUAL_GetPageSize();
40 /* FIXME: better values for the two entries below... */
41 cachedsi.lpMinimumApplicationAddress = (void *)0x40000000;
42 cachedsi.lpMaximumApplicationAddress = (void *)0x7FFFFFFF;
43 cachedsi.dwActiveProcessorMask = 1;
44 cachedsi.dwNumberOfProcessors = 1;
45 cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
46 cachedsi.dwAllocationGranularity = 0x10000;
47 cachedsi.wProcessorLevel = 3; /* 386 */
48 cachedsi.wProcessorRevision = 0;
50 cache = 1; /* even if there is no more info, we now have a cacheentry */
51 memcpy(si,&cachedsi,sizeof(*si));
53 /* hmm, reasonable processor feature defaults? */
58 FILE *f = fopen ("/proc/cpuinfo", "r");
63 RegCreateKey16(HKEY_LOCAL_MACHINE,"\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor",&hkey);
64 while (fgets(line,200,f)!=NULL) {
67 /* NOTE: the ':' is the only character we can rely on */
68 if (!(value = strchr(line,':')))
70 /* terminate the valuename */
72 /* skip any leading spaces */
73 while (*value==' ') value++;
74 if ((s=strchr(value,'\n')))
78 if (!lstrncmpi32A(line, "cpu family",strlen("cpu family"))) {
79 if (isdigit (value[0])) {
80 switch (value[0] - '0') {
81 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
82 cachedsi.wProcessorLevel= 3;
84 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
85 cachedsi.wProcessorLevel= 4;
87 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
88 cachedsi.wProcessorLevel= 5;
90 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
91 cachedsi.wProcessorLevel= 5;
97 /* set the CPU type of the current processor */
98 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
100 RegSetValueEx32A(xhkey,"Identifier",0,REG_SZ,buf,strlen(buf));
104 if (!lstrncmpi32A(line, "cpu",strlen("cpu"))) {
105 if ( isdigit (value[0]) && value[1] == '8' &&
106 value[2] == '6' && value[3] == 0
108 switch (value[0] - '0') {
109 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
110 cachedsi.wProcessorLevel= 3;
112 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
113 cachedsi.wProcessorLevel= 4;
115 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
116 cachedsi.wProcessorLevel= 5;
118 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
119 cachedsi.wProcessorLevel= 5;
125 /* set the CPU type of the current processor */
126 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
128 RegSetValueEx32A(xhkey,"Identifier",0,REG_SZ,buf,strlen(buf));
131 if (!lstrncmpi32A(line,"fdiv_bug",strlen("fdiv_bug"))) {
132 if (!lstrncmpi32A(value,"yes",3))
133 PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
137 if (!lstrncmpi32A(line,"fpu",strlen("fpu"))) {
138 if (!lstrncmpi32A(value,"no",2))
139 PF[PF_FLOATING_POINT_EMULATED] = TRUE;
143 if (!lstrncmpi32A(line,"processor",strlen("processor"))) {
144 /* processor number counts up...*/
147 if (sscanf(value,"%d",&x))
148 if (x+1>cachedsi.dwNumberOfProcessors)
149 cachedsi.dwNumberOfProcessors=x+1;
151 /* create a new processor subkey */
155 RegCreateKey16(hkey,buf,&xhkey);
157 if (!lstrncmpi32A(line,"stepping",strlen("stepping"))) {
160 if (sscanf(value,"%d",&x))
161 cachedsi.wProcessorRevision = x;
163 if (!lstrncmpi32A(line,"flags",strlen("flags"))) {
164 if (strstr(value,"cx8"))
165 PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
166 if (strstr(value,"mmx"))
167 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
173 memcpy(si,&cachedsi,sizeof(*si));
175 /* FIXME: how do we do this on other systems? */
177 RegCreateKey16(hkey,"0",&xhkey);
178 RegSetValueEx32A(xhkey,"Identifier",0,REG_SZ,"CPU 386",strlen("CPU 386"));
185 /***********************************************************************
186 * IsProcessorFeaturePresent [KERNELL32.880]
188 BOOL32 WINAPI IsProcessorFeaturePresent (DWORD feature)
191 GetSystemInfo (&si); /* to ensure the information is loaded and cached */