PDP11: Fix to correctly set PS value on CPU reset to reflect the model specific ways real hardware behaved. (from Bob Supnik)

Here's a PDP11 SIMH bug as old as the simulator itself: the reset_cpu routine sets the PS to 340 (interrupts disabled). This causes some versions of Lunar Lander not to work. In fact, the initial state of the PS is not architecturally standardized:

      04: cleared (from schematics)
      05: cleared (from manual)
      20: cleared (from schematics)
      34: cleared (from schematics), set to 340 on boot?
      40: cleared (from schematics)
      44: cleared on init, set to 340 on boot (from schematics, manual)
      45: cleared (from schematics)
      60: cleared (from schematics)
      70: cleared (from schematics)
      T11: set to 340 (from spec)
      LSI11, F11: 4 mode behavior (from memory on power recovery, cleared on GO, 340 on boot, mode 3 undefined)
      J11: 4 mode behavior (from memory on power recovery, cleared on GO, 340 on boot, 340 on jump to  custom PROM)

The story seems to be this. All non-VLSI PDP11s used TTL chips to implement the PS, either discrete flip-flops, or 4b registers, or both.
Starting with the first system, the 11/20, they were wired clear on the processor INIT signal (power-up or front panel START switch), so that all internal state started as 0. This worked fine, because START also reset the Unibus and cleared all interrupt enables. So even though the processor was as IPL = 0, no interrupts were possible. Then along came the LSI11...

The LSI11 implemented a line-time clock with NO INTERRUPT DISABLE. Thus, if IPL was left at 0 and a bootstrap routine from a slow device was started (e.g., a floppy drive), the clock would tick, and an interrupt would occur, before the bootstrap routine finished. Because no vectors were set up, the processor would crash. So the LSI11 started the practice, carried over to all later PDP11 VLSI chips, of setting the PS to 340 before jumping to a boot ROM.

The T11 did this in all modes of startup, because its only startup behavior was to jump to a "boot" routine. It did not have a console of any kind.

Accordingly, it appears that the cpu_reset routine needs to set the PS based on the processor model. Further, all boot routines need to set the PS to 0 or 340 based on the processor model. (It's probably safe for boot routines just to set the PS to 340, but it's not technically
accurate.)
This commit is contained in:
Mark Pizzolato 2013-10-27 05:30:13 -07:00
parent c8ae76cb65
commit f0d41f15d7
16 changed files with 55 additions and 39 deletions

View file

@ -25,6 +25,7 @@
cpu PDP-11 CPU
23-Oct-13 RMS Fixed PS behavior on initialization and boot
10-Apr-13 RMS MMR1 does not track PC changes (Johnny Billquist)
29-Apr-12 RMS Fixed compiler warning (Mark Pizzolato)
19-Mar-12 RMS Fixed declaration of sim_switches (Mark Pizzolato)
@ -2992,7 +2993,9 @@ t_stat cpu_reset (DEVICE *dptr)
{
PIRQ = 0;
STKLIM = 0;
PSW = 000340;
if (CPUT (CPUT_T)) /* T11? */
PSW = 000340; /* start at IPL 7 */
else PSW = 0; /* else at IPL 0 */
MMR0 = 0;
MMR1 = 0;
MMR2 = 0;
@ -3012,6 +3015,15 @@ set_r_display (0, MD_KER);
return SCPE_OK;
}
/* Boot setup routine */
void cpu_set_boot (int32 pc)
{
saved_PC = pc;
PSW = 000340;
return;
}
/* Memory examine */
t_stat cpu_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw)

View file

@ -26,6 +26,7 @@
The author gratefully acknowledges the help of Max Burnet, Megan Gentry,
and John Wilson in resolving questions about the PDP-11
23-Oct-13 RMS Added cpu_set_boot prototype
02-Sep-13 RMS Added third Massbus adapter and RS drive
11-Dec-11 RMS Fixed priority of PIRQ vs IO; added INT_INTERNALn
22-May-10 RMS Added check for 64b definitions
@ -801,6 +802,8 @@ void mba_set_don (uint32 mbus);
void mba_set_enbdis (uint32 mb, t_bool dis);
t_stat mba_show_num (FILE *st, UNIT *uptr, int32 val, void *desc);
void cpu_set_boot (int32 pc);
#include "pdp11_io_lib.h"
#endif

View file

