2020-07-25 13:31:02 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: NEC PC-98 series HAL
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: Reboot routine
|
|
|
|
* COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <hal.h>
|
|
|
|
|
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
|
|
|
|
2023-06-20 20:28:31 +00:00
|
|
|
#ifndef _MINIHAL_
|
|
|
|
static DECLSPEC_NORETURN
|
|
|
|
VOID
|
2020-07-25 13:31:02 +00:00
|
|
|
HalpFreezeSystem(VOID)
|
|
|
|
{
|
2023-06-20 20:28:31 +00:00
|
|
|
/* Disable interrupts and halt the CPU */
|
|
|
|
_disable();
|
|
|
|
__halt();
|
|
|
|
UNREACHABLE;
|
2020-07-25 13:31:02 +00:00
|
|
|
}
|
2023-06-20 20:28:31 +00:00
|
|
|
#endif
|
2020-07-25 13:31:02 +00:00
|
|
|
|
2023-06-20 20:28:31 +00:00
|
|
|
DECLSPEC_NORETURN
|
2020-07-25 13:31:02 +00:00
|
|
|
VOID
|
|
|
|
HalpReboot(VOID)
|
|
|
|
{
|
|
|
|
/* Disable interrupts */
|
|
|
|
_disable();
|
|
|
|
|
|
|
|
/* Flush write buffers */
|
|
|
|
KeFlushWriteBuffer();
|
|
|
|
|
|
|
|
/* Send the reset command */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_0_ENABLE);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)PPI_IO_o_CONTROL, PPI_SHUTDOWN_1_ENABLE);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)CPU_IO_o_RESET, 0);
|
|
|
|
|
|
|
|
/* Halt the CPU */
|
|
|
|
__halt();
|
2023-06-20 20:28:31 +00:00
|
|
|
UNREACHABLE;
|
2020-07-25 13:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
2023-06-20 20:28:31 +00:00
|
|
|
#ifndef _MINIHAL_
|
2020-07-25 13:31:02 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalReturnToFirmware(
|
|
|
|
_In_ FIRMWARE_REENTRY Action)
|
|
|
|
{
|
|
|
|
switch (Action)
|
|
|
|
{
|
2023-06-20 20:28:31 +00:00
|
|
|
/* All recognized actions */
|
|
|
|
case HalHaltRoutine:
|
2020-07-25 13:31:02 +00:00
|
|
|
case HalPowerDownRoutine:
|
|
|
|
HalpFreezeSystem();
|
|
|
|
|
2023-06-20 20:28:31 +00:00
|
|
|
case HalRestartRoutine:
|
2020-07-25 13:31:02 +00:00
|
|
|
case HalRebootRoutine:
|
2023-06-20 20:28:31 +00:00
|
|
|
{
|
2020-07-25 13:31:02 +00:00
|
|
|
/* Acquire the display */
|
|
|
|
InbvAcquireDisplayOwnership();
|
|
|
|
|
|
|
|
/* Call the internal reboot function */
|
|
|
|
HalpReboot();
|
2023-06-20 20:28:31 +00:00
|
|
|
}
|
2020-07-25 13:31:02 +00:00
|
|
|
|
|
|
|
/* Anything else */
|
|
|
|
default:
|
2023-06-20 20:28:31 +00:00
|
|
|
{
|
2020-07-25 13:31:02 +00:00
|
|
|
/* Print message and break */
|
|
|
|
DbgPrint("HalReturnToFirmware called!\n");
|
|
|
|
DbgBreakPoint();
|
2023-06-20 20:28:31 +00:00
|
|
|
}
|
2020-07-25 13:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-20 20:28:31 +00:00
|
|
|
#endif // _MINIHAL_
|
|
|
|
|
|
|
|
/* EOF */
|