Automatic date update in version.in
[binutils-gdb.git] / sim / README-HACKING
index 26dbde2932074d925653ad6bdbf252e256f4d668..38915bf3bb9446f09f183685babe0dc64ea9e817 100644 (file)
@@ -20,10 +20,7 @@ The common directory contains:
 - common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
 
 In addition "common" contains portions of the system call support
-(e.g. callback.c, nltvals.def).
-
-Even though no files are built in this directory, it is still configured
-so support for regenerating nltvals.def is present.
+(e.g. callback.c, target-newlib-*.c).
 \f
 Common Makefile Support
 =======================
@@ -38,24 +35,14 @@ The configure.ac of a simulator using the common framework should look like:
 
 --- snip ---
 dnl Process this file with autoconf to produce a configure script.
-sinclude(../common/aclocal.m4)
-AC_PREREQ(2.5)dnl
 AC_INIT(Makefile.in)
-
-SIM_AC_COMMON
+AC_CONFIG_MACRO_DIRS([../common ../.. ../../config])
 
 ... target specific additions ...
 
 SIM_AC_OUTPUT
 --- snip ---
 
-SIM_AC_COMMON:
-
-- invokes the autoconf macros most often used by the simulators
-- defines --enable/--with options usable by all simulators
-- initializes sim_link_files/sim_link_links as the set of symbolic links
-  to set up
-
 SIM_AC_OUTPUT:
 
 - creates the symbolic links defined in sim_link_{files,links}
@@ -84,12 +71,6 @@ SIM_EXTRA_DEPS =
 SIM_EXTRA_CFLAGS =
 # List of extra libraries to link with.
 SIM_EXTRA_LIBS =
-# List of extra program dependencies.
-SIM_EXTRA_LIBDEPS =
-# List of main object files for `run'.
-SIM_RUN_OBJS = run.o
-# Dependency of `all' to build any extra files.
-SIM_EXTRA_ALL =
 # Dependency of `install' to install any extra files.
 SIM_EXTRA_INSTALL =
 # Dependency of `clean' to clean any extra files.
@@ -161,33 +142,7 @@ To add the entries to an alternative ChangeLog file, use:
 C Language Assumptions
 ======================
 
-The programmer may assume that the simulator is being built using an
-ANSI C compiler that supports a 64 bit data type.  Consequently:
-
-       o       prototypes can be used
-
-       o       If sim-types.h is included, the two
-               types signed64 and unsigned64 are
-               available.
-
-       o       The type `unsigned' is valid.
-
-However, the user should be aware of the following:
-
-       o       GCC's `<number>LL' is NOT acceptable.
-               Microsoft-C doesn't reconize it.
-
-       o       MSC's `<number>i64' is NOT acceptable.
-               GCC doesn't reconize it.
-
-       o       GCC's `long long' MSC's `_int64' can
-               NOT be used to define 64 bit integer data
-               types.
-
-       o       An empty array (eg int a[0]) is not valid.
-
-When building with GCC it is effectivly a requirement that
---enable-build-warnings=,-Werror be specified during configuration.
+An ISO C11 compiler is required, as is an ISO C standard library.
 \f
 "dump" commands under gdb
 =========================
@@ -203,8 +158,8 @@ internal state pretty printed from gdb.
 
 FIXME: This can obviously be made more elaborate.  As needed it will be.
 \f
-Rebuilding nltvals.def
-======================
+Rebuilding target-newlib-* files
+================================
 
 Checkout a copy of the SIM and LIBGLOSS modules (Unless you've already
 got one to hand):
@@ -213,36 +168,29 @@ got one to hand):
        $  cd /tmp/$$
        $  cvs checkout sim-no-testsuite libgloss-no-testsuite newlib-no-testsuite
 
