summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/contrib/rom-o-matic
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/ipxe/contrib/rom-o-matic')
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/README62
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/bottom.php62
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/build.php311
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/customize-flags.php69
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/directions.php63
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/AUTOBOOT_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/BANNER_TIMEOUT.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMCONSOLE.html3
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMDATA.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPARITY.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPRESERVE.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSPEED.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSTOP.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CONFIG_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_PC_BIOS.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_SERIAL.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WEP.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA2.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/DHCP_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/DNS_RESOLVER.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_FTP.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_HTTP.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_TFTP.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IFMGMT_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_BZIMAGE.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_ELF.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_MULTIBOOT.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_NBI.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_PXE.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_SCRIPT.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/IWMGMT_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/NMB_RESOLVER.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/NVO_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/ROUTE_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/doc/SANBOOT_CMD.html1
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/flag-table.php531
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/globals.php51
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/index.php47
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/top.php41
-rw-r--r--qemu/roms/ipxe/contrib/rom-o-matic/utils.php684
42 files changed, 1955 insertions, 0 deletions
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/README b/qemu/roms/ipxe/contrib/rom-o-matic/README
new file mode 100644
index 000000000..b68cf775e
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/README
@@ -0,0 +1,62 @@
+ROM-o-matic web interface for building iPXE ROMs
+------------------------------------------------
+
+This web application generates iPXE images and sends them to a web
+browser.
+
+Available as part of the iPXE source code distribution, which can be
+downlaoded from http://etherboot.org/
+
+Author: Marty Connor <mdc@etherboot.org>
+License: GPLv2
+Support: http://etherboot.org/mailman/listinfo/ipxe
+ Please send support questions to the iPXE mailing list
+
+System Requirements
+-------------------
+- Apache web server
+- PHP 4+
+- Tools required to build iPXE installed on the server
+ - gcc, mtools, syslinux, perl, etc.
+
+Setup
+-----
+As distributed, it is expected that the rom-o-matic source code
+directory is in the contrib directory of a iPXE source distribution.
+
+The easiest way to do this is to simply put a iPXE source distribution
+in a web server accessible directory.
+
+If this is not the case, you will need to either edit the file
+
+ "globals.php"
+
+or create a file called
+
+ "local-config.php"
+
+containing the following lines:
+
+<?php
+$src_dir = "../../src";
+?>
+
+Then change the line beginning "$src_dir = " to the path of your iPXE
+source code tree.
+
+To make build times shorter, before you run rom-o-matic for the first time
+you should cd to the ipxe "src" directory and enter the following
+commands:
+
+ $ make
+ $ make bin/NIC
+
+This will pro-compile most object files and will make your rom-o-matic
+builds much faster.
+
+Running rom-o-matic from a web browser
+--------------------------------------
+Enter a URL like:
+
+ http://example.com/ipxe-1.x.x/contrib/rom-o-matic
+
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/bottom.php b/qemu/roms/ipxe/contrib/rom-o-matic/bottom.php
new file mode 100644
index 000000000..9ba8e3190
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/bottom.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+?>
+<hr>
+<h4>
+Resources:
+</h4>
+<ul>
+ <li>
+ Source code for iPXE images is available at
+ <a href="http://www.ipxe.org/download" target="_blank">
+ http://www.ipxe.org/download</a>
+ <br><br>
+ </li>
+ <li>
+ For general information about using iPXE, please visit the
+ <a href="http://www.ipxe.org/" target="_blank">
+ iPXE Project Home Page</a>
+ <br><br>
+ </li>
+ <li>
+ For Email-based support for iPXE please join
+ <a href="http://www.ipxe.org/contact" target="_blank">
+ iPXE Project mailing lists.</a>
+ <br><br>
+ </li>
+ <li>
+ For real-time online iPXE support via IRC please visit the
+ <a href="irc://irc.freenode.net/%23ipxe"> #ipxe channel
+ of irc.freenode.net</a>.
+ <br><br>
+ </li>
+</ul>
+<hr>
+ <font size="-1">
+ <br>
+ Please email <a href="mailto:<?php echo "${webmaster_email}" ?>"><?php echo "${webmaster_email}"?></a>
+ with questions or comments about this website.
+ </font>
+ <br><br>
+<hr>
+</body>
+</html>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/build.php b/qemu/roms/ipxe/contrib/rom-o-matic/build.php
new file mode 100644
index 000000000..b2b5bb452
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/build.php
@@ -0,0 +1,311 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// Get utility functions and set globals
+require_once "utils.php";
+
+// Make sure at least $A (action) was supplied
+if ( ! isset ( $_POST['A'] ) ) {
+
+ // Present user with form to customize build options
+ require_once "customize-flags.php";
+
+ exit ();
+
+// If user chose "Customize" option on form
+} else if ( $_POST['A'] == "Customize" ) {
+
+ // Present user with form to customize build options
+ require_once "customize-flags.php";
+
+ exit ();
+
+// The following conditional includes all other cases except "Get Image"
+// particularly the explicit ($A == "Start Over") case
+} else if ( $_POST['A'] != "Get Image" ) {
+
+ // Note that this method of redirections discards all the
+ // configuration flags, which is intentional in this case.
+
+ $dest = curDirURL ();
+ header ( "Location: $dest" );
+
+ // This next "echo" should normally not be seen, because
+ // the "header" statement above should cause immediate
+ // redirection but just in case...
+
+ echo "Try this link: <a href=\"$dest\">$dest</a>";
+
+ exit ();
+}
+
+// OK, we're going to try to use whatever options have been set
+// to build an image.
+
+// Make sure at least $nic was supplied
+if ( ! isset ( $_POST['nic'] ) ) {
+ die ( "No NIC supplied!" );
+}
+if ( isset ( $nics[$_POST['nic']] ) ) {
+ $nic = $nics[$_POST['nic']];
+} else {
+ die ( "Invalid NIC \"${_POST['nic']}\" supplied!" );
+}
+
+// Fetch flags
+$flags = get_flags ();
+
+// Get requested format
+$ofmt = isset ( $_POST['ofmt'] ) ? $_POST['ofmt'] : "";
+$fmt_extension = isset ( $ofmts[$ofmt] ) ? $ofmts[$ofmt] : 'dsk';
+
+// Handle some special cases
+
+$pci_vendor_code = "";
+$pci_device_code = "";
+
+if ( $nic == 'undionly' && $fmt_extension == "pxe" ) {
+
+ // undionly.pxe can't work because it unloads the PXE stack
+ // that it needs to communicate with, so we set the extension
+ // to .kpxe, which has a chance of working. The extension
+ // .kkpxe is another option.
+
+ $fmt_extension = "kpxe";
+
+} else if ( $fmt_extension == "rom" ) {
+
+ if ( ! isset ( $_POST['pci_vendor_code'] )
+ || ! isset ( $_POST['pci_device_code'] ) ) {
+ die ( "rom output format selected but PCI code(s) missing!" );
+ }
+
+ $pci_vendor_code = $_POST['pci_vendor_code'];
+ $pci_device_code = $_POST['pci_device_code'];
+
+ if ( $pci_vendor_code == ""
+ || $pci_device_code == "" ) {
+ die ( "rom output format selected but PCI code(s) missing!" );
+ }
+
+ // Try to be forgiving of 0xAAAA format
+ if ( strtolower ( substr ( $pci_vendor_code, 0, 2 ) ) == "0x"
+ && strlen ( $pci_vendor_code ) == 6 ) {
+ $pci_vendor_code = substr ( $pci_vendor_code, 2, 4 );
+ }
+ if ( strtolower ( substr ( $pci_device_code, 0, 2 ) ) == "0x"
+ && strlen ( $pci_device_code ) == 6 ) {
+ $pci_device_code = substr ( $pci_device_code, 2, 4 );
+ }
+
+ // concatenate the pci codes to get the $nic part of the
+ // Make target
+ $pci_codes = strtolower ( $pci_vendor_code . $pci_device_code );
+
+ $nic = $pci_codes;
+ if ( ! isset ( $roms[$pci_codes] ) ) {
+ die ( "Sorry, no network driver supports PCI codes<br>"
+ . "${_POST['pci_vendor_code']}:"
+ . "${_POST['pci_device_code']}" );
+ }
+} else if ( $fmt_extension != "rom"
+ && ( $pci_vendor_code != "" || $pci_device_code != "" ) ) {
+ die ( "'$fmt_extension' format was selected but PCI IDs were"
+ . " also entered.<br>Did you mean to select 'rom' output format"
+ . " instead?" );
+}
+
+/**
+ * remove temporary build directory
+ *
+ * @return bool true if removal is successful, false otherwise
+ */
+function rm_build_dir ()
+{
+ global $build_dir;
+ global $keep_build_dir;
+
+ if ( $keep_build_dir !== true ) {
+ rm_file_or_dir ( $build_dir );
+ }
+}
+
+// Arrange for the build directory to always be removed on exit.
+$build_dir = "";
+$keep_build_dir = false;
+register_shutdown_function ( 'rm_build_dir' );
+
+// Make temporary copy of src directory
+$build_dir = mktempcopy ( "$src_dir", "/tmp", "MDCROM" );
+$config_dir = $build_dir . "/config";
+
+// Write config files with supplied flags
+write_ipxe_config_files ( $config_dir, $flags );
+
+// Handle a possible embedded script
+$emb_script_cmd = "";
+$embedded_script = isset ( $_POST['embedded_script'] ) ? $_POST['embedded_script'] : "";
+if ( $embedded_script != "" ) {
+ $emb_script_path = "$build_dir" . "/script0.ipxe";
+
+ if ( substr ( $embedded_script, 0, 5 ) != "#!ipxe" ) {
+ $embedded_script = "#!ipxe\n" . $embedded_script;
+ }
+
+ // iPXE 0.9.7 doesn't like '\r\n" in the shebang...
+ $embedded_script = str_replace ( "\r\n", "\n", $embedded_script );
+
+ write_file_from_string ( $emb_script_path, $embedded_script );
+ $emb_script_cmd = "EMBEDDED_IMAGE=${emb_script_path}";
+}
+
+// Make the requested image. $status is set to 0 on success
+$make_target = "bin/${nic}.${fmt_extension}";
+$gitversion = exec('git describe --always --abbrev=1 --match "" 2>/dev/null');
+if ($gitversion) {
+ $gitversion = "GITVERSION=$gitversion";
+}
+
+$make_cmd = "make -C '$build_dir' '$make_target' $gitversion $emb_script_cmd 2>&1";
+
+exec ( $make_cmd, $maketxt, $status );
+
+// Uncomment the following section for debugging
+
+/**
+
+echo "<h2>build.php:</h2>";
+echo "<h3>Begin debugging output</h3>";
+
+//echo "<h3>\$_POST variables</h3>";
+//echo "<pre>"; var_dump ( $_POST ); echo "</pre>";
+
+echo "<h3>Build options:</h3>";
+echo "<strong>Build directory is:</strong> $build_dir" . "<br><br>";
+echo "\$_POST['ofmt'] = " . "\"${_POST['ofmt']}\"" . "<br>";
+echo "\$_POST['nic'] = " . "\"${_POST['nic']}\"" . "<br>";
+echo "\$_POST['pci_vendor_code'] = " . "\"${_POST['pci_vendor_code']}\"" . "<br>";
+echo "\$_POST['pci_device_code'] = " . "\"${_POST['pci_device_code']}\"" . "<br>";
+
+echo "<h3>Flags:</h3>";
+show_flags ( $flags );
+
+if ( $embedded_script != "" ) {
+ echo "<h3>Embedded script:</h3>";
+ echo "<blockquote>"."<pre>";
+ echo $embedded_script;
+ echo "</pre>"."</blockquote>";
+}
+
+echo "<h3>Make output:</h3>";
+echo "Make command: " . $make_cmd . "<br>";
+echo "Build status = <? echo $status ?>" . "<br>";
+echo "<blockquote>"."<pre>";
+echo htmlentities ( implode ("\n", $maketxt ) );
+echo "</pre>"."</blockquote>";
+// Uncomment the next line if you want to keep the
+// build directory around for inspection after building.
+$keep_build_dir = true;
+die ( "<h3>End debugging output</h3>" );
+
+**/ // End debugging section
+
+// Send ROM to browser (with extreme prejudice)
+
+if ( $status == 0 ) {
+
+ $fp = fopen("${build_dir}/${make_target}", "rb" );
+ if ( $fp > 0 ) {
+
+ $len = filesize ( "${build_dir}/${make_target}" );
+ if ( $len > 0 ) {
+
+ $buf = fread ( $fp, $len );
+ fclose ( $fp );
+
+ // Delete build directory as soon as it is not needed
+ rm_build_dir ();
+
+ $output_filename = preg_replace('/[^a-z0-9\+\.\-]/i', '', "ipxe-${version}-${nic}.${fmt_extension}");
+
+ // Try to force IE to handle downloading right.
+ Header ( "Cache-control: private");
+ Header ( "Content-Type: application/x-octet-stream; " .
+ "name=$output_filename");
+ Header ( "Content-Disposition: attachment; " .
+ "Filename=$output_filename");
+ Header ( "Content-Location: $output_filename");
+ Header ( "Content-Length: $len");
+
+ echo $buf;
+
+ exit ();
+ }
+ }
+}
+
+/*
+ * If we reach this point, the build has failed, and we provide
+ * debugging information for a potential bug report
+ *
+ */
+
+// Remove build directory
+rm_build_dir ();
+
+// Announce failure if $status from make was non-zero
+echo "<h2>Build failed. Status = " . $status . "</h2>";
+echo "<h2>build.php:</h2>";
+echo "<h3>Build options:</h3>";
+echo "<strong>Build directory is:</strong> $build_dir" . "<br><br>";
+echo "\$_POST['ofmt'] = " . "\"${_POST['ofmt']}\"" . "<br>";
+echo "\$_POST['nic'] = " . "\"${_POST['nic']}\"" . "<br>";
+echo "\$_POST['pci_vendor_code'] = " . "\"${_POST['pci_vendor_code']}\"" . "<br>";
+echo "\$_POST['pci_device_code'] = " . "\"${_POST['pci_device_code']}\"" . "<br>";
+
+echo "<h3>Flags:</h3>";
+show_flags ( $flags );
+
+if ( $embedded_script != "" ) {
+ echo "<h3>Embedded script:</h3>";
+ echo "<blockquote>"."<pre>";
+ echo $embedded_script;
+ echo "</pre>"."</blockquote>";
+}
+
+echo "<h3>Make output:</h3>";
+echo "Make command: " . $make_cmd . "<br>";
+echo "<blockquote>"."<pre>";
+echo htmlentities ( implode ("\n", $maketxt ) );
+echo "</pre>"."</blockquote>";
+
+echo "Please let us know that this happened, and paste the above output into your email message.<br>";
+
+include_once $bottom_inc;
+
+// For emacs:
+// Local variables:
+// c-basic-offset: 4
+// c-indent-level: 4
+// tab-width: 4
+// End:
+
+?>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/customize-flags.php b/qemu/roms/ipxe/contrib/rom-o-matic/customize-flags.php
new file mode 100644
index 000000000..e283921a8
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/customize-flags.php
@@ -0,0 +1,69 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// Get utility functions and set globals
+require_once "utils.php";
+
+// Prepare settable compile options for presentation to user
+$flags = default_flags ();
+
+$build = "<input type=\"submit\" name=\"A\" value=\"Get Image\">";
+$restart = "<input type=\"submit\" name=\"A\" value=\"Start Over\">";
+
+// Begin html output
+include_once $top_inc;
+
+?>
+
+<form action="build.php" method=POST>
+ <input type="hidden" name="version" value = "<?php echo $version ?>">
+ <input type="hidden" name="use_flags" value="1">
+ <h3>
+ Make changes below and press <?php echo $build ?> to create an image, <br>
+ Or press <?php echo $restart ?> to return to the main page.
+ </h3>
+ <hr>
+ <ul>
+ <?php require ( "directions.php" ); ?>
+ </ul>
+ <hr>
+ <?php echo_flags( $flags ); ?>
+ <hr>
+ <h3>Embedded Script:</h3>
+ <?php echo textarea ( "embedded_script", "", "10", "50" ); ?>
+ <br><br>
+ <hr>
+ <center><table width="35%"><tr>
+ <td align="left"> <?php echo $build; ?> </td>
+ <td align="right"> <?php echo $restart ?></td>
+ </tr></table></center>
+</form>
+
+<?php include_once $bottom_inc; ?>
+<?
+// For emacs:
+//
+// Local variables:
+// c-basic-offset: 4
+// c-indent-level: 4
+// tab-width: 4
+// End:
+?>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/directions.php b/qemu/roms/ipxe/contrib/rom-o-matic/directions.php
new file mode 100644
index 000000000..540121edd
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/directions.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+?>
+ <li>
+ Choose an output format: <?php echo keys_menubox ( "ofmt", $ofmts,
+ isset ( $_POST['ofmt'] ) ? $_POST['ofmt'] : "") ?>
+ <br><br>
+ </li>
+ <li>
+ Choose a NIC type: <?php echo keys_menubox ( "nic", $nics,
+ isset ( $_POST['nic'] ) ? $_POST['nic'] : "" ) ?>
+ <br><br>
+ </li>
+ <li>
+ <strong>( optional &mdash; for binary ROM image format only )</strong> <br><br>
+ If you choose <em>Binary ROM image</em> as your output format, you must<br>
+ enter <strong>4 hex digits</strong> below for
+ <em>PCI VENDOR CODE</em> and <em>PCI DEVICE CODE</em> <br>
+ that match the NIC device for which you are making this image.<br><br>
+ Information on how to determine NIC PCI IDs may be found
+ <a href="http://www.ipxe.org/howto/romburning"
+ target="_blank">here</a>.
+ <br><br>
+ PCI VENDOR CODE: <?php echo textbox ( "pci_vendor_code",
+ isset ( $_POST['pci_vendor_code'] ) ? $_POST['pci_vendor_code']
+ : "", 6 ); ?>
+ &nbsp;&nbsp;
+ PCI DEVICE CODE: <?php echo textbox ( "pci_device_code",
+ isset ( $_POST['pci_device_code'] ) ? $_POST['pci_device_code']
+ : "", 6 ); ?>
+ <h4>Please note for ROM images:</h4>
+ <ul>
+ <li>
+ If you enter PCI IDs, we will attempt to determine the correct<br>
+ driver to support them, and will ignore any NIC type entered
+ above.<br><br>
+ </li>
+ <li>
+ iPXE does not support all possible PCI IDs for supported
+ NICs.
+ <br><br>
+ </li>
+ </ul>
+ </li>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/AUTOBOOT_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/AUTOBOOT_CMD.html
new file mode 100644
index 000000000..444c5e602
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/AUTOBOOT_CMD.html
@@ -0,0 +1 @@
+Automatic booting
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/BANNER_TIMEOUT.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/BANNER_TIMEOUT.html
new file mode 100644
index 000000000..e135897f1
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/BANNER_TIMEOUT.html
@@ -0,0 +1 @@
+Tenths of a second for which the shell banner should appear
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMCONSOLE.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMCONSOLE.html
new file mode 100644
index 000000000..e7036c00e
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMCONSOLE.html
@@ -0,0 +1,3 @@
+Serial Console I/O port address. Common addresses are:<br>
+COM1 => 0x3f8, COM2 => 0x2f8, COM3 => 0x3e8, COM4 => 0x2e8
+
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMDATA.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMDATA.html
new file mode 100644
index 000000000..a27e27510
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMDATA.html
@@ -0,0 +1 @@
+Serial Console Data bits
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPARITY.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPARITY.html
new file mode 100644
index 000000000..14f359517
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPARITY.html
@@ -0,0 +1 @@
+Serial Console Parity: 0=None, 1=Odd, 2=Even
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPRESERVE.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPRESERVE.html
new file mode 100644
index 000000000..6e41a10b3
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMPRESERVE.html
@@ -0,0 +1 @@
+Keep settings from a previous user of the serial port \ No newline at end of file
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSPEED.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSPEED.html
new file mode 100644
index 000000000..32b685957
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSPEED.html
@@ -0,0 +1 @@
+Serial Console Baud rate
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSTOP.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSTOP.html
new file mode 100644
index 000000000..ae3fd24fb
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/COMSTOP.html
@@ -0,0 +1 @@
+Serial Console Stop bits
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONFIG_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONFIG_CMD.html
new file mode 100644
index 000000000..1256c0694
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONFIG_CMD.html
@@ -0,0 +1 @@
+Option configuration console
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_PC_BIOS.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_PC_BIOS.html
new file mode 100644
index 000000000..144eea3b9
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_PC_BIOS.html
@@ -0,0 +1 @@
+Enable Default BIOS console
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_SERIAL.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_SERIAL.html
new file mode 100644
index 000000000..f35e2ff5a
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CONSOLE_SERIAL.html
@@ -0,0 +1 @@
+Enable Serial port console
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WEP.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WEP.html
new file mode 100644
index 000000000..26fdf8a85
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WEP.html
@@ -0,0 +1 @@
+Wireless WEP encryption support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA.html
new file mode 100644
index 000000000..b218a1e91
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA.html
@@ -0,0 +1 @@
+Wireless WPA encryption support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA2.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA2.html
new file mode 100644
index 000000000..947597d13
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/CRYPTO_80211_WPA2.html
@@ -0,0 +1 @@
+Wireless WPA2 encryption support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/DHCP_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DHCP_CMD.html
new file mode 100644
index 000000000..a0c31c7c0
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DHCP_CMD.html
@@ -0,0 +1 @@
+DHCP management commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/DNS_RESOLVER.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DNS_RESOLVER.html
new file mode 100644
index 000000000..1029b9c52
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DNS_RESOLVER.html
@@ -0,0 +1 @@
+DNS resolver
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_FTP.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_FTP.html
new file mode 100644
index 000000000..7686d5d8a
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_FTP.html
@@ -0,0 +1 @@
+File Transfer Protocol
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_HTTP.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_HTTP.html
new file mode 100644
index 000000000..c28d88868
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_HTTP.html
@@ -0,0 +1 @@
+Hypertext Transfer Protocol
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_TFTP.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_TFTP.html
new file mode 100644
index 000000000..f2b31b17a
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/DOWNLOAD_PROTO_TFTP.html
@@ -0,0 +1 @@
+Trivial File Transfer Protocol
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IFMGMT_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IFMGMT_CMD.html
new file mode 100644
index 000000000..0e2b2a5e8
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IFMGMT_CMD.html
@@ -0,0 +1 @@
+Interface management commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_BZIMAGE.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_BZIMAGE.html
new file mode 100644
index 000000000..d85e5d079
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_BZIMAGE.html
@@ -0,0 +1 @@
+Linux bzImage image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_CMD.html
new file mode 100644
index 000000000..6f5acb538
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_CMD.html
@@ -0,0 +1 @@
+Image management commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_ELF.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_ELF.html
new file mode 100644
index 000000000..5e39e8bd4
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_ELF.html
@@ -0,0 +1 @@
+ELF image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_MULTIBOOT.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_MULTIBOOT.html
new file mode 100644
index 000000000..6a092a203
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_MULTIBOOT.html
@@ -0,0 +1 @@
+MultiBoot image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_NBI.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_NBI.html
new file mode 100644
index 000000000..eb78e03c3
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_NBI.html
@@ -0,0 +1 @@
+NBI image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_PXE.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_PXE.html
new file mode 100644
index 000000000..bdca3841d
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_PXE.html
@@ -0,0 +1 @@
+PXE image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_SCRIPT.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_SCRIPT.html
new file mode 100644
index 000000000..87416727f
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IMAGE_SCRIPT.html
@@ -0,0 +1 @@
+iPXE script image support
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/IWMGMT_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IWMGMT_CMD.html
new file mode 100644
index 000000000..0d5bd4a6f
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/IWMGMT_CMD.html
@@ -0,0 +1 @@
+Wireless interface management commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/NMB_RESOLVER.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/NMB_RESOLVER.html
new file mode 100644
index 000000000..a0bdc17d3
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/NMB_RESOLVER.html
@@ -0,0 +1 @@
+NMB resolver
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/NVO_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/NVO_CMD.html
new file mode 100644
index 000000000..5346f3f57
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/NVO_CMD.html
@@ -0,0 +1 @@
+Non-volatile option storage commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/ROUTE_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/ROUTE_CMD.html
new file mode 100644
index 000000000..8114c265b
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/ROUTE_CMD.html
@@ -0,0 +1 @@
+Routing table management commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/doc/SANBOOT_CMD.html b/qemu/roms/ipxe/contrib/rom-o-matic/doc/SANBOOT_CMD.html
new file mode 100644
index 000000000..2e9d84075
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/doc/SANBOOT_CMD.html
@@ -0,0 +1 @@
+SAN boot commands
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/flag-table.php b/qemu/roms/ipxe/contrib/rom-o-matic/flag-table.php
new file mode 100644
index 000000000..fe81c8029
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/flag-table.php
@@ -0,0 +1,531 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+$ofmts = array
+ ( "Floppy bootable image (.dsk)" => "dsk",
+ "SYSLINUX-based bootable floppy image (.sdsk)" => "sdsk",
+ "ISO bootable image (.iso)" => "iso",
+ "ISO bootable image with legacy floppy emulation (.liso)" => "liso",
+ "Linux kernel (SYSLINUX/GRUB/LILO) loadable image (.lkrn)" => "lkrn",
+ "USB Keychain disk image (.usb)" => "usb",
+ "ROM binary (flashable) image (.rom)" => "rom",
+ "ROM binary (flashable) for problem PMM BIOSES (.hrom)" => "hrom",
+ "PXE bootstrap loader image [Unload PXE stack] (.pxe)" => "pxe",
+ "PXE bootstrap loader keep [Keep PXE stack method 1] (.kpxe)" => "kpxe",
+ "PXE bootstrap loader keep [Keep PXE stack method 2] (.kkpxe)" => "kkpxe",
+ );
+
+$flag_table = array (
+
+ // Begin General Options:
+
+ "HDR_MISC_OPTIONS"
+ => array (
+ "flag" => "HDR_MISC_OPTIONS",
+ "hide_from_user" => "yes", // Hide even the header
+ "type" => "header",
+ "label" => "Miscellaneous Options"
+ ),
+
+ "PRODUCT_NAME"
+ => array (
+ "flag" => "PRODUCT_NAME",
+ "hide_from_user" => "yes",
+ "type" => "string",
+ "value" => "",
+ "cfgsec" => "general"
+ ),
+
+ "PRODUCT_SHORT_NAME"
+ => array (
+ "flag" => "PRODUCT_SHORT_NAME",
+ "hide_from_user" => "yes",
+ "type" => "string",
+ "value" => "iPXE",
+ "cfgsec" => "general"
+ ),
+
+ // End General Options:
+
+ // Begin Console Options:
+
+ "HDR_CONSOLE_OPTIONS"
+ => array (
+ "flag" => "HDR_CONSOLE_OPTIONS",
+ "type" => "header",
+ "label" => "Console Options"
+ ),
+
+ "CONSOLE_PCBIOS"
+ => array (
+ "flag" => "CONSOLE_PCBIOS",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "console"
+ ),
+
+ "CONSOLE_SERIAL"
+ => array (
+ "flag" => "CONSOLE_SERIAL",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "console"
+ ),
+
+ "BANNER_TIMEOUT"
+ => array (
+ "flag" => "BANNER_TIMEOUT",
+ "type" => "integer",
+ "value" => "20",
+ "cfgsec" => "general"
+ ),
+
+ "KEYBOARD_MAP"
+ => array (
+ "flag" => "KEYBOARD_MAP",
+ "type" => "choice",
+ "options" => array("al","az","bg","by","cf","cz","de","dk","es","et","fi","fr",
+ "gr","hu","il","it","lt","mk","mt","nl","no","pl","pt","ro","ru","sg","sr",
+ "th","ua","uk","us","wo"),
+ "value" => "us",
+ "cfgsec" => "console"
+ ),
+
+ "LOG_LEVEL"
+ => array (
+ "flag" => "LOG_LEVEL",
+ "type" => "choice",
+ "options" => array("LOG_NONE","LOG_EMERG","LOG_ALERT","LOG_CRIT","LOG_ERR",
+ "LOG_WARNING","LOG_NOTICE","LOG_INFO","LOG_DEBUG","LOG_ALL"),
+ "value" => "LOG_NONE",
+ "cfgsec" => "console"
+ ),
+
+ // End Console Options
+
+ // Begin Network Protocol Options:
+
+ "HDR_NETWORK_PROTOCOL_OPTIONS"
+ => array (
+ "flag" => "HDR_NETWORK_PROTOCOL_OPTIONS",
+ "hide_from_user" => "yes", // Hide even the header
+ "type" => "header",
+ "label" => "Network Protocol Options"
+ ),
+
+ "NET_PROTO_IPV4"
+ => array (
+ "flag" => "NET_PROTO_IPV4",
+ "type" => "on/off",
+ "value" => "on",
+ "hide_from_user" => "yes",
+ "cfgsec" => "general"
+ ),
+
+ // End Network Protocol Options
+
+ // Begin Serial Port configuration
+
+ "HDR_SERIAL_PORT_OPTIONS"
+ => array (
+ "flag" => "HDR_SERIAL_PORT_OPTIONS",
+ "type" => "header",
+ "label" => "Serial Port Options"
+ ),
+
+ "COMCONSOLE"
+ => array (
+ "flag" => "COMCONSOLE",
+ "type" => "integer-hex", // e.g. 0x378
+ "value" => "0x3F8",
+ "cfgsec" => "serial"
+ ),
+
+ "COMPRESERVE"
+ => array (
+ "flag" => "COMPRESERVE",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "serial"
+ ),
+
+ "COMSPEED"
+ => array (
+ "flag" => "COMSPEED",
+ "type" => "integer",
+ "value" => "115200",
+ "cfgsec" => "serial"
+ ),
+
+ "COMDATA"
+ => array (
+ "flag" => "COMDATA",
+ "type" => "integer",
+ "value" => "8",
+ "cfgsec" => "serial"
+ ),
+
+ "COMPARITY"
+ => array (
+ "flag" => "COMPARITY",
+ "type" => "integer",
+ "value" => "0",
+ "cfgsec" => "serial"
+ ),
+
+ "COMSTOP"
+ => array (
+ "flag" => "COMSTOP",
+ "type" => "integer",
+ "value" => "1",
+ "cfgsec" => "serial"
+ ),
+
+ // End Serial Options
+
+ // Begin Download Protocols
+
+ "HDR_DOWNLOAD_PROTOCOLS"
+ => array (
+ "flag" => "HDR_DOWNLOAD_PROTOCOLS",
+ "type" => "header",
+ "label" => "Download Protocols"
+ ),
+
+ "DOWNLOAD_PROTO_TFTP"
+ => array (
+ "flag" => "DOWNLOAD_PROTO_TFTP",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "DOWNLOAD_PROTO_HTTP"
+ => array (
+ "flag" => "DOWNLOAD_PROTO_HTTP",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "DOWNLOAD_PROTO_HTTPS"
+ => array (
+ "flag" => "DOWNLOAD_PROTO_HTTPS",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "general"
+ ),
+
+ "DOWNLOAD_PROTO_FTP"
+ => array (
+ "flag" => "DOWNLOAD_PROTO_FTP",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "general"
+ ),
+
+ // End Download Protocols
+
+ // Begin SAN boot protocols
+
+ "HDR_SANBOOT_PROTOCOLS"
+ => array (
+ "flag" => "HDR_SANBOOT_PROTOCOLS",
+ "type" => "header",
+ "label" => "SAN Boot Protocols"
+ ),
+
+ "SANBOOT_PROTO_ISCSI"
+ => array (
+ "flag" => "SANBOOT_PROTO_ISCSI",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "SANBOOT_PROTO_AOE"
+ => array (
+ "flag" => "SANBOOT_PROTO_AOE",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ // End SAN boot protocols
+
+ // Begin Name resolution modules
+
+ "HDR_NAME_RESOLUTION_MODULES"
+ => array (
+ "flag" => "HDR_NAME_RESOLUTION_MODULES",
+ "type" => "header",
+ "label" => "Name Resolution Modules"
+ ),
+
+ "DNS_RESOLVER"
+ => array (
+ "flag" => "DNS_RESOLVER",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "NMB_RESOLVER"
+ => array (
+ "flag" => "NMB_RESOLVER",
+ "type" => "on/off",
+ "value" => "off",
+ "hide_from_user" => "yes",
+ "cfgsec" => "general"
+ ),
+
+ // End Name resolution modules
+
+ // Begin Image types
+
+ "HDR_IMAGE_TYPES"
+ => array (
+ "flag" => "HDR_IMAGE_TYPES",
+ "type" => "header",
+ "label" => "Image Types",
+ ),
+
+ "IMAGE_ELF"
+ => array (
+ "flag" => "IMAGE_ELF",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_NBI"
+ => array (
+ "flag" => "IMAGE_NBI",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_MULTIBOOT"
+ => array (
+ "flag" => "IMAGE_MULTIBOOT",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_PXE"
+ => array (
+ "flag" => "IMAGE_PXE",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_SCRIPT"
+ => array (
+ "flag" => "IMAGE_SCRIPT",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_BZIMAGE"
+ => array (
+ "flag" => "IMAGE_BZIMAGE",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_COMBOOT"
+ => array (
+ "flag" => "IMAGE_COMBOOT",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ // End Image types
+
+ // Begin Command-line commands to include
+
+ "HDR_COMMAND_LINE_OPTIONS"
+ => array (
+ "flag" => "HDR_COMMAND_LINE_OPTIONS",
+ "type" => "header",
+ "label" => "Command Line Options",
+ ),
+
+ "AUTOBOOT_CMD"
+ => array (
+ "flag" => "AUTOBOOT_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "NVO_CMD"
+ => array (
+ "flag" => "NVO_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "CONFIG_CMD"
+ => array (
+ "flag" => "CONFIG_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IFMGMT_CMD"
+ => array (
+ "flag" => "IFMGMT_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IWMGMT_CMD"
+ => array (
+ "flag" => "IWMGMT_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "ROUTE_CMD"
+ => array (
+ "flag" => "ROUTE_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "IMAGE_CMD"
+ => array (
+ "flag" => "IMAGE_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "DHCP_CMD"
+ => array (
+ "flag" => "DHCP_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "SANBOOT_CMD"
+ => array (
+ "flag" => "SANBOOT_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "LOGIN_CMD"
+ => array (
+ "flag" => "LOGIN_CMD",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "TIME_CMD"
+ => array (
+ "flag" => "TIME_CMD",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "general"
+ ),
+
+ "DIGEST_CMD"
+ => array (
+ "flag" => "DIGEST_CMD",
+ "type" => "on/off",
+ "value" => "off",
+ "cfgsec" => "general"
+ ),
+
+ // End Command-line commands to include
+
+ // Begin Wireless options
+
+ "HDR_WIRELESS_OPTIONS"
+ => array (
+ "flag" => "HDR_WIRELESS_OPTIONS",
+ "type" => "header",
+ "label" => "Wireless Interface Options",
+ ),
+
+ "CRYPTO_80211_WEP"
+ => array (
+ "flag" => "CRYPTO_80211_WEP",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "CRYPTO_80211_WPA"
+ => array (
+ "flag" => "CRYPTO_80211_WPA",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ "CRYPTO_80211_WPA2"
+ => array (
+ "flag" => "CRYPTO_80211_WPA2",
+ "type" => "on/off",
+ "value" => "on",
+ "cfgsec" => "general"
+ ),
+
+ // End Wireless options
+
+ // Obscure options required to compile
+ "NETDEV_DISCARD_RATE"
+ => array (
+ "flag" => "NETDEV_DISCARD_RATE",
+ "type" => "integer",
+ "value" => "0",
+ "cfgsec" => "general",
+ "hide_from_user" => true
+ )
+
+ // End Obscure options
+);
+
+// For emacs:
+// Local variables:
+// c-basic-offset: 4
+// c-indent-level: 4
+// tab-width: 4
+// End:
+
+?>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/globals.php b/qemu/roms/ipxe/contrib/rom-o-matic/globals.php
new file mode 100644
index 000000000..822e4bc0b
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/globals.php
@@ -0,0 +1,51 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// Directory containing iPXE source code tree
+$src_dir = "../../src";
+
+// Compute iPXE version based on source tree
+exec ( "make -C '$src_dir' version 2>&1", $make_output, $status );
+$version = ( $status == 0 && count ( $make_output ) > 1 )
+ ? trim ( $make_output[count ( $make_output ) - 2] )
+ : "";
+
+// Email address of person responsible for this website
+$webmaster_email = "webmaster@example.com";
+
+// Files that header and footer text
+$top_inc = "top.php";
+$bottom_inc = "bottom.php";
+
+// Descriptive strings
+$header_title = "ROM-o-matic for iPXE $version";
+$html_tagline = "ROM-o-matic dynamically generates iPXE images";
+$html_title = "ROM-o-matic for iPXE $version";
+$description = "a dynamic iPXE image generator";
+
+// For emacs:
+// Local variables:
+// c-basic-offset: 4
+// c-indent-level: 4
+// tab-width: 4
+// End:
+
+?>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/index.php b/qemu/roms/ipxe/contrib/rom-o-matic/index.php
new file mode 100644
index 000000000..26585c975
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/index.php
@@ -0,0 +1,47 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// Get utility functions and set globals
+require_once "utils.php";
+
+// Begin html output
+include_once $top_inc;
+
+?>
+<form action="build.php" method=POST>
+ <input type="hidden" name="version" value = "<?php echo $version ?>">
+ <h3>To create an image:</h3>
+ <ol>
+ <?php require ( "directions.php" ); ?>
+ <li>
+ Generate and download an image:
+ <input type="submit" name="A" value="Get Image">
+ <br><br>
+ </li>
+ <li>
+ (optional) Customize image configuration options:
+ <input type="submit" name="A" value="Customize">
+ <br><br>
+ </li>
+ </ol>
+</form>
+
+<?php include_once $bottom_inc ?>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/top.php b/qemu/roms/ipxe/contrib/rom-o-matic/top.php
new file mode 100644
index 000000000..42a8e2d27
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/top.php
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<?php
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+?>
+
+<html>
+<head>
+ <link rev="made" href="mailto:<?php echo "${webmaster_email}" ?>">
+ <meta name="keywords" content="rom, etherboot, ipxe, open source, rom-o-matic.net">
+ <title><?php echo $header_title ?></title>
+ <meta name="description" content="<?php echo $description ?>">
+</head>
+<h1>
+<?php echo "$html_title" ?>&nbsp;
+</h1>
+<hr>
+<h2>
+<?php echo "$html_tagline" ?>
+</h2>
+</form>
+<hr>
diff --git a/qemu/roms/ipxe/contrib/rom-o-matic/utils.php b/qemu/roms/ipxe/contrib/rom-o-matic/utils.php
new file mode 100644
index 000000000..e0e62f447
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/rom-o-matic/utils.php
@@ -0,0 +1,684 @@
+<?php // -*- Mode: PHP; -*-
+
+/**
+ * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
+ * Copyright (C) 2009 Entity Cyber, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// Include table of user-configurable iPXE options
+require_once "flag-table.php";
+
+// Include user-shadowable globals
+require_once "globals.php";
+
+// Allow user to shadow globals
+if ( is_file ( 'local-config.php' ) ) {
+ include_once "local-config.php";
+}
+
+////
+// General utility functions
+////
+
+/**
+ * Remove undesirable characters from a given string
+ *
+ * Certain characters have the potential to be used for
+ * malicious purposes by web-based attackers. This routine
+ * filters out such characters.
+ *
+ * @param string $s supplied string
+ *
+ * @return string returned string with unwanted characters
+ * removed
+ */
+function cleanstring ( $s )
+{
+ $len = strlen ( $s );
+ if ( $len > 80 ) {
+ $s = substr ( $s, 0, 80 );
+ }
+
+ $s = trim ( $s );
+ $pos = 0;
+ $result = "";
+
+ while ( $pos < $len ) {
+ $ltr = ord ( ucfirst ( $s[$pos] ) );
+ if ( ( $ltr >= ord ( "A" ) ) && ( $ltr <= ord ( "Z" ) ) ||
+ ( $ltr >= ord ( "0" ) ) && ( $ltr <= ord ( "9" ) ) ||
+ ( $ltr == ord ( "." ) ) && ( strlen ( $result ) > 0 ) ||
+ ( $ltr == ord ( "_" ) ) ||
+ ( $ltr == ord ( "+" ) ) ||
+ ( $ltr == ord ( ":" ) ) ||
+ ( $ltr == ord ( "/" ) ) ||
+ ( $ltr == ord ( "-" ) ) ) {
+ $result .= $s[$pos];
+ }
+ $pos++;
+ }
+ return $result;
+}
+
+/**
+ * Return URL of the currently running script, minus the filename
+ *
+ * @return string the URL of the currently running script, minus the filename
+ */
+function curDirURL ()
+{
+ $dir = dirname ( $_SERVER['PHP_SELF'] );
+
+ if ( $dir == "." || $dir == "/" ) {
+ $dir = "";
+ }
+
+ $isHTTPS = ( isset ( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" );
+ $port = ( isset($_SERVER["SERVER_PORT"] ) &&
+ ( ( !$isHTTPS && $_SERVER["SERVER_PORT"] != "80" ) ||
+ ( $isHTTPS && $_SERVER["SERVER_PORT"] != "443" ) ) );
+
+ $port = ( $port ) ? ':' . $_SERVER["SERVER_PORT"] : '';
+
+ $dest = ( $isHTTPS ? 'https://' : 'http://' ) .
+ $_SERVER["SERVER_NAME"] . $dir . "/";
+
+ return $dest;
+}
+
+/**
+ * Extract NIC families and associated ROM PCI IDs from the src/bin/NIC file.
+ *
+ * $src_dir must contain the path of the iPXE src directory for this build
+ *
+ * @return array[0] array $new_nics
+ * @return array[1] array $roms
+ */
+function parse_nic_file ()
+{
+ global $src_dir;
+
+ $fd = fopen ( "$src_dir/bin/NIC", "r" );
+ if ( ! $fd ) {
+ die ( "Missing src/bin/NIC file. 'make bin/NIC'" );
+ }
+
+ $nics = array ();
+ $roms = array ();
+ $nic = "";
+
+ while ( !feof ( $fd ) ) {
+
+ $line = trim ( fgets ( $fd, 200 ) );
+
+ $first_eight_chars = substr ( $line, 0, 8 );
+ settype ( $first_eight_chars, "string" );
+
+ if ( strpos ( $first_eight_chars, "family" ) === 0 ) {
+
+ // get pathname of NIC driver
+ #list ( $dummy, $nic ) = split( "[ \t]+", $line );
+ list ( $dummy, $nic ) = explode("\t", $line);
+ settype ( $nic, "string" );
+
+ // extract filename name of driver from pathname
+ $nic = substr ( $nic, strrpos ( $nic, "/" ) + 1,
+ strlen ( $nic ) - strrpos ( $nic, "/" ) + 1 );
+
+ $nics[$nic] = $nic;
+
+ // For each ISA NIC, there can only be one ROM variant
+ $roms[$nic] = $nic;
+ }
+
+ // If the first 8 digits of the line are hex digits
+ // add this rom to the current nic family.
+
+ if ( ( strlen ( $first_eight_chars ) == 8 )
+ && ( ctype_xdigit ( $first_eight_chars ) )
+ && ( $nic != "" ) ) {
+
+ $roms[$first_eight_chars] = $nic;
+ }
+ }
+ fclose ( $fd );
+
+ // put most NICs in nice alpha order for menu
+ ksort ( $nics );
+
+ // add special cases to the top
+
+ $new_nics = array ( "all-drivers" => "ipxe",
+ "undionly" => "undionly",
+ "undi" => "undi",
+ );
+
+ foreach ( $nics as $key => $value ) {
+ // skip the undi driver
+ if ( $key != "undi" ) {
+ $new_nics[$key] = $value;
+ }
+ }
+
+ return array ( $new_nics, $roms );
+}
+
+////
+// HTML form utility functions
+////
+
+/**
+ * Return html code to create hidden form input fields
+ *
+ * @param string $flag name of form variable to set
+ * @param string $value value to give form variable
+ *
+ * @return string html code for given hidden form input field
+ */
+function hidden ( $flag, $value )
+{
+ $value = htmlentities ( $value );
+ return "<input type=\"hidden\" value=\"$value\" name=\"$flag\"></input>";
+}
+
+/**
+ * Return html code to create checkbox form input fields
+ *
+ * @param string $flag name of form variable to set
+ * @param string $value "on" means box should be checked
+ *
+ * @return string html code for given hidden form input field
+ */
+function checkbox ( $flag, $value )
+{
+ return "<input type=\"checkbox\" value=\"on\" name=\"$flag\"" .
+ ($value == "on" ? " checked>" : ">" );
+}
+
+/**
+ * Return html code to create text form input fields
+ *
+ * @param string $flag name of form variable to set
+ * @param string $value initial contents of field
+ * @param string $size size in characters of text box
+ *
+ * @return string html code for given text input field
+ */
+function textbox ( $flag, $value, $size )
+{
+ $value = htmlentities ( $value );
+ return "<input type=\"text\" size=\"$size\" value=\"$value\" name=\"$flag\">";
+}
+
+/**
+ * Return html code to create textarea form fields
+ *
+ * @param string $flag name of form variable to set
+ * @param string $value initial contents of textarea
+ * @param string $rows height of text area in rows
+ * @param string $cols width of text area in columns
+ *
+ * @return string html code for given textarea input field
+ */
+function textarea ( $flag, $value, $rows, $cols )
+{
+ $value = htmlentities ( $value );
+ return "<textarea name=\"$flag\" rows=\"$rows\" cols=\"$cols\">"
+ . $value . "</textarea>";
+}
+
+/**
+ * Return html code to create select (menu) form fields
+ *
+ * Use array of strings as menu choices
+ *
+ * @param string $flag name of form variable to set
+ * @param array $options array of strings representing choices
+ * @param string $value value of choice to select in menu
+ *
+ * @return string html code for given select (menu) input field
+ */
+function menubox ( $name, $options, $value )
+{
+ $s="<select name=\"$name\">";
+
+ foreach ( $options as $ignore => $option ) {
+ if ( !$value ) $value = $option;
+ $s .= "<option" . ( $option == $value ? " selected>" : ">" ) .
+ htmlentities ( $option ) . "</option>";
+ }
+ return $s . "</select>";
+}
+
+/**
+ * Return html code to create select (menu) form fields
+ *
+ * Use indices of array of strings as menu choices rather than
+ * the values pointed to by the indicies.
+ *
+ * @param string $flag name of form variable to set
+ * @param array $options array of strings representing choices
+ * @param string $value value of choice to select in menu
+ *
+ * @return string html code for given select (menu) input field
+ */
+function keys_menubox ( $name, $options, $value )
+{
+ $s="<select name=\"$name\">";
+
+ foreach ( $options as $option => $ignore ) {
+ if ( !$value ) $value = $option;
+ $s .= "<option" . ( $option == $value ? " selected>" : ">" ) .
+ htmlentities ( $option ) . "</option>";
+ }
+ return $s . "</select>";
+}
+
+////
+// Flag (compile option) handling functions
+////
+
+/**
+ * Return default compile options (flags)
+ *
+ * Initial compile options are in a global called $flag_table.
+ * Create and return an array containing the ones we want.
+ *
+ * @return array default compile options (flags)
+ */
+function default_flags ()
+{
+ global $flag_table;
+
+ $flags = array ();
+
+ foreach ( $flag_table as $key => $props ) {
+
+ $flag = $props["flag"];
+ $type = $props["type"];
+
+ // Fields like headers have no "value" property
+ if ( isset ( $props["value"] ) ) {
+ $flags[$flag] = $props["value"];
+ }
+ }
+ return $flags;
+}
+
+/**
+ * Return combination of default and user compile options (flags)
+ *
+ * Initial compile options are in a global called $flag_table.
+ * Compile options may have been changed via form input. We return
+ * an array with either the default value of each option or a user
+ * supplied value from form input.
+ *
+ * @return array combined default and user supplied compile options (flags)
+ */
+function get_flags ()
+{
+ global $flag_table;
+
+ $flags = default_flags ();
+
+ if ( ! isset ( $_POST["use_flags"] ) )
+ return $flags;
+
+ foreach ( $flag_table as $key => $props ) {
+
+ $flag = $props["flag"];
+ $type = $props["type"];
+
+ if ( isset ( $_POST["$flag"] ) ) {
+ $flags[$flag] = $_POST["$flag"];
+ if ( $type == "integer-hex" ) {
+ if ( strtolower ( substr ( $flags[$flag], 0, 2 ) ) != "0x" ) {
+ $flags[$flag] = "0x" . $flags[$flag];
+ }
+ }
+ } else if ( $type == "on/off" ) {
+ // Unchecked checkboxes don't pass any POST value
+ // so we must check for them specially. At this
+ // point we know that there is no $_POST value set
+ // for this option. If it is a checkbox, this means
+ // it is unchecked, so record that in $flags so we
+ // can later generate an #undef for this option.
+ $flags[$flag] = "off";
+ }
+ }
+ return $flags;
+}
+
+/**
+ * Output given value in appropriate format for iPXE config file
+ *
+ * iPXE config/*.h files use C pre-processor syntax. Output the given
+ * compile option in a format appropriate to its type
+ *
+ * @param string $key index into $flag_table for given compile option
+ * @param string $value value we wish to set compile option to
+ *
+ * @return string code to set compile option to given value
+ */
+function pprint_flag ( $key, $value )
+{
+ global $flag_table;
+
+ // Determine type of given compile option (flag)
+ $type = $flag_table[$key]["type"];
+ $s = "";
+
+ if ( $type == "on/off" && $value == "on" ) {
+ $s = "#define $key";
+ } else if ( $type == "on/off" && $value != "on" ) {
+ $s = "#undef $key";
+ } else if ( $type == "string" ) {
+ $s = ( "#define $key \"" . cleanstring ( $value ) . "\"" );
+ } else if ($type == "qstring" ) {
+ $s = ( "#define $key \\\"" . cleanstring ( $value ) . "\\\"" );
+ } else {
+ $s = "#define $key " . cleanstring ( $value );
+ }
+
+ return $s;
+}
+
+/**
+ * Output html code to display all compile options as a table
+ *
+ * @param array $flags array of compile options
+ *
+ * @return void
+ */
+function echo_flags ( $flags )
+{
+ global $flag_table;
+
+ echo "<table>\n";
+
+ foreach ( $flag_table as $key => $props ) {
+
+ // Hide parameters from users that should not be changed.
+ $hide_from_user = isset ( $props["hide_from_user"] ) ? $props["hide_from_user"] : "no";
+
+ $flag = $props["flag"];
+ $type = $props["type"];
+
+ $value = isset ( $flags[$flag] ) ? $flags[$flag] : '';
+
+ if ( $hide_from_user == "yes" ) {
+
+ // Hidden flags cannot not be set by the user. We use hidden form
+ // fields to keep them at their default values.
+ if ( $type != "header" ) {
+ echo hidden ( $flag, $value );
+ }
+
+ } else {
+
+ // Flag (iPXE compile option) should be displayed to user
+
+ if ( $type == "header" ) {
+
+ $label = $props["label"];
+ echo "<td colspan=2><hr><h3>$label</h3><hr></td>";
+
+ } else if ($type == "on/off" ) {
+
+ echo "<td>", checkbox ( $flag, $value ), "</td><td><strong>$flag</strong></td>";
+
+ } else { // don't display checkbox for non-on/off flags
+
+ echo "<td>&nbsp;</td><td><strong>$flag: </strong>";
+
+ if ($type == "choice" ) {
+ $options = $props["options"];
+ echo menubox($flag, $options, $value);
+
+ } else {
+
+ echo textbox($flag, $value, ($type == "integer" ||
+ $type == "integer-hex"
+ ? 7 : 25));
+ }
+ echo "</td>";
+ }
+ echo "</tr>\n";
+
+ if ( $type != "header" ) {
+ echo "<tr><td>&nbsp;</td>";
+ echo "<td>\n";
+ if ( is_file ( "doc/$flag.html" ) ) {
+ include_once "doc/$flag.html";
+ }
+ echo "\n</td></tr>\n";
+ }
+ }
+ }
+ echo "</table>";
+}
+
+/**
+ * Return an array of configuration sections used in all compile options
+ *
+ * $flag_table, the global list of compile options contains a 'cfgsec'
+ * property for each flag we are interested in. We return a list of
+ * all the unique cfgsec options we find in $flag_table.
+ *
+ * @return array an array of strings representing all unique cfgsec values
+ * found in $flag_table
+ */
+function get_flag_cfgsecs ()
+{
+ global $flag_table;
+ $cfgsecs = array ();
+
+ foreach ( $flag_table as $key => $props ) {
+ if ( isset ( $props['cfgsec'] ) ) {
+ $cfgsec = $props["cfgsec"];
+ $cfgsecs[$cfgsec] = $cfgsec;
+ }
+ }
+ return $cfgsecs;
+}
+
+////
+// File and directory handling functions
+////
+
+/**
+ * Create a copy of a given source directory to a given destination
+ *
+ * Since we are going to modify the source directory, we create a copy
+ * of the directory with a unique name in the given destination directory.
+ * We supply a prefix for the tempnam call to prepend to the random filename
+ * it generates.
+ *
+ * @param string $src source directory
+ * @param string $dst destination directory
+ * @param string $prefix string to append to directory created
+ *
+ * @return string absolute path to destination directory
+ */
+function mktempcopy ( $src, $dst, $prefix )
+{
+ if ( $src[0] != "/" ) {
+ $src = dirname ( $_SERVER['SCRIPT_FILENAME'] ) . "/" . $src;
+ }
+
+ // Create a file in the given destination directory with a unique name
+ $dir = tempnam ( $dst, $prefix );
+
+ // Delete the file just created, since it would interfere with the copy we
+ // are about to do. We only care that the dir name we copy to is unique.
+ unlink ( $dir );
+
+ exec ( "/bin/cp -a '$src' '$dir' 2>&1", $cpytxt, $status );
+
+ if ( $status != 0 ) {
+ die ( "src directory copy failed!" );
+ }
+ return $dir;
+}
+
+/**
+ * Write iPXE config files based on value of given flags
+ *
+ * iPXE compile options are stored in src/config/*.h .
+ * We write out a config file for each set of options.
+ *
+ * @param string $config_dir directory to write .h files to
+ * @param array $flags array of compile options for this build
+ *
+ * @return void
+ */
+function write_ipxe_config_files ( $config_dir, $flags )
+{
+ global $flag_table;
+
+ $cfgsecs = get_flag_cfgsecs ();
+
+ foreach ( $cfgsecs as $cfgsec ) {
+
+ $fname = $config_dir . "/" . $cfgsec . ".h";
+
+ $fp = fopen ( $fname, "wb" );
+ if ( $fp <= 0 ) {
+ die ( "Unable to open $fname file for output!" );
+ }
+
+ $ifdef_secname = "CONFIG_" . strtoupper ( $cfgsec ) . "_H";
+
+ fwrite ( $fp, "#ifndef ${ifdef_secname}\n" );
+ fwrite ( $fp, "#define ${ifdef_secname}\n" );
+ fwrite ( $fp, "#include <config/defaults.h>\n" );
+
+ foreach ( $flags as $key => $value ) {
+ // When the flag matches this section name, write it out
+ if ( $flag_table[$key]["cfgsec"] == $cfgsec ) {
+ fwrite ( $fp, pprint_flag ( $key, $value ) . "\n" );
+ }
+ }
+ fwrite ( $fp, "#endif /* ${ifdef_secname} */\n" );
+ fclose ( $fp );
+ }
+}
+
+/**
+ * Output a string to a file
+ *
+ * Output a given string to a given pathname. The file will be created if
+ * necessary, and the string will replace the file's contents in all cases.
+ *
+ * @param string $fname pathname of file to output string to
+ * @param string $ftext text to output to file
+ *
+ * @return void
+ */
+function write_file_from_string ( $fname, $ftext )
+{
+ $fp = fopen ( $fname, "wb" );
+ if ( ! $fp ) {
+ die ( "Unable to open $fname file for output!" );
+ }
+ fwrite ( $fp, $ftext );
+ fclose ( $fp );
+}
+
+/**
+ * Delete a file or recursively delete a directory tree
+ *
+ * @param string $file_or_dir_name name of file or directory to delete
+ * @return bool Returns TRUE on success, FALSE on failure
+ */
+function rm_file_or_dir ( $file_or_dir_name )
+{
+ if ( ! file_exists ( $file_or_dir_name ) ) {
+ return false;
+ }
+
+ if ( is_file ( $file_or_dir_name ) || is_link ( $file_or_dir_name ) ) {
+ return unlink ( $file_or_dir_name );
+ }
+
+ $dir = dir ( $file_or_dir_name );
+ while ( ( $dir_entry = $dir->read () ) !== false ) {
+
+ if ( $dir_entry == '.' || $dir_entry == '..') {
+ continue;
+ }
+ rm_file_or_dir ( $file_or_dir_name . '/' . $dir_entry );
+ }
+ $dir->close();
+
+ return rmdir ( $file_or_dir_name );
+}
+
+////
+// Debugging functions
+////
+
+/**
+ * Emit html code to display given array of compile options (flags)
+ *
+ * @param array $flags array of compile options for this build
+ *
+ * @return void
+ */
+function show_flags ( $flags )
+{
+ echo ( "\$flags contains " . count ( $flags ) . " elements:" . "<br>" );
+
+ foreach ( $flags as $key => $flag ) {
+ echo ( "\$flags[" . $key . "]=" . "\"$flag\"" . "<br>" );
+ }
+}
+
+/**
+ * Emit HTML code to display default array of compile options (flags)
+ *
+ * $flag_table contains default compile options and properties. This
+ * routine outputs HTML code to display all properties of $flag_table.
+ *
+ * @return void
+ */
+function dump_flag_table ()
+{
+ global $flag_table;
+
+ echo ( "\$flag_table contains " . count ( $flag_table ) . " elements:" . "<br>" );
+
+ foreach ( $flag_table as $key => $props ) {
+ print ( "flag_table[" . $key . "] = " . "<br>" );
+
+ foreach ( $props as $key2 => $props2 ) {
+ print ( "&nbsp;&nbsp;&nbsp;" . $key2 . " = " . $props2 . "<br>" );
+ }
+ }
+}
+
+// Parse src/bin/NIC file
+list ( $nics, $roms ) = parse_nic_file ();
+
+// For emacs:
+// Local variables:
+// c-basic-offset: 4
+// c-indent-level: 4
+// tab-width: 4
+// End:
+
+?>