2 /* Simulator for the MIPS architecture.
4 This file is part of the MIPS sim
6 THIS SOFTWARE IS NOT COPYRIGHTED
8 Cygnus offers the following for use in the public domain. Cygnus
9 makes no warranty with regard to the software or it's performance
10 and the user accepts the software "AS IS" with all faults.
12 CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
13 THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 The IDT monitor (found on the VR4300 board), seems to lie about
19 register contents. It seems to treat the registers as sign-extended
20 32-bit values. This cause *REAL* problems when single-stepping 64-bit
28 #include "sim-utils.h"
29 #include "sim-options.h"
30 #include "sim-assert.h"
56 #include "libiberty.h"
58 #include "gdb/callback.h" /* GDB simulator callback interface */
59 #include "gdb/remote-sim.h" /* GDB simulator interface */
61 char* pr_addr (SIM_ADDR addr
);
62 char* pr_uword64 (uword64 addr
);
65 /* Within interp.c we refer to the sim_state and sim_cpu directly. */
70 /* The following reserved instruction value is used when a simulator
71 trap is required. NOTE: Care must be taken, since this value may be
72 used in later revisions of the MIPS ISA. */
74 #define RSVD_INSTRUCTION (0x00000039)
75 #define RSVD_INSTRUCTION_MASK (0xFC00003F)
77 #define RSVD_INSTRUCTION_ARG_SHIFT 6
78 #define RSVD_INSTRUCTION_ARG_MASK 0xFFFFF
81 /* Bits in the Debug register */
82 #define Debug_DBD 0x80000000 /* Debug Branch Delay */
83 #define Debug_DM 0x40000000 /* Debug Mode */
84 #define Debug_DBp 0x00000002 /* Debug Breakpoint indicator */
86 /*---------------------------------------------------------------------------*/
87 /*-- GDB simulator interface ------------------------------------------------*/
88 /*---------------------------------------------------------------------------*/
90 static void ColdReset (SIM_DESC sd
);
92 /*---------------------------------------------------------------------------*/
96 #define DELAYSLOT() {\
97 if (STATE & simDELAYSLOT)\
98 sim_io_eprintf(sd,"Delay slot already activated (branch in delay slot?)\n");\
99 STATE |= simDELAYSLOT;\
102 #define JALDELAYSLOT() {\
104 STATE |= simJALDELAYSLOT;\
108 STATE &= ~simDELAYSLOT;\
109 STATE |= simSKIPNEXT;\
112 #define CANCELDELAYSLOT() {\
114 STATE &= ~(simDELAYSLOT | simJALDELAYSLOT);\
117 #define INDELAYSLOT() ((STATE & simDELAYSLOT) != 0)
118 #define INJALDELAYSLOT() ((STATE & simJALDELAYSLOT) != 0)
120 /* Note that the monitor code essentially assumes this layout of memory.
121 If you change these, change the monitor code, too. */
122 /* FIXME Currently addresses are truncated to 32-bits, see
123 mips/sim-main.c:address_translation(). If that changes, then these
124 values will need to be extended, and tested for more carefully. */
125 #define K0BASE (0x80000000)
126 #define K0SIZE (0x20000000)
127 #define K1BASE (0xA0000000)
128 #define K1SIZE (0x20000000)
130 /* Simple run-time monitor support.
132 We emulate the monitor by placing magic reserved instructions at
133 the monitor's entry points; when we hit these instructions, instead
134 of raising an exception (as we would normally), we look at the
135 instruction and perform the appropriate monitory operation.
137 `*_monitor_base' are the physical addresses at which the corresponding
138 monitor vectors are located. `0' means none. By default,
140 The RSVD_INSTRUCTION... macros specify the magic instructions we
141 use at the monitor entry points. */
142 static int firmware_option_p
= 0;
143 static SIM_ADDR idt_monitor_base
= 0xBFC00000;
144 static SIM_ADDR pmon_monitor_base
= 0xBFC00500;
145 static SIM_ADDR lsipmon_monitor_base
= 0xBFC00200;
147 static SIM_RC
sim_firmware_command (SIM_DESC sd
, char* arg
);
149 #define MEM_SIZE (8 << 20) /* 8 MBytes */
153 static char *tracefile
= "trace.din"; /* default filename for trace log */
154 FILE *tracefh
= NULL
;
155 static void open_trace (SIM_DESC sd
);
157 #define open_trace(sd)
160 static const char * get_insn_name (sim_cpu
*, int);
162 /* simulation target board. NULL=canonical */
163 static char* board
= NULL
;
166 static DECLARE_OPTION_HANDLER (mips_option_handler
);
169 OPTION_DINERO_TRACE
= OPTION_START
,
176 static int display_mem_info
= 0;
179 mips_option_handler (SIM_DESC sd
, sim_cpu
*cpu
, int opt
, char *arg
,
185 case OPTION_DINERO_TRACE
: /* ??? */
187 /* Eventually the simTRACE flag could be treated as a toggle, to
188 allow external control of the program points being traced
189 (i.e. only from main onwards, excluding the run-time setup,
191 for (cpu_nr
= 0; cpu_nr
< MAX_NR_PROCESSORS
; cpu_nr
++)
193 sim_cpu
*cpu
= STATE_CPU (sd
, cpu_nr
);
196 else if (strcmp (arg
, "yes") == 0)
198 else if (strcmp (arg
, "no") == 0)
200 else if (strcmp (arg
, "on") == 0)
202 else if (strcmp (arg
, "off") == 0)
206 fprintf (stderr
, "Unrecognized dinero-trace option `%s'\n", arg
);
211 #else /* !WITH_TRACE_ANY_P */
213 Simulator constructed without dinero tracing support (for performance).\n\
214 Re-compile simulator with \"-DWITH_TRACE_ANY_P\" to enable this option.\n");
216 #endif /* !WITH_TRACE_ANY_P */
218 case OPTION_DINERO_FILE
:
220 if (optarg
!= NULL
) {
222 tmp
= (char *)malloc(strlen(optarg
) + 1);
225 sim_io_printf(sd
,"Failed to allocate buffer for tracefile name \"%s\"\n",optarg
);
231 sim_io_printf(sd
,"Placing trace information into file \"%s\"\n",tracefile
);
234 #endif /* WITH_TRACE_ANY_P */
237 case OPTION_FIRMWARE
:
238 return sim_firmware_command (sd
, arg
);
244 board
= zalloc(strlen(arg
) + 1);
250 case OPTION_INFO_MEMORY
:
251 display_mem_info
= 1;
259 static const OPTION mips_options
[] =
261 { {"dinero-trace", optional_argument
, NULL
, OPTION_DINERO_TRACE
},
262 '\0', "on|off", "Enable dinero tracing",
263 mips_option_handler
},
264 { {"dinero-file", required_argument
, NULL
, OPTION_DINERO_FILE
},
265 '\0', "FILE", "Write dinero trace to FILE",
266 mips_option_handler
},
267 { {"firmware", required_argument
, NULL
, OPTION_FIRMWARE
},
268 '\0', "[idt|pmon|lsipmon|none][@ADDRESS]", "Emulate ROM monitor",
269 mips_option_handler
},
270 { {"board", required_argument
, NULL
, OPTION_BOARD
},
271 '\0', "none" /* rely on compile-time string concatenation for other options */
273 #define BOARD_JMR3904 "jmr3904"
275 #define BOARD_JMR3904_PAL "jmr3904pal"
276 "|" BOARD_JMR3904_PAL
277 #define BOARD_JMR3904_DEBUG "jmr3904debug"
278 "|" BOARD_JMR3904_DEBUG
279 #define BOARD_BSP "bsp"
282 , "Customize simulation for a particular board.", mips_option_handler
},
284 /* These next two options have the same names as ones found in the
285 memory_options[] array in common/sim-memopt.c. This is because
286 the intention is to provide an alternative handler for those two
287 options. We need an alternative handler because the memory
288 regions are not set up until after the command line arguments
289 have been parsed, and so we cannot display the memory info whilst
290 processing the command line. There is a hack in sim_open to
291 remove these handlers when we want the real --memory-info option
293 { { "info-memory", no_argument
, NULL
, OPTION_INFO_MEMORY
},
294 '\0', NULL
, "List configured memory regions", mips_option_handler
},
295 { { "memory-info", no_argument
, NULL
, OPTION_INFO_MEMORY
},
296 '\0', NULL
, NULL
, mips_option_handler
},
298 { {NULL
, no_argument
, NULL
, 0}, '\0', NULL
, NULL
, NULL
}
302 int interrupt_pending
;
305 interrupt_event (SIM_DESC sd
, void *data
)
307 sim_cpu
*cpu
= STATE_CPU (sd
, 0); /* FIXME */
308 address_word cia
= CPU_PC_GET (cpu
);
311 interrupt_pending
= 0;
312 SignalExceptionInterrupt (1); /* interrupt "1" */
314 else if (!interrupt_pending
)
315 sim_events_schedule (sd
, 1, interrupt_event
, data
);
319 /*---------------------------------------------------------------------------*/
320 /*-- Device registration hook -----------------------------------------------*/
321 /*---------------------------------------------------------------------------*/
322 static void device_init(SIM_DESC sd
) {
324 extern void register_devices(SIM_DESC
);
325 register_devices(sd
);
329 /*---------------------------------------------------------------------------*/
330 /*-- GDB simulator interface ------------------------------------------------*/
331 /*---------------------------------------------------------------------------*/
334 mips_pc_get (sim_cpu
*cpu
)
340 mips_pc_set (sim_cpu
*cpu
, sim_cia pc
)
345 static int mips_reg_fetch (SIM_CPU
*, int, unsigned char *, int);
346 static int mips_reg_store (SIM_CPU
*, int, unsigned char *, int);
349 sim_open (SIM_OPEN_KIND kind
, host_callback
*cb
, struct bfd
*abfd
, char **argv
)
352 SIM_DESC sd
= sim_state_alloc (kind
, cb
);
355 SIM_ASSERT (STATE_MAGIC (sd
) == SIM_MAGIC_NUMBER
);
357 /* The cpu data is kept in a separately allocated chunk of memory. */
358 if (sim_cpu_alloc_all (sd
, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK
)
361 cpu
= STATE_CPU (sd
, 0); /* FIXME */
363 /* FIXME: watchpoints code shouldn't need this */
364 STATE_WATCHPOINTS (sd
)->pc
= &(PC
);
365 STATE_WATCHPOINTS (sd
)->sizeof_pc
= sizeof (PC
);
366 STATE_WATCHPOINTS (sd
)->interrupt_handler
= interrupt_event
;
368 /* Initialize the mechanism for doing insn profiling. */
369 CPU_INSN_NAME (cpu
) = get_insn_name
;
370 CPU_MAX_INSNS (cpu
) = nr_itable_entries
;
374 if (sim_pre_argv_init (sd
, argv
[0]) != SIM_RC_OK
)
376 sim_add_option_table (sd
, NULL
, mips_options
);
379 /* The parser will print an error message for us, so we silently return. */
380 if (sim_parse_args (sd
, argv
) != SIM_RC_OK
)
382 /* Uninstall the modules to avoid memory leaks,
383 file descriptor leaks, etc. */
384 sim_module_uninstall (sd
);
388 /* handle board-specific memory maps */
391 /* Allocate core managed memory */
392 sim_memopt
*entry
, *match
= NULL
;
393 address_word mem_size
= 0;
396 /* For compatibility with the old code - under this (at level one)
397 are the kernel spaces K0 & K1. Both of these map to a single
398 smaller sub region */
399 sim_do_command(sd
," memory region 0x7fff8000,0x8000") ; /* MTZ- 32 k stack */
401 /* Look for largest memory region defined on command-line at
403 for (entry
= STATE_MEMOPT (sd
); entry
!= NULL
; entry
= entry
->next
)
405 /* If we find an entry at address 0, then we will end up
406 allocating a new buffer in the "memory alias" command
407 below. The region at address 0 will be deleted. */
408 address_word size
= (entry
->modulo
!= 0
409 ? entry
->modulo
: entry
->nr_bytes
);
411 && (!match
|| entry
->level
< match
->level
))
413 else if (entry
->addr
== K0BASE
|| entry
->addr
== K1BASE
)
418 for (alias
= entry
->alias
; alias
!= NULL
; alias
= alias
->next
)
421 && (!match
|| entry
->level
< match
->level
))
423 else if (alias
->addr
== K0BASE
|| alias
->addr
== K1BASE
)
433 /* Get existing memory region size. */
434 mem_size
= (match
->modulo
!= 0
435 ? match
->modulo
: match
->nr_bytes
);
436 /* Delete old region. */
437 sim_do_commandf (sd
, "memory delete %d:0x%lx@%d",
438 match
->space
, match
->addr
, match
->level
);
440 else if (mem_size
== 0)
442 /* Limit to KSEG1 size (512MB) */
443 if (mem_size
> K1SIZE
)
445 /* memory alias K1BASE@1,K1SIZE%MEMSIZE,K0BASE */
446 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx%%0x%lx,0x%0x",
447 K1BASE
, K1SIZE
, (long)mem_size
, K0BASE
);
452 else if (board
!= NULL
453 && (strcmp(board
, BOARD_BSP
) == 0))
457 STATE_ENVIRONMENT (sd
) = OPERATING_ENVIRONMENT
;
459 /* ROM: 0x9FC0_0000 - 0x9FFF_FFFF and 0xBFC0_0000 - 0xBFFF_FFFF */
460 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
462 4 * 1024 * 1024, /* 4 MB */
465 /* SRAM: 0x8000_0000 - 0x803F_FFFF and 0xA000_0000 - 0xA03F_FFFF */
466 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
468 4 * 1024 * 1024, /* 4 MB */
471 /* DRAM: 0x8800_0000 - 0x89FF_FFFF and 0xA800_0000 - 0xA9FF_FFFF */
472 for (i
=0; i
<8; i
++) /* 32 MB total */
474 unsigned size
= 4 * 1024 * 1024; /* 4 MB */
475 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
476 0x88000000 + (i
* size
),
478 0xA8000000 + (i
* size
));
482 else if (board
!= NULL
483 && (strcmp(board
, BOARD_JMR3904
) == 0 ||
484 strcmp(board
, BOARD_JMR3904_PAL
) == 0 ||
485 strcmp(board
, BOARD_JMR3904_DEBUG
) == 0))
487 /* match VIRTUAL memory layout of JMR-TX3904 board */
490 /* --- disable monitor unless forced on by user --- */
492 if (! firmware_option_p
)
494 idt_monitor_base
= 0;
495 pmon_monitor_base
= 0;
496 lsipmon_monitor_base
= 0;
499 /* --- environment --- */
501 STATE_ENVIRONMENT (sd
) = OPERATING_ENVIRONMENT
;
505 /* ROM: 0x9FC0_0000 - 0x9FFF_FFFF and 0xBFC0_0000 - 0xBFFF_FFFF */
506 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
508 4 * 1024 * 1024, /* 4 MB */
511 /* SRAM: 0x8000_0000 - 0x803F_FFFF and 0xA000_0000 - 0xA03F_FFFF */
512 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
514 4 * 1024 * 1024, /* 4 MB */
517 /* DRAM: 0x8800_0000 - 0x89FF_FFFF and 0xA800_0000 - 0xA9FF_FFFF */
518 for (i
=0; i
<8; i
++) /* 32 MB total */
520 unsigned size
= 4 * 1024 * 1024; /* 4 MB */
521 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx,0x%0x",
522 0x88000000 + (i
* size
),
524 0xA8000000 + (i
* size
));
527 /* Dummy memory regions for unsimulated devices - sorted by address */
529 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xB1000000, 0x400); /* ISA I/O */
530 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xB2100000, 0x004); /* ISA ctl */
531 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xB2500000, 0x004); /* LED/switch */
532 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xB2700000, 0x004); /* RTC */
533 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xB3C00000, 0x004); /* RTC */
534 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xFFFF8000, 0x900); /* DRAMC */
535 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xFFFF9000, 0x200); /* EBIF */
536 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xFFFFE000, 0x01c); /* EBIF */
537 sim_do_commandf (sd
, "memory alias 0x%lx@1,0x%lx", 0xFFFFF500, 0x300); /* PIO */
540 /* --- simulated devices --- */
541 sim_hw_parse (sd
, "/tx3904irc@0xffffc000/reg 0xffffc000 0x20");
542 sim_hw_parse (sd
, "/tx3904cpu");
543 sim_hw_parse (sd
, "/tx3904tmr@0xfffff000/reg 0xfffff000 0x100");
544 sim_hw_parse (sd
, "/tx3904tmr@0xfffff100/reg 0xfffff100 0x100");
545 sim_hw_parse (sd
, "/tx3904tmr@0xfffff200/reg 0xfffff200 0x100");
546 sim_hw_parse (sd
, "/tx3904sio@0xfffff300/reg 0xfffff300 0x100");
548 /* FIXME: poking at dv-sockser internals, use tcp backend if
549 --sockser_addr option was given.*/
550 extern char* sockser_addr
;
551 if(sockser_addr
== NULL
)
552 sim_hw_parse (sd
, "/tx3904sio@0xfffff300/backend stdio");
554 sim_hw_parse (sd
, "/tx3904sio@0xfffff300/backend tcp");
556 sim_hw_parse (sd
, "/tx3904sio@0xfffff400/reg 0xfffff400 0x100");
557 sim_hw_parse (sd
, "/tx3904sio@0xfffff400/backend stdio");
559 /* -- device connections --- */
560 sim_hw_parse (sd
, "/tx3904irc > ip level /tx3904cpu");
561 sim_hw_parse (sd
, "/tx3904tmr@0xfffff000 > int tmr0 /tx3904irc");
562 sim_hw_parse (sd
, "/tx3904tmr@0xfffff100 > int tmr1 /tx3904irc");
563 sim_hw_parse (sd
, "/tx3904tmr@0xfffff200 > int tmr2 /tx3904irc");
564 sim_hw_parse (sd
, "/tx3904sio@0xfffff300 > int sio0 /tx3904irc");
565 sim_hw_parse (sd
, "/tx3904sio@0xfffff400 > int sio1 /tx3904irc");
567 /* add PAL timer & I/O module */
568 if(! strcmp(board
, BOARD_JMR3904_PAL
))
571 sim_hw_parse (sd
, "/pal@0xffff0000");
572 sim_hw_parse (sd
, "/pal@0xffff0000/reg 0xffff0000 64");
574 /* wire up interrupt ports to irc */
575 sim_hw_parse (sd
, "/pal@0x31000000 > countdown tmr0 /tx3904irc");
576 sim_hw_parse (sd
, "/pal@0x31000000 > timer tmr1 /tx3904irc");
577 sim_hw_parse (sd
, "/pal@0x31000000 > int int0 /tx3904irc");
580 if(! strcmp(board
, BOARD_JMR3904_DEBUG
))
582 /* -- DEBUG: glue interrupt generators --- */
583 sim_hw_parse (sd
, "/glue@0xffff0000/reg 0xffff0000 0x50");
584 sim_hw_parse (sd
, "/glue@0xffff0000 > int0 int0 /tx3904irc");
585 sim_hw_parse (sd
, "/glue@0xffff0000 > int1 int1 /tx3904irc");
586 sim_hw_parse (sd
, "/glue@0xffff0000 > int2 int2 /tx3904irc");
587 sim_hw_parse (sd
, "/glue@0xffff0000 > int3 int3 /tx3904irc");
588 sim_hw_parse (sd
, "/glue@0xffff0000 > int4 int4 /tx3904irc");
589 sim_hw_parse (sd
, "/glue@0xffff0000 > int5 int5 /tx3904irc");
590 sim_hw_parse (sd
, "/glue@0xffff0000 > int6 int6 /tx3904irc");
591 sim_hw_parse (sd
, "/glue@0xffff0000 > int7 int7 /tx3904irc");
592 sim_hw_parse (sd
, "/glue@0xffff0000 > int8 dmac0 /tx3904irc");
593 sim_hw_parse (sd
, "/glue@0xffff0000 > int9 dmac1 /tx3904irc");
594 sim_hw_parse (sd
, "/glue@0xffff0000 > int10 dmac2 /tx3904irc");
595 sim_hw_parse (sd
, "/glue@0xffff0000 > int11 dmac3 /tx3904irc");
596 sim_hw_parse (sd
, "/glue@0xffff0000 > int12 sio0 /tx3904irc");
597 sim_hw_parse (sd
, "/glue@0xffff0000 > int13 sio1 /tx3904irc");
598 sim_hw_parse (sd
, "/glue@0xffff0000 > int14 tmr0 /tx3904irc");
599 sim_hw_parse (sd
, "/glue@0xffff0000 > int15 tmr1 /tx3904irc");
600 sim_hw_parse (sd
, "/glue@0xffff0000 > int16 tmr2 /tx3904irc");
601 sim_hw_parse (sd
, "/glue@0xffff0000 > int17 nmi /tx3904cpu");
608 if (display_mem_info
)
610 struct option_list
* ol
;
611 struct option_list
* prev
;
613 /* This is a hack. We want to execute the real --memory-info command
614 line switch which is handled in common/sim-memopts.c, not the
615 override we have defined in this file. So we remove the
616 mips_options array from the state options list. This is safe
617 because we have now processed all of the command line. */
618 for (ol
= STATE_OPTIONS (sd
), prev
= NULL
;
620 prev
= ol
, ol
= ol
->next
)
621 if (ol
->options
== mips_options
)
624 SIM_ASSERT (ol
!= NULL
);
627 STATE_OPTIONS (sd
) = ol
->next
;
629 prev
->next
= ol
->next
;
631 sim_do_commandf (sd
, "memory-info");
634 /* check for/establish the a reference program image */
635 if (sim_analyze_program (sd
,
636 (STATE_PROG_ARGV (sd
) != NULL
637 ? *STATE_PROG_ARGV (sd
)
641 sim_module_uninstall (sd
);
645 /* Configure/verify the target byte order and other runtime
646 configuration options */
647 if (sim_config (sd
) != SIM_RC_OK
)
649 sim_module_uninstall (sd
);
653 if (sim_post_argv_init (sd
) != SIM_RC_OK
)
655 /* Uninstall the modules to avoid memory leaks,
656 file descriptor leaks, etc. */
657 sim_module_uninstall (sd
);
661 /* verify assumptions the simulator made about the host type system.
662 This macro does not return if there is a problem */
663 SIM_ASSERT (sizeof(int) == (4 * sizeof(char)));
664 SIM_ASSERT (sizeof(word64
) == (8 * sizeof(char)));
666 /* This is NASTY, in that we are assuming the size of specific
670 for (rn
= 0; (rn
< (LAST_EMBED_REGNUM
+ 1)); rn
++)
673 cpu
->register_widths
[rn
] = WITH_TARGET_WORD_BITSIZE
;
674 else if ((rn
>= FGR_BASE
) && (rn
< (FGR_BASE
+ NR_FGR
)))
675 cpu
->register_widths
[rn
] = WITH_TARGET_FLOATING_POINT_BITSIZE
;
676 else if ((rn
>= 33) && (rn
<= 37))
677 cpu
->register_widths
[rn
] = WITH_TARGET_WORD_BITSIZE
;
678 else if ((rn
== SRIDX
)
681 || ((rn
>= 72) && (rn
<= 89)))
682 cpu
->register_widths
[rn
] = 32;
684 cpu
->register_widths
[rn
] = 0;
690 if (STATE
& simTRACE
)
694 sim_io_eprintf (sd, "idt@%x pmon@%x lsipmon@%x\n",
697 lsipmon_monitor_base);
700 /* Write the monitor trap address handlers into the monitor (eeprom)
701 address space. This can only be done once the target endianness
702 has been determined. */
703 if (idt_monitor_base
!= 0)
706 unsigned idt_monitor_size
= 1 << 11;
708 /* the default monitor region */
709 sim_do_commandf (sd
, "memory region 0x%x,0x%x",
710 idt_monitor_base
, idt_monitor_size
);
712 /* Entry into the IDT monitor is via fixed address vectors, and
713 not using machine instructions. To avoid clashing with use of
714 the MIPS TRAP system, we place our own (simulator specific)
715 "undefined" instructions into the relevant vector slots. */
716 for (loop
= 0; (loop
< idt_monitor_size
); loop
+= 4)
718 address_word vaddr
= (idt_monitor_base
+ loop
);
719 unsigned32 insn
= (RSVD_INSTRUCTION
|
720 (((loop
>> 2) & RSVD_INSTRUCTION_ARG_MASK
)
721 << RSVD_INSTRUCTION_ARG_SHIFT
));
723 sim_write (sd
, vaddr
, (unsigned char *)&insn
, sizeof (insn
));
727 if ((pmon_monitor_base
!= 0) || (lsipmon_monitor_base
!= 0))
729 /* The PMON monitor uses the same address space, but rather than
730 branching into it the address of a routine is loaded. We can
731 cheat for the moment, and direct the PMON routine to IDT style
732 instructions within the monitor space. This relies on the IDT
733 monitor not using the locations from 0xBFC00500 onwards as its
736 for (loop
= 0; (loop
< 24); loop
++)
738 unsigned32 value
= ((0x500 - 8) / 8); /* default UNDEFINED reason code */
754 value
= ((0x500 - 16) / 8); /* not an IDT reason code */
756 case 8: /* cliexit */
759 case 11: /* flush_cache */
764 SIM_ASSERT (idt_monitor_base
!= 0);
765 value
= ((unsigned int) idt_monitor_base
+ (value
* 8));
768 if (pmon_monitor_base
!= 0)
770 address_word vaddr
= (pmon_monitor_base
+ (loop
* 4));
771 sim_write (sd
, vaddr
, (unsigned char *)&value
, sizeof (value
));
774 if (lsipmon_monitor_base
!= 0)
776 address_word vaddr
= (lsipmon_monitor_base
+ (loop
* 4));
777 sim_write (sd
, vaddr
, (unsigned char *)&value
, sizeof (value
));
781 /* Write an abort sequence into the TRAP (common) exception vector
782 addresses. This is to catch code executing a TRAP (et.al.)
783 instruction without installing a trap handler. */
784 if ((idt_monitor_base
!= 0) ||
785 (pmon_monitor_base
!= 0) ||
786 (lsipmon_monitor_base
!= 0))
788 unsigned32 halt
[2] = { 0x2404002f /* addiu r4, r0, 47 */,
789 HALT_INSTRUCTION
/* BREAK */ };
792 sim_write (sd
, 0x80000000, (unsigned char *) halt
, sizeof (halt
));
793 sim_write (sd
, 0x80000180, (unsigned char *) halt
, sizeof (halt
));
794 sim_write (sd
, 0x80000200, (unsigned char *) halt
, sizeof (halt
));
795 /* XXX: Write here unconditionally? */
796 sim_write (sd
, 0xBFC00200, (unsigned char *) halt
, sizeof (halt
));
797 sim_write (sd
, 0xBFC00380, (unsigned char *) halt
, sizeof (halt
));
798 sim_write (sd
, 0xBFC00400, (unsigned char *) halt
, sizeof (halt
));
802 /* CPU specific initialization. */
803 for (i
= 0; i
< MAX_NR_PROCESSORS
; ++i
)
805 SIM_CPU
*cpu
= STATE_CPU (sd
, i
);
807 CPU_REG_FETCH (cpu
) = mips_reg_fetch
;
808 CPU_REG_STORE (cpu
) = mips_reg_store
;
809 CPU_PC_FETCH (cpu
) = mips_pc_get
;
810 CPU_PC_STORE (cpu
) = mips_pc_set
;
818 open_trace (SIM_DESC sd
)
820 tracefh
= fopen(tracefile
,"wb+");
823 sim_io_eprintf(sd
,"Failed to create file \"%s\", writing trace information to stderr.\n",tracefile
);
829 /* Return name of an insn, used by insn profiling. */
831 get_insn_name (sim_cpu
*cpu
, int i
)
833 return itable
[i
].name
;
837 mips_sim_close (SIM_DESC sd
, int quitting
)
840 if (tracefh
!= NULL
&& tracefh
!= stderr
)
847 mips_reg_store (SIM_CPU
*cpu
, int rn
, unsigned char *memory
, int length
)
849 /* NOTE: gdb (the client) stores registers in target byte order
850 while the simulator uses host byte order */
852 /* Unfortunately this suffers from the same problem as the register
853 numbering one. We need to know what the width of each logical
854 register number is for the architecture being simulated. */
856 if (cpu
->register_widths
[rn
] == 0)
858 sim_io_eprintf (CPU_STATE (cpu
), "Invalid register width for %d (register store ignored)\n", rn
);
862 if (rn
>= FGR_BASE
&& rn
< FGR_BASE
+ NR_FGR
)
864 cpu
->fpr_state
[rn
- FGR_BASE
] = fmt_uninterpreted
;
865 if (cpu
->register_widths
[rn
] == 32)
869 cpu
->fgr
[rn
- FGR_BASE
] =
870 (unsigned32
) T2H_8 (*(unsigned64
*)memory
);
875 cpu
->fgr
[rn
- FGR_BASE
] = T2H_4 (*(unsigned32
*)memory
);
883 cpu
->fgr
[rn
- FGR_BASE
] = T2H_8 (*(unsigned64
*)memory
);
888 cpu
->fgr
[rn
- FGR_BASE
] = T2H_4 (*(unsigned32
*)memory
);
894 if (cpu
->register_widths
[rn
] == 32)
899 (unsigned32
) T2H_8 (*(unsigned64
*)memory
);
904 cpu
->registers
[rn
] = T2H_4 (*(unsigned32
*)memory
);
912 cpu
->registers
[rn
] = T2H_8 (*(unsigned64
*)memory
);
917 cpu
->registers
[rn
] = (signed32
) T2H_4(*(unsigned32
*)memory
);
926 mips_reg_fetch (SIM_CPU
*cpu
, int rn
, unsigned char *memory
, int length
)
928 /* NOTE: gdb (the client) stores registers in target byte order
929 while the simulator uses host byte order */
931 if (cpu
->register_widths
[rn
] == 0)
933 sim_io_eprintf (CPU_STATE (cpu
), "Invalid register width for %d (register fetch ignored)\n", rn
);
937 /* Any floating point register */
938 if (rn
>= FGR_BASE
&& rn
< FGR_BASE
+ NR_FGR
)
940 if (cpu
->register_widths
[rn
] == 32)
944 *(unsigned64
*)memory
=
945 H2T_8 ((unsigned32
) (cpu
->fgr
[rn
- FGR_BASE
]));
950 *(unsigned32
*)memory
= H2T_4 (cpu
->fgr
[rn
- FGR_BASE
]);
958 *(unsigned64
*)memory
= H2T_8 (cpu
->fgr
[rn
- FGR_BASE
]);
963 *(unsigned32
*)memory
= H2T_4 ((unsigned32
)(cpu
->fgr
[rn
- FGR_BASE
]));
969 if (cpu
->register_widths
[rn
] == 32)
973 *(unsigned64
*)memory
=
974 H2T_8 ((unsigned32
) (cpu
->registers
[rn
]));
979 *(unsigned32
*)memory
= H2T_4 ((unsigned32
)(cpu
->registers
[rn
]));
987 *(unsigned64
*)memory
=
988 H2T_8 ((unsigned64
) (cpu
->registers
[rn
]));
993 *(unsigned32
*)memory
= H2T_4 ((unsigned32
)(cpu
->registers
[rn
]));
1002 sim_create_inferior (SIM_DESC sd
, struct bfd
*abfd
, char **argv
, char **env
)
1006 #if 0 /* FIXME: doesn't compile */
1007 printf("DBG: sim_create_inferior entered: start_address = 0x%s\n",
1016 /* override PC value set by ColdReset () */
1018 for (cpu_nr
= 0; cpu_nr
< sim_engine_nr_cpus (sd
); cpu_nr
++)
1020 sim_cpu
*cpu
= STATE_CPU (sd
, cpu_nr
);
1021 CPU_PC_SET (cpu
, (unsigned64
) bfd_get_start_address (abfd
));
1025 #if 0 /* def DEBUG */
1028 /* We should really place the argv slot values into the argument
1029 registers, and onto the stack as required. However, this
1030 assumes that we have a stack defined, which is not
1031 necessarily true at the moment. */
1033 sim_io_printf(sd
,"sim_create_inferior() : passed arguments ignored\n");
1034 for (cptr
= argv
; (cptr
&& *cptr
); cptr
++)
1035 printf("DBG: arg \"%s\"\n",*cptr
);
1042 /*---------------------------------------------------------------------------*/
1043 /*-- Private simulator support interface ------------------------------------*/
1044 /*---------------------------------------------------------------------------*/
1046 /* Read a null terminated string from memory, return in a buffer */
1048 fetch_str (SIM_DESC sd
,
1054 while (sim_read (sd
, addr
+ nr
, &null
, 1) == 1 && null
!= 0)
1056 buf
= NZALLOC (char, nr
+ 1);
1057 sim_read (sd
, addr
, (unsigned char *)buf
, nr
);
1062 /* Implements the "sim firmware" command:
1063 sim firmware NAME[@ADDRESS] --- emulate ROM monitor named NAME.
1064 NAME can be idt, pmon, or lsipmon. If omitted, ADDRESS
1065 defaults to the normal address for that monitor.
1066 sim firmware none --- don't emulate any ROM monitor. Useful
1067 if you need a clean address space. */
1069 sim_firmware_command (SIM_DESC sd
, char *arg
)
1071 int address_present
= 0;
1074 /* Signal occurrence of this option. */
1075 firmware_option_p
= 1;
1077 /* Parse out the address, if present. */
1079 char *p
= strchr (arg
, '@');
1083 address_present
= 1;
1084 p
++; /* skip over @ */
1086 address
= strtoul (p
, &q
, 0);
1089 sim_io_printf (sd
, "Invalid address given to the"
1090 "`sim firmware NAME@ADDRESS' command: %s\n",
1097 address_present
= 0;
1098 address
= -1; /* Dummy value. */
1102 if (! strncmp (arg
, "idt", 3))
1104 idt_monitor_base
= address_present
? address
: 0xBFC00000;
1105 pmon_monitor_base
= 0;
1106 lsipmon_monitor_base
= 0;
1108 else if (! strncmp (arg
, "pmon", 4))
1110 /* pmon uses indirect calls. Hook into implied idt. */
1111 pmon_monitor_base
= address_present
? address
: 0xBFC00500;
1112 idt_monitor_base
= pmon_monitor_base
- 0x500;
1113 lsipmon_monitor_base
= 0;
1115 else if (! strncmp (arg
, "lsipmon", 7))
1117 /* lsipmon uses indirect calls. Hook into implied idt. */
1118 pmon_monitor_base
= 0;
1119 lsipmon_monitor_base
= address_present
? address
: 0xBFC00200;
1120 idt_monitor_base
= lsipmon_monitor_base
- 0x200;
1122 else if (! strncmp (arg
, "none", 4))
1124 if (address_present
)
1127 "The `sim firmware none' command does "
1128 "not take an `ADDRESS' argument.\n");
1131 idt_monitor_base
= 0;
1132 pmon_monitor_base
= 0;
1133 lsipmon_monitor_base
= 0;
1137 sim_io_printf (sd
, "\
1138 Unrecognized name given to the `sim firmware NAME' command: %s\n\
1139 Recognized firmware names are: `idt', `pmon', `lsipmon', and `none'.\n",
1149 /* Simple monitor interface (currently setup for the IDT and PMON monitors) */
1151 sim_monitor (SIM_DESC sd
,
1154 unsigned int reason
)
1157 printf("DBG: sim_monitor: entered (reason = %d)\n",reason
);
1160 /* The IDT monitor actually allows two instructions per vector
1161 slot. However, the simulator currently causes a trap on each
1162 individual instruction. We cheat, and lose the bottom bit. */
1165 /* The following callback functions are available, however the
1166 monitor we are simulating does not make use of them: get_errno,
1167 isatty, lseek, rename, system, time and unlink */
1171 case 6: /* int open(char *path,int flags) */
1173 char *path
= fetch_str (sd
, A0
);
1174 V0
= sim_io_open (sd
, path
, (int)A1
);
1179 case 7: /* int read(int file,char *ptr,int len) */
1183 char *buf
= zalloc (nr
);
1184 V0
= sim_io_read (sd
, fd
, buf
, nr
);
1185 sim_write (sd
, A1
, (unsigned char *)buf
, nr
);
1190 case 8: /* int write(int file,char *ptr,int len) */
1194 char *buf
= zalloc (nr
);
1195 sim_read (sd
, A1
, (unsigned char *)buf
, nr
);
1196 V0
= sim_io_write (sd
, fd
, buf
, nr
);
1198 sim_io_flush_stdout (sd
);
1200 sim_io_flush_stderr (sd
);
1205 case 10: /* int close(int file) */
1207 V0
= sim_io_close (sd
, (int)A0
);
1211 case 2: /* Densan monitor: char inbyte(int waitflag) */
1213 if (A0
== 0) /* waitflag == NOWAIT */
1214 V0
= (unsigned_word
)-1;
1216 /* Drop through to case 11 */
1218 case 11: /* char inbyte(void) */
1221 /* ensure that all output has gone... */
1222 sim_io_flush_stdout (sd
);
1223 if (sim_io_read_stdin (sd
, &tmp
, sizeof(char)) != sizeof(char))
1225 sim_io_error(sd
,"Invalid return from character read");
1226 V0
= (unsigned_word
)-1;
1229 V0
= (unsigned_word
)tmp
;
1233 case 3: /* Densan monitor: void co(char chr) */
1234 case 12: /* void outbyte(char chr) : write a byte to "stdout" */
1236 char tmp
= (char)(A0
& 0xFF);
1237 sim_io_write_stdout (sd
, &tmp
, sizeof(char));
1241 case 17: /* void _exit() */
1243 sim_io_eprintf (sd
, "sim_monitor(17): _exit(int reason) to be coded\n");
1244 sim_engine_halt (SD
, CPU
, NULL
, NULL_CIA
, sim_exited
,
1245 (unsigned int)(A0
& 0xFFFFFFFF));
1249 case 28: /* PMON flush_cache */
1252 case 55: /* void get_mem_info(unsigned int *ptr) */
1253 /* in: A0 = pointer to three word memory location */
1254 /* out: [A0 + 0] = size */
1255 /* [A0 + 4] = instruction cache size */
1256 /* [A0 + 8] = data cache size */
1259 unsigned_4 zero
= 0;
1260 address_word mem_size
;
1261 sim_memopt
*entry
, *match
= NULL
;
1263 /* Search for memory region mapped to KSEG0 or KSEG1. */
1264 for (entry
= STATE_MEMOPT (sd
);
1266 entry
= entry
->next
)
1268 if ((entry
->addr
== K0BASE
|| entry
->addr
== K1BASE
)
1269 && (!match
|| entry
->level
< match
->level
))
1274 for (alias
= entry
->alias
;
1276 alias
= alias
->next
)
1277 if ((alias
->addr
== K0BASE
|| alias
->addr
== K1BASE
)
1278 && (!match
|| entry
->level
< match
->level
))
1283 /* Get region size, limit to KSEG1 size (512MB). */
1284 SIM_ASSERT (match
!= NULL
);
1285 mem_size
= (match
->modulo
!= 0
1286 ? match
->modulo
: match
->nr_bytes
);
1287 if (mem_size
> K1SIZE
)
1292 sim_write (sd
, A0
+ 0, (unsigned char *)&value
, 4);
1293 sim_write (sd
, A0
+ 4, (unsigned char *)&zero
, 4);
1294 sim_write (sd
, A0
+ 8, (unsigned char *)&zero
, 4);
1295 /* sim_io_eprintf (sd, "sim: get_mem_info() deprecated\n"); */
1299 case 158: /* PMON printf */
1300 /* in: A0 = pointer to format string */
1301 /* A1 = optional argument 1 */
1302 /* A2 = optional argument 2 */
1303 /* A3 = optional argument 3 */
1305 /* The following is based on the PMON printf source */
1307 address_word s
= A0
;
1309 signed_word
*ap
= &A1
; /* 1st argument */
1310 /* This isn't the quickest way, since we call the host print
1311 routine for every character almost. But it does avoid
1312 having to allocate and manage a temporary string buffer. */
1313 /* TODO: Include check that we only use three arguments (A1,
1315 while (sim_read (sd
, s
++, &c
, 1) && c
!= '\0')
1320 enum {FMT_RJUST
, FMT_LJUST
, FMT_RJUST0
, FMT_CENTER
} fmt
= FMT_RJUST
;
1321 int width
= 0, trunc
= 0, haddot
= 0, longlong
= 0;
1322 while (sim_read (sd
, s
++, &c
, 1) && c
!= '\0')
1324 if (strchr ("dobxXulscefg%", c
))
1339 else if (c
>= '1' && c
<= '9')
1343 while (sim_read (sd
, s
++, &c
, 1) == 1 && isdigit (c
))
1346 n
= (unsigned int)strtol(tmp
,NULL
,10);
1359 sim_io_printf (sd
, "%%");
1364 address_word p
= *ap
++;
1366 while (sim_read (sd
, p
++, &ch
, 1) == 1 && ch
!= '\0')
1367 sim_io_printf(sd
, "%c", ch
);
1370 sim_io_printf(sd
,"(null)");
1373 sim_io_printf (sd
, "%c", (int)*ap
++);
1378 sim_read (sd
, s
++, &c
, 1);
1382 sim_read (sd
, s
++, &c
, 1);
1385 if (strchr ("dobxXu", c
))
1387 word64 lv
= (word64
) *ap
++;
1389 sim_io_printf(sd
,"<binary not supported>");
1392 sprintf (tmp
, "%%%s%c", longlong
? "ll" : "", c
);
1394 sim_io_printf(sd
, tmp
, lv
);
1396 sim_io_printf(sd
, tmp
, (int)lv
);
1399 else if (strchr ("eEfgG", c
))
1401 double dbl
= *(double*)(ap
++);
1402 sprintf (tmp
, "%%%d.%d%c", width
, trunc
, c
);
1403 sim_io_printf (sd
, tmp
, dbl
);
1409 sim_io_printf(sd
, "%c", c
);
1415 /* Unknown reason. */
1421 /* Store a word into memory. */
1424 store_word (SIM_DESC sd
,
1430 address_word paddr
= vaddr
;
1432 if ((vaddr
& 3) != 0)
1433 SignalExceptionAddressStore ();
1436 const uword64 mask
= 7;
1440 paddr
= (paddr
& ~mask
) | ((paddr
& mask
) ^ (ReverseEndian
<< 2));
1441 byte
= (vaddr
& mask
) ^ (BigEndianCPU
<< 2);
1442 memval
= ((uword64
) val
) << (8 * byte
);
1443 StoreMemory (AccessLength_WORD
, memval
, 0, paddr
, vaddr
,
1448 /* Load a word from memory. */
1451 load_word (SIM_DESC sd
,
1456 if ((vaddr
& 3) != 0)
1458 SIM_CORE_SIGNAL (SD
, cpu
, cia
, read_map
, AccessLength_WORD
+1, vaddr
, read_transfer
, sim_core_unaligned_signal
);
1462 address_word paddr
= vaddr
;
1463 const uword64 mask
= 0x7;
1464 const unsigned int reverse
= ReverseEndian
? 1 : 0;
1465 const unsigned int bigend
= BigEndianCPU
? 1 : 0;
1469 paddr
= (paddr
& ~mask
) | ((paddr
& mask
) ^ (reverse
<< 2));
1470 LoadMemory (&memval
, NULL
, AccessLength_WORD
, paddr
, vaddr
, isDATA
,
1472 byte
= (vaddr
& mask
) ^ (bigend
<< 2);
1473 return EXTEND32 (memval
>> (8 * byte
));
1479 /* Simulate the mips16 entry and exit pseudo-instructions. These
1480 would normally be handled by the reserved instruction exception
1481 code, but for ease of simulation we just handle them directly. */
1484 mips16_entry (SIM_DESC sd
,
1489 int aregs
, sregs
, rreg
;
1492 printf("DBG: mips16_entry: entered (insn = 0x%08X)\n",insn
);
1495 aregs
= (insn
& 0x700) >> 8;
1496 sregs
= (insn
& 0x0c0) >> 6;
1497 rreg
= (insn
& 0x020) >> 5;
1499 /* This should be checked by the caller. */
1508 /* This is the entry pseudo-instruction. */
1510 for (i
= 0; i
< aregs
; i
++)
1511 store_word (SD
, CPU
, cia
, (uword64
) (SP
+ 4 * i
), GPR
[i
+ 4]);
1519 store_word (SD
, CPU
, cia
, (uword64
) tsp
, RA
);
1522 for (i
= 0; i
< sregs
; i
++)
1525 store_word (SD
, CPU
, cia
, (uword64
) tsp
, GPR
[16 + i
]);
1533 /* This is the exit pseudo-instruction. */
1540 RA
= load_word (SD
, CPU
, cia
, (uword64
) tsp
);
1543 for (i
= 0; i
< sregs
; i
++)
1546 GPR
[i
+ 16] = load_word (SD
, CPU
, cia
, (uword64
) tsp
);
1551 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
1555 FGR
[0] = WORD64LO (GPR
[4]);
1556 FPR_STATE
[0] = fmt_uninterpreted
;
1558 else if (aregs
== 6)
1560 FGR
[0] = WORD64LO (GPR
[5]);
1561 FGR
[1] = WORD64LO (GPR
[4]);
1562 FPR_STATE
[0] = fmt_uninterpreted
;
1563 FPR_STATE
[1] = fmt_uninterpreted
;
1572 /*-- trace support ----------------------------------------------------------*/
1574 /* The trace support is provided (if required) in the memory accessing
1575 routines. Since we are also providing the architecture specific
1576 features, the architecture simulation code can also deal with
1577 notifying the trace world of cache flushes, etc. Similarly we do
1578 not need to provide profiling support in the simulator engine,
1579 since we can sample in the instruction fetch control loop. By
1580 defining the trace manifest, we add tracing as a run-time
1583 #if WITH_TRACE_ANY_P
1584 /* Tracing by default produces "din" format (as required by
1585 dineroIII). Each line of such a trace file *MUST* have a din label
1586 and address field. The rest of the line is ignored, so comments can
1587 be included if desired. The first field is the label which must be
1588 one of the following values:
1593 3 escape record (treated as unknown access type)
1594 4 escape record (causes cache flush)
1596 The address field is a 32bit (lower-case) hexadecimal address
1597 value. The address should *NOT* be preceded by "0x".
1599 The size of the memory transfer is not important when dealing with
1600 cache lines (as long as no more than a cache line can be
1601 transferred in a single operation :-), however more information
1602 could be given following the dineroIII requirement to allow more
1603 complete memory and cache simulators to provide better
1604 results. i.e. the University of Pisa has a cache simulator that can
1605 also take bus size and speed as (variable) inputs to calculate
1606 complete system performance (a much more useful ability when trying
1607 to construct an end product, rather than a processor). They
1608 currently have an ARM version of their tool called ChARM. */
1612 dotrace (SIM_DESC sd
,
1620 if (STATE
& simTRACE
) {
1622 fprintf(tracefh
,"%d %s ; width %d ; ",
1626 va_start(ap
,comment
);
1627 vfprintf(tracefh
,comment
,ap
);
1629 fprintf(tracefh
,"\n");
1631 /* NOTE: Since the "din" format will only accept 32bit addresses, and
1632 we may be generating 64bit ones, we should put the hi-32bits of the
1633 address into the comment field. */
1635 /* TODO: Provide a buffer for the trace lines. We can then avoid
1636 performing writes until the buffer is filled, or the file is
1639 /* NOTE: We could consider adding a comment field to the "din" file
1640 produced using type 3 markers (unknown access). This would then
1641 allow information about the program that the "din" is for, and
1642 the MIPs world that was being simulated, to be placed into the
1647 #endif /* WITH_TRACE_ANY_P */
1649 /*---------------------------------------------------------------------------*/
1650 /*-- simulator engine -------------------------------------------------------*/
1651 /*---------------------------------------------------------------------------*/
1654 ColdReset (SIM_DESC sd
)
1657 for (cpu_nr
= 0; cpu_nr
< sim_engine_nr_cpus (sd
); cpu_nr
++)
1659 sim_cpu
*cpu
= STATE_CPU (sd
, cpu_nr
);
1660 /* RESET: Fixed PC address: */
1661 PC
= (unsigned_word
) UNSIGNED64 (0xFFFFFFFFBFC00000);
1662 /* The reset vector address is in the unmapped, uncached memory space. */
1664 SR
&= ~(status_SR
| status_TS
| status_RP
);
1665 SR
|= (status_ERL
| status_BEV
);
1667 /* Cheat and allow access to the complete register set immediately */
1668 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
1669 && WITH_TARGET_WORD_BITSIZE
== 64)
1670 SR
|= status_FR
; /* 64bit registers */
1672 /* Ensure that any instructions with pending register updates are
1674 PENDING_INVALIDATE();
1676 /* Initialise the FPU registers to the unknown state */
1677 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
1680 for (rn
= 0; (rn
< 32); rn
++)
1681 FPR_STATE
[rn
] = fmt_uninterpreted
;
1684 /* Initialise the Config0 register. */
1685 C0_CONFIG
= 0x80000000 /* Config1 present */
1686 | 2; /* KSEG0 uncached */
1687 if (WITH_TARGET_WORD_BITSIZE
== 64)
1689 /* FIXME Currently mips/sim-main.c:address_translation()
1690 truncates all addresses to 32-bits. */
1691 if (0 && WITH_TARGET_ADDRESS_BITSIZE
== 64)
1692 C0_CONFIG
|= (2 << 13); /* MIPS64, 64-bit addresses */
1694 C0_CONFIG
|= (1 << 13); /* MIPS64, 32-bit addresses */
1697 C0_CONFIG
|= 0x00008000; /* Big Endian */
1704 /* Description from page A-26 of the "MIPS IV Instruction Set" manual (revision 3.1) */
1705 /* Signal an exception condition. This will result in an exception
1706 that aborts the instruction. The instruction operation pseudocode
1707 will never see a return from this function call. */
1710 signal_exception (SIM_DESC sd
,
1718 sim_io_printf(sd
,"DBG: SignalException(%d) PC = 0x%s\n",exception
,pr_addr(cia
));
1721 /* Ensure that any active atomic read/modify/write operation will fail: */
1724 /* Save registers before interrupt dispatching */
1725 #ifdef SIM_CPU_EXCEPTION_TRIGGER
1726 SIM_CPU_EXCEPTION_TRIGGER(sd
, cpu
, cia
);
1729 switch (exception
) {
1731 case DebugBreakPoint
:
1732 if (! (Debug
& Debug_DM
))
1738 Debug
|= Debug_DBD
; /* signaled from within in delay slot */
1739 DEPC
= cia
- 4; /* reference the branch instruction */
1743 Debug
&= ~Debug_DBD
; /* not signaled from within a delay slot */
1747 Debug
|= Debug_DM
; /* in debugging mode */
1748 Debug
|= Debug_DBp
; /* raising a DBp exception */
1750 sim_engine_restart (SD
, CPU
, NULL
, NULL_CIA
);
1754 case ReservedInstruction
:
1757 unsigned int instruction
;
1758 va_start(ap
,exception
);
1759 instruction
= va_arg(ap
,unsigned int);
1761 /* Provide simple monitor support using ReservedInstruction
1762 exceptions. The following code simulates the fixed vector
1763 entry points into the IDT monitor by causing a simulator
1764 trap, performing the monitor operation, and returning to
1765 the address held in the $ra register (standard PCS return
1766 address). This means we only need to pre-load the vector
1767 space with suitable instruction values. For systems were
1768 actual trap instructions are used, we would not need to
1769 perform this magic. */
1770 if ((instruction
& RSVD_INSTRUCTION_MASK
) == RSVD_INSTRUCTION
)
1772 int reason
= (instruction
>> RSVD_INSTRUCTION_ARG_SHIFT
) & RSVD_INSTRUCTION_ARG_MASK
;
1773 if (!sim_monitor (SD
, CPU
, cia
, reason
))
1774 sim_io_error (sd
, "sim_monitor: unhandled reason = %d, pc = 0x%s\n", reason
, pr_addr (cia
));
1776 /* NOTE: This assumes that a branch-and-link style
1777 instruction was used to enter the vector (which is the
1778 case with the current IDT monitor). */
1779 sim_engine_restart (SD
, CPU
, NULL
, RA
);
1781 /* Look for the mips16 entry and exit instructions, and
1782 simulate a handler for them. */
1783 else if ((cia
& 1) != 0
1784 && (instruction
& 0xf81f) == 0xe809
1785 && (instruction
& 0x0c0) != 0x0c0)
1787 mips16_entry (SD
, CPU
, cia
, instruction
);
1788 sim_engine_restart (sd
, NULL
, NULL
, NULL_CIA
);
1790 /* else fall through to normal exception processing */
1791 sim_io_eprintf(sd
,"ReservedInstruction at PC = 0x%s\n", pr_addr (cia
));
1795 /* Store exception code into current exception id variable (used
1798 /* TODO: If not simulating exceptions then stop the simulator
1799 execution. At the moment we always stop the simulation. */
1801 #ifdef SUBTARGET_R3900
1802 /* update interrupt-related registers */
1804 /* insert exception code in bits 6:2 */
1805 CAUSE
= LSMASKED32(CAUSE
, 31, 7) | LSINSERTED32(exception
, 6, 2);
1806 /* shift IE/KU history bits left */
1807 SR
= LSMASKED32(SR
, 31, 4) | LSINSERTED32(LSEXTRACTED32(SR
, 3, 0), 5, 2);
1809 if (STATE
& simDELAYSLOT
)
1811 STATE
&= ~simDELAYSLOT
;
1813 EPC
= (cia
- 4); /* reference the branch instruction */
1818 if (SR
& status_BEV
)
1819 PC
= (signed)0xBFC00000 + 0x180;
1821 PC
= (signed)0x80000000 + 0x080;
1823 /* See figure 5-17 for an outline of the code below */
1824 if (! (SR
& status_EXL
))
1826 CAUSE
= (exception
<< 2);
1827 if (STATE
& simDELAYSLOT
)
1829 STATE
&= ~simDELAYSLOT
;
1831 EPC
= (cia
- 4); /* reference the branch instruction */
1835 /* FIXME: TLB et.al. */
1836 /* vector = 0x180; */
1840 CAUSE
= (exception
<< 2);
1841 /* vector = 0x180; */
1844 /* Store exception code into current exception id variable (used
1847 if (SR
& status_BEV
)
1848 PC
= (signed)0xBFC00200 + 0x180;
1850 PC
= (signed)0x80000000 + 0x180;
1853 switch ((CAUSE
>> 2) & 0x1F)
1856 /* Interrupts arrive during event processing, no need to
1862 #ifdef SUBTARGET_3900
1863 /* Exception vector: BEV=0 BFC00000 / BEF=1 BFC00000 */
1864 PC
= (signed)0xBFC00000;
1865 #endif /* SUBTARGET_3900 */
1868 case TLBModification
:
1873 case InstructionFetch
:
1875 /* The following is so that the simulator will continue from the
1876 exception handler address. */
1877 sim_engine_halt (SD
, CPU
, NULL
, PC
,
1878 sim_stopped
, SIM_SIGBUS
);
1880 case ReservedInstruction
:
1881 case CoProcessorUnusable
:
1883 sim_engine_halt (SD
, CPU
, NULL
, PC
,
1884 sim_stopped
, SIM_SIGILL
);
1886 case IntegerOverflow
:
1888 sim_engine_halt (SD
, CPU
, NULL
, PC
,
1889 sim_stopped
, SIM_SIGFPE
);
1892 sim_engine_halt (SD
, CPU
, NULL
, PC
, sim_stopped
, SIM_SIGTRAP
);
1897 sim_engine_restart (SD
, CPU
, NULL
, PC
);
1902 sim_engine_halt (SD
, CPU
, NULL
, PC
,
1903 sim_stopped
, SIM_SIGTRAP
);
1905 default: /* Unknown internal exception */
1907 sim_engine_halt (SD
, CPU
, NULL
, PC
,
1908 sim_stopped
, SIM_SIGABRT
);
1912 case SimulatorFault
:
1916 va_start(ap
,exception
);
1917 msg
= va_arg(ap
,char *);
1919 sim_engine_abort (SD
, CPU
, NULL_CIA
,
1920 "FATAL: Simulator error \"%s\"\n",msg
);
1929 /* This function implements what the MIPS32 and MIPS64 ISAs define as
1930 "UNPREDICTABLE" behaviour.
1932 About UNPREDICTABLE behaviour they say: "UNPREDICTABLE results
1933 may vary from processor implementation to processor implementation,
1934 instruction to instruction, or as a function of time on the same
1935 implementation or instruction. Software can never depend on results
1936 that are UNPREDICTABLE. ..." (MIPS64 Architecture for Programmers
1937 Volume II, The MIPS64 Instruction Set. MIPS Document MD00087 revision
1940 For UNPREDICTABLE behaviour, we print a message, if possible print
1941 the offending instructions mips.igen instruction name (provided by
1942 the caller), and stop the simulator.
1944 XXX FIXME: eventually, stopping the simulator should be made conditional
1945 on a command-line option. */
1947 unpredictable_action(sim_cpu
*cpu
, address_word cia
)
1949 SIM_DESC sd
= CPU_STATE(cpu
);
1951 sim_io_eprintf(sd
, "UNPREDICTABLE: PC = 0x%s\n", pr_addr (cia
));
1952 sim_engine_halt (SD
, CPU
, NULL
, cia
, sim_stopped
, SIM_SIGABRT
);
1956 /*-- co-processor support routines ------------------------------------------*/
1959 CoProcPresent(unsigned int coproc_number
)
1961 /* Return TRUE if simulator provides a model for the given co-processor number */
1966 cop_lw (SIM_DESC sd
,
1971 unsigned int memword
)
1976 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
1979 printf("DBG: COP_LW: memword = 0x%08X (uword64)memword = 0x%s\n",memword
,pr_addr(memword
));
1981 StoreFPR(coproc_reg
,fmt_uninterpreted_32
,(uword64
)memword
);
1986 #if 0 /* this should be controlled by a configuration option */
1987 sim_io_printf(sd
,"COP_LW(%d,%d,0x%08X) at PC = 0x%s : TODO (architecture specific)\n",coproc_num
,coproc_reg
,memword
,pr_addr(cia
));
1996 cop_ld (SIM_DESC sd
,
2005 printf("DBG: COP_LD: coproc_num = %d, coproc_reg = %d, value = 0x%s : PC = 0x%s\n", coproc_num
, coproc_reg
, pr_uword64(memword
), pr_addr(cia
) );
2008 switch (coproc_num
) {
2010 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
2012 StoreFPR(coproc_reg
,fmt_uninterpreted_64
,memword
);
2017 #if 0 /* this message should be controlled by a configuration option */
2018 sim_io_printf(sd
,"COP_LD(%d,%d,0x%s) at PC = 0x%s : TODO (architecture specific)\n",coproc_num
,coproc_reg
,pr_addr(memword
),pr_addr(cia
));
2030 cop_sw (SIM_DESC sd
,
2036 unsigned int value
= 0;
2041 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
2043 value
= (unsigned int)ValueFPR(coproc_reg
,fmt_uninterpreted_32
);
2048 #if 0 /* should be controlled by configuration option */
2049 sim_io_printf(sd
,"COP_SW(%d,%d) at PC = 0x%s : TODO (architecture specific)\n",coproc_num
,coproc_reg
,pr_addr(cia
));
2058 cop_sd (SIM_DESC sd
,
2068 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
2070 value
= ValueFPR(coproc_reg
,fmt_uninterpreted_64
);
2075 #if 0 /* should be controlled by configuration option */
2076 sim_io_printf(sd
,"COP_SD(%d,%d) at PC = 0x%s : TODO (architecture specific)\n",coproc_num
,coproc_reg
,pr_addr(cia
));
2088 decode_coproc (SIM_DESC sd
,
2091 unsigned int instruction
,
2100 case 0: /* standard CPU control and cache registers */
2102 /* R4000 Users Manual (second edition) lists the following CP0
2104 CODE><-RT><RD-><--TAIL--->
2105 DMFC0 Doubleword Move From CP0 (VR4100 = 01000000001tttttddddd00000000000)
2106 DMTC0 Doubleword Move To CP0 (VR4100 = 01000000101tttttddddd00000000000)
2107 MFC0 word Move From CP0 (VR4100 = 01000000000tttttddddd00000000000)
2108 MTC0 word Move To CP0 (VR4100 = 01000000100tttttddddd00000000000)
2109 TLBR Read Indexed TLB Entry (VR4100 = 01000010000000000000000000000001)
2110 TLBWI Write Indexed TLB Entry (VR4100 = 01000010000000000000000000000010)
2111 TLBWR Write Random TLB Entry (VR4100 = 01000010000000000000000000000110)
2112 TLBP Probe TLB for Matching Entry (VR4100 = 01000010000000000000000000001000)
2113 CACHE Cache operation (VR4100 = 101111bbbbbpppppiiiiiiiiiiiiiiii)
2114 ERET Exception return (VR4100 = 01000010000000000000000000011000)
2116 if (((op
== cp0_mfc0
) || (op
== cp0_mtc0
) /* MFC0 / MTC0 */
2117 || (op
== cp0_dmfc0
) || (op
== cp0_dmtc0
)) /* DMFC0 / DMTC0 */
2120 switch (rd
) /* NOTEs: Standard CP0 registers */
2122 /* 0 = Index R4000 VR4100 VR4300 */
2123 /* 1 = Random R4000 VR4100 VR4300 */
2124 /* 2 = EntryLo0 R4000 VR4100 VR4300 */
2125 /* 3 = EntryLo1 R4000 VR4100 VR4300 */
2126 /* 4 = Context R4000 VR4100 VR4300 */
2127 /* 5 = PageMask R4000 VR4100 VR4300 */
2128 /* 6 = Wired R4000 VR4100 VR4300 */
2129 /* 8 = BadVAddr R4000 VR4100 VR4300 */
2130 /* 9 = Count R4000 VR4100 VR4300 */
2131 /* 10 = EntryHi R4000 VR4100 VR4300 */
2132 /* 11 = Compare R4000 VR4100 VR4300 */
2133 /* 12 = SR R4000 VR4100 VR4300 */
2134 #ifdef SUBTARGET_R3900
2136 /* 3 = Config R3900 */
2138 /* 7 = Cache R3900 */
2140 /* 15 = PRID R3900 */
2146 /* 8 = BadVAddr R4000 VR4100 VR4300 */
2147 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2148 GPR
[rt
] = (signed_word
) (signed_address
) COP0_BADVADDR
;
2150 COP0_BADVADDR
= GPR
[rt
];
2153 #endif /* SUBTARGET_R3900 */
2155 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2160 /* 13 = Cause R4000 VR4100 VR4300 */
2162 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2167 /* 14 = EPC R4000 VR4100 VR4300 */
2169 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2170 GPR
[rt
] = (signed_word
) (signed_address
) EPC
;
2174 /* 15 = PRId R4000 VR4100 VR4300 */
2175 #ifdef SUBTARGET_R3900
2178 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2184 /* 16 = Config R4000 VR4100 VR4300 */
2186 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2187 GPR
[rt
] = C0_CONFIG
;
2189 /* only bottom three bits are writable */
2190 C0_CONFIG
= (C0_CONFIG
& ~0x7) | (GPR
[rt
] & 0x7);
2193 #ifdef SUBTARGET_R3900
2196 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2202 /* 17 = LLAddr R4000 VR4100 VR4300 */
2204 /* 18 = WatchLo R4000 VR4100 VR4300 */
2205 /* 19 = WatchHi R4000 VR4100 VR4300 */
2206 /* 20 = XContext R4000 VR4100 VR4300 */
2207 /* 26 = PErr or ECC R4000 VR4100 VR4300 */
2208 /* 27 = CacheErr R4000 VR4100 */
2209 /* 28 = TagLo R4000 VR4100 VR4300 */
2210 /* 29 = TagHi R4000 VR4100 VR4300 */
2211 /* 30 = ErrorEPC R4000 VR4100 VR4300 */
2212 if (STATE_VERBOSE_P(SD
))
2214 "Warning: PC 0x%lx:interp.c decode_coproc DEADC0DE\n",
2215 (unsigned long)cia
);
2216 GPR
[rt
] = 0xDEADC0DE; /* CPR[0,rd] */
2217 /* CPR[0,rd] = GPR[rt]; */
2219 if (op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2220 GPR
[rt
] = (signed_word
) (signed32
) COP0_GPR
[rd
];
2222 COP0_GPR
[rd
] = GPR
[rt
];
2225 sim_io_printf(sd
,"Warning: MFC0 %d,%d ignored, PC=%08x (architecture specific)\n",rt
,rd
, (unsigned)cia
);
2227 sim_io_printf(sd
,"Warning: MTC0 %d,%d ignored, PC=%08x (architecture specific)\n",rt
,rd
, (unsigned)cia
);
2231 else if ((op
== cp0_mfc0
|| op
== cp0_dmfc0
)
2234 /* [D]MFC0 RT,C0_CONFIG,SEL */
2242 /* MIPS32 r/o Config1:
2245 /* MIPS16 implemented.
2246 XXX How to check configuration? */
2248 if (CURRENT_FLOATING_POINT
== HARD_FLOATING_POINT
)
2249 /* MDMX & FPU implemented */
2253 /* MIPS32 r/o Config2:
2258 /* MIPS32 r/o Config3:
2259 SmartMIPS implemented. */
2265 else if (op
== cp0_eret
&& sel
== 0x18)
2268 if (SR
& status_ERL
)
2270 /* Oops, not yet available */
2271 sim_io_printf(sd
,"Warning: ERET when SR[ERL] set not handled yet");
2281 else if (op
== cp0_rfe
&& sel
== 0x10)
2284 #ifdef SUBTARGET_R3900
2285 /* TX39: Copy IEp/KUp -> IEc/KUc, and IEo/KUo -> IEp/KUp */
2287 /* shift IE/KU history bits right */
2288 SR
= LSMASKED32(SR
, 31, 4) | LSINSERTED32(LSEXTRACTED32(SR
, 5, 2), 3, 0);
2290 /* TODO: CACHE register */
2291 #endif /* SUBTARGET_R3900 */
2293 else if (op
== cp0_deret
&& sel
== 0x1F)
2301 sim_io_eprintf(sd
,"Unrecognised COP0 instruction 0x%08X at PC = 0x%s : No handler present\n",instruction
,pr_addr(cia
));
2302 /* TODO: When executing an ERET or RFE instruction we should
2303 clear LLBIT, to ensure that any out-standing atomic
2304 read/modify/write sequence fails. */
2308 case 2: /* co-processor 2 */
2315 sim_io_eprintf(sd
, "COP2 instruction 0x%08X at PC = 0x%s : No handler present\n",
2316 instruction
,pr_addr(cia
));
2321 case 1: /* should not occur (FPU co-processor) */
2322 case 3: /* should not occur (FPU co-processor) */
2323 SignalException(ReservedInstruction
,instruction
);
2331 /* This code copied from gdb's utils.c. Would like to share this code,
2332 but don't know of a common place where both could get to it. */
2334 /* Temporary storage using circular buffer */
2340 static char buf
[NUMCELLS
][CELLSIZE
];
2342 if (++cell
>=NUMCELLS
) cell
=0;
2346 /* Print routines to handle variable size regs, etc */
2348 /* Eliminate warning from compiler on 32-bit systems */
2349 static int thirty_two
= 32;
2352 pr_addr (SIM_ADDR addr
)
2354 char *paddr_str
=get_cell();
2355 switch (sizeof(addr
))
2358 sprintf(paddr_str
,"%08lx%08lx",
2359 (unsigned long)(addr
>>thirty_two
),(unsigned long)(addr
&0xffffffff));
2362 sprintf(paddr_str
,"%08lx",(unsigned long)addr
);
2365 sprintf(paddr_str
,"%04x",(unsigned short)(addr
&0xffff));
2368 sprintf(paddr_str
,"%x",addr
);
2374 pr_uword64 (uword64 addr
)
2376 char *paddr_str
=get_cell();
2377 sprintf(paddr_str
,"%08lx%08lx",
2378 (unsigned long)(addr
>>thirty_two
),(unsigned long)(addr
&0xffffffff));
2384 mips_core_signal (SIM_DESC sd
,
2390 transfer_type transfer
,
2391 sim_core_signals sig
)
2393 const char *copy
= (transfer
== read_transfer
? "read" : "write");
2394 address_word ip
= CIA_ADDR (cia
);
2398 case sim_core_unmapped_signal
:
2399 sim_io_eprintf (sd
, "mips-core: %d byte %s to unmapped address 0x%lx at 0x%lx\n",
2401 (unsigned long) addr
, (unsigned long) ip
);
2402 COP0_BADVADDR
= addr
;
2403 SignalExceptionDataReference();
2406 case sim_core_unaligned_signal
:
2407 sim_io_eprintf (sd
, "mips-core: %d byte %s to unaligned address 0x%lx at 0x%lx\n",
2409 (unsigned long) addr
, (unsigned long) ip
);
2410 COP0_BADVADDR
= addr
;
2411 if(transfer
== read_transfer
)
2412 SignalExceptionAddressLoad();
2414 SignalExceptionAddressStore();
2418 sim_engine_abort (sd
, cpu
, cia
,
2419 "mips_core_signal - internal error - bad switch");
2425 mips_cpu_exception_trigger(SIM_DESC sd
, sim_cpu
* cpu
, address_word cia
)
2427 ASSERT(cpu
!= NULL
);
2429 if(cpu
->exc_suspended
> 0)
2430 sim_io_eprintf(sd
, "Warning, nested exception triggered (%d)\n", cpu
->exc_suspended
);
2433 memcpy(cpu
->exc_trigger_registers
, cpu
->registers
, sizeof(cpu
->exc_trigger_registers
));
2434 cpu
->exc_suspended
= 0;
2438 mips_cpu_exception_suspend(SIM_DESC sd
, sim_cpu
* cpu
, int exception
)
2440 ASSERT(cpu
!= NULL
);
2442 if(cpu
->exc_suspended
> 0)
2443 sim_io_eprintf(sd
, "Warning, nested exception signal (%d then %d)\n",
2444 cpu
->exc_suspended
, exception
);
2446 memcpy(cpu
->exc_suspend_registers
, cpu
->registers
, sizeof(cpu
->exc_suspend_registers
));
2447 memcpy(cpu
->registers
, cpu
->exc_trigger_registers
, sizeof(cpu
->registers
));
2448 cpu
->exc_suspended
= exception
;
2452 mips_cpu_exception_resume(SIM_DESC sd
, sim_cpu
* cpu
, int exception
)
2454 ASSERT(cpu
!= NULL
);
2456 if(exception
== 0 && cpu
->exc_suspended
> 0)
2458 /* warn not for breakpoints */
2459 if(cpu
->exc_suspended
!= sim_signal_to_host(sd
, SIM_SIGTRAP
))
2460 sim_io_eprintf(sd
, "Warning, resuming but ignoring pending exception signal (%d)\n",
2461 cpu
->exc_suspended
);
2463 else if(exception
!= 0 && cpu
->exc_suspended
> 0)
2465 if(exception
!= cpu
->exc_suspended
)
2466 sim_io_eprintf(sd
, "Warning, resuming with mismatched exception signal (%d vs %d)\n",
2467 cpu
->exc_suspended
, exception
);
2469 memcpy(cpu
->registers
, cpu
->exc_suspend_registers
, sizeof(cpu
->registers
));
2471 else if(exception
!= 0 && cpu
->exc_suspended
== 0)
2473 sim_io_eprintf(sd
, "Warning, ignoring spontanous exception signal (%d)\n", exception
);
2475 cpu
->exc_suspended
= 0;
2479 /*---------------------------------------------------------------------------*/
2480 /*> EOF interp.c <*/