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.
23 #include "sim-assert.h"
27 int current_host_byte_order
;
28 int current_target_byte_order
;
31 enum sim_alignments current_alignment
;
33 #if defined (WITH_FLOATING_POINT)
34 int current_floating_point
;
39 /* map a byte order onto a textual string */
42 config_byte_order_to_a (int byte_order
)
47 return "LITTLE_ENDIAN";
58 config_stdio_to_a (int stdio
)
63 return "DONT_USE_STDIO";
65 return "DO_USE_STDIO";
74 config_environment_to_a (enum sim_environment environment
)
79 return "ALL_ENVIRONMENT";
80 case USER_ENVIRONMENT
:
81 return "USER_ENVIRONMENT";
82 case VIRTUAL_ENVIRONMENT
:
83 return "VIRTUAL_ENVIRONMENT";
84 case OPERATING_ENVIRONMENT
:
85 return "OPERATING_ENVIRONMENT";
92 config_alignment_to_a (enum sim_alignments alignment
)
97 return "MIXED_ALIGNMENT";
98 case NONSTRICT_ALIGNMENT
:
99 return "NONSTRICT_ALIGNMENT";
100 case STRICT_ALIGNMENT
:
101 return "STRICT_ALIGNMENT";
102 case FORCED_ALIGNMENT
:
103 return "FORCED_ALIGNMENT";
109 #if defined (WITH_FLOATING_POINT)
111 config_floating_point_to_a (int floating_point
)
113 switch (floating_point
)
115 case SOFT_FLOATING_POINT
:
116 return "SOFT_FLOATING_POINT";
117 case HARD_FLOATING_POINT
:
118 return "HARD_FLOATING_POINT";
126 /* Set the default environment, prior to parsing argv. */
129 sim_config_default (SIM_DESC sd
)
131 /* Set the current environment to ALL_ENVIRONMENT to indicate none has been
132 selected yet. This is so that after parsing argv, we know whether the
133 environment was explicitly specified or not. */
134 STATE_ENVIRONMENT (sd
) = ALL_ENVIRONMENT
;
137 /* Complete and verify the simulation environment. */
140 sim_config (SIM_DESC sd
)
142 int prefered_target_byte_order
;
143 SIM_ASSERT (STATE_MAGIC (sd
) == SIM_MAGIC_NUMBER
);
145 /* extract all relevant information */
146 if (STATE_PROG_BFD (sd
) == NULL
)
147 prefered_target_byte_order
= 0;
149 prefered_target_byte_order
= (bfd_little_endian(STATE_PROG_BFD (sd
))
153 /* set the host byte order */
154 current_host_byte_order
= 1;
155 if (*(char*)(¤t_host_byte_order
))
156 current_host_byte_order
= LITTLE_ENDIAN
;
158 current_host_byte_order
= BIG_ENDIAN
;
160 /* verify the host byte order */
161 if (CURRENT_HOST_BYTE_ORDER
!= current_host_byte_order
)
163 sim_io_eprintf (sd
, "host (%s) and configured (%s) byte order in conflict",
164 config_byte_order_to_a (current_host_byte_order
),
165 config_byte_order_to_a (CURRENT_HOST_BYTE_ORDER
));
170 /* set the target byte order */
171 #if (WITH_TREE_PROPERTIES)
172 if (current_target_byte_order
== 0)
173 current_target_byte_order
174 = (tree_find_boolean_property (root
, "/options/little-endian?")
178 if (current_target_byte_order
== 0
179 && prefered_target_byte_order
!= 0)
180 current_target_byte_order
= prefered_target_byte_order
;
181 if (current_target_byte_order
== 0)
182 current_target_byte_order
= WITH_TARGET_BYTE_ORDER
;
183 if (current_target_byte_order
== 0)
184 current_target_byte_order
= WITH_DEFAULT_TARGET_BYTE_ORDER
;
186 /* verify the target byte order */
187 if (CURRENT_TARGET_BYTE_ORDER
== 0)
189 sim_io_eprintf (sd
, "Target byte order unspecified\n");
192 if (CURRENT_TARGET_BYTE_ORDER
!= current_target_byte_order
)
193 sim_io_eprintf (sd
, "Target (%s) and configured (%s) byte order in conflict\n",
194 config_byte_order_to_a (current_target_byte_order
),
195 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
));
196 if (prefered_target_byte_order
!= 0
197 && CURRENT_TARGET_BYTE_ORDER
!= prefered_target_byte_order
)
198 sim_io_eprintf (sd
, "Target (%s) and specified (%s) byte order in conflict\n",
199 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
),
200 config_byte_order_to_a (prefered_target_byte_order
));
204 if (current_stdio
== 0)
205 current_stdio
= WITH_STDIO
;
206 if (current_stdio
== 0)
207 current_stdio
= DO_USE_STDIO
;
209 /* verify the stdio */
210 if (CURRENT_STDIO
== 0)
212 sim_io_eprintf (sd
, "Target standard IO unspecified\n");
215 if (CURRENT_STDIO
!= current_stdio
)
217 sim_io_eprintf (sd
, "Target (%s) and configured (%s) standard IO in conflict\n",
218 config_stdio_to_a (CURRENT_STDIO
),
219 config_stdio_to_a (current_stdio
));
224 /* check the value of MSB */
225 if (WITH_TARGET_WORD_MSB
!= 0
226 && WITH_TARGET_WORD_MSB
!= (WITH_TARGET_WORD_BITSIZE
- 1))
228 sim_io_eprintf (sd
, "Target bitsize (%d) contradicts target most significant bit (%d)\n",
229 WITH_TARGET_WORD_BITSIZE
, WITH_TARGET_WORD_MSB
);
234 /* set the environment */
235 #if (WITH_TREE_PROPERTIES)
236 if (STATE_ENVIRONMENT (sd
) == ALL_ENVIRONMENT
)
239 tree_find_string_property(root
, "/openprom/options/env");
240 STATE_ENVIRONMENT (sd
) = ((strcmp(env
, "user") == 0
241 || strcmp(env
, "uea") == 0)
243 : (strcmp(env
, "virtual") == 0
244 || strcmp(env
, "vea") == 0)
245 ? VIRTUAL_ENVIRONMENT
246 : (strcmp(env
, "operating") == 0
247 || strcmp(env
, "oea") == 0)
248 ? OPERATING_ENVIRONMENT
252 if (STATE_ENVIRONMENT (sd
) == ALL_ENVIRONMENT
)
253 STATE_ENVIRONMENT (sd
) = DEFAULT_ENVIRONMENT
;
256 /* set the alignment */
257 #if (WITH_TREE_PROPERTIES)
258 if (current_alignment
== 0)
260 (tree_find_boolean_property(root
, "/openprom/options/strict-alignment?")
262 : NONSTRICT_ALIGNMENT
);
264 if (current_alignment
== 0)
265 current_alignment
= WITH_ALIGNMENT
;
266 if (current_alignment
== 0)
267 current_alignment
= WITH_DEFAULT_ALIGNMENT
;
269 /* verify the alignment */
270 if (CURRENT_ALIGNMENT
== 0)
272 sim_io_eprintf (sd
, "Target alignment unspecified\n");
275 if (CURRENT_ALIGNMENT
!= current_alignment
)
277 sim_io_eprintf (sd
, "Target (%s) and configured (%s) alignment in conflict\n",
278 config_alignment_to_a (CURRENT_ALIGNMENT
),
279 config_alignment_to_a (current_alignment
));
283 #if defined (WITH_FLOATING_POINT)
285 /* set the floating point */
286 if (current_floating_point
== 0)
287 current_floating_point
= WITH_FLOATING_POINT
;
289 /* verify the floating point */
290 if (CURRENT_FLOATING_POINT
== 0)
292 sim_io_eprintf (sd
, "Target floating-point unspecified\n");
295 if (CURRENT_FLOATING_POINT
!= current_floating_point
)
297 sim_io_eprintf (sd
, "Target (%s) and configured (%s) floating-point in conflict\n",
298 config_alignment_to_a (CURRENT_FLOATING_POINT
),
299 config_alignment_to_a (current_floating_point
));
309 print_sim_config (SIM_DESC sd
)
311 #if defined (__GNUC__) && defined (__VERSION__)
312 sim_io_printf (sd
, "Compiled by GCC %s on %s %s\n",
313 __VERSION__
, __DATE__
, __TIME__
);
315 sim_io_printf (sd
, "Compiled on %s %s\n", __DATE__
, __TIME__
);
318 sim_io_printf (sd
, "WITH_TARGET_BYTE_ORDER = %s\n",
319 config_byte_order_to_a (WITH_TARGET_BYTE_ORDER
));
321 sim_io_printf (sd
, "WITH_DEFAULT_TARGET_BYTE_ORDER = %s\n",
322 config_byte_order_to_a (WITH_DEFAULT_TARGET_BYTE_ORDER
));
324 sim_io_printf (sd
, "WITH_HOST_BYTE_ORDER = %s\n",
325 config_byte_order_to_a (WITH_HOST_BYTE_ORDER
));
327 sim_io_printf (sd
, "WITH_STDIO = %s\n",
328 config_stdio_to_a (WITH_STDIO
));
330 sim_io_printf (sd
, "WITH_TARGET_WORD_MSB = %d\n",
331 WITH_TARGET_WORD_MSB
);
333 sim_io_printf (sd
, "WITH_TARGET_WORD_BITSIZE = %d\n",
334 WITH_TARGET_WORD_BITSIZE
);
336 sim_io_printf (sd
, "WITH_TARGET_ADDRESS_BITSIZE = %d\n",
337 WITH_TARGET_ADDRESS_BITSIZE
);
339 sim_io_printf (sd
, "WITH_TARGET_CELL_BITSIZE = %d\n",
340 WITH_TARGET_CELL_BITSIZE
);
342 sim_io_printf (sd
, "WITH_TARGET_FLOATING_POINT_BITSIZE = %d\n",
343 WITH_TARGET_FLOATING_POINT_BITSIZE
);
345 sim_io_printf (sd
, "WITH_ENVIRONMENT = %s\n",
346 config_environment_to_a (WITH_ENVIRONMENT
));
348 sim_io_printf (sd
, "WITH_ALIGNMENT = %s\n",
349 config_alignment_to_a (WITH_ALIGNMENT
));
351 #if defined (WITH_DEFAULT_ALIGNMENT)
352 sim_io_printf (sd
, "WITH_DEFAULT_ALIGNMENT = %s\n",
353 config_alignment_to_a (WITH_DEFAULT_ALIGNMENT
));
356 #if defined (WITH_XOR_ENDIAN)
357 sim_io_printf (sd
, "WITH_XOR_ENDIAN = %d\n", WITH_XOR_ENDIAN
);
360 #if defined (WITH_FLOATING_POINT)
361 sim_io_printf (sd
, "WITH_FLOATING_POINT = %s\n",
362 config_floating_point_to_a (WITH_FLOATING_POINT
));
365 #if defined (WITH_SMP)
366 sim_io_printf (sd
, "WITH_SMP = %d\n", WITH_SMP
);
369 #if defined (WITH_RESERVED_BITS)
370 sim_io_printf (sd
, "WITH_RESERVED_BITS = %d\n", WITH_RESERVED_BITS
);
373 #if defined (WITH_PROFILE)
374 sim_io_printf (sd
, "WITH_PROFILE = %d\n", WITH_PROFILE
);