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)
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 /* Lock CMOS Access (and disable interrupts) */
53 HalpAcquireCmosSpinLock();
55 /* Setup control register B */
56 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x0B);
57 KeStallExecutionProcessor(1);
59 /* Read periodic register and clear the interrupt enable */
60 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
61 WRITE_PORT_UCHAR((PUCHAR
)0x71, Data
& ~0x40);
62 KeStallExecutionProcessor(1);
64 /* Setup control register A */
65 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x0A);
66 KeStallExecutionProcessor(1);
68 /* Read divider rate and reset it */
69 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
70 WRITE_PORT_UCHAR((PUCHAR
)0x71, (Data
& ~0x9) | 0x06);
71 KeStallExecutionProcessor(1);
73 /* Reset neutral CMOS address */
74 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x15);
75 KeStallExecutionProcessor(1);
77 /* Flush write buffers and send the reset command */
79 HalpWriteResetCommand();
85 /* PUBLIC FUNCTIONS **********************************************************/
92 HalReturnToFirmware(IN FIRMWARE_REENTRY Action
)
94 /* Check what kind of action this is */
97 /* All recognized actions */
99 case HalRebootRoutine
:
102 /* Acquire the display */
103 InbvAcquireDisplayOwnership();
106 /* Call the internal reboot function */
112 /* Print message and break */
113 DbgPrint("HalReturnToFirmware called!\n");