ReactOS  0.4.15-dev-488-gc7a1924
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

INIT_FUNCTION VOID NTAPI HalpReportSerialNumber (VOID)
 
INIT_FUNCTION 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 151 of file misc.c.

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

◆ HalpFlushTLB()

VOID NTAPI HalpFlushTLB ( VOID  )

Definition at line 161 of file misc.c.

162 {
163  ULONG_PTR Flags, Cr4;
164  INT CpuInfo[4];
165  ULONG_PTR PageDirectory;
166 
167  //
168  // Disable interrupts
169  //
170  Flags = __readeflags();
171  _disable();
172 
173  //
174  // Get page table directory base
175  //
176  PageDirectory = __readcr3();
177 
178  //
179  // Check for CPUID support
180  //
181  if (KeGetCurrentPrcb()->CpuID)
182  {
183  //
184  // Check for global bit in CPU features
185  //
186  __cpuid(CpuInfo, 1);
187  if (CpuInfo[3] & 0x2000)
188  {
189  //
190  // Get current CR4 value
191  //
192  Cr4 = __readcr4();
193 
194  //
195  // Disable global bit
196  //
197  __writecr4(Cr4 & ~CR4_PGE);
198 
199  //
200  // Flush TLB and re-enable global bit
201  //
202  __writecr3(PageDirectory);
203  __writecr4(Cr4);
204 
205  //
206  // Restore interrupts
207  //
209  return;
210  }
211  }
212 
213  //
214  // Legacy: just flush TLB
215  //
216  __writecr3(PageDirectory);
218 }
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1680
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1706
int32_t INT
Definition: typedefs.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define CR4_PGE
Definition: ketypes.h:91
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1675
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1555
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1550
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1713
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()

INIT_FUNCTION NTSTATUS NTAPI HalpMarkAcpiHal ( VOID  )

Definition at line 62 of file misc.c.

63 {
65  UNICODE_STRING KeyString;
67  HANDLE Handle;
69 
70  /* Open the control set key */
71  RtlInitUnicodeString(&KeyString,
72  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
74  if (NT_SUCCESS(Status))
75  {
76  /* Open the PNP key */
77  RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
79  Handle,
80  &KeyString,
82  TRUE);
83  /* Close root key */
84  ZwClose(Handle);
85 
86  /* Check if PNP BIOS key exists */
87  if (NT_SUCCESS(Status))
88  {
89  /* Set the disable value to false -- we need the mapper */
90  RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
91  Status = ZwSetValueKey(KeyHandle,
92  &KeyString,
93  0,
94  REG_DWORD,
95  &Value,
96  sizeof(Value));
97 
98  /* Close subkey */
100  }
101  }
102 
103  /* Return status */
104  return Status;
105 }
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
IN UCHAR Value
Definition: halp.h:394
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:109
_In_ HANDLE Handle
Definition: extypes.h:390
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
BOOLEAN HalDisableFirmwareMapper
Definition: halacpi.c:43
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
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 109 of file misc.c.

114 {
118 
119  /* Setup the attributes we received */
121  KeyName,
123  RootKey,
124  NULL);
125 
126  /* What to do? */
127  if ( Create )
128  {
129  /* Create the key */
130  Status = ZwCreateKey(KeyHandle,
133  0,
134  NULL,
136  &Disposition);
137  }
138  else
139  {
140  /* Open the key */
142  }
143 
144  /* We're done */
145  return Status;
146 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
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:519
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
smooth NULL
Definition: ftsmooth.c:416
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4137
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()

INIT_FUNCTION VOID NTAPI HalpReportSerialNumber ( VOID  )

Definition at line 31 of file misc.c.

32 {
34  UNICODE_STRING KeyString;
35  HANDLE Handle;
36 
37  /* Make sure there is a serial number */
38  if (!HalpSerialLen) return;
39 
40  /* Open the system key */
41  RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
43  if (NT_SUCCESS(Status))
44  {
45  /* Add the serial number */
46  RtlInitUnicodeString(&KeyString, L"Serial Number");
47  ZwSetValueKey(Handle,
48  &KeyString,
49  0,
50  REG_BINARY,
53 
54  /* Close the handle */
55  ZwClose(Handle);
56  }
57 }
#define REG_BINARY
Definition: nt_native.h:1496
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:109
_In_ HANDLE Handle
Definition: extypes.h:390
UCHAR HalpSerialLen
Definition: misc.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
CHAR HalpSerialNumber[31]
Definition: misc.c:23
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
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 227 of file misc.c.

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

◆ KeFlushWriteBuffer()

VOID NTAPI KeFlushWriteBuffer ( VOID  )

Definition at line 242 of file misc.c.

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

Variable Documentation

◆ HalpSerialLen

UCHAR HalpSerialLen

Definition at line 22 of file misc.c.

Referenced by HalpReportSerialNumber().

◆ HalpSerialNumber

CHAR HalpSerialNumber[31]

Definition at line 23 of file misc.c.

Referenced by HalpReportSerialNumber().