Home | History | Annotate | Line # | Download | only in common
      1       1.1  christos /* Miscellaneous simulator utilities.
      2  1.1.1.10  christos    Copyright (C) 1997-2024 Free Software Foundation, Inc.
      3       1.1  christos    Contributed by Cygnus Support.
      4       1.1  christos 
      5       1.1  christos This file is part of GDB, the GNU debugger.
      6       1.1  christos 
      7       1.1  christos This program is free software; you can redistribute it and/or modify
      8       1.1  christos it under the terms of the GNU General Public License as published by
      9       1.1  christos the Free Software Foundation; either version 3 of the License, or
     10       1.1  christos (at your option) any later version.
     11       1.1  christos 
     12       1.1  christos This program is distributed in the hope that it will be useful,
     13       1.1  christos but WITHOUT ANY WARRANTY; without even the implied warranty of
     14       1.1  christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15       1.1  christos GNU General Public License for more details.
     16       1.1  christos 
     17       1.1  christos You should have received a copy of the GNU General Public License
     18       1.1  christos along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19       1.1  christos 
     20       1.1  christos #ifndef SIM_UTILS_H
     21       1.1  christos #define SIM_UTILS_H
     22       1.1  christos 
     23   1.1.1.9  christos #include "ansidecl.h"
     24   1.1.1.9  christos 
     25       1.1  christos /* Memory management with an allocator that clears memory before use. */
     26       1.1  christos 
     27       1.1  christos void *zalloc (unsigned long size);
     28       1.1  christos 
     29       1.1  christos #define ZALLOC(TYPE) (TYPE*)zalloc(sizeof (TYPE))
     30       1.1  christos #define NZALLOC(TYPE,N) (TYPE*)zalloc(sizeof (TYPE) * (N))
     31       1.1  christos 
     32       1.1  christos /* Turn VALUE into a string with commas.  */
     33       1.1  christos char *sim_add_commas (char *, int, unsigned long);
     34       1.1  christos 
     35       1.1  christos /* Utilities for elapsed time reporting.  */
     36       1.1  christos 
     37       1.1  christos /* Opaque type, known only inside sim_elapsed_time_foo fns. Externally
     38       1.1  christos    it is known to never have the value zero. */
     39       1.1  christos typedef unsigned long SIM_ELAPSED_TIME;
     40       1.1  christos 
     41       1.1  christos 
     42       1.1  christos /* Get reference point for future call to sim_time_elapsed.  */
     43       1.1  christos SIM_ELAPSED_TIME sim_elapsed_time_get (void);
     44       1.1  christos 
     45       1.1  christos /* Elapsed time in milliseconds since START.  */
     46       1.1  christos unsigned long sim_elapsed_time_since (SIM_ELAPSED_TIME start);
     47       1.1  christos 
     48       1.1  christos /* Utilities for manipulating the load image.  */
     49       1.1  christos 
     50   1.1.1.4  christos SIM_RC sim_analyze_program (SIM_DESC sd, const char *prog_name,
     51       1.1  christos 			    struct bfd *prog_bfd);
     52       1.1  christos 
     53       1.1  christos /* Load program PROG into the simulator using the function DO_LOAD.
     54       1.1  christos    If PROG_BFD is non-NULL, the file has already been opened.
     55       1.1  christos    If VERBOSE_P is non-zero statistics are printed of each loaded section
     56       1.1  christos    and the transfer rate (for consistency with gdb).
     57       1.1  christos    If LMA_P is non-zero the program sections are loaded at the LMA
     58       1.1  christos    rather than the VMA
     59       1.1  christos    If this fails an error message is printed and NULL is returned.
     60       1.1  christos    If it succeeds the bfd is returned.
     61       1.1  christos    NOTE: For historical reasons, older hardware simulators incorrectly
     62       1.1  christos    write the program sections at LMA interpreted as a virtual address.
     63       1.1  christos    This is still accommodated for backward compatibility reasons. */
     64       1.1  christos 
     65   1.1.1.9  christos typedef struct host_callback_struct host_callback;
     66  1.1.1.10  christos typedef uint64_t sim_write_fn (SIM_DESC sd, uint64_t mem,
     67  1.1.1.10  christos 			       const void *buf, uint64_t length);
     68       1.1  christos struct bfd *sim_load_file (SIM_DESC sd, const char *myname,
     69   1.1.1.4  christos 			   host_callback *callback, const char *prog,
     70       1.1  christos 			   struct bfd *prog_bfd, int verbose_p,
     71       1.1  christos 			   int lma_p, sim_write_fn do_load);
     72       1.1  christos 
     73       1.1  christos /* Internal version of sim_do_command, include formatting */
     74   1.1.1.9  christos void sim_do_commandf (SIM_DESC sd, const char *fmt, ...)
     75   1.1.1.9  christos     ATTRIBUTE_PRINTF (2, 3);
     76       1.1  christos 
     77       1.1  christos 
     78       1.1  christos /* sim-basics.h defines a number of enumerations, convert each of them
     79       1.1  christos    to a string representation */
     80       1.1  christos const char *map_to_str (unsigned map);
     81       1.1  christos const char *access_to_str (unsigned access);
     82       1.1  christos const char *transfer_to_str (unsigned transfer);
     83       1.1  christos 
     84       1.1  christos #endif
     85