1 /* run front end support for arm
2 Copyright (C) 1995, 1996, 1997, 2000, 2001, 2002, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
5 This file is part of ARM SIM.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* This file provides the interface between the simulator and
21 run.c and gdb (when the simulator is linked with gdb).
22 All simulator interaction should go through this file. */
29 #include "gdb/callback.h"
30 #include "gdb/remote-sim.h"
35 #include "sim-utils.h"
37 #include "gdb/sim-arm.h"
38 #include "gdb/signals.h"
40 host_callback
*sim_callback
;
42 static struct ARMul_State
*state
;
44 /* Who is using the simulator. */
45 static SIM_OPEN_KIND sim_kind
;
50 /* Memory size in bytes. */
51 static int mem_size
= (1 << 21);
53 /* Non-zero to display start up banner, and maybe other things. */
56 /* Non-zero to set big endian mode. */
57 static int big_endian
;
61 /* Cirrus DSP registers.
63 We need to define these registers outside of maverick.c because
64 maverick.c might not be linked in unless --target=arm9e-* in which
65 case wrapper.c will not compile because it tries to access Cirrus
66 registers. This should all go away once we get the Cirrus and ARM
67 Coprocessor to coexist in armcopro.c-- aldyh. */
84 union maverick_acc_regs
86 long double ld
; /* Acc registers are 72-bits. */
89 struct maverick_regs DSPregs
[16];
90 union maverick_acc_regs DSPacc
[4];
100 ARMul_EmulateInit ();
101 state
= ARMul_NewState ();
102 state
->bigendSig
= (big_endian
? HIGH
: LOW
);
103 ARMul_MemoryInit (state
, mem_size
);
104 ARMul_OSInit (state
);
105 state
->verbose
= verbosity
;
110 /* Set verbosity level of simulator.
111 This is not intended to produce detailed tracing or debugging information.
113 /* FIXME: common/run.c doesn't do this yet. */
122 /* Set the memory size to SIZE bytes.
123 Must be called before initializing simulator. */
124 /* FIXME: Rename to sim_set_mem_size. */
134 ARMul_ConsolePrint
VPARAMS ((ARMul_State
* state
,
142 va_start (ap
, format
);
143 vprintf (format
, ap
);
149 ARMul_Debug (state
, pc
, instr
)
150 ARMul_State
* state ATTRIBUTE_UNUSED
;
151 ARMword pc ATTRIBUTE_UNUSED
;
152 ARMword instr ATTRIBUTE_UNUSED
;
158 sim_write (sd
, addr
, buffer
, size
)
159 SIM_DESC sd ATTRIBUTE_UNUSED
;
161 const unsigned char * buffer
;
168 for (i
= 0; i
< size
; i
++)
169 ARMul_SafeWriteByte (state
, addr
+ i
, buffer
[i
]);
175 sim_read (sd
, addr
, buffer
, size
)
176 SIM_DESC sd ATTRIBUTE_UNUSED
;
178 unsigned char * buffer
;
185 for (i
= 0; i
< size
; i
++)
186 buffer
[i
] = ARMul_SafeReadByte (state
, addr
+ i
);
193 SIM_DESC sd ATTRIBUTE_UNUSED
;
195 (*sim_callback
->printf_filtered
)
197 "This simulator does not support tracing\n");
203 SIM_DESC sd ATTRIBUTE_UNUSED
;
205 state
->Emulate
= STOP
;
211 sim_resume (sd
, step
, siggnal
)
212 SIM_DESC sd ATTRIBUTE_UNUSED
;
214 int siggnal ATTRIBUTE_UNUSED
;
216 state
->EndCondition
= 0;
221 state
->Reg
[15] = ARMul_DoInstr (state
);
222 if (state
->EndCondition
== 0)
223 state
->EndCondition
= RDIError_BreakpointReached
;
227 state
->NextInstr
= RESUME
; /* treat as PC change */
228 state
->Reg
[15] = ARMul_DoProg (state
);
235 sim_create_inferior (sd
, abfd
, argv
, env
)
236 SIM_DESC sd ATTRIBUTE_UNUSED
;
246 ARMul_SetPC (state
, bfd_get_start_address (abfd
));
248 ARMul_SetPC (state
, 0); /* ??? */
250 mach
= bfd_get_mach (abfd
);
255 (*sim_callback
->printf_filtered
)
257 "Unknown machine type '%d'; please update sim_create_inferior.\n",
262 /* We wouldn't set the machine type with earlier toolchains, so we
263 explicitly select a processor capable of supporting all ARMs in
265 /* We choose the XScale rather than the iWMMXt, because the iWMMXt
266 removes the FPE emulator, since it conflicts with its coprocessors.
267 For the most generic ARM support, we want the FPE emulator in place. */
268 case bfd_mach_arm_XScale
:
269 ARMul_SelectProcessor (state
, ARM_v5_Prop
| ARM_v5e_Prop
| ARM_XScale_Prop
| ARM_v6_Prop
);
272 case bfd_mach_arm_iWMMXt
:
274 extern int SWI_vector_installed
;
277 if (! SWI_vector_installed
)
279 /* Intialise the hardware vectors to zero. */
280 if (! SWI_vector_installed
)
281 for (i
= ARMul_ResetV
; i
<= ARMFIQV
; i
+= 4)
282 ARMul_WriteWord (state
, i
, 0);
284 /* ARM_WriteWord will have detected the write to the SWI vector,
285 but we want SWI_vector_installed to remain at 0 so that thumb
286 mode breakpoints will work. */
287 SWI_vector_installed
= 0;
290 ARMul_SelectProcessor (state
, ARM_v5_Prop
| ARM_v5e_Prop
| ARM_XScale_Prop
| ARM_iWMMXt_Prop
);
293 case bfd_mach_arm_ep9312
:
294 ARMul_SelectProcessor (state
, ARM_v4_Prop
| ARM_ep9312_Prop
);
298 if (bfd_family_coff (abfd
))
300 /* This is a special case in order to support COFF based ARM toolchains.
301 The COFF header does not have enough room to store all the different
302 kinds of ARM cpu, so the XScale, v5T and v5TE architectures all default
303 to v5. (See coff_set_flags() in bdf/coffcode.h). So if we see a v5
304 machine type here, we assume it could be any of the above architectures
305 and so select the most feature-full. */
306 ARMul_SelectProcessor (state
, ARM_v5_Prop
| ARM_v5e_Prop
| ARM_XScale_Prop
);
309 /* Otherwise drop through. */
311 case bfd_mach_arm_5T
:
312 ARMul_SelectProcessor (state
, ARM_v5_Prop
);
315 case bfd_mach_arm_5TE
:
316 ARMul_SelectProcessor (state
, ARM_v5_Prop
| ARM_v5e_Prop
);
320 case bfd_mach_arm_4T
:
321 ARMul_SelectProcessor (state
, ARM_v4_Prop
);
325 case bfd_mach_arm_3M
:
326 ARMul_SelectProcessor (state
, ARM_Lock_Prop
);
330 case bfd_mach_arm_2a
:
331 ARMul_SelectProcessor (state
, ARM_Fix26_Prop
);
335 if ( mach
!= bfd_mach_arm_3
336 && mach
!= bfd_mach_arm_3M
337 && mach
!= bfd_mach_arm_2
338 && mach
!= bfd_mach_arm_2a
)
340 /* Reset mode to ARM. A gdb user may rerun a program that had entered
341 THUMB mode from the start and cause the ARM-mode startup code to be
342 executed in THUMB mode. */
343 ARMul_SetCPSR (state
, SVC32MODE
);
348 /* Set up the command line by laboriously stringing together
349 the environment carefully picked apart by our caller. */
351 /* Free any old stuff. */
352 if (state
->CommandLine
!= NULL
)
354 free (state
->CommandLine
);
355 state
->CommandLine
= NULL
;
358 /* See how much we need. */
359 for (arg
= argv
; *arg
!= NULL
; arg
++)
360 argvlen
+= strlen (*arg
) + 1;
363 state
->CommandLine
= malloc (argvlen
+ 1);
364 if (state
->CommandLine
!= NULL
)
367 state
->CommandLine
[0] = '\0';
369 for (arg
= argv
; *arg
!= NULL
; arg
++)
371 strcat (state
->CommandLine
, *arg
);
372 strcat (state
->CommandLine
, " ");
379 /* Now see if there's a MEMSIZE spec in the environment. */
382 if (strncmp (*env
, "MEMSIZE=", sizeof ("MEMSIZE=") - 1) == 0)
386 /* Set up memory limit. */
388 strtoul (*env
+ sizeof ("MEMSIZE=") - 1, &end_of_num
, 0);
398 sim_info (sd
, verbose
)
399 SIM_DESC sd ATTRIBUTE_UNUSED
;
400 int verbose ATTRIBUTE_UNUSED
;
405 frommem (state
, memory
)
406 struct ARMul_State
*state
;
407 unsigned char *memory
;
409 if (state
->bigendSig
== HIGH
)
410 return (memory
[0] << 24) | (memory
[1] << 16)
411 | (memory
[2] << 8) | (memory
[3] << 0);
413 return (memory
[3] << 24) | (memory
[2] << 16)
414 | (memory
[1] << 8) | (memory
[0] << 0);
418 tomem (state
, memory
, val
)
419 struct ARMul_State
*state
;
420 unsigned char *memory
;
423 if (state
->bigendSig
== HIGH
)
425 memory
[0] = val
>> 24;
426 memory
[1] = val
>> 16;
427 memory
[2] = val
>> 8;
428 memory
[3] = val
>> 0;
432 memory
[3] = val
>> 24;
433 memory
[2] = val
>> 16;
434 memory
[1] = val
>> 8;
435 memory
[0] = val
>> 0;
440 sim_store_register (sd
, rn
, memory
, length
)
441 SIM_DESC sd ATTRIBUTE_UNUSED
;
443 unsigned char *memory
;
444 int length ATTRIBUTE_UNUSED
;
448 switch ((enum sim_arm_regs
) rn
)
450 case SIM_ARM_R0_REGNUM
:
451 case SIM_ARM_R1_REGNUM
:
452 case SIM_ARM_R2_REGNUM
:
453 case SIM_ARM_R3_REGNUM
:
454 case SIM_ARM_R4_REGNUM
:
455 case SIM_ARM_R5_REGNUM
:
456 case SIM_ARM_R6_REGNUM
:
457 case SIM_ARM_R7_REGNUM
:
458 case SIM_ARM_R8_REGNUM
:
459 case SIM_ARM_R9_REGNUM
:
460 case SIM_ARM_R10_REGNUM
:
461 case SIM_ARM_R11_REGNUM
:
462 case SIM_ARM_R12_REGNUM
:
463 case SIM_ARM_R13_REGNUM
:
464 case SIM_ARM_R14_REGNUM
:
465 case SIM_ARM_R15_REGNUM
: /* PC */
466 case SIM_ARM_FP0_REGNUM
:
467 case SIM_ARM_FP1_REGNUM
:
468 case SIM_ARM_FP2_REGNUM
:
469 case SIM_ARM_FP3_REGNUM
:
470 case SIM_ARM_FP4_REGNUM
:
471 case SIM_ARM_FP5_REGNUM
:
472 case SIM_ARM_FP6_REGNUM
:
473 case SIM_ARM_FP7_REGNUM
:
474 case SIM_ARM_FPS_REGNUM
:
475 ARMul_SetReg (state
, state
->Mode
, rn
, frommem (state
, memory
));
478 case SIM_ARM_PS_REGNUM
:
479 state
->Cpsr
= frommem (state
, memory
);
480 ARMul_CPSRAltered (state
);
483 case SIM_ARM_MAVERIC_COP0R0_REGNUM
:
484 case SIM_ARM_MAVERIC_COP0R1_REGNUM
:
485 case SIM_ARM_MAVERIC_COP0R2_REGNUM
:
486 case SIM_ARM_MAVERIC_COP0R3_REGNUM
:
487 case SIM_ARM_MAVERIC_COP0R4_REGNUM
:
488 case SIM_ARM_MAVERIC_COP0R5_REGNUM
:
489 case SIM_ARM_MAVERIC_COP0R6_REGNUM
:
490 case SIM_ARM_MAVERIC_COP0R7_REGNUM
:
491 case SIM_ARM_MAVERIC_COP0R8_REGNUM
:
492 case SIM_ARM_MAVERIC_COP0R9_REGNUM
:
493 case SIM_ARM_MAVERIC_COP0R10_REGNUM
:
494 case SIM_ARM_MAVERIC_COP0R11_REGNUM
:
495 case SIM_ARM_MAVERIC_COP0R12_REGNUM
:
496 case SIM_ARM_MAVERIC_COP0R13_REGNUM
:
497 case SIM_ARM_MAVERIC_COP0R14_REGNUM
:
498 case SIM_ARM_MAVERIC_COP0R15_REGNUM
:
499 memcpy (& DSPregs
[rn
- SIM_ARM_MAVERIC_COP0R0_REGNUM
],
500 memory
, sizeof (struct maverick_regs
));
501 return sizeof (struct maverick_regs
);
503 case SIM_ARM_MAVERIC_DSPSC_REGNUM
:
504 memcpy (&DSPsc
, memory
, sizeof DSPsc
);
507 case SIM_ARM_IWMMXT_COP0R0_REGNUM
:
508 case SIM_ARM_IWMMXT_COP0R1_REGNUM
:
509 case SIM_ARM_IWMMXT_COP0R2_REGNUM
:
510 case SIM_ARM_IWMMXT_COP0R3_REGNUM
:
511 case SIM_ARM_IWMMXT_COP0R4_REGNUM
:
512 case SIM_ARM_IWMMXT_COP0R5_REGNUM
:
513 case SIM_ARM_IWMMXT_COP0R6_REGNUM
:
514 case SIM_ARM_IWMMXT_COP0R7_REGNUM
:
515 case SIM_ARM_IWMMXT_COP0R8_REGNUM
:
516 case SIM_ARM_IWMMXT_COP0R9_REGNUM
:
517 case SIM_ARM_IWMMXT_COP0R10_REGNUM
:
518 case SIM_ARM_IWMMXT_COP0R11_REGNUM
:
519 case SIM_ARM_IWMMXT_COP0R12_REGNUM
:
520 case SIM_ARM_IWMMXT_COP0R13_REGNUM
:
521 case SIM_ARM_IWMMXT_COP0R14_REGNUM
:
522 case SIM_ARM_IWMMXT_COP0R15_REGNUM
:
523 case SIM_ARM_IWMMXT_COP1R0_REGNUM
:
524 case SIM_ARM_IWMMXT_COP1R1_REGNUM
:
525 case SIM_ARM_IWMMXT_COP1R2_REGNUM
:
526 case SIM_ARM_IWMMXT_COP1R3_REGNUM
:
527 case SIM_ARM_IWMMXT_COP1R4_REGNUM
:
528 case SIM_ARM_IWMMXT_COP1R5_REGNUM
:
529 case SIM_ARM_IWMMXT_COP1R6_REGNUM
:
530 case SIM_ARM_IWMMXT_COP1R7_REGNUM
:
531 case SIM_ARM_IWMMXT_COP1R8_REGNUM
:
532 case SIM_ARM_IWMMXT_COP1R9_REGNUM
:
533 case SIM_ARM_IWMMXT_COP1R10_REGNUM
:
534 case SIM_ARM_IWMMXT_COP1R11_REGNUM
:
535 case SIM_ARM_IWMMXT_COP1R12_REGNUM
:
536 case SIM_ARM_IWMMXT_COP1R13_REGNUM
:
537 case SIM_ARM_IWMMXT_COP1R14_REGNUM
:
538 case SIM_ARM_IWMMXT_COP1R15_REGNUM
:
539 return Store_Iwmmxt_Register (rn
- SIM_ARM_IWMMXT_COP0R0_REGNUM
, memory
);
549 sim_fetch_register (sd
, rn
, memory
, length
)
550 SIM_DESC sd ATTRIBUTE_UNUSED
;
552 unsigned char *memory
;
553 int length ATTRIBUTE_UNUSED
;
559 switch ((enum sim_arm_regs
) rn
)
561 case SIM_ARM_R0_REGNUM
:
562 case SIM_ARM_R1_REGNUM
:
563 case SIM_ARM_R2_REGNUM
:
564 case SIM_ARM_R3_REGNUM
:
565 case SIM_ARM_R4_REGNUM
:
566 case SIM_ARM_R5_REGNUM
:
567 case SIM_ARM_R6_REGNUM
:
568 case SIM_ARM_R7_REGNUM
:
569 case SIM_ARM_R8_REGNUM
:
570 case SIM_ARM_R9_REGNUM
:
571 case SIM_ARM_R10_REGNUM
:
572 case SIM_ARM_R11_REGNUM
:
573 case SIM_ARM_R12_REGNUM
:
574 case SIM_ARM_R13_REGNUM
:
575 case SIM_ARM_R14_REGNUM
:
576 case SIM_ARM_R15_REGNUM
: /* PC */
577 regval
= ARMul_GetReg (state
, state
->Mode
, rn
);
580 case SIM_ARM_FP0_REGNUM
:
581 case SIM_ARM_FP1_REGNUM
:
582 case SIM_ARM_FP2_REGNUM
:
583 case SIM_ARM_FP3_REGNUM
:
584 case SIM_ARM_FP4_REGNUM
:
585 case SIM_ARM_FP5_REGNUM
:
586 case SIM_ARM_FP6_REGNUM
:
587 case SIM_ARM_FP7_REGNUM
:
588 case SIM_ARM_FPS_REGNUM
:
589 memset (memory
, 0, length
);
592 case SIM_ARM_PS_REGNUM
:
593 regval
= ARMul_GetCPSR (state
);
596 case SIM_ARM_MAVERIC_COP0R0_REGNUM
:
597 case SIM_ARM_MAVERIC_COP0R1_REGNUM
:
598 case SIM_ARM_MAVERIC_COP0R2_REGNUM
:
599 case SIM_ARM_MAVERIC_COP0R3_REGNUM
:
600 case SIM_ARM_MAVERIC_COP0R4_REGNUM
:
601 case SIM_ARM_MAVERIC_COP0R5_REGNUM
:
602 case SIM_ARM_MAVERIC_COP0R6_REGNUM
:
603 case SIM_ARM_MAVERIC_COP0R7_REGNUM
:
604 case SIM_ARM_MAVERIC_COP0R8_REGNUM
:
605 case SIM_ARM_MAVERIC_COP0R9_REGNUM
:
606 case SIM_ARM_MAVERIC_COP0R10_REGNUM
:
607 case SIM_ARM_MAVERIC_COP0R11_REGNUM
:
608 case SIM_ARM_MAVERIC_COP0R12_REGNUM
:
609 case SIM_ARM_MAVERIC_COP0R13_REGNUM
:
610 case SIM_ARM_MAVERIC_COP0R14_REGNUM
:
611 case SIM_ARM_MAVERIC_COP0R15_REGNUM
:
612 memcpy (memory
, & DSPregs
[rn
- SIM_ARM_MAVERIC_COP0R0_REGNUM
],
613 sizeof (struct maverick_regs
));
614 return sizeof (struct maverick_regs
);
616 case SIM_ARM_MAVERIC_DSPSC_REGNUM
:
617 memcpy (memory
, & DSPsc
, sizeof DSPsc
);
620 case SIM_ARM_IWMMXT_COP0R0_REGNUM
:
621 case SIM_ARM_IWMMXT_COP0R1_REGNUM
:
622 case SIM_ARM_IWMMXT_COP0R2_REGNUM
:
623 case SIM_ARM_IWMMXT_COP0R3_REGNUM
:
624 case SIM_ARM_IWMMXT_COP0R4_REGNUM
:
625 case SIM_ARM_IWMMXT_COP0R5_REGNUM
:
626 case SIM_ARM_IWMMXT_COP0R6_REGNUM
:
627 case SIM_ARM_IWMMXT_COP0R7_REGNUM
:
628 case SIM_ARM_IWMMXT_COP0R8_REGNUM
:
629 case SIM_ARM_IWMMXT_COP0R9_REGNUM
:
630 case SIM_ARM_IWMMXT_COP0R10_REGNUM
:
631 case SIM_ARM_IWMMXT_COP0R11_REGNUM
:
632 case SIM_ARM_IWMMXT_COP0R12_REGNUM
:
633 case SIM_ARM_IWMMXT_COP0R13_REGNUM
:
634 case SIM_ARM_IWMMXT_COP0R14_REGNUM
:
635 case SIM_ARM_IWMMXT_COP0R15_REGNUM
:
636 case SIM_ARM_IWMMXT_COP1R0_REGNUM
:
637 case SIM_ARM_IWMMXT_COP1R1_REGNUM
:
638 case SIM_ARM_IWMMXT_COP1R2_REGNUM
:
639 case SIM_ARM_IWMMXT_COP1R3_REGNUM
:
640 case SIM_ARM_IWMMXT_COP1R4_REGNUM
:
641 case SIM_ARM_IWMMXT_COP1R5_REGNUM
:
642 case SIM_ARM_IWMMXT_COP1R6_REGNUM
:
643 case SIM_ARM_IWMMXT_COP1R7_REGNUM
:
644 case SIM_ARM_IWMMXT_COP1R8_REGNUM
:
645 case SIM_ARM_IWMMXT_COP1R9_REGNUM
:
646 case SIM_ARM_IWMMXT_COP1R10_REGNUM
:
647 case SIM_ARM_IWMMXT_COP1R11_REGNUM
:
648 case SIM_ARM_IWMMXT_COP1R12_REGNUM
:
649 case SIM_ARM_IWMMXT_COP1R13_REGNUM
:
650 case SIM_ARM_IWMMXT_COP1R14_REGNUM
:
651 case SIM_ARM_IWMMXT_COP1R15_REGNUM
:
652 return Fetch_Iwmmxt_Register (rn
- SIM_ARM_IWMMXT_COP0R0_REGNUM
, memory
);
660 tomem (state
, memory
, regval
);
670 #ifdef SIM_TARGET_SWITCHES
672 static void sim_target_parse_arg_array
PARAMS ((char **));
677 unsigned int swi_mask
;
680 #define SWI_SWITCH "--swi-support"
682 static swi_options options
[] =
685 { "demon", SWI_MASK_DEMON
},
686 { "angel", SWI_MASK_ANGEL
},
687 { "redboot", SWI_MASK_REDBOOT
},
690 { "DEMON", SWI_MASK_DEMON
},
691 { "ANGEL", SWI_MASK_ANGEL
},
692 { "REDBOOT", SWI_MASK_REDBOOT
},
698 sim_target_parse_command_line (argc
, argv
)
704 for (i
= 1; i
< argc
; i
++)
706 char * ptr
= argv
[i
];
709 if ((ptr
== NULL
) || (* ptr
!= '-'))
712 if (strncmp (ptr
, SWI_SWITCH
, sizeof SWI_SWITCH
- 1) != 0)
715 if (ptr
[sizeof SWI_SWITCH
- 1] == 0)
717 /* Remove this option from the argv array. */
718 for (arg
= i
; arg
< argc
; arg
++)
719 argv
[arg
] = argv
[arg
+ 1];
725 ptr
+= sizeof SWI_SWITCH
;
733 for (i
= sizeof options
/ sizeof options
[0]; i
--;)
734 if (strncmp (ptr
, options
[i
].swi_option
,
735 strlen (options
[i
].swi_option
)) == 0)
737 swi_mask
|= options
[i
].swi_mask
;
738 ptr
+= strlen (options
[i
].swi_option
);
751 fprintf (stderr
, "Ignoring swi options: %s\n", ptr
);
753 /* Remove this option from the argv array. */
754 for (arg
= i
; arg
< argc
; arg
++)
755 argv
[arg
] = argv
[arg
+ 1];
763 sim_target_parse_arg_array (argv
)
768 for (i
= 0; argv
[i
]; i
++)
771 sim_target_parse_command_line (i
, argv
);
775 sim_target_display_usage (help
)
778 FILE *stream
= help
? stdout
: stderr
;
780 fprintf (stream
, "%s=<list> Comma seperated list of SWI protocols to supoport.\n\
781 This list can contain: NONE, DEMON, ANGEL, REDBOOT and/or ALL.\n",
787 sim_open (kind
, ptr
, abfd
, argv
)
794 if (myname
) free (myname
);
795 myname
= (char *) xstrdup (argv
[0]);
798 #ifdef SIM_TARGET_SWITCHES
799 sim_target_parse_arg_array (argv
);
802 /* Decide upon the endian-ness of the processor.
803 If we can, get the information from the bfd itself.
804 Otherwise look to see if we have been given a command
805 line switch that tells us. Otherwise default to little endian. */
807 big_endian
= bfd_big_endian (abfd
);
808 else if (argv
[1] != NULL
)
812 /* Scan for endian-ness and memory-size switches. */
813 for (i
= 0; (argv
[i
] != NULL
) && (argv
[i
][0] != 0); i
++)
814 if (argv
[i
][0] == '-' && argv
[i
][1] == 'E')
818 if ((c
= argv
[i
][2]) == 0)
827 sim_callback
->printf_filtered
828 (sim_callback
, "No argument to -E option provided\n");
842 sim_callback
->printf_filtered
843 (sim_callback
, "Unrecognised argument to -E option\n");
847 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'm')
849 if (argv
[i
][2] != '\0')
850 sim_size (atoi (&argv
[i
][2]));
851 else if (argv
[i
+ 1] != NULL
)
853 sim_size (atoi (argv
[i
+ 1]));
858 sim_callback
->printf_filtered (sim_callback
,
859 "Missing argument to -m option\n");
870 sim_close (sd
, quitting
)
871 SIM_DESC sd ATTRIBUTE_UNUSED
;
872 int quitting ATTRIBUTE_UNUSED
;
880 sim_load (sd
, prog
, abfd
, from_tty
)
884 int from_tty ATTRIBUTE_UNUSED
;
888 prog_bfd
= sim_load_file (sd
, myname
, sim_callback
, prog
, abfd
,
889 sim_kind
== SIM_OPEN_DEBUG
, 0, sim_write
);
890 if (prog_bfd
== NULL
)
892 ARMul_SetPC (state
, bfd_get_start_address (prog_bfd
));
894 bfd_close (prog_bfd
);
899 sim_stop_reason (sd
, reason
, sigrc
)
900 SIM_DESC sd ATTRIBUTE_UNUSED
;
901 enum sim_stop
*reason
;
906 *reason
= sim_stopped
;
907 *sigrc
= TARGET_SIGNAL_INT
;
909 else if (state
->EndCondition
== 0)
911 *reason
= sim_exited
;
912 *sigrc
= state
->Reg
[0] & 255;
916 *reason
= sim_stopped
;
917 if (state
->EndCondition
== RDIError_BreakpointReached
)
918 *sigrc
= TARGET_SIGNAL_TRAP
;
919 else if ( state
->EndCondition
== RDIError_DataAbort
920 || state
->EndCondition
== RDIError_AddressException
)
921 *sigrc
= TARGET_SIGNAL_BUS
;
928 sim_do_command (sd
, cmd
)
929 SIM_DESC sd ATTRIBUTE_UNUSED
;
930 char *cmd ATTRIBUTE_UNUSED
;
932 (*sim_callback
->printf_filtered
)
934 "This simulator does not accept any commands.\n");
938 sim_set_callbacks (ptr
)