Changed DMA, PIC and Timer initialization to reuse objects instead of reallocating them
This commit is contained in:
parent
99880e01da
commit
7737a9ca0a
1 changed files with 79 additions and 54 deletions
|
|
@ -397,7 +397,7 @@ ChipSet.DMA_MODE = {
|
||||||
MODE_CASCADE: 0xC0
|
MODE_CASCADE: 0xC0
|
||||||
};
|
};
|
||||||
|
|
||||||
ChipSet.DMA_REFRESH = 0x00; // DMA channel assigned to the Floppy Drive Controller (FDC)
|
ChipSet.DMA_REFRESH = 0x00; // DMA channel assigned to memory refresh
|
||||||
ChipSet.DMA_FDC = 0x02; // DMA channel assigned to the Floppy Drive Controller (FDC)
|
ChipSet.DMA_FDC = 0x02; // DMA channel assigned to the Floppy Drive Controller (FDC)
|
||||||
ChipSet.DMA_HDC = 0x03; // DMA channel assigned to the Hard Drive Controller (HDC; XTC only)
|
ChipSet.DMA_HDC = 0x03; // DMA channel assigned to the Hard Drive Controller (HDC; XTC only)
|
||||||
|
|
||||||
|
|
@ -1579,6 +1579,8 @@ ChipSet.prototype.restore = function(data)
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChipSet.aDMAControllerInit = [0, null, null, 0, new Array(4)];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initDMAController(iDMAC, aState)
|
* initDMAController(iDMAC, aState)
|
||||||
*
|
*
|
||||||
|
|
@ -1588,21 +1590,24 @@ ChipSet.prototype.restore = function(data)
|
||||||
*/
|
*/
|
||||||
ChipSet.prototype.initDMAController = function(iDMAC, aState)
|
ChipSet.prototype.initDMAController = function(iDMAC, aState)
|
||||||
{
|
{
|
||||||
var controller = this.aDMACs[iDMAC] = {};
|
var controller = this.aDMACs[iDMAC];
|
||||||
if (!aState || aState.length != 5) {
|
if (!controller) controller = {
|
||||||
aState = [0, undefined, undefined, 0, []];
|
aChannels: new Array(4)
|
||||||
}
|
};
|
||||||
controller.bStatus = aState[0];
|
var a = aState && aState.length == 5? aState : ChipSet.aDMAControllerInit;
|
||||||
controller.bCmd = aState[1];
|
controller.bStatus = a[0];
|
||||||
controller.bReq = aState[2];
|
controller.bCmd = a[1];
|
||||||
controller.bIndex = aState[3];
|
controller.bReq = a[2];
|
||||||
|
controller.bIndex = a[3];
|
||||||
controller.nChannelBase = iDMAC << 2;
|
controller.nChannelBase = iDMAC << 2;
|
||||||
controller.aChannels = new Array(4);
|
|
||||||
for (var iChannel = 0; iChannel < controller.aChannels.length; iChannel++) {
|
for (var iChannel = 0; iChannel < controller.aChannels.length; iChannel++) {
|
||||||
this.initDMAChannel(controller, iChannel, aState[4][iChannel]);
|
this.initDMAChannel(controller, iChannel, a[4][iChannel]);
|
||||||
}
|
}
|
||||||
|
this.aDMACs[iDMAC] = controller;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChipSet.aDMAChannelInit = [true, [0,0], [0,0], [0,0], [0,0]];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initDMAChannel(controller, iChannel, aState)
|
* initDMAChannel(controller, iChannel, aState)
|
||||||
*
|
*
|
||||||
|
|
@ -1613,29 +1618,40 @@ ChipSet.prototype.initDMAController = function(iDMAC, aState)
|
||||||
*/
|
*/
|
||||||
ChipSet.prototype.initDMAChannel = function(controller, iChannel, aState)
|
ChipSet.prototype.initDMAChannel = function(controller, iChannel, aState)
|
||||||
{
|
{
|
||||||
var channel = controller.aChannels[iChannel] = {};
|
var a = ChipSet.aDMAChannelInit;
|
||||||
if (aState === undefined || aState.length != 8) {
|
var channel = controller.aChannels[iChannel];
|
||||||
aState = [true, [], [], [], []];
|
if (!channel) {
|
||||||
|
Component.assert(!aState);
|
||||||
|
channel = {
|
||||||
|
masked: true,
|
||||||
|
addrInit: [0,0],
|
||||||
|
countInit: [0,0],
|
||||||
|
addrCurrent: [0,0],
|
||||||
|
countCurrent: [0,0]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
if (aState && aState.length == 8) a = aState;
|
||||||
|
channel.masked = a[0];
|
||||||
|
channel.addrInit[0] = a[1][0]; channel.addrInit[1] = a[1][1];
|
||||||
|
channel.countInit[0] = a[2][0]; channel.countInit[1] = a[2][1];
|
||||||
|
channel.addrCurrent[0] = a[3][0]; channel.addrCurrent[1] = a[3][1];
|
||||||
|
channel.countCurrent[0] = a[4][0]; channel.countCurrent[1] = a[4][1];
|
||||||
|
channel.mode = a[5];
|
||||||
|
channel.bPage = a[6];
|
||||||
|
// a[7] is deprecated
|
||||||
}
|
}
|
||||||
channel.controller = controller;
|
channel.controller = controller;
|
||||||
channel.iChannel = iChannel;
|
channel.iChannel = iChannel;
|
||||||
channel.masked = aState[0];
|
this.initDMAFunction(channel, a[8], a[9]);
|
||||||
channel.addrInit = aState[1];
|
controller.aChannels[iChannel] = channel;
|
||||||
channel.countInit = aState[2];
|
|
||||||
channel.addrCurrent = aState[3];
|
|
||||||
channel.countCurrent = aState[4];
|
|
||||||
channel.mode = aState[5];
|
|
||||||
channel.bPage = aState[6];
|
|
||||||
// aState[7] is deprecated
|
|
||||||
this.initDMAFunction(channel, aState[8], aState[9]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initDMAFunction(channel)
|
* initDMAFunction(channel)
|
||||||
*
|
*
|
||||||
* @param {Object} channel
|
* @param {Object} channel
|
||||||
* @param {Component|string} component
|
* @param {Component|string|undefined} component
|
||||||
* @param {string} sFunction
|
* @param {string|undefined} sFunction
|
||||||
* @param {Object} [obj]
|
* @param {Object} [obj]
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
|
|
@ -1704,6 +1720,8 @@ ChipSet.prototype.saveDMAChannels = function(controller)
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChipSet.aPICInit = [0, new Array(4)];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initPIC(iPIC, aState)
|
* initPIC(iPIC, aState)
|
||||||
*
|
*
|
||||||
|
|
@ -1714,20 +1732,20 @@ ChipSet.prototype.saveDMAChannels = function(controller)
|
||||||
*/
|
*/
|
||||||
ChipSet.prototype.initPIC = function(iPIC, port, aState)
|
ChipSet.prototype.initPIC = function(iPIC, port, aState)
|
||||||
{
|
{
|
||||||
var pic = this.aPICs[iPIC] = {};
|
var pic = this.aPICs[iPIC];
|
||||||
if (!aState || aState.length != 8) {
|
if (!pic) pic = {};
|
||||||
aState = [0, [undefined, undefined, undefined, undefined]];
|
var a = aState && aState.length == 8? aState : ChipSet.aPICInit;
|
||||||
}
|
|
||||||
pic.port = port;
|
pic.port = port;
|
||||||
pic.nIRQBase = iPIC << 3;
|
pic.nIRQBase = iPIC << 3;
|
||||||
pic.nDelay = aState[0];
|
pic.nDelay = a[0];
|
||||||
pic.aICW = aState[1];
|
pic.aICW = a[1];
|
||||||
pic.nICW = aState[2];
|
pic.nICW = a[2];
|
||||||
pic.bIMR = aState[3];
|
pic.bIMR = a[3];
|
||||||
pic.bIRR = aState[4];
|
pic.bIRR = a[4];
|
||||||
pic.bISR = aState[5];
|
pic.bISR = a[5];
|
||||||
pic.bIRLow = aState[6];
|
pic.bIRLow = a[6];
|
||||||
pic.bOCW3 = aState[7];
|
pic.bOCW3 = a[7];
|
||||||
|
this.aPICs[iPIC] = pic;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1755,6 +1773,8 @@ ChipSet.prototype.savePICs = function()
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChipSet.aTimerInit = [[0,0], [0,0], [0,0], [0,0]];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initTimer(iTimer, aState)
|
* initTimer(iTimer, aState)
|
||||||
*
|
*
|
||||||
|
|
@ -1764,23 +1784,28 @@ ChipSet.prototype.savePICs = function()
|
||||||
*/
|
*/
|
||||||
ChipSet.prototype.initTimer = function(iTimer, aState)
|
ChipSet.prototype.initTimer = function(iTimer, aState)
|
||||||
{
|
{
|
||||||
var timer = this.aTimers[iTimer] = {};
|
var timer = this.aTimers[iTimer];
|
||||||
if (aState === undefined || aState.length != 13) {
|
if (!timer) timer = {
|
||||||
aState = [ [0,0], [0,0], [0,0], [0,0] ];
|
countInit: [0,0],
|
||||||
}
|
countStart: [0,0],
|
||||||
timer.countInit = aState[0];
|
countCurrent: [0,0],
|
||||||
timer.countStart = aState[1];
|
countLatched: [0,0]
|
||||||
timer.countCurrent = aState[2];
|
};
|
||||||
timer.countLatched = aState[3];
|
var a = aState && aState.length == 13? aState : ChipSet.aTimerInit;
|
||||||
timer.bcd = aState[4];
|
timer.countInit[0] = a[0][0]; timer.countInit[1] = a[0][1];
|
||||||
timer.mode = aState[5];
|
timer.countStart[0] = a[1][0]; timer.countStart[1] = a[1][1];
|
||||||
timer.rw = aState[6];
|
timer.countCurrent[0] = a[2][0]; timer.countCurrent[1] = a[2][1];
|
||||||
timer.countIndex = aState[7];
|
timer.countLatched[0] = a[3][0]; timer.countLatched[1] = a[3][1];
|
||||||
timer.countBytes = aState[8];
|
timer.bcd = a[4];
|
||||||
timer.fOUT = aState[9];
|
timer.mode = a[5];
|
||||||
timer.fLatched = aState[10];
|
timer.rw = a[6];
|
||||||
timer.fCounting = aState[11];
|
timer.countIndex = a[7];
|
||||||
timer.nStartCycles = aState[12];
|
timer.countBytes = a[8];
|
||||||
|
timer.fOUT = a[9];
|
||||||
|
timer.fLatched = a[10];
|
||||||
|
timer.fCounting = a[11];
|
||||||
|
timer.nStartCycles = a[12];
|
||||||
|
this.aTimers[iTimer] = timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue