1 /* This file is part of the program psim.
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 /* endianness of the host/target:
28 If the build process is aware (at compile time) of the endianness
29 of the host/target it is able to eliminate slower generic endian
32 Possible values are 0 (unknown), LITTLE_ENDIAN, BIG_ENDIAN */
34 #ifndef WITH_HOST_BYTE_ORDER
35 #define WITH_HOST_BYTE_ORDER 0 /*unknown*/
38 #ifndef WITH_TARGET_BYTE_ORDER
39 #define WITH_TARGET_BYTE_ORDER 0 /*unknown*/
42 extern int current_host_byte_order;
43 #define CURRENT_HOST_BYTE_ORDER (WITH_HOST_BYTE_ORDER \
44 ? WITH_HOST_BYTE_ORDER \
45 : current_host_byte_order)
46 extern int current_target_byte_order;
47 #define CURRENT_TARGET_BYTE_ORDER (WITH_TARGET_BYTE_ORDER \
48 ? WITH_TARGET_BYTE_ORDER \
49 : current_target_byte_order)
52 /* PowerPC XOR endian.
54 In addition to the above, the simulator can support the PowerPC's
55 horrible XOR endian mode. This feature makes it possible to
56 control the endian mode of a processor using the MSR. */
58 #ifndef WITH_XOR_ENDIAN
59 #define WITH_XOR_ENDIAN 8
63 /* Intel host BSWAP support:
65 Whether to use bswap on the 486 and pentiums rather than the 386
66 sequence that uses xchgb/rorl/xchgb */
74 Sets a limit on the number of processors that can be simulated. If
75 WITH_SMP is set to zero (0), the simulator is restricted to
76 suporting only on processor (and as a consequence leaves the SMP
77 code out of the build process).
79 The actual number of processors is taken from the device
80 /options/smp@<nr-cpu> */
86 #define MAX_NR_PROCESSORS WITH_SMP
88 #define MAX_NR_PROCESSORS 1
92 /* Word size of host/target:
94 Set these according to your host and target requirements. At this
95 point in time, I've only compiled (not run) for a 64bit and never
96 built for a 64bit host. This will always remain a compile time
99 #ifndef WITH_TARGET_WORD_BITSIZE
100 #define WITH_TARGET_WORD_BITSIZE 32 /* compiled only */
103 #ifndef WITH_HOST_WORD_BITSIZE
104 #define WITH_HOST_WORD_BITSIZE 32 /* 64bit ready? */
108 /* Program environment:
110 Three environments are available - UEA (user), VEA (virtual) and
111 OEA (perating). The former two are environment that users would
112 expect to see (VEA includes things like coherency and the time
113 base) while OEA is what an operating system expects to see. By
114 setting these to specific values, the build process is able to
115 eliminate non relevent environment code
117 CURRENT_ENVIRONMENT specifies which of vea or oea is required for
118 the current runtime. */
120 #define USER_ENVIRONMENT 1
121 #define VIRTUAL_ENVIRONMENT 2
122 #define OPERATING_ENVIRONMENT 3
124 #ifndef WITH_ENVIRONMENT
125 #define WITH_ENVIRONMENT 0
128 extern int current_environment;
129 #define CURRENT_ENVIRONMENT (WITH_ENVIRONMENT \
131 : current_environment)
134 /* Optional VEA/OEA code:
136 The below, required for the OEA model may also be included in the
137 VEA model however, as far as I can tell only make things
141 /* Events. Devices modeling real H/W need to be able to efficiently
142 schedule things to do at known times in the future. The event
143 queue implements this. Unfortunatly this adds the need to check
144 for any events once each full instruction cycle. */
146 #define WITH_EVENTS (WITH_ENVIRONMENT != USER_ENVIRONMENT)
151 The PowerPC architecture includes the addition of both a time base
152 register and a decrement timer. Like events adds to the overhead
153 of of some instruction cycles. */
155 #ifndef WITH_TIME_BASE
156 #define WITH_TIME_BASE (WITH_ENVIRONMENT != USER_ENVIRONMENT)
160 /* Callback/Default Memory.
162 Core includes a builtin memory type (raw_memory) that is
163 implemented using an array. raw_memory does not require any
164 additional functions etc.
166 Callback memory is where the core calls a core device for the data
169 Default memory is an extenstion of this where for addresses that do
170 not map into either a callback or core memory range a default map
173 The OEA model uses callback memory for devices and default memory
176 The VEA model uses callback memory to capture `page faults'.
178 While it may be possible to eliminate callback/default memory (and
179 hence also eliminate an additional test per memory fetch) it
180 probably is not worth the effort.
182 BTW, while raw_memory could have been implemented as a callback,
183 profiling has shown that there is a biger win (at least for the
184 x86) in eliminating a function call for the most common
185 (raw_memory) case. */
187 #define WITH_CALLBACK_MEMORY 1
192 The PowerPC may or may not handle miss aligned transfers. An
193 implementation normally handles miss aligned transfers in big
194 endian mode but generates an exception in little endian mode.
196 This model. Instead allows both little and big endian modes to
197 either take exceptions or handle miss aligned transfers.
199 If 0 is specified then for big-endian mode miss alligned accesses
200 are permitted (NONSTRICT_ALIGNMENT) while in little-endian mode the
201 processor will fault on them (STRICT_ALIGNMENT). */
203 #define NONSTRICT_ALIGNMENT 1
204 #define STRICT_ALIGNMENT 2
206 #ifndef WITH_ALIGNMENT
207 #define WITH_ALIGNMENT 0
210 extern int current_alignment;
211 #define CURRENT_ALIGNMENT (WITH_ALIGNMENT \
216 /* Floating point suport:
218 Still under development. */
220 #define SOFT_FLOATING_POINT 1
221 #define HARD_FLOATING_POINT 2
223 #ifndef WITH_FLOATING_POINT
224 #define WITH_FLOATING_POINT HARD_FLOATING_POINT
226 extern int current_floating_point;
227 #define CURRENT_FLOATING_POINT (WITH_FLOATING_POINT \
228 ? WITH_FLOATING_POINT \
229 : current_floating_point)
234 Control the inclusion of debugging code. */
236 /* Include the tracing code. Disabling this eliminates all tracing
243 /* include code that checks assertions scattered through out the
247 #define WITH_ASSERT 1
250 /* Whether to check instructions for reserved bits being set */
252 #ifndef WITH_RESERVED_BITS
253 #define WITH_RESERVED_BITS 1
256 /* include monitoring code */
258 #define MONITOR_INSTRUCTION_ISSUE 1
259 #define MONITOR_LOAD_STORE_UNIT 2
261 #define WITH_MON (MONITOR_LOAD_STORE_UNIT \
262 | MONITOR_INSTRUCTION_ISSUE)
266 /* Include code that simulates function units to model particular
267 machines more closely and provide more detailed information about
268 optimization potential. */
270 #ifndef WITH_FUNCTION_UNIT
271 #define WITH_FUNCTION_UNIT 1
274 /* Which specific processor to model */
275 typedef enum _ppc_model {
288 #ifndef WITH_DEFAULT_PPC_MODEL
289 #define WITH_DEFAULT_PPC_MODEL PPC_MODEL_603e
292 extern ppc_model current_ppc_model;
294 #ifndef WITH_PPC_MODEL
295 #define WITH_PPC_MODEL 0
298 #define CURRENT_PPC_MODEL (WITH_PPC_MODEL \
302 /* Current CPU model (models are in the generated models.h include file) */
307 #define CURRENT_MODEL (WITH_MODEL \
311 #ifndef WITH_DEFAULT_MODEL
312 #define WITH_DEFAULT_MODEL DEFAULT_MODEL
315 /* INLINE CODE SELECTION:
317 GCC -O3 attempts to inline any function or procedure in scope. The
318 options below facilitate fine grained control over what is and what
319 isn't made inline. For instance it can control things down to a
320 specific modules static routines. This control is implemented in
321 two parts. Doing this allows the compiler to both eliminate the
322 overhead of function calls and (as a consequence) also eliminate
325 Experementing with CISC (x86) I've found that I can achieve an
326 order of magintude speed improvement (x3-x5). In the case of RISC
327 (sparc) while the performance gain isn't as great it is still
330 Part One - Static functions: It is possible to control how static
331 functions within each module are to be compiled. On a per module
332 or global basis, it is possible to specify that a modules static
333 functions should be compiled inline. This is controled by the the
334 macro's STATIC_INLINE and INLINE_STATIC_<module>.
336 Part Two - External functions: Again it is possible to allow the
337 inlining of calls to external functions. This is far more
338 complicated and much heaver on the compiler. In this case, it is
339 controled by the <module>_INLINE macro's. Where each can have a
342 0 Make a normal external call to functions in the module.
344 1 Include the module but to not inline functions within it.
345 This allows functions within the module to inline functions
346 from other modules that have been included.
348 2 Both include the module and inline functions contained within
351 Finally, this is not for the faint harted. I've seen GCC get up to
352 200mb trying to compile what this can create */
354 /* Your compilers inline reserved word */
357 #if defined(__GNUC__) && defined(__OPTIMIZE__) && \
358 (DEFAULT_INLINE || SIM_ENDIAN_INLINE || BITS_INLINE || CPU_INLINE || VM_INLINE || CORE_INLINE \
359 || EVENTS_INLINE || MON_INLINE || INTERRUPTS_INLINE || REGISTERS_INLINE || DEVICE_TREE_INLINE \
360 || DEVICES_INLINE || SPREG_INLINE || SEMANTICS_INLINE || IDECODE_INLINE || MODEL_INLINE \
361 || FUNCTION_UNIT_INLINE)
362 #define INLINE __inline__
364 #define INLINE /*inline*/
368 /* Default prefix for static functions */
370 #ifndef STATIC_INLINE
371 #define STATIC_INLINE static INLINE
374 /* Default macro to simplify control several of key the inlines */
376 #ifndef DEFAULT_INLINE
377 #define DEFAULT_INLINE 0
380 /* Code that converts between hosts and target byte order. Used on
381 every memory access (instruction and data). (See sim-endian.h for
382 additional byte swapping configuration information) */
384 #ifndef SIM_ENDIAN_INLINE
385 #define SIM_ENDIAN_INLINE DEFAULT_INLINE
388 /* Low level bit manipulation routines used to work around a compiler
392 #define BITS_INLINE DEFAULT_INLINE
395 /* Code that gives access to various CPU internals such as registers.
396 Used every time an instruction is executed */
399 #define CPU_INLINE DEFAULT_INLINE
402 /* Code that translates between an effective and real address. Used
403 by every load or store. */
406 #define VM_INLINE DEFAULT_INLINE
409 /* Code that loads/stores data to/from the memory data structure.
410 Used by every load or store */
413 #define CORE_INLINE DEFAULT_INLINE
416 /* Code to check for and process any events scheduled in the future.
417 Called once per instruction cycle */
419 #ifndef EVENTS_INLINE
420 #define EVENTS_INLINE DEFAULT_INLINE
423 /* Code monotoring the processors performance. It counts events on
424 every instruction cycle */
427 #define MON_INLINE DEFAULT_INLINE
430 /* Code called on the rare occasions that an interrupt occures. */
432 #ifndef INTERRUPTS_INLINE
433 #define INTERRUPTS_INLINE 0
436 /* Code called on the rare occasion that either gdb or the device tree
437 need to manipulate a register within a processor */
439 #ifndef REGISTERS_INLINE
440 #define REGISTERS_INLINE 0
443 /* Code called on the rare occasion that a processor is manipulating
444 real hardware instead of RAM.
446 Also, most of the functions in devices.c are always called through
449 There seems to be some problem with making either device_tree or
450 devices inline. It reports the message: device_tree_find_node()
453 #ifndef DEVICE_TREE_INLINE
454 #define DEVICE_TREE_INLINE 0
457 #ifndef DEVICES_INLINE
458 #define DEVICES_INLINE 0
461 /* Code called whenever information on a Special Purpose Register is
462 required. Called by the mflr/mtlr pseudo instructions */
465 #define SPREG_INLINE DEFAULT_INLINE
468 /* Functions modeling the semantics of each instruction. Two cases to
469 consider, firstly of idecode is implemented with a switch then this
470 allows the idecode function to inline each semantic function
471 (avoiding a call). The second case is when idecode is using a
472 table, even then while the semantic functions can't be inlined,
473 setting it to one still enables each semantic function to inline
474 anything they call (if that code is marked for being inlined).
476 WARNING: you need lots (like 200mb of swap) of swap. Setting this
477 to 1 is useful when using a table as it enables the sematic code to
478 inline all of their called functions */
480 #ifndef SEMANTICS_INLINE
481 #define SEMANTICS_INLINE (DEFAULT_INLINE ? 1 : 0)
484 /* Code to decode an instruction. Normally called on every instruction
487 #ifndef IDECODE_INLINE
488 #define IDECODE_INLINE DEFAULT_INLINE
491 /* Model specific code used in simulating functional units */
494 #define MODEL_INLINE DEFAULT_INLINE
497 /* Code to simulate functional units of real machines */
499 #ifndef FUNCTION_UNIT_INLINE
500 #define FUNCTION_UNIT_INLINE DEFAULT_INLINE
503 /* Code to print out what options we were compiled with. Because this
504 is called at process startup, it doesn't have to be inlined, but
505 if it isn't brought in and the model routines are inline, the model
506 routines will be pulled in twice. */
508 #ifndef OPTIONS_INLINE
509 #define OPTIONS_INLINE (DEFAULT_INLINE ? 1 : 0)
512 #endif /* _CONFIG_H */