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
23 #include "wine/port.h"
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h>
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
36 #define WIN32_NO_STATUS
41 #include "wine/unicode.h"
42 #include "wine/debug.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.
55 * counter [O] Destination for the current counter reading
58 * Success: TRUE. counter contains the current reading
62 * See QueryPerformanceFrequency.
64 BOOL WINAPI
QueryPerformanceCounter(PLARGE_INTEGER counter
)
66 NtQueryPerformanceCounter( counter
, NULL
);
71 /****************************************************************************
72 * QueryPerformanceFrequency (KERNEL32.@)
74 * Get the resolution of the performance counter.
77 * frequency [O] Destination for the counter resolution
80 * Success. TRUE. Frequency contains the resolution of the counter.
84 * See QueryPerformanceCounter.
86 BOOL WINAPI
QueryPerformanceFrequency(PLARGE_INTEGER frequency
)
88 LARGE_INTEGER counter
;
89 NtQueryPerformanceCounter( &counter
, frequency
);
94 /***********************************************************************
95 * GetSystemInfo [KERNEL32.@]
97 * Get information about the system.
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 */)
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
));
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
:
137 case 3: si
->dwProcessorType
= PROCESSOR_INTEL_386
; break;
138 case 4: si
->dwProcessorType
= PROCESSOR_INTEL_486
; break;
140 case 6: si
->dwProcessorType
= PROCESSOR_INTEL_PENTIUM
; break;
141 default: si
->dwProcessorType
= PROCESSOR_INTEL_PENTIUM
; break;
144 case PROCESSOR_ARCHITECTURE_PPC
:
147 case 1: si
->dwProcessorType
= PROCESSOR_PPC_601
; break;
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;
156 default: FIXME("Unknown processor architecture %x\n", sci
.Architecture
);
158 si
->dwAllocationGranularity
= sbi
.AllocationGranularity
;
159 si
->wProcessorLevel
= sci
.Level
;
160 si
->wProcessorRevision
= sci
.Revision
;
164 /***********************************************************************
165 * GetNativeSystemInfo [KERNEL32.@]
167 VOID WINAPI
GetNativeSystemInfo(
168 LPSYSTEM_INFO si
/* [out] Destination for system information, may not be NULL */)
170 static BOOL reported
= FALSE
;
172 FIXME("(%p) using GetSystemInfo()\n", si
);
175 TRACE("(%p) using GetSystemInfo()\n", si
);
179 /***********************************************************************
180 * IsProcessorFeaturePresent [KERNEL32.@]
182 * Determine if the cpu supports a given feature.
185 * TRUE, If the processor supports feature,
188 BOOL WINAPI
IsProcessorFeaturePresent (
189 DWORD feature
/* [in] Feature number, (PF_ constants from "winnt.h") */)
192 return SHARED_DATA
->ProcessorFeatures
[feature
];