ReactOS 0.4.16-dev-88-ga65b6ae
misc.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI HalpReportSerialNumber (VOID)
 
NTSTATUS NTAPI HalpMarkAcpiHal (VOID)
 
NTSTATUS NTAPI HalpOpenRegistryKey (IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
 
VOID NTAPI HalpCheckPowerButton (VOID)
 
VOID NTAPI HalpFlushTLB (VOID)
 
UCHAR FASTCALL HalSystemVectorDispatchEntry (IN ULONG Vector, OUT PKINTERRUPT_ROUTINE **FlatDispatch, OUT PKINTERRUPT_ROUTINE *NoConnection)
 
VOID NTAPI KeFlushWriteBuffer (VOID)
 

Variables

UCHAR HalpSerialLen
 
CHAR HalpSerialNumber [31]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file misc.c.

Function Documentation

◆ HalpCheckPowerButton()

VOID NTAPI HalpCheckPowerButton ( VOID  )

Definition at line 146 of file misc.c.

147{
148 //
149 // Nothing to do on non-ACPI
150 //
151 return;
152}

Referenced by HalpRegisterKdSupportFunctions().

◆ HalpFlushTLB()

VOID NTAPI HalpFlushTLB ( VOID  )

Definition at line 156 of file misc.c.

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}
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 CR4_PGE
Definition: ketypes.h:152
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by HalpMapPhysicalMemory64Vista(), HalpMapRealModeMemory(), HalpUnmapRealModeMemory(), and HalpUnmapVirtualAddressVista().

◆ HalpMarkAcpiHal()

NTSTATUS NTAPI HalpMarkAcpiHal ( VOID  )

Definition at line 57 of file misc.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:104
BOOLEAN HalDisableFirmwareMapper
Definition: halacpi.c:43
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by HalpReportResourceUsage().

◆ HalpOpenRegistryKey()

NTSTATUS NTAPI HalpOpenRegistryKey ( IN PHANDLE  KeyHandle,
IN HANDLE  RootKey,
IN PUNICODE_STRING  KeyName,
IN ACCESS_MASK  DesiredAccess,
IN BOOLEAN  Create 
)

Definition at line 104 of file misc.c.

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}
@ Create
Definition: registry.c:563
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
static PMEMKEY RootKey
Definition: registry.c:55
_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

Referenced by HalpMarkAcpiHal(), HalpMarkChipsetDecode(), HalpRegisterPciDebuggingDeviceInfo(), and HalpReportSerialNumber().

◆ HalpReportSerialNumber()

VOID NTAPI HalpReportSerialNumber ( VOID  )

Definition at line 26 of file misc.c.

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}
CHAR HalpSerialNumber[31]
Definition: misc.c:18
UCHAR HalpSerialLen
Definition: misc.c:17
#define REG_BINARY
Definition: nt_native.h:1496

Referenced by HalpReportResourceUsage().

◆ HalSystemVectorDispatchEntry()

UCHAR FASTCALL HalSystemVectorDispatchEntry ( IN ULONG  Vector,
OUT PKINTERRUPT_ROUTINE **  FlatDispatch,
OUT PKINTERRUPT_ROUTINE NoConnection 
)

Definition at line 222 of file misc.c.

225{
226 //
227 // Not implemented on x86
228 //
229 return 0;
230}

◆ KeFlushWriteBuffer()

VOID NTAPI KeFlushWriteBuffer ( VOID  )

Definition at line 237 of file misc.c.

238{
239 //
240 // Not implemented on x86
241 //
242 return;
243}

Variable Documentation

◆ HalpSerialLen

UCHAR HalpSerialLen

Definition at line 17 of file misc.c.

Referenced by HalpReportSerialNumber().

◆ HalpSerialNumber

CHAR HalpSerialNumber[31]

Definition at line 18 of file misc.c.

Referenced by HalpReportSerialNumber().