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