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