Fixed RL11 disk memory access (addresses are always mapped, apparently)

This commit is contained in:
Jeff Parsons 2016-11-29 17:10:37 -08:00 committed by Jeff Parsons
commit a06a4c9324
7 changed files with 355 additions and 348 deletions

View file

@ -1520,28 +1520,22 @@ CPUStatePDP11.prototype.getTrapStatus = function()
*/
CPUStatePDP11.prototype.mapUnibus = function(addr)
{
/*
* NOTE: Most callers check the first condition themselves (addr >= BusPDP11.UNIBUS_22BIT) to avoid
* making unnecessary function calls.
*/
if (addr >= BusPDP11.UNIBUS_22BIT) {
var idx = (addr >> 13) & 0x1f;
if (idx < 31) {
if (this.regMMR3 & PDP11.MMR3.UNIBUS_MAP) {
/*
* The UNIBUS map relocation is enabled
*/
addr = (this.regsUniMap[idx] + (addr & 0x1ffe)) & 0x3ffffe;
this.assert(addr < BusPDP11.UNIBUS_22BIT || addr >= BusPDP11.IOPAGE_22BIT);
} else {
/*
* Since UNIBUS map relocation is NOT enabled, then as explained above:
*
* If the UNIBUS map relocation is not enabled, an incoming 18-bit UNIBUS address has 4 leading zeroes added for
* referencing a 22-bit physical address. The lower 18 bits are the same. No relocation is performed.
*/
addr &= ~BusPDP11.UNIBUS_22BIT;
}
var idx = (addr >> 13) & 0x1f;
if (idx < 31) {
if (this.regMMR3 & PDP11.MMR3.UNIBUS_MAP) {
/*
* The UNIBUS map relocation is enabled
*/
addr = (this.regsUniMap[idx] + (addr & 0x1ffe)) & 0x3ffffe;
this.assert(addr < BusPDP11.UNIBUS_22BIT || addr >= BusPDP11.IOPAGE_22BIT);
} else {
/*
* Since UNIBUS map relocation is NOT enabled, then as explained above:
*
* If the UNIBUS map relocation is not enabled, an incoming 18-bit UNIBUS address has 4 leading zeroes added for
* referencing a 22-bit physical address. The lower 18 bits are the same. No relocation is performed.
*/
addr &= ~BusPDP11.UNIBUS_22BIT;
}
}
return addr;

View file

@ -42,6 +42,7 @@ if (DEBUGGER) {
var Keys = require("../../shared/lib/keys");
var State = require("../../shared/lib/state");
var PDP11 = require("./defines");
var BusPDP11 = require("./bus");
var CPUPDP11 = require("./cpu");
var MemoryPDP11 = require("./memory");
var MessagesPDP11 = require("./messages");
@ -644,6 +645,18 @@ if (DEBUGGER) {
return addr;
};
/**
* mapUnibus(addr)
*
* @this {DebuggerPDP11}
* @param {number} addr
* @return {number}
*/
DebuggerPDP11.prototype.mapUnibus = function(addr)
{
return (addr >= BusPDP11.UNIBUS_22BIT)? this.cpu.mapUnibus(addr) : addr;
};
/**
* getByte(dbgAddr, inc)
*
@ -659,7 +672,7 @@ if (DEBUGGER) {
var b = 0xff;
var addr = this.getAddr(dbgAddr, false, 1);
if (addr !== PDP11.ADDR_INVALID) {
b = (dbgAddr.fPhysical || addr > 0xffff)? this.bus.getByteDirect(this.cpu.mapUnibus(addr)) : this.cpu.getByteSafe(addr);
b = (dbgAddr.fPhysical || addr > 0xffff)? this.bus.getByteDirect(this.mapUnibus(addr)) : this.cpu.getByteSafe(addr);
if (inc) this.incAddr(dbgAddr, inc);
}
return b;
@ -678,7 +691,7 @@ if (DEBUGGER) {
var w = 0xffff;
var addr = this.getAddr(dbgAddr, false, 2);
if (addr !== PDP11.ADDR_INVALID) {
w = (dbgAddr.fPhysical || addr > 0xffff)? this.bus.getWordDirect(this.cpu.mapUnibus(addr)) : this.cpu.getWordSafe(addr);
w = (dbgAddr.fPhysical || addr > 0xffff)? this.bus.getWordDirect(this.mapUnibus(addr)) : this.cpu.getWordSafe(addr);
if (inc) this.incAddr(dbgAddr, inc);
}
return w;
@ -697,7 +710,7 @@ if (DEBUGGER) {
var addr = this.getAddr(dbgAddr, true, 1);
if (addr !== PDP11.ADDR_INVALID) {
if (dbgAddr.fPhysical || addr > 0xffff) {
this.bus.setByteDirect(this.cpu.mapUnibus(addr), b);
this.bus.setByteDirect(this.mapUnibus(addr), b);
} else {
this.cpu.setByteSafe(addr, b);
}
@ -719,7 +732,7 @@ if (DEBUGGER) {
var addr = this.getAddr(dbgAddr, true, 2);
if (addr !== PDP11.ADDR_INVALID) {
if (dbgAddr.fPhysical || addr > 0xffff) {
this.bus.setWordDirect(this.cpu.mapUnibus(addr), w);
this.bus.setWordDirect(this.mapUnibus(addr), w);
} else {
this.cpu.setWordSafe(addr, w);
}

View file

@ -933,7 +933,7 @@ RK11.prototype.processCommand = function()
nWords = (0x10000 - this.wcr) & 0xffff;
if (DEBUG && this.messageEnabled(MessagesPDP11.READ)) {
var pos = ((((iCylinder << 1) + iHead) * drive.nSectors) + iSector) * 256;
this.printMessage((fnReadWrite == this.readData? "readData" : "writeData") + "(pos=" + pos + ",addr=" + str.toOct(addr) + ",bytes=" + (nWords * 2) + ")", true, true);
console.log((fnReadWrite == this.readData? "readData" : "writeData") + "(pos=" + pos + ",addr=" + str.toOct(addr) + ",bytes=" + (nWords * 2) + ")", true, true);
}
fInterrupt = fnReadWrite.call(this, drive, iCylinder, iHead, iSector, nWords, addr, this.endReadWrite.bind(this));
break;
@ -1017,11 +1017,12 @@ RK11.prototype.readData = function(drive, iCylinder, iHead, iSector, nWords, add
err = PDP11.RK11.RKER.NXS;
break;
}
this.bus.setWordDirect(this.cpu.mapUnibus(addr), data = b0 | (b1 << 8));
this.bus.setWordDirect(addr, data = b0 | (b1 << 8));
if (DEBUG && this.messageEnabled(MessagesPDP11.READ)) {
if (!sWords) sWords = str.toOct(addr) + ": ";
sWords += str.toOct(data) + ' ';
if (sWords.length >= 56) {
this.printMessage(sWords + '\n', true);
if (sWords.length >= 64) {
console.log(sWords);
sWords = "";
}
}
@ -1072,7 +1073,7 @@ RK11.prototype.writeData = function(drive, iCylinder, iHead, iSector, nWords, ad
}
while (nWords--) {
var data = this.bus.getWordDirect(this.cpu.mapUnibus(addr));
var data = this.bus.getWordDirect(addr);
if (this.bus.checkFault()) {
err = PDP11.RK11.RKER.NXM;
break;

View file

@ -958,7 +958,7 @@ RL11.prototype.processCommand = function()
nWords = (0x10000 - this.mpr) & 0xffff;
var pos = ((((iCylinder << 1) + iHead) * drive.nSectors) + iSector) * 128;
if (DEBUG && this.messageEnabled(MessagesPDP11.READ)) {
this.printMessage((fnReadWrite == this.readData? "readData" : "writeData") + "(pos=" + pos + ",addr=" + str.toOct(addr) + ",bytes=" + (nWords * 2) + ")", true, true);
console.log((fnReadWrite == this.readData? "readData" : "writeData") + "(pos=" + pos + ",addr=" + str.toOct(addr) + ",bytes=" + (nWords * 2) + ")");
}
fInterrupt = fnReadWrite.call(this, drive, pos, iCylinder, iHead, iSector, nWords, addr, this.endReadWrite.bind(this));
break;
@ -1025,7 +1025,7 @@ RL11.prototype.readData = function(drive, pos, iCylinder, iHead, iSector, nWords
nWords = 0;
}
var sWords = "", fDump = (addr == 0);
var sWords = "";
while (nWords--) {
if (!sector) {
sector = drive.disk.seek(iCylinder, iHead, iSector + 1);
@ -1041,10 +1041,11 @@ RL11.prototype.readData = function(drive, pos, iCylinder, iHead, iSector, nWords
break;
}
this.bus.setWordDirect(this.cpu.mapUnibus(addr), data = b0 | (b1 << 8));
if (DEBUG && fDump && this.messageEnabled(MessagesPDP11.READ)) {
if (MAXDEBUG && this.messageEnabled(MessagesPDP11.READ)) {
if (!sWords) sWords = str.toOct(addr) + ": ";
sWords += str.toOct(data) + ' ';
if (sWords.length >= 56) {
this.println(sWords);
if (sWords.length >= 64) {
console.log(sWords);
sWords = "";
}
}
@ -1070,10 +1071,7 @@ RL11.prototype.readData = function(drive, pos, iCylinder, iHead, iSector, nWords
}
if (DEBUG && this.messageEnabled(MessagesPDP11.READ)) {
this.printMessage("checksum: " + (checksum|0), true);
if (pos == 732160) {
this.cpu.stopCPU();
}
console.log("checksum: " + (checksum|0));
}
return done(err, iCylinder, iHead, iSector, nWords, addr);
@ -1105,17 +1103,18 @@ RL11.prototype.writeData = function(drive, pos, iCylinder, iHead, iSector, nWord
nWords = 0;
}
var sWords = "", fDump = (pos = 946944);
var sWords = "";
while (nWords--) {
var data = this.bus.getWordDirect(this.cpu.mapUnibus(addr));
if (this.bus.checkFault()) {
err = PDP11.RL11.ERRC.NXM;
break;
}
if (DEBUG && fDump && this.messageEnabled(MessagesPDP11.READ)) {
if (MAXDEBUG && this.messageEnabled(MessagesPDP11.READ)) {
if (!sWords) sWords = str.toOct(addr) + ": ";
sWords += str.toOct(data) + ' ';
if (sWords.length >= 56) {
this.println(sWords);
if (sWords.length >= 64) {
console.log(sWords);
sWords = "";
}
}
@ -1149,7 +1148,7 @@ RL11.prototype.writeData = function(drive, pos, iCylinder, iHead, iSector, nWord
}
if (DEBUG && this.messageEnabled(MessagesPDP11.READ)) {
this.printMessage("checksum: " + (checksum|0), true);
console.log("checksum: " + (checksum|0));
}
return done(err, iCylinder, iHead, iSector, nWords, addr);