~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/kernel32/cpu.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * What processor?
  3  *
  4  * Copyright 1995,1997 Morten Welinder
  5  * Copyright 1997-1998 Marcus Meissner
  6  *
  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.
 11  *
 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.
 16  *
 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
 20  */
 21 
 22 #include "config.h"
 23 #include "wine/port.h"
 24 
 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
 31 
 32 
 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 "psapi.h"
 42 #include "ddk/wdm.h"
 43 #include "wine/unicode.h"
 44 #include "kernel_private.h"
 45 #include "wine/debug.h"
 46 
 47 WINE_DEFAULT_DEBUG_CHANNEL(reg);
 48 
 49 #define SHARED_DATA     ((KSHARED_USER_DATA*)0x7ffe0000)
 50 
 51 /****************************************************************************
 52  *              QueryPerformanceCounter (KERNEL32.@)
 53  *
 54  * Get the current value of the performance counter.
 55  * 
 56  * PARAMS
 57  *  counter [O] Destination for the current counter reading
 58  *
 59  * RETURNS
 60  *  Success: TRUE. counter contains the current reading
 61  *  Failure: FALSE.
 62  *
 63  * SEE ALSO
 64  *  See QueryPerformanceFrequency.
 65  */
 66 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
 67 {
 68     NtQueryPerformanceCounter( counter, NULL );
 69     return TRUE;
 70 }
 71 
 72 
 73 /****************************************************************************
 74  *              QueryPerformanceFrequency (KERNEL32.@)
 75  *
 76  * Get the resolution of the performance counter.
 77  *
 78  * PARAMS
 79  *  frequency [O] Destination for the counter resolution
 80  *
 81  * RETURNS
 82  *  Success. TRUE. Frequency contains the resolution of the counter.
 83  *  Failure: FALSE.
 84  *
 85  * SEE ALSO
 86  *  See QueryPerformanceCounter.
 87  */
 88 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
 89 {
 90     LARGE_INTEGER counter;
 91     NtQueryPerformanceCounter( &counter, frequency );
 92     return TRUE;
 93 }
 94 
 95 
 96 /***********************************************************************
 97  *                      GetSystemInfo                   [KERNEL32.@]
 98  *
 99  * Get information about the system.
100  *
101  * RETURNS
102  *  Nothing.
103  */
104 VOID WINAPI GetSystemInfo(
105         LPSYSTEM_INFO si        /* [out] Destination for system information, may not be NULL */)
106 {
107     NTSTATUS                 nts;
108     SYSTEM_CPU_INFORMATION   sci;
109 
110     TRACE("si=0x%p\n", si);
111 
112     if ((nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
113     {
114         SetLastError(RtlNtStatusToDosError(nts));
115         return;
116     }
117 
118     si->u.s.wProcessorArchitecture  = sci.Architecture;
119     si->u.s.wReserved               = 0;
120     si->dwPageSize                  = system_info.PageSize;
121     si->lpMinimumApplicationAddress = system_info.LowestUserAddress;
122     si->lpMaximumApplicationAddress = system_info.HighestUserAddress;
123     si->dwActiveProcessorMask       = system_info.ActiveProcessorsAffinityMask;
124     si->dwNumberOfProcessors        = system_info.NumberOfProcessors;
125 
126     switch (sci.Architecture)
127     {
128     case PROCESSOR_ARCHITECTURE_INTEL:
129         switch (sci.Level)
130         {
131         case 3:  si->dwProcessorType = PROCESSOR_INTEL_386;     break;
132         case 4:  si->dwProcessorType = PROCESSOR_INTEL_486;     break;
133         case 5:
134         case 6:  si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
135         default: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
136         }
137         break;
138     case PROCESSOR_ARCHITECTURE_PPC:
139         switch (sci.Level)
140         {
141         case 1:  si->dwProcessorType = PROCESSOR_PPC_601;       break;
142         case 3:
143         case 6:  si->dwProcessorType = PROCESSOR_PPC_603;       break;
144         case 4:  si->dwProcessorType = PROCESSOR_PPC_604;       break;
145         case 9:  si->dwProcessorType = PROCESSOR_PPC_604;       break;
146         case 20: si->dwProcessorType = PROCESSOR_PPC_620;       break;
147         default: si->dwProcessorType = 0;
148         }
149         break;
150     case PROCESSOR_ARCHITECTURE_AMD64:
151         si->dwProcessorType = PROCESSOR_AMD_X8664;
152         break;
153     case PROCESSOR_ARCHITECTURE_ARM:
154         switch (sci.Level)
155         {
156         case 4:  si->dwProcessorType = PROCESSOR_ARM_7TDMI;     break;
157         default: si->dwProcessorType = PROCESSOR_ARM920;
158         }
159         break;
160     default:
161         FIXME("Unknown processor architecture %x\n", sci.Architecture);
162         si->dwProcessorType = 0;
163     }
164     si->dwAllocationGranularity     = system_info.AllocationGranularity;
165     si->wProcessorLevel             = sci.Level;
166     si->wProcessorRevision          = sci.Revision;
167 }
168 
169 
170 /***********************************************************************
171  *                      GetNativeSystemInfo             [KERNEL32.@]
172  */
173 VOID WINAPI GetNativeSystemInfo(
174     LPSYSTEM_INFO si    /* [out] Destination for system information, may not be NULL */)
175 {
176     BOOL is_wow64;
177 
178     GetSystemInfo(si); 
179 
180     IsWow64Process(GetCurrentProcess(), &is_wow64);
181     if (is_wow64)
182     {
183         if (si->u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
184         {
185             si->u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
186             si->dwProcessorType = PROCESSOR_AMD_X8664;
187         }
188         else
189         {
190             FIXME("Add the proper information for %d in wow64 mode\n",
191                   si->u.s.wProcessorArchitecture);
192         }
193     }
194 }
195 
196 /***********************************************************************
197  *                      IsProcessorFeaturePresent       [KERNEL32.@]
198  *
199  * Determine if the cpu supports a given feature.
200  * 
201  * RETURNS
202  *  TRUE, If the processor supports feature,
203  *  FALSE otherwise.
204  */
205 BOOL WINAPI IsProcessorFeaturePresent (
206         DWORD feature   /* [in] Feature number, (PF_ constants from "winnt.h") */) 
207 {
208   if (feature < PROCESSOR_FEATURE_MAX)
209     return SHARED_DATA->ProcessorFeatures[feature];
210   else
211     return FALSE;
212 }
213 
214 /***********************************************************************
215  *           K32GetPerformanceInfo (KERNEL32.@)
216  */
217 BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size)
218 {
219     NTSTATUS status;
220 
221     TRACE( "(%p, %d)\n", info, size );
222 
223     status = NtQuerySystemInformation( SystemPerformanceInformation, info, size, NULL );
224 
225     if (status)
226     {
227         SetLastError( RtlNtStatusToDosError( status ) );
228         return FALSE;
229     }
230     return TRUE;
231 }
232 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.