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 /* The currently selected environment.
32 This isn't used unless the choice is runtime selectable.
33 The proper way to determine the currently selected environment
34 is with the CURRENT_ENVIRONMENT macro.
35 This is set to ALL_ENVIRONMENT to indicate none has been selected yet. */
36 enum sim_environment current_environment
= ALL_ENVIRONMENT
;
38 enum sim_alignments current_alignment
;
40 #if defined (WITH_FLOATING_POINT)
41 int current_floating_point
;
46 /* map a byte order onto a textual string */
49 config_byte_order_to_a (int byte_order
)
54 return "LITTLE_ENDIAN";
65 config_stdio_to_a (int stdio
)
70 return "DONT_USE_STDIO";
72 return "DO_USE_STDIO";
81 config_environment_to_a (enum sim_environment environment
)
86 return "ALL_ENVIRONMENT";
87 case USER_ENVIRONMENT
:
88 return "USER_ENVIRONMENT";
89 case VIRTUAL_ENVIRONMENT
:
90 return "VIRTUAL_ENVIRONMENT";
91 case OPERATING_ENVIRONMENT
:
92 return "OPERATING_ENVIRONMENT";
99 config_alignment_to_a (enum sim_alignments 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
)
137 int prefered_target_byte_order
;
138 SIM_ASSERT (STATE_MAGIC (sd
) == SIM_MAGIC_NUMBER
);
140 /* extract all relevant information */
141 if (STATE_PROG_BFD (sd
) == NULL
)
142 prefered_target_byte_order
= 0;
144 prefered_target_byte_order
= (bfd_little_endian(STATE_PROG_BFD (sd
))
148 /* set the host byte order */
149 current_host_byte_order
= 1;
150 if (*(char*)(¤t_host_byte_order
))
151 current_host_byte_order
= LITTLE_ENDIAN
;
153 current_host_byte_order
= BIG_ENDIAN
;
155 /* verify the host byte order */
156 if (CURRENT_HOST_BYTE_ORDER
!= current_host_byte_order
)
158 sim_io_eprintf (sd
, "host (%s) and configured (%s) byte order in conflict",
159 config_byte_order_to_a (current_host_byte_order
),
160 config_byte_order_to_a (CURRENT_HOST_BYTE_ORDER
));
165 /* set the target byte order */
167 if (current_target_byte_order
== 0)
168 current_target_byte_order
169 = (tree_find_boolean_property (root
, "/options/little-endian?")
173 if (current_target_byte_order
== 0
174 && prefered_target_byte_order
!= 0)
175 current_target_byte_order
= prefered_target_byte_order
;
176 if (current_target_byte_order
== 0)
177 current_target_byte_order
= WITH_TARGET_BYTE_ORDER
;
178 if (current_target_byte_order
== 0)
179 current_target_byte_order
= WITH_DEFAULT_TARGET_BYTE_ORDER
;
181 /* verify the target byte order */
182 if (CURRENT_TARGET_BYTE_ORDER
== 0)
184 sim_io_eprintf (sd
, "Target byte order unspecified\n");
187 if (CURRENT_TARGET_BYTE_ORDER
!= current_target_byte_order
)
188 sim_io_eprintf (sd
, "Target (%s) and configured (%s) byte order in conflict\n",
189 config_byte_order_to_a (current_target_byte_order
),
190 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
));
191 if (prefered_target_byte_order
!= 0
192 && CURRENT_TARGET_BYTE_ORDER
!= prefered_target_byte_order
)
193 sim_io_eprintf (sd
, "Target (%s) and specified (%s) byte order in conflict\n",
194 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
),
195 config_byte_order_to_a (prefered_target_byte_order
));
199 if (current_stdio
== 0)
200 current_stdio
= WITH_STDIO
;
201 if (current_stdio
== 0)
202 current_stdio
= DO_USE_STDIO
;
204 /* verify the stdio */
205 if (CURRENT_STDIO
== 0)
207 sim_io_eprintf (sd
, "Target standard IO unspecified\n");
210 if (CURRENT_STDIO
!= current_stdio
)
212 sim_io_eprintf (sd
, "Target (%s) and configured (%s) standard IO in conflict\n",
213 config_stdio_to_a (CURRENT_STDIO
),
214 config_stdio_to_a (current_stdio
));
219 /* check the value of MSB */
220 if (WITH_TARGET_WORD_MSB
!= 0
221 && WITH_TARGET_WORD_MSB
!= (WITH_TARGET_WORD_BITSIZE
- 1))
223 sim_io_eprintf (sd
, "Target bitsize (%d) contradicts target most significant bit (%d)\n",
224 WITH_TARGET_WORD_BITSIZE
, WITH_TARGET_WORD_MSB
);
229 /* set the environment */
231 if (current_environment
== ALL_ENVIRONMENT
)
234 tree_find_string_property(root
, "/openprom/options/env");
235 current_environment
= ((strcmp(env
, "user") == 0
236 || strcmp(env
, "uea") == 0)
238 : (strcmp(env
, "virtual") == 0
239 || strcmp(env
, "vea") == 0)
240 ? VIRTUAL_ENVIRONMENT
241 : (strcmp(env
, "operating") == 0
242 || strcmp(env
, "oea") == 0)
243 ? OPERATING_ENVIRONMENT
247 if (current_environment
== ALL_ENVIRONMENT
)
248 current_environment
= DEFAULT_ENVIRONMENT
;
251 /* set the alignment */
252 #if defined (WITH_DEVICES)
253 if (current_alignment
== 0)
255 (tree_find_boolean_property(root
, "/openprom/options/strict-alignment?")
257 : NONSTRICT_ALIGNMENT
);
259 if (current_alignment
== 0)
260 current_alignment
= WITH_ALIGNMENT
;
261 if (current_alignment
== 0)
262 current_alignment
= WITH_DEFAULT_ALIGNMENT
;
264 /* verify the alignment */
265 if (CURRENT_ALIGNMENT
== 0)
267 sim_io_eprintf (sd
, "Target alignment unspecified\n");
270 if (CURRENT_ALIGNMENT
!= current_alignment
)
272 sim_io_eprintf (sd
, "Target (%s) and configured (%s) alignment in conflict\n",
273 config_alignment_to_a (CURRENT_ALIGNMENT
),
274 config_alignment_to_a (current_alignment
));
278 #if defined (WITH_FLOATING_POINT)
280 /* set the floating point */
281 if (current_floating_point
== 0)
282 current_floating_point
= WITH_FLOATING_POINT
;
284 /* verify the floating point */
285 if (CURRENT_FLOATING_POINT
== 0)
287 sim_io_eprintf (sd
, "Target floating-point unspecified\n");
290 if (CURRENT_FLOATING_POINT
!= current_floating_point
)
292 sim_io_eprintf (sd
, "Target (%s) and configured (%s) floating-point in conflict\n",
293 config_alignment_to_a (CURRENT_FLOATING_POINT
),
294 config_alignment_to_a (current_floating_point
));
304 print_sim_config (SIM_DESC sd
)
306 #if defined (__GNUC__) && defined (__VERSION__)
307 sim_io_printf (sd
, "Compiled by GCC %s on %s %s\n",
308 __VERSION__
, __DATE__
, __TIME__
);
310 sim_io_printf (sd
, "Compiled on %s %s\n", __DATE__
, __TIME__
);
313 sim_io_printf (sd
, "WITH_TARGET_BYTE_ORDER = %s\n",
314 config_byte_order_to_a (WITH_TARGET_BYTE_ORDER
));
316 sim_io_printf (sd
, "WITH_DEFAULT_TARGET_BYTE_ORDER = %s\n",
317 config_byte_order_to_a (WITH_DEFAULT_TARGET_BYTE_ORDER
));
319 sim_io_printf (sd
, "WITH_HOST_BYTE_ORDER = %s\n",
320 config_byte_order_to_a (WITH_HOST_BYTE_ORDER
));
322 sim_io_printf (sd
, "WITH_STDIO = %s\n",
323 config_stdio_to_a (WITH_STDIO
));
325 sim_io_printf (sd
, "WITH_TARGET_WORD_BITSIZE = %d\n",
326 WITH_TARGET_WORD_BITSIZE
);
328 sim_io_printf (sd
, "WITH_TARGET_WORD_MSB = %d\n",
329 WITH_TARGET_WORD_MSB
);
331 sim_io_printf (sd
, "WITH_ENVIRONMENT = %s\n",
332 config_environment_to_a (WITH_ENVIRONMENT
));
334 sim_io_printf (sd
, "WITH_ALIGNMENT = %s\n",
335 config_alignment_to_a (WITH_ALIGNMENT
));
337 #if defined (WITH_DEFAULT_ALIGNMENT)
338 sim_io_printf (sd
, "WITH_DEFAULT_ALIGNMENT = %s\n",
339 config_alignment_to_a (WITH_DEFAULT_ALIGNMENT
));
342 #if defined (WITH_XOR_ENDIAN)
343 sim_io_printf (sd
, "WITH_XOR_ENDIAN = %d\n", WITH_XOR_ENDIAN
);
346 #if defined (WITH_FLOATING_POINT)
347 sim_io_printf (sd
, "WITH_FLOATING_POINT = %s\n",
348 config_floating_point_to_a (WITH_FLOATING_POINT
));
351 #if defined (WITH_SMP)
352 sim_io_printf (sd
, "WITH_SMP = %d\n", WITH_SMP
);
355 #if defined (WITH_RESERVED_BITS)
356 sim_io_printf (sd
, "WITH_RESERVED_BITS = %d\n", WITH_RESERVED_BITS
);
359 #if defined (WITH_PROFILE)
360 sim_io_printf (sd
, "WITH_PROFILE = %d\n", WITH_PROFILE
);