+
+diff -urp bochs-2.1.1-upstream/iodev/serial.cc bochs-2.1.1/iodev/serial.cc
+--- tmp/bochs-2.1.1/iodev/serial.cc 2004-02-11 14:28:54.000000000 -0800
++++ bochs-2.1.1/iodev/serial.cc 2005-06-01 20:26:01.000000000 -0700
+@@ -53,7 +53,7 @@
+ #endif
+ #endif
+
+-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__)
++#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__) || defined(__sun__)
+ #define SERIAL_ENABLE
+ #endif
+
+@@ -118,10 +118,11 @@ bx_serial_c::init(void)
+
+ #ifdef SERIAL_ENABLE
+ if (strlen(bx_options.com[0].Odev->getptr ()) > 0) {
+- tty_id = open(bx_options.com[0].Odev->getptr (), O_RDWR|O_NONBLOCK,600);
++ tty_id = open(bx_options.com[0].Odev->getptr (), O_RDWR,600);
+ if (tty_id < 0)
+ BX_PANIC(("open of %s (%s) failed\n",
+ "com1", bx_options.com[0].Odev->getptr ()));
++#if 0
+ BX_DEBUG(("tty_id: %d",tty_id));
+ tcgetattr(tty_id, &term_orig);
+ bcopy((caddr_t) &term_orig, (caddr_t) &term_new, sizeof(struct termios));
+@@ -145,6 +148,7 @@ bx_serial_c::init(void)
+ term_new.c_cc[VTIME] = 0;
+ //term_new.c_iflag |= IXOFF;
+ tcsetattr(tty_id, TCSAFLUSH, &term_new);
++#endif
+ }
+ #endif /* def SERIAL_ENABLE */
+ // nothing for now
+@@ -955,7 +968,7 @@ bx_serial_c::rx_timer(void)
+ }
+ if (rdy) {
+ chbuf = data;
+-#elif defined(SERIAL_ENABLE)
++#elif 0 && defined(SERIAL_ENABLE)
+ if ((tty_id >= 0) && (select(tty_id + 1, &fds, NULL, NULL, &tval) == 1)) {
+ (void) read(tty_id, &chbuf, 1);
+ BX_DEBUG(("read: '%c'",chbuf));
+
+diff -urp bochs-2.1.1.orig/bochs.h bochs-2.1.1/bochs.h
+--- bochs-2.1.1.orig/bochs.h 2004-02-11 14:28:03.000000000 -0800
++++ bochs-2.1.1/bochs.h 2004-09-20 17:02:01.000000000 -0700
+@@ -757,4 +757,6 @@ int bx_init_hardware ();
+
+ #endif
+
++extern int jitter;
++
+ #endif /* BX_BOCHS_H */
+diff -urp bochs-2.1.1.orig/iodev/pit82c54.cc bochs-2.1.1/iodev/pit82c54.cc
+--- bochs-2.1.1.orig/iodev/pit82c54.cc 2004-02-11 14:28:53.000000000 -0800
++++ bochs-2.1.1/iodev/pit82c54.cc 2004-09-20 17:18:24.000000000 -0700
+@@ -28,6 +28,7 @@
+
+ #include "bochs.h"
+ #include "pit82c54.h"
++#include <stdlib.h>
+ #define LOG_THIS this->
+
+
+@@ -356,7 +357,13 @@ pit_82C54::clock(Bit8u cnum) {
+ case 2:
+ if(thisctr.count_written) {
+ if(thisctr.triggerGATE || thisctr.first_pass) {
+- set_count(thisctr, thisctr.inlatch);
++ unsigned n = thisctr.inlatch;
++ if (jitter) {
++ n *= (double) rand() / RAND_MAX;
++ if (n < 5)
++ n = 5;
++ }
++ set_count(thisctr, n);
+ thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
+ thisctr.null_count=0;
+ if(thisctr.inlatch==1) {
+diff -urp bochs-2.1.1.orig/iodev/pit_wrap.cc bochs-2.1.1/iodev/pit_wrap.cc
+diff -urp bochs-2.1.1.orig/iodev/serial.cc bochs-2.1.1/iodev/serial.cc
+diff -urp bochs-2.1.1.orig/main.cc bochs-2.1.1/main.cc
+--- bochs-2.1.1.orig/main.cc 2004-02-11 14:28:41.000000000 -0800
++++ bochs-2.1.1/main.cc 2004-09-20 17:15:39.000000000 -0700
+@@ -58,6 +58,7 @@
+
+
+ int bochsrc_include_count = 0;
++int jitter = 0;
+
+ extern "C" {
+ #include <signal.h>
+@@ -2022,6 +2024,13 @@ bx_init_main (int argc, char *argv[])
+ else if (!strcmp ("-q", argv[arg])) {
+ SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START);
+ }
++ else if (!strcmp ("-j", argv[arg])) {
++ if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
++ else {
++ jitter = 1;
++ srand (atoi (argv[arg]));
++ }
++ }
+ else if (!strcmp ("-f", argv[arg])) {
+ if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
+ else bochsrc_filename = argv[arg];