Commit | Line | Data |
---|---|---|
ea6bbfba | 1 | /* front end to the simulator. |
a154eea7 | 2 | |
ea6bbfba SC |
3 | Written by Steve Chamberlain of Cygnus Support. |
4 | sac@cygnus.com | |
a154eea7 | 5 | |
ea6bbfba | 6 | This file is part of H8/300 sim |
a154eea7 | 7 | |
a154eea7 | 8 | |
ea6bbfba | 9 | THIS SOFTWARE IS NOT COPYRIGHTED |
a154eea7 | 10 | |
ea6bbfba SC |
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. | |
a154eea7 | 14 | |
ea6bbfba SC |
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. | |
18 | ||
19 | */ | |
a154eea7 | 20 | |
3a1d485d | 21 | #include <varargs.h> |
a415cf0a | 22 | #include <stdio.h> |
a154eea7 SC |
23 | #include "bfd.h" |
24 | #include "sysdep.h" | |
3a1d485d | 25 | #include "remote-sim.h" |
a154eea7 SC |
26 | |
27 | int | |
1cec8dae SC |
28 | main (ac, av) |
29 | int ac; | |
30 | char **av; | |
a154eea7 SC |
31 | { |
32 | bfd *abfd; | |
33 | bfd_vma start_address; | |
34 | asection *s; | |
35 | int i; | |
36 | int verbose = 0; | |
37 | int trace = 0; | |
38 | char *name = ""; | |
3a1d485d | 39 | |
a154eea7 | 40 | for (i = 1; i < ac; i++) |
a154eea7 | 41 | { |
ce38539a SC |
42 | if (strcmp(av[i],"-v") == 0) |
43 | verbose++; | |
44 | ||
45 | else if (strcmp(av[i],"-t") == 0) | |
1cec8dae SC |
46 | { |
47 | trace = 1; | |
48 | } | |
ce38539a | 49 | else if (strcmp(av[i],"-c") == 0) |
1cec8dae | 50 | { |
ce38539a SC |
51 | sim_csize(atoi(av[i+1])); |
52 | i++; | |
1cec8dae | 53 | } |
89a2c4fd | 54 | else if (strcmp(av[i],"-h") == 0) |
3a1d485d | 55 | set_h8300h (1); |
ce38539a | 56 | else |
1835992e DE |
57 | name = av[i]; |
58 | } | |
7ecaa5af | 59 | |
1835992e DE |
60 | if (verbose) |
61 | printf ("run %s\n", name); | |
ce38539a | 62 | |
cf5b4aa6 DE |
63 | abfd = bfd_openr (name, "coff-h8300"); |
64 | if (abfd) | |
65 | { | |
66 | if (bfd_check_format(abfd, bfd_object)) | |
ce38539a | 67 | { |
cf5b4aa6 | 68 | if (abfd->arch_info->mach == bfd_mach_h8300h) |
3a1d485d | 69 | set_h8300h (1); |
ce38539a | 70 | |
cf5b4aa6 DE |
71 | for (s = abfd->sections; s; s=s->next) |
72 | { | |
73 | char *buffer = malloc(bfd_section_size(abfd,s)); | |
74 | bfd_get_section_contents(abfd, s, buffer, 0, bfd_section_size(abfd,s)); | |
75 | sim_write(s->vma, buffer, bfd_section_size(abfd,s)); | |
ce38539a | 76 | } |
cf5b4aa6 DE |
77 | |
78 | start_address = bfd_get_start_address(abfd); | |
3a1d485d | 79 | sim_create_inferior (start_address, NULL, NULL); |
cf5b4aa6 DE |
80 | sim_resume(0,0); |
81 | if (verbose) | |
3a1d485d | 82 | sim_info (verbose - 1); |
cf5b4aa6 | 83 | return 0; |
1cec8dae | 84 | } |
cf5b4aa6 | 85 | } |
a154eea7 SC |
86 | |
87 | return 1; | |
88 | } | |
3a1d485d DE |
89 | |
90 | void | |
91 | printf_filtered (va_alist) | |
92 | va_dcl | |
93 | { | |
94 | char *msg; | |
95 | va_list args; | |
96 | ||
97 | va_start (args); | |
98 | msg = va_arg (args, char *); | |
99 | vfprintf (stdout, msg, args); | |
100 | va_end (args); | |
101 | } |