GNU Binutils with patches for OS216
Revision | 727b6b4b411c55d0d6719556bcf6a5da5c54adb6 (tree) |
---|---|
Time | 2006-03-14 12:34:28 |
Author | DJ Delorie <dj@redh...> |
Commiter | DJ Delorie |
* 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.
@@ -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 | + | |
1 | 13 | 2005-10-06 Jim Blandy <jimb@redhat.com> |
2 | 14 | |
3 | 15 | Simulator for Renesas M32C and M16C, by DJ Delorie <dj@redhat.com>, |
@@ -202,6 +202,23 @@ mem_put_byte (int address, unsigned char value) | ||
202 | 202 | } |
203 | 203 | break; |
204 | 204 | |
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 | + | |
205 | 222 | case 0x400: |
206 | 223 | m32c_syscall (value); |
207 | 224 | break; |
@@ -232,6 +249,11 @@ mem_put_qi (int address, unsigned char value) | ||
232 | 249 | void |
233 | 250 | mem_put_hi (int address, unsigned short value) |
234 | 251 | { |
252 | + if (address == 0x402) | |
253 | + { | |
254 | + printf ("SimTrace: %06lx %04x\n", regs.r_pc, value); | |
255 | + return; | |
256 | + } | |
235 | 257 | S ("<="); |
236 | 258 | mem_put_byte (address, value & 0xff); |
237 | 259 | mem_put_byte (address + 1, value >> 8); |
@@ -288,16 +310,16 @@ mem_get_byte (int address) | ||
288 | 310 | address &= membus_mask; |
289 | 311 | S ("=>"); |
290 | 312 | m = mem_ptr (address); |
291 | - if (trace) | |
313 | + switch (address) | |
292 | 314 | { |
293 | - if (tpr) | |
315 | + case 0x3ad: /* uart1c1 */ | |
316 | + E(); | |
317 | + return 2; /* transmitter empty */ | |
318 | + break; | |
319 | + default: | |
320 | + if (trace) | |
294 | 321 | printf (" %02x", *m); |
295 | - else | |
296 | - { | |
297 | - S ("=>"); | |
298 | - printf (" %02x", *m); | |
299 | - E (); | |
300 | - } | |
322 | + break; | |
301 | 323 | } |
302 | 324 | E (); |
303 | 325 | return *m; |
@@ -240,6 +240,15 @@ shift_op (srcdest sd, int arith, int count) | ||
240 | 240 | { |
241 | 241 | mask = 0xffffffffU; |
242 | 242 | 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); | |
243 | 252 | } |
244 | 253 | |
245 | 254 | tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count); |
@@ -292,6 +301,12 @@ shift_op (srcdest sd, int arith, int count) | ||
292 | 301 | tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \ |
293 | 302 | set_c (v); |
294 | 303 | |
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 | + | |
295 | 310 | int |
296 | 311 | decode_r8c() |
297 | 312 | { |
@@ -448,7 +463,7 @@ decode_r8c() | ||
448 | 463 | /** 0111 1110 0010 dest BMcnd dest */ |
449 | 464 | |
450 | 465 | dc = decode_bit (dest); |
451 | - if (condition_true (IMM (0))) | |
466 | + if (condition_true (bmcnd_cond_map [IMM (0) & 15])) | |
452 | 467 | put_bit (dc, 1); |
453 | 468 | else |
454 | 469 | put_bit (dc, 0); |
@@ -347,7 +347,7 @@ condition_true (int cond_id) | ||
347 | 347 | "(S^O)|Z", "O", "!(S^O)", "unk", |
348 | 348 | "!((S^O)|Z)", "!O", "S^O", "unk" |
349 | 349 | }; |
350 | - switch (cond_id) | |
350 | + switch (cond_id & 15) | |
351 | 351 | { |
352 | 352 | case 0: |
353 | 353 | f = FLAG_C; |
@@ -409,7 +409,7 @@ condition_true (int cond_id) | ||
409 | 409 | "C", "GTU", "Z", "N", |
410 | 410 | "O", "LE", "LT", "!?" |
411 | 411 | }; |
412 | - switch (cond_id) | |
412 | + switch (cond_id & 15) | |
413 | 413 | { |
414 | 414 | case 0: |
415 | 415 | f = !FLAG_C; |
@@ -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 |
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
33 | 33 | #include "mem.h" |
34 | 34 | #include "syscalls.h" |
35 | 35 | |
36 | -#include "../../libgloss/syscall.h" | |
36 | +#include "syscall.h" | |
37 | 37 | |
38 | 38 | /* The current syscall callbacks we're using. */ |
39 | 39 | static struct host_callback_struct *callbacks; |