1 /* Simulator for the Renesas (formerly Hitachi) / SuperH Inc. SH architecture.
3 Written by Steve Chamberlain of Cygnus Support.
6 This file is part of SH sim
9 THIS SOFTWARE IS NOT COPYRIGHTED
11 Cygnus offers the following for use in the public domain. Cygnus
12 makes no warranty with regard to the software or it's performance
13 and the user accepts the software "AS IS" with all faults.
15 CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
16 THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 # define MAP_FAILED -1
32 # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
33 # define MAP_ANONYMOUS MAP_ANON
39 #include "gdb/callback.h"
40 #include "gdb/remote-sim.h"
41 #include "gdb/sim-sh.h"
43 /* This file is local - if newlib changes, then so should this. */
49 #include <float.h> /* Needed for _isnan() */
54 #define SIGBUS SIGSEGV
58 #define SIGQUIT SIGTERM
65 extern unsigned short sh_jump_table
[], sh_dsp_table
[0x1000], ppi_table
[];
67 int sim_write (SIM_DESC sd
, SIM_ADDR addr
, unsigned char *buffer
, int size
);
69 #define O_RECOMPILE 85
71 #define DISASSEMBLER_TABLE
73 /* Define the rate at which the simulator should poll the host
75 #define POLL_QUIT_INTERVAL 0x60000
90 /* System registers. For sh-dsp this also includes A0 / X0 / X1 / Y0 / Y1
91 which are located in fregs, i.e. strictly speaking, these are
92 out-of-bounds accesses of sregs.i . This wart of the code could be
93 fixed by making fregs part of sregs, and including pc too - to avoid
94 alignment repercussions - but this would cause very onerous union /
95 structure nesting, which would only be managable with anonymous
96 unions and structs. */
105 int fpul
; /* A1 for sh-dsp - but only for movs etc. */
106 int fpscr
; /* dsr for sh-dsp */
120 /* Control registers; on the SH4, ldc / stc is privileged, except when
137 int dbr
; /* debug base register */
138 int sgr
; /* saved gr15 */
139 int ldst
; /* load/store flag (boolean) */
141 int ibcr
; /* sh2a bank control register */
142 int ibnr
; /* sh2a bank number register */
147 unsigned char *insn_end
;
159 int end_of_registers
;
162 #define PROFILE_FREQ 1
163 #define PROFILE_SHIFT 2
165 unsigned short *profile_hist
;
166 unsigned char *memory
;
167 int xyram_select
, xram_start
, yram_start
;
170 unsigned char *xmem_offset
;
171 unsigned char *ymem_offset
;
172 unsigned long bfd_mach
;
173 regstacktype
*regstack
;
179 saved_state_type saved_state
;
181 struct loop_bounds
{ unsigned char *start
, *end
; };
183 /* These variables are at file scope so that functions other than
184 sim_resume can use the fetch/store macros */
186 static int target_little_endian
;
187 static int global_endianw
, endianb
;
188 static int target_dsp
;
189 static int host_little_endian
;
190 static char **prog_argv
;
192 static int maskw
= 0;
193 static int maskl
= 0;
195 static SIM_OPEN_KIND sim_kind
;
197 static int tracing
= 0;
200 /* Short hand definitions of the registers */
202 #define SBIT(x) ((x)&sbit)
203 #define R0 saved_state.asregs.regs[0]
204 #define Rn saved_state.asregs.regs[n]
205 #define Rm saved_state.asregs.regs[m]
206 #define UR0 (unsigned int) (saved_state.asregs.regs[0])
207 #define UR (unsigned int) R
208 #define UR (unsigned int) R
209 #define SR0 saved_state.asregs.regs[0]
210 #define CREG(n) (saved_state.asregs.cregs.i[(n)])
211 #define GBR saved_state.asregs.cregs.named.gbr
212 #define VBR saved_state.asregs.cregs.named.vbr
213 #define DBR saved_state.asregs.cregs.named.dbr
214 #define TBR saved_state.asregs.cregs.named.tbr
215 #define IBCR saved_state.asregs.cregs.named.ibcr
216 #define IBNR saved_state.asregs.cregs.named.ibnr
217 #define BANKN (saved_state.asregs.cregs.named.ibnr & 0x1ff)
218 #define ME ((saved_state.asregs.cregs.named.ibnr >> 14) & 0x3)
219 #define SSR saved_state.asregs.cregs.named.ssr
220 #define SPC saved_state.asregs.cregs.named.spc
221 #define SGR saved_state.asregs.cregs.named.sgr
222 #define SREG(n) (saved_state.asregs.sregs.i[(n)])
223 #define MACH saved_state.asregs.sregs.named.mach
224 #define MACL saved_state.asregs.sregs.named.macl
225 #define PR saved_state.asregs.sregs.named.pr
226 #define FPUL saved_state.asregs.sregs.named.fpul
232 /* Alternate bank of registers r0-r7 */
234 /* Note: code controling SR handles flips between BANK0 and BANK1 */
235 #define Rn_BANK(n) (saved_state.asregs.cregs.named.bank[(n)])
236 #define SET_Rn_BANK(n, EXP) do { saved_state.asregs.cregs.named.bank[(n)] = (EXP); } while (0)
241 #define SR_MASK_BO (1 << 14)
242 #define SR_MASK_CS (1 << 13)
243 #define SR_MASK_DMY (1 << 11)
244 #define SR_MASK_DMX (1 << 10)
245 #define SR_MASK_M (1 << 9)
246 #define SR_MASK_Q (1 << 8)
247 #define SR_MASK_I (0xf << 4)
248 #define SR_MASK_S (1 << 1)
249 #define SR_MASK_T (1 << 0)
251 #define SR_MASK_BL (1 << 28)
252 #define SR_MASK_RB (1 << 29)
253 #define SR_MASK_MD (1 << 30)
254 #define SR_MASK_RC 0x0fff0000
255 #define SR_RC_INCREMENT -0x00010000
257 #define BO ((saved_state.asregs.cregs.named.sr & SR_MASK_BO) != 0)
258 #define CS ((saved_state.asregs.cregs.named.sr & SR_MASK_CS) != 0)
259 #define M ((saved_state.asregs.cregs.named.sr & SR_MASK_M) != 0)
260 #define Q ((saved_state.asregs.cregs.named.sr & SR_MASK_Q) != 0)
261 #define S ((saved_state.asregs.cregs.named.sr & SR_MASK_S) != 0)
262 #define T ((saved_state.asregs.cregs.named.sr & SR_MASK_T) != 0)
263 #define LDST ((saved_state.asregs.cregs.named.ldst) != 0)
265 #define SR_BL ((saved_state.asregs.cregs.named.sr & SR_MASK_BL) != 0)
266 #define SR_RB ((saved_state.asregs.cregs.named.sr & SR_MASK_RB) != 0)
267 #define SR_MD ((saved_state.asregs.cregs.named.sr & SR_MASK_MD) != 0)
268 #define SR_DMY ((saved_state.asregs.cregs.named.sr & SR_MASK_DMY) != 0)
269 #define SR_DMX ((saved_state.asregs.cregs.named.sr & SR_MASK_DMX) != 0)
270 #define SR_RC ((saved_state.asregs.cregs.named.sr & SR_MASK_RC))
272 /* Note: don't use this for privileged bits */
273 #define SET_SR_BIT(EXP, BIT) \
276 saved_state.asregs.cregs.named.sr |= (BIT); \
278 saved_state.asregs.cregs.named.sr &= ~(BIT); \
281 #define SET_SR_BO(EXP) SET_SR_BIT ((EXP), SR_MASK_BO)
282 #define SET_SR_CS(EXP) SET_SR_BIT ((EXP), SR_MASK_CS)
283 #define SET_BANKN(EXP) \
285 IBNR = (IBNR & 0xfe00) | (EXP & 0x1f); \
287 #define SET_ME(EXP) \
289 IBNR = (IBNR & 0x3fff) | ((EXP & 0x3) << 14); \
291 #define SET_SR_M(EXP) SET_SR_BIT ((EXP), SR_MASK_M)
292 #define SET_SR_Q(EXP) SET_SR_BIT ((EXP), SR_MASK_Q)
293 #define SET_SR_S(EXP) SET_SR_BIT ((EXP), SR_MASK_S)
294 #define SET_SR_T(EXP) SET_SR_BIT ((EXP), SR_MASK_T)
295 #define SET_LDST(EXP) (saved_state.asregs.cregs.named.ldst = ((EXP) != 0))
297 /* stc currently relies on being able to read SR without modifications. */
298 #define GET_SR() (saved_state.asregs.cregs.named.sr - 0)
300 #define SET_SR(x) set_sr (x)
303 (saved_state.asregs.cregs.named.sr \
304 = saved_state.asregs.cregs.named.sr & 0xf000ffff | ((x) & 0xfff) << 16)
306 /* Manipulate FPSCR */
308 #define FPSCR_MASK_FR (1 << 21)
309 #define FPSCR_MASK_SZ (1 << 20)
310 #define FPSCR_MASK_PR (1 << 19)
312 #define FPSCR_FR ((GET_FPSCR () & FPSCR_MASK_FR) != 0)
313 #define FPSCR_SZ ((GET_FPSCR () & FPSCR_MASK_SZ) != 0)
314 #define FPSCR_PR ((GET_FPSCR () & FPSCR_MASK_PR) != 0)
316 /* Count the number of arguments in an argv. */
318 count_argc (char **argv
)
325 for (i
= 0; argv
[i
] != NULL
; ++i
)
334 int old
= saved_state
.asregs
.sregs
.named
.fpscr
;
335 saved_state
.asregs
.sregs
.named
.fpscr
= (x
);
336 /* swap the floating point register banks */
337 if ((saved_state
.asregs
.sregs
.named
.fpscr
^ old
) & FPSCR_MASK_FR
338 /* Ignore bit change if simulating sh-dsp. */
341 union fregs_u tmpf
= saved_state
.asregs
.fregs
[0];
342 saved_state
.asregs
.fregs
[0] = saved_state
.asregs
.fregs
[1];
343 saved_state
.asregs
.fregs
[1] = tmpf
;
347 /* sts relies on being able to read fpscr directly. */
348 #define GET_FPSCR() (saved_state.asregs.sregs.named.fpscr)
349 #define SET_FPSCR(x) \
354 #define DSR (saved_state.asregs.sregs.named.fpscr)
362 #define RAISE_EXCEPTION(x) \
363 (saved_state.asregs.exception = x, saved_state.asregs.insn_end = 0)
365 #define RAISE_EXCEPTION_IF_IN_DELAY_SLOT() \
366 if (in_delay_slot) RAISE_EXCEPTION (SIGILL)
368 /* This function exists mainly for the purpose of setting a breakpoint to
369 catch simulated bus errors when running the simulator under GDB. */
381 raise_exception (SIGBUS
);
384 #define PROCESS_SPECIAL_ADDRESS(addr, endian, ptr, bits_written, \
385 forbidden_addr_bits, data, retval) \
387 if (addr & forbidden_addr_bits) \
392 else if ((addr & saved_state.asregs.xyram_select) \
393 == saved_state.asregs.xram_start) \
394 ptr = (void *) &saved_state.asregs.xmem_offset[addr ^ endian]; \
395 else if ((addr & saved_state.asregs.xyram_select) \
396 == saved_state.asregs.yram_start) \
397 ptr = (void *) &saved_state.asregs.ymem_offset[addr ^ endian]; \
398 else if ((unsigned) addr >> 24 == 0xf0 \
399 && bits_written == 32 && (data & 1) == 0) \
400 /* This invalidates (if not associative) or might invalidate \
401 (if associative) an instruction cache line. This is used for \
402 trampolines. Since we don't simulate the cache, this is a no-op \
403 as far as the simulator is concerned. */ \
407 if (bits_written == 8 && addr > 0x5000000) \
408 IOMEM (addr, 1, data); \
409 /* We can't do anything useful with the other stuff, so fail. */ \
415 /* FIXME: sim_resume should be renamed to sim_engine_run. sim_resume
416 being implemented by ../common/sim_resume.c and the below should
417 make a call to sim_engine_halt */
419 #define BUSERROR(addr, mask) ((addr) & (mask))
421 #define WRITE_BUSERROR(addr, mask, data, addr_func) \
426 addr_func (addr, data); \
432 #define READ_BUSERROR(addr, mask, addr_func) \
436 return addr_func (addr); \
440 /* Define this to enable register lifetime checking.
441 The compiler generates "add #0,rn" insns to mark registers as invalid,
442 the simulator uses this info to call fail if it finds a ref to an invalid
443 register before a def
450 #define CREF(x) if (!valid[x]) fail ();
451 #define CDEF(x) valid[x] = 1;
452 #define UNDEF(x) valid[x] = 0;
459 static void parse_and_set_memory_size
PARAMS ((char *str
));
460 static int IOMEM
PARAMS ((int addr
, int write
, int value
));
461 static struct loop_bounds get_loop_bounds
PARAMS ((int, int, unsigned char *,
462 unsigned char *, int, int));
463 static void process_wlat_addr
PARAMS ((int, int));
464 static void process_wwat_addr
PARAMS ((int, int));
465 static void process_wbat_addr
PARAMS ((int, int));
466 static int process_rlat_addr
PARAMS ((int));
467 static int process_rwat_addr
PARAMS ((int));
468 static int process_rbat_addr
PARAMS ((int));
469 static void INLINE wlat_fast
PARAMS ((unsigned char *, int, int, int));
470 static void INLINE wwat_fast
PARAMS ((unsigned char *, int, int, int, int));
471 static void INLINE wbat_fast
PARAMS ((unsigned char *, int, int, int));
472 static int INLINE rlat_fast
PARAMS ((unsigned char *, int, int));
473 static int INLINE rwat_fast
PARAMS ((unsigned char *, int, int, int));
474 static int INLINE rbat_fast
PARAMS ((unsigned char *, int, int));
476 static host_callback
*callback
;
480 /* Floating point registers */
482 #define DR(n) (get_dr (n))
488 if (host_little_endian
)
495 dr
.i
[1] = saved_state
.asregs
.fregs
[0].i
[n
+ 0];
496 dr
.i
[0] = saved_state
.asregs
.fregs
[0].i
[n
+ 1];
500 return (saved_state
.asregs
.fregs
[0].d
[n
>> 1]);
503 #define SET_DR(n, EXP) set_dr ((n), (EXP))
510 if (host_little_endian
)
518 saved_state
.asregs
.fregs
[0].i
[n
+ 0] = dr
.i
[1];
519 saved_state
.asregs
.fregs
[0].i
[n
+ 1] = dr
.i
[0];
522 saved_state
.asregs
.fregs
[0].d
[n
>> 1] = exp
;
525 #define SET_FI(n,EXP) (saved_state.asregs.fregs[0].i[(n)] = (EXP))
526 #define FI(n) (saved_state.asregs.fregs[0].i[(n)])
528 #define FR(n) (saved_state.asregs.fregs[0].f[(n)])
529 #define SET_FR(n,EXP) (saved_state.asregs.fregs[0].f[(n)] = (EXP))
531 #define XD_TO_XF(n) ((((n) & 1) << 5) | ((n) & 0x1e))
532 #define XF(n) (saved_state.asregs.fregs[(n) >> 5].i[(n) & 0x1f])
533 #define SET_XF(n,EXP) (saved_state.asregs.fregs[(n) >> 5].i[(n) & 0x1f] = (EXP))
535 #define RS saved_state.asregs.cregs.named.rs
536 #define RE saved_state.asregs.cregs.named.re
537 #define MOD (saved_state.asregs.cregs.named.mod)
540 MOD_ME = (unsigned) MOD >> 16 | (SR_DMY ? ~0xffff : (SR_DMX ? 0 : 0x10000)), \
541 MOD_DELTA = (MOD & 0xffff) - ((unsigned) MOD >> 16))
543 #define DSP_R(n) saved_state.asregs.sregs.i[(n)]
544 #define DSP_GRD(n) DSP_R ((n) + 8)
545 #define GET_DSP_GRD(n) ((n | 2) == 7 ? SEXT (DSP_GRD (n)) : SIGN32 (DSP_R (n)))
550 #define Y0 DSP_R (10)
551 #define Y1 DSP_R (11)
552 #define M0 DSP_R (12)
553 #define A1G DSP_R (13)
554 #define M1 DSP_R (14)
555 #define A0G DSP_R (15)
556 /* DSP_R (16) / DSP_GRD (16) are used as a fake destination for pcmp. */
557 #define MOD_ME DSP_GRD (17)
558 #define MOD_DELTA DSP_GRD (18)
560 #define FP_OP(n, OP, m) \
564 if (((n) & 1) || ((m) & 1)) \
565 RAISE_EXCEPTION (SIGILL); \
567 SET_DR (n, (DR (n) OP DR (m))); \
570 SET_FR (n, (FR (n) OP FR (m))); \
573 #define FP_UNARY(n, OP) \
578 RAISE_EXCEPTION (SIGILL); \
580 SET_DR (n, (OP (DR (n)))); \
583 SET_FR (n, (OP (FR (n)))); \
586 #define FP_CMP(n, OP, m) \
590 if (((n) & 1) || ((m) & 1)) \
591 RAISE_EXCEPTION (SIGILL); \
593 SET_SR_T (DR (n) OP DR (m)); \
596 SET_SR_T (FR (n) OP FR (m)); \
603 /* do we need to swap banks */
604 int old_gpr
= SR_MD
&& SR_RB
;
605 int new_gpr
= (new_sr
& SR_MASK_MD
) && (new_sr
& SR_MASK_RB
);
606 if (old_gpr
!= new_gpr
)
609 for (i
= 0; i
< 8; i
++)
611 tmp
= saved_state
.asregs
.cregs
.named
.bank
[i
];
612 saved_state
.asregs
.cregs
.named
.bank
[i
] = saved_state
.asregs
.regs
[i
];
613 saved_state
.asregs
.regs
[i
] = tmp
;
616 saved_state
.asregs
.cregs
.named
.sr
= new_sr
;
621 wlat_fast (memory
, x
, value
, maskl
)
622 unsigned char *memory
;
625 unsigned int *p
= (unsigned int *) (memory
+ x
);
626 WRITE_BUSERROR (x
, maskl
, v
, process_wlat_addr
);
631 wwat_fast (memory
, x
, value
, maskw
, endianw
)
632 unsigned char *memory
;
635 unsigned short *p
= (unsigned short *) (memory
+ (x
^ endianw
));
636 WRITE_BUSERROR (x
, maskw
, v
, process_wwat_addr
);
641 wbat_fast (memory
, x
, value
, maskb
)
642 unsigned char *memory
;
644 unsigned char *p
= memory
+ (x
^ endianb
);
645 WRITE_BUSERROR (x
, maskb
, value
, process_wbat_addr
);
653 rlat_fast (memory
, x
, maskl
)
654 unsigned char *memory
;
656 unsigned int *p
= (unsigned int *) (memory
+ x
);
657 READ_BUSERROR (x
, maskl
, process_rlat_addr
);
663 rwat_fast (memory
, x
, maskw
, endianw
)
664 unsigned char *memory
;
665 int x
, maskw
, endianw
;
667 unsigned short *p
= (unsigned short *) (memory
+ (x
^ endianw
));
668 READ_BUSERROR (x
, maskw
, process_rwat_addr
);
674 riat_fast (insn_ptr
, endianw
)
675 unsigned char *insn_ptr
;
677 unsigned short *p
= (unsigned short *) ((size_t) insn_ptr
^ endianw
);
683 rbat_fast (memory
, x
, maskb
)
684 unsigned char *memory
;
686 unsigned char *p
= memory
+ (x
^ endianb
);
687 READ_BUSERROR (x
, maskb
, process_rbat_addr
);
692 #define RWAT(x) (rwat_fast (memory, x, maskw, endianw))
693 #define RLAT(x) (rlat_fast (memory, x, maskl))
694 #define RBAT(x) (rbat_fast (memory, x, maskb))
695 #define RIAT(p) (riat_fast ((p), endianw))
696 #define WWAT(x,v) (wwat_fast (memory, x, v, maskw, endianw))
697 #define WLAT(x,v) (wlat_fast (memory, x, v, maskl))
698 #define WBAT(x,v) (wbat_fast (memory, x, v, maskb))
700 #define RUWAT(x) (RWAT (x) & 0xffff)
701 #define RSWAT(x) ((short) (RWAT (x)))
702 #define RSLAT(x) ((long) (RLAT (x)))
703 #define RSBAT(x) (SEXT (RBAT (x)))
705 #define RDAT(x, n) (do_rdat (memory, (x), (n), (maskl)))
707 do_rdat (memory
, x
, n
, maskl
)
717 f0
= rlat_fast (memory
, x
+ 0, maskl
);
718 f1
= rlat_fast (memory
, x
+ 4, maskl
);
719 saved_state
.asregs
.fregs
[i
].i
[(j
+ 0)] = f0
;
720 saved_state
.asregs
.fregs
[i
].i
[(j
+ 1)] = f1
;
724 #define WDAT(x, n) (do_wdat (memory, (x), (n), (maskl)))
726 do_wdat (memory
, x
, n
, maskl
)
736 f0
= saved_state
.asregs
.fregs
[i
].i
[(j
+ 0)];
737 f1
= saved_state
.asregs
.fregs
[i
].i
[(j
+ 1)];
738 wlat_fast (memory
, (x
+ 0), f0
, maskl
);
739 wlat_fast (memory
, (x
+ 4), f1
, maskl
);
744 process_wlat_addr (addr
, value
)
750 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, 32, 3, value
, );
755 process_wwat_addr (addr
, value
)
761 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, 16, 1, value
, );
766 process_wbat_addr (addr
, value
)
772 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, 8, 0, value
, );
777 process_rlat_addr (addr
)
782 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, -32, 3, -1, 0);
787 process_rwat_addr (addr
)
792 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, -16, 1, -1, 0);
797 process_rbat_addr (addr
)
802 PROCESS_SPECIAL_ADDRESS (addr
, endianb
, ptr
, -8, 0, -1, 0);
806 #define SEXT(x) (((x & 0xff) ^ (~0x7f))+0x80)
807 #define SEXT12(x) (((x & 0xfff) ^ 0x800) - 0x800)
808 #define SEXTW(y) ((int) ((short) y))
810 #define SEXT32(x) ((int) ((x & 0xffffffff) ^ 0x80000000U) - 0x7fffffff - 1)
812 #define SEXT32(x) ((int) (x))
814 #define SIGN32(x) (SEXT32 (x) >> 31)
816 /* convert pointer from target to host value. */
817 #define PT2H(x) ((x) + memory)
818 /* convert pointer from host to target value. */
819 #define PH2T(x) ((x) - memory)
821 #define SKIP_INSN(p) ((p) += ((RIAT (p) & 0xfc00) == 0xf800 ? 4 : 2))
823 #define SET_NIP(x) nip = (x); CHECK_INSN_PTR (nip);
825 static int in_delay_slot
= 0;
826 #define Delay_Slot(TEMPPC) iword = RIAT (TEMPPC); in_delay_slot = 1; goto top;
828 #define CHECK_INSN_PTR(p) \
830 if (saved_state.asregs.exception || PH2T (p) & maskw) \
831 saved_state.asregs.insn_end = 0; \
832 else if (p < loop.end) \
833 saved_state.asregs.insn_end = loop.end; \
835 saved_state.asregs.insn_end = mem_end; \
848 do { memstalls += ((((int) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
850 #define L(x) thislock = x;
851 #define TL(x) if ((x) == prevlock) stalls++;
852 #define TB(x,y) if ((x) == prevlock || (y) == prevlock) stalls++;
856 #if defined(__GO32__)
857 int sim_memory_size
= 19;
859 int sim_memory_size
= 24;
862 static int sim_profile_size
= 17;
868 #define SMR1 (0x05FFFEC8) /* Channel 1 serial mode register */
869 #define BRR1 (0x05FFFEC9) /* Channel 1 bit rate register */
870 #define SCR1 (0x05FFFECA) /* Channel 1 serial control register */
871 #define TDR1 (0x05FFFECB) /* Channel 1 transmit data register */
872 #define SSR1 (0x05FFFECC) /* Channel 1 serial status register */
873 #define RDR1 (0x05FFFECD) /* Channel 1 receive data register */
875 #define SCI_RDRF 0x40 /* Recieve data register full */
876 #define SCI_TDRE 0x80 /* Transmit data register empty */
879 IOMEM (addr
, write
, value
)
911 return time ((long *) 0);
920 static FILE *profile_file
;
922 static unsigned INLINE
927 n
= (n
<< 24 | (n
& 0xff00) << 8
928 | (n
& 0xff0000) >> 8 | (n
& 0xff000000) >> 24);
932 static unsigned short INLINE
937 n
= n
<< 8 | (n
& 0xff00) >> 8;
947 union { char b
[4]; int n
; } u
;
949 fwrite (u
.b
, 4, 1, profile_file
);
957 union { char b
[4]; int n
; } u
;
959 fwrite (u
.b
, 2, 1, profile_file
);
962 /* Turn a pointer in a register into a pointer into real memory. */
968 return (char *) (x
+ saved_state
.asregs
.memory
);
971 /* STR points to a zero-terminated string in target byte order. Return
972 the number of bytes that need to be converted to host byte order in order
973 to use this string as a zero-terminated string on the host.
974 (Not counting the rounding up needed to operate on entire words.) */
979 unsigned char *memory
= saved_state
.asregs
.memory
;
981 int endian
= endianb
;
986 for (end
= str
; memory
[end
^ endian
]; end
++) ;
987 return end
- str
+ 1;
997 if (! endianb
|| ! len
)
999 start
= (int *) ptr (str
& ~3);
1000 end
= (int *) ptr (str
+ len
);
1004 *start
= (old
<< 24 | (old
& 0xff00) << 8
1005 | (old
& 0xff0000) >> 8 | (old
& 0xff000000) >> 24);
1008 while (start
< end
);
1011 /* Simulate a monitor trap, put the result into r0 and errno into r1
1012 return offset by which to adjust pc. */
1015 trap (i
, regs
, insn_ptr
, memory
, maskl
, maskw
, endianw
)
1018 unsigned char *insn_ptr
;
1019 unsigned char *memory
;
1024 printf ("%c", regs
[0]);
1027 raise_exception (SIGQUIT
);
1029 case 3: /* FIXME: for backwards compat, should be removed */
1032 unsigned int countp
= * (unsigned int *) (insn_ptr
+ 4);
1034 WLAT (countp
, RLAT (countp
) + 1);
1046 #if !defined(__GO32__) && !defined(_WIN32)
1050 /* This would work only if endianness matched between host and target.
1051 Besides, it's quite dangerous. */
1054 regs
[0] = execve (ptr (regs
[5]), (char **) ptr (regs
[6]),
1055 (char **) ptr (regs
[7]));
1058 regs
[0] = execve (ptr (regs
[5]), (char **) ptr (regs
[6]), 0);
1063 regs
[0] = (BUSERROR (regs
[5], maskl
)
1065 : pipe ((int *) ptr (regs
[5])));
1070 regs
[0] = wait (ptr (regs
[5]));
1072 #endif /* !defined(__GO32__) && !defined(_WIN32) */
1075 strnswap (regs
[6], regs
[7]);
1077 = callback
->read (callback
, regs
[5], ptr (regs
[6]), regs
[7]);
1078 strnswap (regs
[6], regs
[7]);
1081 strnswap (regs
[6], regs
[7]);
1083 regs
[0] = (int) callback
->write_stdout (callback
,
1084 ptr (regs
[6]), regs
[7]);
1086 regs
[0] = (int) callback
->write (callback
, regs
[5],
1087 ptr (regs
[6]), regs
[7]);
1088 strnswap (regs
[6], regs
[7]);
1091 regs
[0] = callback
->lseek (callback
,regs
[5], regs
[6], regs
[7]);
1094 regs
[0] = callback
->close (callback
,regs
[5]);
1098 int len
= strswaplen (regs
[5]);
1099 strnswap (regs
[5], len
);
1100 regs
[0] = callback
->open (callback
, ptr (regs
[5]), regs
[6]);
1101 strnswap (regs
[5], len
);
1105 /* EXIT - caller can look in r5 to work out the reason */
1106 raise_exception (SIGQUIT
);
1110 case SYS_stat
: /* added at hmsi */
1111 /* stat system call */
1113 struct stat host_stat
;
1115 int len
= strswaplen (regs
[5]);
1117 strnswap (regs
[5], len
);
1118 regs
[0] = stat (ptr (regs
[5]), &host_stat
);
1119 strnswap (regs
[5], len
);
1123 WWAT (buf
, host_stat
.st_dev
);
1125 WWAT (buf
, host_stat
.st_ino
);
1127 WLAT (buf
, host_stat
.st_mode
);
1129 WWAT (buf
, host_stat
.st_nlink
);
1131 WWAT (buf
, host_stat
.st_uid
);
1133 WWAT (buf
, host_stat
.st_gid
);
1135 WWAT (buf
, host_stat
.st_rdev
);
1137 WLAT (buf
, host_stat
.st_size
);
1139 WLAT (buf
, host_stat
.st_atime
);
1143 WLAT (buf
, host_stat
.st_mtime
);
1147 WLAT (buf
, host_stat
.st_ctime
);
1161 int len
= strswaplen (regs
[5]);
1163 strnswap (regs
[5], len
);
1164 regs
[0] = chown (ptr (regs
[5]), regs
[6], regs
[7]);
1165 strnswap (regs
[5], len
);
1171 int len
= strswaplen (regs
[5]);
1173 strnswap (regs
[5], len
);
1174 regs
[0] = chmod (ptr (regs
[5]), regs
[6]);
1175 strnswap (regs
[5], len
);
1180 /* Cast the second argument to void *, to avoid type mismatch
1181 if a prototype is present. */
1182 int len
= strswaplen (regs
[5]);
1184 strnswap (regs
[5], len
);
1185 regs
[0] = utime (ptr (regs
[5]), (void *) ptr (regs
[6]));
1186 strnswap (regs
[5], len
);
1190 regs
[0] = count_argc (prog_argv
);
1193 if (regs
[5] < count_argc (prog_argv
))
1194 regs
[0] = strlen (prog_argv
[regs
[5]]);
1199 if (regs
[5] < count_argc (prog_argv
))
1201 /* Include the termination byte. */
1202 int i
= strlen (prog_argv
[regs
[5]]) + 1;
1203 regs
[0] = sim_write (0, regs
[6], prog_argv
[regs
[5]], i
);
1209 regs
[0] = get_now ();
1212 regs
[0] = callback
->ftruncate (callback
, regs
[5], regs
[6]);
1216 int len
= strswaplen (regs
[5]);
1217 strnswap (regs
[5], len
);
1218 regs
[0] = callback
->truncate (callback
, ptr (regs
[5]), regs
[6]);
1219 strnswap (regs
[5], len
);
1226 regs
[1] = callback
->get_errno (callback
);
1231 case 13: /* Set IBNR */
1232 IBNR
= regs
[0] & 0xffff;
1234 case 14: /* Set IBCR */
1235 IBCR
= regs
[0] & 0xffff;
1239 raise_exception (SIGTRAP
);
1248 control_c (sig
, code
, scp
, addr
)
1254 raise_exception (SIGINT
);
1258 div1 (R
, iRn2
, iRn1
/*, T*/)
1265 unsigned char old_q
, tmp1
;
1268 SET_SR_Q ((unsigned char) ((0x80000000 & R
[iRn1
]) != 0));
1270 R
[iRn1
] |= (unsigned long) T
;
1280 tmp1
= (R
[iRn1
] > tmp0
);
1287 SET_SR_Q ((unsigned char) (tmp1
== 0));
1294 tmp1
= (R
[iRn1
] < tmp0
);
1298 SET_SR_Q ((unsigned char) (tmp1
== 0));
1313 tmp1
= (R
[iRn1
] < tmp0
);
1320 SET_SR_Q ((unsigned char) (tmp1
== 0));
1327 tmp1
= (R
[iRn1
] > tmp0
);
1331 SET_SR_Q ((unsigned char) (tmp1
== 0));
1352 unsigned long RnL
, RnH
;
1353 unsigned long RmL
, RmH
;
1354 unsigned long temp0
, temp1
, temp2
, temp3
;
1355 unsigned long Res2
, Res1
, Res0
;
1358 RnH
= (rn
>> 16) & 0xffff;
1360 RmH
= (rm
>> 16) & 0xffff;
1366 Res1
= temp1
+ temp2
;
1369 temp1
= (Res1
<< 16) & 0xffff0000;
1370 Res0
= temp0
+ temp1
;
1373 Res2
+= ((Res1
>> 16) & 0xffff) + temp3
;
1377 if (rn
& 0x80000000)
1379 if (rm
& 0x80000000)
1388 macw (regs
, memory
, n
, m
, endianw
)
1390 unsigned char *memory
;
1395 long prod
, macl
, sum
;
1397 tempm
=RSWAT (regs
[m
]); regs
[m
]+=2;
1398 tempn
=RSWAT (regs
[n
]); regs
[n
]+=2;
1401 prod
= (long) (short) tempm
* (long) (short) tempn
;
1405 if ((~(prod
^ macl
) & (sum
^ prod
)) < 0)
1407 /* MACH's lsb is a sticky overflow bit. */
1409 /* Store the smallest negative number in MACL if prod is
1410 negative, and the largest positive number otherwise. */
1411 sum
= 0x7fffffff + (prod
< 0);
1417 /* Add to MACH the sign extended product, and carry from low sum. */
1418 mach
= MACH
+ (-(prod
< 0)) + ((unsigned long) sum
< prod
);
1419 /* Sign extend at 10:th bit in MACH. */
1420 MACH
= (mach
& 0x1ff) | -(mach
& 0x200);
1426 macl (regs
, memory
, n
, m
)
1428 unsigned char *memory
;
1432 long prod
, macl
, mach
, sum
;
1433 long long ans
,ansl
,ansh
,t
;
1434 unsigned long long high
,low
,combine
;
1437 long m
[2]; /* mach and macl*/
1438 long long m64
; /* 64 bit MAC */
1441 tempm
= RSLAT (regs
[m
]);
1444 tempn
= RSLAT (regs
[n
]);
1453 ans
= (long long) tempm
* (long long) tempn
; /* Multiply 32bit * 32bit */
1455 mac64
.m64
+= ans
; /* Accumulate 64bit + 64 bit */
1460 if (S
) /* Store only 48 bits of the result */
1462 if (mach
< 0) /* Result is negative */
1464 mach
= mach
& 0x0000ffff; /* Mask higher 16 bits */
1465 mach
|= 0xffff8000; /* Sign extend higher 16 bits */
1468 mach
= mach
& 0x00007fff; /* Postive Result */
1499 /* Do extended displacement move instructions. */
1501 do_long_move_insn (int op
, int disp12
, int m
, int n
, int *thatlock
)
1504 int thislock
= *thatlock
;
1505 int endianw
= global_endianw
;
1506 int *R
= &(saved_state
.asregs
.regs
[0]);
1507 unsigned char *memory
= saved_state
.asregs
.memory
;
1508 int maskb
= ~((saved_state
.asregs
.msize
- 1) & ~0);
1509 unsigned char *insn_ptr
= PT2H (saved_state
.asregs
.pc
);
1512 case MOVB_RM
: /* signed */
1513 WBAT (disp12
* 1 + R
[n
], R
[m
]);
1516 WWAT (disp12
* 2 + R
[n
], R
[m
]);
1519 WLAT (disp12
* 4 + R
[n
], R
[m
]);
1521 case FMOV_RM
: /* floating point */
1525 WDAT (R
[n
] + 8 * disp12
, m
);
1528 WLAT (R
[n
] + 4 * disp12
, FI (m
));
1531 R
[n
] = RSBAT (disp12
* 1 + R
[m
]);
1535 R
[n
] = RSWAT (disp12
* 2 + R
[m
]);
1539 R
[n
] = RLAT (disp12
* 4 + R
[m
]);
1545 RDAT (R
[m
] + 8 * disp12
, n
);
1548 SET_FI (n
, RLAT (R
[m
] + 4 * disp12
));
1550 case MOVU_BMR
: /* unsigned */
1551 R
[n
] = RBAT (disp12
* 1 + R
[m
]);
1555 R
[n
] = RWAT (disp12
* 2 + R
[m
]);
1559 RAISE_EXCEPTION (SIGINT
);
1562 saved_state
.asregs
.memstalls
+= memstalls
;
1563 *thatlock
= thislock
;
1566 /* Do binary logical bit-manipulation insns. */
1568 do_blog_insn (int imm
, int addr
, int binop
,
1569 unsigned char *memory
, int maskb
)
1571 int oldval
= RBAT (addr
);
1574 case B_BCLR
: /* bclr.b */
1575 WBAT (addr
, oldval
& ~imm
);
1577 case B_BSET
: /* bset.b */
1578 WBAT (addr
, oldval
| imm
);
1580 case B_BST
: /* bst.b */
1582 WBAT (addr
, oldval
| imm
);
1584 WBAT (addr
, oldval
& ~imm
);
1586 case B_BLD
: /* bld.b */
1587 SET_SR_T ((oldval
& imm
) != 0);
1589 case B_BAND
: /* band.b */
1590 SET_SR_T (T
&& ((oldval
& imm
) != 0));
1592 case B_BOR
: /* bor.b */
1593 SET_SR_T (T
|| ((oldval
& imm
) != 0));
1595 case B_BXOR
: /* bxor.b */
1596 SET_SR_T (T
^ ((oldval
& imm
) != 0));
1598 case B_BLDNOT
: /* bldnot.b */
1599 SET_SR_T ((oldval
& imm
) == 0);
1601 case B_BANDNOT
: /* bandnot.b */
1602 SET_SR_T (T
&& ((oldval
& imm
) == 0));
1604 case B_BORNOT
: /* bornot.b */
1605 SET_SR_T (T
|| ((oldval
& imm
) == 0));
1610 fsca_s (int in
, double (*f
) (double))
1612 double rad
= ldexp ((in
& 0xffff), -15) * 3.141592653589793238462643383;
1613 double result
= (*f
) (rad
);
1614 double error
, upper
, lower
, frac
;
1617 /* Search the value with the maximum error that is still within the
1618 architectural spec. */
1619 error
= ldexp (1., -21);
1620 /* compensate for calculation inaccuracy by reducing error. */
1621 error
= error
- ldexp (1., -50);
1622 upper
= result
+ error
;
1623 frac
= frexp (upper
, &exp
);
1624 upper
= ldexp (floor (ldexp (frac
, 24)), exp
- 24);
1625 lower
= result
- error
;
1626 frac
= frexp (lower
, &exp
);
1627 lower
= ldexp (ceil (ldexp (frac
, 24)), exp
- 24);
1628 return abs (upper
- result
) >= abs (lower
- result
) ? upper
: lower
;
1634 double result
= 1. / sqrt (in
);
1636 double frac
, upper
, lower
, error
, eps
;
1639 result
= result
- (result
* result
* in
- 1) * 0.5 * result
;
1640 /* Search the value with the maximum error that is still within the
1641 architectural spec. */
1642 frac
= frexp (result
, &exp
);
1643 frac
= ldexp (frac
, 24);
1644 error
= 4.0; /* 1 << 24-1-21 */
1645 /* use eps to compensate for possible 1 ulp error in our 'exact' result. */
1646 eps
= ldexp (1., -29);
1647 upper
= floor (frac
+ error
- eps
);
1648 if (upper
> 16777216.)
1649 upper
= floor ((frac
+ error
- eps
) * 0.5) * 2.;
1650 lower
= ceil ((frac
- error
+ eps
) * 2) * .5;
1651 if (lower
> 8388608.)
1652 lower
= ceil (frac
- error
+ eps
);
1653 upper
= ldexp (upper
, exp
- 24);
1654 lower
= ldexp (lower
, exp
- 24);
1655 return upper
- result
>= result
- lower
? upper
: lower
;
1659 /* GET_LOOP_BOUNDS {EXTENDED}
1660 These two functions compute the actual starting and ending point
1661 of the repeat loop, based on the RS and RE registers (repeat start,
1662 repeat stop). The extended version is called for LDRC, and the
1663 regular version is called for SETRC. The difference is that for
1664 LDRC, the loop start and end instructions are literally the ones
1665 pointed to by RS and RE -- for SETRC, they're not (see docs). */
1667 static struct loop_bounds
1668 get_loop_bounds_ext (rs
, re
, memory
, mem_end
, maskw
, endianw
)
1670 unsigned char *memory
, *mem_end
;
1673 struct loop_bounds loop
;
1675 /* FIXME: should I verify RS < RE? */
1676 loop
.start
= PT2H (RS
); /* FIXME not using the params? */
1677 loop
.end
= PT2H (RE
& ~1); /* Ignore bit 0 of RE. */
1678 SKIP_INSN (loop
.end
);
1679 if (loop
.end
>= mem_end
)
1680 loop
.end
= PT2H (0);
1684 static struct loop_bounds
1685 get_loop_bounds (rs
, re
, memory
, mem_end
, maskw
, endianw
)
1687 unsigned char *memory
, *mem_end
;
1690 struct loop_bounds loop
;
1696 loop
.start
= PT2H (RE
- 4);
1697 SKIP_INSN (loop
.start
);
1698 loop
.end
= loop
.start
;
1700 SKIP_INSN (loop
.end
);
1702 SKIP_INSN (loop
.end
);
1703 SKIP_INSN (loop
.end
);
1707 loop
.start
= PT2H (RS
);
1708 loop
.end
= PT2H (RE
- 4);
1709 SKIP_INSN (loop
.end
);
1710 SKIP_INSN (loop
.end
);
1711 SKIP_INSN (loop
.end
);
1712 SKIP_INSN (loop
.end
);
1714 if (loop
.end
>= mem_end
)
1715 loop
.end
= PT2H (0);
1718 loop
.end
= PT2H (0);
1723 static void ppi_insn ();
1727 /* Provide calloc / free versions that use an anonymous mmap. This can
1728 significantly cut the start-up time when a large simulator memory is
1729 required, because pages are only zeroed on demand. */
1730 #ifdef MAP_ANONYMOUS
1732 mcalloc (size_t nmemb
, size_t size
)
1738 return mmap (0, size
, PROT_READ
| PROT_WRITE
, MAP_PRIVATE
| MAP_ANONYMOUS
,
1742 #define mfree(start,length) munmap ((start), (length))
1744 #define mcalloc calloc
1745 #define mfree(start,length) free(start)
1748 /* Set the memory size to the power of two provided. */
1755 sim_memory_size
= power
;
1757 if (saved_state
.asregs
.memory
)
1759 mfree (saved_state
.asregs
.memory
, saved_state
.asregs
.msize
);
1762 saved_state
.asregs
.msize
= 1 << power
;
1764 saved_state
.asregs
.memory
=
1765 (unsigned char *) mcalloc (1, saved_state
.asregs
.msize
);
1767 if (!saved_state
.asregs
.memory
)
1770 "Not enough VM for simulation of %d bytes of RAM\n",
1771 saved_state
.asregs
.msize
);
1773 saved_state
.asregs
.msize
= 1;
1774 saved_state
.asregs
.memory
= (unsigned char *) mcalloc (1, 1);
1782 int was_dsp
= target_dsp
;
1783 unsigned long mach
= bfd_get_mach (abfd
);
1785 if (mach
== bfd_mach_sh_dsp
||
1786 mach
== bfd_mach_sh4al_dsp
||
1787 mach
== bfd_mach_sh3_dsp
)
1789 int ram_area_size
, xram_start
, yram_start
;
1793 if (mach
== bfd_mach_sh_dsp
)
1795 /* SH7410 (orig. sh-sdp):
1796 4KB each for X & Y memory;
1797 On-chip X RAM 0x0800f000-0x0800ffff
1798 On-chip Y RAM 0x0801f000-0x0801ffff */
1799 xram_start
= 0x0800f000;
1800 ram_area_size
= 0x1000;
1802 if (mach
== bfd_mach_sh3_dsp
|| mach
== bfd_mach_sh4al_dsp
)
1805 8KB each for X & Y memory;
1806 On-chip X RAM 0x1000e000-0x1000ffff
1807 On-chip Y RAM 0x1001e000-0x1001ffff */
1808 xram_start
= 0x1000e000;
1809 ram_area_size
= 0x2000;
1811 yram_start
= xram_start
+ 0x10000;
1812 new_select
= ~(ram_area_size
- 1);
1813 if (saved_state
.asregs
.xyram_select
!= new_select
)
1815 saved_state
.asregs
.xyram_select
= new_select
;
1816 free (saved_state
.asregs
.xmem
);
1817 free (saved_state
.asregs
.ymem
);
1818 saved_state
.asregs
.xmem
=
1819 (unsigned char *) calloc (1, ram_area_size
);
1820 saved_state
.asregs
.ymem
=
1821 (unsigned char *) calloc (1, ram_area_size
);
1823 /* Disable use of X / Y mmeory if not allocated. */
1824 if (! saved_state
.asregs
.xmem
|| ! saved_state
.asregs
.ymem
)
1826 saved_state
.asregs
.xyram_select
= 0;
1827 if (saved_state
.asregs
.xmem
)
1828 free (saved_state
.asregs
.xmem
);
1829 if (saved_state
.asregs
.ymem
)
1830 free (saved_state
.asregs
.ymem
);
1833 saved_state
.asregs
.xram_start
= xram_start
;
1834 saved_state
.asregs
.yram_start
= yram_start
;
1835 saved_state
.asregs
.xmem_offset
= saved_state
.asregs
.xmem
- xram_start
;
1836 saved_state
.asregs
.ymem_offset
= saved_state
.asregs
.ymem
- yram_start
;
1841 if (saved_state
.asregs
.xyram_select
)
1843 saved_state
.asregs
.xyram_select
= 0;
1844 free (saved_state
.asregs
.xmem
);
1845 free (saved_state
.asregs
.ymem
);
1849 if (! saved_state
.asregs
.xyram_select
)
1851 saved_state
.asregs
.xram_start
= 1;
1852 saved_state
.asregs
.yram_start
= 1;
1855 if (saved_state
.asregs
.regstack
== NULL
)
1856 saved_state
.asregs
.regstack
=
1857 calloc (512, sizeof *saved_state
.asregs
.regstack
);
1859 if (target_dsp
!= was_dsp
)
1863 for (i
= (sizeof sh_dsp_table
/ sizeof sh_dsp_table
[0]) - 1; i
>= 0; i
--)
1865 tmp
= sh_jump_table
[0xf000 + i
];
1866 sh_jump_table
[0xf000 + i
] = sh_dsp_table
[i
];
1867 sh_dsp_table
[i
] = tmp
;
1875 host_little_endian
= 0;
1876 * (char*) &host_little_endian
= 1;
1877 host_little_endian
&= 1;
1879 if (saved_state
.asregs
.msize
!= 1 << sim_memory_size
)
1881 sim_size (sim_memory_size
);
1884 if (saved_state
.asregs
.profile
&& !profile_file
)
1886 profile_file
= fopen ("gmon.out", "wb");
1887 /* Seek to where to put the call arc data */
1888 nsamples
= (1 << sim_profile_size
);
1890 fseek (profile_file
, nsamples
* 2 + 12, 0);
1894 fprintf (stderr
, "Can't open gmon.out\n");
1898 saved_state
.asregs
.profile_hist
=
1899 (unsigned short *) calloc (64, (nsamples
* sizeof (short) / 64));
1912 p
= saved_state
.asregs
.profile_hist
;
1914 maxpc
= (1 << sim_profile_size
);
1916 fseek (profile_file
, 0L, 0);
1917 swapout (minpc
<< PROFILE_SHIFT
);
1918 swapout (maxpc
<< PROFILE_SHIFT
);
1919 swapout (nsamples
* 2 + 12);
1920 for (i
= 0; i
< nsamples
; i
++)
1921 swapout16 (saved_state
.asregs
.profile_hist
[i
]);
1935 #define MMASKB ((saved_state.asregs.msize -1) & ~0)
1941 raise_exception (SIGINT
);
1946 sim_resume (sd
, step
, siggnal
)
1950 register unsigned char *insn_ptr
;
1951 unsigned char *mem_end
;
1952 struct loop_bounds loop
;
1953 register int cycles
= 0;
1954 register int stalls
= 0;
1955 register int memstalls
= 0;
1956 register int insts
= 0;
1957 register int prevlock
;
1961 register int thislock
;
1963 register unsigned int doprofile
;
1964 register int pollcount
= 0;
1965 /* endianw is used for every insn fetch, hence it makes sense to cache it.
1966 endianb is used less often. */
1967 register int endianw
= global_endianw
;
1969 int tick_start
= get_now ();
1971 void (*prev_fpe
) ();
1973 register unsigned short *jump_table
= sh_jump_table
;
1975 register int *R
= &(saved_state
.asregs
.regs
[0]);
1981 register int maskb
= ~((saved_state
.asregs
.msize
- 1) & ~0);
1982 register int maskw
= ~((saved_state
.asregs
.msize
- 1) & ~1);
1983 register int maskl
= ~((saved_state
.asregs
.msize
- 1) & ~3);
1984 register unsigned char *memory
;
1985 register unsigned int sbit
= ((unsigned int) 1 << 31);
1987 prev
= signal (SIGINT
, control_c
);
1988 prev_fpe
= signal (SIGFPE
, SIG_IGN
);
1991 saved_state
.asregs
.exception
= 0;
1993 memory
= saved_state
.asregs
.memory
;
1994 mem_end
= memory
+ saved_state
.asregs
.msize
;
1997 loop
= get_loop_bounds_ext (RS
, RE
, memory
, mem_end
, maskw
, endianw
);
1999 loop
= get_loop_bounds (RS
, RE
, memory
, mem_end
, maskw
, endianw
);
2001 insn_ptr
= PT2H (saved_state
.asregs
.pc
);
2002 CHECK_INSN_PTR (insn_ptr
);
2005 PR
= saved_state
.asregs
.sregs
.named
.pr
;
2007 /*T = GET_SR () & SR_MASK_T;*/
2008 prevlock
= saved_state
.asregs
.prevlock
;
2009 thislock
= saved_state
.asregs
.thislock
;
2010 doprofile
= saved_state
.asregs
.profile
;
2012 /* If profiling not enabled, disable it by asking for
2013 profiles infrequently. */
2018 if (step
&& insn_ptr
< saved_state
.asregs
.insn_end
)
2020 if (saved_state
.asregs
.exception
)
2021 /* This can happen if we've already been single-stepping and
2022 encountered a loop end. */
2023 saved_state
.asregs
.insn_end
= insn_ptr
;
2026 saved_state
.asregs
.exception
= SIGTRAP
;
2027 saved_state
.asregs
.insn_end
= insn_ptr
+ 2;
2031 while (insn_ptr
< saved_state
.asregs
.insn_end
)
2033 register unsigned int iword
= RIAT (insn_ptr
);
2034 register unsigned int ult
;
2035 register unsigned char *nip
= insn_ptr
+ 2;
2042 fprintf (stderr
, "PC: %08x, insn: %04x\n", PH2T (insn_ptr
), iword
);
2050 if (--pollcount
< 0)
2052 pollcount
= POLL_QUIT_INTERVAL
;
2053 if ((*callback
->poll_quit
) != NULL
2054 && (*callback
->poll_quit
) (callback
))
2061 prevlock
= thislock
;
2065 if (cycles
>= doprofile
)
2068 saved_state
.asregs
.cycles
+= doprofile
;
2069 cycles
-= doprofile
;
2070 if (saved_state
.asregs
.profile_hist
)
2072 int n
= PH2T (insn_ptr
) >> PROFILE_SHIFT
;
2075 int i
= saved_state
.asregs
.profile_hist
[n
];
2077 saved_state
.asregs
.profile_hist
[n
] = i
+ 1;
2084 if (saved_state
.asregs
.insn_end
== loop
.end
)
2086 saved_state
.asregs
.cregs
.named
.sr
+= SR_RC_INCREMENT
;
2088 insn_ptr
= loop
.start
;
2091 saved_state
.asregs
.insn_end
= mem_end
;
2092 loop
.end
= PT2H (0);
2097 if (saved_state
.asregs
.exception
== SIGILL
2098 || saved_state
.asregs
.exception
== SIGBUS
)
2102 /* Check for SIGBUS due to insn fetch. */
2103 else if (! saved_state
.asregs
.exception
)
2104 saved_state
.asregs
.exception
= SIGBUS
;
2106 saved_state
.asregs
.ticks
+= get_now () - tick_start
;
2107 saved_state
.asregs
.cycles
+= cycles
;
2108 saved_state
.asregs
.stalls
+= stalls
;
2109 saved_state
.asregs
.memstalls
+= memstalls
;
2110 saved_state
.asregs
.insts
+= insts
;
2111 saved_state
.asregs
.pc
= PH2T (insn_ptr
);
2113 saved_state
.asregs
.sregs
.named
.pr
= PR
;
2116 saved_state
.asregs
.prevlock
= prevlock
;
2117 saved_state
.asregs
.thislock
= thislock
;
2124 signal (SIGFPE
, prev_fpe
);
2125 signal (SIGINT
, prev
);
2129 sim_write (sd
, addr
, buffer
, size
)
2132 unsigned char *buffer
;
2139 for (i
= 0; i
< size
; i
++)
2141 saved_state
.asregs
.memory
[(MMASKB
& (addr
+ i
)) ^ endianb
] = buffer
[i
];
2147 sim_read (sd
, addr
, buffer
, size
)
2150 unsigned char *buffer
;
2157 for (i
= 0; i
< size
; i
++)
2159 buffer
[i
] = saved_state
.asregs
.memory
[(MMASKB
& (addr
+ i
)) ^ endianb
];
2164 static int gdb_bank_number
;
2174 sim_store_register (sd
, rn
, memory
, length
)
2177 unsigned char *memory
;
2183 val
= swap (* (int *) memory
);
2186 case SIM_SH_R0_REGNUM
: case SIM_SH_R1_REGNUM
: case SIM_SH_R2_REGNUM
:
2187 case SIM_SH_R3_REGNUM
: case SIM_SH_R4_REGNUM
: case SIM_SH_R5_REGNUM
:
2188 case SIM_SH_R6_REGNUM
: case SIM_SH_R7_REGNUM
: case SIM_SH_R8_REGNUM
:
2189 case SIM_SH_R9_REGNUM
: case SIM_SH_R10_REGNUM
: case SIM_SH_R11_REGNUM
:
2190 case SIM_SH_R12_REGNUM
: case SIM_SH_R13_REGNUM
: case SIM_SH_R14_REGNUM
:
2191 case SIM_SH_R15_REGNUM
:
2192 saved_state
.asregs
.regs
[rn
] = val
;
2194 case SIM_SH_PC_REGNUM
:
2195 saved_state
.asregs
.pc
= val
;
2197 case SIM_SH_PR_REGNUM
:
2200 case SIM_SH_GBR_REGNUM
:
2203 case SIM_SH_VBR_REGNUM
:
2206 case SIM_SH_MACH_REGNUM
:
2209 case SIM_SH_MACL_REGNUM
:
2212 case SIM_SH_SR_REGNUM
:
2215 case SIM_SH_FPUL_REGNUM
:
2218 case SIM_SH_FPSCR_REGNUM
:
2221 case SIM_SH_FR0_REGNUM
: case SIM_SH_FR1_REGNUM
: case SIM_SH_FR2_REGNUM
:
2222 case SIM_SH_FR3_REGNUM
: case SIM_SH_FR4_REGNUM
: case SIM_SH_FR5_REGNUM
:
2223 case SIM_SH_FR6_REGNUM
: case SIM_SH_FR7_REGNUM
: case SIM_SH_FR8_REGNUM
:
2224 case SIM_SH_FR9_REGNUM
: case SIM_SH_FR10_REGNUM
: case SIM_SH_FR11_REGNUM
:
2225 case SIM_SH_FR12_REGNUM
: case SIM_SH_FR13_REGNUM
: case SIM_SH_FR14_REGNUM
:
2226 case SIM_SH_FR15_REGNUM
:
2227 SET_FI (rn
- SIM_SH_FR0_REGNUM
, val
);
2229 case SIM_SH_DSR_REGNUM
:
2232 case SIM_SH_A0G_REGNUM
:
2235 case SIM_SH_A0_REGNUM
:
2238 case SIM_SH_A1G_REGNUM
:
2241 case SIM_SH_A1_REGNUM
:
2244 case SIM_SH_M0_REGNUM
:
2247 case SIM_SH_M1_REGNUM
:
2250 case SIM_SH_X0_REGNUM
:
2253 case SIM_SH_X1_REGNUM
:
2256 case SIM_SH_Y0_REGNUM
:
2259 case SIM_SH_Y1_REGNUM
:
2262 case SIM_SH_MOD_REGNUM
:
2265 case SIM_SH_RS_REGNUM
:
2268 case SIM_SH_RE_REGNUM
:
2271 case SIM_SH_SSR_REGNUM
:
2274 case SIM_SH_SPC_REGNUM
:
2277 /* The rn_bank idiosyncracies are not due to hardware differences, but to
2278 a weird aliasing naming scheme for sh3 / sh3e / sh4. */
2279 case SIM_SH_R0_BANK0_REGNUM
: case SIM_SH_R1_BANK0_REGNUM
:
2280 case SIM_SH_R2_BANK0_REGNUM
: case SIM_SH_R3_BANK0_REGNUM
:
2281 case SIM_SH_R4_BANK0_REGNUM
: case SIM_SH_R5_BANK0_REGNUM
:
2282 case SIM_SH_R6_BANK0_REGNUM
: case SIM_SH_R7_BANK0_REGNUM
:
2283 if (saved_state
.asregs
.bfd_mach
== bfd_mach_sh2a
)
2285 rn
-= SIM_SH_R0_BANK0_REGNUM
;
2286 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[rn
] = val
;
2290 Rn_BANK (rn
- SIM_SH_R0_BANK0_REGNUM
) = val
;
2292 saved_state
.asregs
.regs
[rn
- SIM_SH_R0_BANK0_REGNUM
] = val
;
2294 case SIM_SH_R0_BANK1_REGNUM
: case SIM_SH_R1_BANK1_REGNUM
:
2295 case SIM_SH_R2_BANK1_REGNUM
: case SIM_SH_R3_BANK1_REGNUM
:
2296 case SIM_SH_R4_BANK1_REGNUM
: case SIM_SH_R5_BANK1_REGNUM
:
2297 case SIM_SH_R6_BANK1_REGNUM
: case SIM_SH_R7_BANK1_REGNUM
:
2298 if (saved_state
.asregs
.bfd_mach
== bfd_mach_sh2a
)
2300 rn
-= SIM_SH_R0_BANK1_REGNUM
;
2301 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[rn
+ 8] = val
;
2305 saved_state
.asregs
.regs
[rn
- SIM_SH_R0_BANK1_REGNUM
] = val
;
2307 Rn_BANK (rn
- SIM_SH_R0_BANK1_REGNUM
) = val
;
2309 case SIM_SH_R0_BANK_REGNUM
: case SIM_SH_R1_BANK_REGNUM
:
2310 case SIM_SH_R2_BANK_REGNUM
: case SIM_SH_R3_BANK_REGNUM
:
2311 case SIM_SH_R4_BANK_REGNUM
: case SIM_SH_R5_BANK_REGNUM
:
2312 case SIM_SH_R6_BANK_REGNUM
: case SIM_SH_R7_BANK_REGNUM
:
2313 SET_Rn_BANK (rn
- SIM_SH_R0_BANK_REGNUM
, val
);
2315 case SIM_SH_TBR_REGNUM
:
2318 case SIM_SH_IBNR_REGNUM
:
2321 case SIM_SH_IBCR_REGNUM
:
2324 case SIM_SH_BANK_REGNUM
:
2325 /* This is a pseudo-register maintained just for gdb.
2326 It tells us what register bank gdb would like to read/write. */
2327 gdb_bank_number
= val
;
2329 case SIM_SH_BANK_MACL_REGNUM
:
2330 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_MACL
] = val
;
2332 case SIM_SH_BANK_GBR_REGNUM
:
2333 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_GBR
] = val
;
2335 case SIM_SH_BANK_PR_REGNUM
:
2336 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_PR
] = val
;
2338 case SIM_SH_BANK_IVN_REGNUM
:
2339 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_IVN
] = val
;
2341 case SIM_SH_BANK_MACH_REGNUM
:
2342 saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_MACH
] = val
;
2351 sim_fetch_register (sd
, rn
, memory
, length
)
2354 unsigned char *memory
;
2362 case SIM_SH_R0_REGNUM
: case SIM_SH_R1_REGNUM
: case SIM_SH_R2_REGNUM
:
2363 case SIM_SH_R3_REGNUM
: case SIM_SH_R4_REGNUM
: case SIM_SH_R5_REGNUM
:
2364 case SIM_SH_R6_REGNUM
: case SIM_SH_R7_REGNUM
: case SIM_SH_R8_REGNUM
:
2365 case SIM_SH_R9_REGNUM
: case SIM_SH_R10_REGNUM
: case SIM_SH_R11_REGNUM
:
2366 case SIM_SH_R12_REGNUM
: case SIM_SH_R13_REGNUM
: case SIM_SH_R14_REGNUM
:
2367 case SIM_SH_R15_REGNUM
:
2368 val
= saved_state
.asregs
.regs
[rn
];
2370 case SIM_SH_PC_REGNUM
:
2371 val
= saved_state
.asregs
.pc
;
2373 case SIM_SH_PR_REGNUM
:
2376 case SIM_SH_GBR_REGNUM
:
2379 case SIM_SH_VBR_REGNUM
:
2382 case SIM_SH_MACH_REGNUM
:
2385 case SIM_SH_MACL_REGNUM
:
2388 case SIM_SH_SR_REGNUM
:
2391 case SIM_SH_FPUL_REGNUM
:
2394 case SIM_SH_FPSCR_REGNUM
:
2397 case SIM_SH_FR0_REGNUM
: case SIM_SH_FR1_REGNUM
: case SIM_SH_FR2_REGNUM
:
2398 case SIM_SH_FR3_REGNUM
: case SIM_SH_FR4_REGNUM
: case SIM_SH_FR5_REGNUM
:
2399 case SIM_SH_FR6_REGNUM
: case SIM_SH_FR7_REGNUM
: case SIM_SH_FR8_REGNUM
:
2400 case SIM_SH_FR9_REGNUM
: case SIM_SH_FR10_REGNUM
: case SIM_SH_FR11_REGNUM
:
2401 case SIM_SH_FR12_REGNUM
: case SIM_SH_FR13_REGNUM
: case SIM_SH_FR14_REGNUM
:
2402 case SIM_SH_FR15_REGNUM
:
2403 val
= FI (rn
- SIM_SH_FR0_REGNUM
);
2405 case SIM_SH_DSR_REGNUM
:
2408 case SIM_SH_A0G_REGNUM
:
2411 case SIM_SH_A0_REGNUM
:
2414 case SIM_SH_A1G_REGNUM
:
2417 case SIM_SH_A1_REGNUM
:
2420 case SIM_SH_M0_REGNUM
:
2423 case SIM_SH_M1_REGNUM
:
2426 case SIM_SH_X0_REGNUM
:
2429 case SIM_SH_X1_REGNUM
:
2432 case SIM_SH_Y0_REGNUM
:
2435 case SIM_SH_Y1_REGNUM
:
2438 case SIM_SH_MOD_REGNUM
:
2441 case SIM_SH_RS_REGNUM
:
2444 case SIM_SH_RE_REGNUM
:
2447 case SIM_SH_SSR_REGNUM
:
2450 case SIM_SH_SPC_REGNUM
:
2453 /* The rn_bank idiosyncracies are not due to hardware differences, but to
2454 a weird aliasing naming scheme for sh3 / sh3e / sh4. */
2455 case SIM_SH_R0_BANK0_REGNUM
: case SIM_SH_R1_BANK0_REGNUM
:
2456 case SIM_SH_R2_BANK0_REGNUM
: case SIM_SH_R3_BANK0_REGNUM
:
2457 case SIM_SH_R4_BANK0_REGNUM
: case SIM_SH_R5_BANK0_REGNUM
:
2458 case SIM_SH_R6_BANK0_REGNUM
: case SIM_SH_R7_BANK0_REGNUM
:
2459 if (saved_state
.asregs
.bfd_mach
== bfd_mach_sh2a
)
2461 rn
-= SIM_SH_R0_BANK0_REGNUM
;
2462 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[rn
];
2465 val
= (SR_MD
&& SR_RB
2466 ? Rn_BANK (rn
- SIM_SH_R0_BANK0_REGNUM
)
2467 : saved_state
.asregs
.regs
[rn
- SIM_SH_R0_BANK0_REGNUM
]);
2469 case SIM_SH_R0_BANK1_REGNUM
: case SIM_SH_R1_BANK1_REGNUM
:
2470 case SIM_SH_R2_BANK1_REGNUM
: case SIM_SH_R3_BANK1_REGNUM
:
2471 case SIM_SH_R4_BANK1_REGNUM
: case SIM_SH_R5_BANK1_REGNUM
:
2472 case SIM_SH_R6_BANK1_REGNUM
: case SIM_SH_R7_BANK1_REGNUM
:
2473 if (saved_state
.asregs
.bfd_mach
== bfd_mach_sh2a
)
2475 rn
-= SIM_SH_R0_BANK1_REGNUM
;
2476 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[rn
+ 8];
2479 val
= (! SR_MD
|| ! SR_RB
2480 ? Rn_BANK (rn
- SIM_SH_R0_BANK1_REGNUM
)
2481 : saved_state
.asregs
.regs
[rn
- SIM_SH_R0_BANK1_REGNUM
]);
2483 case SIM_SH_R0_BANK_REGNUM
: case SIM_SH_R1_BANK_REGNUM
:
2484 case SIM_SH_R2_BANK_REGNUM
: case SIM_SH_R3_BANK_REGNUM
:
2485 case SIM_SH_R4_BANK_REGNUM
: case SIM_SH_R5_BANK_REGNUM
:
2486 case SIM_SH_R6_BANK_REGNUM
: case SIM_SH_R7_BANK_REGNUM
:
2487 val
= Rn_BANK (rn
- SIM_SH_R0_BANK_REGNUM
);
2489 case SIM_SH_TBR_REGNUM
:
2492 case SIM_SH_IBNR_REGNUM
:
2495 case SIM_SH_IBCR_REGNUM
:
2498 case SIM_SH_BANK_REGNUM
:
2499 /* This is a pseudo-register maintained just for gdb.
2500 It tells us what register bank gdb would like to read/write. */
2501 val
= gdb_bank_number
;
2503 case SIM_SH_BANK_MACL_REGNUM
:
2504 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_MACL
];
2506 case SIM_SH_BANK_GBR_REGNUM
:
2507 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_GBR
];
2509 case SIM_SH_BANK_PR_REGNUM
:
2510 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_PR
];
2512 case SIM_SH_BANK_IVN_REGNUM
:
2513 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_IVN
];
2515 case SIM_SH_BANK_MACH_REGNUM
:
2516 val
= saved_state
.asregs
.regstack
[gdb_bank_number
].regs
[REGBANK_MACH
];
2521 * (int *) memory
= swap (val
);
2530 sim_resume (sd
, 0, 0);
2536 sim_stop_reason (sd
, reason
, sigrc
)
2538 enum sim_stop
*reason
;
2541 /* The SH simulator uses SIGQUIT to indicate that the program has
2542 exited, so we must check for it here and translate it to exit. */
2543 if (saved_state
.asregs
.exception
== SIGQUIT
)
2545 *reason
= sim_exited
;
2546 *sigrc
= saved_state
.asregs
.regs
[5];
2550 *reason
= sim_stopped
;
2551 *sigrc
= saved_state
.asregs
.exception
;
2556 sim_info (sd
, verbose
)
2561 (double) saved_state
.asregs
.ticks
/ (double) now_persec ();
2562 double virttime
= saved_state
.asregs
.cycles
/ 36.0e6
;
2564 callback
->printf_filtered (callback
, "\n\n# instructions executed %10d\n",
2565 saved_state
.asregs
.insts
);
2566 callback
->printf_filtered (callback
, "# cycles %10d\n",
2567 saved_state
.asregs
.cycles
);
2568 callback
->printf_filtered (callback
, "# pipeline stalls %10d\n",
2569 saved_state
.asregs
.stalls
);
2570 callback
->printf_filtered (callback
, "# misaligned load/store %10d\n",
2571 saved_state
.asregs
.memstalls
);
2572 callback
->printf_filtered (callback
, "# real time taken %10.4f\n",
2574 callback
->printf_filtered (callback
, "# virtual time taken %10.4f\n",
2576 callback
->printf_filtered (callback
, "# profiling size %10d\n",
2578 callback
->printf_filtered (callback
, "# profiling frequency %10d\n",
2579 saved_state
.asregs
.profile
);
2580 callback
->printf_filtered (callback
, "# profile maxpc %10x\n",
2581 (1 << sim_profile_size
) << PROFILE_SHIFT
);
2585 callback
->printf_filtered (callback
, "# cycles/second %10d\n",
2586 (int) (saved_state
.asregs
.cycles
/ timetaken
));
2587 callback
->printf_filtered (callback
, "# simulation ratio %10.4f\n",
2588 virttime
/ timetaken
);
2596 saved_state
.asregs
.profile
= n
;
2600 sim_set_profile_size (n
)
2603 sim_profile_size
= n
;
2607 sim_open (kind
, cb
, abfd
, argv
)
2628 for (p
= argv
+ 1; *p
!= NULL
; ++p
)
2630 if (strcmp (*p
, "-E") == 0)
2635 /* FIXME: This doesn't use stderr, but then the rest of the
2636 file doesn't either. */
2637 callback
->printf_filtered (callback
, "Missing argument to `-E'.\n");
2640 target_little_endian
= strcmp (*p
, "big") != 0;
2643 else if (isdigit (**p
))
2644 parse_and_set_memory_size (*p
);
2647 if (abfd
!= NULL
&& ! endian_set
)
2648 target_little_endian
= ! bfd_big_endian (abfd
);
2653 for (i
= 4; (i
-= 2) >= 0; )
2654 mem_word
.s
[i
>> 1] = i
;
2655 global_endianw
= mem_word
.i
>> (target_little_endian
? 0 : 16) & 0xffff;
2657 for (i
= 4; --i
>= 0; )
2659 endianb
= mem_word
.i
>> (target_little_endian
? 0 : 24) & 0xff;
2661 /* fudge our descriptor for now */
2662 return (SIM_DESC
) 1;
2666 parse_and_set_memory_size (str
)
2671 n
= strtol (str
, NULL
, 10);
2672 if (n
> 0 && n
<= 24)
2673 sim_memory_size
= n
;
2675 callback
->printf_filtered (callback
, "Bad memory size %d; must be 1 to 24, inclusive\n", n
);
2679 sim_close (sd
, quitting
)
2687 sim_load (sd
, prog
, abfd
, from_tty
)
2693 extern bfd
*sim_load_file (); /* ??? Don't know where this should live. */
2696 prog_bfd
= sim_load_file (sd
, myname
, callback
, prog
, abfd
,
2697 sim_kind
== SIM_OPEN_DEBUG
,
2700 /* Set the bfd machine type. */
2702 saved_state
.asregs
.bfd_mach
= bfd_get_mach (prog_bfd
);
2704 saved_state
.asregs
.bfd_mach
= bfd_get_mach (abfd
);
2706 saved_state
.asregs
.bfd_mach
= 0;
2708 if (prog_bfd
== NULL
)
2711 bfd_close (prog_bfd
);
2716 sim_create_inferior (sd
, prog_bfd
, argv
, env
)
2718 struct bfd
*prog_bfd
;
2722 /* Clear the registers. */
2723 memset (&saved_state
, 0,
2724 (char*) &saved_state
.asregs
.end_of_registers
- (char*) &saved_state
);
2727 if (prog_bfd
!= NULL
)
2728 saved_state
.asregs
.pc
= bfd_get_start_address (prog_bfd
);
2730 /* Set the bfd machine type. */
2731 if (prog_bfd
!= NULL
)
2732 saved_state
.asregs
.bfd_mach
= bfd_get_mach (prog_bfd
);
2734 /* Record the program's arguments. */
2741 sim_do_command (sd
, cmd
)
2745 char *sms_cmd
= "set-memory-size";
2748 if (cmd
== NULL
|| *cmd
== '\0')
2753 cmdsize
= strlen (sms_cmd
);
2754 if (strncmp (cmd
, sms_cmd
, cmdsize
) == 0
2755 && strchr (" \t", cmd
[cmdsize
]) != NULL
)
2757 parse_and_set_memory_size (cmd
+ cmdsize
+ 1);
2759 else if (strcmp (cmd
, "help") == 0)
2761 (callback
->printf_filtered
) (callback
,
2762 "List of SH simulator commands:\n\n");
2763 (callback
->printf_filtered
) (callback
, "set-memory-size <n> -- Set the number of address bits to use\n");
2764 (callback
->printf_filtered
) (callback
, "\n");
2768 (callback
->printf_filtered
) (callback
, "Error: \"%s\" is not a valid SH simulator command.\n", cmd
);
2773 sim_set_callbacks (p
)