1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, 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.
29 extern char **environ
;
36 printf_filtered(const char *msg
, ...)
44 error (char *msg
, ...)
55 void *memory
= malloc(size
);
57 error("zmalloc failed\n");
71 error ("Usage: psim [ -a -p -c -C -s -i -t ] <image> [ <image-args> ... ]\n");
75 main(int argc
, char **argv
)
78 const char *name_of_file
;
80 unsigned_word stack_pointer
;
85 /* check for arguments - FIXME use getopt */
86 while ((letter
= getopt (argc
, argv
, "acCipst")) != EOF
)
90 for (i
= 0; i
< nr_trace
; i
++)
94 trace
[trace_cpu
] = trace
[trace_semantics
] = 1;
97 trace
[trace_core
] = 1;
100 trace
[trace_console_device
] = 1;
103 trace
[trace_create_stack
] = 1;
106 trace
[trace_icu_device
] = 1;
109 trace
[trace_device_tree
] = 1;
118 name_of_file
= argv
[optind
];
120 /* create the simulator */
121 system
= psim_create(name_of_file
, ((WITH_SMP
> 0) ? WITH_SMP
: 1));
123 /* fudge the environment so that _=prog-name */
124 arg_
= (char*)zalloc(strlen(argv
[optind
]) + strlen("_=") + 1);
126 strcat(arg_
, argv
[optind
]);
131 psim_stack(system
, &argv
[optind
], environ
);
135 /* why did we stop */
136 status
= psim_get_status(system
);
137 switch (status
.reason
) {
139 error("psim: continuing while stoped!\n");
142 error("psim: no trap insn\n");
145 return status
.signal
;
147 return status
.signal
;
149 error("unknown halt condition\n");