[HAL][MINIHAL] Minor cleanup in reboot.c files (#5359)

And remove pic/processor.c from minihal compilation.
This commit is contained in:
Hermès Bélusca-Maïto 2023-06-20 22:28:31 +02:00
parent 50d78f04e3
commit 9ba1849a97
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
6 changed files with 71 additions and 44 deletions

View file

@ -9,35 +9,41 @@
/* INCLUDES ******************************************************************/
#include <hal.h>
#define NDEBUG
#include <debug.h>
/* PUBLIC FUNCTIONS **********************************************************/
#ifndef _MINIHAL_
/*
* @implemented
*/
VOID
NTAPI
HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
HalReturnToFirmware(
_In_ FIRMWARE_REENTRY Action)
{
/* Check what kind of action this is */
switch (Action)
{
/* All recognized actions */
case HalHaltRoutine:
case HalPowerDownRoutine:
case HalRestartRoutine:
case HalRebootRoutine:
{
/* Acquire the display */
InbvAcquireDisplayOwnership();
// TODO: Reboot
}
/* Anything else */
default:
{
/* Print message and break */
DbgPrint("HalReturnToFirmware called!\n");
DbgBreakPoint();
}
}
}
#endif // _MINIHAL_
/* EOF */

View file

@ -10,21 +10,18 @@
/* INCLUDES ******************************************************************/
#include <hal.h>
#define NDEBUG
#include <debug.h>
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
static VOID
HalpWriteResetCommand(VOID)
{
/* Generate RESET signal via keyboard controller */
WRITE_PORT_UCHAR((PUCHAR)0x64, 0xFE);
};
DECLSPEC_NORETURN
VOID
NTAPI
HalpReboot(VOID)
{
PHYSICAL_ADDRESS PhysicalAddress;
@ -69,39 +66,45 @@ HalpReboot(VOID)
/* Halt the CPU */
__halt();
UNREACHABLE;
}
/* PUBLIC FUNCTIONS **********************************************************/
#ifndef _MINIHAL_
/*
* @implemented
*/
VOID
NTAPI
HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
HalReturnToFirmware(
_In_ FIRMWARE_REENTRY Action)
{
/* Check what kind of action this is */
switch (Action)
{
/* All recognized actions */
case HalHaltRoutine:
case HalPowerDownRoutine:
case HalRestartRoutine:
case HalRebootRoutine:
#ifndef _MINIHAL_
{
/* Acquire the display */
InbvAcquireDisplayOwnership();
#endif
/* Call the internal reboot function */
HalpReboot();
}
/* Anything else */
default:
{
/* Print message and break */
DbgPrint("HalReturnToFirmware called!\n");
DbgBreakPoint();
}
}
}
#endif // _MINIHAL_
/* EOF */

View file

@ -14,7 +14,6 @@ list(APPEND MINI_HAL_SOURCE
../generic/timer.c
../generic/usage.c
../pic/pic.c
../pic/processor.c
../include/hal.h
halinit.c)

View file

@ -9,24 +9,22 @@
#include <hal.h>
#define NDEBUG
#include <debug.h>
/* PRIVATE FUNCTIONS *********************************************************/
static VOID
DECLSPEC_NORETURN
NTAPI
#ifndef _MINIHAL_
static DECLSPEC_NORETURN
VOID
HalpFreezeSystem(VOID)
{
HaliHaltSystem();
while (TRUE)
NOTHING;
/* Disable interrupts and halt the CPU */
_disable();
__halt();
UNREACHABLE;
}
#endif
DECLSPEC_NORETURN
VOID
NTAPI
HalpReboot(VOID)
{
/* Disable interrupts */
@ -42,10 +40,12 @@ HalpReboot(VOID)
/* Halt the CPU */
__halt();
UNREACHABLE;
}
/* PUBLIC FUNCTIONS **********************************************************/
#ifndef _MINIHAL_
VOID
NTAPI
HalReturnToFirmware(
@ -53,23 +53,30 @@ HalReturnToFirmware(
{
switch (Action)
{
/* All recognized actions */
case HalHaltRoutine:
case HalPowerDownRoutine:
HalpFreezeSystem();
case HalHaltRoutine:
case HalRestartRoutine:
case HalRebootRoutine:
#ifndef _MINIHAL_
{
/* Acquire the display */
InbvAcquireDisplayOwnership();
#endif
/* Call the internal reboot function */
HalpReboot();
}
/* Anything else */
default:
{
/* Print message and break */
DbgPrint("HalReturnToFirmware called!\n");
DbgBreakPoint();
}
}
}
#endif // _MINIHAL_
/* EOF */

View file

@ -27,7 +27,6 @@ HaliHaltSystem(VOID)
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/

View file

@ -15,14 +15,13 @@
#include "halxbox.h"
#define NDEBUG
#include <debug.h>
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
SMBusWriteByte(UCHAR Address, UCHAR Register, UCHAR Data)
static VOID
SMBusWriteByte(
_In_ UCHAR Address,
_In_ UCHAR Register,
_In_ UCHAR Data)
{
INT Retries = 50;
@ -63,35 +62,47 @@ SMBusWriteByte(UCHAR Address, UCHAR Register, UCHAR Data)
}
}
static DECLSPEC_NORETURN
VOID
DECLSPEC_NORETURN
NTAPI
HalpXboxPowerAction(IN UCHAR Action)
HalpXboxPowerAction(
_In_ UCHAR Action)
{
/* Disable interrupts */
_disable();
/* Send the command */
SMBusWriteByte(SMB_DEVICE_SMC_PIC16LC, SMC_REG_POWER, Action);
/* Halt the CPU */
__halt();
UNREACHABLE;
}
while (TRUE); /* 'noreturn' function */
DECLSPEC_NORETURN
VOID
HalpReboot(VOID)
{
HalpXboxPowerAction(SMC_REG_POWER_RESET);
}
/* PUBLIC FUNCTIONS **********************************************************/
#ifndef _MINIHAL_
/*
* @implemented
*/
VOID
NTAPI
HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
HalReturnToFirmware(
_In_ FIRMWARE_REENTRY Action)
{
/* Check what kind of action this is */
switch (Action)
{
/* All recognized actions */
/* All recognized actions: call the internal power function */
case HalHaltRoutine:
case HalPowerDownRoutine:
{
/* Call the internal power function */
HalpXboxPowerAction(SMC_REG_POWER_SHUTDOWN);
}
case HalRestartRoutine:
@ -102,6 +113,7 @@ HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
{
HalpXboxPowerAction(SMC_REG_POWER_RESET);
}
/* Anything else */
default:
{
@ -111,5 +123,6 @@ HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
}
}
}
#endif // _MINIHAL_
/* EOF */