Improve description.
[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 Here's a ./configure invocation for Bochs that works optimally with
18 the `pintos' utility:
19         ./configure --with-x --with-x11 --with-term --with-nogui
20 If you want the gdb stub, add --enable-gdb-stub
21 If you want the internal debugger, add --enable-debugger
22
23 diff -urp orig/bochs-2.1.1/Makefile.in bochs-2.1.1/Makefile.in
24 --- orig/bochs-2.1.1/Makefile.in        2004-02-11 14:28:02.000000000 -0800
25 +++ bochs-2.1.1/Makefile.in     2004-09-13 15:05:26.281550000 -0700
26 @@ -92,7 +92,7 @@ CXX = @CXX@
27  CFLAGS = @CFLAGS@ @GUI_CFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
28  CXXFLAGS = @CXXFLAGS@ @GUI_CXXFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
29  
30 -LDFLAGS = @LDFLAGS@
31 +LDFLAGS = @LDFLAGS@ -lsocket
32  LIBS = @LIBS@
33  # To compile with readline:
34  #   linux needs just -lreadline
35
36 diff -urp orig/bochs-2.1.1/gui/Makefile.in bochs-2.1.1/gui/Makefile.in
37 --- orig/bochs-2.1.1/gui/Makefile.in    2003-11-28 07:07:28.000000000 -0800
38 +++ bochs-2.1.1/gui/Makefile.in 2004-09-13 15:05:09.402039000 -0700
39 @@ -44,7 +44,7 @@ SHELL = /bin/sh
40  @SET_MAKE@
41  
42  CXX = @CXX@
43 -CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@  @GUI_CXXFLAGS@
44 +CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@  @GUI_CXXFLAGS@ -fms-extensions
45  LOCAL_CXXFLAGS =
46  LDFLAGS = @LDFLAGS@
47  LIBS = @LIBS@
48
49
50 diff -urp orig/bochs-2.1.1/gdbstub.cc bochs-2.1.1/gdbstub.cc
51 --- orig/bochs-2.1.1/gdbstub.cc 2004-02-11 14:28:41.000000000 -0800
52 +++ bochs-2.1.1/gdbstub.cc      2004-09-13 16:41:59.652988000 -0700
53 @@ -474,11 +475,13 @@ static void debug_loop(void)
54            case 'P':
55                {
56                   int reg;
57 -                 int value;
58 +                 Bit8u vbits[4];
59 +                 Bit32u value;
60                   char* ebuf;
61                   
62                   reg = strtoul(&buffer[1], &ebuf, 16);
63 -                 value = ntohl(strtoul(ebuf + 1, &ebuf, 16));
64 +                 hex2mem(ebuf + 1, vbits, sizeof value);
65 +                 ReadHostDWordFromLittleEndian(vbits, value);
66                   
67                   BX_INFO (("reg %d set to %x", reg, value));
68                   
69 @@ -527,35 +530,36 @@ static void debug_loop(void)
70                }
71              
72            case 'g':
73 -            registers[0] = EAX;
74 -            registers[1] = ECX;
75 -            registers[2] = EDX;
76 -            registers[3] = EBX;
77 -            registers[4] = ESP;
78 -            registers[5] = EBP;
79 -            registers[6] = ESI;
80 -            registers[7] = EDI;
81 +            WriteHostDWordToLittleEndian(registers + 0, EAX);
82 +            WriteHostDWordToLittleEndian(registers + 1, ECX);
83 +            WriteHostDWordToLittleEndian(registers + 2, EDX);
84 +            WriteHostDWordToLittleEndian(registers + 3, EBX);
85 +            WriteHostDWordToLittleEndian(registers + 4, ESP);
86 +            WriteHostDWordToLittleEndian(registers + 5, EBP);
87 +            WriteHostDWordToLittleEndian(registers + 6, ESI);
88 +            WriteHostDWordToLittleEndian(registers + 7, EDI);
89              if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT)
90                {
91 -                 registers[8] = EIP + 1;
92 +                WriteHostDWordToLittleEndian(registers + 8, EIP + 1);
93                }
94              else
95                {
96 -                 registers[8] = EIP;
97 +                WriteHostDWordToLittleEndian(registers + 8, EIP);
98                }
99 -            registers[9] = BX_CPU_THIS_PTR read_eflags();
100 -            registers[10] = 
101 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value;
102 -            registers[11] = 
103 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value;
104 -            registers[12] = 
105 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value;
106 -            registers[13] = 
107 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value;
108 -            registers[14] = 
109 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value;
110 -            registers[15] = 
111 -              BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value;
112 +            WriteHostDWordToLittleEndian(registers + 9,
113 +                                         BX_CPU_THIS_PTR read_eflags());
114 +            WriteHostDWordToLittleEndian(registers + 10,
115 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value);
116 +            WriteHostDWordToLittleEndian(registers + 11,
117 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value);
118 +            WriteHostDWordToLittleEndian(registers + 12,
119 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value);
120 +            WriteHostDWordToLittleEndian(registers + 13,
121 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value);
122 +            WriteHostDWordToLittleEndian(registers + 14,
123 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value);
124 +            WriteHostDWordToLittleEndian(registers + 15,
125 +              BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value);
126              mem2hex((char *)registers, obuf, NUMREGSBYTES);
127              put_reply(obuf);
128              break;
129 --- tmp/bochs-2.1.1/iodev/serial.cc     2004-02-11 14:28:54.000001000 -0800
130 +++ bochs-2.1.1/iodev/serial.cc 2004-09-14 23:02:04.000001000 -0700
131 @@ -53,7 +53,7 @@
132  #endif
133  #endif
134  
135 -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__)
136 +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__APPLE__) || defined(__sun__)
137  #define SERIAL_ENABLE
138  #endif
139  
140 @@ -122,6 +122,7 @@
141      if (tty_id < 0)
142        BX_PANIC(("open of %s (%s) failed\n",
143                  "com1", bx_options.com[0].Odev->getptr ()));
144 +#if 0
145      BX_DEBUG(("tty_id: %d",tty_id));
146      tcgetattr(tty_id, &term_orig);
147      bcopy((caddr_t) &term_orig, (caddr_t) &term_new, sizeof(struct termios));
148 @@ -145,6 +146,7 @@
149      term_new.c_cc[VTIME] = 0;
150      //term_new.c_iflag |= IXOFF;
151      tcsetattr(tty_id, TCSAFLUSH, &term_new);
152 +#endif
153    }
154  #endif   /* def SERIAL_ENABLE */
155    // nothing for now