[FREELDR]

- Effectively reboot instead of exiting the bootloader and hanging.
- Do a cold reboot instead of a (soft) warm reboot, to let the user be able to choose another boot support or do anything else, instead of directly rebooting to the bootloader. Rename the concerned function accordingly.

svn path=/trunk/; revision=57935
This commit is contained in:
Hermès Bélusca-Maïto 2012-12-17 00:22:11 +00:00
parent d03fcd8a09
commit 16ce2a0acf
10 changed files with 27 additions and 25 deletions

View file

@ -359,5 +359,5 @@ VOID OptionMenuReboot(VOID)
UiMessageBox("The system will now reboot."); UiMessageBox("The system will now reboot.");
DiskStopFloppyMotor(); DiskStopFloppyMotor();
SoftReboot(); Reboot();
} }

View file

@ -198,10 +198,10 @@ _PxeCallApi:
ret ret
PUBLIC _SoftReboot PUBLIC _Reboot
_SoftReboot: _Reboot:
/* Set the function ID */ /* Set the function ID */
mov bx, FNID_SoftReboot mov bx, FNID_Reboot
/*Switch to real mode (We don't return) */ /*Switch to real mode (We don't return) */
jmp SwitchToReal jmp SwitchToReal

View file

@ -50,7 +50,7 @@ Startup:
/* Wait for a keypress */ /* Wait for a keypress */
int HEX(16) int HEX(16)
jmp SoftReboot jmp Reboot
Msg_Unsupported: Msg_Unsupported:
.ascii "This CPU is not supported.", CR, LF .ascii "This CPU is not supported.", CR, LF
@ -330,11 +330,11 @@ LongModeEntryPoint:
.long 0, 0 .long 0, 0
int HEX(16) int HEX(16)
jmp SoftReboot jmp Reboot
CallbackTable: CallbackTable:
.word Int386 .word Int386
.word SoftReboot .word Reboot
.word ChainLoadBiosBootSectorCode .word ChainLoadBiosBootSectorCode
.word PxeCallApi .word PxeCallApi
.word PnpBiosGetDeviceNodeCount .word PnpBiosGetDeviceNodeCount

View file

@ -92,20 +92,17 @@ writehex_common:
popfd popfd
ret ret
SoftReboot: Reboot:
mov ax, HEX(40) cli
mov ds, ax
mov si, HEX(72)
/* Set the word at location 40:72 to 1234h */ /* Set the word at location 40h:72h to 0 (cold reboot) */
mov word ptr [si], HEX(1234) mov word ptr ds:[HEX(0472)], HEX(0)
/* and jump to location FFFF:0 in ROM */ /* and jump to location F000h:FFF0h in ROM */
ljmp16 HEX(0FFFF), HEX(0000) ljmp16 HEX(0F000), HEX(0FFF0)
ChainLoadBiosBootSectorCode: ChainLoadBiosBootSectorCode:
/* Load segment registers */ /* Load segment registers */
cli cli
xor ax, ax xor ax, ax
@ -117,4 +114,4 @@ ChainLoadBiosBootSectorCode:
mov esp, HEX(7C00) mov esp, HEX(7C00)
/* Jump to the bootsector code */ /* Jump to the bootsector code */
ljmp16 HEX(0000), HEX(7C00) ljmp16 HEX(0000), HEX(7C00)

View file

@ -142,7 +142,7 @@ pm_entrypoint:
callback_table: callback_table:
.word Int386 .word Int386
.word SoftReboot .word Reboot
.word ChainLoadBiosBootSectorCode .word ChainLoadBiosBootSectorCode
.word PxeCallApi .word PxeCallApi
.word PnpBiosGetDeviceNodeCount .word PnpBiosGetDeviceNodeCount

View file

@ -40,13 +40,13 @@ VOID BootMain(LPSTR CmdLine)
if (!UiInitialize(FALSE)) if (!UiInitialize(FALSE))
{ {
UiMessageBoxCritical("Unable to initialize UI.\n"); UiMessageBoxCritical("Unable to initialize UI.\n");
return; goto quit;
} }
if (!MmInitializeMemoryManager()) if (!MmInitializeMemoryManager())
{ {
UiMessageBoxCritical("Unable to initialize memory manager"); UiMessageBoxCritical("Unable to initialize memory manager");
return; goto quit;
} }
#ifdef _M_IX86 #ifdef _M_IX86
@ -54,6 +54,11 @@ VOID BootMain(LPSTR CmdLine)
HalpInitBusHandler(); HalpInitBusHandler();
#endif #endif
RunLoader(); RunLoader();
quit:
/* If we reach this point, something went wrong before, therefore reboot */
DiskStopFloppyMotor();
Reboot();
} }
// We need to emulate these, because the original ones don't work in freeldr // We need to emulate these, because the original ones don't work in freeldr

View file

@ -119,7 +119,7 @@ int Int386(int ivec, REGS* in, REGS* out);
void EnableA20(void); void EnableA20(void);
VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S
VOID SoftReboot(VOID); // Implemented in boot.S VOID Reboot(VOID); // Implemented in boot.S
VOID DetectHardware(VOID); // Implemented in hardware.c VOID DetectHardware(VOID); // Implemented in hardware.c
#endif /* ! __ASM__ */ #endif /* ! __ASM__ */

View file

@ -48,7 +48,7 @@
/* Realmode function IDs */ /* Realmode function IDs */
#define FNID_Int386 0 #define FNID_Int386 0
#define FNID_SoftReboot 1 #define FNID_Reboot 1
#define FNID_ChainLoadBiosBootSectorCode 2 #define FNID_ChainLoadBiosBootSectorCode 2
#define FNID_PxeCallApi 3 #define FNID_PxeCallApi 3
#define FNID_PnpBiosGetDeviceNodeCount 4 #define FNID_PnpBiosGetDeviceNodeCount 4

View file

@ -48,8 +48,8 @@ int TuiPrintf(const char *Format, ...)
BOOLEAN TuiInitialize(VOID) BOOLEAN TuiInitialize(VOID)
{ {
MachVideoClearScreen(ATTR(COLOR_WHITE, COLOR_BLACK));
MachVideoHideShowTextCursor(FALSE); MachVideoHideShowTextCursor(FALSE);
MachVideoClearScreen(ATTR(COLOR_GRAY, COLOR_BLACK));
TextVideoBuffer = VideoAllocateOffScreenBuffer(); TextVideoBuffer = VideoAllocateOffScreenBuffer();
if (TextVideoBuffer == NULL) if (TextVideoBuffer == NULL)
@ -71,7 +71,7 @@ VOID TuiUnInitialize(VOID)
MachVideoSetDisplayMode(NULL, FALSE); MachVideoSetDisplayMode(NULL, FALSE);
} }
//VideoClearScreen(); MachVideoClearScreen(ATTR(COLOR_GRAY, COLOR_BLACK));
MachVideoHideShowTextCursor(TRUE); MachVideoHideShowTextCursor(TRUE);
} }

View file

@ -229,7 +229,7 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui)
VOID UiUnInitialize(PCSTR BootText) VOID UiUnInitialize(PCSTR BootText)
{ {
UiDrawBackdrop(); UiDrawBackdrop();
UiDrawStatusText("Booting..."); UiDrawStatusText(BootText);
UiInfoBox(BootText); UiInfoBox(BootText);
UiVtbl.UnInitialize(); UiVtbl.UnInitialize();