Browse Source

[cmdline] Add "reboot" command

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
a4bb95599c
3 changed files with 70 additions and 0 deletions
  1. 66
    0
      src/arch/i386/hci/commands/reboot_cmd.c
  2. 3
    0
      src/config/config.c
  3. 1
    0
      src/config/general.h

+ 66
- 0
src/arch/i386/hci/commands/reboot_cmd.c View File

@@ -0,0 +1,66 @@
1
+/*
2
+ * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <realmode.h>
20
+#include <ipxe/command.h>
21
+#include <ipxe/parseopt.h>
22
+
23
+FILE_LICENCE ( GPL2_OR_LATER );
24
+
25
+/** @file
26
+ *
27
+ * Reboot command
28
+ *
29
+ */
30
+
31
+/** "reboot" options */
32
+struct reboot_options {};
33
+
34
+/** "reboot" option list */
35
+static struct option_descriptor reboot_opts[] = {};
36
+
37
+/** "reboot" command descriptor */
38
+static struct command_descriptor reboot_cmd =
39
+	COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "", "" );
40
+
41
+/**
42
+ * The "reboot" command
43
+ *
44
+ * @v argc		Argument count
45
+ * @v argv		Argument list
46
+ * @ret rc		Return status code
47
+ */
48
+static int reboot_exec ( int argc, char **argv ) {
49
+	struct reboot_options opts;
50
+	int rc;
51
+
52
+	/* Parse options */
53
+	if ( ( rc = parse_options ( argc, argv, &reboot_cmd, &opts ) ) != 0 )
54
+		return rc;
55
+
56
+	/* Reboot system */
57
+	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : );
58
+
59
+	return 0;
60
+}
61
+
62
+/** "reboot" command */
63
+struct command reboot_command __command = {
64
+	.name = "reboot",
65
+	.exec = reboot_exec,
66
+};

+ 3
- 0
src/config/config.c View File

@@ -237,6 +237,9 @@ REQUIRE_OBJECT ( lotest_cmd );
237 237
 #ifdef VLAN_CMD
238 238
 REQUIRE_OBJECT ( vlan_cmd );
239 239
 #endif
240
+#ifdef REBOOT_CMD
241
+REQUIRE_OBJECT ( reboot_cmd );
242
+#endif
240 243
 
241 244
 /*
242 245
  * Drag in miscellaneous objects

+ 1
- 0
src/config/general.h View File

@@ -125,6 +125,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
125 125
 #undef	LOTEST_CMD		/* Loopback testing commands */
126 126
 #undef	VLAN_CMD		/* VLAN commands */
127 127
 #undef	PXE_CMD			/* PXE commands */
128
+#undef	REBOOT_CMD		/* Reboot command */
128 129
 
129 130
 /*
130 131
  * Error message tables to include

Loading…
Cancel
Save