1 /* This file is part of the GNU simulators.
3 Copyright (C) 1994-1995,1997, 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.
26 int current_host_byte_order
;
27 int current_target_byte_order
;
30 #if defined (WITH_ENVIRONMENT)
31 int current_environment
;
34 #if defined (WITH_ALIGNMENT)
35 enum sim_alignments current_alignment
;
38 #if defined (WITH_FLOATING_POINT)
39 int current_floating_point
;
44 /* map a byte order onto a textual string */
47 config_byte_order_to_a (int byte_order
)
52 return "LITTLE_ENDIAN";
63 config_stdio_to_a (int stdio
)
68 return "DONT_USE_STDIO";
70 return "DO_USE_STDIO";
78 #if defined (WITH_ENVIRONMENT)
80 config_environment_to_a (int environment
)
84 case USER_ENVIRONMENT
:
85 return "USER_ENVIRONMENT";
86 case VIRTUAL_ENVIRONMENT
:
87 return "VIRTUAL_ENVIRONMENT";
88 case OPERATING_ENVIRONMENT
:
89 return "OPERATING_ENVIRONMENT";
99 config_alignment_to_a (int alignment
)
103 case MIXED_ALIGNMENT
:
104 return "MIXED_ALIGNMENT";
105 case NONSTRICT_ALIGNMENT
:
106 return "NONSTRICT_ALIGNMENT";
107 case STRICT_ALIGNMENT
:
108 return "STRICT_ALIGNMENT";
109 case FORCED_ALIGNMENT
:
110 return "FORCED_ALIGNMENT";
116 #if defined (WITH_FLOATING_POINT)
118 config_floating_point_to_a (int floating_point
)
120 switch (floating_point
)
122 case SOFT_FLOATING_POINT
:
123 return "SOFT_FLOATING_POINT";
124 case HARD_FLOATING_POINT
:
125 return "HARD_FLOATING_POINT";
135 sim_config (SIM_DESC sd
,
138 int prefered_target_byte_order
;
140 /* clone the bfd struct (or open prog_name directly) */
142 const char *prog_name
;
143 if (STATE_PROG_ARGV (sd
) == NULL
)
146 prog_name
= bfd_get_filename (abfd
);
151 prog_name
= *STATE_PROG_ARGV (sd
);
152 if (prog_name
!= NULL
)
154 abfd
= bfd_openr (prog_name
, 0);
157 sim_io_eprintf (sd
, "%s: can't open \"%s\": %s\n",
160 bfd_errmsg (bfd_get_error ()));
163 STATE_PROG_BFD (sd
) = abfd
;
166 STATE_PROG_BFD (sd
) = NULL
;
169 /* extract all relevant information */
171 prefered_target_byte_order
= 0;
173 prefered_target_byte_order
= (bfd_little_endian(abfd
)
177 /* set the host byte order */
178 current_host_byte_order
= 1;
179 if (*(char*)(¤t_host_byte_order
))
180 current_host_byte_order
= LITTLE_ENDIAN
;
182 current_host_byte_order
= BIG_ENDIAN
;
184 /* verify the host byte order */
185 if (CURRENT_HOST_BYTE_ORDER
!= current_host_byte_order
)
187 sim_io_eprintf (sd
, "host (%s) and configured (%s) byte order in conflict",
188 config_byte_order_to_a (current_host_byte_order
),
189 config_byte_order_to_a (CURRENT_HOST_BYTE_ORDER
));
194 /* set the target byte order */
196 if (current_target_byte_order
== 0)
197 current_target_byte_order
198 = (tree_find_boolean_property (root
, "/options/little-endian?")
202 if (current_target_byte_order
== 0
203 && prefered_target_byte_order
!= 0)
204 current_target_byte_order
= prefered_target_byte_order
;
205 if (current_target_byte_order
== 0)
206 current_target_byte_order
= WITH_TARGET_BYTE_ORDER
;
207 if (current_target_byte_order
== 0)
208 current_target_byte_order
= WITH_DEFAULT_TARGET_BYTE_ORDER
;
210 /* verify the target byte order */
211 if (CURRENT_TARGET_BYTE_ORDER
== 0)
213 sim_io_eprintf (sd
, "target byte order unspecified");
216 if (CURRENT_TARGET_BYTE_ORDER
!= current_target_byte_order
)
217 sim_io_eprintf (sd
, "target (%s) and configured (%s) byte order in conflict",
218 config_byte_order_to_a (current_target_byte_order
),
219 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
));
220 if (prefered_target_byte_order
!= 0
221 && CURRENT_TARGET_BYTE_ORDER
!= prefered_target_byte_order
)
222 sim_io_eprintf (sd
, "target (%s) and specified (%s) byte order in conflict",
223 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
),
224 config_byte_order_to_a (prefered_target_byte_order
));
228 if (current_stdio
== 0)
229 current_stdio
= WITH_STDIO
;
230 if (current_stdio
== 0)
231 current_stdio
= DO_USE_STDIO
;
233 /* verify the stdio */
234 if (CURRENT_STDIO
== 0)
236 sim_io_eprintf (sd
, "target standard IO unspecified");
239 if (CURRENT_STDIO
!= current_stdio
)
241 sim_io_eprintf (sd
, "target (%s) and configured (%s) standard IO in conflict",
242 config_stdio_to_a (CURRENT_STDIO
),
243 config_stdio_to_a (current_stdio
));
248 /* check the value of MSB */
249 if (WITH_TARGET_WORD_MSB
!= 0
250 && WITH_TARGET_WORD_MSB
!= (WITH_TARGET_WORD_BITSIZE
- 1))
252 sim_io_eprintf (sd
, "target bitsize (%d) contradicts target most significant bit (%d)",
253 WITH_TARGET_WORD_BITSIZE
, WITH_TARGET_WORD_MSB
);
258 #if defined (WITH_ENVIRONMENT)
260 /* set the environment */
262 if (current_environment
== 0)
265 tree_find_string_property(root
, "/openprom/options/env");
266 current_environment
= ((strcmp(env
, "user") == 0
267 || strcmp(env
, "uea") == 0)
269 : (strcmp(env
, "virtual") == 0
270 || strcmp(env
, "vea") == 0)
271 ? VIRTUAL_ENVIRONMENT
272 : (strcmp(env
, "operating") == 0
273 || strcmp(env
, "oea") == 0)
274 ? OPERATING_ENVIRONMENT
278 if (current_environment
== 0)
279 current_environment
= WITH_ENVIRONMENT
;
281 /* verify the environment */
282 if (CURRENT_ENVIRONMENT
== 0)
284 sim_io_eprintf (sd
, "target environment unspecified");
287 if (CURRENT_ENVIRONMENT
!= current_environment
)
289 sim_io_eprintf (sd
, "target (%s) and configured (%s) environment in conflict",
290 config_environment_to_a (CURRENT_ENVIRONMENT
),
291 config_environment_to_a (current_environment
));
297 #if defined (WITH_ALIGNMENT)
299 /* set the alignment */
300 #if defined (WITH_DEVICES)
301 if (current_alignment
== 0)
303 (tree_find_boolean_property(root
, "/openprom/options/strict-alignment?")
305 : NONSTRICT_ALIGNMENT
);
307 if (current_alignment
== 0)
308 current_alignment
= WITH_ALIGNMENT
;
310 /* verify the alignment */
311 if (CURRENT_ALIGNMENT
== 0)
313 sim_io_eprintf (sd
, "target alignment unspecified");
316 if (CURRENT_ALIGNMENT
!= current_alignment
)
318 sim_io_eprintf (sd
, "target (%s) and configured (%s) alignment in conflict",
319 config_alignment_to_a (CURRENT_ALIGNMENT
),
320 config_alignment_to_a (current_alignment
));
326 #if defined (WITH_FLOAING_POINT)
328 /* set the floating point */
329 if (current_floating_point
== 0)
330 current_floating_point
= WITH_FLOATING_POINT
;
332 /* verify the floating point */
333 if (CURRENT_FLOATING_POINT
== 0)
335 sim_io_eprintf (sd
, "target floating-point unspecified");
338 if (CURRENT_FLOATING_POINT
!= current_floating_point
)
340 sim_io_eprintf (sd
, "target (%s) and configured (%s) floating-point in conflict",
341 config_alignment_to_a (CURRENT_FLOATING_POINT
),
342 config_alignment_to_a (current_floating_point
));
352 print_sim_config (SIM_DESC sd
)
354 #if defined (__GNUC__) && defined (__VERSION__)
355 sim_io_printf (sd
, "Compiled by GCC %s on %s %s\n",
356 __VERSION__
, __DATE__
, __TIME__
);
358 sim_io_printf (sd
, "Compiled on %s %s\n", __DATE__
, __TIME__
);
361 sim_io_printf (sd
, "WITH_TARGET_BYTE_ORDER = %s\n",
362 config_byte_order_to_a (WITH_TARGET_BYTE_ORDER
));
364 sim_io_printf (sd
, "WITH_DEFAULT_TARGET_BYTE_ORDER = %s\n",
365 config_byte_order_to_a (WITH_DEFAULT_TARGET_BYTE_ORDER
));
367 sim_io_printf (sd
, "WITH_HOST_BYTE_ORDER = %s\n",
368 config_byte_order_to_a (WITH_HOST_BYTE_ORDER
));
370 sim_io_printf (sd
, "WITH_STDIO = %s\n",
371 config_stdio_to_a (WITH_STDIO
));
373 sim_io_printf (sd
, "WITH_TARGET_WORD_BITSIZE = %d\n",
374 WITH_TARGET_WORD_BITSIZE
);
376 sim_io_printf (sd
, "WITH_TARGET_WORD_MSB = %d\n",
377 WITH_TARGET_WORD_MSB
);
379 #if defined (WITH_XOR_ENDIAN)
380 sim_io_printf (sd
, "WITH_XOR_ENDIAN = %d\n", WITH_XOR_ENDIAN
);
383 #if defined (WITH_ENVIRONMENT)
384 sim_io_printf (sd
, "WITH_ENVIRONMENT = %s\n",
385 config_environment_to_a (WITH_ENVIRONMENT
));
388 #if defined (WITH_ALIGNMENT)
389 sim_io_printf (sd
, "WITH_ALIGNMENT = %s\n",
390 config_alignment_to_a (WITH_ALIGNMENT
));
393 #if defined (WITH_FLOATING_POINT)
394 sim_io_printf (sd
, "WITH_FLOATING_POINT = %s\n",
395 config_floating_point_to_a (WITH_FLOATING_POINT
));
398 #if defined (WITH_SMP)
399 sim_io_printf (sd
, "WITH_SMP = %d\n", WITH_SMP
);
402 #if defined (WITH_RESERVED_BITS)
403 sim_io_printf (sd
, "WITH_RESERVED_BITS = %d\n", WITH_RESERVED_BITS
);