1 /* This file is part of the program psim.
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include "device.h" /* FIXME: psim should provide the interface */
45 extern char **environ
;
48 printf_filtered(const char *msg
, ...)
63 error (char *msg
, ...)
75 void *memory
= malloc(size
);
77 error("zmalloc failed\n");
78 memset(memory
, 0, size
);
89 main(int argc
, char **argv
)
92 const char *name_of_file
;
95 device
*root
= psim_tree();
97 /* parse the arguments */
98 argv
= psim_options(root
, argv
+ 1);
101 name_of_file
= argv
[0];
103 if (ppc_trace
[trace_opts
])
106 /* create the simulator */
107 system
= psim_create(name_of_file
, root
);
109 /* fudge the environment so that _=prog-name */
110 arg_
= (char*)zalloc(strlen(argv
[0]) + strlen("_=") + 1);
112 strcat(arg_
, argv
[0]);
117 psim_stack(system
, argv
, environ
);
121 /* any final clean up */
122 if (ppc_trace
[trace_print_info
])
123 psim_print_info (system
, ppc_trace
[trace_print_info
]);
125 /* why did we stop */
126 status
= psim_get_status(system
);
127 switch (status
.reason
) {
129 error("psim: continuing while stoped!\n");
132 error("psim: no trap insn\n");
135 return status
.signal
;
137 printf ("%s: Caught signal %d at address 0x%lx\n",
138 name_of_file
, (int)status
.signal
,
139 (long)status
.program_counter
);
140 return status
.signal
;
142 error("unknown halt condition\n");
This page took 0.034466 seconds and 5 git commands to generate.