• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision727b6b4b411c55d0d6719556bcf6a5da5c54adb6 (tree)
Time2006-03-14 12:34:28
AuthorDJ Delorie <dj@redh...>
CommiterDJ Delorie

Log Message

* mem.c (mem_put_byte): Hook simulated UART to stdout.
(mem_put_hi): Hook in simulated trace port.
(mem_get_byte): Hook in simulated uart control port.
* opc2c: Be more picky about matching special comments.
* r8c.opc (shift_op): Limit shift counts to -16..16.
(BMcnd): Map conditional codes.
* reg.c (condition_true): Mask condition code to 4 bits.
* syscalls.c: Include local syscall.h.
* syscall.h: New, copied from libgloss.

Change Summary

Incremental Difference

--- a/sim/m32c/ChangeLog
+++ b/sim/m32c/ChangeLog
@@ -1,3 +1,15 @@
1+2006-03-13 DJ Delorie <dj@redhat.com>
2+
3+ * mem.c (mem_put_byte): Hook simulated UART to stdout.
4+ (mem_put_hi): Hook in simulated trace port.
5+ (mem_get_byte): Hook in simulated uart control port.
6+ * opc2c: Be more picky about matching special comments.
7+ * r8c.opc (shift_op): Limit shift counts to -16..16.
8+ (BMcnd): Map conditional codes.
9+ * reg.c (condition_true): Mask condition code to 4 bits.
10+ * syscalls.c: Include local syscall.h.
11+ * syscall.h: New, copied from libgloss.
12+
113 2005-10-06 Jim Blandy <jimb@redhat.com>
214
315 Simulator for Renesas M32C and M16C, by DJ Delorie <dj@redhat.com>,
--- a/sim/m32c/mem.c
+++ b/sim/m32c/mem.c
@@ -202,6 +202,23 @@ mem_put_byte (int address, unsigned char value)
202202 }
203203 break;
204204
205+ case 0x3aa: /* uart1tx */
206+ {
207+ static int pending_exit = 0;
208+ if (value == 0)
209+ {
210+ if (pending_exit)
211+ {
212+ step_result = M32C_MAKE_EXITED(value);
213+ return;
214+ }
215+ pending_exit = 1;
216+ }
217+ else
218+ putchar(value);
219+ }
220+ break;
221+
205222 case 0x400:
206223 m32c_syscall (value);
207224 break;
@@ -232,6 +249,11 @@ mem_put_qi (int address, unsigned char value)
232249 void
233250 mem_put_hi (int address, unsigned short value)
234251 {
252+ if (address == 0x402)
253+ {
254+ printf ("SimTrace: %06lx %04x\n", regs.r_pc, value);
255+ return;
256+ }
235257 S ("<=");
236258 mem_put_byte (address, value & 0xff);
237259 mem_put_byte (address + 1, value >> 8);
@@ -288,16 +310,16 @@ mem_get_byte (int address)
288310 address &= membus_mask;
289311 S ("=>");
290312 m = mem_ptr (address);
291- if (trace)
313+ switch (address)
292314 {
293- if (tpr)
315+ case 0x3ad: /* uart1c1 */
316+ E();
317+ return 2; /* transmitter empty */
318+ break;
319+ default:
320+ if (trace)
294321 printf (" %02x", *m);
295- else
296- {
297- S ("=>");
298- printf (" %02x", *m);
299- E ();
300- }
322+ break;
301323 }
302324 E ();
303325 return *m;
--- a/sim/m32c/r8c.opc
+++ b/sim/m32c/r8c.opc
@@ -240,6 +240,15 @@ shift_op (srcdest sd, int arith, int count)
240240 {
241241 mask = 0xffffffffU;
242242 msb = 0x80000000U;
243+ if (count > 16 || count < -16)
244+ {
245+ fprintf(stderr, "Error: SI shift of %d undefined\n", count);
246+ exit(1);
247+ }
248+ if (count > 16)
249+ count = (count - 1) % 16 + 1;
250+ if (count < -16)
251+ count = -((-count - 1) % 16 + 1);
243252 }
244253
245254 tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count);
@@ -292,6 +301,12 @@ shift_op (srcdest sd, int arith, int count)
292301 tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \
293302 set_c (v);
294303
304+/* The "BMcnd dest" opcode uses a different encoding for the */
305+/* condition than other opcodes. */
306+static int bmcnd_cond_map[] = {
307+ 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15
308+};
309+
295310 int
296311 decode_r8c()
297312 {
@@ -448,7 +463,7 @@ decode_r8c()
448463 /** 0111 1110 0010 dest BMcnd dest */
449464
450465 dc = decode_bit (dest);
451- if (condition_true (IMM (0)))
466+ if (condition_true (bmcnd_cond_map [IMM (0) & 15]))
452467 put_bit (dc, 1);
453468 else
454469 put_bit (dc, 0);
--- a/sim/m32c/reg.c
+++ b/sim/m32c/reg.c
@@ -347,7 +347,7 @@ condition_true (int cond_id)
347347 "(S^O)|Z", "O", "!(S^O)", "unk",
348348 "!((S^O)|Z)", "!O", "S^O", "unk"
349349 };
350- switch (cond_id)
350+ switch (cond_id & 15)
351351 {
352352 case 0:
353353 f = FLAG_C;
@@ -409,7 +409,7 @@ condition_true (int cond_id)
409409 "C", "GTU", "Z", "N",
410410 "O", "LE", "LT", "!?"
411411 };
412- switch (cond_id)
412+ switch (cond_id & 15)
413413 {
414414 case 0:
415415 f = !FLAG_C;
--- /dev/null
+++ b/sim/m32c/syscall.h
@@ -0,0 +1,50 @@
1+/* Copied from libgloss */
2+/* General use syscall.h file.
3+ The more ports that use this file, the simpler sim/common/nltvals.def
4+ remains. */
5+
6+#ifndef LIBGLOSS_SYSCALL_H
7+#define LIBGLOSS_SYSCALL_H
8+
9+/* Note: This file may be included by assembler source. */
10+
11+/* These should be as small as possible to allow a port to use a trap type
12+ instruction, which the system call # as the trap (the d10v for instance
13+ supports traps 0..31). An alternative would be to define one trap for doing
14+ system calls, and put the system call number in a register that is not used
15+ for the normal calling sequence (so that you don't have to shift down the
16+ arguments to add the system call number). Obviously, if these system call
17+ numbers are ever changed, all of the simulators and potentially user code
18+ will need to be updated. */
19+
20+/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait,
21+ etc. etc. Don't add them. */
22+
23+/* These are required by the ANSI C part of newlib (excluding system() of
24+ course). */
25+#define SYS_exit 1
26+#define SYS_open 2
27+#define SYS_close 3
28+#define SYS_read 4
29+#define SYS_write 5
30+#define SYS_lseek 6
31+#define SYS_unlink 7
32+#define SYS_getpid 8
33+#define SYS_kill 9
34+#define SYS_fstat 10
35+/*#define SYS_sbrk 11 - not currently a system call, but reserved. */
36+
37+/* ARGV support. */
38+#define SYS_argvlen 12
39+#define SYS_argv 13
40+
41+/* These are extras added for one reason or another. */
42+#define SYS_chdir 14
43+#define SYS_stat 15
44+#define SYS_chmod 16
45+#define SYS_utime 17
46+#define SYS_time 18
47+#define SYS_gettimeofday 19
48+#define SYS_times 20
49+#define SYS_link 21
50+#endif
--- a/sim/m32c/syscalls.c
+++ b/sim/m32c/syscalls.c
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
3333 #include "mem.h"
3434 #include "syscalls.h"
3535
36-#include "../../libgloss/syscall.h"
36+#include "syscall.h"
3737
3838 /* The current syscall callbacks we're using. */
3939 static struct host_callback_struct *callbacks;