ReactOS 0.4.15-dev-7953-g1f49173
misc.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Hardware Abstraction Layer (HAL)
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * PURPOSE: I/O Mapping and x86 Subs
5 * PROGRAMMERS: ReactOS Portable Systems Group
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include <hal.h>
11
12#define NDEBUG
13#include <debug.h>
14
15/* GLOBALS *******************************************************************/
16
19
20/* PRIVATE FUNCTIONS **********************************************************/
21
22#ifndef _MINIHAL_
23CODE_SEG("INIT")
24VOID
27{
29 UNICODE_STRING KeyString;
31
32 /* Make sure there is a serial number */
33 if (!HalpSerialLen) return;
34
35 /* Open the system key */
36 RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
38 if (NT_SUCCESS(Status))
39 {
40 /* Add the serial number */
41 RtlInitUnicodeString(&KeyString, L"Serial Number");
42 ZwSetValueKey(Handle,
43 &KeyString,
44 0,
48
49 /* Close the handle */
51 }
52}
53
54CODE_SEG("INIT")
58{
60 UNICODE_STRING KeyString;
64
65 /* Open the control set key */
66 RtlInitUnicodeString(&KeyString,
67 L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
69 if (NT_SUCCESS(Status))
70 {
71 /* Open the PNP key */
72 RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
74 Handle,
75 &KeyString,
77 TRUE);
78 /* Close root key */
80
81 /* Check if PNP BIOS key exists */
82 if (NT_SUCCESS(Status))
83 {
84 /* Set the disable value to false -- we need the mapper */
85 RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
86 Status = ZwSetValueKey(KeyHandle,
87 &KeyString,
88 0,
90 &Value,
91 sizeof(Value));
92
93 /* Close subkey */
95 }
96 }
97
98 /* Return status */
99 return Status;
100}
101
103NTAPI
109{
113
114 /* Setup the attributes we received */
116 KeyName,
118 RootKey,
119 NULL);
120
121 /* What to do? */
122 if ( Create )
123 {
124 /* Create the key */
125 Status = ZwCreateKey(KeyHandle,
128 0,
129 NULL,
131 &Disposition);
132 }
133 else
134 {
135 /* Open the key */
137 }
138
139 /* We're done */
140 return Status;
141}
142#endif /* !_MINIHAL_ */
143
144VOID
145NTAPI
147{
148 //
149 // Nothing to do on non-ACPI
150 //
151 return;
152}
153
154VOID
155NTAPI
157{
158 ULONG_PTR Flags, Cr4;
159 INT CpuInfo[4];
160 ULONG_PTR PageDirectory;
161
162 //
163 // Disable interrupts
164 //
166 _disable();
167
168 //
169 // Get page table directory base
170 //
171 PageDirectory = __readcr3();
172
173 //
174 // Check for CPUID support
175 //
176 if (KeGetCurrentPrcb()->CpuID)
177 {
178 //
179 // Check for global bit in CPU features
180 //
181 __cpuid(CpuInfo, 1);
182 if (CpuInfo[3] & 0x2000)
183 {
184 //
185 // Get current CR4 value
186 //
187 Cr4 = __readcr4();
188
189 //
190 // Disable global bit
191 //
192 __writecr4(Cr4 & ~CR4_PGE);
193
194 //
195 // Flush TLB and re-enable global bit
196 //
197 __writecr3(PageDirectory);
198 __writecr4(Cr4);
199
200 //
201 // Restore interrupts
202 //
204 return;
205 }
206 }
207
208 //
209 // Legacy: just flush TLB
210 //
211 __writecr3(PageDirectory);
213}
214
215/* FUNCTIONS *****************************************************************/
216
217/*
218 * @implemented
219 */
220UCHAR
223 OUT PKINTERRUPT_ROUTINE **FlatDispatch,
224 OUT PKINTERRUPT_ROUTINE *NoConnection)
225{
226 //
227 // Not implemented on x86
228 //
229 return 0;
230}
231
232/*
233 * @implemented
234 */
235VOID
236NTAPI
238{
239 //
240 // Not implemented on x86
241 //
242 return;
243}
244
245#ifdef _M_IX86
246/* x86 fastcall wrappers */
247
248#undef KeRaiseIrql
249/*
250 * @implemented
251 */
252VOID
253NTAPI
256{
257 /* Call the fastcall function */
259}
260
261#undef KeLowerIrql
262/*
263 * @implemented
264 */
265VOID
266NTAPI
268{
269 /* Call the fastcall function */
271}
272
273#undef KeAcquireSpinLock
274/*
275 * @implemented
276 */
277VOID
278NTAPI
281{
282 /* Call the fastcall function */
284}
285
286#undef KeReleaseSpinLock
287/*
288 * @implemented
289 */
290VOID
291NTAPI
294{
295 /* Call the fastcall function */
297}
298
299#endif /* _M_IX86 */
#define CODE_SEG(...)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
@ Create
Definition: registry.c:563
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
UCHAR FASTCALL HalSystemVectorDispatchEntry(IN ULONG Vector, OUT PKINTERRUPT_ROUTINE **FlatDispatch, OUT PKINTERRUPT_ROUTINE *NoConnection)
Definition: misc.c:24
VOID NTAPI KeFlushWriteBuffer(VOID)
Definition: misc.c:39
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
KIRQL FASTCALL KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
Definition: spinlock.c:85
VOID FASTCALL KfReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL OldIrql)
Definition: spinlock.c:96
NTSTATUS NTAPI HalpMarkAcpiHal(VOID)
Definition: misc.c:57
VOID NTAPI HalpCheckPowerButton(VOID)
Definition: misc.c:146
VOID NTAPI HalpFlushTLB(VOID)
Definition: misc.c:156
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:104
CHAR HalpSerialNumber[31]
Definition: misc.c:18
UCHAR HalpSerialLen
Definition: misc.c:17
VOID NTAPI HalpReportSerialNumber(VOID)
Definition: misc.c:26
BOOLEAN HalDisableFirmwareMapper
Definition: halacpi.c:43
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
void __cdecl _disable(void)
Definition: intrin_arm.h:365
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1818
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1669
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1825
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1794
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1799
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define CR4_PGE
Definition: ketypes.h:152
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define REG_BINARY
Definition: nt_native.h:1496
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FASTCALL
Definition: nt_native.h:50
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
static PMEMKEY RootKey
Definition: registry.c:55
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
VOID(NTAPI * PKINTERRUPT_ROUTINE)(VOID)
Definition: ketypes.h:502
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175