ReactOS 0.4.16-dev-91-g764881a
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
14/* PRIVATE FUNCTIONS *********************************************************/
15
16static VOID
18{
19 /* Generate RESET signal via keyboard controller */
20 WRITE_PORT_UCHAR((PUCHAR)0x64, 0xFE);
21};
22
24VOID
26{
28 UCHAR Data;
29 PVOID ZeroPageMapping;
30
31 /* Map the first physical page */
33 ZeroPageMapping = HalpMapPhysicalMemory64(PhysicalAddress, 1);
34
35 /* Enable warm reboot */
36 ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234;
37
38 /* Lock CMOS Access (and disable interrupts) */
40
41 /* Setup control register B */
42 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B);
44
45 /* Read periodic register and clear the interrupt enable */
47 WRITE_PORT_UCHAR((PUCHAR)0x71, Data & ~0x40);
49
50 /* Setup control register A */
51 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0A);
53
54 /* Read divider rate and reset it */
56 WRITE_PORT_UCHAR((PUCHAR)0x71, (Data & ~0x9) | 0x06);
58
59 /* Reset neutral CMOS address */
60 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x15);
62
63 /* Flush write buffers and send the reset command */
66
67 /* Halt the CPU */
68 __halt();
70}
71
72/* PUBLIC FUNCTIONS **********************************************************/
73
74#ifndef _MINIHAL_
75/*
76 * @implemented
77 */
78VOID
82{
83 /* Check what kind of action this is */
84 switch (Action)
85 {
86 /* All recognized actions */
87 case HalHaltRoutine:
91 {
92 /* Acquire the display */
94
95 /* Call the internal reboot function */
96 HalpReboot();
97 }
98
99 /* Anything else */
100 default:
101 {
102 /* Print message and break */
103 DbgPrint("HalReturnToFirmware called!\n");
105 }
106 }
107}
108#endif // _MINIHAL_
109
110/* EOF */
VOID NTAPI KeFlushWriteBuffer(VOID)
Definition: misc.c:39
#define DbgPrint
Definition: hal.h:12
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount)
Definition: memory.c:140
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:226
VOID NTAPI HalReturnToFirmware(_In_ FIRMWARE_REENTRY Action)
Definition: reboot.c:21
static VOID HalpWriteResetCommand(VOID)
Definition: reboot.c:17
DECLSPEC_NORETURN VOID HalpReboot(VOID)
Definition: reboot.c:25
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:290
NTSYSAPI void WINAPI DbgBreakPoint(void)
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1714
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
#define _In_
Definition: ms_sal.h:308
enum _FIRMWARE_REENTRY FIRMWARE_REENTRY
@ HalRestartRoutine
Definition: haltypes.h:36
@ HalHaltRoutine
Definition: haltypes.h:34
@ HalPowerDownRoutine
Definition: haltypes.h:35
@ HalRebootRoutine
Definition: haltypes.h:37
#define UNREACHABLE
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
unsigned char UCHAR
Definition: xmlstorage.h:181