Basic Eraser support.
[pintos-anon] / src / misc / bochs-2.1.1-jitter.patch
1 This patch adds the `jitter' feature described in the project
2 documentation, in which timer interrupts are delivered at random
3 intervals.
4
5 diff -urp bochs-2.1.1.orig/bochs.h bochs-2.1.1/bochs.h
6 --- bochs-2.1.1.orig/bochs.h    2004-02-11 14:28:03.000000000 -0800
7 +++ bochs-2.1.1/bochs.h 2004-09-20 17:02:01.000000000 -0700
8 @@ -757,4 +757,6 @@ int bx_init_hardware ();
9  
10  #endif
11  
12 +extern int jitter;
13 +
14  #endif  /* BX_BOCHS_H */
15 diff -urp bochs-2.1.1.orig/iodev/pit82c54.cc bochs-2.1.1/iodev/pit82c54.cc
16 --- bochs-2.1.1.orig/iodev/pit82c54.cc  2004-02-11 14:28:53.000000000 -0800
17 +++ bochs-2.1.1/iodev/pit82c54.cc       2004-09-20 17:18:24.000000000 -0700
18 @@ -28,6 +28,7 @@
19  
20  #include "bochs.h"
21  #include "pit82c54.h"
22 +#include <stdlib.h>
23  #define LOG_THIS this->
24  
25  
26 @@ -356,7 +357,13 @@ pit_82C54::clock(Bit8u cnum) {
27        case 2:
28         if(thisctr.count_written) {
29           if(thisctr.triggerGATE || thisctr.first_pass) {
30 -           set_count(thisctr, thisctr.inlatch);
31 +            unsigned n = thisctr.inlatch;
32 +            if (jitter) {
33 +                n *= (double) rand() / RAND_MAX;
34 +                if (n < 5)
35 +                    n = 5;
36 +            }
37 +           set_count(thisctr, n);
38             thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
39             thisctr.null_count=0;
40             if(thisctr.inlatch==1) {
41 diff -urp bochs-2.1.1.orig/main.cc bochs-2.1.1/main.cc
42 --- bochs-2.1.1.orig/main.cc    2004-02-11 14:28:41.000000000 -0800
43 +++ bochs-2.1.1/main.cc 2004-09-20 17:15:39.000000000 -0700
44 @@ -58,6 +58,7 @@
45  
46  
47  int bochsrc_include_count = 0;
48 +int jitter = 0;
49  
50  extern "C" {
51  #include <signal.h>
52 @@ -2022,6 +2024,13 @@ bx_init_main (int argc, char *argv[])
53      else if (!strcmp ("-q", argv[arg])) {
54        SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START);
55      }
56 +    else if (!strcmp ("-j", argv[arg])) {
57 +      if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
58 +      else {
59 +        jitter = 1;
60 +        srand (atoi (argv[arg]));
61 +      }
62 +    }
63      else if (!strcmp ("-f", argv[arg])) {
64        if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
65        else bochsrc_filename = argv[arg];