Opened 15 years ago

Closed 15 years ago

#5113 closed enhancement (duplicate)

[PATCH] Warm boot for Bootloader

Reported by: Grey Owned by: axeld
Priority: normal Milestone: R1
Component: System/Boot Loader Version: R1/alpha1
Keywords: Warm boot Cc:
Blocked By: #5312 Blocking:
Platform: x86

Description (last modified by axeld)

This is small patch for bootloader. X86 only! Function war_boot() added to src/system/boot/platform/bios_ia32/bios.S Press 'W' or 'w' for warm boot.

Index: src/system/boot/platform/bios_ia32/keyboard.h
===================================================================
--- src/system/boot/platform/bios_ia32/keyboard.h	(revision 34640)
+++ src/system/boot/platform/bios_ia32/keyboard.h	(working copy)
@@ -29,6 +29,7 @@
 extern void clear_key_buffer(void);
 extern union key wait_for_key(void);
 extern uint32 check_for_boot_keys(void);
+extern void warm_boot(void);
 
 #ifdef __cplusplus
 }
Index: src/system/boot/platform/bios_ia32/bios.S
===================================================================
--- src/system/boot/platform/bios_ia32/bios.S	(revision 34640)
+++ src/system/boot/platform/bios_ia32/bios.S	(working copy)
@@ -231,7 +231,49 @@
 	ret
 
 //--------------------------------------------------------------
+/** void warm_boot()
+ *	Warm booting computer via BIOS int 0x19. save_crx() have to be called before paging setup.
+ */
+FUNCTION(warm_boot)
+	cli
+	movl	saved_cr0,%eax
+	movl	%eax,%cr0
+	movl	saved_cr3,%eax
+	movl	%eax,%cr3
+	movl	saved_cr4,%eax
+	movl	%eax,%cr4
+	lidt	saved_idt
+	call	switch_to_real_mode
+	.byte  0xCD
+	.byte  0x19
+	ret
+//--------------------------------------------------------------
+/** void save_crx()
+ *	Save CRx registers state. Required for warm_boot.
+ */
+FUNCTION(save_crx)
+	cli
+	movl	%cr0,%eax
+	movl	%eax,saved_cr0
+	movl	%cr3,%eax
+	movl	%eax,saved_cr3
+	movl	%cr4,%eax
+	movl	%eax,saved_cr4
+	sidt	saved_idt
+	ret
+//--------------------------------------------------------------
+	.p2align 4
+saved_idt:
+	.long	0x0
+	.long	0x0
+saved_cr0:
+	.long	0x0
+saved_cr3:
+	.long	0x0
+saved_cr4:
+	.long	0x0
 
+	.p2align 4
 .globl idt_descriptor
 idt_descriptor:
 	.short	0x7ff				// IDT at 0x0, default real mode location
Index: src/system/boot/platform/bios_ia32/keyboard.cpp
===================================================================
--- src/system/boot/platform/bios_ia32/keyboard.cpp	(revision 34640)
+++ src/system/boot/platform/bios_ia32/keyboard.cpp	(working copy)
@@ -69,6 +69,9 @@
 			case 0x1b:	// escape
 				options |= BOOT_OPTION_DEBUG_OUTPUT;
 				break;
+			case 'w':
+			case 'W':
+				warm_boot();
 			case 0:
 				// evaluate BIOS scan codes
 				// ...
Index: src/system/boot/platform/bios_ia32/start.c
===================================================================
--- src/system/boot/platform/bios_ia32/start.c	(revision 34640)
+++ src/system/boot/platform/bios_ia32/start.c	(working copy)
@@ -107,7 +107,6 @@
 	out8(0xfe, 0x64);
 }
 
-
 void
 _start(void)
 {
@@ -126,6 +125,7 @@
 	serial_init();
 	console_init();
 	cpu_init();
+	save_crx();
 	mmu_init();
 	parse_multiboot_commandline(&args);
 

Attachments (2)

warm_boot.patch (2.6 KB ) - added by Grey 15 years ago.
warm_boot_patch
warm_boot.2.patch (2.5 KB ) - added by Grey 15 years ago.
corrected warm_boot.patch

Download all attachments as: .zip

Change History (5)

by Grey, 15 years ago

Attachment: warm_boot.patch added

warm_boot_patch

comment:1 by axeld, 15 years ago

Description: modified (diff)

First of all thanks for the patch.

But then, please attach a diff instead of of copying it into the ticket description next time. Also, changes like:

 }
 
-
 void
 _start(void)

shouldn't be found in such a patch, as this introduces a style violation in previously fine code.

Then:

+			case 'w':
+			case 'W':
+				warm_boot();
 			case 0:

There is a "break;" missing - even if warm_boot() is not supposed to return, it's just good style.

Finally, what is the purpose of this patch? What does it do, and what does one gain?

by Grey, 15 years ago

Attachment: warm_boot.2.patch added

corrected warm_boot.patch

comment:2 by Grey, 15 years ago

Ok. Patch corrected and attached. I am working on boot_loader patch for compressed kernel and modules loading. A lot of reboots required for this job. So I make this small patch to accelerate reboot. I hope warm_reboot will be useful for other developers. When boot_loader starting, it's possible to press space or ESC for open menu. This patch add one more opportunity - to press W for warm boot and fast reload fist level bootmanager ( in my case it is GRUB).

comment:3 by axeld, 15 years ago

Blocked By: 5312 added
Resolution: duplicate
Status: newclosed

Superceded by #5312.

Note: See TracTickets for help on using tickets.