-Configure things for an arbitrary simulator target (I've d10v for
+Configure things for an arbitrary simulator target (d10v is used here for
 convenience):
 
        $  mkdir /tmp/$$/build
        $  cd /tmp/$$/build
        $  /tmp/$$/devo/configure --target=d10v-elf
 
-In the sim/common directory rebuild the headers:
+In the sim/ directory rebuild the headers:
 
-       $  cd sim/common
-       $  make headers
+       $  cd sim/
+       $  make nltvals
 
-To add a new target:
+If the target uses the common syscall table (libgloss/syscall.h), then you're
+all set!  If the target has a custom syscall table, you need to declare it:
 
-       devo/sim/common/gennltvals.sh
+       devo/sim/common/gennltvals.py
 
                Add your new processor target (you'll need to grub
                around to find where your syscall.h lives).
 
-       devo/sim/<processor>/Makefile.in
-
-               Add the definition:
-
-                       ``NL_TARGET = -DNL_TARGET_d10v''
-
-               just before the line COMMON_POST_CONFIG_FRAG.
-
        devo/sim/<processor>/*.[ch]
 
-               Include targ-vals.h instead of syscall.h.
+               Include target-newlib-syscall.h instead of syscall.h.
 \f
 Tracing
 =======
@@ -296,10 +244,8 @@ And in your insn fetcher:
   PROFILE_COUNT_CORE (cpu, target_addr, size_in_bytes, map_exec);
 
 To use the PC profiling code, you simply have to tell the system where to find
-your simulator's PC and its size.  So in your sim_open() function:
-  STATE_WATCHPOINTS (sd)->pc = address_of_cpu0_pc;
-  STATE_WATCHPOINTS (sd)->sizeof_pc = number_of_bytes_for_pc_storage;
-In a typical 32bit system, the sizeof_pc will be 4 bytes.
+your simulator's PC.  So in your model initialization function:
+  CPU_PC_FETCH (cpu) = function_that_fetches_the_pc;
 
 To profile branches, in every location where a branch insn is executed, call
 one of the related helpers:
@@ -312,8 +258,8 @@ Environment Simulation
 
 The simplest simulator doesn't include environment support -- it merely
 simulates the Instruction Set Architecture (ISA).  Once you're ready to move
-on to the next level, call the common macro in your configure.ac:
-SIM_AC_OPTION_ENVIRONMENT
+on to the next level, it's time to start handling the --env option.  It's
+enabled by default for all ports already.
 
 This will support for the user, virtual, and operating environments.  See the
 sim-config.h header for a more detailed description of them.  The former are
@@ -328,7 +274,7 @@ Userspace System Calls
 By default, the libgloss userspace is simulated.  That means the system call
 numbers and calling convention matches that of libgloss.  Simulating other
 userspaces (such as Linux) is pretty straightforward, but let's first focus
-on the basics.  The basic API is covered in include/gdb/callback.h.
+on the basics.  The basic API is covered in include/sim/callback.h.
 
 When an instruction is simulated that invokes the system call method (such as
 forcing a hardware trap or exception), your simulator code should set up the
@@ -378,8 +324,8 @@ only store the error code when the result is an error.
 
 Keep in mind that the CB_SYS_xxx defines are normalized values with no real
 meaning with respect to the target.  They provide a unique map on the host so
-that it can parse things sanely.  For libgloss, the common/nltvals.def file
-creates the target's system call numbers to the CB_SYS_xxx values.
+that it can parse things sanely.  For libgloss, the common/target-newlib-syscall
+file contains the target's system call numbers to the CB_SYS_xxx values.
 
 To simulate other userspace targets, you really only need to update the maps
 pointers that are part of the callback interface.  So create CB_TARGET_DEFS_MAP
@@ -430,8 +376,8 @@ Hardware Devices
 ================
 
 The simplest simulator doesn't include hardware device support.  Once you're
-ready to move on to the next level, call the common macro in your configure.ac:
-SIM_AC_OPTION_HARDWARE(yes,,devone devtwo devthree)
+ready to move on to the next level, declare in your Makefile.in:
+SIM_EXTRA_HW_DEVICES = devone devtwo devthree
 
 The basic hardware API is documented in common/hw-device.h.