summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/contrib
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/ipxe/contrib
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff)
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/ipxe/contrib')
-rw-r--r--qemu/roms/ipxe/contrib/README9
-rw-r--r--qemu/roms/ipxe/contrib/errdb/.gitignore1
-rwxr-xr-xqemu/roms/ipxe/contrib/errdb/errdb.pl109
-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
-rw-r--r--qemu/roms/ipxe/contrib/vm/.gitignore6
-rw-r--r--qemu/roms/ipxe/contrib/vm/Makefile7
-rw-r--r--qemu/roms/ipxe/contrib/vm/bochs-writable-ROM-patch15
-rw-r--r--qemu/roms/ipxe/contrib/vm/bochsrc.txt1131
-rwxr-xr-xqemu/roms/ipxe/contrib/vm/cow49
-rwxr-xr-xqemu/roms/ipxe/contrib/vm/serial-console278
51 files changed, 3560 insertions, 0 deletions
diff --git a/qemu/roms/ipxe/contrib/README b/qemu/roms/ipxe/contrib/README
new file mode 100644
index 000000000..e77d46907
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/README
@@ -0,0 +1,9 @@
+Most of the content that was previously in this directory has been
+moved to a separate git repository:
+
+ http://git.etherboot.org/?p=contrib.git;a=summary
+
+or the Etherboot Project wiki:
+
+ http://etherboot.org/
+
diff --git a/qemu/roms/ipxe/contrib/errdb/.gitignore b/qemu/roms/ipxe/contrib/errdb/.gitignore
new file mode 100644
index 000000000..95bf5c3cd
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/errdb/.gitignore
@@ -0,0 +1 @@
+errors.db
diff --git a/qemu/roms/ipxe/contrib/errdb/errdb.pl b/qemu/roms/ipxe/contrib/errdb/errdb.pl
new file mode 100755
index 000000000..6423d8347
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/errdb/errdb.pl
@@ -0,0 +1,109 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+errdb.pl
+
+=head1 SYNOPSIS
+
+errdb.pl [options] ../../src/bin/errors
+
+Options:
+
+ -d,--database=db Specify path to errors.db
+ -h,--help Display brief help message
+ -v,--verbose Increase verbosity
+ -q,--quiet Decrease verbosity
+
+=cut
+
+use Getopt::Long;
+use Pod::Usage;
+use DBI;
+use strict;
+use warnings;
+
+# Parse command-line options
+my $verbosity = 0;
+my $errdb = "errors.db";
+Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
+GetOptions (
+ 'database|d=s' => sub { shift; $errdb = shift; },
+ 'verbose|v+' => sub { $verbosity++; },
+ 'quiet|q+' => sub { $verbosity--; },
+ 'help|h' => sub { pod2usage ( 1 ); },
+) or die "Could not parse command-line options\n";
+pod2usage ( 1 ) unless @ARGV >= 1;
+
+# Open database
+my $dbh = DBI->connect ( "dbi:SQLite:dbname=".$errdb, "", "",
+ { RaiseError => 1, PrintError => 0 } );
+$dbh->begin_work();
+
+# Create errors table if necessary
+eval {
+ $dbh->selectall_arrayref ( "SELECT * FROM errors LIMIT 1" );
+};
+if ( $@ ) {
+ print "Creating errors table\n" if $verbosity >= 1;
+ $dbh->do ( "CREATE TABLE errors (".
+ " errno char(8) NOT NULL,".
+ " description text NOT NULL,".
+ " PRIMARY KEY ( errno ) )" );
+}
+
+# Create xrefs table if necessary
+eval {
+ $dbh->selectall_arrayref ( "SELECT * FROM xrefs LIMIT 1" );
+};
+if ( $@ ) {
+ print "Creating xrefs table\n" if $verbosity >= 1;
+ $dbh->do ( "CREATE TABLE xrefs (".
+ " errno char(8) NOT NULL,".
+ " filename text NOT NULL,".
+ " line integer NOT NULL,".
+ " UNIQUE ( errno, filename, line ),".
+ " FOREIGN KEY ( errno ) REFERENCES errors ( errno ) )" );
+ $dbh->do ( "CREATE INDEX xrefs_errno ON xrefs ( errno )" );
+}
+
+# Parse input file(s)
+my $errors = {};
+my $xrefs = {};
+while ( <> ) {
+ chomp;
+ ( my $errno, my $filename, my $line, my $description ) = split ( /\t/ );
+ $errno = substr ( $errno, 0, 6 ) unless $errno =~ /^7f/;
+ $errors->{$errno} = $description;
+ $xrefs->{$errno} ||= {};
+ $xrefs->{$errno}->{$filename} ||= {};
+ $xrefs->{$errno}->{$filename}->{$line} ||= 1;
+}
+
+# Ensure all errors are present in database
+my $error_update =
+ $dbh->prepare ( "UPDATE errors SET description = ? WHERE errno = ?" );
+my $error_insert = $dbh->prepare ( "INSERT INTO errors VALUES ( ?, ? )" );
+while ( ( my $errno, my $description ) = each %$errors ) {
+ print "Error ".$errno." is \"".$description."\"\n" if $verbosity >= 2;
+ if ( $error_update->execute ( $description, $errno ) == 0 ) {
+ $error_insert->execute ( $errno, $description );
+ }
+}
+
+# Replace xrefs in database
+$dbh->do ( "DELETE FROM xrefs" );
+my $xref_insert = $dbh->prepare ( "INSERT INTO xrefs VALUES ( ?, ?, ? )" );
+while ( ( my $errno, my $xref_errno ) = each %$xrefs ) {
+ while ( ( my $filename, my $xref_filename ) = each %$xref_errno ) {
+ foreach my $line ( keys %$xref_filename ) {
+ print "Error ".$errno." is used at ".$filename." line ".$line."\n"
+ if $verbosity >= 2;
+ $xref_insert->execute ( $errno, $filename, $line );
+ }
+ }
+}
+
+# Close database
+$dbh->commit();
+$dbh->disconnect();
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:
+
+?>
diff --git a/qemu/roms/ipxe/contrib/vm/.gitignore b/qemu/roms/ipxe/contrib/vm/.gitignore
new file mode 100644
index 000000000..610792ed8
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/.gitignore
@@ -0,0 +1,6 @@
+bochsout.txt
+parport.out
+ne2k-tx.log
+ne2k-txdump.txt
+bochs
+qemu
diff --git a/qemu/roms/ipxe/contrib/vm/Makefile b/qemu/roms/ipxe/contrib/vm/Makefile
new file mode 100644
index 000000000..3c0e645ab
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/Makefile
@@ -0,0 +1,7 @@
+all : serial-console.1
+
+%.1 : %
+ pod2man $< > $@
+
+clean :
+ rm -f serial-console.1
diff --git a/qemu/roms/ipxe/contrib/vm/bochs-writable-ROM-patch b/qemu/roms/ipxe/contrib/vm/bochs-writable-ROM-patch
new file mode 100644
index 000000000..dc586ddee
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/bochs-writable-ROM-patch
@@ -0,0 +1,15 @@
+--- memory/memory.cc 18 Oct 2008 18:10:14 -0000 1.71
++++ memory/memory.cc 21 Oct 2008 19:47:07 -0000
+@@ -172,7 +172,11 @@
+ break;
+
+ case 0x0: // Writes to ROM, Inhibit
+- BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
++ if ((a20addr & 0xfffe0000) == 0x000e0000) {
++ BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
++ } else {
++ BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ] = *data_ptr;
++ }
+ break;
+
+ default:
diff --git a/qemu/roms/ipxe/contrib/vm/bochsrc.txt b/qemu/roms/ipxe/contrib/vm/bochsrc.txt
new file mode 100644
index 000000000..d0f12504b
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/bochsrc.txt
@@ -0,0 +1,1131 @@
+# You may now use double quotes around pathnames, in case
+# your pathname includes spaces.
+
+#=======================================================================
+# PLUGIN_CTRL:
+# Controls the presence of optional device plugins. These plugins are loaded
+# directly with this option and some of them install a config option that is
+# only available when the plugin device is loaded. The value "1" means to load
+# the plugin and "0" will unload it (if loaded before).
+# These plugins are currently supported: 'biosdev', 'e1000', 'es1370',
+# 'extfpuirq', 'gameport', 'iodebug', 'ne2k', 'parallel', 'pcidev', 'pcipnic',
+# 'sb16', 'serial', 'speaker', 'unmapped', 'usb_ohci', 'usb_uhci' and 'usb_xhci'.
+#=======================================================================
+plugin_ctrl: unmapped=1, biosdev=1, speaker=1, e1000=1, parallel=1, serial=1
+
+#=======================================================================
+# CONFIG_INTERFACE
+#
+# The configuration interface is a series of menus or dialog boxes that
+# allows you to change all the settings that control Bochs's behavior.
+# Depending on the platform there are up to 3 choices of configuration
+# interface: a text mode version called "textconfig" and two graphical versions
+# called "win32config" and "wx". The text mode version uses stdin/stdout and
+# is always compiled in, unless Bochs is compiled for wx only. The choice
+# "win32config" is only available on win32 and it is the default there.
+# The choice "wx" is only available when you use "--with-wx" on the configure
+# command. If you do not write a config_interface line, Bochs will
+# choose a default for you.
+#
+# NOTE: if you use the "wx" configuration interface, you must also use
+# the "wx" display library.
+#=======================================================================
+#config_interface: textconfig
+#config_interface: win32config
+#config_interface: wx
+
+#=======================================================================
+# DISPLAY_LIBRARY
+#
+# The display library is the code that displays the Bochs VGA screen. Bochs
+# has a selection of about 10 different display library implementations for
+# different platforms. If you run configure with multiple --with-* options,
+# the display_library command lets you choose which one you want to run with.
+# If you do not write a display_library line, Bochs will choose a default for
+# you.
+#
+# The choices are:
+# x use X windows interface, cross platform
+# win32 use native win32 libraries
+# carbon use Carbon library (for MacOS X)
+# macintosh use MacOS pre-10
+# amigaos use native AmigaOS libraries
+# sdl use SDL library, cross platform
+# svga use SVGALIB library for Linux, allows graphics without X11
+# term text only, uses curses/ncurses library, cross platform
+# rfb provides an interface to AT&T's VNC viewer, cross platform
+# wx use wxWidgets library, cross platform
+# nogui no display at all
+#
+# NOTE: if you use the "wx" configuration interface, you must also use
+# the "wx" display library.
+#
+# Specific options:
+# Some display libraries now support specific options to control their
+# behaviour. These options are supported by more than one display library:
+#
+# "gui_debug" - use GTK debugger gui (sdl, x) / Win32 debugger gui (win32)
+# "hideIPS" - disable IPS output in status bar (sdl, wx, x)
+# "nokeyrepeat" - turn off host keyboard repeat (sdl, win32, x)
+#
+# See the examples below for other currently supported options.
+#=======================================================================
+#display_library: amigaos
+#display_library: carbon
+#display_library: macintosh
+#display_library: nogui
+#display_library: rfb, options="timeout=60" # time to wait for client
+#display_library: sdl, options="fullscreen" # startup in fullscreen mode
+#display_library: term
+#display_library: win32
+#display_library: wx
+#display_library: x
+
+#=======================================================================
+# ROMIMAGE:
+# The ROM BIOS controls what the PC does when it first powers on.
+# Normally, you can use a precompiled BIOS in the source or binary
+# distribution called BIOS-bochs-latest. The ROM BIOS is usually loaded
+# starting at address 0xf0000, and it is exactly 64k long. Another option
+# is 128k BIOS which is loaded at address 0xe0000.
+# You can also use the environment variable $BXSHARE to specify the
+# location of the BIOS.
+# The usage of external large BIOS images (up to 512k) at memory top is
+# now supported, but we still recommend to use the BIOS distributed with
+# Bochs. The start address optional, since it can be calculated from image size.
+#=======================================================================
+#romimage: file=$BXSHARE/BIOS-bochs-latest
+#romimage: file=bios/seabios-1.6.3.bin
+#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory top
+romimage: file=bochs/bios/BIOS-bochs-latest
+
+#=======================================================================
+# CPU:
+# This defines cpu-related parameters inside Bochs:
+#
+# MODEL:
+# Selects CPU configuration to emulate from pre-defined list of all
+# supported configurations. When this option is used, the CPUID option
+# has no effect anymore.
+#
+# CPU configurations that can be selected:
+# -----------------------------------------------------------------
+# pentium_mmx Intel Pentium MMX
+# amd_k6_2_chomper AMD-K6(tm) 3D processor (Chomper)
+# p2_klamath Intel Pentium II (Klamath)
+# p3_katmai Intel Pentium III (Katmai)
+# p4_willamette Intel(R) Pentium(R) 4 (Willamette)
+# core_duo_t2400_yonah Intel(R) Core(TM) Duo CPU T2400 (Yonah)
+# atom_n270 Intel(R) Atom(TM) CPU N270
+# athlon64_clawhammer AMD Athlon(tm) 64 Processor 2800+ (Clawhammer)
+# athlon64_venice AMD Athlon(tm) 64 Processor 3000+ (Venice)
+# turion64_tyler AMD Turion(tm) 64 X2 Mobile TL-60 (Tyler)
+# phenom_8650_toliman AMD Phenom X3 8650 (Toliman)
+# p4_prescott_celeron_336 Intel(R) Celeron(R) 336 (Prescott)
+# core2_penryn_t9600 Intel Mobile Core 2 Duo T9600 (Penryn)
+# corei5_lynnfield_750 Intel(R) Core(TM) i5 750 (Lynnfield)
+# corei5_arrandale_m520 Intel(R) Core(TM) i5 M 520 (Arrandale)
+# corei7_sandy_bridge_2600k Intel(R) Core(TM) i7-2600K (Sandy Bridge)
+# corei7_ivy_bridge_3770k Intel(R) Core(TM) i7-3770K CPU (Ivy Bridge)
+#
+# COUNT:
+# Set the number of processors:cores per processor:threads per core
+# when Bochs is compiled for SMP emulation.
+# Bochs currently supports up to 8 threads running simultaniosly.
+# If Bochs is compiled without SMP support, it won't accept values
+# different from 1.
+#
+# QUANTUM:
+# Maximum amount of instructions allowed to execute by processor before
+# returning control to another cpu. This option exists only in Bochs
+# binary compiled with SMP support.
+#
+# RESET_ON_TRIPLE_FAULT:
+# Reset the CPU when triple fault occur (highly recommended) rather than
+# PANIC. Remember that if you trying to continue after triple fault the
+# simulation will be completely bogus !
+#
+# CPUID_LIMIT_WINNT:
+# Determine whether to limit maximum CPUID function to 2. This mode is
+# required to workaround WinNT installation and boot issues.
+#
+# MSRS:
+# Define path to user CPU Model Specific Registers (MSRs) specification.
+# See example in msrs.def.
+#
+# IGNORE_BAD_MSRS:
+# Ignore MSR references that Bochs does not understand; print a warning
+# message instead of generating #GP exception. This option is enabled
+# by default but will not be avaiable if configurable MSRs are enabled.
+#
+# MWAIT_IS_NOP:
+# When this option is enabled MWAIT will not put the CPU into a sleep state.
+# This option exists only if Bochs compiled with --enable-monitor-mwait.
+#
+# IPS:
+# Emulated Instructions Per Second. This is the number of IPS that bochs
+# is capable of running on your machine. You can recompile Bochs with
+# --enable-show-ips option enabled, to find your host's capability.
+# Measured IPS value will then be logged into your log file or shown
+# in the status bar (if supported by the gui).
+#
+# IPS is used to calibrate many time-dependent events within the bochs
+# simulation. For example, changing IPS affects the frequency of VGA
+# updates, the duration of time before a key starts to autorepeat, and
+# the measurement of BogoMips and other benchmarks.
+#
+# Examples:
+#
+# Bochs Machine/Compiler Mips
+# ______________________________________________________________________
+# 2.4.6 3.4Ghz Intel Core i7 2600 with Win7x64/g++ 4.5.2 85 to 95 Mips
+# 2.3.7 3.2Ghz Intel Core 2 Q9770 with WinXP/g++ 3.4 50 to 55 Mips
+# 2.3.7 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 38 to 43 Mips
+# 2.2.6 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 21 to 25 Mips
+# 2.2.6 2.1Ghz Athlon XP with Linux 2.6/g++ 3.4 12 to 15 Mips
+#=======================================================================
+cpu: model=core2_penryn_t9600, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
+cpu: cpuid_limit_winnt=0
+
+#=======================================================================
+# CPUID:
+#
+# This defines features and functionality supported by Bochs emulated CPU.
+# The option has no offect if CPU model was selected in CPU option.
+#
+# MMX:
+# Select MMX instruction set support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5.
+#
+# APIC:
+# Select APIC configuration (LEGACY/XAPIC/XAPIC_EXT/X2APIC).
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5.
+#
+# SEP:
+# Select SYSENTER/SYSEXIT instruction set support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# SSE:
+# Select SSE instruction set support.
+# Any of NONE/SSE/SSE2/SSE3/SSSE3/SSE4_1/SSE4_2 could be selected.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# SSE4A:
+# Select AMD SSE4A instructions support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# AES:
+# Select AES instruction set support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# MOVBE:
+# Select MOVBE Intel(R) Atom instruction support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# XSAVE:
+# Select XSAVE extensions support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# XSAVEOPT:
+# Select XSAVEOPT instruction support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# AVX:
+# Select AVX/AVX2 instruction set support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# AVX_F16C:
+# Select AVX float16 convert instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# AVX_FMA:
+# Select AVX fused multiply add (FMA) instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# BMI:
+# Select BMI1/BMI2 instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# XOP:
+# Select AMD XOP instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# FMA4:
+# Select AMD four operand FMA instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# TBM:
+# Select AMD Trailing Bit Manipulation (TBM) instructions support.
+# This option exists only if Bochs compiled with --enable-avx option.
+#
+# X86-64:
+# Enable x86-64 and long mode support.
+# This option exists only if Bochs compiled with x86-64 support.
+#
+# 1G_PAGES:
+# Enable 1G page size support in long mode.
+# This option exists only if Bochs compiled with x86-64 support.
+#
+# PCID:
+# Enable Process-Context Identifiers (PCID) support in long mode.
+# This option exists only if Bochs compiled with x86-64 support.
+#
+# FSGSBASE:
+# Enable GS/GS BASE access instructions support in long mode.
+# This option exists only if Bochs compiled with x86-64 support.
+#
+# SMEP:
+# Enable Supervisor Mode Execution Protection (SMEP) support.
+# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
+#
+# MWAIT:
+# Select MONITOR/MWAIT instructions support.
+# This option exists only if Bochs compiled with --enable-monitor-mwait.
+#
+# VMX:
+# Select VMX extensions emulation support.
+# This option exists only if Bochs compiled with --enable-vmx option.
+#
+# VENDOR_STRING:
+# Set the CPUID vendor string returned by CPUID(0x0). This should be a
+# twelve-character ASCII string.
+#
+# BRAND_STRING:
+# Set the CPUID vendor string returned by CPUID(0x80000002 .. 0x80000004).
+# This should be at most a forty-eight-character ASCII string.
+#
+# FAMILY:
+# Set model information returned by CPUID. Default family value determined
+# by configure option --enable-cpu-level.
+#
+# MODEL:
+# Set model information returned by CPUID. Default model value is 3.
+#
+# STEPPING:
+# Set stepping information returned by CPUID. Default stepping value is 3.
+#=======================================================================
+#cpuid: x86_64=1, mmx=1, sep=1, sse=sse4_2, apic=xapic, aes=1, movbe=1, xsave=1
+#cpuid: family=6, model=0x1a, stepping=5
+
+#=======================================================================
+# MEMORY
+# Set the amount of physical memory you want to emulate.
+#
+# GUEST:
+# Set amount of guest physical memory to emulate. The default is 32MB,
+# the maximum amount limited only by physical address space limitations.
+#
+# HOST:
+# Set amount of host memory you want to allocate for guest RAM emulation.
+# It is possible to allocate less memory than you want to emulate in guest
+# system. This will fake guest to see the non-existing memory. Once guest
+# system touches new memory block it will be dynamically taken from the
+# memory pool. You will be warned (by FATAL PANIC) in case guest already
+# used all allocated host memory and wants more.
+#
+#=======================================================================
+memory: guest=512, host=256
+
+#=======================================================================
+# OPTROMIMAGE[1-4]:
+# You may now load up to 4 optional ROM images. Be sure to use a
+# read-only area, typically between C8000 and EFFFF. These optional
+# ROM images should not overwrite the rombios (located at
+# F0000-FFFFF) and the videobios (located at C0000-C7FFF).
+# Those ROM images will be initialized by the bios if they contain
+# the right signature (0x55AA) and a valid checksum.
+# It can also be a convenient way to upload some arbitrary code/data
+# in the simulation, that can be retrieved by the boot loader
+#=======================================================================
+#optromimage1: file=optionalrom.bin, address=0xd0000
+#optromimage2: file=optionalrom.bin, address=0xd1000
+#optromimage3: file=optionalrom.bin, address=0xd2000
+#optromimage4: file=optionalrom.bin, address=0xd3000
+optromimage1: file=../../src/bin/intel.rom, address=0xcb000
+
+#optramimage1: file=/path/file1.img, address=0x0010000
+#optramimage2: file=/path/file2.img, address=0x0020000
+#optramimage3: file=/path/file3.img, address=0x0030000
+#optramimage4: file=/path/file4.img, address=0x0040000
+
+#=======================================================================
+# VGAROMIMAGE
+# You now need to load a VGA ROM BIOS into C0000.
+#=======================================================================
+#vgaromimage: file=bios/VGABIOS-elpin-2.40
+#vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
+#vgaromimage: file=bios/VGABIOS-lgpl-latest-cirrus
+vgaromimage: file=bochs/bios/VGABIOS-lgpl-latest
+
+#=======================================================================
+# VGA:
+# This defines parameters related to the VGA display
+#
+# EXTENSION
+# Here you can specify the display extension to be used. With the value
+# 'none' you can use standard VGA with no extension. Other supported
+# values are 'vbe' for Bochs VBE and 'cirrus' for Cirrus SVGA support.
+#
+# UPDATE_FREQ
+# The VGA update frequency is based on the emulated clock and the default
+# value is 5. Keep in mind that you must tweak the 'cpu: ips=N' directive
+# to be as close to the number of emulated instructions-per-second your
+# workstation can do, for this to be accurate. If the realtime sync is
+# enabled with the 'clock' option, the value is based on the real time.
+# This parameter can be changed at runtime.
+#
+# Examples:
+# vga: extension=cirrus, update_freq=10
+#=======================================================================
+#vga: extension=vbe, update_freq=5
+
+#=======================================================================
+# FLOPPYA:
+# Point this to pathname of floppy image file or device
+# This should be of a bootable floppy(image/device) if you're
+# booting from 'a' (or 'floppy').
+#
+# You can set the initial status of the media to 'ejected' or 'inserted'.
+# floppya: 2_88=path, status=ejected (2.88M 3.5" media)
+# floppya: 1_44=path, status=inserted (1.44M 3.5" media)
+# floppya: 1_2=path, status=ejected (1.2M 5.25" media)
+# floppya: 720k=path, status=inserted (720K 3.5" media)
+# floppya: 360k=path, status=inserted (360K 5.25" media)
+# floppya: 320k=path, status=inserted (320K 5.25" media)
+# floppya: 180k=path, status=inserted (180K 5.25" media)
+# floppya: 160k=path, status=inserted (160K 5.25" media)
+# floppya: image=path, status=inserted (guess media type from image size)
+# floppya: 1_44=vvfat:path, status=inserted (use directory as VFAT media)
+# floppya: type=1_44 (1.44M 3.5" floppy drive, no media)
+#
+# The path should be the name of a disk image file. On Unix, you can use a raw
+# device name such as /dev/fd0 on Linux. On win32 platforms, use drive letters
+# such as a: or b: as the path. The parameter 'image' works with image files
+# only. In that case the size must match one of the supported types.
+# The parameter 'type' can be used to enable the floppy drive without media
+# and status specified. Usually the drive type is set up based on the media type.
+# The optional parameter 'write_protected' can be used to control the media
+# write protect switch. By default it is turned off.
+#=======================================================================
+#floppya: 1_44=/dev/fd0, status=inserted
+#floppya: image=../1.44, status=inserted
+#floppya: 1_44=/dev/fd0H1440, status=inserted
+#floppya: 1_2=../1_2, status=inserted
+#floppya: 1_44=a:, status=inserted
+#floppya: 1_44=a.img, status=inserted, write_protected=1
+#floppya: 1_44=/dev/rfd0a, status=inserted
+floppya: 1_44=../../src/bin/ipxe.dsk, status=inserted
+
+#=======================================================================
+# FLOPPYB:
+# See FLOPPYA above for syntax
+#=======================================================================
+#floppyb: 1_44=b:, status=inserted
+#floppyb: 1_44=b.img, status=inserted
+
+#=======================================================================
+# ATA0, ATA1, ATA2, ATA3
+# ATA controller for hard disks and cdroms
+#
+# ata[0-3]: enabled=[0|1], ioaddr1=addr, ioaddr2=addr, irq=number
+#
+# These options enables up to 4 ata channels. For each channel
+# the two base io addresses and the irq must be specified.
+#
+# ata0 and ata1 are enabled by default with the values shown below
+#
+# Examples:
+# ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
+# ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
+# ata2: enabled=1, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
+# ata3: enabled=1, ioaddr1=0x168, ioaddr2=0x360, irq=9
+#=======================================================================
+ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
+ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
+ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
+ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
+
+#=======================================================================
+# ATA[0-3]-MASTER, ATA[0-3]-SLAVE
+#
+# This defines the type and characteristics of all attached ata devices:
+# type= type of attached device [disk|cdrom]
+# mode= only valid for disks [flat|concat|external|dll|sparse|vmware3]
+# mode= only valid for disks [undoable|growing|volatile|vvfat]
+# path= path of the image / directory
+# cylinders= only valid for disks
+# heads= only valid for disks
+# spt= only valid for disks
+# status= only valid for cdroms [inserted|ejected]
+# biosdetect= type of biosdetection [none|auto], only for disks on ata0 [cmos]
+# translation=type of translation of the bios, only for disks [none|lba|large|rechs|auto]
+# model= string returned by identify device command
+# journal= optional filename of the redolog for undoable, volatile and vvfat disks
+#
+# Point this at a hard disk image file, cdrom iso file, or physical cdrom
+# device. To create a hard disk image, try running bximage. It will help you
+# choose the size and then suggest a line that works with it.
+#
+# In UNIX it may be possible to use a raw device as a Bochs hard disk,
+# but WE DON'T RECOMMEND IT. In Windows there is no easy way.
+#
+# In windows, the drive letter + colon notation should be used for cdroms.
+# Depending on versions of windows and drivers, you may only be able to
+# access the "first" cdrom in the system. On MacOSX, use path="drive"
+# to access the physical drive.
+#
+# The path is mandatory for hard disks. Disk geometry autodetection works with
+# images created by bximage if CHS is set to 0/0/0 (cylinders are calculated
+# using heads=16 and spt=63). For other hard disk images and modes the
+# cylinders, heads, and spt are mandatory. In all cases the disk size reported
+# from the image must be exactly C*H*S*512.
+#
+# Default values are:
+# mode=flat, biosdetect=auto, translation=auto, model="Generic 1234"
+#
+# The biosdetect option has currently no effect on the bios
+#
+# Examples:
+# ata0-master: type=disk, mode=flat, path=10M.sample, cylinders=306, heads=4, spt=17
+# ata0-slave: type=disk, mode=flat, path=20M.sample, cylinders=615, heads=4, spt=17
+# ata1-master: type=disk, mode=flat, path=30M.sample, cylinders=615, heads=6, spt=17
+# ata1-slave: type=disk, mode=flat, path=46M.sample, cylinders=940, heads=6, spt=17
+# ata2-master: type=disk, mode=flat, path=62M.sample, cylinders=940, heads=8, spt=17
+# ata2-slave: type=disk, mode=flat, path=112M.sample, cylinders=900, heads=15, spt=17
+# ata3-master: type=disk, mode=flat, path=483M.sample, cylinders=1024, heads=15, spt=63
+# ata3-slave: type=cdrom, path=iso.sample, status=inserted
+#=======================================================================
+#ata0-master: type=disk, mode=flat, path="30M.sample"
+#ata0-master: type=disk, mode=flat, path="30M.sample", cylinders=615, heads=6, spt=17
+#ata0-master: type=disk, mode=flat, path="c.img", cylinders=0 # autodetect
+#ata0-slave: type=disk, mode=vvfat, path=/bochs/images/vvfat, journal=vvfat.redolog
+#ata0-slave: type=cdrom, path=D:, status=inserted
+#ata0-slave: type=cdrom, path=/dev/cdrom, status=inserted
+#ata0-slave: type=cdrom, path="drive", status=inserted
+#ata0-slave: type=cdrom, path=/dev/rcd0d, status=inserted
+
+#=======================================================================
+# BOOT:
+# This defines the boot sequence. Now you can specify up to 3 boot drives,
+# which can be 'floppy', 'disk', 'cdrom' or 'network' (boot ROM).
+# Legacy 'a' and 'c' are also supported.
+# Examples:
+# boot: floppy
+# boot: cdrom, disk
+# boot: network, disk
+# boot: cdrom, floppy, disk
+#=======================================================================
+#boot: floppy
+#boot: disk
+boot: network, floppy
+
+#=======================================================================
+# CLOCK:
+# This defines the parameters of the clock inside Bochs:
+#
+# SYNC:
+# This defines the method how to synchronize the Bochs internal time
+# with realtime. With the value 'none' the Bochs time relies on the IPS
+# value and no host time synchronization is used. The 'slowdown' method
+# sacrifices performance to preserve reproducibility while allowing host
+# time correlation. The 'realtime' method sacrifices reproducibility to
+# preserve performance and host-time correlation.
+# It is possible to enable both synchronization methods.
+#
+# RTC_SYNC:
+# If this option is enabled together with the realtime synchronization,
+# the RTC runs at realtime speed. This feature is disabled by default.
+#
+# TIME0:
+# Specifies the start (boot) time of the virtual machine. Use a time
+# value as returned by the time(2) system call. If no time0 value is
+# set or if time0 equal to 1 (special case) or if time0 equal 'local',
+# the simulation will be started at the current local host time.
+# If time0 equal to 2 (special case) or if time0 equal 'utc',
+# the simulation will be started at the current utc time.
+#
+# Syntax:
+# clock: sync=[none|slowdown|realtime|both], time0=[timeValue|local|utc]
+#
+# Example:
+# clock: sync=none, time0=local # Now (localtime)
+# clock: sync=slowdown, time0=315529200 # Tue Jan 1 00:00:00 1980
+# clock: sync=none, time0=631148400 # Mon Jan 1 00:00:00 1990
+# clock: sync=realtime, time0=938581955 # Wed Sep 29 07:12:35 1999
+# clock: sync=realtime, time0=946681200 # Sat Jan 1 00:00:00 2000
+# clock: sync=none, time0=1 # Now (localtime)
+# clock: sync=none, time0=utc # Now (utc/gmt)
+#
+# Default value are sync=none, time0=local
+#=======================================================================
+#clock: sync=none, time0=local
+
+
+#=======================================================================
+# FLOPPY_BOOTSIG_CHECK: disabled=[0|1]
+# Enables or disables the 0xaa55 signature check on boot floppies
+# Defaults to disabled=0
+# Examples:
+# floppy_bootsig_check: disabled=0
+# floppy_bootsig_check: disabled=1
+#=======================================================================
+floppy_bootsig_check: disabled=0
+
+#=======================================================================
+# LOG:
+# Give the path of the log file you'd like Bochs debug and misc. verbiage
+# to be written to. If you don't use this option or set the filename to
+# '-' the output is written to the console. If you really don't want it,
+# make it "/dev/null" (Unix) or "nul" (win32). :^(
+#
+# Examples:
+# log: ./bochs.out
+# log: /dev/tty
+#=======================================================================
+#log: /dev/null
+log: bochsout.txt
+
+#=======================================================================
+# LOGPREFIX:
+# This handles the format of the string prepended to each log line.
+# You may use those special tokens :
+# %t : 11 decimal digits timer tick
+# %i : 8 hexadecimal digits of cpu current eip (ignored in SMP configuration)
+# %e : 1 character event type ('i'nfo, 'd'ebug, 'p'anic, 'e'rror)
+# %d : 5 characters string of the device, between brackets
+#
+# Default : %t%e%d
+# Examples:
+# logprefix: %t-%e-@%i-%d
+# logprefix: %i%e%d
+#=======================================================================
+#logprefix: %t%e%d
+
+#=======================================================================
+# LOG CONTROLS
+#
+# Bochs has four severity levels for event logging.
+# panic: cannot proceed. If you choose to continue after a panic,
+# don't be surprised if you get strange behavior or crashes.
+# error: something went wrong, but it is probably safe to continue the
+# simulation.
+# info: interesting or useful messages.
+# debug: messages useful only when debugging the code. This may
+# spit out thousands per second.
+#
+# For events of each level, you can choose to exit Bochs ('fatal'), 'report'
+# or 'ignore'. On some guis you have the additional choice 'ask'. A gui dialog
+# appears asks how to proceed.
+#
+# It is also possible to specify the 'action' to do for each Bochs facility
+# separately (e.g. crash on panics from everything except the cdrom, and only
+# report those). See the 'log function' module list in the user documentation.
+#
+# If you are experiencing many panics, it can be helpful to change
+# the panic action to report instead of fatal. However, be aware
+# that anything executed after a panic is uncharted territory and can
+# cause bochs to become unstable. The panic is a "graceful exit," so
+# if you disable it you may get a spectacular disaster instead.
+#=======================================================================
+panic: action=ask
+error: action=report
+info: action=report
+debug: action=ignore, pci=report # report BX_DEBUG from module 'pci'
+
+#=======================================================================
+# DEBUGGER_LOG:
+# Give the path of the log file you'd like Bochs to log debugger output.
+# If you really don't want it, make it /dev/null or '-'. :^(
+#
+# Examples:
+# debugger_log: ./debugger.out
+#=======================================================================
+#debugger_log: /dev/null
+#debugger_log: debugger.out
+debugger_log: -
+
+#=======================================================================
+# COM1, COM2, COM3, COM4:
+# This defines a serial port (UART type 16550A). In the 'term' you can specify
+# a device to use as com1. This can be a real serial line, or a pty. To use
+# a pty (under X/Unix), create two windows (xterms, usually). One of them will
+# run bochs, and the other will act as com1. Find out the tty the com1
+# window using the `tty' command, and use that as the `dev' parameter.
+# Then do `sleep 1000000' in the com1 window to keep the shell from
+# messing with things, and run bochs in the other window. Serial I/O to
+# com1 (port 0x3f8) will all go to the other window.
+# In socket* and pipe* (win32 only) modes Bochs becomes either socket/named pipe
+# client or server. In client mode it connects to an already running server (if
+# connection fails Bochs treats com port as not connected). In server mode it
+# opens socket/named pipe and waits until a client application connects to it
+# before starting simulation. This mode is useful for remote debugging (e.g.
+# with gdb's "target remote host:port" command or windbg's command line option
+# -k com:pipe,port=\\.\pipe\pipename). Note: 'socket' is a shorthand for
+# 'socket-client' and 'pipe' for 'pipe-client'. Socket modes use simple TCP
+# communication, pipe modes use duplex byte mode pipes.
+# Other serial modes are 'null' (no input/output), 'file' (output to a file
+# specified as the 'dev' parameter), 'raw' (use the real serial port - under
+# construction for win32), 'mouse' (standard serial mouse - requires
+# mouse option setting 'type=serial', 'type=serial_wheel' or 'type=serial_msys').
+#
+# Examples:
+# com1: enabled=1, mode=null
+# com1: enabled=1, mode=mouse
+# com2: enabled=1, mode=file, dev=serial.out
+# com3: enabled=1, mode=raw, dev=com1
+# com3: enabled=1, mode=socket-client, dev=localhost:8888
+# com3: enabled=1, mode=socket-server, dev=localhost:8888
+# com4: enabled=1, mode=pipe-client, dev=\\.\pipe\mypipe
+# com4: enabled=1, mode=pipe-server, dev=\\.\pipe\mypipe
+#=======================================================================
+#com1: enabled=1, mode=term, dev=/dev/ttyp9
+
+
+#=======================================================================
+# PARPORT1, PARPORT2:
+# This defines a parallel (printer) port. When turned on and an output file is
+# defined the emulated printer port sends characters printed by the guest OS
+# into the output file. On some platforms a device filename can be used to
+# send the data to the real parallel port (e.g. "/dev/lp0" on Linux, "lpt1" on
+# win32 platforms).
+#
+# Examples:
+# parport1: enabled=1, file="parport.out"
+# parport2: enabled=1, file="/dev/lp0"
+# parport1: enabled=0
+#=======================================================================
+parport1: enabled=1, file="parport.out"
+
+#=======================================================================
+# SB16:
+# This defines the SB16 sound emulation. It can have several of the
+# following properties.
+# All properties are in the format sb16: property=value
+# enabled:
+# This optional property controls the presence of the SB16 emulation.
+# The emulation is turned on unless this property is used and set to 0.
+# midi: The filename is where the midi data is sent. This can be a
+# device or just a file if you want to record the midi data.
+# midimode:
+# 0=no data
+# 1=output to device (system dependent. midi denotes the device driver)
+# 2=SMF file output, including headers
+# 3=output the midi data stream to the file (no midi headers and no
+# delta times, just command and data bytes)
+# wave: This is the device/file where wave output is stored
+# wavemode:
+# 0=no data
+# 1=output to device (system dependent. wave denotes the device driver)
+# 2=VOC file output, incl. headers
+# 3=output the raw wave stream to the file
+# log: The file to write the sb16 emulator messages to.
+# loglevel:
+# 0=no log
+# 1=resource changes, midi program and bank changes
+# 2=severe errors
+# 3=all errors
+# 4=all errors plus all port accesses
+# 5=all errors and port accesses plus a lot of extra info
+# dmatimer:
+# microseconds per second for a DMA cycle. Make it smaller to fix
+# non-continuous sound. 750000 is usually a good value. This needs a
+# reasonably correct setting for the IPS parameter of the CPU option.
+#
+# Examples for output devices:
+# sb16: midimode=1, midi="", wavemode=1, wave="" # win32
+# sb16: midimode=1, midi=alsa:128:0, wavemode=1, wave=alsa # Linux with ALSA
+#=======================================================================
+#sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=sb16.log, dmatimer=600000
+
+#=======================================================================
+# ES1370:
+# This defines the ES1370 sound emulation. The parameter 'enabled' controls the
+# presence of the device. In addition to this, it must be loaded with 'plugin_ctrl'
+# and assigned to a PCI slot. The 'wavedev' parameter is similar to the 'wave'
+# parameter of the SB16 soundcard. The emulation supports recording and playback
+# (except DAC1+DAC2 output at the same time).
+#
+# Examples:
+# es1370: enabled=1, wavedev="" # win32
+# es1370: enabled=1, wavedev=alsa # Linux with ALSA
+#=======================================================================
+#es1370: enabled=1, wavedev=alsa
+
+#=======================================================================
+# KEYBOARD_SERIAL_DELAY:
+# Approximate time in microseconds that it takes one character to
+# be transfered from the keyboard to controller over the serial path.
+# Examples:
+# keyboard_serial_delay: 200
+#=======================================================================
+keyboard_serial_delay: 250
+
+#=======================================================================
+# KEYBOARD_PASTE_DELAY:
+# Approximate time in microseconds between attempts to paste
+# characters to the keyboard controller. This leaves time for the
+# guest os to deal with the flow of characters. The ideal setting
+# depends on how your operating system processes characters. The
+# default of 100000 usec (.1 seconds) was chosen because it works
+# consistently in Windows.
+#
+# If your OS is losing characters during a paste, increase the paste
+# delay until it stops losing characters.
+#
+# Examples:
+# keyboard_paste_delay: 100000
+#=======================================================================
+keyboard_paste_delay: 100000
+
+#=======================================================================
+# MOUSE:
+# This defines parameters for the emulated mouse type, the initial status
+# of the mouse capture and the runtime method to toggle it.
+#
+# TYPE:
+# With the mouse type option you can select the type of mouse to emulate.
+# The default value is 'ps2'. The other choices are 'imps2' (wheel mouse
+# on PS/2), 'serial', 'serial_wheel' and 'serial_msys' (one com port requires
+# setting 'mode=mouse'). To connect a mouse to an USB port, see the 'usb_uhci',
+# 'usb_ohci' or 'usb_xhci' options (requires PCI and USB support).
+#
+# ENABLED:
+# The Bochs gui creates mouse "events" unless the 'enabled' option is
+# set to 0. The hardware emulation itself is not disabled by this.
+# Unless you have a particular reason for enabling the mouse by default,
+# it is recommended that you leave it off. You can also toggle the mouse
+# usage at runtime (RFB, SDL, Win32, wxWidgets and X11 - see below).
+#
+# TOGGLE:
+# The default method to toggle the mouse capture at runtime is to press the
+# CTRL key and the middle mouse button ('ctrl+mbutton'). This option allows
+# to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (like QEMU)
+# or 'f12' (replaces win32 'legacyF12' option).
+#
+# Examples:
+# mouse: enabled=1
+# mouse: type=imps2, enabled=1
+# mouse: type=serial, enabled=1
+# mouse: enabled=0, toggle=ctrl+f10
+#=======================================================================
+mouse: enabled=0
+
+#=======================================================================
+# private_colormap: Request that the GUI create and use it's own
+# non-shared colormap. This colormap will be used
+# when in the bochs window. If not enabled, a
+# shared colormap scheme may be used. Not implemented
+# on all GUI's.
+#
+# Examples:
+# private_colormap: enabled=1
+# private_colormap: enabled=0
+#=======================================================================
+private_colormap: enabled=0
+
+#=======================================================================
+# fullscreen: ONLY IMPLEMENTED ON AMIGA
+# Request that Bochs occupy the entire screen instead of a
+# window.
+#
+# Examples:
+# fullscreen: enabled=0
+# fullscreen: enabled=1
+#=======================================================================
+#fullscreen: enabled=0
+#screenmode: name="sample"
+
+#=======================================================================
+# ne2k: NE2000 compatible ethernet adapter
+#
+# Format:
+# ne2k: enabled=1, ioaddr=IOADDR, irq=IRQ, mac=MACADDR, ethmod=MODULE,
+# ethdev=DEVICE, script=SCRIPT, bootrom=BOOTROM
+#
+# IOADDR, IRQ: You probably won't need to change ioaddr and irq, unless there
+# are IRQ conflicts. These arguments are ignored when assign the ne2k to a
+# PCI slot.
+#
+# MAC: The MAC address MUST NOT match the address of any machine on the net.
+# Also, the first byte must be an even number (bit 0 set means a multicast
+# address), and you cannot use ff:ff:ff:ff:ff:ff because that's the broadcast
+# address. For the ethertap module, you must use fe:fd:00:00:00:01. There may
+# be other restrictions too. To be safe, just use the b0:c4... address.
+#
+# ETHDEV: The ethdev value is the name of the network interface on your host
+# platform. On UNIX machines, you can get the name by running ifconfig. On
+# Windows machines, you must run niclist to get the name of the ethdev.
+# Niclist source code is in misc/niclist.c and it is included in Windows
+# binary releases.
+#
+# SCRIPT: The script value is optional, and is the name of a script that
+# is executed after bochs initialize the network interface. You can use
+# this script to configure this network interface, or enable masquerading.
+# This is mainly useful for the tun/tap devices that only exist during
+# Bochs execution. The network interface name is supplied to the script
+# as first parameter.
+#
+# BOOTROM: The bootrom value is optional, and is the name of the ROM image
+# to load. Note that this feature is only implemented for the PCI version of
+# the NE2000.
+#
+# If you don't want to make connections to any physical networks,
+# you can use the following 'ethmod's to simulate a virtual network.
+# null: All packets are discarded, but logged to a few files.
+# vde: Virtual Distributed Ethernet
+# vnet: ARP, ICMP-echo(ping), DHCP and read/write TFTP are simulated.
+# The virtual host uses 192.168.10.1.
+# DHCP assigns 192.168.10.2 to the guest.
+# TFTP uses the 'ethdev' value for the root directory and doesn't
+# overwrite files.
+#
+#=======================================================================
+# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=fbsd, ethdev=en0 #macosx
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:00, ethmod=fbsd, ethdev=xl0
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:00, ethmod=linux, ethdev=eth0
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=win32, ethdev=MYCARD
+# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=tap, ethdev=tap0
+# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=tuntap, ethdev=/dev/net/tun0, script=./tunconfig
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=null, ethdev=eth0
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=vde, ethdev="/tmp/vde.ctl"
+# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=vnet, ethdev="c:/temp"
+# ne2k: mac=b0:c4:20:00:00:01, ethmod=slirp, script=/usr/local/bin/slirp, bootrom=ne2k_pci.rom
+
+#=======================================================================
+# pnic: Bochs/Etherboot pseudo-NIC
+#
+# Format:
+# pnic: enabled=1, mac=MACADDR, ethmod=MODULE, ethdev=DEVICE, script=SCRIPT,
+# bootrom=BOOTROM
+#
+# The pseudo-NIC accepts the same syntax (for mac, ethmod, ethdev, script,
+# bootrom) and supports the same networking modules as the NE2000 adapter.
+# In addition to this, it must be loaded with 'plugin_ctrl' and assigned
+# to a PCI slot.
+#=======================================================================
+#pnic: enabled=1, mac=b0:c4:20:00:00:00, ethmod=vnet
+
+#=======================================================================
+# e1000: Intel(R) 82540EM Gigabit Ethernet adapter
+#
+# Format:
+# e1000: enabled=1, mac=MACADDR, ethmod=MODULE, ethdev=DEVICE, script=SCRIPT
+# bootrom=BOOTROM
+#
+# The E1000 accepts the same syntax (for mac, ethmod, ethdev, script, bootrom)
+# and supports the same networking modules as the NE2000 adapter. In addition
+# to this, it must be loaded with 'plugin_ctrl' and assigned to a PCI slot.
+#=======================================================================
+#e1000: enabled=1, mac=52:54:00:12:34:56, ethmod=slirp, script=/usr/local/bin/slirp
+e1000: enabled=1, mac=52:54:00:12:34:56, ethmod=tuntap, ethdev=/dev/net/tun:tap0
+
+#=======================================================================
+# KEYBOARD_MAPPING:
+# This enables a remap of a physical localized keyboard to a
+# virtualized us keyboard, as the PC architecture expects.
+# If enabled, the keymap file must be specified.
+#
+# Examples:
+# keyboard_mapping: enabled=1, map=gui/keymaps/x11-pc-de.map
+#=======================================================================
+keyboard_mapping: enabled=0, map=
+
+#=======================================================================
+# KEYBOARD_TYPE:
+# Type of keyboard return by a "identify keyboard" command to the
+# keyboard controler. It must be one of "xt", "at" or "mf".
+# Defaults to "mf". It should be ok for almost everybody. A known
+# exception is french macs, that do have a "at"-like keyboard.
+#
+# Examples:
+# keyboard_type: mf
+#=======================================================================
+#keyboard_type: mf
+
+#=======================================================================
+# USER_SHORTCUT:
+# This defines the keyboard shortcut to be sent when you press the "user"
+# button in the headerbar. The shortcut string is a combination of maximum
+# 3 key names (listed below) separated with a '-' character.
+# Valid key names:
+# "alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
+# "f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup",
+# "plus", "right", "shift", "space", "tab", "up", "win", "print" and "power".
+#
+# Example:
+# user_shortcut: keys=ctrl-alt-del
+#=======================================================================
+#user_shortcut: keys=ctrl-alt-del
+
+#=======================================================================
+# PCI:
+# This option controls the presence of a PCI chipset in Bochs. Currently it only
+# supports the i440FX chipset. You can also specify the devices connected to
+# PCI slots. Up to 5 slots are available. These devices are currently supported:
+# cirrus, e1000, es1370, ne2k, pcivga, pcidev, pcipnic, usb_ohci and usb_xhci.
+#
+# Example:
+# pci: enabled=1, chipset=i440fx, slot1=pcivga, slot2=ne2k
+#=======================================================================
+pci: enabled=1, chipset=i440fx, slot1=e1000
+
+#=======================================================================
+# USB_UHCI:
+# This option controls the presence of the USB root hub which is a part
+# of the i440FX PCI chipset. With the portX parameter you can connect devices
+# to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom'
+# 'hub' and 'printer'). NOTE: UHCI must be loaded with 'plugin_ctrl'.
+#
+# The optionsX parameter can be used to assign specific options to the device
+# connected to the corresponding USB port. Currently this feature is only used
+# to set the speed reported by device and by the 'disk' device to specify
+# an alternative redolog file of some image modes.
+#
+# If you connect the mouse or tablet to one of the ports, Bochs forwards the
+# mouse movement data to the USB device instead of the selected mouse type.
+# When connecting the keypad to one of the ports, Bochs forwards the input of
+# the numeric keypad to the USB device instead of the PS/2 keyboard.
+#
+# To connect a 'flat' mode image as an USB hardisk you can use the 'disk' device
+# with the path to the image separated with a colon. To use other disk image modes
+# similar to ATA disks the syntax 'disk:mode:filename' must be used (see below).
+#
+# To emulate an USB cdrom you can use the 'cdrom' device name and the path to
+# an ISO image or raw device name also separated with a colon. An option to
+# insert/eject media is available in the runtime configuration.
+#
+# The device name 'hub' connects an external hub with max. 8 ports (default: 4)
+# to the root hub. To specify the number of ports you have to add the value
+# separated with a colon. Connecting devices to the external hub ports is only
+# available in the runtime configuration.
+#
+# The device 'printer' emulates the HP Deskjet 920C printer. The PCL data is
+# sent to a file specified in bochsrc.txt. The current code appends the PCL
+# code to the file if the file already existed. It would probably be nice to
+# overwrite the file instead, asking user first.
+#=======================================================================
+#usb_uhci: enabled=1
+#usb_uhci: enabled=1, port1=mouse, port2=disk:usbstick.img
+#usb_uhci: enabled=1, port1=hub:7, port2=disk:growing:usbdisk.img
+#usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options1=journal:redo.log
+#usb_uhci: enabled=1, port1=printer:printdata.bin, port2=cdrom:image.iso
+
+#=======================================================================
+# USB_OHCI:
+# This option controls the presence of the USB OHCI host controller with a
+# 2-port hub. The portX option accepts the same device types with the same
+# syntax as the UHCI controller (see above). The OHCI HC must be assigned to
+# a PCI slot and loaded with 'plugin_ctrl'.
+#=======================================================================
+#usb_ohci: enabled=1
+#usb_ohci: enabled=1, port1=printer:usbprinter.bin
+
+#=======================================================================
+# USB_XHCI:
+# This option controls the presence of the experimental USB xHCI host controller
+# with a 4-port hub. The portX option accepts the same device types with the
+# same syntax as the UHCI controller (see above). The xHCI HC must be assigned
+# to a PCI slot and loaded with 'plugin_ctrl'.
+#=======================================================================
+#usb_xhci: enabled=1
+
+#=======================================================================
+# CMOSIMAGE:
+# This defines image file that can be loaded into the CMOS RAM at startup.
+# The rtc_init parameter controls whether initialize the RTC with values stored
+# in the image. By default the time0 argument given to the clock option is used.
+# With 'rtc_init=image' the image is the source for the initial time.
+#
+# Example:
+# cmosimage: file=cmos.img, rtc_init=image
+#=======================================================================
+#cmosimage: file=cmos.img, rtc_init=time0
+
+#=======================================================================
+# MAGIC_BREAK:
+# This enables the "magic breakpoint" feature when using the debugger.
+# The useless cpu instruction XCHG BX, BX causes Bochs to enter the
+# debugger mode. This might be useful for software development.
+#
+# Example:
+# magic_break: enabled=1
+#=======================================================================
+#magic_break: enabled=1
+magic_break: enabled=1
+
+#=======================================================================
+# PORT_E9_HACK:
+# The 0xE9 port doesn't exists in normal ISA architecture. However, we
+# define a convention here, to display on the console of the system running
+# Bochs anything that is written to it. The idea is to provide debug output
+# very early when writing BIOS or OS code for example, without having to
+# bother with setting up a serial port or etc. Reading from port 0xE9 will
+# will return 0xe9 to let you know if the feature is available.
+# Leave this 0 unless you have a reason to use it.
+#
+# Example:
+# port_e9_hack: enabled=1
+#=======================================================================
+port_e9_hack: enabled=1
+
+#=======================================================================
+# DEBUG_SYMBOLS:
+# This loads symbols from the specified file for use in Bochs' internal
+# debugger. Symbols are loaded into global context. This is equivalent to
+# issuing ldsym debugger command at start up.
+#
+# Example:
+# debug_symbols: file="kernel.sym"
+# debug_symbols: file="kernel.sym", offset=0x80000000
+#=======================================================================
+#debug_symbols: file="kernel.sym"
+
+#=======================================================================
+# other stuff
+#=======================================================================
+#load32bitOSImage: os=nullkernel, path=../kernel.img, iolog=../vga_io.log
+#load32bitOSImage: os=linux, path=../linux.img, iolog=../vga_io.log, initrd=../initrd.img
+#print_timestamps: enabled=1
+
+#-------------------------
+# PCI host device mapping
+#-------------------------
+#pcidev: vendor=0x1234, device=0x5678
+
+#=======================================================================
+# GDBSTUB:
+# Enable GDB stub. See user documentation for details.
+# Default value is enabled=0.
+#=======================================================================
+#gdbstub: enabled=0, port=1234, text_base=0, data_base=0, bss_base=0
+
+#=======================================================================
+# USER_PLUGIN:
+# Load user-defined plugin. This option is available only if Bochs is
+# compiled with plugin support. Maximum 8 different plugins are supported.
+# See the example in the Bochs sources how to write a plugin device.
+#=======================================================================
+#user_plugin: name=testdev
+
+#=======================================================================
+# for Macintosh, use the style of pathnames in the following
+# examples.
+#
+# vgaromimage: :bios:VGABIOS-elpin-2.40
+# romimage: file=:bios:BIOS-bochs-latest, address=0xf0000
+# floppya: 1_44=[fd:], status=inserted
+#=======================================================================
+
+#=======================================================================
+# MEGS
+# Set the number of Megabytes of physical memory you want to emulate.
+# The default is 32MB, most OS's won't need more than that.
+# The maximum amount of memory supported is 2048Mb.
+# The 'MEGS' option is deprecated. Use 'MEMORY' option instead.
+#=======================================================================
+#megs: 256
+#megs: 128
+#megs: 64
+#megs: 32
+#megs: 16
+#megs: 8
diff --git a/qemu/roms/ipxe/contrib/vm/cow b/qemu/roms/ipxe/contrib/vm/cow
new file mode 100755
index 000000000..054ffdde9
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/cow
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+set -e
+
+imgloop=
+tmpfile=
+tmploop=
+dmname=
+cowlink=
+
+function cleanup () {
+ set +e
+ [ -n "$cowlink" ] && rm $cowlink
+ [ -n "$dmname" ] && dmsetup remove $dmname
+ [ -n "$tmploop" ] && losetup -d $tmploop
+ [ -n "$tmpfile" ] && rm $tmpfile
+ [ -n "$imgloop" ] && losetup -d $imgloop
+}
+
+trap cleanup EXIT
+
+imgfile=$1 ; shift
+command=$1 ; shift
+if [ -z "$imgfile" -o -z "$command" ] ; then
+ echo Syntax: $0 /path/to/image/file command [args..]
+ exit 1
+fi
+
+# Set up image loop device
+x=`losetup -f` ; losetup -r $x $imgfile ; imgloop=$x
+
+# Create temporary file and set up temporary loop device
+tmpfile=`mktemp $imgfile.XXXXXXXXXX`
+truncate -r $imgfile $tmpfile
+x=`losetup -f` ; losetup $x $tmpfile ; tmploop=$x
+
+# Create snapshot device
+imgsize=`blockdev --getsz $imgloop`
+x=`basename $imgfile` ; echo 0 $imgsize snapshot $imgloop $tmploop N 16 | \
+ dmsetup create $x ; dmname=$x
+chown --reference=$imgfile /dev/mapper/$dmname
+chmod --reference=$imgfile /dev/mapper/$dmname
+
+# Create symlink
+x=$imgfile.cow ; ln -s /dev/mapper/$dmname $x ; cowlink=$x
+
+# Wait until killed
+echo "Created $cowlink"
+$command "$@" $cowlink
diff --git a/qemu/roms/ipxe/contrib/vm/serial-console b/qemu/roms/ipxe/contrib/vm/serial-console
new file mode 100755
index 000000000..5d09876e3
--- /dev/null
+++ b/qemu/roms/ipxe/contrib/vm/serial-console
@@ -0,0 +1,278 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+serial-console
+
+=head1 SYNOPSIS
+
+serial-console [options]
+
+Options:
+
+ -h,--help Display brief help message
+ -v,--verbose Increase verbosity
+ -q,--quiet Decrease verbosity
+ -l,--log FILE Log output to file
+ -r,--rcfile FILE Modify specified bochsrc file
+
+=head1 DESCRIPTION
+
+C<serial-console> provides a virtual serial console for use with
+Bochs. Running C<serial-console> creates a pseudo-tty. The master
+side of this pty is made available to the user for interaction; the
+slave device is written to the Bochs configuration file
+(C<bochsrc.txt>) for use by a subsequent Bochs session.
+
+=head1 EXAMPLES
+
+=over 4
+
+=item C<serial-console>
+
+Create a virtual serial console for Bochs, modify C<bochsrc.txt>
+appropriately.
+
+=item C<serial-console -r ../.bochsrc -l serial.log>
+
+Create a virtual serial console for Bochs, modify C<../.bochsrc>
+appropriately, log output to C<serial.log>.
+
+=back
+
+=head1 INVOCATION
+
+Before starting Bochs, run C<serial-console> in a different session
+(e.g. a different xterm window). When you subsequently start Bochs,
+anything that the emulated machine writes to its serial port will
+appear in the window running C<serial-console>, and anything typed in
+the C<serial-console> window will arrive on the emulated machine's
+serial port.
+
+You do B<not> need to rerun C<serial-console> afresh for each Bochs
+session.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-l,--log FILE>
+
+Log all output (i.e. everything that is printed in the
+C<serial-console> window) to the specified file.
+
+=item B<-r,--rcfile FILE>
+
+Modify the specified bochsrc file. The file will be updated to
+contain the path to the slave side of the psuedo tty that we create.
+The original file will be restored when C<serial-console> exits. The
+default is to modify the file C<bochsrc.txt> in the current directory.
+
+To avoid modifying any bochsrc file, use C<--norcfile>.
+
+=back
+
+=cut
+
+use IO::Pty;
+use IO::Select;
+use File::Spec::Functions qw ( :ALL );
+use Getopt::Long;
+use Pod::Usage;
+use POSIX qw ( :termios_h );
+use strict;
+use warnings;
+
+my $o;
+my $restore_file = {};
+my $restore_termios;
+use constant BLOCKSIZE => 8192;
+
+##############################################################################
+#
+# Parse command line options into options hash ($o)
+#
+# $o = parse_opts();
+
+sub parse_opts {
+ # $o is the hash that will hold the options
+ my $o = {
+ verbosity => 1,
+ rcfile => 'bochsrc.txt',
+ };
+ # Special handlers for some options
+ my $opt_handlers = {
+ verbose => sub { $o->{verbosity}++; },
+ quiet => sub { $o->{verbosity}--; },
+ help => sub { pod2usage(1); },
+ norcfile => sub { delete $o->{rcfile}; },
+ };
+ # Merge handlers into main options hash (so that Getopt::Long can find them)
+ $o->{$_} = $opt_handlers->{$_} foreach keys %$opt_handlers;
+ # Option specifiers for Getopt::Long
+ my @optspec = ( 'help|h|?',
+ 'quiet|q+',
+ 'verbose|v+',
+ 'log|l=s',
+ 'rcfile|r=s',
+ 'norcfile',
+ );
+ # Do option parsing
+ Getopt::Long::Configure ( 'bundling' );
+ pod2usage("Error parsing command-line options") unless GetOptions (
+ $o, @optspec );
+ # Clean up $o by removing the handlers
+ delete $o->{$_} foreach keys %$opt_handlers;
+ return $o;
+}
+
+##############################################################################
+#
+# Modify bochsrc file
+
+sub patch_bochsrc {
+ my $active = shift;
+ my $pty = shift;
+
+ # Rename active file to backup file
+ ( my $vol, my $dir, my $file ) = splitpath ( $active );
+ $file = '.'.$file.".serial-console";
+ my $backup = catpath ( $vol, $dir, $file );
+ rename $active, $backup
+ or die "Could not back up $active to $backup: $!\n";
+
+ # Derive line to be inserted
+ my $patch = "com1: enabled=1, mode=term, dev=$pty\n";
+
+ # Modify file
+ open my $old, "<$backup" or die "Could not open $backup: $!\n";
+ open my $new, ">$active" or die "Could not open $active: $!\n";
+ print $new <<"EOF";
+##################################################
+#
+# This file has been modified by serial-console.
+#
+# Do not modify this file; it will be erased when
+# serial-console (pid $$) exits and will be
+# replaced with the backup copy held in
+# $backup.
+#
+##################################################
+
+
+EOF
+ my $patched;
+ while ( my $line = <$old> ) {
+ if ( $line =~ /^\s*\#?\s*com1:\s*\S/ ) {
+ if ( ! $patched ) {
+ $line = $patch;
+ $patched = 1;
+ } else {
+ $line = '# '.$line unless $line =~ /^\s*\#/;
+ }
+ }
+ print $new $line;
+ }
+ print $new $patch unless $patched;
+ close $old;
+ close $new;
+
+ return $backup;
+}
+
+##############################################################################
+#
+# Attach/detach message printing and terminal settings
+
+sub bochs_attached {
+ print STDERR "Bochs attached.\n\n\n"
+ if $o->{verbosity} >= 1;
+}
+
+sub bochs_detached {
+ print STDERR "\n\nWaiting for bochs to attach...\n"
+ if $o->{verbosity} >= 1;
+}
+
+##############################################################################
+#
+# Main program
+
+$o = parse_opts();
+pod2usage(1) if @ARGV;
+
+# Catch signals
+my $sigdie = sub { die "Exiting via signal\n"; };
+$SIG{INT} = $sigdie;
+
+# Create Pty, close slave side
+my $pty = IO::Pty->new();
+$pty->close_slave();
+$pty->set_raw();
+print STDERR "Slave pty is ".$pty->ttyname."\n" if $o->{verbosity} >= 1;
+
+# Open logfile
+my $log;
+if ( $o->{log} ) {
+ open $log, ">$o->{log}" or die "Could not open $o->{log}: $!\n";
+}
+
+# Set up terminal
+my $termios;
+if ( -t STDIN ) {
+ $termios = POSIX::Termios->new;
+ $restore_termios = POSIX::Termios->new;
+ $termios->getattr ( fileno(STDIN) );
+ $restore_termios->getattr ( fileno(STDIN) );
+ $termios->setlflag ( $termios->getlflag & ~(ICANON) & ~(ECHO) );
+ $termios->setiflag ( $termios->getiflag & ~(ICRNL) );
+ $termios->setattr ( fileno(STDIN), TCSANOW );
+}
+
+# Modify bochsrc file
+$restore_file = { $o->{rcfile} =>
+ patch_bochsrc ( $o->{rcfile}, $pty->ttyname ) }
+ if $o->{rcfile};
+
+# Start character shunt
+my $attached = 1;
+my $select = IO::Select->new ( \*STDIN, $pty );
+while ( 1 ) {
+ my %can_read = map { $_ => 1 }
+ $select->can_read ( $attached ? undef : 1 );
+ if ( $can_read{\*STDIN} ) {
+ sysread ( STDIN, my $data, BLOCKSIZE )
+ or die "Cannot read from STDIN: $!\n";
+ $pty->syswrite ( $data );
+ }
+ if ( $can_read{$pty} ) {
+ if ( $pty->sysread ( my $data, BLOCKSIZE ) ) {
+ # Actual data available
+ bochs_attached() if $attached == 0;
+ $attached = 1;
+ syswrite ( STDOUT, $data );
+ $log->syswrite ( $data ) if $log;
+ } else {
+ # No data available but select() says we can read. This almost
+ # certainly indicates that nothing is attached to the slave.
+ bochs_detached() if $attached == 1;
+ $attached = 0;
+ sleep ( 1 );
+ }
+ } else {
+ bochs_attached() if $attached == 0;
+ $attached = 1;
+ }
+}
+
+END {
+ # Restore bochsrc file if applicable
+ if ( ( my $orig_file, my $backup_file ) = %$restore_file ) {
+ unlink $orig_file;
+ rename $backup_file, $orig_file;
+ }
+ # Restore terminal settings if applicable
+ if ( $restore_termios ) {
+ $restore_termios->setattr ( fileno(STDIN), TCSANOW );
+ }
+}