configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / kernel32 / cpu.c
blob6594450b8773efa295657b8d8cb559d56951449d
1 /*
2 * What processor?
4 * Copyright 1995,1997 Morten Welinder
5 * Copyright 1997-1998 Marcus Meissner
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h>
30 #endif
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
35 #include "ntstatus.h"
36 #define WIN32_NO_STATUS
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winnt.h"
40 #include "winternl.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "ddk/wdm.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(reg);
47 #define SHARED_DATA ((KSHARED_USER_DATA*)0x7ffe0000)
49 /****************************************************************************
50 * QueryPerformanceCounter (KERNEL32.@)
52 * Get the current value of the performance counter.
54 * PARAMS
55 * counter [O] Destination for the current counter reading
57 * RETURNS
58 * Success: TRUE. counter contains the current reading
59 * Failure: FALSE.
61 * SEE ALSO
62 * See QueryPerformanceFrequency.
64 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
66 NtQueryPerformanceCounter( counter, NULL );
67 return TRUE;
71 /****************************************************************************
72 * QueryPerformanceFrequency (KERNEL32.@)
74 * Get the resolution of the performance counter.
76 * PARAMS
77 * frequency [O] Destination for the counter resolution
79 * RETURNS
80 * Success. TRUE. Frequency contains the resolution of the counter.
81 * Failure: FALSE.
83 * SEE ALSO
84 * See QueryPerformanceCounter.
86 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
88 LARGE_INTEGER counter;
89 NtQueryPerformanceCounter( &counter, frequency );
90 return TRUE;
94 /***********************************************************************
95 * GetSystemInfo [KERNEL32.@]
97 * Get information about the system.
99 * RETURNS
100 * Nothing.
102 * NOTES
103 * On the first call it creates cached values, so it doesn't have to determine
104 * them repeatedly. On Linux, the "/proc/cpuinfo" special file is used.
106 * It also creates a cached flag array for IsProcessorFeaturePresent().
108 VOID WINAPI GetSystemInfo(
109 LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
111 NTSTATUS nts;
112 SYSTEM_BASIC_INFORMATION sbi;
113 SYSTEM_CPU_INFORMATION sci;
115 TRACE("si=0x%p\n", si);
117 if ((nts = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL )) != STATUS_SUCCESS ||
118 (nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
120 SetLastError(RtlNtStatusToDosError(nts));
121 return;
124 si->u.s.wProcessorArchitecture = sci.Architecture;
125 si->u.s.wReserved = 0;
126 si->dwPageSize = sbi.PageSize;
127 si->lpMinimumApplicationAddress = sbi.LowestUserAddress;
128 si->lpMaximumApplicationAddress = sbi.HighestUserAddress;
129 si->dwActiveProcessorMask = sbi.ActiveProcessorsAffinityMask;
130 si->dwNumberOfProcessors = sbi.NumberOfProcessors;
132 switch (sci.Architecture)
134 case PROCESSOR_ARCHITECTURE_INTEL:
135 switch (sci.Level)
137 case 3: si->dwProcessorType = PROCESSOR_INTEL_386; break;
138 case 4: si->dwProcessorType = PROCESSOR_INTEL_486; break;
139 case 5:
140 case 6: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
141 default: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
143 break;
144 case PROCESSOR_ARCHITECTURE_PPC:
145 switch (sci.Level)
147 case 1: si->dwProcessorType = PROCESSOR_PPC_601; break;
148 case 3:
149 case 6: si->dwProcessorType = PROCESSOR_PPC_603; break;
150 case 4: si->dwProcessorType = PROCESSOR_PPC_604; break;
151 case 9: si->dwProcessorType = PROCESSOR_PPC_604; break;
152 case 20: si->dwProcessorType = PROCESSOR_PPC_620; break;
153 default: si->dwProcessorType = 0;
155 break;
156 case PROCESSOR_ARCHITECTURE_AMD64:
157 si->dwProcessorType = PROCESSOR_AMD_X8664;
158 break;
159 default: FIXME("Unknown processor architecture %x\n", sci.Architecture);
161 si->dwAllocationGranularity = sbi.AllocationGranularity;
162 si->wProcessorLevel = sci.Level;
163 si->wProcessorRevision = sci.Revision;
167 /***********************************************************************
168 * GetNativeSystemInfo [KERNEL32.@]
170 VOID WINAPI GetNativeSystemInfo(
171 LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
173 BOOL is_wow64;
175 GetSystemInfo(si);
177 IsWow64Process(GetCurrentProcess(), &is_wow64);
178 if (is_wow64)
180 if (si->u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
182 si->u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
183 si->dwProcessorType = PROCESSOR_AMD_X8664;
185 else
187 FIXME("Add the proper information for %d in wow64 mode\n",
188 si->u.s.wProcessorArchitecture);
193 /***********************************************************************
194 * IsProcessorFeaturePresent [KERNEL32.@]
196 * Determine if the cpu supports a given feature.
198 * RETURNS
199 * TRUE, If the processor supports feature,
200 * FALSE otherwise.
202 BOOL WINAPI IsProcessorFeaturePresent (
203 DWORD feature /* [in] Feature number, (PF_ constants from "winnt.h") */)
205 if (feature < 64)
206 return SHARED_DATA->ProcessorFeatures[feature];
207 else
208 return FALSE;