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 (ekohl@abo.rhein-zeitung.de)
10 /* INCLUDES ******************************************************************/
16 #define GetPteAddress(x) (PHARDWARE_PTE)(((((ULONG_PTR)(x)) >> 12) << 2) + 0xC0000000)
18 /* PRIVATE FUNCTIONS *********************************************************/
22 HalpWriteResetCommand(VOID
)
24 /* Generate RESET signal via keyboard controller */
25 WRITE_PORT_UCHAR((PUCHAR
)0x64, 0xFE);
33 PVOID ZeroPageMapping
;
36 /* Get a PTE in the HAL reserved region */
37 ZeroPageMapping
= (PVOID
)(0xFFC00000 + PAGE_SIZE
);
38 Pte
= GetPteAddress(ZeroPageMapping
);
40 /* Make it valid and map it to the first physical page */
44 Pte
->PageFrameNumber
= 0;
46 /* Flush the TLB by resetting CR3 */
47 __writecr3(__readcr3());
49 /* Enable warm reboot */
50 ((PUSHORT
)ZeroPageMapping
)[0x239] = 0x1234;
52 /* FIXME: Lock CMOS Access */
54 /* Disable interrupts */
57 /* Setup control register B */
58 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x0B);
59 KeStallExecutionProcessor(1);
61 /* Read periodic register and clear the interrupt enable */
62 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
63 WRITE_PORT_UCHAR((PUCHAR
)0x71, Data
& ~0x40);
64 KeStallExecutionProcessor(1);
66 /* Setup control register A */
67 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x0A);
68 KeStallExecutionProcessor(1);
70 /* Read divider rate and reset it */
71 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
72 WRITE_PORT_UCHAR((PUCHAR
)0x71, (Data
& ~0x9) | 0x06);
73 KeStallExecutionProcessor(1);
75 /* Reset neutral CMOS address */
76 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x15);
77 KeStallExecutionProcessor(1);
79 /* Flush write buffers and send the reset command */
81 HalpWriteResetCommand();
87 /* PUBLIC FUNCTIONS **********************************************************/
94 HalReturnToFirmware(IN FIRMWARE_REENTRY Action
)
96 /* Check what kind of action this is */
99 /* All recognized actions */
101 case HalRebootRoutine
:
103 /* Acquire the display */
104 InbvAcquireDisplayOwnership();
106 /* Call the internal reboot function */
112 /* Print message and break */
113 DbgPrint("HalReturnToFirmware called!\n");