Pārlūkot izejas kodu

[cmdline] Add ability to perform a warm reboot

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 gadus atpakaļ
vecāks
revīzija
e68a6ca225

+ 2
- 0
src/arch/i386/include/bios.h Parādīt failu

@@ -6,6 +6,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
6 6
 #define BDA_SEG 0x0040
7 7
 #define BDA_EQUIPMENT_WORD 0x0010
8 8
 #define BDA_FBMS 0x0013
9
+#define BDA_REBOOT 0x0072
10
+#define BDA_REBOOT_WARM 0x1234
9 11
 #define BDA_NUM_DRIVES 0x0075
10 12
 
11 13
 #endif /* BIOS_H */

+ 8
- 1
src/arch/i386/interface/pcbios/bios_reboot.c Parādīt failu

@@ -27,12 +27,19 @@ FILE_LICENCE ( GPL2_OR_LATER );
27 27
 
28 28
 #include <ipxe/reboot.h>
29 29
 #include <realmode.h>
30
+#include <bios.h>
30 31
 
31 32
 /**
32 33
  * Reboot system
33 34
  *
35
+ * @v warm		Perform a warm reboot
34 36
  */
35
-static void bios_reboot ( void ) {
37
+static void bios_reboot ( int warm ) {
38
+	uint16_t flag;
39
+
40
+	/* Configure BIOS for cold/warm reboot */
41
+	flag = ( warm ? BDA_REBOOT_WARM : 0 );
42
+	put_real ( flag, BDA_SEG, BDA_REBOOT );
36 43
 
37 44
 	/* Jump to system reset vector */
38 45
 	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : );

+ 2
- 1
src/core/null_reboot.c Parādīt failu

@@ -32,8 +32,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 32
 /**
33 33
  * Reboot system
34 34
  *
35
+ * @v warm		Perform a warm reboot
35 36
  */
36
-static void null_reboot ( void ) {
37
+static void null_reboot ( int warm __unused ) {
37 38
 
38 39
 	printf ( "Cannot reboot; not implemented\n" );
39 40
 	while ( 1 ) {}

+ 11
- 4
src/hci/commands/reboot_cmd.c Parādīt failu

@@ -17,6 +17,7 @@
17 17
  * 02110-1301, USA.
18 18
  */
19 19
 
20
+#include <getopt.h>
20 21
 #include <ipxe/command.h>
21 22
 #include <ipxe/parseopt.h>
22 23
 #include <ipxe/reboot.h>
@@ -30,14 +31,20 @@ FILE_LICENCE ( GPL2_OR_LATER );
30 31
  */
31 32
 
32 33
 /** "reboot" options */
33
-struct reboot_options {};
34
+struct reboot_options {
35
+	/** Perform a warm reboot */
36
+	int warm;
37
+};
34 38
 
35 39
 /** "reboot" option list */
36
-static struct option_descriptor reboot_opts[] = {};
40
+static struct option_descriptor reboot_opts[] = {
41
+	OPTION_DESC ( "warm", 'w', no_argument,
42
+		      struct reboot_options, warm, parse_flag ),
43
+};
37 44
 
38 45
 /** "reboot" command descriptor */
39 46
 static struct command_descriptor reboot_cmd =
40
-	COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "" );
47
+	COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "[--warm]" );
41 48
 
42 49
 /**
43 50
  * The "reboot" command
@@ -55,7 +62,7 @@ static int reboot_exec ( int argc, char **argv ) {
55 62
 		return rc;
56 63
 
57 64
 	/* Reboot system */
58
-	reboot();
65
+	reboot ( opts.warm );
59 66
 
60 67
 	return 0;
61 68
 }

+ 2
- 1
src/include/ipxe/reboot.h Parādīt failu

@@ -51,7 +51,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
51 51
 /**
52 52
  * Reboot system
53 53
  *
54
+ * @v warm		Perform a warm reboot
54 55
  */
55
-void reboot ( void );
56
+void reboot ( int warm );
56 57
 
57 58
 #endif /* _IPXE_REBOOT_H */

+ 3
- 2
src/interface/efi/efi_reboot.c Parādīt failu

@@ -32,12 +32,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 32
 /**
33 33
  * Reboot system
34 34
  *
35
+ * @v warm		Perform a warm reboot
35 36
  */
36
-static void efi_reboot ( void ) {
37
+static void efi_reboot ( int warm ) {
37 38
 	EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
38 39
 
39 40
 	/* Use runtime services to reset system */
40
-	rs->ResetSystem ( EfiResetCold, 0, 0, NULL );
41
+	rs->ResetSystem ( ( warm ? EfiResetWarm : EfiResetCold ), 0, 0, NULL );
41 42
 }
42 43
 
43 44
 PROVIDE_REBOOT ( efi, reboot, efi_reboot );

Notiek ielāde…
Atcelt
Saglabāt