Explain how to use patch.
[pintos-anon] / src / misc / bochs-2.1.1.patch
1 The first two patches are needed for Bochs to properly compile and run
2 under Solaris on Sparc.  If you're not compiling on Solaris, don't
3 apply them.  The first should probably be handled by Autoconf; I'm not
4 sure why it isn't.  The second is needed to make GCC accept X.h's
5 frequent use of "extern foo(...)", because use of an implicit int
6 return type is forbidden in C++.
7
8 The third patch makes the gdb stubs work on Solaris/Sparc, by doing
9 proper byteswapping.  It should be harmless elsewhere.
10
11 The fourth patch enables the serial device under Solaris and disables
12 tty setup at the same time.  Tty setup is a pain when you want to
13 connect a serial port to stdout and it doesn't work under Solaris
14 anyway.  This patch is useful everywhere with `pintos', but may not be
15 wanted elsewhere.
16
17 To apply all the patches, cd into the Bochs directory, then type
18         patch -p1 < ~/pintos/src/misc/bochs-2.1.1.patch
19 You will have to supply the proper path to the patch, of course.  You
20 can provide the --dry-run option to patch if you want to test whether
21 the patch would apply cleanly before actually patching.
22
23 To apply a subset of the patches, use a text editor to delete the
24 unwanted patches, then follow the above instructions.
25
26 Here's a ./configure invocation for Bochs that works optimally with
27 the `pintos' utility:
28         ./configure --with-x --with-x11 --with-term --with-nogui
29 If you want the gdb stub, add --enable-gdb-stub
30 If you want the internal debugger, add --enable-debugger
31
32 diff -urp orig/bochs-2.1.1/Makefile.in bochs-2.1.1/Makefile.in
33 --- orig/bochs-2.1.1/Makefile.in        2004-02-11 14:28:02.000000000 -0800
34 +++ bochs-2.1.1/Makefile.in     2004-09-13 15:05:26.281550000 -0700
35 @@ -92,7 +92,7 @@ CXX = @CXX@
36  CFLAGS = @CFLAGS@ @GUI_CFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
37  CXXFLAGS = @CXXFLAGS@ @GUI_CXXFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
38  
39 -LDFLAGS = @LDFLAGS@
40 +LDFLAGS = @LDFLAGS@ -lsocket
41  LIBS = @LIBS@
42  # To compile with readline:
43  #   linux needs just -lreadline
44
45 diff -urp orig/bochs-2.1.1/gui/Makefile.in bochs-2.1.1/gui/Makefile.in
46 --- orig/bochs-2.1.1/gui/Makefile.in    2003-11-28 07:07:28.000000000 -0800
47 +++ bochs-2.1.1/gui/Makefile.in 2004-09-13 15:05:09.402039000 -0700
48 @@ -44,7 +44,7 @@ SHELL = /bin/sh
49  @SET_MAKE@
50  
51  CXX = @CXX@
52 -CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@  @GUI_CXXFLAGS@
53 +CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@  @GUI_CXXFLAGS@ -fms-extensions
54  LOCAL_CXXFLAGS =
55  LDFLAGS = @LDFLAGS@
56  LIBS = @LIBS@
57
58
59 diff -urp orig/bochs-2.1.1/gdbstub.cc bochs-2.1.1/gdbstub.cc
60 --- orig/bochs-2.1.1/gdbstub.cc 2004-02-11 14:28:41.000000000 -0800
61 +++ bochs-2.1.1/gdbstub.cc      2004-09-13 16:41:59.652988000 -0700
62 @@ -474,11 +475,13 @@ static void debug_loop(void)
63            case 'P':
64                {
65                   int reg;
66 -                 int value;
67 +                 Bit8u vbits[4];
68 +                 Bit32u value;
69                   char* ebuf;
70                   
71                   reg = strtoul(&buffer[1], &ebuf, 16);
72 -                 value = ntohl(strtoul(ebuf + 1, &ebuf, 16));
73 +                 hex2mem(ebuf + 1, vbits, sizeof value);
74 +                 ReadHostDWordFromLittleEndian(vbits, value);
75                   
76                   BX_INFO (("reg %d set to %x", reg, value));
77                   
78 @@ -527,35 +530,36 @@ static void debug_loop(void)
79                }
80              
81            case 'g':
82 -            registers[0] = EAX;
83 -            registers[1] = ECX;
84 -            registers[2] = EDX;
85 -            registers[3] = EBX;
86 -            registers[4] = ESP;
87 -            registers[5] = EBP;
88 -            registers[6] = ESI;
89 -            registers[7] = EDI;
90 +            WriteHostDWordToLittleEndian(registers + 0, EAX);
91 +            WriteHostDWordToLittleEndian(registers + 1, ECX);
92 +            WriteHostDWordToLittleEndian(registers + 2, EDX);
93 +            WriteHostDWordToLittleEndian(registers + 3, EBX);
94 +            WriteHostDWordToLittleEndian(registers + 4, ESP);
95 +            WriteHostDWordToLittleEndian(registers + 5, EBP);
96 +            WriteHostDWordToLittleEndian(registers + 6, ESI);
97 +            WriteHostDWordToLittleEndian(registers + 7, EDI);
98              if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT)
99                {
100 -                 registers[8] = EIP + 1;
101 +                WriteHostDWordToLittleEndian(registers + 8, EIP + 1);
102                }
103              else
104                {
105 -                 registers[8] = EIP;
106 +                WriteHostDWordToLittleEndian(registers + 8, EIP);
107                }
108 -            registers[9] = BX_CPU_THIS_PTR read_eflags();
109 -            registers[10] = 
110 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value;
111 -            registers[11] = 
112 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value;
113 -            registers[12] = 
114 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value;
115 -            registers[13] = 
116 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value;
117 -            registers[14] = 
118 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value;
119 -            registers[15] = 
120 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value;
121 +            WriteHostDWordToLittleEndian(registers + 9,
122 +                                         BX_CPU_THIS_PTR read_eflags());
123 +            WriteHostDWordToLittleEndian(registers + 10,
124 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value);
125 +            WriteHostDWordToLittleEndian(registers + 11,
126 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value);
127 +            WriteHostDWordToLittleEndian(registers + 12,
128 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value);
129 +            WriteHostDWordToLittleEndian(registers + 13,
130 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value);
131 +            WriteHostDWordToLittleEndian(registers + 14,
132 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value);
133 +            WriteHostDWordToLittleEndian(registers + 15,
134 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value);
135              mem2hex((char *)registers, obuf, NUMREGSBYTES);
136              put_reply(obuf);
137              break;
138 --- tmp/bochs-2.1.1/iodev/serial.cc     2004-02-11 14:28:54.000001000 -0800
139 +++ bochs-2.1.1/iodev/serial.cc 2004-09-14 23:02:04.000001000 -0700
140 @@ -53,7 +53,7 @@
141  #endif
142  #endif
143  
144 -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__)
145 +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__) || defined(__sun__)
146  #define SERIAL_ENABLE
147  #endif
148  
149 @@ -122,6 +122,7 @@
150      if (tty_id < 0)
151        BX_PANIC(("open of %s (%s) failed\n",
152                  "com1", bx_options.com[0].Odev->getptr ()));
153 +#if 0
154      BX_DEBUG(("tty_id: %d",tty_id));
155      tcgetattr(tty_id, &term_orig);
156      bcopy((caddr_t) &term_orig, (caddr_t) &term_new, sizeof(struct termios));
157 @@ -145,6 +146,7 @@
158      term_new.c_cc[VTIME] = 0;
159      //term_new.c_iflag |= IXOFF;
160      tcsetattr(tty_id, TCSAFLUSH, &term_new);
161 +#endif
162    }
163  #endif   /* def SERIAL_ENABLE */
164    // nothing for now