Browse Source

[autoboot] Add "netboot" command

Originally-implemented-by: michael-dev@fami-braun.de
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
4448285142
3 changed files with 38 additions and 4 deletions
  1. 36
    3
      src/hci/commands/autoboot_cmd.c
  2. 1
    0
      src/include/usr/autoboot.h
  3. 1
    1
      src/usr/autoboot.c

+ 36
- 3
src/hci/commands/autoboot_cmd.c View File

@@ -1,5 +1,6 @@
1 1
 #include <stdio.h>
2 2
 #include <ipxe/command.h>
3
+#include <ipxe/netdevice.h>
3 4
 #include <usr/autoboot.h>
4 5
 
5 6
 FILE_LICENCE ( GPL2_OR_LATER );
@@ -21,7 +22,39 @@ static int autoboot_exec ( int argc, char **argv ) {
21 22
 	return 1;
22 23
 }
23 24
 
24
-struct command autoboot_command __command = {
25
-	.name = "autoboot",
26
-	.exec = autoboot_exec,
25
+static int netboot_exec ( int argc, char **argv ) {
26
+	const char *netdev_name;
27
+	struct net_device *netdev;
28
+
29
+	if ( argc != 2 ) {
30
+		printf ( "Usage:\n"
31
+			 "  %s <interface>\n"
32
+			 "\n"
33
+			 "Attempts to boot the system from <interface>\n",
34
+			 argv[0] );
35
+		return 1;
36
+	}
37
+	netdev_name = argv[1];
38
+
39
+	netdev = find_netdev ( netdev_name );
40
+	if ( ! netdev ) {
41
+		printf ( "%s: no such interface\n", netdev_name );
42
+		return 1;
43
+	}
44
+
45
+	netboot ( netdev );
46
+
47
+	/* Can never return success by definition */
48
+	return 1;
49
+}
50
+
51
+struct command autoboot_commands[] __command = {
52
+	{
53
+		.name = "autoboot",
54
+		.exec = autoboot_exec,
55
+	},
56
+	{
57
+		.name = "netboot",
58
+		.exec = netboot_exec,
59
+	},
27 60
 };

+ 1
- 0
src/include/usr/autoboot.h View File

@@ -14,6 +14,7 @@ struct net_device;
14 14
 
15 15
 extern int shutdown_exit_flags;
16 16
 
17
+extern int netboot ( struct net_device *netdev );
17 18
 extern void autoboot ( void );
18 19
 extern int boot_next_server_and_filename ( struct in_addr next_server,
19 20
 					   const char *filename );

+ 1
- 1
src/usr/autoboot.c View File

@@ -220,7 +220,7 @@ int boot_root_path ( const char *root_path ) {
220 220
  * @v netdev		Network device
221 221
  * @ret rc		Return status code
222 222
  */
223
-static int netboot ( struct net_device *netdev ) {
223
+int netboot ( struct net_device *netdev ) {
224 224
 	struct setting vendor_class_id_setting
225 225
 		= { .tag = DHCP_VENDOR_CLASS_ID };
226 226
 	struct setting pxe_discovery_control_setting

Loading…
Cancel
Save