Skip to content

Commit 2a74f5e

Browse files
dt10812binarymaster
authored andcommitted
[FREELDR:UEFI] Implement missing cold reset in Reboot() function (reactos#9092)
- Fix a WARN debug print (Reboot can be called from menu). - Stabilize reboot fallback abstractions. - Drop unimplemented path on ARM. CORE-11954 CORE-17604
1 parent 7a80c49 commit 2a74f5e

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

boot/freeldr/freeldr/arch/uefi/uefildr.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,32 @@ ExecuteLoaderCleanly(PVOID PreviousStack)
104104
UNREACHABLE;
105105
}
106106

107-
#ifndef _M_ARM
108107
DECLSPEC_NORETURN
109108
VOID __cdecl Reboot(VOID)
110109
{
111-
//TODO: Replace with a true firmware reboot eventually
112-
WARN("Something has gone wrong - halting FreeLoader\n");
110+
WARN("Performing cold reset\n");
111+
112+
if (GlobalSystemTable && GlobalSystemTable->RuntimeServices)
113+
{
114+
/* Attempt a native firmware cold reset */
115+
GlobalSystemTable->RuntimeServices->ResetSystem(
116+
EfiResetCold,
117+
EFI_SUCCESS,
118+
0,
119+
NULL
120+
);
121+
}
122+
123+
/* Fallback dead-loop if runtime services are missing or fail to respond */
113124
for (;;)
114125
{
126+
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
127+
__halt();
128+
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
129+
__asm__ __volatile__("hlt");
130+
#else
131+
/* Fallback placeholder loop for other platforms */
115132
NOTHING;
133+
#endif
116134
}
117135
}
118-
#endif

boot/freeldr/freeldr/include/arch/arm/hardware.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ extern ULONG gDiskReadBuffer, gFileSysBuffer;
3434

3535
#define DriveMapGetBiosDriveNumber(DeviceName) 0
3636

37-
DECLSPEC_NORETURN
38-
FORCEINLINE VOID Reboot(VOID)
39-
{
40-
DbgBreakPoint();
41-
}
42-
4337
typedef struct _PAGE_TABLE_ARM
4438
{
4539
HARDWARE_PTE_ARMV6 Pte[1024];

0 commit comments

Comments
 (0)