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 27 /* the system object */ 28 /* typedef struct _psim psim; */ 29 /* typedef struct _device device; */ 30 31 /* when the `system' stops, find out why. FIXME - at this point this 32 is really a bit puzzling. After all, how can there be a status 33 when there several processors involved */ 34 35 typedef struct _psim_status { 36 int cpu_nr; 37 stop_reason reason; 38 int signal; 39 unsigned_word program_counter; 40 } psim_status; 41 42 43 /* create an initial device tree and then populate it using 44 information obtained from either the command line or a file */ 45 46 extern device *psim_tree 47 (void); 48 49 extern char **psim_options 50 (device *root, 51 char **argv); 52 53 extern void psim_command 54 (device *root, 55 char **argv); 56 57 58 extern void psim_merge_device_file 59 (device *root, 60 const char *file_name); 61 62 extern void psim_usage 63 (int verbose, int help); 64 65 66 /* create a new simulator from the device tree */ 67 68 extern psim *psim_create 69 (const char *file_name, 70 device *root); 71 72 73 /* Given the created simulator (re) initialize it */ 74 75 extern void psim_init 76 (psim *system); 77 78 extern void psim_stack 79 (psim *system, 80 char **argv, 81 char **envp); 82 83 84 /* Run/stop the system */ 85 86 extern void psim_step 87 (psim *system); 88 89 extern void psim_run 90 (psim *system); 91 92 extern void psim_restart 93 (psim *system, 94 int cpu_nr); 95 96 extern void psim_set_halt_and_restart 97 (psim *system, 98 void *halt_jmp_buf, 99 void *restart_jmp_buf); 100 101 extern void psim_clear_halt_and_restart 102 (psim *system); 103 104 extern void psim_stop 105 (psim *system); 106 107 extern void psim_halt 108 (psim *system, 109 int cpu_nr, 110 stop_reason reason, 111 int signal); 112 113 extern int psim_last_cpu 114 (psim *system); 115 116 extern int psim_nr_cpus 117 (psim *system); 118 119 120 extern psim_status psim_get_status 121 (psim *system); 122 123 124 /* reveal the internals of the simulation. Grant access to the 125 processor (cpu) device tree (device) and events (event_queue). */ 126 127 extern cpu *psim_cpu 128 (psim *system, 129 int cpu_nr); 130 131 extern device *psim_device 132 (psim *system, 133 const char *path); 134 135 extern event_queue *psim_event_queue 136 (psim *system); 137 138 139 140 /* Manipulate the state (registers or memory) of a processor within 141 the system. In the case of memory, the read/write is performed 142 using the specified processors address translation tables. 143 144 Where applicable, WHICH_CPU == -1 indicates all processors and 145 WHICH_CPU == <nr_cpus> indicates the `current' processor. 146 147 The register functions return the size of the register, or 0 if the 148 register's name is not recognized. */ 149 150 extern int psim_read_register 151 (psim *system, 152 int which_cpu, 153 void *host_ordered_buf, 154 const char reg[], 155 transfer_mode mode); 156 157 extern int psim_write_register 158 (psim *system, 159 int which_cpu, 160 const void *buf, 161 const char reg[], 162 transfer_mode mode); 163 164 extern unsigned psim_read_memory 165 (psim *system, 166 int which_cpu, 167 void *buf, 168 unsigned_word vaddr, 169 unsigned len); 170 171 extern unsigned psim_write_memory 172 (psim *system, 173 int which_cpu, 174 const void *buf, 175 unsigned_word vaddr, 176 unsigned len, 177 int violate_read_only_section); 178 179 extern void psim_print_info 180 (psim *system, 181 int verbose); 182 183 #endif /* _PSIM_H_ */ 184