Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenreboot.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS HAL 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: hal/halx86/generic/reboot.c 00005 * PURPOSE: Reboot functions 00006 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) 00007 * Eric Kohl 00008 */ 00009 00010 /* INCLUDES ******************************************************************/ 00011 00012 #include <hal.h> 00013 #define NDEBUG 00014 #include <debug.h> 00015 00016 #define GetPteAddress(x) (PHARDWARE_PTE)(((((ULONG_PTR)(x)) >> 12) << 2) + 0xC0000000) 00017 00018 /* PRIVATE FUNCTIONS *********************************************************/ 00019 00020 VOID 00021 NTAPI 00022 HalpWriteResetCommand(VOID) 00023 { 00024 /* Generate RESET signal via keyboard controller */ 00025 WRITE_PORT_UCHAR((PUCHAR)0x64, 0xFE); 00026 }; 00027 00028 VOID 00029 NTAPI 00030 HalpReboot(VOID) 00031 { 00032 UCHAR Data; 00033 PVOID ZeroPageMapping; 00034 PHARDWARE_PTE Pte; 00035 00036 /* Get a PTE in the HAL reserved region */ 00037 ZeroPageMapping = (PVOID)(0xFFC00000 + PAGE_SIZE); 00038 Pte = GetPteAddress(ZeroPageMapping); 00039 00040 /* Make it valid and map it to the first physical page */ 00041 Pte->Valid = 1; 00042 Pte->Write = 1; 00043 Pte->Owner = 1; 00044 Pte->PageFrameNumber = 0; 00045 00046 /* Flush the TLB by resetting CR3 */ 00047 __writecr3(__readcr3()); 00048 00049 /* Enable warm reboot */ 00050 ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234; 00051 00052 /* Lock CMOS Access (and disable interrupts) */ 00053 HalpAcquireCmosSpinLock(); 00054 00055 /* Setup control register B */ 00056 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B); 00057 KeStallExecutionProcessor(1); 00058 00059 /* Read periodic register and clear the interrupt enable */ 00060 Data = READ_PORT_UCHAR((PUCHAR)0x71); 00061 WRITE_PORT_UCHAR((PUCHAR)0x71, Data & ~0x40); 00062 KeStallExecutionProcessor(1); 00063 00064 /* Setup control register A */ 00065 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0A); 00066 KeStallExecutionProcessor(1); 00067 00068 /* Read divider rate and reset it */ 00069 Data = READ_PORT_UCHAR((PUCHAR)0x71); 00070 WRITE_PORT_UCHAR((PUCHAR)0x71, (Data & ~0x9) | 0x06); 00071 KeStallExecutionProcessor(1); 00072 00073 /* Reset neutral CMOS address */ 00074 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x15); 00075 KeStallExecutionProcessor(1); 00076 00077 /* Flush write buffers and send the reset command */ 00078 KeFlushWriteBuffer(); 00079 HalpWriteResetCommand(); 00080 00081 /* Halt the CPU */ 00082 __halt(); 00083 } 00084 00085 /* PUBLIC FUNCTIONS **********************************************************/ 00086 00087 /* 00088 * @implemented 00089 */ 00090 VOID 00091 NTAPI 00092 HalReturnToFirmware(IN FIRMWARE_REENTRY Action) 00093 { 00094 /* Check what kind of action this is */ 00095 switch (Action) 00096 { 00097 /* All recognized actions */ 00098 case HalHaltRoutine: 00099 case HalRebootRoutine: 00100 00101 #ifndef _MINIHAL_ 00102 /* Acquire the display */ 00103 InbvAcquireDisplayOwnership(); 00104 #endif 00105 00106 /* Call the internal reboot function */ 00107 HalpReboot(); 00108 00109 /* Anything else */ 00110 default: 00111 00112 /* Print message and break */ 00113 DbgPrint("HalReturnToFirmware called!\n"); 00114 DbgBreakPoint(); 00115 } 00116 } 00117 00118 /* EOF */ Generated on Sun May 27 2012 04:28:40 for ReactOS by
1.7.6.1
|