14e98e3e1Schristos /* The common simulator framework for GDB, the GNU Debugger. 24e98e3e1Schristos 3*88241920Schristos Copyright 2002-2024 Free Software Foundation, Inc. 44e98e3e1Schristos 54e98e3e1Schristos Contributed by Andrew Cagney and Red Hat. 64e98e3e1Schristos 74e98e3e1Schristos This file is part of GDB. 84e98e3e1Schristos 94e98e3e1Schristos This program is free software; you can redistribute it and/or modify 104e98e3e1Schristos it under the terms of the GNU General Public License as published by 114e98e3e1Schristos the Free Software Foundation; either version 3 of the License, or 124e98e3e1Schristos (at your option) any later version. 134e98e3e1Schristos 144e98e3e1Schristos This program is distributed in the hope that it will be useful, 154e98e3e1Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 164e98e3e1Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 174e98e3e1Schristos GNU General Public License for more details. 184e98e3e1Schristos 194e98e3e1Schristos You should have received a copy of the GNU General Public License 204e98e3e1Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 214e98e3e1Schristos 224e98e3e1Schristos 234e98e3e1Schristos #ifndef SIM_CONFIG_H 244e98e3e1Schristos #define SIM_CONFIG_H 254e98e3e1Schristos 264b169a6bSchristos #ifdef SIM_COMMON_BUILD 274b169a6bSchristos #error "This header is unusable in common builds due to reliance on SIM_AC_OPTION_BITSIZE" 284b169a6bSchristos #endif 294e98e3e1Schristos 304e98e3e1Schristos /* Host dependant: 314e98e3e1Schristos 324e98e3e1Schristos The CPP below defines information about the compilation host. In 334e98e3e1Schristos particular it defines the macro's: 344e98e3e1Schristos 35ba340e45Schristos HOST_BYTE_ORDER The byte order of the host. Could be BFD_ENDIAN_LITTLE 36ba340e45Schristos or BFD_ENDIAN_BIG. 374e98e3e1Schristos 384e98e3e1Schristos */ 394e98e3e1Schristos 40ba340e45Schristos #ifdef WORDS_BIGENDIAN 41ba340e45Schristos # define HOST_BYTE_ORDER BFD_ENDIAN_BIG 42ba340e45Schristos #else 43ba340e45Schristos # define HOST_BYTE_ORDER BFD_ENDIAN_LITTLE 444e98e3e1Schristos #endif 454e98e3e1Schristos 464e98e3e1Schristos 474e98e3e1Schristos /* Until devices and tree properties are sorted out, tell sim-config.c 484e98e3e1Schristos not to call the tree_find_foo fns. */ 494e98e3e1Schristos #define WITH_TREE_PROPERTIES 0 504e98e3e1Schristos 514e98e3e1Schristos 52ba340e45Schristos /* Endianness of the target. 534e98e3e1Schristos 54ba340e45Schristos Possible values are BFD_ENDIAN_UNKNOWN, BFD_ENDIAN_LITTLE, or BFD_ENDIAN_BIG. */ 554e98e3e1Schristos 56ba340e45Schristos extern enum bfd_endian current_target_byte_order; 57ba340e45Schristos #define CURRENT_TARGET_BYTE_ORDER \ 58ba340e45Schristos (WITH_TARGET_BYTE_ORDER != BFD_ENDIAN_UNKNOWN \ 59ba340e45Schristos ? WITH_TARGET_BYTE_ORDER : current_target_byte_order) 604e98e3e1Schristos 614e98e3e1Schristos 624e98e3e1Schristos 634e98e3e1Schristos /* XOR endian. 644e98e3e1Schristos 654e98e3e1Schristos In addition to the above, the simulator can support the horrible 664e98e3e1Schristos XOR endian mode (as found in the PowerPC and MIPS ISA). See 674e98e3e1Schristos sim-core for more information. 684e98e3e1Schristos 694e98e3e1Schristos If WITH_XOR_ENDIAN is non-zero, it specifies the number of bytes 704e98e3e1Schristos potentially involved in the XOR munge. A typical value is 8. */ 714e98e3e1Schristos 724e98e3e1Schristos #ifndef WITH_XOR_ENDIAN 734e98e3e1Schristos #define WITH_XOR_ENDIAN 0 744e98e3e1Schristos #endif 754e98e3e1Schristos 764e98e3e1Schristos 774e98e3e1Schristos 784e98e3e1Schristos /* SMP support: 794e98e3e1Schristos 804e98e3e1Schristos Sets a limit on the number of processors that can be simulated. If 814e98e3e1Schristos WITH_SMP is set to zero (0), the simulator is restricted to 824e98e3e1Schristos suporting only one processor (and as a consequence leaves the SMP 834e98e3e1Schristos code out of the build process). 844e98e3e1Schristos 854e98e3e1Schristos The actual number of processors is taken from the device 864e98e3e1Schristos /options/smp@<nr-cpu> */ 874e98e3e1Schristos 884e98e3e1Schristos #if defined (WITH_SMP) && (WITH_SMP > 0) 894e98e3e1Schristos #define MAX_NR_PROCESSORS WITH_SMP 904e98e3e1Schristos #endif 914e98e3e1Schristos 924e98e3e1Schristos #ifndef MAX_NR_PROCESSORS 934e98e3e1Schristos #define MAX_NR_PROCESSORS 1 944e98e3e1Schristos #endif 954e98e3e1Schristos 964e98e3e1Schristos 974e98e3e1Schristos /* Size of target word, address and OpenFirmware Cell: 984e98e3e1Schristos 994e98e3e1Schristos The target word size is determined by the natural size of its 1004e98e3e1Schristos reginsters. 1014e98e3e1Schristos 1024e98e3e1Schristos On most hosts, the address and cell are the same size as a target 1034e98e3e1Schristos word. */ 1044e98e3e1Schristos 1054e98e3e1Schristos #ifndef WITH_TARGET_WORD_BITSIZE 1064e98e3e1Schristos #define WITH_TARGET_WORD_BITSIZE 32 1074e98e3e1Schristos #endif 1084e98e3e1Schristos 1094e98e3e1Schristos #ifndef WITH_TARGET_ADDRESS_BITSIZE 1104e98e3e1Schristos #define WITH_TARGET_ADDRESS_BITSIZE WITH_TARGET_WORD_BITSIZE 1114e98e3e1Schristos #endif 1124e98e3e1Schristos 1134e98e3e1Schristos #ifndef WITH_TARGET_CELL_BITSIZE 1144e98e3e1Schristos #define WITH_TARGET_CELL_BITSIZE WITH_TARGET_WORD_BITSIZE 1154e98e3e1Schristos #endif 1164e98e3e1Schristos 1174e98e3e1Schristos #ifndef WITH_TARGET_FLOATING_POINT_BITSIZE 1184e98e3e1Schristos #define WITH_TARGET_FLOATING_POINT_BITSIZE 64 1194e98e3e1Schristos #endif 1204e98e3e1Schristos 1214e98e3e1Schristos 1224e98e3e1Schristos 1234e98e3e1Schristos /* Most significant bit of target: 1244e98e3e1Schristos 1254e98e3e1Schristos Set this according to your target's bit numbering convention. For 1264e98e3e1Schristos the PowerPC it is zero, for many other targets it is 31 or 63. 1274e98e3e1Schristos 1284e98e3e1Schristos For targets that can both have either 32 or 64 bit words and number 1294e98e3e1Schristos MSB as 31, 63. Define this to be (WITH_TARGET_WORD_BITSIZE - 1) */ 1304e98e3e1Schristos 1314e98e3e1Schristos #ifndef WITH_TARGET_WORD_MSB 1324e98e3e1Schristos #define WITH_TARGET_WORD_MSB 0 1334e98e3e1Schristos #endif 1344e98e3e1Schristos 1354e98e3e1Schristos 1364e98e3e1Schristos 1374e98e3e1Schristos /* Program environment: 1384e98e3e1Schristos 1394e98e3e1Schristos Three environments are available - UEA (user), VEA (virtual) and 1404e98e3e1Schristos OEA (perating). The former two are environment that users would 1414e98e3e1Schristos expect to see (VEA includes things like coherency and the time 1424e98e3e1Schristos base) while OEA is what an operating system expects to see. By 1434e98e3e1Schristos setting these to specific values, the build process is able to 1444e98e3e1Schristos eliminate non relevent environment code. 1454e98e3e1Schristos 1464e98e3e1Schristos STATE_ENVIRONMENT(sd) specifies which of vea or oea is required for 1474e98e3e1Schristos the current runtime. 1484e98e3e1Schristos 1494e98e3e1Schristos ALL_ENVIRONMENT is used during configuration as a value for 1504e98e3e1Schristos WITH_ENVIRONMENT to indicate the choice is runtime selectable. 1514e98e3e1Schristos The default is then USER_ENVIRONMENT [since allowing the user to choose 1524e98e3e1Schristos the default at configure time seems like featuritis and since people using 1534e98e3e1Schristos OPERATING_ENVIRONMENT have more to worry about than selecting the 1544e98e3e1Schristos default]. 1554e98e3e1Schristos ALL_ENVIRONMENT is also used to set STATE_ENVIRONMENT to the 1564e98e3e1Schristos "uninitialized" state. */ 1574e98e3e1Schristos 1584e98e3e1Schristos enum sim_environment { 1594e98e3e1Schristos ALL_ENVIRONMENT, 1604e98e3e1Schristos USER_ENVIRONMENT, 1614e98e3e1Schristos VIRTUAL_ENVIRONMENT, 1624e98e3e1Schristos OPERATING_ENVIRONMENT 1634e98e3e1Schristos }; 1644e98e3e1Schristos 1654e98e3e1Schristos /* To be prepended to simulator calls with absolute file paths and 1664e98e3e1Schristos chdir:ed at startup. */ 1674e98e3e1Schristos extern char *simulator_sysroot; 1684e98e3e1Schristos 1694e98e3e1Schristos /* Callback & Modulo Memory. 1704e98e3e1Schristos 1714e98e3e1Schristos Core includes a builtin memory type (raw_memory) that is 1724e98e3e1Schristos implemented using an array. raw_memory does not require any 1734e98e3e1Schristos additional functions etc. 1744e98e3e1Schristos 1754e98e3e1Schristos Callback memory is where the core calls a core device for the data 1764e98e3e1Schristos it requires. Callback memory can be layered using priorities. 1774e98e3e1Schristos 1784e98e3e1Schristos Modulo memory is a variation on raw_memory where ADDRESS & (MODULO 1794e98e3e1Schristos - 1) is used as the index into the memory array. 1804e98e3e1Schristos 1814e98e3e1Schristos The OEA model uses callback memory for devices. 1824e98e3e1Schristos 1834e98e3e1Schristos The VEA model uses callback memory to capture `page faults'. 1844e98e3e1Schristos 1854e98e3e1Schristos BTW, while raw_memory could have been implemented as a callback, 1864e98e3e1Schristos profiling has shown that there is a biger win (at least for the 1874e98e3e1Schristos x86) in eliminating a function call for the most common 1884e98e3e1Schristos (raw_memory) case. */ 1894e98e3e1Schristos 1904e98e3e1Schristos 1914e98e3e1Schristos /* Alignment: 1924e98e3e1Schristos 1934b169a6bSchristos A processor architecture may or may not handle misaligned 1944e98e3e1Schristos transfers. 1954e98e3e1Schristos 1964e98e3e1Schristos As alternatives: both little and big endian modes take an exception 1974e98e3e1Schristos (STRICT_ALIGNMENT); big and little endian models handle misaligned 1984e98e3e1Schristos transfers (NONSTRICT_ALIGNMENT); or the address is forced into 1994e98e3e1Schristos alignment using a mask (FORCED_ALIGNMENT). 2004e98e3e1Schristos 2014e98e3e1Schristos Mixed alignment should be specified when the simulator needs to be 2024e98e3e1Schristos able to change the alignment requirements on the fly (eg for 2034e98e3e1Schristos bi-endian support). */ 2044e98e3e1Schristos 2054e98e3e1Schristos enum sim_alignments { 2064e98e3e1Schristos MIXED_ALIGNMENT, 2074e98e3e1Schristos NONSTRICT_ALIGNMENT, 2084e98e3e1Schristos STRICT_ALIGNMENT, 2094e98e3e1Schristos FORCED_ALIGNMENT, 2104e98e3e1Schristos }; 2114e98e3e1Schristos 2124e98e3e1Schristos extern enum sim_alignments current_alignment; 2134e98e3e1Schristos 2144e98e3e1Schristos #if !defined (WITH_ALIGNMENT) 2154e98e3e1Schristos #define WITH_ALIGNMENT 0 2164e98e3e1Schristos #endif 2174e98e3e1Schristos 2184e98e3e1Schristos #define CURRENT_ALIGNMENT (WITH_ALIGNMENT \ 2194e98e3e1Schristos ? WITH_ALIGNMENT \ 2204e98e3e1Schristos : current_alignment) 2214e98e3e1Schristos 2224e98e3e1Schristos 2234e98e3e1Schristos 2244e98e3e1Schristos /* Floating point suport: 2254e98e3e1Schristos 2264e98e3e1Schristos Should the processor trap for all floating point instructions (as 2274e98e3e1Schristos if the hardware wasn't implemented) or implement the floating point 2284e98e3e1Schristos instructions directly. */ 2294e98e3e1Schristos 2304e98e3e1Schristos #if defined (WITH_FLOATING_POINT) 2314e98e3e1Schristos 2324e98e3e1Schristos #define SOFT_FLOATING_POINT 1 2334e98e3e1Schristos #define HARD_FLOATING_POINT 2 2344e98e3e1Schristos 2354e98e3e1Schristos extern int current_floating_point; 2364e98e3e1Schristos #define CURRENT_FLOATING_POINT (WITH_FLOATING_POINT \ 2374e98e3e1Schristos ? WITH_FLOATING_POINT \ 2384e98e3e1Schristos : current_floating_point) 2394e98e3e1Schristos 2404e98e3e1Schristos #endif 2414e98e3e1Schristos 2424e98e3e1Schristos 2434e98e3e1Schristos /* Whether to check instructions for reserved bits being set */ 2444e98e3e1Schristos 2454e98e3e1Schristos /* #define WITH_RESERVED_BITS 1 */ 2464e98e3e1Schristos 2474e98e3e1Schristos 2484e98e3e1Schristos 2494e98e3e1Schristos /* include monitoring code */ 2504e98e3e1Schristos 2514e98e3e1Schristos #define MONITOR_INSTRUCTION_ISSUE 1 2524e98e3e1Schristos #define MONITOR_LOAD_STORE_UNIT 2 2534e98e3e1Schristos /* do not define WITH_MON by default */ 2544e98e3e1Schristos #define DEFAULT_WITH_MON (MONITOR_LOAD_STORE_UNIT \ 2554e98e3e1Schristos | MONITOR_INSTRUCTION_ISSUE) 2564e98e3e1Schristos 2574e98e3e1Schristos 2584e98e3e1Schristos /* Whether or not input/output just uses stdio, or uses printf_filtered for 2594e98e3e1Schristos output, and polling input for input. */ 2604e98e3e1Schristos 2614e98e3e1Schristos #define DONT_USE_STDIO 2 2624e98e3e1Schristos #define DO_USE_STDIO 1 2634e98e3e1Schristos 2644e98e3e1Schristos extern int current_stdio; 2654e98e3e1Schristos #define CURRENT_STDIO (WITH_STDIO \ 2664e98e3e1Schristos ? WITH_STDIO \ 2674e98e3e1Schristos : current_stdio) 2684e98e3e1Schristos 2694e98e3e1Schristos 2704e98e3e1Schristos 2714e98e3e1Schristos /* Set the default state configuration, before parsing argv. */ 2724e98e3e1Schristos 2734e98e3e1Schristos extern void sim_config_default (SIM_DESC sd); 2744e98e3e1Schristos 2754e98e3e1Schristos /* Complete and verify the simulator configuration. */ 2764e98e3e1Schristos 2774e98e3e1Schristos extern SIM_RC sim_config (SIM_DESC sd); 2784e98e3e1Schristos 2794e98e3e1Schristos /* Print the simulator configuration. */ 2804e98e3e1Schristos 2814b169a6bSchristos extern void sim_config_print (SIM_DESC sd); 2824e98e3e1Schristos 2834e98e3e1Schristos 2844e98e3e1Schristos #endif 285