ReactOS  0.4.15-dev-3440-g915569a
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  //
165  Flags = __readeflags();
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 }
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1800
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1819
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CR4_PGE
Definition: ketypes.h:91
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1795
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1675
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1670
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1826
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
void __cdecl _disable(void)
Definition: intrin_arm.h:365

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;
62  HANDLE Handle;
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 */
79  ZwClose(Handle);
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,
89  REG_DWORD,
90  &Value,
91  sizeof(Value));
92 
93  /* Close subkey */
95  }
96  }
97 
98  /* Return status */
99  return Status;
100 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:104
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN HalDisableFirmwareMapper
Definition: halacpi.c:43
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_DWORD
Definition: sdbapi.c:596

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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
static PMEMKEY RootKey
Definition: registry.c:55
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
_In_ BOOLEAN Create
Definition: pstypes.h:527
LONG NTSTATUS
Definition: precomp.h:26
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060

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

◆ HalpReportSerialNumber()

VOID NTAPI HalpReportSerialNumber ( VOID  )

Definition at line 26 of file misc.c.

27 {
29  UNICODE_STRING KeyString;
30  HANDLE Handle;
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,
45  REG_BINARY,
48 
49  /* Close the handle */
50  ZwClose(Handle);
51  }
52 }
#define REG_BINARY
Definition: nt_native.h:1496
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:104
Status
Definition: gdiplustypes.h:24
UCHAR HalpSerialLen
Definition: misc.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CHAR HalpSerialNumber[31]
Definition: misc.c:18
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
_In_ HANDLE Handle
Definition: extypes.h:390
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

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().