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 #define NDEBUG 13 #include <debug.h> 14 15 /* PRIVATE FUNCTIONS *********************************************************/ 16 17 static VOID 18 DECLSPEC_NORETURN 19 NTAPI 20 HalpFreezeSystem(VOID) 21 { 22 HaliHaltSystem(); 23 24 while (TRUE) 25 NOTHING; 26 } 27 28 VOID 29 NTAPI 30 HalpReboot(VOID) 31 { 32 /* Disable interrupts */ 33 _disable(); 34 35 /* Flush write buffers */ 36 KeFlushWriteBuffer(); 37 38 /* Send the reset command */ 39 WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_0_ENABLE); 40 WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_1_ENABLE); 41 WRITE_PORT_UCHAR((PUCHAR)CPU_IO_o_RESET, 0); 42 43 /* Halt the CPU */ 44 __halt(); 45 } 46 47 /* PUBLIC FUNCTIONS **********************************************************/ 48 49 VOID 50 NTAPI 51 HalReturnToFirmware( 52 _In_ FIRMWARE_REENTRY Action) 53 { 54 switch (Action) 55 { 56 case HalPowerDownRoutine: 57 HalpFreezeSystem(); 58 59 case HalHaltRoutine: 60 case HalRebootRoutine: 61 #ifndef _MINIHAL_ 62 /* Acquire the display */ 63 InbvAcquireDisplayOwnership(); 64 #endif 65 66 /* Call the internal reboot function */ 67 HalpReboot(); 68 69 /* Anything else */ 70 default: 71 /* Print message and break */ 72 DbgPrint("HalReturnToFirmware called!\n"); 73 DbgBreakPoint(); 74 } 75 } 76