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.
22 #include "sim-state.h"
25 int current_host_byte_order
;
26 int current_target_byte_order
;
29 #if defined (WITH_ENVIRONMENT)
30 int current_environment
;
33 #if defined (WITH_ALIGNMENT)
34 int current_alignment
;
37 #if defined (WITH_FLOATING_POINT)
38 int current_floating_point
;
43 /* map a byte order onto a textual string */
46 config_byte_order_to_a (int byte_order
)
51 return "LITTLE_ENDIAN";
62 config_stdio_to_a (int stdio
)
67 return "DONT_USE_STDIO";
69 return "DO_USE_STDIO";
77 #if defined (WITH_ENVIRONMENT)
79 config_environment_to_a (int environment
)
83 case USER_ENVIRONMENT
:
84 return "USER_ENVIRONMENT";
85 case VIRTUAL_ENVIRONMENT
:
86 return "VIRTUAL_ENVIRONMENT";
87 case OPERATING_ENVIRONMENT
:
88 return "OPERATING_ENVIRONMENT";
97 #if defined (WITH_ALIGNMENT)
99 config_alignment_to_a (int alignment
)
103 case NONSTRICT_ALIGNMENT
:
104 return "NONSTRICT_ALIGNMENT";
105 case STRICT_ALIGNMENT
:
106 return "STRICT_ALIGNMENT";
115 #if defined (WITH_FLOATING_POINT)
117 config_floating_point_to_a (int floating_point
)
119 switch (floating_point
)
121 case SOFT_FLOATING_POINT
:
122 return "SOFT_FLOATING_POINT";
123 case HARD_FLOATING_POINT
:
124 return "HARD_FLOATING_POINT";
134 sim_config (SIM_DESC sd
,
135 int prefered_target_byte_order
)
138 /* set the host byte order */
139 current_host_byte_order
= 1;
140 if (*(char*)(¤t_host_byte_order
))
141 current_host_byte_order
= LITTLE_ENDIAN
;
143 current_host_byte_order
= BIG_ENDIAN
;
145 /* verify the host byte order */
146 if (CURRENT_HOST_BYTE_ORDER
!= current_host_byte_order
)
147 sim_io_error (sd
, "host (%s) and configured (%s) byte order in conflict",
148 config_byte_order_to_a (current_host_byte_order
),
149 config_byte_order_to_a (CURRENT_HOST_BYTE_ORDER
));
152 /* set the target byte order */
154 if (current_target_byte_order
== 0)
155 current_target_byte_order
156 = (tree_find_boolean_property(root
, "/options/little-endian?")
160 if (current_target_byte_order
== 0
161 && prefered_target_byte_order
!= 0)
162 current_target_byte_order
= prefered_target_byte_order
;
163 if (current_target_byte_order
== 0)
164 current_target_byte_order
= WITH_TARGET_BYTE_ORDER
;
166 /* verify the target byte order */
167 if (CURRENT_TARGET_BYTE_ORDER
== 0)
168 sim_io_error (sd
, "target byte order unspecified");
169 if (CURRENT_TARGET_BYTE_ORDER
!= current_target_byte_order
)
170 sim_io_error (sd
, "target (%s) and configured (%s) byte order in conflict",
171 config_byte_order_to_a (current_target_byte_order
),
172 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
));
173 if (prefered_target_byte_order
!= 0
174 && CURRENT_TARGET_BYTE_ORDER
!= prefered_target_byte_order
)
175 sim_io_error (sd
, "target (%s) and specified (%s) byte order in conflict",
176 config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER
),
177 config_byte_order_to_a (prefered_target_byte_order
));
181 if (current_stdio
== 0)
182 current_stdio
= WITH_STDIO
;
183 if (current_stdio
== 0)
184 current_stdio
= DO_USE_STDIO
;
186 /* verify the stdio */
187 if (CURRENT_STDIO
== 0)
188 sim_io_error (sd
, "target standard IO unspecified");
189 if (CURRENT_STDIO
!= current_stdio
)
190 sim_io_error (sd
, "target (%s) and configured (%s) standard IO in conflict",
191 config_stdio_to_a (CURRENT_STDIO
),
192 config_stdio_to_a (current_stdio
));
195 #if defined (WITH_ENVIRONMENT)
197 /* set the environment */
199 if (current_environment
== 0)
202 tree_find_string_property(root
, "/openprom/options/env");
203 current_environment
= ((strcmp(env
, "user") == 0
204 || strcmp(env
, "uea") == 0)
206 : (strcmp(env
, "virtual") == 0
207 || strcmp(env
, "vea") == 0)
208 ? VIRTUAL_ENVIRONMENT
209 : (strcmp(env
, "operating") == 0
210 || strcmp(env
, "oea") == 0)
211 ? OPERATING_ENVIRONMENT
215 if (current_environment
== 0)
216 current_environment
= WITH_ENVIRONMENT
;
218 /* verify the environment */
219 if (CURRENT_ENVIRONMENT
== 0)
220 sim_io_error (sd
, "target environment unspecified");
221 if (CURRENT_ENVIRONMENT
!= current_environment
)
222 sim_io_error (sd
, "target (%s) and configured (%s) environment in conflict",
223 config_environment_to_a (CURRENT_ENVIRONMENT
),
224 config_environment_to_a (current_environment
));
228 #if defined (WITH_ALIGNMENT)
230 /* set the alignment */
231 #if defined (WITH_DEVICES)
232 if (current_alignment
== 0)
234 (tree_find_boolean_property(root
, "/openprom/options/strict-alignment?")
236 : NONSTRICT_ALIGNMENT
);
238 if (current_alignment
== 0)
239 current_alignment
= WITH_ALIGNMENT
;
241 /* verify the alignment */
242 if (CURRENT_ALIGNMENT
== 0)
243 sim_io_error (sd
, "target alignment unspecified");
244 if (CURRENT_ALIGNMENT
!= current_alignment
)
245 sim_io_error (sd
, "target (%s) and configured (%s) alignment in conflict",
246 config_alignment_to_a (CURRENT_ALIGNMENT
),
247 config_alignment_to_a (current_alignment
));
251 #if defined (WITH_FLOAING_POINT)
253 /* set the floating point */
254 if (current_floating_point
== 0)
255 current_floating_point
= WITH_FLOATING_POINT
;
257 /* verify the floating point */
258 if (CURRENT_FLOATING_POINT
== 0)
259 sim_io_error (sd
, "target floating-point unspecified");
260 if (CURRENT_FLOATING_POINT
!= current_floating_point
)
261 sim_io_error (sd
, "target (%s) and configured (%s) floating-point in conflict",
262 config_alignment_to_a (CURRENT_FLOATING_POINT
),
263 config_alignment_to_a (current_floating_point
));
272 print_sim_config (SIM_DESC sd
)
274 #if defined (__GNUC__) && defined (__VERSION__)
275 sim_io_printf (sd
, "Compiled by GCC %s on %s %s\n",
276 __VERSION__
, __DATE__
, __TIME__
);
278 sim_io_printf (sd
, "Compiled on %s %s\n", __DATE__
, __TIME__
);
281 sim_io_printf (sd
, "WITH_TARGET_BYTE_ORDER = %s\n",
282 config_byte_order_to_a (WITH_TARGET_BYTE_ORDER
));
284 sim_io_printf (sd
, "WITH_HOST_BYTE_ORDER = %s\n",
285 config_byte_order_to_a (WITH_HOST_BYTE_ORDER
));
287 sim_io_printf (sd
, "WITH_STDIO = %s\n",
288 config_stdio_to_a (WITH_STDIO
));
290 #if defined (WITH_XOR_ENDIAN)
291 sim_io_printf (sd
, "WITH_XOR_ENDIAN = %d\n", WITH_XOR_ENDIAN
);
294 #if defined (WITH_ENVIRONMENT)
295 sim_io_printf (sd
, "WITH_ENVIRONMENT = %s\n",
296 config_environment_to_a (WITH_ENVIRONMENT
));
299 #if defined (WITH_ALIGNMENT)
300 sim_io_printf (sd
, "WITH_ALIGNMENT = %s\n",
301 config_alignment_to_a (WITH_ALIGNMENT
));
304 #if defined (WITH_FLOATING_POINT)
305 sim_io_printf (sd
, "WITH_FLOATING_POINT = %s\n",
306 config_floating_point_to_a (WITH_FLOATING_POINT
));
309 #if defined (WITH_SMP)
310 sim_io_printf (sd
, "WITH_SMP = %d\n", WITH_SMP
);
313 #if defined (WITH_RESERVED_BITS)
314 sim_io_printf (sd
, "WITH_RESERVED_BITS = %d\n", WITH_RESERVED_BITS
);