https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9ba1849a9765b049527c0bf60f8a91efe70e2991

commit 9ba1849a9765b049527c0bf60f8a91efe70e2991
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Tue Jun 20 22:28:31 2023 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Jun 25 19:39:44 2023 +0200

    [HAL][MINIHAL] Minor cleanup in reboot.c files (#5359)
    
    And remove pic/processor.c from minihal compilation.
---
 hal/halarm/generic/reboot.c       | 16 +++++++++++-----
 hal/halx86/generic/reboot.c       | 23 +++++++++++++----------
 hal/halx86/minihal/CMakeLists.txt |  1 -
 hal/halx86/pc98/reboot.c          | 35 +++++++++++++++++++++--------------
 hal/halx86/pic/processor.c        |  1 -
 hal/halx86/xbox/reboot.c          | 39 ++++++++++++++++++++++++++-------------
 6 files changed, 71 insertions(+), 44 deletions(-)

diff --git a/hal/halarm/generic/reboot.c b/hal/halarm/generic/reboot.c
index 51de4862bc8..408313c98c2 100644
--- a/hal/halarm/generic/reboot.c
+++ b/hal/halarm/generic/reboot.c
@@ -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 */
diff --git a/hal/halx86/generic/reboot.c b/hal/halx86/generic/reboot.c
index 587b116c6f0..ca83b3fb733 100644
--- a/hal/halx86/generic/reboot.c
+++ b/hal/halx86/generic/reboot.c
@@ -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 */
diff --git a/hal/halx86/minihal/CMakeLists.txt 
b/hal/halx86/minihal/CMakeLists.txt
index de7f4de04ed..d446bf3cc7b 100644
--- a/hal/halx86/minihal/CMakeLists.txt
+++ b/hal/halx86/minihal/CMakeLists.txt
@@ -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)
 
diff --git a/hal/halx86/pc98/reboot.c b/hal/halx86/pc98/reboot.c
index d26fef2d1d2..6944ace3315 100644
--- a/hal/halx86/pc98/reboot.c
+++ b/hal/halx86/pc98/reboot.c
@@ -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 */
diff --git a/hal/halx86/pic/processor.c b/hal/halx86/pic/processor.c
index 58bf6e0187e..2ea03b57326 100644
--- a/hal/halx86/pic/processor.c
+++ b/hal/halx86/pic/processor.c
@@ -27,7 +27,6 @@ HaliHaltSystem(VOID)
 
 /* FUNCTIONS *****************************************************************/
 
-
 /*
  * @implemented
  */
diff --git a/hal/halx86/xbox/reboot.c b/hal/halx86/xbox/reboot.c
index 1f2dec387c1..21de1d93073 100644
--- a/hal/halx86/xbox/reboot.c
+++ b/hal/halx86/xbox/reboot.c
@@ -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 */

Reply via email to