ReactOS  0.4.15-dev-2487-g7b27e7c
reboot.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: hal/halx86/generic/reboot.c
5  * PURPOSE: Reboot functions
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  * Eric Kohl
8  */
9 
10 /* INCLUDES ******************************************************************/
11 
12 #include <hal.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* PRIVATE FUNCTIONS *********************************************************/
17 
18 VOID
19 NTAPI
21 {
22  /* Generate RESET signal via keyboard controller */
23  WRITE_PORT_UCHAR((PUCHAR)0x64, 0xFE);
24 };
25 
26 VOID
27 NTAPI
29 {
31  UCHAR Data;
32  PVOID ZeroPageMapping;
33 
34  /* Map the first physical page */
36  ZeroPageMapping = HalpMapPhysicalMemory64(PhysicalAddress, 1);
37 
38  /* Enable warm reboot */
39  ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234;
40 
41  /* Lock CMOS Access (and disable interrupts) */
43 
44  /* Setup control register B */
45  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B);
47 
48  /* Read periodic register and clear the interrupt enable */
49  Data = READ_PORT_UCHAR((PUCHAR)0x71);
50  WRITE_PORT_UCHAR((PUCHAR)0x71, Data & ~0x40);
52 
53  /* Setup control register A */
54  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0A);
56 
57  /* Read divider rate and reset it */
58  Data = READ_PORT_UCHAR((PUCHAR)0x71);
59  WRITE_PORT_UCHAR((PUCHAR)0x71, (Data & ~0x9) | 0x06);
61 
62  /* Reset neutral CMOS address */
63  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x15);
65 
66  /* Flush write buffers and send the reset command */
69 
70  /* Halt the CPU */
71  __halt();
72 }
73 
74 /* PUBLIC FUNCTIONS **********************************************************/
75 
76 /*
77  * @implemented
78  */
79 VOID
80 NTAPI
82 {
83  /* Check what kind of action this is */
84  switch (Action)
85  {
86  /* All recognized actions */
87  case HalHaltRoutine:
88  case HalRebootRoutine:
89 
90 #ifndef _MINIHAL_
91  /* Acquire the display */
93 #endif
94 
95  /* Call the internal reboot function */
96  HalpReboot();
97 
98  /* Anything else */
99  default:
100 
101  /* Print message and break */
102  DbgPrint("HalReturnToFirmware called!\n");
103  DbgBreakPoint();
104  }
105 }
106 
107 /* EOF */
#define IN
Definition: typedefs.h:39
#define DbgPrint
Definition: loader.c:25
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1715
void DbgBreakPoint()
Definition: mach.c:553
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
VOID NTAPI HalpReboot(VOID)
Definition: reboot.c:28
enum _FIRMWARE_REENTRY FIRMWARE_REENTRY
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:227
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:528
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
unsigned char UCHAR
Definition: xmlstorage.h:181
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
VOID NTAPI HalpWriteResetCommand(VOID)
Definition: reboot.c:20
VOID NTAPI KeFlushWriteBuffer(VOID)
Definition: misc.c:39
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
unsigned short * PUSHORT
Definition: retypes.h:2
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:95
LONGLONG QuadPart
Definition: typedefs.h:114