summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/hci/commands
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/ipxe/src/hci/commands')
-rw-r--r--qemu/roms/ipxe/src/hci/commands/autoboot_cmd.c77
-rw-r--r--qemu/roms/ipxe/src/hci/commands/config_cmd.c81
-rw-r--r--qemu/roms/ipxe/src/hci/commands/console_cmd.c263
-rw-r--r--qemu/roms/ipxe/src/hci/commands/dhcp_cmd.c100
-rw-r--r--qemu/roms/ipxe/src/hci/commands/digest_cmd.c123
-rw-r--r--qemu/roms/ipxe/src/hci/commands/fcmgmt_cmd.c215
-rw-r--r--qemu/roms/ipxe/src/hci/commands/gdbstub_cmd.c111
-rw-r--r--qemu/roms/ipxe/src/hci/commands/ifmgmt_cmd.c261
-rw-r--r--qemu/roms/ipxe/src/hci/commands/image_cmd.c441
-rw-r--r--qemu/roms/ipxe/src/hci/commands/image_trust_cmd.c176
-rw-r--r--qemu/roms/ipxe/src/hci/commands/ipstat_cmd.c70
-rw-r--r--qemu/roms/ipxe/src/hci/commands/iwmgmt_cmd.c125
-rw-r--r--qemu/roms/ipxe/src/hci/commands/login_cmd.c73
-rw-r--r--qemu/roms/ipxe/src/hci/commands/lotest_cmd.c97
-rw-r--r--qemu/roms/ipxe/src/hci/commands/menu_cmd.c290
-rw-r--r--qemu/roms/ipxe/src/hci/commands/neighbour_cmd.c69
-rw-r--r--qemu/roms/ipxe/src/hci/commands/nslookup_cmd.c79
-rw-r--r--qemu/roms/ipxe/src/hci/commands/nvo_cmd.c347
-rw-r--r--qemu/roms/ipxe/src/hci/commands/param_cmd.c163
-rw-r--r--qemu/roms/ipxe/src/hci/commands/pci_cmd.c114
-rw-r--r--qemu/roms/ipxe/src/hci/commands/ping_cmd.c109
-rw-r--r--qemu/roms/ipxe/src/hci/commands/poweroff_cmd.c72
-rw-r--r--qemu/roms/ipxe/src/hci/commands/profstat_cmd.c70
-rw-r--r--qemu/roms/ipxe/src/hci/commands/reboot_cmd.c74
-rw-r--r--qemu/roms/ipxe/src/hci/commands/route_cmd.c70
-rw-r--r--qemu/roms/ipxe/src/hci/commands/sanboot_cmd.c193
-rw-r--r--qemu/roms/ipxe/src/hci/commands/sync_cmd.c79
-rw-r--r--qemu/roms/ipxe/src/hci/commands/time_cmd.c83
-rw-r--r--qemu/roms/ipxe/src/hci/commands/vlan_cmd.c139
29 files changed, 4164 insertions, 0 deletions
diff --git a/qemu/roms/ipxe/src/hci/commands/autoboot_cmd.c b/qemu/roms/ipxe/src/hci/commands/autoboot_cmd.c
new file mode 100644
index 000000000..62235a278
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/autoboot_cmd.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/netdevice.h>
+#include <hci/ifmgmt_cmd.h>
+#include <usr/autoboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Booting commands
+ *
+ */
+
+/** "autoboot" options */
+struct autoboot_options {};
+
+/** "autoboot" option list */
+static struct option_descriptor autoboot_opts[] = {};
+
+/**
+ * "autoboot" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int autoboot_payload ( struct net_device *netdev,
+ struct autoboot_options *opts __unused ) {
+ return netboot ( netdev );
+}
+
+/** "autoboot" command descriptor */
+static struct ifcommon_command_descriptor autoboot_cmd =
+ IFCOMMON_COMMAND_DESC ( struct autoboot_options, autoboot_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ autoboot_payload, 0 );
+
+/**
+ * "autoboot" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int autoboot_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &autoboot_cmd );
+}
+
+/** Booting commands */
+struct command autoboot_commands[] __command = {
+ {
+ .name = "autoboot",
+ .exec = autoboot_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/config_cmd.c b/qemu/roms/ipxe/src/hci/commands/config_cmd.c
new file mode 100644
index 000000000..b81c866ff
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/config_cmd.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/settings.h>
+#include <ipxe/settings_ui.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Configuration UI commands
+ *
+ */
+
+/** "config" options */
+struct config_options {};
+
+/** "config" option list */
+static struct option_descriptor config_opts[] = {};
+
+/** "config" command descriptor */
+static struct command_descriptor config_cmd =
+ COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
+
+/**
+ * "config" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int config_exec ( int argc, char **argv ) {
+ struct config_options opts;
+ struct settings *settings;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &config_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse settings option, if present */
+ if ( ( rc = parse_settings ( ( ( optind < argc ) ? argv[optind] : "" ),
+ &settings ) ) != 0 )
+ return rc;
+
+ /* Run settings UI */
+ if ( ( rc = settings_ui ( settings ) ) != 0 ) {
+ printf ( "Could not save settings: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** Configuration UI commands */
+struct command config_command __command = {
+ .name = "config",
+ .exec = config_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/console_cmd.c b/qemu/roms/ipxe/src/hci/commands/console_cmd.c
new file mode 100644
index 000000000..d2eae59f0
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/console_cmd.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Console management commands
+ *
+ */
+
+#include <string.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/console.h>
+#include <ipxe/image.h>
+#include <ipxe/pixbuf.h>
+#include <ipxe/ansiesc.h>
+#include <ipxe/ansicol.h>
+#include <usr/imgmgmt.h>
+
+/** "console" options */
+struct console_options {
+ /** Console configuration */
+ struct console_configuration config;
+ /** Picture URI */
+ char *picture;
+ /** Keep picture after configuration */
+ int keep;
+};
+
+/** "console" option list */
+static struct option_descriptor console_opts[] = {
+ OPTION_DESC ( "x", 'x', required_argument,
+ struct console_options, config.width, parse_integer ),
+ OPTION_DESC ( "y", 'y', required_argument,
+ struct console_options, config.height, parse_integer ),
+ OPTION_DESC ( "left", 'l', required_argument,
+ struct console_options, config.left, parse_integer ),
+ OPTION_DESC ( "right", 'r', required_argument,
+ struct console_options, config.right, parse_integer ),
+ OPTION_DESC ( "top", 't', required_argument,
+ struct console_options, config.top, parse_integer ),
+ OPTION_DESC ( "bottom", 'b', required_argument,
+ struct console_options, config.bottom, parse_integer ),
+ OPTION_DESC ( "depth", 'd', required_argument,
+ struct console_options, config.depth, parse_integer ),
+ OPTION_DESC ( "picture", 'p', required_argument,
+ struct console_options, picture, parse_string ),
+ OPTION_DESC ( "keep", 'k', no_argument,
+ struct console_options, keep, parse_flag ),
+};
+
+/** "console" command descriptor */
+static struct command_descriptor console_cmd =
+ COMMAND_DESC ( struct console_options, console_opts, 0, 0, NULL );
+
+/**
+ * "console" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int console_exec ( int argc, char **argv ) {
+ struct console_options opts;
+ struct image *image = NULL;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &console_cmd, &opts ) ) != 0 )
+ goto err_parse;
+
+ /* Handle background picture, if applicable */
+ if ( opts.picture ) {
+
+ /* Acquire image */
+ if ( ( rc = imgacquire ( opts.picture, 0, &image ) ) != 0 )
+ goto err_acquire;
+
+ /* Convert to pixel buffer */
+ if ( ( rc = image_pixbuf ( image, &opts.config.pixbuf ) ) != 0){
+ printf ( "Could not use picture: %s\n",
+ strerror ( rc ) );
+ goto err_pixbuf;
+ }
+
+ /* Apply image's width and height if none specified */
+ if ( ! opts.config.width )
+ opts.config.width = opts.config.pixbuf->width;
+ if ( ! opts.config.height )
+ opts.config.height = opts.config.pixbuf->height;
+ }
+
+ /* Configure console */
+ if ( ( rc = console_configure ( &opts.config ) ) != 0 ) {
+ printf ( "Could not configure console: %s\n", strerror ( rc ) );
+ goto err_configure;
+ }
+
+ /* Reapply default colour pair and clear screen */
+ ansicol_set_pair ( CPAIR_DEFAULT );
+ printf ( CSI "2J" CSI "H" );
+
+ err_configure:
+ pixbuf_put ( opts.config.pixbuf );
+ err_pixbuf:
+ /* Discard image unless --keep was specified */
+ if ( image && ( ! opts.keep ) )
+ unregister_image ( image );
+ err_acquire:
+ err_parse:
+ return rc;
+}
+
+/** "colour" options */
+struct colour_options {
+ /** Basic colour */
+ unsigned int basic;
+ /** 24-bit RGB value */
+ unsigned int rgb;
+};
+
+/** "colour" option list */
+static struct option_descriptor colour_opts[] = {
+ OPTION_DESC ( "basic", 'b', required_argument,
+ struct colour_options, basic, parse_integer ),
+ OPTION_DESC ( "rgb", 'r', required_argument,
+ struct colour_options, rgb, parse_integer ),
+};
+
+/** "colour" command descriptor */
+static struct command_descriptor colour_cmd =
+ COMMAND_DESC ( struct colour_options, colour_opts, 1, 1, "<colour>" );
+
+/**
+ * "colour" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int colour_exec ( int argc, char **argv ) {
+ struct colour_options opts;
+ unsigned int colour;
+ int rc;
+
+ /* Initialise options */
+ memset ( &opts, 0, sizeof ( opts ) );
+ opts.basic = COLOUR_DEFAULT;
+ opts.rgb = ANSICOL_NO_RGB;
+
+ /* Parse options */
+ if ( ( rc = reparse_options ( argc, argv, &colour_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse colour index */
+ if ( ( rc = parse_integer ( argv[optind], &colour ) ) != 0 )
+ return rc;
+
+ /* Define colour */
+ if ( ( rc = ansicol_define ( colour, opts.basic, opts.rgb ) ) != 0 ) {
+ printf ( "Could not define colour: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ /* Reapply default colour pair, in case definition has changed */
+ ansicol_set_pair ( CPAIR_DEFAULT );
+
+ return 0;
+}
+
+/** "cpair" options */
+struct cpair_options {
+ /** Foreground colour */
+ unsigned int foreground;
+ /** Background colour */
+ unsigned int background;
+};
+
+/** "cpair" option list */
+static struct option_descriptor cpair_opts[] = {
+ OPTION_DESC ( "foreground", 'f', required_argument,
+ struct cpair_options, foreground, parse_integer ),
+ OPTION_DESC ( "background", 'b', required_argument,
+ struct cpair_options, background, parse_integer ),
+};
+
+/** "cpair" command descriptor */
+static struct command_descriptor cpair_cmd =
+ COMMAND_DESC ( struct cpair_options, cpair_opts, 1, 1, "<cpair>" );
+
+/**
+ * "cpair" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int cpair_exec ( int argc, char **argv ) {
+ struct cpair_options opts;
+ unsigned int cpair;
+ int rc;
+
+ /* Initialise options */
+ memset ( &opts, 0, sizeof ( opts ) );
+ opts.foreground = COLOUR_DEFAULT;
+ opts.background = COLOUR_DEFAULT;
+
+ /* Parse options */
+ if ( ( rc = reparse_options ( argc, argv, &cpair_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse colour pair index */
+ if ( ( rc = parse_integer ( argv[optind], &cpair ) ) != 0 )
+ return rc;
+
+ /* Define colour pair */
+ if ( ( rc = ansicol_define_pair ( cpair, opts.foreground,
+ opts.background ) ) != 0 ) {
+ printf ( "Could not define colour pair: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ /* Reapply default colour pair, in case definition has changed */
+ ansicol_set_pair ( CPAIR_DEFAULT );
+
+ return 0;
+}
+
+/** Console management commands */
+struct command console_commands[] __command = {
+ {
+ .name = "console",
+ .exec = console_exec,
+ },
+ {
+ .name = "colour",
+ .exec = colour_exec,
+ },
+ {
+ .name = "cpair",
+ .exec = cpair_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/dhcp_cmd.c b/qemu/roms/ipxe/src/hci/commands/dhcp_cmd.c
new file mode 100644
index 000000000..feeb55ee5
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/dhcp_cmd.c
@@ -0,0 +1,100 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, 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 <ipxe/netdevice.h>
+#include <ipxe/in.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/dhcpmgmt.h>
+#include <hci/ifmgmt_cmd.h>
+
+/** @file
+ *
+ * DHCP management commands
+ *
+ */
+
+/** "pxebs" options */
+struct pxebs_options {};
+
+/** "pxebs" option list */
+static struct option_descriptor pxebs_opts[] = {};
+
+/** "pxebs" command descriptor */
+static struct command_descriptor pxebs_cmd =
+ COMMAND_DESC ( struct pxebs_options, pxebs_opts, 2, 2,
+ "<interface> <server type>" );
+
+/**
+ * The "pxebs" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int pxebs_exec ( int argc, char **argv ) {
+ struct pxebs_options opts;
+ struct net_device *netdev;
+ unsigned int pxe_type;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &pxebs_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse net device name */
+ if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
+ return rc;
+
+ /* Parse boot server type */
+ if ( ( rc = parse_integer ( argv[ optind + 1 ], &pxe_type ) ) != 0 )
+ return rc;
+
+ /* 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 rc;
+ }
+
+ return 0;
+}
+
+/** DHCP management commands */
+struct command dhcp_commands[] __command = {
+ {
+ .name = "dhcp",
+ .exec = ifconf_exec, /* synonym for "ifconf" */
+ },
+ {
+ .name = "pxebs",
+ .exec = pxebs_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/digest_cmd.c b/qemu/roms/ipxe/src/hci/commands/digest_cmd.c
new file mode 100644
index 000000000..71308064f
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/digest_cmd.c
@@ -0,0 +1,123 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/image.h>
+#include <ipxe/crypto.h>
+#include <ipxe/md5.h>
+#include <ipxe/sha1.h>
+#include <usr/imgmgmt.h>
+
+/** @file
+ *
+ * Digest commands
+ *
+ */
+
+/** "digest" options */
+struct digest_options {};
+
+/** "digest" option list */
+static struct option_descriptor digest_opts[] = {};
+
+/** "digest" command descriptor */
+static struct command_descriptor digest_cmd =
+ COMMAND_DESC ( struct digest_options, digest_opts, 1, MAX_ARGUMENTS,
+ "<image> [<image>...]" );
+
+/**
+ * The "digest" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v digest Digest algorithm
+ * @ret rc Return status code
+ */
+static int digest_exec ( int argc, char **argv,
+ struct digest_algorithm *digest ) {
+ struct digest_options opts;
+ 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;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &digest_cmd, &opts ) ) != 0 )
+ return rc;
+
+ for ( i = optind ; i < argc ; i++ ) {
+
+ /* Acquire image */
+ if ( ( rc = imgacquire ( argv[i], 0, &image ) ) != 0 )
+ 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/qemu/roms/ipxe/src/hci/commands/fcmgmt_cmd.c b/qemu/roms/ipxe/src/hci/commands/fcmgmt_cmd.c
new file mode 100644
index 000000000..1c199b5dc
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/fcmgmt_cmd.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <strings.h>
+#include <ipxe/fc.h>
+#include <ipxe/fcels.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/tables.h>
+#include <usr/fcmgmt.h>
+
+/** @file
+ *
+ * Fibre Channel management commands
+ *
+ */
+
+/**
+ * Parse Fibre Channel port name
+ *
+ * @v text Text
+ * @ret port Fibre Channel port
+ * @ret rc Return status code
+ */
+static int parse_fc_port ( char *text, struct fc_port **port ) {
+
+ /* Sanity check */
+ assert ( text != NULL );
+
+ /* Find Fibre Channel port */
+ *port = fc_port_find ( text );
+ if ( ! *port ) {
+ printf ( "\"%s\": no such port\n", text );
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+/**
+ * Parse Fibre Channel port ID
+ *
+ * @v text Text
+ * @ret port_id Fibre Channel port ID
+ * @ret rc Return status code
+ */
+static int parse_fc_port_id ( char *text, struct fc_port_id *port_id ) {
+ int rc;
+
+ /* Sanity check */
+ assert ( text != NULL );
+
+ /* Parse port ID */
+ if ( ( rc = fc_id_aton ( text, port_id ) ) != 0 ) {
+ printf ( "\"%s\": invalid port ID\n", text );
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * Parse Fibre Channel ELS handler name
+ *
+ * @v text Text
+ * @ret handler Fibre Channel ELS handler
+ * @ret rc Return status code
+ */
+static int parse_fc_els_handler ( char *text, struct fc_els_handler **handler ){
+
+ for_each_table_entry ( (*handler), FC_ELS_HANDLERS ) {
+ if ( strcasecmp ( (*handler)->name, text ) == 0 )
+ return 0;
+ }
+
+ printf ( "\"%s\": unrecognised ELS\n", text );
+ return -ENOENT;
+}
+
+/** "fcstat" options */
+struct fcstat_options {};
+
+/** "fcstat" option list */
+static struct option_descriptor fcstat_opts[] = {};
+
+/** "fcstat" command descriptor */
+static struct command_descriptor fcstat_cmd =
+ COMMAND_DESC ( struct fcstat_options, fcstat_opts, 0, 0, NULL );
+
+/**
+ * The "fcstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int fcstat_exec ( int argc, char **argv ) {
+ struct fcstat_options opts;
+ struct fc_port *port;
+ struct fc_peer *peer;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &fcstat_cmd, &opts ) ) != 0 )
+ return rc;
+
+ list_for_each_entry ( port, &fc_ports, list )
+ fcportstat ( port );
+ list_for_each_entry ( peer, &fc_peers, list )
+ fcpeerstat ( peer );
+
+ return 0;
+}
+
+/** "fcels" options */
+struct fcels_options {
+ /** Fibre Channel port */
+ struct fc_port *port;
+ /** Fibre Channel peer port ID */
+ struct fc_port_id peer_port_id;
+};
+
+/** "fcels" option list */
+static struct option_descriptor fcels_opts[] = {
+ OPTION_DESC ( "port", 'p', required_argument,
+ struct fcels_options, port, parse_fc_port ),
+ OPTION_DESC ( "id", 'i', required_argument,
+ struct fcels_options, peer_port_id, parse_fc_port_id ),
+};
+
+/** "fcels" command descriptor */
+static struct command_descriptor fcels_cmd =
+ COMMAND_DESC ( struct fcels_options, fcels_opts, 1, 1, "<request>" );
+
+/**
+ * The "fcels" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int fcels_exec ( int argc, char **argv ) {
+ struct fcels_options opts;
+ struct fc_els_handler *handler;
+ struct fc_port_id *id;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &fcels_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse ELS handler */
+ if ( ( rc = parse_fc_els_handler ( argv[optind], &handler ) ) != 0 )
+ return rc;
+
+ /* Use first port if no port specified */
+ if ( ! opts.port ) {
+ opts.port = list_first_entry ( &fc_ports, struct fc_port,
+ list );
+ if ( ! opts.port ) {
+ printf ( "No ports\n" );
+ return -ENODEV;
+ }
+ }
+
+ /* Use link peer port ID if no peer port ID specified */
+ id = &opts.peer_port_id;
+ if ( memcmp ( id, &fc_empty_port_id, sizeof ( *id ) ) == 0 ) {
+ if ( fc_link_ok ( &opts.port->link ) &&
+ ! ( opts.port->flags & FC_PORT_HAS_FABRIC ) ) {
+ id = &opts.port->ptp_link_port_id;
+ } else {
+ id = &fc_f_port_id;
+ }
+ }
+
+ /** Issue ELS */
+ if ( ( rc = fcels ( opts.port, id, handler ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/** Fibre Channel management commands */
+struct command fcmgmt_commands[] __command = {
+ {
+ .name = "fcstat",
+ .exec = fcstat_exec,
+ },
+ {
+ .name = "fcels",
+ .exec = fcels_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/gdbstub_cmd.c b/qemu/roms/ipxe/src/hci/commands/gdbstub_cmd.c
new file mode 100644
index 000000000..33890aebc
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/gdbstub_cmd.c
@@ -0,0 +1,111 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/gdbstub.h>
+
+/** @file
+ *
+ * GDB stub command
+ *
+ */
+
+/**
+ * Parse GDB transport name
+ *
+ * @v text Text
+ * @ret trans GDB transport
+ * @ret rc Return status code
+ */
+static int parse_gdb_transport ( const char *text,
+ struct gdb_transport **trans ) {
+
+ /* Sanity check */
+ assert ( text != NULL );
+
+ /* Find transport */
+ *trans = find_gdb_transport ( text );
+ if ( ! *trans ) {
+ printf ( "\"%s\": no such transport (is it compiled in?)\n",
+ text );
+ return -ENOTSUP;
+ }
+
+ return 0;
+}
+
+/** "gdbstub" options */
+struct gdbstub_options {};
+
+/** "gdbstub" option list */
+static struct option_descriptor gdbstub_opts[] = {};
+
+/** "gdbstub" command descriptor */
+static struct command_descriptor gdbstub_cmd =
+ COMMAND_DESC ( struct gdbstub_options, gdbstub_opts, 1, MAX_ARGUMENTS,
+ "<transport> [<options>...]" );
+
+/**
+ * The "gdbstub" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int gdbstub_exec ( int argc, char **argv ) {
+ struct gdbstub_options opts;
+ struct gdb_transport *trans;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse transport name */
+ if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
+ return rc;
+
+ /* Initialise transport */
+ if ( trans->init ) {
+ if ( ( rc = trans->init ( argc - optind,
+ &argv[optind] ) ) != 0 ) {
+ return rc;
+ }
+ }
+
+ /* Enter GDB stub */
+ gdbstub_start ( trans );
+
+ return 0;
+}
+
+/** GDB stub commands */
+struct command gdbstub_commands[] __command = {
+ {
+ .name = "gdbstub",
+ .exec = gdbstub_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/ifmgmt_cmd.c b/qemu/roms/ipxe/src/hci/commands/ifmgmt_cmd.c
new file mode 100644
index 000000000..5307c9423
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/ifmgmt_cmd.c
@@ -0,0 +1,261 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/netdevice.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/ifmgmt.h>
+#include <hci/ifmgmt_cmd.h>
+
+/** @file
+ *
+ * Network interface management commands
+ *
+ */
+
+/**
+ * Execute if<xxx> command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v cmd Command descriptor
+ * @v payload Command to execute
+ * @v verb Verb describing the action of the command
+ * @ret rc Return status code
+ */
+int ifcommon_exec ( int argc, char **argv,
+ struct ifcommon_command_descriptor *ifcmd ) {
+ struct command_descriptor *cmd = &ifcmd->cmd;
+ uint8_t opts[cmd->len];
+ struct net_device *netdev;
+ int i;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, cmd, opts ) ) != 0 )
+ return rc;
+
+ if ( optind != argc ) {
+ /* Treat arguments as a list of interfaces to try */
+ for ( i = optind ; i < argc ; i++ ) {
+ if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
+ continue;
+ if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
+ && ifcmd->stop_on_first_success ) {
+ return 0;
+ }
+ }
+ } else {
+ /* Try all interfaces */
+ rc = -ENODEV;
+ for_each_netdev ( netdev ) {
+ if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
+ && ifcmd->stop_on_first_success ) {
+ return 0;
+ }
+ }
+ }
+
+ return rc;
+}
+
+/** "ifopen" options */
+struct ifopen_options {};
+
+/** "ifopen" option list */
+static struct option_descriptor ifopen_opts[] = {};
+
+/**
+ * "ifopen" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int ifopen_payload ( struct net_device *netdev,
+ struct ifopen_options *opts __unused ) {
+ return ifopen ( netdev );
+}
+
+/** "ifopen" command descriptor */
+static struct ifcommon_command_descriptor ifopen_cmd =
+ IFCOMMON_COMMAND_DESC ( struct ifopen_options, ifopen_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ ifopen_payload, 0 );
+
+/**
+ * The "ifopen" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ifopen_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &ifopen_cmd );
+}
+
+/** "ifclose" options */
+struct ifclose_options {};
+
+/** "ifclose" option list */
+static struct option_descriptor ifclose_opts[] = {};
+
+/**
+ * "ifclose" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int ifclose_payload ( struct net_device *netdev,
+ struct ifclose_options *opts __unused ) {
+ ifclose ( netdev );
+ return 0;
+}
+
+/** "ifclose" command descriptor */
+static struct ifcommon_command_descriptor ifclose_cmd =
+ IFCOMMON_COMMAND_DESC ( struct ifclose_options, ifclose_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ ifclose_payload, 0 );
+
+/**
+ * The "ifclose" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ifclose_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &ifclose_cmd );
+}
+
+/** "ifstat" options */
+struct ifstat_options {};
+
+/** "ifstat" option list */
+static struct option_descriptor ifstat_opts[] = {};
+
+/**
+ * "ifstat" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int ifstat_payload ( struct net_device *netdev,
+ struct ifstat_options *opts __unused ) {
+ ifstat ( netdev );
+ return 0;
+}
+
+/** "ifstat" command descriptor */
+static struct ifcommon_command_descriptor ifstat_cmd =
+ IFCOMMON_COMMAND_DESC ( struct ifstat_options, ifstat_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ ifstat_payload, 0 );
+
+/**
+ * The "ifstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ifstat_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &ifstat_cmd );
+}
+
+/** "ifconf" options */
+struct ifconf_options {
+ /** Configurator */
+ struct net_device_configurator *configurator;
+};
+
+/** "ifconf" option list */
+static struct option_descriptor ifconf_opts[] = {
+ OPTION_DESC ( "configurator", 'c', required_argument,
+ struct ifconf_options, configurator,
+ parse_netdev_configurator ),
+};
+
+/**
+ * "ifconf" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int ifconf_payload ( struct net_device *netdev,
+ struct ifconf_options *opts ) {
+ int rc;
+
+ /* Attempt configuration */
+ if ( ( rc = ifconf ( netdev, opts->configurator ) ) != 0 ) {
+
+ /* Close device on failure, to avoid memory exhaustion */
+ netdev_close ( netdev );
+
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "ifconf" command descriptor */
+static struct ifcommon_command_descriptor ifconf_cmd =
+ IFCOMMON_COMMAND_DESC ( struct ifconf_options, ifconf_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ ifconf_payload, 1 );
+
+/**
+ * The "ifconf" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+int ifconf_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &ifconf_cmd );
+}
+
+/** Interface management commands */
+struct command ifmgmt_commands[] __command = {
+ {
+ .name = "ifopen",
+ .exec = ifopen_exec,
+ },
+ {
+ .name = "ifclose",
+ .exec = ifclose_exec,
+ },
+ {
+ .name = "ifstat",
+ .exec = ifstat_exec,
+ },
+ {
+ .name = "ifconf",
+ .exec = ifconf_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/image_cmd.c b/qemu/roms/ipxe/src/hci/commands/image_cmd.c
new file mode 100644
index 000000000..a9e831bf5
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/image_cmd.c
@@ -0,0 +1,441 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/image.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/shell.h>
+#include <usr/imgmgmt.h>
+
+/** @file
+ *
+ * Image management commands
+ *
+ */
+
+/** "img{single}" options */
+struct imgsingle_options {
+ /** Image name */
+ char *name;
+ /** Download timeout */
+ unsigned long timeout;
+ /** Replace image */
+ int replace;
+ /** Free image after execution */
+ int autofree;
+};
+
+/** "img{single}" option list */
+static union {
+ /* "imgexec" takes all three options */
+ struct option_descriptor imgexec[4];
+ /* Other "img{single}" commands take only --name, --timeout,
+ * and --autofree
+ */
+ struct option_descriptor imgsingle[3];
+} opts = {
+ .imgexec = {
+ OPTION_DESC ( "name", 'n', required_argument,
+ struct imgsingle_options, name, parse_string ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct imgsingle_options, timeout, parse_timeout),
+ OPTION_DESC ( "autofree", 'a', no_argument,
+ struct imgsingle_options, autofree, parse_flag ),
+ OPTION_DESC ( "replace", 'r', no_argument,
+ struct imgsingle_options, replace, parse_flag ),
+ },
+};
+
+/** An "img{single}" family command descriptor */
+struct imgsingle_descriptor {
+ /** Command descriptor */
+ struct command_descriptor *cmd;
+ /** Function to use to acquire the image */
+ int ( * acquire ) ( const char *name, unsigned long timeout,
+ struct image **image );
+ /** Pre-action to take upon image, or NULL */
+ void ( * preaction ) ( struct image *image );
+ /** Action to take upon image, or NULL */
+ int ( * action ) ( struct image *image,
+ struct imgsingle_options *opts );
+ /** Verb to describe action */
+ const char *verb;
+};
+
+/**
+ * The "img{single}" family of commands
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v desc "img{single}" command descriptor
+ * @v action_name Action name (for error messages)
+ * @v action Action to take upon image
+ * @ret rc Return status code
+ */
+static int imgsingle_exec ( int argc, char **argv,
+ struct imgsingle_descriptor *desc ) {
+ struct imgsingle_options opts;
+ char *name_uri = NULL;
+ char *cmdline = NULL;
+ struct image *image;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, desc->cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse name/URI string and command line, if present */
+ if ( optind < argc ) {
+ name_uri = argv[optind];
+ if ( argv[ optind + 1 ] != NULL ) {
+ cmdline = concat_args ( &argv[ optind + 1 ] );
+ if ( ! cmdline ) {
+ rc = -ENOMEM;
+ goto err_parse_cmdline;
+ }
+ }
+ }
+
+ /* Acquire the image */
+ if ( name_uri ) {
+ if ( ( rc = desc->acquire ( name_uri, opts.timeout,
+ &image ) ) != 0 )
+ goto err_acquire;
+ } else {
+ image = image_find_selected();
+ if ( ! image ) {
+ printf ( "No image selected\n" );
+ goto err_acquire;
+ }
+ }
+
+ /* Carry out command pre-action, if applicable */
+ if ( desc->preaction )
+ desc->preaction ( image );
+
+ /* Set the image name, if applicable */
+ if ( opts.name ) {
+ if ( ( rc = image_set_name ( image, opts.name ) ) != 0 ) {
+ printf ( "Could not name image: %s\n",
+ strerror ( rc ) );
+ goto err_set_name;
+ }
+ }
+
+ /* Set the command-line arguments, if applicable */
+ if ( cmdline ) {
+ if ( ( rc = image_set_cmdline ( image, cmdline ) ) != 0 ) {
+ printf ( "Could not set arguments: %s\n",
+ strerror ( rc ) );
+ goto err_set_cmdline;
+ }
+ }
+
+ /* Set the auto-unregister flag, if applicable */
+ if ( opts.autofree )
+ image->flags |= IMAGE_AUTO_UNREGISTER;
+
+ /* Carry out command action, if applicable */
+ if ( desc->action ) {
+ if ( ( rc = desc->action ( image, &opts ) ) != 0 ) {
+ printf ( "Could not %s: %s\n",
+ desc->verb, strerror ( rc ) );
+ goto err_action;
+ }
+ }
+
+ /* Success */
+ rc = 0;
+
+ err_action:
+ err_set_cmdline:
+ err_set_name:
+ err_acquire:
+ free ( cmdline );
+ err_parse_cmdline:
+ err_parse_options:
+ return rc;
+}
+
+/** "imgfetch" command descriptor */
+static struct command_descriptor imgfetch_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri> [<arguments>...]" );
+
+/** "imgfetch" family command descriptor */
+struct imgsingle_descriptor imgfetch_desc = {
+ .cmd = &imgfetch_cmd,
+ .acquire = imgdownload_string,
+};
+
+/**
+ * The "imgfetch" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgfetch_exec ( int argc, char **argv ) {
+ return imgsingle_exec ( argc, argv, &imgfetch_desc );
+}
+
+/**
+ * "imgselect" command action
+ *
+ * @v image Image
+ * @v opts Options
+ * @ret rc Return status code
+ */
+static int imgselect ( struct image *image,
+ struct imgsingle_options *opts __unused ) {
+ return image_select ( image );
+}
+
+/** "imgselect" command descriptor */
+static struct command_descriptor imgselect_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri|image> [<arguments>...]" );
+
+/** "imgselect" family command descriptor */
+struct imgsingle_descriptor imgselect_desc = {
+ .cmd = &imgselect_cmd,
+ .acquire = imgacquire,
+ .action = imgselect,
+ .verb = "select",
+};
+
+/**
+ * The "imgselect" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgselect_exec ( int argc, char **argv ) {
+ return imgsingle_exec ( argc, argv, &imgselect_desc );
+}
+
+/** "imgexec" command descriptor */
+static struct command_descriptor imgexec_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgexec,
+ 0, MAX_ARGUMENTS, "[<uri|image> [<arguments>...]]" );
+
+/**
+ * "imgexec" command action
+ *
+ * @v image Image
+ * @v opts Options
+ * @ret rc Return status code
+ */
+static int imgexec ( struct image *image, struct imgsingle_options *opts ) {
+ int rc;
+
+ /* Perform replacement or execution as applicable */
+ if ( opts->replace ) {
+
+ /* Try to replace image */
+ if ( ( rc = image_replace ( image ) ) != 0 )
+ return rc;
+
+ /* Stop script and tail-recurse into replacement image */
+ shell_stop ( SHELL_STOP_COMMAND_SEQUENCE );
+
+ } else {
+
+ /* Try to execute image */
+ if ( ( rc = image_exec ( image ) ) != 0 )
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "imgexec" family command descriptor */
+struct imgsingle_descriptor imgexec_desc = {
+ .cmd = &imgexec_cmd,
+ .acquire = imgacquire,
+ .action = imgexec,
+ .verb = "boot",
+};
+
+/**
+ * The "imgexec" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgexec_exec ( int argc, char **argv) {
+ return imgsingle_exec ( argc, argv, &imgexec_desc );
+}
+
+/** "imgargs" command descriptor */
+static struct command_descriptor imgargs_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri|image> [<arguments>...]" );
+
+/** "imgargs" family command descriptor */
+struct imgsingle_descriptor imgargs_desc = {
+ .cmd = &imgargs_cmd,
+ .acquire = imgacquire,
+ .preaction = image_clear_cmdline,
+};
+
+/**
+ * The "imgargs" command body
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgargs_exec ( int argc, char **argv ) {
+ return imgsingle_exec ( argc, argv, &imgargs_desc );
+}
+
+/** "img{multi}" options */
+struct imgmulti_options {};
+
+/** "img{multi}" option list */
+static struct option_descriptor imgmulti_opts[] = {};
+
+/** "img{multi}" command descriptor */
+static struct command_descriptor imgmulti_cmd =
+ COMMAND_DESC ( struct imgmulti_options, imgmulti_opts, 0, MAX_ARGUMENTS,
+ "[<image>...]" );
+
+/**
+ * The "img{multi}" family of commands
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v payload Function to execute on each image
+ * @ret rc Return status code
+ */
+static int imgmulti_exec ( int argc, char **argv,
+ void ( * payload ) ( struct image *image ) ) {
+ struct imgmulti_options opts;
+ struct image *image;
+ struct image *tmp;
+ int i;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &imgmulti_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* If no images are explicitly specified, process all images */
+ if ( optind == argc ) {
+ for_each_image_safe ( image, tmp )
+ payload ( image );
+ return 0;
+ }
+
+ /* Otherwise, process specified images */
+ for ( i = optind ; i < argc ; i++ ) {
+ image = find_image ( argv[i] );
+ if ( ! image ) {
+ printf ( "\"%s\": no such image\n", argv[i] );
+ return -ENOENT;
+ }
+ payload ( image );
+ }
+
+ return 0;
+}
+
+/**
+ * The "imgstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgstat_exec ( int argc, char **argv ) {
+ return imgmulti_exec ( argc, argv, imgstat );
+}
+
+/**
+ * The "imgfree" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgfree_exec ( int argc, char **argv ) {
+ return imgmulti_exec ( argc, argv, unregister_image );
+}
+
+/** 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 = imgselect_exec, /* synonym for "imgselect" */
+ },
+ {
+ .name = "chain",
+ .exec = imgexec_exec, /* synonym for "imgexec" */
+ },
+ {
+ .name = "imgselect",
+ .exec = imgselect_exec,
+ },
+ {
+ .name = "imgload",
+ .exec = imgselect_exec, /* synonym for "imgselect" */
+ },
+ {
+ .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/qemu/roms/ipxe/src/hci/commands/image_trust_cmd.c b/qemu/roms/ipxe/src/hci/commands/image_trust_cmd.c
new file mode 100644
index 000000000..ca59a858a
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/image_trust_cmd.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/image.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/imgmgmt.h>
+#include <usr/imgtrust.h>
+
+/** @file
+ *
+ * Image trust management commands
+ *
+ */
+
+/** "imgtrust" options */
+struct imgtrust_options {
+ /** Allow trusted images */
+ int allow;
+ /** Make trust requirement permanent */
+ int permanent;
+};
+
+/** "imgtrust" option list */
+static struct option_descriptor imgtrust_opts[] = {
+ OPTION_DESC ( "allow", 'a', no_argument,
+ struct imgtrust_options, allow, parse_flag ),
+ OPTION_DESC ( "permanent", 'p', no_argument,
+ struct imgtrust_options, permanent, parse_flag ),
+};
+
+/** "imgtrust" command descriptor */
+static struct command_descriptor imgtrust_cmd =
+ COMMAND_DESC ( struct imgtrust_options, imgtrust_opts, 0, 0, NULL );
+
+/**
+ * The "imgtrust" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgtrust_exec ( int argc, char **argv ) {
+ struct imgtrust_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &imgtrust_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Set trust requirement */
+ if ( ( rc = image_set_trust ( ( ! opts.allow ),
+ opts.permanent ) ) != 0 ) {
+ printf ( "Could not set image trust requirement: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "imgverify" options */
+struct imgverify_options {
+ /** Required signer common name */
+ char *signer;
+ /** Keep signature after verification */
+ int keep;
+ /** Download timeout */
+ unsigned long timeout;
+};
+
+/** "imgverify" option list */
+static struct option_descriptor imgverify_opts[] = {
+ OPTION_DESC ( "signer", 's', required_argument,
+ struct imgverify_options, signer, parse_string ),
+ OPTION_DESC ( "keep", 'k', no_argument,
+ struct imgverify_options, keep, parse_flag ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct imgverify_options, timeout, parse_timeout),
+};
+
+/** "imgverify" command descriptor */
+static struct command_descriptor imgverify_cmd =
+ COMMAND_DESC ( struct imgverify_options, imgverify_opts, 2, 2,
+ "<uri|image> <signature uri|image>" );
+
+/**
+ * The "imgverify" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int imgverify_exec ( int argc, char **argv ) {
+ struct imgverify_options opts;
+ const char *image_name_uri;
+ const char *signature_name_uri;
+ struct image *image;
+ struct image *signature;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &imgverify_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse image name/URI string */
+ image_name_uri = argv[optind];
+
+ /* Parse signature name/URI string */
+ signature_name_uri = argv[ optind + 1 ];
+
+ /* Acquire the image */
+ if ( ( rc = imgacquire ( image_name_uri, opts.timeout, &image ) ) != 0 )
+ goto err_acquire_image;
+
+ /* Acquire the signature image */
+ if ( ( rc = imgacquire ( signature_name_uri, opts.timeout,
+ &signature ) ) != 0 )
+ goto err_acquire_signature;
+
+ /* Verify image */
+ if ( ( rc = imgverify ( image, signature, opts.signer ) ) != 0 ) {
+ printf ( "Could not verify: %s\n", strerror ( rc ) );
+ goto err_verify;
+ }
+
+ /* Success */
+ rc = 0;
+
+ err_verify:
+ /* Discard signature unless --keep was specified */
+ if ( ! opts.keep )
+ unregister_image ( signature );
+ err_acquire_signature:
+ err_acquire_image:
+ return rc;
+}
+
+/** Image trust management commands */
+struct command image_trust_commands[] __command = {
+ {
+ .name = "imgtrust",
+ .exec = imgtrust_exec,
+ },
+ {
+ .name = "imgverify",
+ .exec = imgverify_exec,
+ },
+};
+
+/* Drag in objects typically required for signature verification */
+REQUIRE_OBJECT ( rsa );
+REQUIRE_OBJECT ( md5 );
+REQUIRE_OBJECT ( sha1 );
+REQUIRE_OBJECT ( sha256 );
diff --git a/qemu/roms/ipxe/src/hci/commands/ipstat_cmd.c b/qemu/roms/ipxe/src/hci/commands/ipstat_cmd.c
new file mode 100644
index 000000000..d565dc0ae
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/ipstat_cmd.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/ipstat.h>
+
+/** @file
+ *
+ * IP statistics commands
+ *
+ */
+
+/** "ipstat" options */
+struct ipstat_options {};
+
+/** "ipstat" option list */
+static struct option_descriptor ipstat_opts[] = {};
+
+/** "ipstat" command descriptor */
+static struct command_descriptor ipstat_cmd =
+ COMMAND_DESC ( struct ipstat_options, ipstat_opts, 0, 0, NULL );
+
+/**
+ * The "ipstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ipstat_exec ( int argc, char **argv ) {
+ struct ipstat_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &ipstat_cmd, &opts ) ) != 0 )
+ return rc;
+
+ ipstat();
+
+ return 0;
+}
+
+/** Routing table management commands */
+struct command ipstat_commands[] __command = {
+ {
+ .name = "ipstat",
+ .exec = ipstat_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/iwmgmt_cmd.c b/qemu/roms/ipxe/src/hci/commands/iwmgmt_cmd.c
new file mode 100644
index 000000000..b61ee8c7b
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/iwmgmt_cmd.c
@@ -0,0 +1,125 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <ipxe/netdevice.h>
+#include <ipxe/net80211.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/iwmgmt.h>
+#include <hci/ifmgmt_cmd.h>
+
+/** @file
+ *
+ * Wireless interface management commands
+ *
+ */
+
+/** "iwstat" options */
+struct iwstat_options {};
+
+/** "iwstat" option list */
+static struct option_descriptor iwstat_opts[] = {};
+
+/**
+ * "iwstat" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int iwstat_payload ( struct net_device *netdev,
+ struct iwstat_options *opts __unused ) {
+ struct net80211_device *dev = net80211_get ( netdev );
+
+ if ( dev )
+ iwstat ( dev );
+
+ return 0;
+}
+
+/** "iwstat" command descriptor */
+static struct ifcommon_command_descriptor iwstat_cmd =
+ IFCOMMON_COMMAND_DESC ( struct iwstat_options, iwstat_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ iwstat_payload, 0 );
+
+/**
+ * The "iwstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int iwstat_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &iwstat_cmd );
+}
+
+/** "iwlist" options */
+struct iwlist_options {};
+
+/** "iwlist" option list */
+static struct option_descriptor iwlist_opts[] = {};
+
+/**
+ * "iwlist" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int iwlist_payload ( struct net_device *netdev,
+ struct iwlist_options *opts __unused ) {
+ struct net80211_device *dev = net80211_get ( netdev );
+
+ if ( dev )
+ return iwlist ( dev );
+
+ return 0;
+}
+
+/** "iwlist" command descriptor */
+static struct ifcommon_command_descriptor iwlist_cmd =
+ IFCOMMON_COMMAND_DESC ( struct iwlist_options, iwlist_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ iwlist_payload, 0 );
+
+/**
+ * The "iwlist" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int iwlist_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &iwlist_cmd );
+}
+
+/** Wireless interface management commands */
+struct command iwmgmt_commands[] __command = {
+ {
+ .name = "iwstat",
+ .exec = iwstat_exec,
+ },
+ {
+ .name = "iwlist",
+ .exec = iwlist_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/login_cmd.c b/qemu/roms/ipxe/src/hci/commands/login_cmd.c
new file mode 100644
index 000000000..f5db427d5
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/login_cmd.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/login_ui.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Login commands
+ *
+ */
+
+/** "login" options */
+struct login_options {};
+
+/** "login" option list */
+static struct option_descriptor login_opts[] = {};
+
+/** "login" command descriptor */
+static struct command_descriptor login_cmd =
+ COMMAND_DESC ( struct login_options, login_opts, 0, 0, NULL );
+
+/**
+ * "login" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int login_exec ( int argc, char **argv ) {
+ struct login_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &login_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Show login UI */
+ if ( ( rc = login_ui() ) != 0 ) {
+ printf ( "Could not set credentials: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** Login commands */
+struct command login_command __command = {
+ .name = "login",
+ .exec = login_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/lotest_cmd.c b/qemu/roms/ipxe/src/hci/commands/lotest_cmd.c
new file mode 100644
index 000000000..0fa031bcb
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/lotest_cmd.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <ipxe/netdevice.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/if_ether.h>
+#include <usr/lotest.h>
+
+/** @file
+ *
+ * Loopback testing commands
+ *
+ */
+
+/** "lotest" options */
+struct lotest_options {
+ /** MTU */
+ unsigned int mtu;
+};
+
+/** "lotest" option list */
+static struct option_descriptor lotest_opts[] = {
+ OPTION_DESC ( "mtu", 'm', required_argument,
+ struct lotest_options, mtu, parse_integer ),
+};
+
+/** "lotest" command descriptor */
+static struct command_descriptor lotest_cmd =
+ COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
+ "<sending interface> <receiving interface>" );
+
+/**
+ * "lotest" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int lotest_exec ( int argc, char **argv ) {
+ struct lotest_options opts;
+ struct net_device *sender;
+ struct net_device *receiver;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &lotest_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse sending interface name */
+ if ( ( rc = parse_netdev ( argv[optind], &sender ) ) != 0 )
+ return rc;
+
+ /* Parse receiving interface name */
+ if ( ( rc = parse_netdev ( argv[ optind + 1 ], &receiver ) ) != 0 )
+ return rc;
+
+ /* Use default MTU if none specified */
+ if ( ! opts.mtu )
+ opts.mtu = ETH_MAX_MTU;
+
+ /* Perform loopback test */
+ if ( ( rc = loopback_test ( sender, receiver, opts.mtu ) ) != 0 ) {
+ printf ( "Test failed: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** Loopback testing commands */
+struct command lotest_command __command = {
+ .name = "lotest",
+ .exec = lotest_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/menu_cmd.c b/qemu/roms/ipxe/src/hci/commands/menu_cmd.c
new file mode 100644
index 000000000..66a6262e6
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/menu_cmd.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Menu commands
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/menu.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/settings.h>
+#include <ipxe/features.h>
+
+FEATURE ( FEATURE_MISC, "Menu", DHCP_EB_FEATURE_MENU, 1 );
+
+/** "menu" options */
+struct menu_options {
+ /** Name */
+ char *name;
+ /** Delete */
+ int delete;
+};
+
+/** "menu" option list */
+static struct option_descriptor menu_opts[] = {
+ OPTION_DESC ( "name", 'n', required_argument,
+ struct menu_options, name, parse_string ),
+ OPTION_DESC ( "delete", 'd', no_argument,
+ struct menu_options, delete, parse_flag ),
+};
+
+/** "menu" command descriptor */
+static struct command_descriptor menu_cmd =
+ COMMAND_DESC ( struct menu_options, menu_opts, 0, MAX_ARGUMENTS,
+ "[<title>]" );
+
+/**
+ * The "menu" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int menu_exec ( int argc, char **argv ) {
+ struct menu_options opts;
+ struct menu *menu;
+ char *title;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &menu_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse title */
+ title = concat_args ( &argv[optind] );
+ if ( ! title ) {
+ rc = -ENOMEM;
+ goto err_parse_title;
+ }
+
+ /* Create menu */
+ menu = create_menu ( opts.name, title );
+ if ( ! menu ) {
+ rc = -ENOMEM;
+ goto err_create_menu;
+ }
+
+ /* Destroy menu, if applicable */
+ if ( opts.delete )
+ destroy_menu ( menu );
+
+ /* Success */
+ rc = 0;
+
+ err_create_menu:
+ free ( title );
+ err_parse_title:
+ err_parse_options:
+ return rc;
+}
+
+/** "item" options */
+struct item_options {
+ /** Menu name */
+ char *menu;
+ /** Shortcut key */
+ unsigned int key;
+ /** Use as default */
+ int is_default;
+ /** Use as a separator */
+ int is_gap;
+};
+
+/** "item" option list */
+static struct option_descriptor item_opts[] = {
+ OPTION_DESC ( "menu", 'm', required_argument,
+ struct item_options, menu, parse_string ),
+ OPTION_DESC ( "key", 'k', required_argument,
+ struct item_options, key, parse_key ),
+ OPTION_DESC ( "default", 'd', no_argument,
+ struct item_options, is_default, parse_flag ),
+ OPTION_DESC ( "gap", 'g', no_argument,
+ struct item_options, is_gap, parse_flag ),
+};
+
+/** "item" command descriptor */
+static struct command_descriptor item_cmd =
+ COMMAND_DESC ( struct item_options, item_opts, 0, MAX_ARGUMENTS,
+ "[<label> [<text>]]" );
+
+/**
+ * The "item" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int item_exec ( int argc, char **argv ) {
+ struct item_options opts;
+ struct menu *menu;
+ struct menu_item *item;
+ char *label = NULL;
+ char *text = NULL;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &item_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse label, if present */
+ if ( ! opts.is_gap )
+ label = argv[optind++]; /* May be NULL */
+
+ /* Parse text, if present */
+ if ( optind < argc ) {
+ text = concat_args ( &argv[optind] );
+ if ( ! text ) {
+ rc = -ENOMEM;
+ goto err_parse_text;
+ }
+ }
+
+ /* Identify menu */
+ if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
+ goto err_parse_menu;
+
+ /* Add menu item */
+ item = add_menu_item ( menu, label, ( text ? text : "" ),
+ opts.key, opts.is_default );
+ if ( ! item ) {
+ rc = -ENOMEM;
+ goto err_add_menu_item;
+ }
+
+ /* Success */
+ rc = 0;
+
+ err_add_menu_item:
+ err_parse_menu:
+ free ( text );
+ err_parse_text:
+ err_parse_options:
+ return rc;
+}
+
+/** "choose" options */
+struct choose_options {
+ /** Menu name */
+ char *menu;
+ /** Timeout */
+ unsigned long timeout;
+ /** Default selection */
+ char *select;
+ /** Keep menu */
+ int keep;
+};
+
+/** "choose" option list */
+static struct option_descriptor choose_opts[] = {
+ OPTION_DESC ( "menu", 'm', required_argument,
+ struct choose_options, menu, parse_string ),
+ OPTION_DESC ( "default", 'd', required_argument,
+ struct choose_options, select, parse_string ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct choose_options, timeout, parse_timeout ),
+ OPTION_DESC ( "keep", 'k', no_argument,
+ struct choose_options, keep, parse_flag ),
+};
+
+/** "choose" command descriptor */
+static struct command_descriptor choose_cmd =
+ COMMAND_DESC ( struct choose_options, choose_opts, 1, 1, "<setting>" );
+
+/**
+ * The "choose" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int choose_exec ( int argc, char **argv ) {
+ struct choose_options opts;
+ struct named_setting setting;
+ struct menu *menu;
+ struct menu_item *item;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &choose_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse setting name */
+ if ( ( rc = parse_autovivified_setting ( argv[optind],
+ &setting ) ) != 0 )
+ goto err_parse_setting;
+
+ /* Identify menu */
+ if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
+ goto err_parse_menu;
+
+ /* Show menu */
+ if ( ( rc = show_menu ( menu, opts.timeout, opts.select, &item ) ) != 0)
+ goto err_show_menu;
+
+ /* Apply default type if necessary */
+ if ( ! setting.setting.type )
+ setting.setting.type = &setting_type_string;
+
+ /* Store setting */
+ if ( ( rc = storef_setting ( setting.settings, &setting.setting,
+ item->label ) ) != 0 ) {
+ printf ( "Could not store \"%s\": %s\n",
+ setting.setting.name, strerror ( rc ) );
+ goto err_store;
+ }
+
+ /* Success */
+ rc = 0;
+
+ err_store:
+ err_show_menu:
+ /* Destroy menu, if applicable */
+ if ( ! opts.keep )
+ destroy_menu ( menu );
+ err_parse_menu:
+ err_parse_setting:
+ err_parse_options:
+ return rc;
+}
+
+/** Menu commands */
+struct command menu_commands[] __command = {
+ {
+ .name = "menu",
+ .exec = menu_exec,
+ },
+ {
+ .name = "item",
+ .exec = item_exec,
+ },
+ {
+ .name = "choose",
+ .exec = choose_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/neighbour_cmd.c b/qemu/roms/ipxe/src/hci/commands/neighbour_cmd.c
new file mode 100644
index 000000000..a1e052439
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/neighbour_cmd.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Neighbour management commands
+ *
+ */
+
+#include <getopt.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/command.h>
+#include <usr/neighmgmt.h>
+
+/** "nstat" options */
+struct nstat_options {};
+
+/** "nstat" option list */
+static struct option_descriptor nstat_opts[] = {};
+
+/** "nstat" command descriptor */
+static struct command_descriptor nstat_cmd =
+ COMMAND_DESC ( struct nstat_options, nstat_opts, 0, 0, NULL );
+
+/**
+ * The "nstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int nstat_exec ( int argc, char **argv ) {
+ struct nstat_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &nstat_cmd, &opts ) ) != 0)
+ return rc;
+
+ nstat();
+
+ return 0;
+}
+
+/** Neighbour management commands */
+struct command neighbour_commands[] __command = {
+ {
+ .name = "nstat",
+ .exec = nstat_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/nslookup_cmd.c b/qemu/roms/ipxe/src/hci/commands/nslookup_cmd.c
new file mode 100644
index 000000000..265afdc3d
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/nslookup_cmd.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 Patrick Plenefisch <phplenefisch@wpi.edu>.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/nslookup.h>
+
+/** @file
+ *
+ * nslookup command
+ *
+ */
+
+/** "nslookup" options */
+struct nslookup_options {};
+
+/** "nslookup" option list */
+static struct option_descriptor nslookup_opts[] = {};
+
+/** "nslookup" command descriptor */
+static struct command_descriptor nslookup_cmd =
+ COMMAND_DESC ( struct nslookup_options, nslookup_opts, 2, 2,
+ "<setting> <name>" );
+
+/**
+ * The "nslookup" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int nslookup_exec ( int argc, char **argv ) {
+ struct nslookup_options opts;
+ const char *name;
+ const char *setting_name;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &nslookup_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse setting name */
+ setting_name = argv[optind];
+
+ /* Parse name to be resolved */
+ name = argv[ optind + 1 ];
+
+ /* Look up name */
+ if ( ( rc = nslookup ( name, setting_name ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/** The "nslookup" command */
+struct command nslookup_command __command = {
+ .name = "nslookup",
+ .exec = nslookup_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/nvo_cmd.c b/qemu/roms/ipxe/src/hci/commands/nvo_cmd.c
new file mode 100644
index 000000000..e63dab08e
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/nvo_cmd.c
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <byteswap.h>
+#include <ipxe/settings.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <readline/readline.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Non-volatile option commands
+ *
+ */
+
+/** "show" options */
+struct show_options {};
+
+/** "show" option list */
+static struct option_descriptor show_opts[] = {};
+
+/** "show" command descriptor */
+static struct command_descriptor show_cmd =
+ COMMAND_DESC ( struct show_options, show_opts, 1, 1, "<setting>" );
+
+/**
+ * "show" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int show_exec ( int argc, char **argv ) {
+ struct show_options opts;
+ struct named_setting setting;
+ struct settings *origin;
+ struct setting fetched;
+ char name_buf[32];
+ char *value;
+ int len;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &show_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse setting name */
+ if ( ( rc = parse_existing_setting ( argv[optind], &setting ) ) != 0 )
+ goto err_parse_setting;
+
+ /* Fetch formatted setting value */
+ if ( ( len = fetchf_setting_copy ( setting.settings, &setting.setting,
+ &origin, &fetched, &value ) ) < 0 ) {
+ rc = len;
+ printf ( "Could not find \"%s\": %s\n",
+ setting.setting.name, strerror ( rc ) );
+ goto err_fetchf;
+ }
+
+ /* Print setting value */
+ setting_name ( origin, &fetched, name_buf, sizeof ( name_buf ) );
+ printf ( "%s = %s\n", name_buf, value );
+
+ /* Success */
+ rc = 0;
+
+ free ( value );
+ err_fetchf:
+ err_parse_setting:
+ err_parse_options:
+ return rc;
+}
+
+/** "set", "clear", and "read" options */
+struct set_core_options {};
+
+/** "set", "clear", and "read" option list */
+static struct option_descriptor set_core_opts[] = {};
+
+/** "set" command descriptor */
+static struct command_descriptor set_cmd =
+ COMMAND_DESC ( struct set_core_options, set_core_opts, 1, MAX_ARGUMENTS,
+ "<setting> <value>" );
+
+/** "clear" and "read" command descriptor */
+static struct command_descriptor clear_read_cmd =
+ COMMAND_DESC ( struct set_core_options, set_core_opts, 1, 1,
+ "<setting>" );
+
+/**
+ * "set", "clear", and "read" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v cmd Command descriptor
+ * @v get_value Method to obtain setting value
+ * @ret rc Return status code
+ */
+static int set_core_exec ( int argc, char **argv,
+ struct command_descriptor *cmd,
+ int ( * get_value ) ( struct named_setting *setting,
+ char **args, char **value ) ) {
+ struct set_core_options opts;
+ struct named_setting setting;
+ char *value;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse setting name */
+ if ( ( rc = parse_autovivified_setting ( argv[optind],
+ &setting ) ) != 0 )
+ goto err_parse_setting;
+
+ /* Parse setting value */
+ if ( ( rc = get_value ( &setting, &argv[ optind + 1 ], &value ) ) != 0 )
+ goto err_get_value;
+
+ /* Apply default type if necessary */
+ if ( ! setting.setting.type )
+ setting.setting.type = &setting_type_string;
+
+ /* Store setting */
+ if ( ( rc = storef_setting ( setting.settings, &setting.setting,
+ value ) ) != 0 ) {
+ printf ( "Could not store \"%s\": %s\n",
+ setting.setting.name, strerror ( rc ) );
+ goto err_store;
+ }
+
+ err_store:
+ free ( value );
+ err_get_value:
+ err_parse_setting:
+ err_parse_options:
+ return rc;
+}
+
+/**
+ * Get setting value for "set" command
+ *
+ * @v setting Named setting
+ * @v args Remaining arguments
+ * @ret value Setting value
+ * @ret rc Return status code
+ */
+static int set_value ( struct named_setting *setting __unused,
+ char **args, char **value ) {
+
+ *value = concat_args ( args );
+ if ( ! *value )
+ return -ENOMEM;
+
+ return 0;
+}
+
+/**
+ * "set" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int set_exec ( int argc, char **argv ) {
+ return set_core_exec ( argc, argv, &set_cmd, set_value );
+}
+
+/**
+ * Get setting value for "clear" command
+ *
+ * @v setting Named setting
+ * @v args Remaining arguments
+ * @ret value Setting value
+ * @ret rc Return status code
+ */
+static int clear_value ( struct named_setting *setting __unused,
+ char **args __unused, char **value ) {
+
+ *value = NULL;
+ return 0;
+}
+
+/**
+ * "clear" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int clear_exec ( int argc, char **argv ) {
+ return set_core_exec ( argc, argv, &clear_read_cmd, clear_value );
+}
+
+/**
+ * Get setting value for "read" command
+ *
+ * @v setting Named setting
+ * @v args Remaining arguments
+ * @ret value Setting value
+ * @ret rc Return status code
+ */
+static int read_value ( struct named_setting *setting, char **args __unused,
+ char **value ) {
+ char *existing;
+ int rc;
+
+ /* Read existing value, treating errors as equivalent to an
+ * empty initial setting.
+ */
+ fetchf_setting_copy ( setting->settings, &setting->setting,
+ NULL, &setting->setting, &existing );
+
+ /* Read new value */
+ if ( ( rc = readline_history ( NULL, existing, NULL, value ) ) != 0 )
+ goto err_readline;
+
+ err_readline:
+ free ( existing );
+ return rc;
+}
+
+/**
+ * "read" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int read_exec ( int argc, char **argv ) {
+ return set_core_exec ( argc, argv, &clear_read_cmd, read_value );
+}
+
+/** "inc" options */
+struct inc_options {};
+
+/** "inc" option list */
+static struct option_descriptor inc_opts[] = {};
+
+/** "inc" command descriptor */
+static struct command_descriptor inc_cmd =
+ COMMAND_DESC ( struct inc_options, inc_opts, 1, 2,
+ "<setting> [<increment>]" );
+
+/**
+ * "inc" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int inc_exec ( int argc, char **argv ) {
+ struct inc_options opts;
+ struct named_setting setting;
+ unsigned int increment = 1;
+ unsigned long value;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &inc_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse setting name */
+ if ( ( rc = parse_existing_setting ( argv[optind], &setting ) ) != 0 )
+ goto err_parse_setting;
+
+ /* Parse increment (if present) */
+ if ( ( ( optind + 1 ) < argc ) &&
+ ( ( rc = parse_integer ( argv[ optind + 1 ], &increment ) ) != 0))
+ goto err_parse_increment;
+
+ /* Read existing value, treating errors as equivalent to a
+ * zero-valued :int32 initial setting.
+ */
+ if ( ( rc = fetchn_setting ( setting.settings, &setting.setting,
+ NULL, &setting.setting, &value ) ) != 0 ) {
+ value = 0;
+ if ( ! setting.setting.type )
+ setting.setting.type = &setting_type_int32;
+ }
+
+ /* Increment value */
+ value += increment;
+
+ /* Store updated setting value */
+ if ( ( rc = storen_setting ( setting.settings, &setting.setting,
+ value ) ) != 0 ) {
+ printf ( "Could not store \"%s\": %s\n",
+ setting.setting.name, strerror ( rc ) );
+ goto err_store;
+ }
+
+ err_store:
+ err_parse_increment:
+ err_parse_setting:
+ err_parse_options:
+ return rc;
+}
+
+/** Non-volatile option commands */
+struct command nvo_commands[] __command = {
+ {
+ .name = "show",
+ .exec = show_exec,
+ },
+ {
+ .name = "set",
+ .exec = set_exec,
+ },
+ {
+ .name = "clear",
+ .exec = clear_exec,
+ },
+ {
+ .name = "read",
+ .exec = read_exec,
+ },
+ {
+ .name = "inc",
+ .exec = inc_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/param_cmd.c b/qemu/roms/ipxe/src/hci/commands/param_cmd.c
new file mode 100644
index 000000000..6cf096d00
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/param_cmd.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Form parameter commands
+ *
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/params.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/command.h>
+
+/** "params" options */
+struct params_options {
+ /** Name */
+ char *name;
+ /** Delete */
+ int delete;
+};
+
+/** "params" option list */
+static struct option_descriptor params_opts[] = {
+ OPTION_DESC ( "name", 'n', required_argument,
+ struct params_options, name, parse_string ),
+ OPTION_DESC ( "delete", 'd', no_argument,
+ struct params_options, delete, parse_flag ),
+};
+
+/** "params" command descriptor */
+static struct command_descriptor params_cmd =
+ COMMAND_DESC ( struct params_options, params_opts, 0, 0, NULL );
+
+/**
+ * The "params" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int params_exec ( int argc, char **argv ) {
+ struct params_options opts;
+ struct parameters *params;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &params_cmd, &opts ) ) != 0)
+ return rc;
+
+ /* Create parameter list */
+ params = create_parameters ( opts.name );
+ if ( ! params )
+ return -ENOMEM;
+
+ /* Destroy parameter list, if applicable */
+ if ( opts.delete ) {
+ claim_parameters ( params );
+ params_put ( params );
+ }
+
+ return 0;
+}
+
+/** "param" options */
+struct param_options {
+ /** Parameter list name */
+ char *params;
+};
+
+/** "param" option list */
+static struct option_descriptor param_opts[] = {
+ OPTION_DESC ( "params", 'p', required_argument,
+ struct param_options, params, parse_string ),
+};
+
+/** "param" command descriptor */
+static struct command_descriptor param_cmd =
+ COMMAND_DESC ( struct param_options, param_opts, 1, MAX_ARGUMENTS,
+ "<key> [<value>]" );
+
+/**
+ * The "param" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int param_exec ( int argc, char **argv ) {
+ struct param_options opts;
+ char *key;
+ char *value;
+ struct parameters *params;
+ struct parameter *param;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &param_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse key */
+ key = argv[optind];
+
+ /* Parse value */
+ value = concat_args ( &argv[ optind + 1 ] );
+ if ( ! value ) {
+ rc = -ENOMEM;
+ goto err_parse_value;
+ }
+
+ /* Identify parameter list */
+ if ( ( rc = parse_parameters ( opts.params, &params ) ) != 0 )
+ goto err_parse_parameters;
+
+ /* Add parameter */
+ param = add_parameter ( params, key, value );
+ if ( ! param ) {
+ rc = -ENOMEM;
+ goto err_add_parameter;
+ }
+
+ /* Success */
+ rc = 0;
+
+ err_add_parameter:
+ err_parse_parameters:
+ free ( value );
+ err_parse_value:
+ err_parse_options:
+ return rc;
+}
+
+/** Form parameter commands */
+struct command param_commands[] __command = {
+ {
+ .name = "params",
+ .exec = params_exec,
+ },
+ {
+ .name = "param",
+ .exec = param_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/pci_cmd.c b/qemu/roms/ipxe/src/hci/commands/pci_cmd.c
new file mode 100644
index 000000000..f5145fb35
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/pci_cmd.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/pci.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * PCI commands
+ *
+ */
+
+/** "pciscan" options */
+struct pciscan_options {};
+
+/** "pciscan" option list */
+static struct option_descriptor pciscan_opts[] = {};
+
+/** "pciscan" command descriptor */
+static struct command_descriptor pciscan_cmd =
+ COMMAND_DESC ( struct pciscan_options, pciscan_opts, 1, 1,
+ "<setting>" );
+
+/**
+ * "pciscan" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int pciscan_exec ( int argc, char **argv ) {
+ struct pciscan_options opts;
+ struct named_setting setting;
+ struct pci_device pci;
+ unsigned long prev;
+ int next;
+ int len;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &pciscan_cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse setting name */
+ if ( ( rc = parse_autovivified_setting ( argv[optind],
+ &setting ) ) != 0 )
+ goto err_parse_setting;
+
+ /* Determine starting bus:dev.fn address */
+ if ( ( len = fetchn_setting ( setting.settings, &setting.setting,
+ NULL, &setting.setting, &prev ) ) < 0 ) {
+ /* Setting not yet defined: start searching from 00:00.0 */
+ prev = 0;
+ } else {
+ /* Setting is defined: start searching from next location */
+ prev++;
+ }
+
+ /* Find next existent PCI device */
+ if ( ( next = pci_find_next ( &pci, prev ) ) < 0 ) {
+ rc = next;
+ goto err_find_next;
+ }
+
+ /* Apply default type if necessary. Use ":uint16" rather than
+ * ":busdevfn" to allow for easy inclusion within a
+ * "${pci/${location}.x.y}" constructed setting.
+ */
+ if ( ! setting.setting.type )
+ setting.setting.type = &setting_type_uint16;
+
+ /* Store setting */
+ if ( ( rc = storen_setting ( setting.settings, &setting.setting,
+ next ) ) != 0 ) {
+ printf ( "Could not store \"%s\": %s\n",
+ setting.setting.name, strerror ( rc ) );
+ goto err_store;
+ }
+
+ err_store:
+ err_find_next:
+ err_parse_setting:
+ err_parse_options:
+ return rc;
+}
+
+/** PCI commands */
+struct command pci_commands[] __command = {
+ {
+ .name = "pciscan",
+ .exec = pciscan_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/ping_cmd.c b/qemu/roms/ipxe/src/hci/commands/ping_cmd.c
new file mode 100644
index 000000000..34807696f
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/ping_cmd.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/timer.h>
+#include <usr/pingmgmt.h>
+
+/** @file
+ *
+ * Ping command
+ *
+ */
+
+/** Default payload length */
+#define PING_DEFAULT_SIZE 64
+
+/** Default timeout */
+#define PING_DEFAULT_TIMEOUT TICKS_PER_SEC
+
+/** "ping" options */
+struct ping_options {
+ /** Payload length */
+ unsigned int size;
+ /** Timeout (in ms) */
+ unsigned long timeout;
+ /** Number of packets to send (or zero for no limit) */
+ unsigned int count;
+ /** Inhibit output */
+ int quiet;
+};
+
+/** "ping" option list */
+static struct option_descriptor ping_opts[] = {
+ OPTION_DESC ( "size", 's', required_argument,
+ struct ping_options, size, parse_integer ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct ping_options, timeout, parse_timeout ),
+ OPTION_DESC ( "count", 'c', required_argument,
+ struct ping_options, count, parse_integer ),
+ OPTION_DESC ( "quiet", 'q', no_argument,
+ struct ping_options, quiet, parse_flag ),
+};
+
+/** "ping" command descriptor */
+static struct command_descriptor ping_cmd =
+ COMMAND_DESC ( struct ping_options, ping_opts, 1, 1, "<host>" );
+
+/**
+ * The "ping" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ping_exec ( int argc, char **argv ) {
+ struct ping_options opts;
+ const char *hostname;
+ int rc;
+
+ /* Initialise options */
+ memset ( &opts, 0, sizeof ( opts ) );
+ opts.size = PING_DEFAULT_SIZE;
+ opts.timeout = PING_DEFAULT_TIMEOUT;
+
+ /* Parse options */
+ if ( ( rc = reparse_options ( argc, argv, &ping_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse hostname */
+ hostname = argv[optind];
+
+ /* Ping */
+ if ( ( rc = ping ( hostname, opts.timeout, opts.size,
+ opts.count, opts.quiet ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/** Ping command */
+struct command ping_command __command = {
+ .name = "ping",
+ .exec = ping_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/poweroff_cmd.c b/qemu/roms/ipxe/src/hci/commands/poweroff_cmd.c
new file mode 100644
index 000000000..9d487d330
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/poweroff_cmd.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Marin Hannache <ipxe@mareo.fr>.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/reboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Power off command
+ *
+ */
+
+/** "poweroff" options */
+struct poweroff_options {};
+
+/** "poweroff" option list */
+static struct option_descriptor poweroff_opts[] = {};
+
+/** "poweroff" command descriptor */
+static struct command_descriptor poweroff_cmd =
+ COMMAND_DESC ( struct poweroff_options, poweroff_opts, 0, 0, NULL );
+
+/**
+ * The "poweroff" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int poweroff_exec ( int argc, char **argv ) {
+ struct poweroff_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &poweroff_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Power off system */
+ rc = poweroff();
+ if ( rc != 0 )
+ printf ( "Could not power off: %s\n", strerror ( rc ) );
+
+ return rc;
+}
+
+/** "poweroff" command */
+struct command poweroff_command __command = {
+ .name = "poweroff",
+ .exec = poweroff_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/profstat_cmd.c b/qemu/roms/ipxe/src/hci/commands/profstat_cmd.c
new file mode 100644
index 000000000..e4c9e5a24
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/profstat_cmd.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/profstat.h>
+
+/** @file
+ *
+ * Profiling commands
+ *
+ */
+
+/** "profstat" options */
+struct profstat_options {};
+
+/** "profstat" option list */
+static struct option_descriptor profstat_opts[] = {};
+
+/** "profstat" command descriptor */
+static struct command_descriptor profstat_cmd =
+ COMMAND_DESC ( struct profstat_options, profstat_opts, 0, 0, NULL );
+
+/**
+ * The "profstat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int profstat_exec ( int argc, char **argv ) {
+ struct profstat_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &profstat_cmd, &opts ) ) != 0 )
+ return rc;
+
+ profstat();
+
+ return 0;
+}
+
+/** Profiling commands */
+struct command profstat_commands[] __command = {
+ {
+ .name = "profstat",
+ .exec = profstat_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/reboot_cmd.c b/qemu/roms/ipxe/src/hci/commands/reboot_cmd.c
new file mode 100644
index 000000000..485939e42
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/reboot_cmd.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/reboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Reboot command
+ *
+ */
+
+/** "reboot" options */
+struct reboot_options {
+ /** Perform a warm reboot */
+ int warm;
+};
+
+/** "reboot" option list */
+static struct option_descriptor reboot_opts[] = {
+ OPTION_DESC ( "warm", 'w', no_argument,
+ struct reboot_options, warm, parse_flag ),
+};
+
+/** "reboot" command descriptor */
+static struct command_descriptor reboot_cmd =
+ COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, NULL );
+
+/**
+ * The "reboot" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int reboot_exec ( int argc, char **argv ) {
+ struct reboot_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &reboot_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Reboot system */
+ reboot ( opts.warm );
+
+ return 0;
+}
+
+/** "reboot" command */
+struct command reboot_command __command = {
+ .name = "reboot",
+ .exec = reboot_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/route_cmd.c b/qemu/roms/ipxe/src/hci/commands/route_cmd.c
new file mode 100644
index 000000000..cc5ffc2f2
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/route_cmd.c
@@ -0,0 +1,70 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/route.h>
+
+/** @file
+ *
+ * Routing table management commands
+ *
+ */
+
+/** "route" options */
+struct route_options {};
+
+/** "route" option list */
+static struct option_descriptor route_opts[] = {};
+
+/** "route" command descriptor */
+static struct command_descriptor route_cmd =
+ COMMAND_DESC ( struct route_options, route_opts, 0, 0, NULL );
+
+/**
+ * The "route" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int route_exec ( int argc, char **argv ) {
+ struct route_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &route_cmd, &opts ) ) != 0 )
+ return rc;
+
+ route();
+
+ return 0;
+}
+
+/** Routing table management commands */
+struct command route_commands[] __command = {
+ {
+ .name = "route",
+ .exec = route_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/sanboot_cmd.c b/qemu/roms/ipxe/src/hci/commands/sanboot_cmd.c
new file mode 100644
index 000000000..5954b6326
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/sanboot_cmd.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/uri.h>
+#include <ipxe/sanboot.h>
+#include <usr/autoboot.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * SAN commands
+ *
+ */
+
+/** "sanboot" options */
+struct sanboot_options {
+ /** Drive number */
+ unsigned int drive;
+ /** Do not describe SAN device */
+ int no_describe;
+ /** Keep SAN device */
+ int keep;
+};
+
+/** "sanboot" option list */
+static union {
+ /* "sanboot" takes all three options */
+ struct option_descriptor sanboot[3];
+ /* "sanhook" takes only --drive and --no-describe */
+ struct option_descriptor sanhook[2];
+ /* "sanunhook" takes only --drive */
+ struct option_descriptor sanunhook[1];
+} opts = {
+ .sanboot = {
+ OPTION_DESC ( "drive", 'd', required_argument,
+ struct sanboot_options, drive, parse_integer ),
+ OPTION_DESC ( "no-describe", 'n', no_argument,
+ struct sanboot_options, no_describe, parse_flag ),
+ OPTION_DESC ( "keep", 'k', no_argument,
+ struct sanboot_options, keep, parse_flag ),
+ },
+};
+
+
+/** "sanhook" command descriptor */
+static struct command_descriptor sanhook_cmd =
+ COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, 1,
+ "<root-path>" );
+
+/** "sanboot" command descriptor */
+static struct command_descriptor sanboot_cmd =
+ COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, 1,
+ "[<root-path>]" );
+
+/** "sanunhook" command descriptor */
+static struct command_descriptor sanunhook_cmd =
+ COMMAND_DESC ( struct sanboot_options, opts.sanunhook, 0, 0, NULL );
+
+/**
+ * The "sanboot", "sanhook" and "sanunhook" commands
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @v default_flags Default set of flags for uriboot()
+ * @v no_root_path_flags Additional flags to apply if no root path is present
+ * @ret rc Return status code
+ */
+static int sanboot_core_exec ( int argc, char **argv,
+ struct command_descriptor *cmd,
+ int default_flags, int no_root_path_flags ) {
+ struct sanboot_options opts;
+ const char *root_path;
+ struct uri *uri;
+ int flags;
+ int rc;
+
+ /* Initialise options */
+ memset ( &opts, 0, sizeof ( opts ) );
+ opts.drive = san_default_drive();
+
+ /* Parse options */
+ if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
+ goto err_parse_options;
+
+ /* Parse root path, if present */
+ if ( argc > optind ) {
+ root_path = argv[optind];
+ uri = parse_uri ( root_path );
+ if ( ! uri ) {
+ rc = -ENOMEM;
+ goto err_parse_uri;
+ }
+ } else {
+ root_path = NULL;
+ uri = NULL;
+ }
+
+ /* Construct flags */
+ flags = default_flags;
+ if ( opts.no_describe )
+ flags |= URIBOOT_NO_SAN_DESCRIBE;
+ if ( opts.keep )
+ flags |= URIBOOT_NO_SAN_UNHOOK;
+ if ( ! root_path )
+ flags |= no_root_path_flags;
+
+ /* Boot from root path */
+ if ( ( rc = uriboot ( NULL, uri, opts.drive, flags ) ) != 0 )
+ goto err_uriboot;
+
+ err_uriboot:
+ uri_put ( uri );
+ err_parse_uri:
+ err_parse_options:
+ return rc;
+}
+
+/**
+ * The "sanhook" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int sanhook_exec ( int argc, char **argv ) {
+ return sanboot_core_exec ( argc, argv, &sanhook_cmd,
+ ( URIBOOT_NO_SAN_BOOT |
+ URIBOOT_NO_SAN_UNHOOK ), 0 );
+}
+
+/**
+ * The "sanboot" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int sanboot_exec ( int argc, char **argv ) {
+ return sanboot_core_exec ( argc, argv, &sanboot_cmd,
+ 0, URIBOOT_NO_SAN_UNHOOK );
+}
+
+/**
+ * The "sanunhook" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int sanunhook_exec ( int argc, char **argv ) {
+ return sanboot_core_exec ( argc, argv, &sanunhook_cmd,
+ ( URIBOOT_NO_SAN_DESCRIBE |
+ URIBOOT_NO_SAN_BOOT ), 0 );
+}
+
+/** SAN commands */
+struct command sanboot_commands[] __command = {
+ {
+ .name = "sanhook",
+ .exec = sanhook_exec,
+ },
+ {
+ .name = "sanboot",
+ .exec = sanboot_exec,
+ },
+ {
+ .name = "sanunhook",
+ .exec = sanunhook_exec,
+ },
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/sync_cmd.c b/qemu/roms/ipxe/src/hci/commands/sync_cmd.c
new file mode 100644
index 000000000..adf7e3cc6
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/sync_cmd.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <string.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/sync.h>
+
+/** @file
+ *
+ * "sync" command
+ *
+ */
+
+/** "sync" options */
+struct sync_options {
+ /** Timeout */
+ unsigned long timeout;
+};
+
+/** "sync" option list */
+static struct option_descriptor sync_opts[] = {
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct sync_options, timeout, parse_timeout ),
+};
+
+/** "sync" command descriptor */
+static struct command_descriptor sync_cmd =
+ COMMAND_DESC ( struct sync_options, sync_opts, 0, 0, NULL );
+
+/**
+ * "sync" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int sync_exec ( int argc, char **argv ) {
+ struct sync_options opts;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &sync_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Wait for pending operations to complete */
+ if ( ( rc = sync ( opts.timeout ) ) != 0 ) {
+ printf ( "Operations did not complete: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** Sync commands */
+struct command sync_command __command = {
+ .name = "sync",
+ .exec = sync_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/time_cmd.c b/qemu/roms/ipxe/src/hci/commands/time_cmd.c
new file mode 100644
index 000000000..d1dd49caf
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/time_cmd.c
@@ -0,0 +1,83 @@
+/*
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * March-19-2009 @ 02:44: Added sleep command.
+ * Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/timer.h>
+
+/** @file
+ *
+ * Time commands
+ *
+ */
+
+/** "time" options */
+struct time_options {};
+
+/** "time" option list */
+static struct option_descriptor time_opts[] = {};
+
+/** "time" command descriptor */
+static struct command_descriptor time_cmd =
+ COMMAND_DESC ( struct time_options, time_opts, 1, MAX_ARGUMENTS,
+ "<command>" );
+
+/**
+ * "time" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int time_exec ( int argc, char **argv ) {
+ struct time_options opts;
+ unsigned long start;
+ unsigned long elapsed;
+ int decisecs;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &time_cmd, &opts ) ) != 0 )
+ return rc;
+
+ start = currticks();
+ rc = execv ( argv[1], argv + 1 );
+ elapsed = ( currticks() - start );
+ decisecs = ( 10 * elapsed / ticks_per_sec() );
+
+ printf ( "%s: %d.%ds\n", argv[0],
+ ( decisecs / 10 ), ( decisecs % 10 ) );
+
+ return rc;
+}
+
+/** "time" command */
+struct command time_command __command = {
+ .name = "time",
+ .exec = time_exec,
+};
diff --git a/qemu/roms/ipxe/src/hci/commands/vlan_cmd.c b/qemu/roms/ipxe/src/hci/commands/vlan_cmd.c
new file mode 100644
index 000000000..5d7298220
--- /dev/null
+++ b/qemu/roms/ipxe/src/hci/commands/vlan_cmd.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <ipxe/netdevice.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/vlan.h>
+
+/** @file
+ *
+ * VLAN commands
+ *
+ */
+
+/** "vcreate" options */
+struct vcreate_options {
+ /** VLAN tag */
+ unsigned int tag;
+ /** VLAN default priority */
+ unsigned int priority;
+};
+
+/** "vcreate" option list */
+static struct option_descriptor vcreate_opts[] = {
+ OPTION_DESC ( "tag", 't', required_argument,
+ struct vcreate_options, tag, parse_integer ),
+ OPTION_DESC ( "priority", 'p', required_argument,
+ struct vcreate_options, priority, parse_integer ),
+};
+
+/** "vcreate" command descriptor */
+static struct command_descriptor vcreate_cmd =
+ COMMAND_DESC ( struct vcreate_options, vcreate_opts, 1, 1,
+ "<trunk interface>" );
+
+/**
+ * "vcreate" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int vcreate_exec ( int argc, char **argv ) {
+ struct vcreate_options opts;
+ struct net_device *trunk;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &vcreate_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse trunk interface */
+ if ( ( rc = parse_netdev ( argv[optind], &trunk ) ) != 0 )
+ return rc;
+
+ /* Create VLAN device */
+ if ( ( rc = vlan_create ( trunk, opts.tag, opts.priority ) ) != 0 ) {
+ printf ( "Could not create VLAN device: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "vdestroy" options */
+struct vdestroy_options {};
+
+/** "vdestroy" option list */
+static struct option_descriptor vdestroy_opts[] = {};
+
+/** "vdestroy" command descriptor */
+static struct command_descriptor vdestroy_cmd =
+ COMMAND_DESC ( struct vdestroy_options, vdestroy_opts, 1, 1,
+ "<VLAN interface>" );
+
+/**
+ * "vdestroy" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int vdestroy_exec ( int argc, char **argv ) {
+ struct vdestroy_options opts;
+ struct net_device *netdev;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &vdestroy_cmd, &opts ) ) != 0 )
+ return rc;
+
+ /* Parse trunk interface */
+ if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
+ return rc;
+
+ /* Destroy VLAN device */
+ if ( ( rc = vlan_destroy ( netdev ) ) != 0 ) {
+ printf ( "Could not destroy VLAN device: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
+}
+
+/** VLAN commands */
+struct command vlan_commands[] __command = {
+ {
+ .name = "vcreate",
+ .exec = vcreate_exec,
+ },
+ {
+ .name = "vdestroy",
+ .exec = vdestroy_exec,
+ },
+};