From 2b8ea8ddee524a32ebfc32bede06ab7fbf11a5b6 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sat, 3 Dec 2016 16:12:25 -0800 Subject: [PATCH] Fixed conditions required for RSTS/E boot code to work --- modules/pdp11/lib/cpustate.js | 10 +++++++++- modules/pdp11/lib/debugger.js | 4 ++-- modules/pdp11/lib/rk11.js | 18 ++++++++++++------ modules/pdp11/lib/rl11.js | 22 ++++++++++++++-------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/modules/pdp11/lib/cpustate.js b/modules/pdp11/lib/cpustate.js index 719962c81..2bfe83c57 100644 --- a/modules/pdp11/lib/cpustate.js +++ b/modules/pdp11/lib/cpustate.js @@ -496,7 +496,14 @@ CPUStatePDP11.prototype.setReset = function(addr, fStart) this.setPSW(0); if (fStart) { - this.autoStart(); + /* + * TODO: Review. I'm zeroing R2-R5 in the fStart case (ie, for boot code) simply because that's what I + * saw the PDP-11 Boot Monitor doing (see /apps/pdp11/boot/monitor/BOOTMON.mac). + */ + for (var i = 2; i <= 5; i++) { + this.regsGen[i] = 0; + } + if (!this.isRunning()) this.startCPU(); } else { if (this.dbg) { @@ -515,6 +522,7 @@ CPUStatePDP11.prototype.setReset = function(addr, fStart) this.stopCPU(); } } + if (!this.isRunning() && this.panel) this.panel.stop(); }; /** diff --git a/modules/pdp11/lib/debugger.js b/modules/pdp11/lib/debugger.js index 08dbff12f..3cf692060 100644 --- a/modules/pdp11/lib/debugger.js +++ b/modules/pdp11/lib/debugger.js @@ -1437,7 +1437,7 @@ if (DEBUGGER) { * is calling us in a loop, in which case it will perform its own updateDisplays() when it's done. */ if (fUpdateDisplays !== false) { - if (this.panel && this.panel.stop) this.panel.stop(); + if (this.panel) this.panel.stop(); this.cmp.updateDisplays(-1); } @@ -3924,7 +3924,7 @@ if (DEBUGGER) { * displayLiveRegs enabled, so once the repeat count has been exhausted, we must perform * a final updateDisplays(). */ - if (dbg.panel && dbg.panel.stop) dbg.panel.stop(); + if (dbg.panel) dbg.panel.stop(); dbg.cmp.updateDisplays(-1); dbg.setBusy(false); } diff --git a/modules/pdp11/lib/rk11.js b/modules/pdp11/lib/rk11.js index 34daa709f..478fc4f26 100644 --- a/modules/pdp11/lib/rk11.js +++ b/modules/pdp11/lib/rk11.js @@ -133,7 +133,7 @@ RK11.prototype.setBinding = function(sType, sBinding, control, sValue) control.onchange = function onChangeListDisks(event) { var controlDesc = rk11.bindings["descDisk"]; - var controlOption = control.options[control.selectedIndex]; + var controlOption = control.options && control.options[control.selectedIndex]; if (controlDesc && controlOption) { var dataValue = {}; var sValue = controlOption.getAttribute("data-value"); @@ -172,7 +172,7 @@ RK11.prototype.setBinding = function(sType, sBinding, control, sValue) control.onclick = function onClickLoadDrive(event) { var controlDisks = rk11.bindings["listDisks"]; - if (controlDisks) { + if (controlDisks && controlDisks.options) { var sDiskName = controlDisks.options[controlDisks.selectedIndex].text; var sDiskPath = controlDisks.value; rk11.loadSelectedDrive(sDiskName, sDiskPath); @@ -561,15 +561,21 @@ RK11.prototype.bootSelectedDisk = function() return; } if (!drive.disk) { - this.notice("No disk loaded in the selected drive"); + this.notice("Load a disk into the drive first"); return; } - var err = this.readData(drive, 0, 0, 0, drive.cbSector >> 1, 0); + /* + * NOTE: We're calling setReset() BEFORE reading the boot code in order to eliminate any side-effects + * of the previous state of either the controller OR the CPU; for example, we don't want any previous MMU + * or UNIBUS Map registers affecting the simulated readData() call. Also, some boot code (eg, RSTS/E) + * expects the controller to be in a READY state; since setReset() triggers a call to our reset() handler, + * a READY state is assured, and the readData() call shouldn't do anything to change that. + */ + this.cpu.setReset(0, true); + var err = this.readData(drive, 0, 0, 0, 512, 0); if (err) { this.notice("Unable to read the boot sector (" + err + ")"); - return; } - this.cpu.setReset(0, true); }; /** diff --git a/modules/pdp11/lib/rl11.js b/modules/pdp11/lib/rl11.js index 1a29c8259..567d32362 100644 --- a/modules/pdp11/lib/rl11.js +++ b/modules/pdp11/lib/rl11.js @@ -135,7 +135,7 @@ RL11.prototype.setBinding = function(sType, sBinding, control, sValue) control.onchange = function onChangeListDisks(event) { var controlDesc = rl11.bindings["descDisk"]; - var controlOption = control.options[control.selectedIndex]; + var controlOption = control.options && control.options[control.selectedIndex]; if (controlDesc && controlOption) { var dataValue = {}; var sValue = controlOption.getAttribute("data-value"); @@ -174,7 +174,7 @@ RL11.prototype.setBinding = function(sType, sBinding, control, sValue) control.onclick = function onClickLoadDrive(event) { var controlDisks = rl11.bindings["listDisks"]; - if (controlDisks) { + if (controlDisks && controlDisks.options) { var sDiskName = controlDisks.options[controlDisks.selectedIndex].text; var sDiskPath = controlDisks.value; rl11.loadSelectedDrive(sDiskName, sDiskPath); @@ -563,15 +563,21 @@ RL11.prototype.bootSelectedDisk = function() return; } if (!drive.disk) { - this.notice("No disk loaded in the selected drive"); + this.notice("Load a disk into the drive first"); return; } - var err = this.readData(drive, 0, 0, 0, drive.cbSector >> 1, 0); + /* + * NOTE: We're calling setReset() BEFORE reading the boot code in order to eliminate any side-effects + * of the previous state of either the controller OR the CPU; for example, we don't want any previous MMU + * or UNIBUS Map registers affecting the simulated readData() call. Also, some boot code (eg, RSTS/E) + * expects the controller to be in a READY state; since setReset() triggers a call to our reset() handler, + * a READY state is assured, and the readData() call shouldn't do anything to change that. + */ + this.cpu.setReset(0, true); + var err = this.readData(drive, 0, 0, 0, 512, 0); if (err) { this.notice("Unable to read the boot sector (" + err + ")"); - return; } - this.cpu.setReset(0, true); }; /** @@ -862,7 +868,7 @@ RL11.prototype.initController = function(data) { var i = 0; if (!data) data = []; - this.regRLCS = data[i++] || 0; + this.regRLCS = data[i++] || (PDP11.RL11.RLCS.DRDY | PDP11.RL11.RLCS.CRDY); this.regRLBA = data[i++] || 0; this.regRLDA = data[i++] || 0; this.tmpRLDA = data[i++] || 0; @@ -958,7 +964,7 @@ RL11.prototype.processCommand = function() * * 1) Normally both set * 2) CRDY is cleared to process a command - * 3) DRDY is cleared to command is in process + * 3) DRDY is cleared to indicate a command in process */ this.regRLCS &= ~PDP11.RL11.RLCS.DRDY;