1
0
mirror of https://github.com/open-simh/simh.git synced 2026-04-29 13:22:34 +00:00

SCP, HP2100, HP3000, I650: Move one time initialization activities to cpu_reset

The paradigm of using a "weak" linker reference to find what was
previously the vm_init_routine() doesn't work reliably on all compile
environments supported by the simulators.  This has been reported
in #794 and it came up again in #862.  This change assures that
it will not come up again AND it reliably solves the problem with
Visual Studio compilers (and linker) that randomly chooses whether
to have the desired effect or not.

Of the 82 simulators which are currently part of simh, only these
three used the sim_vm_init() interface, so removing it had relatively
minor impact.
This commit is contained in:
Mark Pizzolato
2020-05-26 06:25:01 -07:00
parent 6b5d3d0c7e
commit f519513f50
13 changed files with 62 additions and 38 deletions

View File

@@ -3504,6 +3504,9 @@ static t_stat cpu_reset (DEVICE *dptr)
t_stat status;
if (sim_PC == NULL) { /* if this is the first call after simulator start */
hp_one_time_init(); /* perform one time initializations (previously defined as sim_vm_init() */
status = mem_initialize (PA_MAX); /* then allocate main memory */
if (status == SCPE_OK) { /* if memory initialization succeeds */

View File

@@ -934,3 +934,5 @@ extern void hp_initialize_trace (uint32 device_max, uint32 flag_max);
extern void hp_trace (DEVICE *dptr, uint32 flag, ...);
extern void hp_enbdis_pair (DEVICE *ccptr, DEVICE *dcptr);
extern int32 hp_sync_poll (POLLMODE poll_mode);
extern void hp_one_time_init (void); /* One time initialization activities now called in cpu_reset() */

View File

@@ -117,8 +117,8 @@
/* Global release string */
const char *sim_vm_release = "29"; /* HP 2100 simulator release number */
const char *sim_vm_release_message =
const char *hp_vm_release = "29"; /* HP 2100 simulator release number */
const char *hp_vm_release_message =
"This is the last version of this simulator which is API compatible\n"
"with the 4.x version of the simh framework. A supported version of\n"
"this simulator can be found at: http://simh.trailing-edge.com/hp\n";
@@ -1868,7 +1868,7 @@ static DEVICE poll_dev = {
/* System interface local SCP support routines */
static void one_time_init (void);
void hp_one_time_init (void);
static t_bool fprint_stopped (FILE *st, t_stat reason);
static void fprint_addr (FILE *st, DEVICE *dptr, t_addr addr);
static t_addr parse_addr (DEVICE *dptr, CONST char *cptr, CONST char **tptr);
@@ -1934,8 +1934,6 @@ char sim_name [] = "HP 2100"; /* the simulator name */
int32 sim_emax = MAX_INSTR_LENGTH; /* the maximum number of words in any instruction */
void (*sim_vm_init) (void) = &one_time_init; /* a pointer to the one-time initializer */
DEVICE *sim_devices [] = { /* an array of pointers to the simulated devices */
&cpu_dev, /* CPU (must be first) */
&dma1_dev, &dma2_dev, /* DMA/DCPC */
@@ -3503,9 +3501,17 @@ return;
breakpoint types.
*/
static void one_time_init (void)
void hp_one_time_init (void)
{
CTAB *systab, *auxtab = aux_cmds;
static int inited = 0;
if (inited == 1) /* Be sure to only do these things once */
return;
inited = 1;
sim_vm_release = hp_vm_release;
sim_vm_release_message = hp_vm_release_message;
while (auxtab->name != NULL) { /* loop through the auxiliary command table */
systab = find_cmd (auxtab->name); /* find the corresponding system command table entry */