xref: /netbsd/external/gpl3/gdb.old/dist/sim/ppc/psim.h (revision b2396a7b)
1 /*  This file is part of the program psim.
2 
3     Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 3 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, see <http://www.gnu.org/licenses/>.
17 
18     */
19 
20 
21 #ifndef _PSIM_H_
22 #define _PSIM_H_
23 
24 #include "basics.h"
25 
26 #include "gdb/remote-sim.h"
27 
28 /* the system object */
29 /* typedef struct _psim psim; */
30 /* typedef struct _device device; */
31 
32 /* when the `system' stops, find out why.  FIXME - at this point this
33    is really a bit puzzling.  After all, how can there be a status
34    when there several processors involved */
35 
36 typedef struct _psim_status {
37   int cpu_nr;
38   stop_reason reason;
39   int signal;
40   unsigned_word program_counter;
41 } psim_status;
42 
43 
44 /* create an initial device tree and then populate it using
45    information obtained from either the command line or a file */
46 
47 extern device *psim_tree
48 (void);
49 
50 extern char **psim_options
51 (device *root,
52  char **argv,
53  SIM_OPEN_KIND kind);
54 
55 extern void psim_command
56 (device *root,
57  char **argv);
58 
59 
60 extern void psim_merge_device_file
61 (device *root,
62  const char *file_name);
63 
64 extern void psim_usage
65 (int verbose, int help, SIM_OPEN_KIND kind);
66 
67 
68 /* create a new simulator from the device tree */
69 
70 extern psim *psim_create
71 (const char *file_name,
72  device *root);
73 
74 
75 /* Given the created simulator (re) initialize it */
76 
77 extern void psim_init
78 (psim *system);
79 
80 extern void psim_stack
81 (psim *system,
82  char **argv,
83  char **envp);
84 
85 
86 /* Run/stop the system */
87 
88 extern void psim_step
89 (psim *system);
90 
91 extern void psim_run
92 (psim *system);
93 
94 extern void psim_restart
95 (psim *system,
96  int cpu_nr);
97 
98 extern void psim_set_halt_and_restart
99 (psim *system,
100  void *halt_jmp_buf,
101  void *restart_jmp_buf);
102 
103 extern void psim_clear_halt_and_restart
104 (psim *system);
105 
106 extern void psim_stop
107 (psim *system);
108 
109 extern void psim_halt
110 (psim *system,
111  int cpu_nr,
112  stop_reason reason,
113  int signal);
114 
115 extern int psim_last_cpu
116 (psim *system);
117 
118 extern int psim_nr_cpus
119 (psim *system);
120 
121 
122 extern psim_status psim_get_status
123 (psim *system);
124 
125 
126 /* reveal the internals of the simulation.  Grant access to the
127    processor (cpu) device tree (device) and events (event_queue). */
128 
129 extern cpu *psim_cpu
130 (psim *system,
131  int cpu_nr);
132 
133 extern device *psim_device
134 (psim *system,
135  const char *path);
136 
137 extern event_queue *psim_event_queue
138 (psim *system);
139 
140 
141 
142 /* Manipulate the state (registers or memory) of a processor within
143    the system.  In the case of memory, the read/write is performed
144    using the specified processors address translation tables.
145 
146    Where applicable, WHICH_CPU == -1 indicates all processors and
147    WHICH_CPU == <nr_cpus> indicates the `current' processor.
148 
149    The register functions return the size of the register, or 0 if the
150    register's name is not recognized.  */
151 
152 extern int psim_read_register
153 (psim *system,
154  int which_cpu,
155  void *host_ordered_buf,
156  const char reg[],
157  transfer_mode mode);
158 
159 extern int psim_write_register
160 (psim *system,
161  int which_cpu,
162  const void *buf,
163  const char reg[],
164  transfer_mode mode);
165 
166 extern unsigned psim_read_memory
167 (psim *system,
168  int which_cpu,
169  void *buf,
170  unsigned_word vaddr,
171  unsigned len);
172 
173 extern unsigned psim_write_memory
174 (psim *system,
175  int which_cpu,
176  const void *buf,
177  unsigned_word vaddr,
178  unsigned len,
179  int violate_read_only_section);
180 
181 extern void psim_print_info
182 (psim *system,
183  int verbose);
184 
185 #endif /* _PSIM_H_ */
186