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

View file

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

View file

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

View file

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

View file

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

View file

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