From a13bb9348adcf71489edf684f5aa5f2337a39f35 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 22 Sep 2016 08:21:28 -0700 Subject: [PATCH] Bus-related defines moved to the Bus component --- modules/pdp11/lib/bus.js | 11 ++++----- modules/pdp11/lib/cpustate.js | 43 ++++++++++++++++++----------------- modules/pdp11/lib/defines.js | 7 ------ modules/pdp11/lib/device.js | 6 ++--- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/modules/pdp11/lib/bus.js b/modules/pdp11/lib/bus.js index 77ca506df..43f79c0bc 100644 --- a/modules/pdp11/lib/bus.js +++ b/modules/pdp11/lib/bus.js @@ -118,8 +118,7 @@ function BusPDP11(parmsBus, cpu, dbg) * component for details. * * UPDATE: The Debugger wants to piggy-back on these arrays to indicate addresses for which it wants - * notification. In those cases, the registered component/function elements may or may not be set, - * but the following additional element will be set: + * notification. In those cases, the following additional element will be set: * * [4]: true to break on I/O, false to ignore I/O * @@ -154,9 +153,7 @@ BusPDP11.MAX_ADDRESS = 0x400000; /*020000000*/ // Register addr BusPDP11.ERROR = { RANGE_INUSE: 1, RANGE_INVALID: 2, - NO_CONTROLLER: 3, - SETACC_INVALID: 4, - REMOVE_INVALID: 5 + NO_CONTROLLER: 3 }; /* @@ -603,7 +600,7 @@ BusPDP11.prototype.removeMemory = function(addr, size) } return true; } - return this.reportError(BusPDP11.ERROR.REMOVE_INVALID, addr, size); + return this.reportError(BusPDP11.ERROR.RANGE_INVALID, addr, size); }; /** @@ -654,7 +651,7 @@ BusPDP11.prototype.setMemoryAccess = function(addr, size, afn, fQuiet) } return true; } - return this.reportError(BusPDP11.ERROR.SETACC_INVALID, addr, size); + return this.reportError(BusPDP11.ERROR.RANGE_INVALID, addr, size); }; /** diff --git a/modules/pdp11/lib/cpustate.js b/modules/pdp11/lib/cpustate.js index 19b35325b..d33ef8002 100644 --- a/modules/pdp11/lib/cpustate.js +++ b/modules/pdp11/lib/cpustate.js @@ -39,6 +39,7 @@ if (NODE) { var Component = require("../../shared/lib/component"); var State = require("../../shared/lib/state"); var PDP11 = require("./defines"); + var BusPDP11 = require("./bus"); var CPUPDP11 = require("./cpu"); var MessagesPDP11 = require("./messages"); var MemoryPDP11 = require("./memory"); @@ -709,10 +710,10 @@ CPUStatePDP11.prototype.mapUnibus = function(unibusAddress) if (idx < 31) { if (this.MMR3 & 0x20) { unibusAddress = (this.unibusMap[idx] + (unibusAddress & 0x1ffe)) & 0x3ffffe; - if (unibusAddress >= PDP11.IOBASE_UNIBUS && unibusAddress < PDP11.IOBASE_22BIT) this.panic(898); + if (unibusAddress >= BusPDP11.IOPAGE_UNIBUS && unibusAddress < BusPDP11.IOPAGE_22BIT) this.panic(898); } } else { - unibusAddress |= PDP11.IOBASE_22BIT; + unibusAddress |= BusPDP11.IOPAGE_22BIT; } return unibusAddress; }; @@ -772,8 +773,8 @@ CPUStatePDP11.prototype.mapVirtualToPhysical = function(virtualAddress, accessMa if (!(accessMask & this.mmuEnable)) { physicalAddress = virtualAddress & 0xffff; // virtual address without MMU is 16 bit (no I&D) this.mmuLastVirtual = physicalAddress; - if (physicalAddress >= PDP11.IOBASE_VIRT) { - physicalAddress |= PDP11.IOBASE_22BIT; + if (physicalAddress >= BusPDP11.IOPAGE_VIRT) { + physicalAddress |= BusPDP11.IOPAGE_22BIT; } else { // no max_memory check in 16 bit mode if ((physicalAddress & 1) && !(accessMask & PDP11.BYTE_MODE)) { this.CPU_Error |= 0x40; @@ -787,15 +788,15 @@ CPUStatePDP11.prototype.mapVirtualToPhysical = function(virtualAddress, accessMa pdr = this.mmuMap[this.mmuMode][page]; physicalAddress = ((this.mmuMap[this.mmuMode][page + 16] << 6) + (virtualAddress & 0x1fff)) & 0x3fffff; if (this.MMR3 & 0x10) { // if 22 bit MM mode - if (physicalAddress >= PDP11.IOBASE_UNIBUS && physicalAddress < PDP11.IOBASE_22BIT) { + if (physicalAddress >= BusPDP11.IOPAGE_UNIBUS && physicalAddress < BusPDP11.IOPAGE_22BIT) { physicalAddress = this.mapUnibus(physicalAddress & 0x3ffff); // 18bit unibus space } } else { physicalAddress &= 0x3ffff; // truncate if only 18 bit mapping - if (physicalAddress >= PDP11.IOBASE_18BIT) physicalAddress |= PDP11.IOBASE_22BIT; + if (physicalAddress >= BusPDP11.IOPAGE_18BIT) physicalAddress |= BusPDP11.IOPAGE_22BIT; } - if (physicalAddress < PDP11.IOBASE_UNIBUS) { - if (physicalAddress >= PDP11.MAX_MEMORY) { + if (physicalAddress < BusPDP11.IOPAGE_UNIBUS) { + if (physicalAddress >= BusPDP11.MAX_MEMORY) { this.CPU_Error |= 0x20; return this.trap(4, 24); // KB11-EM does this after ABORT handling - KB11-CM before } @@ -880,10 +881,10 @@ CPUStatePDP11.prototype.mapVirtualToPhysical = function(virtualAddress, accessMa */ CPUStatePDP11.prototype.readWordByAddr = function(physicalAddress) { - if (physicalAddress >= PDP11.MAX_ADDRESS) { - return this.regsGen[physicalAddress - PDP11.MAX_ADDRESS]; + if (physicalAddress >= BusPDP11.MAX_ADDRESS) { + return this.regsGen[physicalAddress - BusPDP11.MAX_ADDRESS]; } else { - // if (physicalAddress >= PDP11.IOBASE_UNIBUS) { + // if (physicalAddress >= BusPDP11.IOPAGE_UNIBUS) { // return this.bus.access_iopage(physicalAddress, -1, 0); // } else { if (physicalAddress >= 0) { @@ -905,10 +906,10 @@ CPUStatePDP11.prototype.readWordByAddr = function(physicalAddress) CPUStatePDP11.prototype.writeWordByAddr = function(physicalAddress, data) { data &= 0xffff; - if (physicalAddress >= PDP11.MAX_ADDRESS) { - return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] = data); + if (physicalAddress >= BusPDP11.MAX_ADDRESS) { + return (this.regsGen[physicalAddress - BusPDP11.MAX_ADDRESS] = data); } else { - // if (physicalAddress >= PDP11.IOBASE_UNIBUS) { + // if (physicalAddress >= BusPDP11.IOPAGE_UNIBUS) { // return this.bus.access_iopage(physicalAddress, data, 0); // } else { if (physicalAddress >= 0) { @@ -930,10 +931,10 @@ CPUStatePDP11.prototype.writeWordByAddr = function(physicalAddress, data) CPUStatePDP11.prototype.readByteByAddr = function(physicalAddress) { var result; - if (physicalAddress >= PDP11.MAX_ADDRESS) { - return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] & 0xff); + if (physicalAddress >= BusPDP11.MAX_ADDRESS) { + return (this.regsGen[physicalAddress - BusPDP11.MAX_ADDRESS] & 0xff); } else { - // if (physicalAddress >= PDP11.IOBASE_UNIBUS) { + // if (physicalAddress >= BusPDP11.IOPAGE_UNIBUS) { // return this.bus.access_iopage(physicalAddress, -1, 1); // } else { if (physicalAddress >= 0) { @@ -955,10 +956,10 @@ CPUStatePDP11.prototype.readByteByAddr = function(physicalAddress) CPUStatePDP11.prototype.writeByteByAddr = function(physicalAddress, data) { data &= 0xff; - if (physicalAddress >= PDP11.MAX_ADDRESS) { - return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] = (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] & 0xff00) | data); + if (physicalAddress >= BusPDP11.MAX_ADDRESS) { + return (this.regsGen[physicalAddress - BusPDP11.MAX_ADDRESS] = (this.regsGen[physicalAddress - BusPDP11.MAX_ADDRESS] & 0xff00) | data); } else { - // if (physicalAddress >= PDP11.IOBASE_UNIBUS) { + // if (physicalAddress >= BusPDP11.IOPAGE_UNIBUS) { // return this.bus.access_iopage(physicalAddress, data, 1); // } else { if (physicalAddress >= 0) { @@ -1169,7 +1170,7 @@ CPUStatePDP11.prototype.getAddrByMode = function(addressMode, accessMode) { var result; if (!(addressMode & 0x38)) { - return PDP11.MAX_ADDRESS + (addressMode & 7); // Registers have special addresses above maximum address + return BusPDP11.MAX_ADDRESS + (addressMode & 7); // Registers have special addresses above maximum address } else { if ((result = this.getVirtualByMode(addressMode, accessMode)) >= 0) { result = this.mapVirtualToPhysical(result, accessMode); diff --git a/modules/pdp11/lib/defines.js b/modules/pdp11/lib/defines.js index 772a79831..61465510c 100644 --- a/modules/pdp11/lib/defines.js +++ b/modules/pdp11/lib/defines.js @@ -183,13 +183,6 @@ var PDP11 = { // TODO }, - IOBASE_VIRT: 0x00E000, /*000160000*/ - IOBASE_18BIT: 0x03E000, /*000760000*/ - IOBASE_UNIBUS: 0x3C0000, /*017000000*/ - IOBASE_22BIT: 0x3FE000, /*017760000*/ - MAX_MEMORY: 0x3C0000 - 16384, // Maximum memory address (need less memory for BSD 2.9 boot) - MAX_ADDRESS: 0x400000, /*020000000*/ // Register addresses are above 22 bit addressing - BYTE_MODE: 1, READ_MODE: 2, WRITE_MODE: 4, diff --git a/modules/pdp11/lib/device.js b/modules/pdp11/lib/device.js index aa91d5596..3942b1fb5 100644 --- a/modules/pdp11/lib/device.js +++ b/modules/pdp11/lib/device.js @@ -636,10 +636,10 @@ DevicePDP11.prototype.mapUnibus = function(unibusAddress) if (idx < 31) { if (this.cpu.MMR3 & 0x20) { unibusAddress = (this.cpu.unibusMap[idx] + (unibusAddress & 0x1ffe)) & 0x3ffffe; - if (unibusAddress >= PDP11.IOBASE_UNIBUS && unibusAddress < PDP11.IOBASE_22BIT) this.cpu.panic(898); + if (unibusAddress >= BusPDP11.IOPAGE_UNIBUS && unibusAddress < BusPDP11.IOPAGE_22BIT) this.cpu.panic(898); } } else { - unibusAddress |= PDP11.IOBASE_22BIT; + unibusAddress |= BusPDP11.IOPAGE_22BIT; } return unibusAddress; }; @@ -916,7 +916,7 @@ DevicePDP11.prototype.access = function(physicalAddress, data, byteFlag) break; case 0x3FFFF0: /*017777760*/ // Lower size if (cpu.cpuType !== 70) return cpu.trap(4, 228); - result = (PDP11.MAX_MEMORY >> 6) - 1; + result = (BusPDP11.MAX_MEMORY >> 6) - 1; break; case 0x3FFFF8: /*017777770*/ // Microprogram break if (data >= 0 && !(physicalAddress & 1)) data &= 0xff; // Required for KB11-CM without MFPT instruction