summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/gpxe/src/hci/commands
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/syslinux-4.02/gpxe/src/hci/commands')
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/autoboot_cmd.c27
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/config_cmd.c39
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/dhcp_cmd.c190
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/digest_cmd.c120
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/gdbstub_cmd.c105
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/ifmgmt_cmd.c180
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/image_cmd.c608
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/iwmgmt_cmd.c69
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/login_cmd.c29
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/nvo_cmd.c79
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/route_cmd.c87
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/sanboot_cmd.c70
-rw-r--r--contrib/syslinux-4.02/gpxe/src/hci/commands/time_cmd.c84
13 files changed, 1687 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/autoboot_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/autoboot_cmd.c
new file mode 100644
index 0000000..95b172d
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/autoboot_cmd.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <gpxe/command.h>
+#include <usr/autoboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int autoboot_exec ( int argc, char **argv ) {
+
+ if ( argc != 1 ) {
+ printf ( "Usage:\n"
+ " %s\n"
+ "\n"
+ "Attempts to boot the system\n",
+ argv[0] );
+ return 1;
+ }
+
+ autoboot();
+
+ /* Can never return success by definition */
+ return 1;
+}
+
+struct command autoboot_command __command = {
+ .name = "autoboot",
+ .exec = autoboot_exec,
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/config_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/config_cmd.c
new file mode 100644
index 0000000..a9e1f16
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/config_cmd.c
@@ -0,0 +1,39 @@
+#include <string.h>
+#include <stdio.h>
+#include <gpxe/command.h>
+#include <gpxe/settings.h>
+#include <gpxe/settings_ui.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int config_exec ( int argc, char **argv ) {
+ char *settings_name;
+ struct settings *settings;
+ int rc;
+
+ if ( argc > 2 ) {
+ printf ( "Usage: %s [scope]\n"
+ "Opens the option configuration console\n", argv[0] );
+ return 1;
+ }
+
+ settings_name = ( ( argc == 2 ) ? argv[1] : "" );
+ settings = find_settings ( settings_name );
+ if ( ! settings ) {
+ printf ( "No such scope \"%s\"\n", settings_name );
+ return 1;
+ }
+
+ if ( ( rc = settings_ui ( settings ) ) != 0 ) {
+ printf ( "Could not save settings: %s\n",
+ strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+struct command config_command __command = {
+ .name = "config",
+ .exec = config_exec,
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/dhcp_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/dhcp_cmd.c
new file mode 100644
index 0000000..96aac8d
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/dhcp_cmd.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stddef.h>
+#include <string.h>
+#include <assert.h>
+#include <getopt.h>
+#include <gpxe/netdevice.h>
+#include <gpxe/in.h>
+#include <gpxe/command.h>
+#include <usr/dhcpmgmt.h>
+
+/** @file
+ *
+ * DHCP management commands
+ *
+ */
+
+/**
+ * "dhcp" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void dhcp_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <interface>\n"
+ "\n"
+ "Configure a network interface using DHCP\n",
+ argv[0] );
+}
+
+/**
+ * The "dhcp" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int dhcp_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ const char *netdev_txt;
+ struct net_device *netdev;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ dhcp_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need exactly one interface name remaining after the options */
+ if ( optind != ( argc - 1 ) ) {
+ dhcp_syntax ( argv );
+ return 1;
+ }
+ netdev_txt = argv[optind];
+
+ /* Parse arguments */
+ netdev = find_netdev ( netdev_txt );
+ if ( ! netdev ) {
+ printf ( "No such interface: %s\n", netdev_txt );
+ return 1;
+ }
+
+ /* Perform DHCP */
+ if ( ( rc = dhcp ( netdev ) ) != 0 ) {
+ printf ( "Could not configure %s: %s\n", netdev->name,
+ strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * "pxebs" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void pxebs_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <interface> <server_type>\n"
+ "\n"
+ "Perform PXE Boot Server discovery\n",
+ argv[0] );
+}
+
+/**
+ * The "pxebs" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int pxebs_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ const char *netdev_txt;
+ const char *pxe_type_txt;
+ struct net_device *netdev;
+ unsigned int pxe_type;
+ char *end;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ pxebs_syntax ( argv );
+ return 1;
+ }
+ }
+ if ( optind != ( argc - 2 ) ) {
+ pxebs_syntax ( argv );
+ return 1;
+ }
+ netdev_txt = argv[optind];
+ pxe_type_txt = argv[ optind + 1 ];
+
+ /* Parse arguments */
+ netdev = find_netdev ( netdev_txt );
+ if ( ! netdev ) {
+ printf ( "No such interface: %s\n", netdev_txt );
+ return 1;
+ }
+ pxe_type = strtoul ( pxe_type_txt, &end, 0 );
+ if ( *end ) {
+ printf ( "Bad server type: %s\n", pxe_type_txt );
+ return 1;
+ }
+
+ /* Perform Boot Server Discovery */
+ if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
+ printf ( "Could not discover boot server on %s: %s\n",
+ netdev->name, strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+/** DHCP management commands */
+struct command dhcp_commands[] __command = {
+ {
+ .name = "dhcp",
+ .exec = dhcp_exec,
+ },
+ {
+ .name = "pxebs",
+ .exec = pxebs_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/digest_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/digest_cmd.c
new file mode 100644
index 0000000..bc6e551
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/digest_cmd.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2009 Daniel Verkamp <daniel@drv.nu>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <gpxe/command.h>
+#include <gpxe/image.h>
+#include <gpxe/crypto.h>
+
+#include <gpxe/md5.h>
+#include <gpxe/sha1.h>
+
+/**
+ * "digest" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void digest_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <image name>\n"
+ "\n"
+ "Calculate the %s of an image\n",
+ argv[0], argv[0] );
+}
+
+/**
+ * The "digest" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v digest Digest algorithm
+ * @ret rc Exit code
+ */
+static int digest_exec ( int argc, char **argv,
+ struct digest_algorithm *digest ) {
+ const char *image_name;
+ struct image *image;
+ uint8_t digest_ctx[digest->ctxsize];
+ uint8_t digest_out[digest->digestsize];
+ uint8_t buf[128];
+ size_t offset;
+ size_t len;
+ size_t frag_len;
+ int i;
+ unsigned j;
+
+ if ( argc < 2 ||
+ !strcmp ( argv[1], "--help" ) ||
+ !strcmp ( argv[1], "-h" ) ) {
+ digest_syntax ( argv );
+ return 1;
+ }
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ image_name = argv[i];
+
+ /* find image */
+ image = find_image ( image_name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", image_name );
+ continue;
+ }
+ offset = 0;
+ len = image->len;
+
+ /* calculate digest */
+ digest_init ( digest, digest_ctx );
+ while ( len ) {
+ frag_len = len;
+ if ( frag_len > sizeof ( buf ) )
+ frag_len = sizeof ( buf );
+ copy_from_user ( buf, image->data, offset, frag_len );
+ digest_update ( digest, digest_ctx, buf, frag_len );
+ len -= frag_len;
+ offset += frag_len;
+ }
+ digest_final ( digest, digest_ctx, digest_out );
+
+ for ( j = 0 ; j < sizeof ( digest_out ) ; j++ )
+ printf ( "%02x", digest_out[j] );
+
+ printf ( " %s\n", image->name );
+ }
+
+ return 0;
+}
+
+static int md5sum_exec ( int argc, char **argv ) {
+ return digest_exec ( argc, argv, &md5_algorithm );
+}
+
+static int sha1sum_exec ( int argc, char **argv ) {
+ return digest_exec ( argc, argv, &sha1_algorithm );
+}
+
+struct command md5sum_command __command = {
+ .name = "md5sum",
+ .exec = md5sum_exec,
+};
+
+struct command sha1sum_command __command = {
+ .name = "sha1sum",
+ .exec = sha1sum_exec,
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/gdbstub_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/gdbstub_cmd.c
new file mode 100644
index 0000000..7416752
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/gdbstub_cmd.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <gpxe/command.h>
+#include <gpxe/gdbstub.h>
+
+/** @file
+ *
+ * GDB stub command
+ *
+ */
+
+/**
+ * "gdbstub" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void gdbstub_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <transport> [<options>...]\n"
+ "\n"
+ "Start remote debugging using one of the following transports:\n"
+ " serial use serial port (if compiled in)\n"
+ " udp <interface> use UDP over network interface (if compiled in)\n",
+ argv[0] );
+}
+
+/**
+ * The "gdbstub" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int gdbstub_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ const char *trans_name;
+ struct gdb_transport *trans;
+ int c;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ gdbstub_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* At least one argument */
+ if ( optind == argc ) {
+ gdbstub_syntax ( argv );
+ return 1;
+ }
+
+ trans_name = argv[optind++];
+
+ /* Initialise transport */
+ trans = find_gdb_transport ( trans_name );
+ if ( !trans ) {
+ printf ( "%s: no such transport (is it compiled in?)\n", trans_name );
+ return 1;
+ }
+
+ if ( trans->init ) {
+ if ( trans->init ( argc - optind, &argv[optind] ) != 0 ) {
+ return 1;
+ }
+ }
+
+ /* Enter GDB stub */
+ gdbstub_start ( trans );
+ return 0;
+}
+
+/** GDB stub commands */
+struct command gdbstub_commands[] __command = {
+ {
+ .name = "gdbstub",
+ .exec = gdbstub_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/ifmgmt_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/ifmgmt_cmd.c
new file mode 100644
index 0000000..ad069f1
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/ifmgmt_cmd.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <gpxe/netdevice.h>
+#include <gpxe/command.h>
+#include <usr/ifmgmt.h>
+#include <hci/ifmgmt_cmd.h>
+
+/** @file
+ *
+ * Network interface management commands
+ *
+ */
+
+/** Options shared by all if<xxx> commands */
+static struct option ifcommon_longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+};
+
+/**
+ * Print syntax of if<xxx> command
+ *
+ * @v argv Command arguments
+ * @v verb Verb describing the action of the command
+ */
+static void ifcommon_syntax ( char **argv, const char *verb ) {
+ printf ( "Usage:\n"
+ " %s [<interface>] [<interface>...]\n"
+ "\n"
+ "%s the specified network interfaces\n",
+ argv[0], verb );
+}
+
+/**
+ * Execute if<xxx> command over all network devices
+ *
+ * @v payload Command to execute
+ * @ret rc Exit code
+ */
+static int ifcommon_do_all ( int ( * payload ) ( struct net_device * ) ) {
+ struct net_device *netdev;
+ int rc = 0;
+
+ /* Execute payload for each network device */
+ for_each_netdev ( netdev ) {
+ if ( payload ( netdev ) != 0 )
+ rc = 1;
+ }
+ return rc;
+}
+
+/**
+ * Execute if<xxx> command over list of network devices
+ *
+ * @v payload Command to execute
+ * @ret rc Exit code
+ */
+static int ifcommon_do_list ( int ( * payload ) ( struct net_device * ),
+ char **list, unsigned int count ) {
+ const char *netdev_name;
+ struct net_device *netdev;
+ int rc = 0;
+
+ while ( count-- ) {
+ netdev_name = *(list++);
+ netdev = find_netdev ( netdev_name );
+ if ( ! netdev ) {
+ printf ( "%s: no such interface\n", netdev_name );
+ rc = 1;
+ continue;
+ }
+ if ( payload ( netdev ) != 0 )
+ rc = 1;
+ }
+ return rc;
+}
+
+/**
+ * Execute if<xxx> command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v payload Command to execute
+ * @v verb Verb describing the action of the command
+ * @ret rc Exit code
+ */
+int ifcommon_exec ( int argc, char **argv,
+ int ( * payload ) ( struct net_device * ),
+ const char *verb ) {
+ int c;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", ifcommon_longopts,
+ NULL ) ) >= 0 ) {
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ ifcommon_syntax ( argv, verb );
+ return 1;
+ }
+ }
+
+ if ( optind == argc ) {
+ return ifcommon_do_all ( payload );
+ } else {
+ return ifcommon_do_list ( payload, &argv[optind],
+ ( argc - optind ) );
+ }
+}
+
+/* "ifopen" command */
+
+static int ifopen_payload ( struct net_device *netdev ) {
+ return ifopen ( netdev );
+}
+
+static int ifopen_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, ifopen_payload, "Open" );
+}
+
+/* "ifclose" command */
+
+static int ifclose_payload ( struct net_device *netdev ) {
+ ifclose ( netdev );
+ return 0;
+}
+
+static int ifclose_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, ifclose_payload, "Close" );
+}
+
+/* "ifstat" command */
+
+static int ifstat_payload ( struct net_device *netdev ) {
+ ifstat ( netdev );
+ return 0;
+}
+
+static int ifstat_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv,
+ ifstat_payload, "Display status of" );
+}
+
+/** Interface management commands */
+struct command ifmgmt_commands[] __command = {
+ {
+ .name = "ifopen",
+ .exec = ifopen_exec,
+ },
+ {
+ .name = "ifclose",
+ .exec = ifclose_exec,
+ },
+ {
+ .name = "ifstat",
+ .exec = ifstat_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/image_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/image_cmd.c
new file mode 100644
index 0000000..33994b5
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/image_cmd.c
@@ -0,0 +1,608 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <libgen.h>
+#include <getopt.h>
+#include <gpxe/image.h>
+#include <gpxe/command.h>
+#include <usr/imgmgmt.h>
+
+/** @file
+ *
+ * Image management commands
+ *
+ */
+
+enum image_action {
+ IMG_FETCH = 0,
+ IMG_LOAD,
+ IMG_EXEC,
+};
+
+/**
+ * Fill in image command line
+ *
+ * @v image Image
+ * @v nargs Argument count
+ * @v args Argument list
+ * @ret rc Return status code
+ */
+static int imgfill_cmdline ( struct image *image, unsigned int nargs,
+ char **args ) {
+ size_t len;
+ unsigned int i;
+
+ /* Determine total length of command line */
+ len = 1; /* NUL */
+ for ( i = 0 ; i < nargs ; i++ )
+ len += ( 1 /* possible space */ + strlen ( args[i] ) );
+
+ {
+ char buf[len];
+ char *ptr = buf;
+
+ /* Assemble command line */
+ buf[0] = '\0';
+ for ( i = 0 ; i < nargs ; i++ ) {
+ ptr += sprintf ( ptr, "%s%s", ( i ? " " : "" ),
+ args[i] );
+ }
+ assert ( ptr < ( buf + len ) );
+
+ return image_set_cmdline ( image, buf );
+ }
+}
+
+/**
+ * "imgfetch"/"module"/"kernel" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgfetch_core_syntax ( char **argv, enum image_action action ) {
+ static const char *actions[] = {
+ [IMG_FETCH] = "Fetch",
+ [IMG_LOAD] = "Fetch and load",
+ [IMG_EXEC] = "Fetch and execute",
+ };
+
+ printf ( "Usage:\n"
+ " %s [-n|--name <name>] filename [arguments...]\n"
+ "\n"
+ "%s executable/loadable image\n",
+ argv[0], actions[action] );
+}
+
+/**
+ * The "imgfetch"/"module"/"kernel" command body
+ *
+ * @v image_type Image type to assign (or NULL)
+ * @v load Image will be automatically loaded after fetching
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgfetch_core_exec ( struct image_type *image_type,
+ enum image_action action,
+ int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { "name", required_argument, NULL, 'n' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ const char *name = NULL;
+ char *filename;
+ int ( * image_register ) ( struct image *image );
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "hn:",
+ longopts, NULL ) ) >= 0 ) {
+ switch ( c ) {
+ case 'n':
+ /* Set image name */
+ name = optarg;
+ break;
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgfetch_core_syntax ( argv, action );
+ return -EINVAL;
+ }
+ }
+
+ /* Need at least a filename remaining after the options */
+ if ( optind == argc ) {
+ imgfetch_core_syntax ( argv, action );
+ return -EINVAL;
+ }
+ filename = argv[optind++];
+ if ( ! name )
+ name = basename ( filename );
+
+ /* Allocate image */
+ image = alloc_image();
+ if ( ! image ) {
+ printf ( "%s\n", strerror ( -ENOMEM ) );
+ return -ENOMEM;
+ }
+
+ /* Fill in image name */
+ if ( name ) {
+ if ( ( rc = image_set_name ( image, name ) ) != 0 )
+ return rc;
+ }
+
+ /* Set image type (if specified) */
+ image->type = image_type;
+
+ /* Fill in command line */
+ if ( ( rc = imgfill_cmdline ( image, ( argc - optind ),
+ &argv[optind] ) ) != 0 )
+ return rc;
+
+ /* Fetch the image */
+ switch ( action ) {
+ case IMG_FETCH:
+ image_register = register_image;
+ break;
+ case IMG_LOAD:
+ image_register = register_and_autoload_image;
+ break;
+ case IMG_EXEC:
+ image_register = register_and_autoexec_image;
+ break;
+ default:
+ assert ( 0 );
+ return -EINVAL;
+ }
+ if ( ( rc = imgfetch ( image, filename, image_register ) ) != 0 ) {
+ printf ( "Could not fetch %s: %s\n",
+ filename, strerror ( rc ) );
+ image_put ( image );
+ return rc;
+ }
+
+ image_put ( image );
+ return 0;
+}
+
+/**
+ * The "imgfetch"/"module" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgfetch_exec ( int argc, char **argv ) {
+ int rc;
+
+ if ( ( rc = imgfetch_core_exec ( NULL, IMG_FETCH,
+ argc, argv ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
+ * The "kernel" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int kernel_exec ( int argc, char **argv ) {
+ int rc;
+
+ if ( ( rc = imgfetch_core_exec ( NULL, IMG_LOAD, argc, argv ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
+ * The "chain" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int chain_exec ( int argc, char **argv) {
+ int rc;
+
+ if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
+ * "imgload" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgload_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <image name>\n"
+ "\n"
+ "Load executable/loadable image\n",
+ argv[0] );
+}
+
+/**
+ * The "imgload" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgload_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ const char *name;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgload_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need exactly one image name remaining after the options */
+ if ( optind != ( argc - 1 ) ) {
+ imgload_syntax ( argv );
+ return 1;
+ }
+ name = argv[optind];
+
+ /* Load all specified images */
+ image = find_image ( name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", name );
+ return 1;
+ }
+ if ( ( rc = imgload ( image ) ) != 0 ) {
+ printf ( "Could not load %s: %s\n", name, strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/**
+ * "imgargs" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgargs_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <image name> [<arguments>...]\n"
+ "\n"
+ "Set arguments for executable/loadable image\n",
+ argv[0] );
+}
+
+/**
+ * The "imgargs" command body
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgargs_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ const char *name;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgargs_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need at least an image name remaining after the options */
+ if ( optind == argc ) {
+ imgargs_syntax ( argv );
+ return 1;
+ }
+ name = argv[optind++];
+
+ /* Fill in command line */
+ image = find_image ( name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", name );
+ return 1;
+ }
+ if ( ( rc = imgfill_cmdline ( image, ( argc - optind ),
+ &argv[optind] ) ) != 0 )
+ return rc;
+
+
+ return 0;
+}
+
+/**
+ * "imgexec" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgexec_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <image name>\n"
+ "\n"
+ "Execute executable/loadable image\n",
+ argv[0] );
+}
+
+/**
+ * The "imgexec" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgexec_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ const char *name = NULL;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgexec_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need no more than one image name */
+ if ( optind != argc )
+ name = argv[optind++];
+ if ( optind != argc ) {
+ imgexec_syntax ( argv );
+ return 1;
+ }
+
+ /* Execute specified image */
+ if ( name ) {
+ image = find_image ( name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", name );
+ return 1;
+ }
+ } else {
+ image = imgautoselect();
+ if ( ! image ) {
+ printf ( "No (unique) loaded image\n" );
+ return 1;
+ }
+ }
+
+ if ( ( rc = imgexec ( image ) ) != 0 ) {
+ printf ( "Could not execute %s: %s\n",
+ image->name, strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * "imgstat" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgstat_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s\n"
+ "\n"
+ "List executable/loadable images\n",
+ argv[0] );
+}
+
+/**
+ * The "imgstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgstat_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ int c;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgstat_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* No arguments */
+ if ( optind != argc ) {
+ imgstat_syntax ( argv );
+ return 1;
+ }
+
+ /* Show status of all images */
+ for_each_image ( image ) {
+ imgstat ( image );
+ }
+ return 0;
+}
+
+/**
+ * "imgstat" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void imgfree_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s [<image name>]\n"
+ "\n"
+ "Free one or all executable/loadable images\n",
+ argv[0] );
+}
+
+/**
+ * The "imgfree" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int imgfree_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ struct image *image;
+ struct image *tmp;
+ const char *name = NULL;
+ int c;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ imgfree_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need no more than one image name */
+ if ( optind != argc )
+ name = argv[optind++];
+ if ( optind != argc ) {
+ imgfree_syntax ( argv );
+ return 1;
+ }
+
+ if ( name ) {
+ /* Free specified image (may leak) */
+ image = find_image ( name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", name );
+ return 1;
+ }
+ imgfree ( image );
+ } else {
+ /* Free all images */
+ list_for_each_entry_safe ( image, tmp, &images, list ) {
+ imgfree ( image );
+ }
+ }
+ return 0;
+}
+
+/** Image management commands */
+struct command image_commands[] __command = {
+ {
+ .name = "imgfetch",
+ .exec = imgfetch_exec,
+ },
+ {
+ .name = "module",
+ .exec = imgfetch_exec, /* synonym for "imgfetch" */
+ },
+ {
+ .name = "initrd",
+ .exec = imgfetch_exec, /* synonym for "imgfetch" */
+ },
+ {
+ .name = "kernel",
+ .exec = kernel_exec,
+ },
+ {
+ .name = "chain",
+ .exec = chain_exec,
+ },
+ {
+ .name = "imgload",
+ .exec = imgload_exec,
+ },
+ {
+ .name = "imgargs",
+ .exec = imgargs_exec,
+ },
+ {
+ .name = "imgexec",
+ .exec = imgexec_exec,
+ },
+ {
+ .name = "boot", /* synonym for "imgexec" */
+ .exec = imgexec_exec,
+ },
+ {
+ .name = "imgstat",
+ .exec = imgstat_exec,
+ },
+ {
+ .name = "imgfree",
+ .exec = imgfree_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/iwmgmt_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/iwmgmt_cmd.c
new file mode 100644
index 0000000..006c9f1
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/iwmgmt_cmd.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <gpxe/netdevice.h>
+#include <gpxe/net80211.h>
+#include <gpxe/command.h>
+#include <usr/iwmgmt.h>
+#include <hci/ifmgmt_cmd.h>
+
+/* "iwstat" command */
+
+static int iwstat_payload ( struct net_device *netdev ) {
+ struct net80211_device *dev = net80211_get ( netdev );
+
+ if ( dev )
+ iwstat ( dev );
+
+ return 0;
+}
+
+static int iwstat_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv,
+ iwstat_payload, "Display wireless status of" );
+}
+
+/* "iwlist" command */
+
+static int iwlist_payload ( struct net_device *netdev ) {
+ struct net80211_device *dev = net80211_get ( netdev );
+
+ if ( dev )
+ return iwlist ( dev );
+
+ return 0;
+}
+
+static int iwlist_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, iwlist_payload,
+ "List wireless networks available via" );
+}
+
+/** Wireless interface management commands */
+struct command iwmgmt_commands[] __command = {
+ {
+ .name = "iwstat",
+ .exec = iwstat_exec,
+ },
+ {
+ .name = "iwlist",
+ .exec = iwlist_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/login_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/login_cmd.c
new file mode 100644
index 0000000..0da2497
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/login_cmd.c
@@ -0,0 +1,29 @@
+#include <string.h>
+#include <stdio.h>
+#include <gpxe/command.h>
+#include <gpxe/login_ui.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int login_exec ( int argc, char **argv ) {
+ int rc;
+
+ if ( argc > 1 ) {
+ printf ( "Usage: %s\n"
+ "Prompt for login credentials\n", argv[0] );
+ return 1;
+ }
+
+ if ( ( rc = login_ui() ) != 0 ) {
+ printf ( "Could not set credentials: %s\n",
+ strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+struct command login_command __command = {
+ .name = "login",
+ .exec = login_exec,
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/nvo_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/nvo_cmd.c
new file mode 100644
index 0000000..5eb2f06
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/nvo_cmd.c
@@ -0,0 +1,79 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <gpxe/settings.h>
+#include <gpxe/command.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int show_exec ( int argc, char **argv ) {
+ char buf[256];
+ int rc;
+
+ if ( argc != 2 ) {
+ printf ( "Syntax: %s <identifier>\n", argv[0] );
+ return 1;
+ }
+
+ if ( ( rc = fetchf_named_setting ( argv[1], buf,
+ sizeof ( buf ) ) ) < 0 ){
+ printf ( "Could not find \"%s\": %s\n",
+ argv[1], strerror ( rc ) );
+ return 1;
+ }
+
+ printf ( "%s = %s\n", argv[1], buf );
+ return 0;
+}
+
+static int set_exec ( int argc, char **argv ) {
+ int rc;
+
+ if ( argc != 3 ) {
+ printf ( "Syntax: %s <identifier> <value>\n", argv[0] );
+ return 1;
+ }
+
+ if ( ( rc = storef_named_setting ( argv[1], argv[2] ) ) != 0 ) {
+ printf ( "Could not set \"%s\"=\"%s\": %s\n",
+ argv[1], argv[2], strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+static int clear_exec ( int argc, char **argv ) {
+ int rc;
+
+ if ( argc != 2 ) {
+ printf ( "Syntax: %s <identifier>\n", argv[0] );
+ return 1;
+ }
+
+ if ( ( rc = delete_named_setting ( argv[1] ) ) != 0 ) {
+ printf ( "Could not clear \"%s\": %s\n",
+ argv[1], strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+struct command nvo_commands[] __command = {
+ {
+ .name = "show",
+ .exec = show_exec,
+ },
+ {
+ .name = "set",
+ .exec = set_exec,
+ },
+ {
+ .name = "clear",
+ .exec = clear_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/route_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/route_cmd.c
new file mode 100644
index 0000000..4372e34
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/route_cmd.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <gpxe/command.h>
+#include <usr/route.h>
+
+/** @file
+ *
+ * Routing table management commands
+ *
+ */
+
+/**
+ * "route" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void route_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s\n"
+ "\n"
+ "Displays the routing table\n",
+ argv[0] );
+}
+
+/**
+ * The "route" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int route_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ int c;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ route_syntax ( argv );
+ return 1;
+ }
+ }
+
+ if ( optind != argc ) {
+ route_syntax ( argv );
+ return 1;
+ }
+
+ route();
+ return 0;
+}
+
+/** Routing table management commands */
+struct command route_commands[] __command = {
+ {
+ .name = "route",
+ .exec = route_exec,
+ },
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/sanboot_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/sanboot_cmd.c
new file mode 100644
index 0000000..783b747
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/sanboot_cmd.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <string.h>
+#include <getopt.h>
+#include <gpxe/command.h>
+#include <usr/autoboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/**
+ * "sanboot" command syntax message
+ *
+ * @v argv Argument list
+ */
+static void sanboot_syntax ( char **argv ) {
+ printf ( "Usage:\n"
+ " %s <root-path>\n"
+ "\n"
+ "Boot from SAN target\n",
+ argv[0] );
+}
+
+/**
+ * The "sanboot" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Exit code
+ */
+static int sanboot_exec ( int argc, char **argv ) {
+ static struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+ const char *root_path = NULL;
+ int c;
+ int rc;
+
+ /* Parse options */
+ while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
+ switch ( c ) {
+ case 'h':
+ /* Display help text */
+ default:
+ /* Unrecognised/invalid option */
+ sanboot_syntax ( argv );
+ return 1;
+ }
+ }
+
+ /* Need exactly one image name remaining after the options */
+ if ( optind != ( argc - 1 ) ) {
+ sanboot_syntax ( argv );
+ return 1;
+ }
+ root_path = argv[optind];
+
+ /* Boot from root path */
+ if ( ( rc = boot_root_path ( root_path ) ) != 0 ) {
+ printf ( "Could not boot from %s: %s\n",
+ root_path, strerror ( rc ) );
+ return 1;
+ }
+
+ return 0;
+}
+
+struct command sanboot_command __command = {
+ .name = "sanboot",
+ .exec = sanboot_exec,
+};
diff --git a/contrib/syslinux-4.02/gpxe/src/hci/commands/time_cmd.c b/contrib/syslinux-4.02/gpxe/src/hci/commands/time_cmd.c
new file mode 100644
index 0000000..947410e
--- /dev/null
+++ b/contrib/syslinux-4.02/gpxe/src/hci/commands/time_cmd.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Daniel Verkamp <daniel@drv.nu>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * March-19-2009 @ 02:44: Added sleep command.
+ * Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <gpxe/command.h>
+#include <gpxe/nap.h>
+#include <gpxe/timer.h>
+
+static int time_exec ( int argc, char **argv ) {
+ unsigned long start;
+ int rc, secs;
+
+ if ( argc == 1 ||
+ !strcmp ( argv[1], "--help" ) ||
+ !strcmp ( argv[1], "-h" ) )
+ {
+ printf ( "Usage:\n"
+ " %s <command>\n"
+ "\n"
+ "Time a command\n",
+ argv[0] );
+ return 1;
+ }
+
+ start = currticks();
+ rc = execv ( argv[1], argv + 1 );
+ secs = (currticks() - start) / ticks_per_sec();
+
+ printf ( "%s: %ds\n", argv[0], secs );
+
+ return rc;
+}
+
+struct command time_command __command = {
+ .name = "time",
+ .exec = time_exec,
+};
+
+static int sleep_exec ( int argc, char **argv ) {
+ unsigned long start, delay;
+
+ if ( argc == 1 ||
+ !strcmp ( argv[1], "--help" ) ||
+ !strcmp ( argv[1], "-h" ))
+ {
+ printf ( "Usage:\n"
+ " %s <seconds>\n"
+ "\n"
+ "Sleep for <seconds> seconds\n",
+ argv[0] );
+ return 1;
+ }
+ start = currticks();
+ delay = strtoul ( argv[1], NULL, 0 ) * ticks_per_sec();
+ while ( ( currticks() - start ) <= delay )
+ cpu_nap();
+ return 0;
+}
+
+struct command sleep_command __command = {
+ .name = "sleep",
+ .exec = sleep_exec,
+};