Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 1 | /* sim_frontpanel.h: simulator frontpanel API definitions
|
| 2 |
|
| 3 | Copyright (c) 2015, Mark Pizzolato
|
| 4 |
|
| 5 | Permission is hereby granted, free of charge, to any person obtaining a
|
| 6 | copy of this software and associated documentation files (the "Software"),
|
| 7 | to deal in the Software without restriction, including without limitation
|
| 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 9 | and/or sell copies of the Software, and to permit persons to whom the
|
| 10 | Software is furnished to do so, subject to the following conditions:
|
| 11 |
|
| 12 | The above copyright notice and this permission notice shall be included in
|
| 13 | all copies or substantial portions of the Software.
|
| 14 |
|
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 18 | MARK PIZZOLATO BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 21 |
|
| 22 | Except as contained in this notice, the name of Mark Pizzolato shall not be
|
| 23 | used in advertising or otherwise to promote the sale, use or other dealings
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 24 | in this Software without prior written authorization from Mark Pizzolato.
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 25 |
|
| 26 | 15-Jan-15 MP Initial implementation
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 27 | 01-Apr-15 MP Added register indirect, mem_examine and mem_deposit
|
Mark Pizzolato | 9d47891 | 2015-04-04 09:18:02 -0700 | [diff] [blame] | 28 | 03-Apr-15 MP Added logic to pass simulator startup messages in
|
| 29 | panel error text if the connection to the simulator
|
| 30 | shuts down while it is starting.
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 31 | 04-Apr-15 MP Added mount and dismount routines to connect and
|
| 32 | disconnect removable media
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 33 |
|
| 34 | This module defines interface between a front panel application and a simh
|
| 35 | simulator. Facilities provide ways to gather information from and to
|
| 36 | observe and control the state of a simulator.
|
| 37 |
|
Mark Pizzolato | ce3e635 | 2015-02-17 16:36:23 -0800 | [diff] [blame] | 38 | Any application which wants to use this API needs to:
|
| 39 | 1) include this file in the application code
|
| 40 | 2) compile sim_frontpanel.c and sim_sock.c from the top level directory
|
| 41 | of the simh source.
|
| 42 | 3) link the sim_frontpanel and sim_sock object modules and libpthreads
|
| 43 | into the application.
|
| 44 | 4) Use a simh simulator built from the same version of simh that the
|
| 45 | sim_frontpanel and sim_sock modules came from.
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 46 | */
|
| 47 |
|
| 48 | #ifndef SIM_FRONTPANEL_H_
|
| 49 | #define SIM_FRONTPANEL_H_ 0
|
| 50 |
|
| 51 | #ifdef __cplusplus
|
| 52 | extern "C" {
|
| 53 | #endif
|
| 54 |
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 55 | #include <stdlib.h>
|
| 56 |
|
Mark Pizzolato | 3719a07 | 2015-04-13 15:48:53 -0700 | [diff] [blame] | 57 | #if !defined(__VAX) /* Unsupported platform */
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 58 |
|
Mark Pizzolato | 2efc3a1 | 2018-01-12 10:07:15 -0800 | [diff] [blame] | 59 | #define SIM_FRONTPANEL_VERSION 12
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 60 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 61 | /**
|
| 62 |
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 63 | sim_panel_start_simulator A starts a simulator with a particular
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 64 | configuration
|
| 65 |
|
| 66 | sim_path the path to the simulator binary
|
| 67 | sim_config the configuration to run the simulator with
|
| 68 | device_panel_count the number of sub panels for connected devices
|
| 69 |
|
| 70 | Note 1: - The path specified must be either a fully specified path or
|
Mark Pizzolato | 8551a2d | 2017-11-09 23:02:39 -0800 | [diff] [blame] | 71 | it could be merely the simulator name if the simulator binary
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 72 | is located in the current PATH.
|
| 73 | - The simulator binary must be built from the same version
|
| 74 | simh source code that the frontpanel API was acquired fron
|
| 75 | (the API and the simh framework must speak the same language)
|
| 76 |
|
| 77 | Note 2: - Configuration file specified should contain device setup
|
| 78 | statements (enable, disable, CPU types and attach commands).
|
| 79 | It should not start a simulator running.
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 80 | */
|
| 81 |
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 82 | typedef struct PANEL PANEL;
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 83 |
|
| 84 | PANEL *
|
| 85 | sim_panel_start_simulator (const char *sim_path,
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 86 | const char *sim_config,
|
| 87 | size_t device_panel_count);
|
| 88 |
|
Mark Pizzolato | 71fe58b | 2015-02-26 11:28:08 -0800 | [diff] [blame] | 89 | PANEL *
|
| 90 | sim_panel_start_simulator_debug (const char *sim_path,
|
| 91 | const char *sim_config,
|
| 92 | size_t device_panel_count,
|
| 93 | const char *debug_file);
|
| 94 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 95 | /**
|
| 96 |
|
| 97 | sim_panel_add_device_panel - creates a sub panel associated
|
| 98 | with a specific simulator panel
|
| 99 |
|
| 100 | simulator_panel the simulator panel to connect to
|
| 101 | device_name the simulator's name for the device
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 102 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 103 |
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 104 | PANEL *
|
| 105 | sim_panel_add_device_panel (PANEL *simulator_panel,
|
| 106 | const char *device_name);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 107 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 108 | /**
|
| 109 |
|
| 110 | sim_panel_destroy to shutdown a panel or sub panel.
|
| 111 |
|
| 112 | Note: destroying a simulator panel will also destroy any
|
| 113 | related sub panels
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 114 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 115 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 116 | int
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 117 | sim_panel_destroy (PANEL *panel);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 118 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 119 | /**
|
| 120 |
|
| 121 | The frontpanel API exposes the state of a simulator via access to
|
| 122 | simh register variables that the simulator and its devices define.
|
| 123 | These registers certainly include any architecturally described
|
| 124 | registers (PC, PSL, SP, etc.), but also include anything else
|
| 125 | the simulator uses as internal state to implement the running
|
| 126 | simulator.
|
| 127 |
|
| 128 | The registers that a particular frontpanel application mught need
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 129 | access to are specified by the application when it calls:
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 130 |
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 131 | sim_panel_add_register
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 132 | sim_panel_add_register_bits
|
Mark Pizzolato | d75ec66 | 2015-04-17 14:46:06 -0700 | [diff] [blame] | 133 | sim_panel_add_register_array
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 134 | and
|
| 135 | sim_panel_add_register_indirect
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 136 | sim_panel_add_register_indirect_bits
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 137 |
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 138 | name the name the simulator knows this register by
|
| 139 | device_name the device this register is part of. Defaults to
|
| 140 | the device of the panel (in a device panel) or the
|
| 141 | default device in the simulator (usually the CPU).
|
Mark Pizzolato | d75ec66 | 2015-04-17 14:46:06 -0700 | [diff] [blame] | 142 | element_count number of elements in the register array
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 143 | size the size (in local storage) of the buffer which will
|
| 144 | receive the data in the simulator's register
|
| 145 | addr a pointer to the location of the buffer which will
|
| 146 | be loaded with the data in the simulator's register
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 147 | bit_width the number of values to populate in the bits array
|
| 148 | bits an array of integers which is bit_width long that
|
| 149 | will receive each bit's current accumulated value.
|
| 150 | The accumulated value will range from 0 thru the
|
| 151 | the sample_depth specified when calling
|
| 152 | sim_panel_set_sampling_parameters().
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 153 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 154 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 155 | int
|
| 156 | sim_panel_add_register (PANEL *panel,
|
| 157 | const char *name,
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 158 | const char *device_name,
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 159 | size_t size,
|
| 160 | void *addr);
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 161 |
|
| 162 | int
|
| 163 | sim_panel_add_register_bits (PANEL *panel,
|
| 164 | const char *name,
|
| 165 | const char *device_name,
|
| 166 | size_t bit_width,
|
| 167 | int *bits);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 168 |
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 169 | int
|
Mark Pizzolato | d75ec66 | 2015-04-17 14:46:06 -0700 | [diff] [blame] | 170 | sim_panel_add_register_array (PANEL *panel,
|
| 171 | const char *name,
|
| 172 | const char *device_name,
|
| 173 | size_t element_count,
|
| 174 | size_t size,
|
| 175 | void *addr);
|
| 176 |
|
| 177 | int
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 178 | sim_panel_add_register_indirect (PANEL *panel,
|
| 179 | const char *name,
|
| 180 | const char *device_name,
|
| 181 | size_t size,
|
| 182 | void *addr);
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 183 |
|
| 184 | int
|
| 185 | sim_panel_add_register_indirect_bits (PANEL *panel,
|
| 186 | const char *name,
|
| 187 | const char *device_name,
|
| 188 | size_t bit_width,
|
| 189 | int *bits);
|
| 190 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 191 | /**
|
| 192 |
|
| 193 | A panel application has a choice of two different methods of getting
|
| 194 | the values contained in the set of registers it has declared interest in via
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 195 | the sim_panel_add_register APIs.
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 196 |
|
Mark Pizzolato | e73d45e | 2017-11-04 10:28:00 -0700 | [diff] [blame] | 197 | 1) The values can be polled (whenever it is desired) by calling
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 198 | sim_panel_get_registers().
|
Mark Pizzolato | 110ded6 | 2017-01-27 23:06:30 -0800 | [diff] [blame] | 199 | 2) The panel can call sim_panel_set_display_callback_interval() to
|
| 200 | specify a callback routine and a periodic rate that the callback
|
| 201 | routine should be called. The panel API will make a best effort
|
| 202 | to deliver the current register state at the desired rate.
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 203 |
|
| 204 |
|
Mark Pizzolato | 3719a07 | 2015-04-13 15:48:53 -0700 | [diff] [blame] | 205 | Note 1: The buffers described in a panel's register set will be
|
| 206 | dynamically revised as soon as data is available from the
|
| 207 | simulator. The callback routine merely serves as a notification
|
| 208 | that a complete register set has arrived.
|
| 209 | Note 2: The callback routine should, in general, not run for a long time
|
| 210 | or frontpanel interactions with the simulator may be disrupted.
|
| 211 | Setting a flag, signaling an event or posting a message are
|
| 212 | reasonable activities to perform in a callback routine.
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 213 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 214 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 215 | int
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 216 | sim_panel_get_registers (PANEL *panel, unsigned long long *simulation_time);
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 217 |
|
| 218 | typedef void (*PANEL_DISPLAY_PCALLBACK)(PANEL *panel,
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 219 | unsigned long long simulation_time,
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 220 | void *context);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 221 |
|
| 222 | int
|
Mark Pizzolato | 110ded6 | 2017-01-27 23:06:30 -0800 | [diff] [blame] | 223 | sim_panel_set_display_callback_interval (PANEL *panel,
|
| 224 | PANEL_DISPLAY_PCALLBACK callback,
|
| 225 | void *context,
|
| 226 | int usecs_between_callbacks);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 227 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 228 | /**
|
| 229 |
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 230 | When a front panel application wants to get averaged bit sample
|
| 231 | values, it must first declare the sampling parameters that will
|
Mark Pizzolato | 8551a2d | 2017-11-09 23:02:39 -0800 | [diff] [blame] | 232 | be used while collecting the bit values. The dithering
|
| 233 | percentage must be 25% or less and when non 0 causes the sample
|
| 234 | frequency to vary by plus or minus a random percentage value up
|
| 235 | to the specified value.
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 236 |
|
| 237 | sim_panel_set_sampling_parameters
|
Mark Pizzolato | 8551a2d | 2017-11-09 23:02:39 -0800 | [diff] [blame] | 238 | sim_panel_set_sampling_parameters_ex
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 239 |
|
| 240 | sample_frequency cycles/instructions between sample captures
|
Mark Pizzolato | 8551a2d | 2017-11-09 23:02:39 -0800 | [diff] [blame] | 241 | sample_dither_pct percentage of sample_frequency to vary randomly
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 242 | sample_depth how many samples to accumulate in the rolling
|
| 243 | average for each bit sample. Returned bit
|
| 244 | sample values will range from 0 thru this
|
| 245 | value.
|
| 246 | */
|
| 247 |
|
| 248 | int
|
Mark Pizzolato | 8551a2d | 2017-11-09 23:02:39 -0800 | [diff] [blame] | 249 | sim_panel_set_sampling_parameters_ex (PANEL *panel,
|
| 250 | unsigned int sample_frequency,
|
| 251 | unsigned int sample_dither_pct,
|
| 252 | unsigned int sample_depth);
|
| 253 |
|
| 254 | int
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 255 | sim_panel_set_sampling_parameters (PANEL *panel,
|
| 256 | unsigned int sample_frequency,
|
| 257 | unsigned int sample_depth);
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 258 | /**
|
| 259 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 260 | When a front panel application needs to change the running
|
| 261 | state of a simulator one of the following routines should
|
| 262 | be called:
|
| 263 |
|
| 264 | sim_panel_exec_halt - Stop instruction execution
|
| 265 | sim_panel_exec_boot - Boot a simulator from a specific device
|
| 266 | sim_panel_exec_run - Start/Resume a simulator running instructions
|
Mark Pizzolato | e73d45e | 2017-11-04 10:28:00 -0700 | [diff] [blame] | 267 | sim_panel_exec_start - Start a simulator running instructions
|
| 268 | after resetting all devices
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 269 | sim_panel_exec_step - Have a simulator execute a single step
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 270 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 271 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 272 | int
|
| 273 | sim_panel_exec_halt (PANEL *panel);
|
| 274 |
|
| 275 | int
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 276 | sim_panel_exec_boot (PANEL *panel, const char *device);
|
Mark Pizzolato | e73d45e | 2017-11-04 10:28:00 -0700 | [diff] [blame] | 277 |
|
| 278 | int
|
| 279 | sim_panel_exec_start (PANEL *panel);
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 280 |
|
| 281 | int
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 282 | sim_panel_exec_run (PANEL *panel);
|
| 283 |
|
| 284 | int
|
| 285 | sim_panel_exec_step (PANEL *panel);
|
| 286 |
|
Mark Pizzolato | 2efc3a1 | 2018-01-12 10:07:15 -0800 | [diff] [blame] | 287 |
|
| 288 |
|
| 289 | /**
|
| 290 | A simulator often displays some useful information as it stops
|
| 291 | executing instructions.
|
| 292 |
|
| 293 | sim_panel_halt_text - Returns the simulator output immediately prior
|
| 294 | to the most recent transition to the Halt state.
|
| 295 | */
|
| 296 |
|
| 297 | const char *
|
| 298 | sim_panel_halt_text (PANEL *panel);
|
| 299 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 300 | /**
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 301 |
|
Mark Pizzolato | d497aea | 2016-02-11 16:42:25 -0800 | [diff] [blame] | 302 | When a front panel application wants to describe conditions that
|
| 303 | should stop instruction execution an execution or an output
|
Mark Pizzolato | 43dc5fd | 2016-12-17 03:44:45 -0800 | [diff] [blame] | 304 | breakpoint should be used. To established or clear a breakpoint,
|
| 305 | one of the following routines should be called:
|
Mark Pizzolato | d497aea | 2016-02-11 16:42:25 -0800 | [diff] [blame] | 306 |
|
| 307 | sim_panel_break_set - Establish a simulation breakpoint
|
| 308 | sim_panel_break_clear - Cancel/Delete a previously defined
|
| 309 | breakpoint
|
| 310 | sim_panel_break_output_set - Establish a simulator output
|
| 311 | breakpoint
|
| 312 | sim_panel_break_output_clear - Cancel/Delete a previously defined
|
| 313 | output breakpoint
|
| 314 |
|
| 315 | Note: Any breakpoint switches/flags must be located at the
|
| 316 | beginning of the condition string
|
Mark Pizzolato | d497aea | 2016-02-11 16:42:25 -0800 | [diff] [blame] | 317 | */
|
| 318 |
|
| 319 | int
|
| 320 | sim_panel_break_set (PANEL *panel, const char *condition);
|
| 321 |
|
| 322 | int
|
| 323 | sim_panel_break_clear (PANEL *panel, const char *condition);
|
| 324 |
|
| 325 | int
|
| 326 | sim_panel_break_output_set (PANEL *panel, const char *condition);
|
| 327 |
|
| 328 | int
|
| 329 | sim_panel_break_output_clear (PANEL *panel, const char *condition);
|
| 330 |
|
| 331 |
|
| 332 | /**
|
| 333 |
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 334 | When a front panel application needs to change or access
|
| 335 | memory or a register one of the following routines should
|
| 336 | be called:
|
| 337 |
|
Mark Pizzolato | 8cc11fa | 2017-12-13 05:44:43 -0800 | [diff] [blame] | 338 | sim_panel_gen_examine - Examine register or memory
|
| 339 | sim_panel_gen_deposit - Deposit to register or memory
|
| 340 | sim_panel_mem_examine - Examine memory location
|
| 341 | sim_panel_mem_deposit - Deposit to memory location
|
| 342 | sim_panel_mem_deposit_instruction - Deposit instruction to memory
|
| 343 | location
|
| 344 | sim_panel_set_register_value - Deposit to a register or memory
|
| 345 | location
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 346 | */
|
| 347 |
|
| 348 |
|
| 349 | /**
|
| 350 |
|
| 351 | sim_panel_gen_examine
|
| 352 |
|
| 353 | name_or_addr the name the simulator knows this register by
|
| 354 | size the size (in local storage) of the buffer which will
|
| 355 | receive the data returned when examining the simulator
|
| 356 | value a pointer to the buffer which will be loaded with the
|
| 357 | data returned when examining the simulator
|
| 358 | */
|
| 359 |
|
| 360 | int
|
| 361 | sim_panel_gen_examine (PANEL *panel,
|
| 362 | const char *name_or_addr,
|
| 363 | size_t size,
|
| 364 | void *value);
|
Mark Pizzolato | 33fc5c4 | 2017-12-18 15:05:58 -0800 | [diff] [blame] | 365 |
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 366 | /**
|
| 367 |
|
| 368 | sim_panel_gen_deposit
|
| 369 |
|
| 370 | name_or_addr the name the simulator knows this register by
|
| 371 | size the size (in local storage) of the buffer which
|
| 372 | contains the data to be deposited into the simulator
|
| 373 | value a pointer to the buffer which contains the data to
|
| 374 | be deposited into the simulator
|
| 375 | */
|
| 376 |
|
| 377 | int
|
| 378 | sim_panel_gen_deposit (PANEL *panel,
|
| 379 | const char *name_or_addr,
|
| 380 | size_t size,
|
| 381 | const void *value);
|
| 382 |
|
| 383 | /**
|
| 384 |
|
| 385 | sim_panel_mem_examine
|
| 386 |
|
| 387 | addr_size the size (in local storage) of the buffer which
|
| 388 | contains the memory address of the data to be examined
|
| 389 | in the simulator
|
| 390 | addr a pointer to the buffer containing the memory address
|
| 391 | of the data to be examined in the simulator
|
| 392 | value_size the size (in local storage) of the buffer which will
|
| 393 | receive the data returned when examining the simulator
|
| 394 | value a pointer to the buffer which will be loaded with the
|
| 395 | data returned when examining the simulator
|
| 396 | */
|
| 397 |
|
| 398 | int
|
| 399 | sim_panel_mem_examine (PANEL *panel,
|
| 400 | size_t addr_size,
|
| 401 | const void *addr,
|
| 402 | size_t value_size,
|
| 403 | void *value);
|
| 404 |
|
| 405 | /**
|
| 406 |
|
| 407 | sim_panel_mem_deposit
|
| 408 |
|
| 409 | addr_size the size (in local storage) of the buffer which
|
| 410 | contains the memory address of the data to be deposited
|
| 411 | into the simulator
|
| 412 | addr a pointer to the buffer containing the memory address
|
| 413 | of the data to be deposited into the simulator
|
| 414 | value_size the size (in local storage) of the buffer which will
|
| 415 | contains the data to be deposited into the simulator
|
| 416 | value a pointer to the buffer which contains the data to be
|
| 417 | deposited into the simulator
|
| 418 | */
|
| 419 |
|
| 420 | int
|
| 421 | sim_panel_mem_deposit (PANEL *panel,
|
| 422 | size_t addr_size,
|
| 423 | const void *addr,
|
| 424 | size_t value_size,
|
| 425 | const void *value);
|
| 426 |
|
| 427 | /**
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 428 |
|
Mark Pizzolato | 8cc11fa | 2017-12-13 05:44:43 -0800 | [diff] [blame] | 429 | sim_panel_mem_deposit_instruction
|
| 430 |
|
| 431 | addr_size the size (in local storage) of the buffer which
|
| 432 | contains the memory address of the data to be deposited
|
| 433 | into the simulator
|
| 434 | addr a pointer to the buffer containing the memory address
|
| 435 | of the data to be deposited into the simulator
|
| 436 | instruction a pointer to the buffer that contains the mnemonic
|
| 437 | instruction to be deposited at the indicated address
|
| 438 | */
|
| 439 |
|
| 440 | int
|
| 441 | sim_panel_mem_deposit_instruction (PANEL *panel,
|
| 442 | size_t addr_size,
|
| 443 | const void *addr,
|
| 444 | const char *instruction);
|
| 445 |
|
| 446 | /**
|
| 447 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 448 | sim_panel_set_register_value
|
| 449 |
|
Mark Pizzolato | bccf98e | 2015-04-03 04:44:09 -0700 | [diff] [blame] | 450 | name the name of a simulator register or a memory address
|
| 451 | which is to receive a new value
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 452 | value the new value in character string form. The string
|
| 453 | must be in the native/natural radix that the simulator
|
| 454 | uses when referencing that register
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 455 | */
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 456 | int
|
| 457 | sim_panel_set_register_value (PANEL *panel,
|
| 458 | const char *name,
|
| 459 | const char *value);
|
| 460 |
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 461 | /**
|
| 462 |
|
Mark Pizzolato | 33fc5c4 | 2017-12-18 15:05:58 -0800 | [diff] [blame] | 463 | A front panel application might want to have access to the
|
| 464 | instruction execution history that a simulator may be capable
|
| 465 | of providing. If this functionality is desired, enabling of
|
| 466 | recording instruction history should be explicitly enabled
|
| 467 | in the sim_config file that the simulator is started with.
|
| 468 | */
|
| 469 |
|
| 470 | /**
|
| 471 |
|
| 472 | sim_panel_get_history
|
| 473 |
|
| 474 | count the number of instructions to return
|
| 475 | size the size (in local storage) of the buffer which will
|
| 476 | receive the data returned when examining the simulator
|
| 477 | buffer a pointer to the buffer which will be loaded with the
|
| 478 | instruction history returned from the simulator
|
| 479 | */
|
| 480 |
|
| 481 | int
|
| 482 | sim_panel_get_history (PANEL *panel,
|
| 483 | int count,
|
| 484 | size_t size,
|
| 485 | char *buffer);
|
| 486 |
|
| 487 |
|
| 488 | /**
|
| 489 |
|
Mark Pizzolato | 2efc3a1 | 2018-01-12 10:07:15 -0800 | [diff] [blame] | 490 | A front panel application might want some details of simulator
|
| 491 | and/or device behavior that is provided by a particular simulator
|
| 492 | via debug information. Debugging for particular device(s)
|
| 493 | and/or simulator debug settings can be controlled via the
|
| 494 | sim_panel_device_debug_mode API.
|
| 495 | */
|
| 496 |
|
| 497 | /**
|
| 498 |
|
| 499 | sim_panel_device_debug_mode
|
| 500 |
|
| 501 | device the device whose debug mode is to change
|
| 502 | set_untset 1 to set debug flags, 0 to clear debug flags
|
| 503 | mode_bits character string with different debug mode bits
|
| 504 | to enable or disable. An empty string will
|
| 505 | enable or disable all mode bits for the specified
|
| 506 | device
|
| 507 | */
|
| 508 |
|
| 509 | int
|
| 510 | sim_panel_device_debug_mode (PANEL *panel,
|
| 511 | const char *device,
|
| 512 | int set_unset,
|
| 513 | const char *mode_bits);
|
| 514 |
|
| 515 |
|
| 516 | /**
|
| 517 |
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 518 | When a front panel application needs to change the media
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 519 | in a simulated removable media device one of the following
|
| 520 | routines should be called:
|
| 521 |
|
| 522 | sim_panel_mount - mounts the indicated media file on a device
|
| 523 | sim_panel_dismount - dismounts the currently mounted media file
|
| 524 | from a device
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 525 | */
|
| 526 |
|
| 527 | /**
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 528 |
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 529 | sim_panel_mount
|
| 530 |
|
| 531 | device the name of a simulator device/unit
|
| 532 | switches any switches appropriate for the desire attach
|
| 533 | path the path on the local system to be attached
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 534 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 535 |
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 536 | int
|
| 537 | sim_panel_mount (PANEL *panel,
|
| 538 | const char *device,
|
| 539 | const char *switches,
|
| 540 | const char *path);
|
| 541 |
|
| 542 | /**
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 543 |
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 544 | sim_panel_dismount
|
| 545 |
|
| 546 | device the name of a simulator device/unit
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 547 | */
|
Mark Pizzolato | 665ebf0 | 2017-02-04 10:48:13 -0800 | [diff] [blame] | 548 |
|
Mark Pizzolato | 325e369 | 2015-04-04 16:37:43 -0700 | [diff] [blame] | 549 | int
|
| 550 | sim_panel_dismount (PANEL *panel,
|
| 551 | const char *device);
|
| 552 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 553 |
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 554 | typedef enum {
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 555 | Halt, /* Simulation is halted (instructions not being executed) */
|
| 556 | Run, /* Simulation is executing instructions */
|
| 557 | Error /* Panel simulator is in an error state and should be */
|
| 558 | /* closed (destroyed). sim_panel_get_error might help */
|
| 559 | /* explain why */
|
Mark Pizzolato | 4c8e163 | 2015-02-12 14:59:24 -0800 | [diff] [blame] | 560 | } OperationalState;
|
| 561 |
|
Mark Pizzolato | 5a472f8 | 2015-02-11 11:16:07 -0800 | [diff] [blame] | 562 | OperationalState
|
| 563 | sim_panel_get_state (PANEL *panel);
|
| 564 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 565 | /**
|
| 566 |
|
Mark Pizzolato | 33fc5c4 | 2017-12-18 15:05:58 -0800 | [diff] [blame] | 567 | All API routines which return an int return 0 for
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 568 | success and -1 for an error.
|
Mark Pizzolato | 3719a07 | 2015-04-13 15:48:53 -0700 | [diff] [blame] | 569 |
|
Mark Pizzolato | 2292f2c | 2017-12-10 04:14:36 -0800 | [diff] [blame] | 570 | An API which returns an error (-1), will not change the panel state
|
| 571 | except to possibly set the panel state to Error if the panel
|
| 572 | condition is no longer useful.
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 573 |
|
| 574 | sim_panel_get_error - the details of the most recent error
|
| 575 | sim_panel_clear_error - clears the error buffer
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 576 | */
|
| 577 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 578 | const char *sim_panel_get_error (void);
|
| 579 | void sim_panel_clear_error (void);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 580 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 581 | /**
|
| 582 |
|
| 583 | The panek<->simulator wire protocol can be traced if protocol problems arise.
|
| 584 |
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 585 | sim_panel_set_debug_mode - Specifies the debug detail to be recorded
|
| 586 | sim_panel_flush_debug - Flushes debug output to disk
|
Mark Pizzolato | 2292f2c | 2017-12-10 04:14:36 -0800 | [diff] [blame] | 587 | sim_panel_debug - Write message to the debug file
|
Mark Pizzolato | e1b7bb3 | 2015-02-17 07:58:21 -0800 | [diff] [blame] | 588 |
|
| 589 | */
|
Mark Pizzolato | 335def0 | 2015-02-15 11:04:18 -0800 | [diff] [blame] | 590 | #define DBG_XMT 1 /* Transmit Data */
|
| 591 | #define DBG_RCV 2 /* Receive Data */
|
Mark Pizzolato | 110ded6 | 2017-01-27 23:06:30 -0800 | [diff] [blame] | 592 | #define DBG_REQ 4 /* Request Data */
|
| 593 | #define DBG_RSP 8 /* Response Data */
|
Mark Pizzolato | e73d45e | 2017-11-04 10:28:00 -0700 | [diff] [blame] | 594 | #define DBG_THR 16 /* Thread Activities */
|
Mark Pizzolato | 2292f2c | 2017-12-10 04:14:36 -0800 | [diff] [blame] | 595 | #define DBG_APP 32 /* Application Activities */
|
Mark Pizzolato | 335def0 | 2015-02-15 11:04:18 -0800 | [diff] [blame] | 596 |
|
| 597 | void
|
| 598 | sim_panel_set_debug_mode (PANEL *panel, int debug_bits);
|
| 599 |
|
| 600 | void
|
Mark Pizzolato | 2292f2c | 2017-12-10 04:14:36 -0800 | [diff] [blame] | 601 | sim_panel_debug (PANEL *panel, const char *fmt, ...);
|
| 602 |
|
| 603 | void
|
Mark Pizzolato | 335def0 | 2015-02-15 11:04:18 -0800 | [diff] [blame] | 604 | sim_panel_flush_debug (PANEL *panel);
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 605 |
|
Mark Pizzolato | 059a541 | 2015-02-24 19:49:09 -0800 | [diff] [blame] | 606 | #endif /* !defined(__VAX) */
|
| 607 |
|
Mark Pizzolato | b198e13 | 2015-01-15 12:37:30 -0800 | [diff] [blame] | 608 | #ifdef __cplusplus
|
| 609 | }
|
| 610 | #endif
|
| 611 |
|
Mark Pizzolato | 71fe58b | 2015-02-26 11:28:08 -0800 | [diff] [blame] | 612 | #endif /* SIM_FRONTPANEL_H_ */
|