/* run front end support for arm
- Copyright (C) 1995-2015 Free Software Foundation, Inc.
+ Copyright (C) 1995-2020 Free Software Foundation, Inc.
This file is part of ARM SIM.
#include "gdb/signals.h"
#include "libiberty.h"
#include "iwmmxt.h"
+#include "maverick.h"
/* TODO: This should get pulled from the SIM_DESC. */
host_callback *sim_callback;
print_insn (ARMword instr)
{
int size;
+ disassembler_ftype disassemble_fn;
opbuf[0] = 0;
info.application_data = & instr;
- size = print_insn_little_arm (0, & info);
+ disassemble_fn = disassembler (bfd_arch_arm, 0, 0, NULL);
+ size = disassemble_fn (0, & info);
fprintf (stderr, " %*s\n", size, opbuf);
}
-/* Cirrus DSP registers.
-
- We need to define these registers outside of maverick.c because
- maverick.c might not be linked in unless --target=arm9e-* in which
- case wrapper.c will not compile because it tries to access Cirrus
- registers. This should all go away once we get the Cirrus and ARM
- Coprocessor to coexist in armcopro.c-- aldyh. */
-
-struct maverick_regs
-{
- union
- {
- int i;
- float f;
- } upper;
-
- union
- {
- int i;
- float f;
- } lower;
-};
-
-union maverick_acc_regs
-{
- long double ld; /* Acc registers are 72-bits. */
-};
-
-struct maverick_regs DSPregs[16];
-union maverick_acc_regs DSPacc[4];
-ARMword DSPsc;
-
static void
init (void)
{
{
ARMul_EmulateInit ();
state = ARMul_NewState ();
- state->bigendSig = (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN ? HIGH : LOW);
+ state->bigendSig = (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? HIGH : LOW);
ARMul_MemoryInit (state, mem_size);
ARMul_OSInit (state);
state->verbose = 0;
}
}
-ARMword
-ARMul_Debug (ARMul_State * state ATTRIBUTE_UNUSED,
- ARMword pc ATTRIBUTE_UNUSED,
- ARMword instr ATTRIBUTE_UNUSED)
-{
- return 0;
-}
-
int
sim_write (SIM_DESC sd ATTRIBUTE_UNUSED,
SIM_ADDR addr,
SIM_RC
sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED,
struct bfd * abfd,
- char ** argv,
- char ** env)
+ char * const *argv,
+ char * const *env)
{
int argvlen = 0;
int mach;
- char **arg;
+ char * const *arg;
init ();
mach = 0;
}
+#ifdef MODET
+ if (abfd != NULL && (bfd_get_start_address (abfd) & 1))
+ SETT;
+#endif
+
switch (mach)
{
default:
break;
}
- if ( mach != bfd_mach_arm_3
- && mach != bfd_mach_arm_3M
- && mach != bfd_mach_arm_2
- && mach != bfd_mach_arm_2a)
- {
- /* Reset mode to ARM. A gdb user may rerun a program that had entered
- THUMB mode from the start and cause the ARM-mode startup code to be
- executed in THUMB mode. */
- ARMul_SetCPSR (state, SVC32MODE);
- }
-
memset (& info, 0, sizeof (info));
INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
info.read_memory_func = sim_dis_read;
}
}
-int
-sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
- int rn,
- unsigned char *memory,
- int length)
+static int
+arm_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
init ();
return length;
}
-int
-sim_fetch_register (SIM_DESC sd ATTRIBUTE_UNUSED,
- int rn,
- unsigned char *memory,
- int length)
+static int
+arm_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
ARMword regval;
int len = length;
len -= 4;
memory += 4;
regval = 0;
- }
+ }
return length;
}
trace = 1;
continue;
}
-
+
if (strcmp (ptr, "-z") == 0)
{
/* Remove this option from the argv array. */
trace_funcs = 1;
continue;
}
-
+
if (strcmp (ptr, "-d") == 0)
{
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
argv[arg] = argv[arg + 1];
argc --;
-
+
ptr = argv[i];
}
else
ptr += sizeof SWI_SWITCH;
swi_mask = 0;
-
+
while (* ptr)
{
int i;
- for (i = sizeof options / sizeof options[0]; i--;)
+ for (i = ARRAY_SIZE (options); i--;)
if (strncmp (ptr, options[i].swi_option,
strlen (options[i].swi_option)) == 0)
{
if (* ptr != 0)
fprintf (stderr, "Ignoring swi options: %s\n", ptr);
-
+
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
argv[arg] = argv[arg + 1];
static void
sim_target_parse_arg_array (char ** argv)
{
- int i;
+ sim_target_parse_command_line (countargv (argv), argv);
+}
- for (i = 0; argv[i]; i++)
- ;
+static sim_cia
+arm_pc_get (sim_cpu *cpu)
+{
+ return PC;
+}
- sim_target_parse_command_line (i, argv);
+static void
+arm_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+ ARMul_SetPC (state, pc);
}
static void
sim_open (SIM_OPEN_KIND kind,
host_callback *cb,
struct bfd *abfd,
- char **argv)
+ char * const *argv)
{
+ int i;
SIM_DESC sd = sim_state_alloc (kind, cb);
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
return 0;
}
- /* getopt will print the error message so we just have to exit if this fails.
- FIXME: Hmmm... in the case of gdb we need getopt to call
- print_filtered. */
+ /* The parser will print an error message for us, so we silently return. */
if (sim_parse_args (sd, argv) != SIM_RC_OK)
{
free_state (sd);
return 0;
}
+ /* CPU specific initialization. */
+ for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+ {
+ SIM_CPU *cpu = STATE_CPU (sd, i);
+
+ CPU_REG_FETCH (cpu) = arm_reg_fetch;
+ CPU_REG_STORE (cpu) = arm_reg_store;
+ CPU_PC_FETCH (cpu) = arm_pc_get;
+ CPU_PC_STORE (cpu) = arm_pc_set;
+ }
+
sim_callback = cb;
sim_target_parse_arg_array (argv);
"Missing argument to -m option\n");
return NULL;
}
-
}
}
return sd;
}
-void
-sim_close (SIM_DESC sd ATTRIBUTE_UNUSED,
- int quitting ATTRIBUTE_UNUSED)
-{
- /* Nothing to do. */
-}
-
void
sim_stop_reason (SIM_DESC sd ATTRIBUTE_UNUSED,
enum sim_stop *reason,