aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-11-20 17:20:03 +0000
committerMichael Brown <mcb30@ipxe.org>2010-11-20 17:20:03 +0000
commit44482851427e26ba6f77485064ef7217b632daac (patch)
tree09103b15661deba88b6d926867404c0487d0122f
parent6fd09b541fbc426057661c7e0da4f39000b6803e (diff)
downloadipxe-44482851427e26ba6f77485064ef7217b632daac.tar.gz
[autoboot] Add "netboot" command
Originally-implemented-by: michael-dev@fami-braun.de Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/hci/commands/autoboot_cmd.c39
-rw-r--r--src/include/usr/autoboot.h1
-rw-r--r--src/usr/autoboot.c2
3 files changed, 38 insertions, 4 deletions
diff --git a/src/hci/commands/autoboot_cmd.c b/src/hci/commands/autoboot_cmd.c
index 51ba6f1fd..17bd6bcfc 100644
--- a/src/hci/commands/autoboot_cmd.c
+++ b/src/hci/commands/autoboot_cmd.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <ipxe/command.h>
+#include <ipxe/netdevice.h>
#include <usr/autoboot.h>
FILE_LICENCE ( GPL2_OR_LATER );
@@ -21,7 +22,39 @@ static int autoboot_exec ( int argc, char **argv ) {
return 1;
}
-struct command autoboot_command __command = {
- .name = "autoboot",
- .exec = autoboot_exec,
+static int netboot_exec ( int argc, char **argv ) {
+ const char *netdev_name;
+ struct net_device *netdev;
+
+ if ( argc != 2 ) {
+ printf ( "Usage:\n"
+ " %s <interface>\n"
+ "\n"
+ "Attempts to boot the system from <interface>\n",
+ argv[0] );
+ return 1;
+ }
+ netdev_name = argv[1];
+
+ netdev = find_netdev ( netdev_name );
+ if ( ! netdev ) {
+ printf ( "%s: no such interface\n", netdev_name );
+ return 1;
+ }
+
+ netboot ( netdev );
+
+ /* Can never return success by definition */
+ return 1;
+}
+
+struct command autoboot_commands[] __command = {
+ {
+ .name = "autoboot",
+ .exec = autoboot_exec,
+ },
+ {
+ .name = "netboot",
+ .exec = netboot_exec,
+ },
};
diff --git a/src/include/usr/autoboot.h b/src/include/usr/autoboot.h
index 81b686b54..46e3b4816 100644
--- a/src/include/usr/autoboot.h
+++ b/src/include/usr/autoboot.h
@@ -14,6 +14,7 @@ struct net_device;
extern int shutdown_exit_flags;
+extern int netboot ( struct net_device *netdev );
extern void autoboot ( void );
extern int boot_next_server_and_filename ( struct in_addr next_server,
const char *filename );
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index 4e8db60e2..d87e36270 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -220,7 +220,7 @@ int boot_root_path ( const char *root_path ) {
* @v netdev Network device
* @ret rc Return status code
*/
-static int netboot ( struct net_device *netdev ) {
+int netboot ( struct net_device *netdev ) {
struct setting vendor_class_id_setting
= { .tag = DHCP_VENDOR_CLASS_ID };
struct setting pxe_discovery_control_setting