ReactOS 0.4.17-dev-1190-g4c812f4
misc.c File Reference
#include <hal.h>
#include <smp.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

HALP_APIC_INFO_TABLE HalpApicInfoTable
 
UCHAR HalpSerialLen
 
CHAR HalpSerialNumber [31]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file misc.c.

Function Documentation

◆ HalpCheckPowerButton()

VOID NTAPI HalpCheckPowerButton ( VOID  )

Definition at line 150 of file misc.c.

151{
152 //
153 // Nothing to do on non-ACPI
154 //
155 return;
156}

Referenced by HalpRegisterKdSupportFunctions().

◆ HalpFlushTLB()

VOID NTAPI HalpFlushTLB ( VOID  )

Definition at line 160 of file misc.c.

161{
162 ULONG_PTR Flags, Cr4;
163 INT CpuInfo[4];
164 ULONG_PTR PageDirectory;
165
166 //
167 // Disable interrupts
168 //
170 _disable();
171
172 //
173 // Get page table directory base
174 //
175 PageDirectory = __readcr3();
176
177 //
178 // Check for CPUID support
179 //
180 if (KeGetCurrentPrcb()->CpuID)
181 {
182 //
183 // Check for global bit in CPU features
184 //
185 __cpuid(CpuInfo, 1);
186 if (CpuInfo[3] & 0x2000)
187 {
188 //
189 // Get current CR4 value
190 //
191 Cr4 = __readcr4();
192
193 //
194 // Disable global bit
195 //
196 __writecr4(Cr4 & ~CR4_PGE);
197
198 //
199 // Flush TLB and re-enable global bit
200 //
201 __writecr3(PageDirectory);
202 __writecr4(Cr4);
203
204 //
205 // Restore interrupts
206 //
208 return;
209 }
210 }
211
212 //
213 // Legacy: just flush TLB
214 //
215 __writecr3(PageDirectory);
217}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1850
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1701
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1857
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1706
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1826
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1831
#define CR4_PGE
Definition: ketypes.h:161
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1197
void __cdecl _disable(void)
Definition: intrin_arm.h:365
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65

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

◆ HalpMarkAcpiHal()

NTSTATUS NTAPI HalpMarkAcpiHal ( VOID  )

Definition at line 61 of file misc.c.

62{
64 UNICODE_STRING KeyString;
68
69 /* Open the control set key */
70 RtlInitUnicodeString(&KeyString,
71 L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
73 if (NT_SUCCESS(Status))
74 {
75 /* Open the PNP key */
76 RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
78 Handle,
79 &KeyString,
81 TRUE);
82 /* Close root key */
84
85 /* Check if PNP BIOS key exists */
86 if (NT_SUCCESS(Status))
87 {
88 /* Set the disable value to false -- we need the mapper */
89 RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
90 Status = ZwSetValueKey(KeyHandle,
91 &KeyString,
92 0,
94 &Value,
95 sizeof(Value));
96
97 /* Close subkey */
99 }
100 }
101
102 /* Return status */
103 return Status;
104}
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
#define L(x)
Definition: resources.c:13
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:108
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:1044
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_DWORD
Definition: sdbapi.c:615
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 108 of file misc.c.

113{
117
118 /* Setup the attributes we received */
120 KeyName,
122 RootKey,
123 NULL);
124
125 /* What to do? */
126 if ( Create )
127 {
128 /* Create the key */
129 Status = ZwCreateKey(KeyHandle,
132 0,
133 NULL,
135 &Disposition);
136 }
137 else
138 {
139 /* Open the key */
141 }
142
143 /* We're done */
144 return Status;
145}
@ Create
Definition: registry.c:563
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_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:1063
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static PMEMKEY RootKey
Definition: registry.c:55
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705

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

◆ HalpReportSerialNumber()

VOID NTAPI HalpReportSerialNumber ( VOID  )

Definition at line 30 of file misc.c.

31{
33 UNICODE_STRING KeyString;
35
36 /* Make sure there is a serial number */
37 if (!HalpSerialLen) return;
38
39 /* Open the system key */
40 RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
42 if (NT_SUCCESS(Status))
43 {
44 /* Add the serial number */
45 RtlInitUnicodeString(&KeyString, L"Serial Number");
46 ZwSetValueKey(Handle,
47 &KeyString,
48 0,
52
53 /* Close the handle */
55 }
56}
CHAR HalpSerialNumber[31]
Definition: misc.c:22
UCHAR HalpSerialLen
Definition: misc.c:21
#define REG_BINARY
Definition: nt_native.h:1499

Referenced by HalpReportResourceUsage().

◆ HalSystemVectorDispatchEntry()

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

Definition at line 226 of file misc.c.

229{
230 //
231 // Not implemented on x86
232 //
233 return 0;
234}

◆ KeFlushWriteBuffer()

VOID NTAPI KeFlushWriteBuffer ( VOID  )

Definition at line 241 of file misc.c.

242{
243 //
244 // Not implemented on x86
245 //
246 return;
247}

Variable Documentation

◆ HalpApicInfoTable

◆ HalpSerialLen

UCHAR HalpSerialLen

Definition at line 21 of file misc.c.

Referenced by HalpReportSerialNumber().

◆ HalpSerialNumber

CHAR HalpSerialNumber[31]

Definition at line 22 of file misc.c.

Referenced by HalpReportSerialNumber().