std-config.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /* This file is part of the program psim.
  2. Copyright 1994, 1995, 2002 Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _PSIM_CONFIG_H_
  15. #define _PSIM_CONFIG_H_
  16. #include "bfd.h"
  17. /* endianness of the host/target:
  18. If the build process is aware (at compile time) of the endianness
  19. of the host/target it is able to eliminate slower generic endian
  20. handling code.
  21. Possible values are BFD_ENDIAN_UNKNOWN, BFD_ENDIAN_LITTLE,
  22. BFD_ENDIAN_BIG. */
  23. #ifdef WORDS_BIGENDIAN
  24. # define HOST_BYTE_ORDER BFD_ENDIAN_BIG
  25. #else
  26. # define HOST_BYTE_ORDER BFD_ENDIAN_LITTLE
  27. #endif
  28. #ifndef WITH_TARGET_BYTE_ORDER
  29. #define WITH_TARGET_BYTE_ORDER BFD_ENDIAN_UNKNOWN
  30. #endif
  31. extern enum bfd_endian current_target_byte_order;
  32. #define CURRENT_TARGET_BYTE_ORDER \
  33. (WITH_TARGET_BYTE_ORDER != BFD_ENDIAN_UNKNOWN \
  34. ? WITH_TARGET_BYTE_ORDER : current_target_byte_order)
  35. /* PowerPC XOR endian.
  36. In addition to the above, the simulator can support the PowerPC's
  37. horrible XOR endian mode. This feature makes it possible to
  38. control the endian mode of a processor using the MSR. */
  39. #ifndef WITH_XOR_ENDIAN
  40. #define WITH_XOR_ENDIAN 8
  41. #endif
  42. /* SMP support:
  43. Sets a limit on the number of processors that can be simulated. If
  44. WITH_SMP is set to zero (0), the simulator is restricted to
  45. suporting only on processor (and as a consequence leaves the SMP
  46. code out of the build process).
  47. The actual number of processors is taken from the device
  48. /options/smp@<nr-cpu> */
  49. #ifndef WITH_SMP
  50. #define WITH_SMP 5
  51. #endif
  52. #if WITH_SMP
  53. #define MAX_NR_PROCESSORS WITH_SMP
  54. #else
  55. #define MAX_NR_PROCESSORS 1
  56. #endif
  57. /* Word size of host/target:
  58. Set these according to your host and target requirements. At this
  59. point in time, I've only compiled (not run) for a 64bit and never
  60. built for a 64bit host. This will always remain a compile time
  61. option */
  62. #ifndef WITH_TARGET_WORD_BITSIZE
  63. #define WITH_TARGET_WORD_BITSIZE 32 /* compiled only */
  64. #endif
  65. #ifndef WITH_HOST_WORD_BITSIZE
  66. #define WITH_HOST_WORD_BITSIZE 32 /* 64bit ready? */
  67. #endif
  68. /* Program environment:
  69. Three environments are available - UEA (user), VEA (virtual) and
  70. OEA (perating). The former two are environment that users would
  71. expect to see (VEA includes things like coherency and the time
  72. base) while OEA is what an operating system expects to see. By
  73. setting these to specific values, the build process is able to
  74. eliminate non relevent environment code
  75. CURRENT_ENVIRONMENT specifies which of vea or oea is required for
  76. the current runtime. */
  77. #define ALL_ENVIRONMENT 0
  78. #define USER_ENVIRONMENT 1
  79. #define VIRTUAL_ENVIRONMENT 2
  80. #define OPERATING_ENVIRONMENT 3
  81. extern int current_environment;
  82. #define CURRENT_ENVIRONMENT (WITH_ENVIRONMENT \
  83. ? WITH_ENVIRONMENT \
  84. : current_environment)
  85. /* Optional VEA/OEA code:
  86. The below, required for the OEA model may also be included in the
  87. VEA model however, as far as I can tell only make things
  88. slower... */
  89. /* Events. Devices modeling real H/W need to be able to efficiently
  90. schedule things to do at known times in the future. The event
  91. queue implements this. Unfortunatly this adds the need to check
  92. for any events once each full instruction cycle. */
  93. #define WITH_EVENTS (WITH_ENVIRONMENT != USER_ENVIRONMENT)
  94. /* Time base:
  95. The PowerPC architecture includes the addition of both a time base
  96. register and a decrement timer. Like events adds to the overhead
  97. of of some instruction cycles. */
  98. #ifndef WITH_TIME_BASE
  99. #define WITH_TIME_BASE (WITH_ENVIRONMENT != USER_ENVIRONMENT)
  100. #endif
  101. /* Callback/Default Memory.
  102. Core includes a builtin memory type (raw_memory) that is
  103. implemented using an array. raw_memory does not require any
  104. additional functions etc.
  105. Callback memory is where the core calls a core device for the data
  106. it requires.
  107. Default memory is an extenstion of this where for addresses that do
  108. not map into either a callback or core memory range a default map
  109. can be used.
  110. The OEA model uses callback memory for devices and default memory
  111. for buses.
  112. The VEA model uses callback memory to capture `page faults'.
  113. While it may be possible to eliminate callback/default memory (and
  114. hence also eliminate an additional test per memory fetch) it
  115. probably is not worth the effort.
  116. BTW, while raw_memory could have been implemented as a callback,
  117. profiling has shown that there is a biger win (at least for the
  118. x86) in eliminating a function call for the most common
  119. (raw_memory) case. */
  120. #define WITH_CALLBACK_MEMORY 1
  121. /* Alignment:
  122. The PowerPC may or may not handle miss aligned transfers. An
  123. implementation normally handles miss aligned transfers in big
  124. endian mode but generates an exception in little endian mode.
  125. This model. Instead allows both little and big endian modes to
  126. either take exceptions or handle miss aligned transfers.
  127. If 0 is specified then for big-endian mode miss aligned accesses
  128. are permitted (NONSTRICT_ALIGNMENT) while in little-endian mode the
  129. processor will fault on them (STRICT_ALIGNMENT). */
  130. #define NONSTRICT_ALIGNMENT 1
  131. #define STRICT_ALIGNMENT 2
  132. #ifndef WITH_ALIGNMENT
  133. #define WITH_ALIGNMENT 0
  134. #endif
  135. extern int current_alignment;
  136. #define CURRENT_ALIGNMENT (WITH_ALIGNMENT \
  137. ? WITH_ALIGNMENT \
  138. : current_alignment)
  139. /* Floating point suport:
  140. Still under development. */
  141. #define SOFT_FLOATING_POINT 1
  142. #define HARD_FLOATING_POINT 2
  143. #ifndef WITH_FLOATING_POINT
  144. #define WITH_FLOATING_POINT HARD_FLOATING_POINT
  145. #endif
  146. extern int current_floating_point;
  147. #define CURRENT_FLOATING_POINT (WITH_FLOATING_POINT \
  148. ? WITH_FLOATING_POINT \
  149. : current_floating_point)
  150. /* Debugging:
  151. Control the inclusion of debugging code. */
  152. /* include monitoring code */
  153. #define MONITOR_INSTRUCTION_ISSUE 1
  154. #define MONITOR_LOAD_STORE_UNIT 2
  155. #ifndef WITH_MON
  156. #define WITH_MON (MONITOR_LOAD_STORE_UNIT \
  157. | MONITOR_INSTRUCTION_ISSUE)
  158. #endif
  159. /* Current CPU model (models are in the generated models.h include file) */
  160. #ifndef WITH_MODEL
  161. #define WITH_MODEL 0
  162. #endif
  163. #define CURRENT_MODEL (WITH_MODEL \
  164. ? WITH_MODEL \
  165. : current_model)
  166. #ifndef WITH_DEFAULT_MODEL
  167. #define WITH_DEFAULT_MODEL DEFAULT_MODEL
  168. #endif
  169. #define MODEL_ISSUE_IGNORE (-1)
  170. #define MODEL_ISSUE_PROCESS 1
  171. #ifndef WITH_MODEL_ISSUE
  172. #define WITH_MODEL_ISSUE 0
  173. #endif
  174. extern int current_model_issue;
  175. #define CURRENT_MODEL_ISSUE (WITH_MODEL_ISSUE \
  176. ? WITH_MODEL_ISSUE \
  177. : current_model_issue)
  178. /* Whether or not input/output just uses stdio, or uses printf_filtered for
  179. output, and polling input for input. */
  180. #define DONT_USE_STDIO 2
  181. #define DO_USE_STDIO 1
  182. extern int current_stdio;
  183. #define CURRENT_STDIO (WITH_STDIO \
  184. ? WITH_STDIO \
  185. : current_stdio)
  186. /* INLINE CODE SELECTION:
  187. GCC -O3 attempts to inline any function or procedure in scope. The
  188. options below facilitate fine grained control over what is and what
  189. isn't made inline. For instance it can control things down to a
  190. specific modules static routines. Doing this allows the compiler
  191. to both eliminate the overhead of function calls and (as a
  192. consequence) also eliminate further dead code.
  193. On a CISC (x86) I've found that I can achieve an order of magnitude
  194. speed improvement (x3-x5). In the case of RISC (sparc) while the
  195. performance gain isn't as great it is still significant.
  196. Each module is controled by the macro <module>_INLINE which can
  197. have the values described below
  198. 0 Do not inline any thing for the given module
  199. The following additional values are `bit fields' and can be
  200. combined.
  201. REVEAL_MODULE:
  202. Include the C file for the module into the file being compiled
  203. but do not make the functions within the module inline.
  204. While of no apparent benefit, this makes it possible for the
  205. included module, when compiled to inline its calls to what
  206. would otherwize be external functions.
  207. INLINE_MODULE:
  208. Make external functions within the module `inline'. Thus if
  209. the module is included into a file being compiled, calls to
  210. its funtions can be eliminated. 2 implies 1.
  211. INLINE_LOCALS:
  212. Make internal (static) functions within the module `inline'.
  213. The following abreviations are available:
  214. INCLUDE_MODULE == (REVEAL_MODULE | INLINE_MODULE)
  215. ALL_C_INLINE == (REVEAL_MODULE | INLINE_MODULE | INLINE_LOCALS)
  216. In addition to this, modules have been put into two categories.
  217. Simple modules - eg sim-endian.h bits.h
  218. Because these modules are small and simple and do not have
  219. any complex interpendencies they are configured, if
  220. <module>_INLINE is so enabled, to inline themselves in all
  221. modules that include those files.
  222. For the default build, this is a real win as all byte
  223. conversion and bit manipulation functions are inlined.
  224. Complex modules - the rest
  225. These are all handled using the files inline.h and inline.c.
  226. psim.c includes the above which in turn include any remaining
  227. code.
  228. IMPLEMENTATION:
  229. The inline ability is enabled by prefixing every data / function
  230. declaration and definition with one of the following:
  231. INLINE_<module>
  232. Prefix to any global function that is a candidate for being
  233. inline.
  234. values - `', `static', `static INLINE'
  235. EXTERN_<module>
  236. Prefix to any global data structures for the module. Global
  237. functions that are not to be inlined shall also be prefixed
  238. with this.
  239. values - `', `static', `static'
  240. STATIC_INLINE_<module>
  241. Prefix to any local (static) function that is a candidate for
  242. being made inline.
  243. values - `static', `static INLINE'
  244. static
  245. Prefix all local data structures. Local functions that are not
  246. to be inlined shall also be prefixed with this.
  247. values - `static', `static'
  248. nb: will not work for modules that are being inlined for every
  249. use (white lie).
  250. extern
  251. #ifndef _INLINE_C_
  252. #endif
  253. Prefix to any declaration of a global object (function or
  254. variable) that should not be inlined and should have only one
  255. definition. The #ifndef wrapper goes around the definition
  256. propper to ensure that only one copy is generated.
  257. nb: this will not work when a module is being inlined for every
  258. use.
  259. STATIC_<module>
  260. Replaced by either `static' or `EXTERN_MODULE'.
  261. REALITY CHECK:
  262. This is not for the faint hearted. I've seen GCC get up to 500mb
  263. trying to compile what this can create.
  264. Some of the modules do not yet implement the WITH_INLINE_STATIC
  265. option. Instead they use the macro STATIC_INLINE to control their
  266. local function.
  267. Because of the way that GCC parses __attribute__(), the macro's
  268. need to be adjacent to the function name rather than at the start
  269. of the line vis:
  270. int STATIC_INLINE_MODULE f(void);
  271. void INLINE_MODULE *g(void);
  272. */
  273. #include "../common/sim-inline.h"
  274. #define REVEAL_MODULE H_REVEALS_MODULE
  275. #define INLINE_MODULE C_REVEALS_MODULE
  276. #define INCLUDE_MODULE (INLINE_MODULE | REVEAL_MODULE)
  277. /* Your compilers inline reserved word */
  278. #ifndef INLINE
  279. #if defined(__GNUC__) && defined(__OPTIMIZE__)
  280. #define INLINE __inline__
  281. #else
  282. #define INLINE /*inline*/
  283. #endif
  284. #endif
  285. /* Default prefix for static functions */
  286. #ifndef STATIC_INLINE
  287. #define STATIC_INLINE static INLINE
  288. #endif
  289. /* Default macro to simplify control several of key the inlines */
  290. #ifndef DEFAULT_INLINE
  291. #define DEFAULT_INLINE INLINE_LOCALS
  292. #endif
  293. /* Code that converts between hosts and target byte order. Used on
  294. every memory access (instruction and data). See sim-endian.h for
  295. additional byte swapping configuration information. This module
  296. can inline for all callers */
  297. #ifndef SIM_ENDIAN_INLINE
  298. #define SIM_ENDIAN_INLINE (DEFAULT_INLINE ? ALL_C_INLINE : 0)
  299. #endif
  300. /* Low level bit manipulation routines. This module can inline for all
  301. callers */
  302. #ifndef BITS_INLINE
  303. #define BITS_INLINE (DEFAULT_INLINE ? ALL_C_INLINE : 0)
  304. #endif
  305. /* Code that gives access to various CPU internals such as registers.
  306. Used every time an instruction is executed */
  307. #ifndef CPU_INLINE
  308. #define CPU_INLINE (DEFAULT_INLINE ? ALL_C_INLINE : 0)
  309. #endif
  310. /* Code that translates between an effective and real address. Used
  311. by every load or store. */
  312. #ifndef VM_INLINE
  313. #define VM_INLINE DEFAULT_INLINE
  314. #endif
  315. /* Code that loads/stores data to/from the memory data structure.
  316. Used by every load or store */
  317. #ifndef CORE_INLINE
  318. #define CORE_INLINE DEFAULT_INLINE
  319. #endif
  320. /* Code to check for and process any events scheduled in the future.
  321. Called once per instruction cycle */
  322. #ifndef EVENTS_INLINE
  323. #define EVENTS_INLINE (DEFAULT_INLINE ? ALL_C_INLINE : 0)
  324. #endif
  325. /* Code monotoring the processors performance. It counts events on
  326. every instruction cycle */
  327. #ifndef MON_INLINE
  328. #define MON_INLINE (DEFAULT_INLINE ? ALL_C_INLINE : 0)
  329. #endif
  330. /* Code called on the rare occasions that an interrupt occures. */
  331. #ifndef INTERRUPTS_INLINE
  332. #define INTERRUPTS_INLINE DEFAULT_INLINE
  333. #endif
  334. /* Code called on the rare occasion that either gdb or the device tree
  335. need to manipulate a register within a processor */
  336. #ifndef REGISTERS_INLINE
  337. #define REGISTERS_INLINE DEFAULT_INLINE
  338. #endif
  339. /* Code called on the rare occasion that a processor is manipulating
  340. real hardware instead of RAM.
  341. Also, most of the functions in devices.c are always called through
  342. a jump table. */
  343. #ifndef DEVICE_INLINE
  344. #define DEVICE_INLINE (DEFAULT_INLINE ? INLINE_LOCALS : 0)
  345. #endif
  346. /* Code called used while the device tree is being built.
  347. Inlining this is of no benefit */
  348. #ifndef TREE_INLINE
  349. #define TREE_INLINE (DEFAULT_INLINE ? INLINE_LOCALS : 0)
  350. #endif
  351. /* Code called whenever information on a Special Purpose Register is
  352. required. Called by the mflr/mtlr pseudo instructions */
  353. #ifndef SPREG_INLINE
  354. #define SPREG_INLINE DEFAULT_INLINE
  355. #endif
  356. /* Functions modeling the semantics of each instruction. Two cases to
  357. consider, firstly of idecode is implemented with a switch then this
  358. allows the idecode function to inline each semantic function
  359. (avoiding a call). The second case is when idecode is using a
  360. table, even then while the semantic functions can't be inlined,
  361. setting it to one still enables each semantic function to inline
  362. anything they call (if that code is marked for being inlined).
  363. WARNING: you need lots (like 200mb of swap) of swap. Setting this
  364. to 1 is useful when using a table as it enables the sematic code to
  365. inline all of their called functions */
  366. #ifndef SEMANTICS_INLINE
  367. #define SEMANTICS_INLINE (DEFAULT_INLINE & ~INLINE_MODULE)
  368. #endif
  369. /* When using the instruction cache, code to decode an instruction and
  370. install it into the cache. Normally called when ever there is a
  371. miss in the instruction cache. */
  372. #ifndef ICACHE_INLINE
  373. #define ICACHE_INLINE (DEFAULT_INLINE & ~INLINE_MODULE)
  374. #endif
  375. /* General functions called by semantics functions but part of the
  376. instruction table. Although called by the semantic functions the
  377. frequency of calls is low. Consequently the need to inline this
  378. code is reduced. */
  379. #ifndef SUPPORT_INLINE
  380. #define SUPPORT_INLINE INLINE_LOCALS
  381. #endif
  382. /* Model specific code used in simulating functional units. Note, it actaully
  383. pays NOT to inline the PowerPC model functions (at least on the x86). This
  384. is because if it is inlined, each PowerPC instruction gets a separate copy
  385. of the code, which is not friendly to the cache. */
  386. #ifndef MODEL_INLINE
  387. #define MODEL_INLINE (DEFAULT_INLINE & ~INLINE_MODULE)
  388. #endif
  389. /* Code to print out what options we were compiled with. Because this
  390. is called at process startup, it doesn't have to be inlined, but
  391. if it isn't brought in and the model routines are inline, the model
  392. routines will be pulled in twice. */
  393. #ifndef OPTIONS_INLINE
  394. #define OPTIONS_INLINE MODEL_INLINE
  395. #endif
  396. /* idecode acts as the hub of the system, everything else is imported
  397. into this file */
  398. #ifndef IDECOCE_INLINE
  399. #define IDECODE_INLINE INLINE_LOCALS
  400. #endif
  401. /* psim, isn't actually inlined */
  402. #ifndef PSIM_INLINE
  403. #define PSIM_INLINE INLINE_LOCALS
  404. #endif
  405. /* Code to emulate os or rom compatibility. This code is called via a
  406. table and hence there is little benefit in making it inline */
  407. #ifndef OS_EMUL_INLINE
  408. #define OS_EMUL_INLINE 0
  409. #endif
  410. #endif /* _PSIM_CONFIG_H */