ReactOS  0.4.14-dev-342-gdc047f9
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)
 
VOID NTAPI HalHandleNMI (IN PVOID NmiInfo)
 
UCHAR FASTCALL HalSystemVectorDispatchEntry (IN ULONG Vector, OUT PKINTERRUPT_ROUTINE **FlatDispatch, OUT PKINTERRUPT_ROUTINE *NoConnection)
 
VOID NTAPI KeFlushWriteBuffer (VOID)
 

Variables

BOOLEAN HalpNMIInProgress
 
UCHAR HalpSerialLen
 
CHAR HalpSerialNumber [31]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file misc.c.

Function Documentation

◆ HalHandleNMI()

VOID NTAPI HalHandleNMI ( IN PVOID  NmiInfo)

Definition at line 229 of file misc.c.

230 {
231 #ifndef _MINIHAL_
232  SYSTEM_CONTROL_PORT_B_REGISTER SystemControl;
233 
234  //
235  // Don't recurse
236  //
238 
239  //
240  // Read the system control register B
241  //
242  SystemControl.Bits = __inbyte(SYSTEM_CONTROL_PORT_B);
243 
244  //
245  // Switch to boot vieo
246  //
248  {
249  //
250  // Acquire ownership
251  //
254 
255  //
256  // Fill the screen
257  //
258  InbvSolidColorFill(0, 0, 639, 479, 1);
259  InbvSetScrollRegion(0, 0, 639, 479);
260 
261  //
262  // Enable text
263  //
264  InbvSetTextColor(15);
267  }
268 
269  //
270  // Display NMI failure string
271  //
272  InbvDisplayString("\r\n*** Hardware Malfunction\r\n\r\n");
273  InbvDisplayString("Call your hardware vendor for support\r\n\r\n");
274 
275  //
276  // Check for parity error
277  //
278  if (SystemControl.ParityCheck)
279  {
280  //
281  // Display message
282  //
283  InbvDisplayString("NMI: Parity Check / Memory Parity Error\r\n");
284  }
285 
286  //
287  // Check for I/O failure
288  //
289  if (SystemControl.ChannelCheck)
290  {
291  //
292  // Display message
293  //
294  InbvDisplayString("NMI: Channel Check / IOCHK\r\n");
295  }
296 
297  //
298  // Check for EISA systems
299  //
301  {
302  //
303  // FIXME: Not supported
304  //
306  }
307 
308  //
309  // Halt the system
310  //
311  InbvDisplayString("\r\n*** The system has halted ***\r\n");
312 
313 
314  //
315  // Enter the debugger if possible
316  //
317  KiBugCheckData[0] = (ULONG_PTR)KeServiceDescriptorTable; /* NMI Corruption? */
318  //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
319 #endif
320  //
321  // Freeze the system
322  //
323  while (TRUE);
324 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:573
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:720
#define SYSTEM_CONTROL_PORT_B
Definition: halp.h:171
#define ERROR_DBGBREAK(...)
Definition: debug.h:221
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:696
ULONG HalpBusType
Definition: bus.c:17
ULONG_PTR KiBugCheckData[5]
Definition: bug.c:30
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:532
BOOLEAN HalpNMIInProgress
Definition: misc.c:22
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:610
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:634
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:668
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:626
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
#define UNIMPLEMENTED
Definition: debug.h:114
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:685
#define MACHINE_TYPE_EISA
Definition: ketypes.h:53
PPC_QUAL unsigned char __inbyte(const unsigned long Port)
Definition: intrin_ppc.h:539

◆ HalpCheckPowerButton()

VOID NTAPI HalpCheckPowerButton ( VOID  )

Definition at line 153 of file misc.c.

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

◆ HalpFlushTLB()

VOID NTAPI HalpFlushTLB ( VOID  )

Definition at line 163 of file misc.c.

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

65 {
67  UNICODE_STRING KeyString;
69  HANDLE Handle;
71 
72  /* Open the control set key */
73  RtlInitUnicodeString(&KeyString,
74  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
76  if (NT_SUCCESS(Status))
77  {
78  /* Open the PNP key */
79  RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
81  Handle,
82  &KeyString,
84  TRUE);
85  /* Close root key */
86  ZwClose(Handle);
87 
88  /* Check if PNP BIOS key exists */
89  if (NT_SUCCESS(Status))
90  {
91  /* Set the disable value to false -- we need the mapper */
92  RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
93  Status = ZwSetValueKey(KeyHandle,
94  &KeyString,
95  0,
96  REG_DWORD,
97  &Value,
98  sizeof(Value));
99 
100  /* Close subkey */
102  }
103  }
104 
105  /* Return status */
106  return Status;
107 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#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
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:111
_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 111 of file misc.c.

116 {
120 
121  /* Setup the attributes we received */
123  KeyName,
125  RootKey,
126  NULL);
127 
128  /* What to do? */
129  if ( Create )
130  {
131  /* Create the key */
132  Status = ZwCreateKey(KeyHandle,
135  0,
136  NULL,
138  &Disposition);
139  }
140  else
141  {
142  /* Open the key */
144  }
145 
146  /* We're done */
147  return Status;
148 }
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
_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:511
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
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
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:4157
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 33 of file misc.c.

34 {
36  UNICODE_STRING KeyString;
37  HANDLE Handle;
38 
39  /* Make sure there is a serial number */
40  if (!HalpSerialLen) return;
41 
42  /* Open the system key */
43  RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
45  if (NT_SUCCESS(Status))
46  {
47  /* Add the serial number */
48  RtlInitUnicodeString(&KeyString, L"Serial Number");
49  ZwSetValueKey(Handle,
50  &KeyString,
51  0,
52  REG_BINARY,
55 
56  /* Close the handle */
57  ZwClose(Handle);
58  }
59 }
#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:111
_In_ HANDLE Handle
Definition: extypes.h:390
UCHAR HalpSerialLen
Definition: misc.c:24
#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:25
#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 331 of file misc.c.

334 {
335  //
336  // Not implemented on x86
337  //
338  return 0;
339 }

◆ KeFlushWriteBuffer()

VOID NTAPI KeFlushWriteBuffer ( VOID  )

Definition at line 346 of file misc.c.

347 {
348  //
349  // Not implemented on x86
350  //
351  return;
352 }

Variable Documentation

◆ HalpNMIInProgress

BOOLEAN HalpNMIInProgress

Definition at line 22 of file misc.c.

Referenced by HalHandleNMI(), and HalpRestoreTrapHandlers().

◆ HalpSerialLen

UCHAR HalpSerialLen

Definition at line 24 of file misc.c.

Referenced by HalpReportSerialNumber().

◆ HalpSerialNumber

CHAR HalpSerialNumber[31]

Definition at line 25 of file misc.c.

Referenced by HalpReportSerialNumber().