@ -25,6 +25,7 @@
hk RK611/RK06/RK07 disk
23-Oct-13 RMS Revised for new boot setup routine
01-Sep-13 RMS Revised error handling to command-response model
Revised interrupt logic to follow the hardware
10-Jun-13 RMS Fixed bug to write through end of sector (Oleg Safiullin)
@ -1612,13 +1613,12 @@ static const uint16 boot_rom[] = {
t_stat hk_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & CS2_M_UNIT;
M[BOOT_CSR >> 1] = hk_dib.ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -25,6 +25,7 @@
rf RF11 fixed head disk
23-Oct-13 RMS Revised for new boot setup routine
03-Sep-13 RMS Added explicit void * cast
19-Mar-12 RMS Fixed bug in updating mem addr extension (Peter Schorn)
25-Dec-06 RMS Fixed bug in unit mask (John Dundas)
@ -468,12 +469,11 @@ static const uint16 boot_rom[] = {
t_stat rf_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_CSR >> 1] = (rf_dib.ba & DMASK) + 012;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_rl.c: RL11 (RLV12) cartridge disk simulator
Copyright (c) 1993-2008, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
rl RL11(RLV12)/RL01/RL02 cartridge disk
23-Oct-13 RMS Revised for new boot setup routine
24-Mar-11 JAD Various changes to support diagnostics, including:
- distinguish between RLV11 & 12
- more complete drive state
@ -1212,13 +1213,12 @@ t_stat rl_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern uint16 *M;
extern int32 saved_PC;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & RLCS_M_DRIVE;
M[BOOT_CSR >> 1] = rl_dib.ba & 0177777;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_rp.c - RP04/05/06/07 RM02/03/05/80 Massbus disk controller
Copyright (c) 1993-2008, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
rp RH/RP/RM moving head disks
23-Oct-13 RMS Revised for new boot setup routine
06-Mar-11 MP Converted to using sim_disk library and refactored
for Asynch I/O.
Set STIME value to default of 26 which allows VMS V4.x
@ -1469,7 +1470,6 @@ static const uint16 boot_rom[] = {
t_stat rp_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
UNIT *uptr = dptr->units + unitno;
@ -1480,7 +1480,7 @@ M[BOOT_CSR >> 1] = mba_get_csr (rp_dib.ba) & DMASK;
if (drv_tab[GET_DTYPE (uptr->flags)].ctrl == RP_CTRL)
M[BOOT_START >> 1] = 042102; /* "BD" */
else M[BOOT_START >> 1] = 042122; /* "RD" */
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_rq.c: MSCP disk controller simulator
Copyright (c) 2002-2010, Robert M Supnik
Copyright (c) 2002-2013, Robert M Supnik
Derived from work by Stephen F. Shirron
Permission is hereby granted, free of charge, to any person obtaining a
@ -26,6 +26,7 @@
rq MSCP disk controller
23-Oct-13 RMS Revised for new boot setup routine
09-Dec-12 MB Added support for changing controller type.
24-Oct-12 MB Added mapped transfers for VAX
29-Jan-11 HUH Added RC25, RCF25 and RA80 disks
@ -2933,7 +2934,6 @@ static const uint16 boot_rom[] = {
t_stat rq_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
DIB *dibp = (DIB *) dptr->ctxt;
@ -2941,7 +2941,7 @@ for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & 3;
M[BOOT_CSR >> 1] = dibp->ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -24,6 +24,8 @@
in this Software without prior written authorization from Robert M Supnik.
rs RS03/RS04 fixed head disks
23-Oct-13 RMS Revised for new boot setup routine
*/
#if defined (VM_PDP10)
@ -686,8 +688,7 @@ static const uint16 boot_rom[] = {
t_stat rs_boot (int32 unitno, DEVICE *dptr)
{
int32 i;
extern int32 saved_PC;
size_t i;
extern uint16 *M;
UNIT *uptr = rs_dev.units + unitno;
@ -695,7 +696,7 @@ for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & (RS_NUMDR - 1);
M[BOOT_CSR >> 1] = mba_get_csr (rs_dib.ba) & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -25,6 +25,7 @@
rx RX11/RX01 floppy disk
23-Oct-13 RMS Revised for new boot setup routine
03-Sep-13 RMS Added explicit void * cast
07-Jul-05 RMS Removed extraneous externs
12-Oct-02 RMS Added autoconfigure support
@ -526,13 +527,12 @@ static const uint16 boot_rom[] = {
t_stat rx_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & RX_M_NUMDR;
M[BOOT_CSR >> 1] = rx_dib.ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -25,6 +25,7 @@
ry RX211/RXV21/RX02 floppy disk
23-Oct-13 RMS Revised for new boot setup routine
03-Sep-13 RMS Added explicit void * cast
15-May-06 RMS Fixed bug in autosize attach (David Gesswein)
07-Jul-05 RMS Removed extraneous externs
@ -692,7 +693,6 @@ static const uint16 boot_rom[] = {
t_stat ry_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
if ((ry_unit[unitno & RX_M_NUMDR].flags & UNIT_DEN) == 0)
@ -701,7 +701,7 @@ for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & RX_M_NUMDR;
M[BOOT_CSR >> 1] = ry_dib.ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -25,6 +25,7 @@
ta TA11/TU60 cassette tape
23-Oct-13 RMS Revised for new boot setup routine
06-Jun-13 RMS Reset must set RDY (Ian Hammond)
Added CAPS-11 bootstrap (Ian Hammond)
06-Aug-07 RMS Foward op at BOT skips initial file gap
@ -660,14 +661,13 @@ static const uint16 boot_rom[] = {
t_stat ta_boot (int32 unitno, DEVICE *dptr)
{
int32 i;
extern int32 saved_PC;
size_t i;
extern uint16 *M;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_CSR >> 1] = ta_dib.ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_tc.c: PDP-11 DECtape simulator
Copyright (c) 1993-2008, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
tc TC11/TU56 DECtape
23-Oct-13 RMS Revised for new boot setup routine
23-Jun-06 RMS Fixed switch conflict in ATTACH
10-Feb-06 RMS READ sets extended data bits in TCST (Alan Frisbie)
16-Aug-05 RMS Fixed C++ declaration and cast problems
@ -1188,14 +1189,13 @@ static const uint16 boot_rom[] = {
t_stat dt_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
dt_unit[unitno].pos = DT_EZLIN;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & DT_M_NUMDR;
M[BOOT_CSR >> 1] = (dt_dib.ba & DMASK) + 02;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_tm.c: PDP-11 magnetic tape simulator
Copyright (c) 1993-2008, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
tm TM11/TU10 magtape
23-Oct-13 RMS Revised for new boot setup routine
16-Feb-06 RMS Added tape capacity checking
31-Oct-05 RMS Fixed address width for large files
16-Aug-05 RMS Fixed C++ declaration and cast problems
@ -719,7 +720,6 @@ static const uint16 boot2_rom[] = {
t_stat tm_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
sim_tape_rewind (&tm_unit[unitno]);
if (sim_switches & SWMASK ('O')) {
@ -732,7 +732,7 @@ else {
}
M[BOOT_UNIT >> 1] = unitno;
M[BOOT_CSR >> 1] = (tm_dib.ba & DMASK) + 06;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_tq.c: TMSCP tape controller simulator
Copyright (c) 2002-2011, Robert M Supnik
Copyright (c) 2002-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
tq TQK50 tape controller
23-Oct-13 RMS Revised for new boot setup routine
23-Jan-12 MP Added missing support for Logical EOT detection while
positioning.
17-Aug-11 RMS Added CAPACITY modifier
@ -2208,14 +2209,13 @@ static const uint16 boot_rom[] = {
t_stat tq_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & 3;
M[BOOT_CSR >> 1] = tq_dib.ba & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_ts.c: TS11/TSV05 magnetic tape simulator
Copyright (c) 1993-2012, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
ts TS11/TSV05 magtape
23-Oct-13 RMS Revised for new boot setup routine
19-Mar-12 RMS Fixed declaration of cpu_opt (Mark Pizzolato)
22-May-10 RMS Fixed t_addr printouts for 64b big-endian systems
(Mark Pizzolato)
@ -1158,7 +1159,6 @@ static const uint16 boot_rom[] = {
t_stat ts_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
sim_tape_rewind (&ts_unit);
@ -1166,7 +1166,7 @@ for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_CSR0 >> 1] = ts_dib.ba & DMASK;
M[BOOT_CSR1 >> 1] = (ts_dib.ba & DMASK) + 02;
saved_PC = BOOT_START;
cpu_set_boot (BOOT_START);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp11_tu.c - PDP-11 TM02/TU16 TM03/TU45/TU77 Massbus magnetic tape controller
Copyright (c) 1993-2012, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
tu TM02/TM03 magtape
23-Oct-13 RMS Revised for new boot setup routine
18-Apr-11 MP Fixed t_addr printouts for 64b big-endian systems
17-May-07 RMS CS1 DVA resides in device, not MBA
29-Apr-07 RMS Fixed bug in setting FCE on TMK Naoki Hamada)
@ -1045,14 +1046,13 @@ static const uint16 boot_rom[] = {
t_stat tu_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 *M;
for (i = 0; i < BOOT_LEN; i++)
M[(BOOT_START >> 1) + i] = boot_rom[i];
M[BOOT_UNIT >> 1] = unitno & (TU_NUMDR - 1);
M[BOOT_CSR >> 1] = mba_get_csr (tu_dib.ba) & DMASK;
saved_PC = BOOT_ENTRY;
cpu_set_boot (BOOT_ENTRY);
return SCPE_OK;
}