Browse Source

[cmdline] Add ability to perform a warm reboot

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
e68a6ca225

+ 2
- 0
src/arch/i386/include/bios.h View File

6
 #define BDA_SEG 0x0040
6
 #define BDA_SEG 0x0040
7
 #define BDA_EQUIPMENT_WORD 0x0010
7
 #define BDA_EQUIPMENT_WORD 0x0010
8
 #define BDA_FBMS 0x0013
8
 #define BDA_FBMS 0x0013
9
+#define BDA_REBOOT 0x0072
10
+#define BDA_REBOOT_WARM 0x1234
9
 #define BDA_NUM_DRIVES 0x0075
11
 #define BDA_NUM_DRIVES 0x0075
10
 
12
 
11
 #endif /* BIOS_H */
13
 #endif /* BIOS_H */

+ 8
- 1
src/arch/i386/interface/pcbios/bios_reboot.c View File

27
 
27
 
28
 #include <ipxe/reboot.h>
28
 #include <ipxe/reboot.h>
29
 #include <realmode.h>
29
 #include <realmode.h>
30
+#include <bios.h>
30
 
31
 
31
 /**
32
 /**
32
  * Reboot system
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
 	/* Jump to system reset vector */
44
 	/* Jump to system reset vector */
38
 	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : );
45
 	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : );

+ 2
- 1
src/core/null_reboot.c View File

32
 /**
32
 /**
33
  * Reboot system
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
 	printf ( "Cannot reboot; not implemented\n" );
39
 	printf ( "Cannot reboot; not implemented\n" );
39
 	while ( 1 ) {}
40
 	while ( 1 ) {}

+ 11
- 4
src/hci/commands/reboot_cmd.c View File

17
  * 02110-1301, USA.
17
  * 02110-1301, USA.
18
  */
18
  */
19
 
19
 
20
+#include <getopt.h>
20
 #include <ipxe/command.h>
21
 #include <ipxe/command.h>
21
 #include <ipxe/parseopt.h>
22
 #include <ipxe/parseopt.h>
22
 #include <ipxe/reboot.h>
23
 #include <ipxe/reboot.h>
30
  */
31
  */
31
 
32
 
32
 /** "reboot" options */
33
 /** "reboot" options */
33
-struct reboot_options {};
34
+struct reboot_options {
35
+	/** Perform a warm reboot */
36
+	int warm;
37
+};
34
 
38
 
35
 /** "reboot" option list */
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
 /** "reboot" command descriptor */
45
 /** "reboot" command descriptor */
39
 static struct command_descriptor reboot_cmd =
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
  * The "reboot" command
50
  * The "reboot" command
55
 		return rc;
62
 		return rc;
56
 
63
 
57
 	/* Reboot system */
64
 	/* Reboot system */
58
-	reboot();
65
+	reboot ( opts.warm );
59
 
66
 
60
 	return 0;
67
 	return 0;
61
 }
68
 }

+ 2
- 1
src/include/ipxe/reboot.h View File

51
 /**
51
 /**
52
  * Reboot system
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
 #endif /* _IPXE_REBOOT_H */
58
 #endif /* _IPXE_REBOOT_H */

+ 3
- 2
src/interface/efi/efi_reboot.c View File

32
 /**
32
 /**
33
  * Reboot system
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
 	EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
38
 	EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
38
 
39
 
39
 	/* Use runtime services to reset system */
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
 PROVIDE_REBOOT ( efi, reboot, efi_reboot );
44
 PROVIDE_REBOOT ( efi, reboot, efi_reboot );

Loading…
Cancel
Save