1 /* 2 * PROJECT: NEC PC-98 series HAL 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Reboot routine 5 * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com) 6 */ 7 8 /* INCLUDES ******************************************************************/ 9 10 #include <hal.h> 11 12 /* PRIVATE FUNCTIONS *********************************************************/ 13 14 #ifndef _MINIHAL_ 15 static DECLSPEC_NORETURN 16 VOID HalpFreezeSystem(VOID)17HalpFreezeSystem(VOID) 18 { 19 /* Disable interrupts and halt the CPU */ 20 _disable(); 21 __halt(); 22 UNREACHABLE; 23 } 24 #endif 25 26 DECLSPEC_NORETURN 27 VOID HalpReboot(VOID)28HalpReboot(VOID) 29 { 30 /* Disable interrupts */ 31 _disable(); 32 33 /* Flush write buffers */ 34 KeFlushWriteBuffer(); 35 36 /* Send the reset command */ 37 WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_0_ENABLE); 38 WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_1_ENABLE); 39 WRITE_PORT_UCHAR((PUCHAR)CPU_IO_o_RESET, 0); 40 41 /* Halt the CPU */ 42 __halt(); 43 UNREACHABLE; 44 } 45 46 /* PUBLIC FUNCTIONS **********************************************************/ 47 48 #ifndef _MINIHAL_ 49 VOID 50 NTAPI HalReturnToFirmware(_In_ FIRMWARE_REENTRY Action)51HalReturnToFirmware( 52 _In_ FIRMWARE_REENTRY Action) 53 { 54 switch (Action) 55 { 56 /* All recognized actions */ 57 case HalHaltRoutine: 58 case HalPowerDownRoutine: 59 HalpFreezeSystem(); 60 61 case HalRestartRoutine: 62 case HalRebootRoutine: 63 { 64 /* Acquire the display */ 65 InbvAcquireDisplayOwnership(); 66 67 /* Call the internal reboot function */ 68 HalpReboot(); 69 } 70 71 /* Anything else */ 72 default: 73 { 74 /* Print message and break */ 75 DbgPrint("HalReturnToFirmware called!\n"); 76 DbgBreakPoint(); 77 } 78 } 79 } 80 #endif // _MINIHAL_ 81 82 /* EOF */ 83