/* Simulator for the FT32 processor
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
Contributed by FTDI <support@ftdichip.com>
This file is part of simulators.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <stdint.h>
#include "bfd.h"
-#include "gdb/callback.h"
+#include "sim/callback.h"
#include "libiberty.h"
-#include "gdb/remote-sim.h"
+#include "sim/sim.h"
#include "sim-main.h"
#include "sim-options.h"
uint32_t bit_len;
uint32_t upper;
uint32_t insnpc;
+ unsigned int sc[2];
+ int isize;
- if (cpu->state.cycles >= cpu->state.next_tick_cycle)
- {
- cpu->state.next_tick_cycle += 100000;
- ft32_push (sd, cpu->state.pc);
- cpu->state.pc = 12; /* interrupt 1. */
- }
inst = ft32_read_item (sd, 2, cpu->state.pc);
cpu->state.cycles += 1;
+ if ((STATE_ARCHITECTURE (sd)->mach == bfd_mach_ft32b)
+ && ft32_decode_shortcode (cpu->state.pc, inst, sc))
+ {
+ if ((cpu->state.pc & 3) == 0)
+ inst = sc[0];
+ else
+ inst = sc[1];
+ isize = 2;
+ }
+ else
+ isize = 4;
+
/* Handle "call 8" (which is FT32's "break" equivalent) here. */
if (inst == 0x00340002)
{
upper = (inst >> 27);
insnpc = cpu->state.pc;
- cpu->state.pc += 4;
+ cpu->state.pc += isize;
switch (upper)
{
case FT32_PAT_TOC:
SIM_DESC sd = sim_state_alloc (kind, cb);
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
{
free_state (sd);
return 0;