Support for overriding machine hard drive(s)

This commit is contained in:
Jeff Parsons 2016-03-10 00:54:34 -08:00
commit e9e7ccf6f2
17 changed files with 370 additions and 310 deletions

View file

@ -333,6 +333,7 @@ MarkOut.aHTMLEntities = {
* 'template' (eg, "machine.xsl")
* 'uncompiled' (eg, true)
* 'autoMount' (eg, {"A":{"name":"OS/2 FOOTBALL Boot Disk (v7.68.17)","path":"/disks/pc/os2/misc/football/debugger/FOOTBALL-7.68.17.json"}})
* 'drives' (eg, [{name:"68Mb Hard Disk",type:4,path:"http://archive.pcjs.org/disks/pc/fixed/68mb/win95.json"}])
* 'parms'
*
* Non-reserved properties include:
@ -356,7 +357,7 @@ MarkOut.aHTMLEntities = {
MarkOut.aFMBooleanMachineProps = {
'autopower': "autoPower"
};
MarkOut.aFMReservedMachineProps = ['id', 'name', 'type', 'debugger', 'config', 'template', 'uncompiled', 'autoMount', 'parms'];
MarkOut.aFMReservedMachineProps = ['id', 'name', 'type', 'debugger', 'config', 'template', 'uncompiled', 'autoMount', 'drives', 'parms'];
/**
* convertMD()
@ -480,6 +481,7 @@ MarkOut.prototype.convertMD = function(sIndent)
/*
* Any "non-reserved" properties are now merged into the 'parms' property; 'autoMount'
* is treated as reserved only because it must be encoded as an object rather than a string.
* Ditto for 'drives'.
*/
machine['parms'] = '{';
for (sProp in machine) {
@ -491,7 +493,19 @@ MarkOut.prototype.convertMD = function(sIndent)
machine['parms'] += sProp + ':"' + machine[sProp] + '",';
}
}
machine['parms'] += 'autoMount:' + machine['autoMount'] + '}';
var sDrives = machine['drives'];
if (sDrives) {
var matchQuotes = sDrives.match(/(['"])(.*)\1/);
if (matchQuotes) {
sDrives = matchQuotes[2];
if (!sDrives) {
sDrives = '[]';
} else {
sDrives = sDrives.replace(/'/g, '"');
}
}
}
machine['parms'] += 'autoMount:' + (machine['autoMount'] || "null") + ',drives:' + (sDrives || "null") + '}';
if (id) this.aMachineDefs[id] = machine;
}
}

View file

@ -88,21 +88,11 @@ function HDC(parmsHDC) {
this.aDriveConfigs = [];
if (parmsHDC['drives']) {
try {
/*
* The most likely source of any exception will be right here, where we're parsing
* the JSON-encoded drive data.
*/
this.aDriveConfigs = eval("(" + parmsHDC['drives'] + ")");
/*
* Nothing more to do with aDriveConfigs now. initController() and autoMount() (if there are
* any disk image "path" properties to process) will take care of the rest.
*/
} catch (e) {
Component.error("HDC drive configuration error: " + e.message + " (" + parmsHDC['drives'] + ")");
}
}
/*
* We used to eval() sDriveConfigs immediately, but now we wait until initBus()
* is called, so that we can check for any machine overrides.
*/
this.sDriveConfigs = parmsHDC['drives'];
/*
* Set fATC (AT Controller flag) according to the 'type' parameter. This in turn determines other
@ -112,7 +102,7 @@ function HDC(parmsHDC) {
this.fATC = (parmsHDC['type'] == "at");
/*
* The remainder of HDC initialization now takes place in our initBus() handler
* The remainder of HDC initialization now takes place in our initBus() handler.
*/
}
@ -586,6 +576,26 @@ HDC.prototype.initBus = function(cmp, bus, cpu, dbg)
this.dbg = dbg;
this.cmp = cmp;
var aDriveConfigs = cmp.getMachineParm('drives');
if (aDriveConfigs) {
this.aDriveConfigs = aDriveConfigs;
}
else if (this.sDriveConfigs) {
try {
/*
* The most likely source of any exception will be right here, where we're parsing
* the JSON-encoded drive data.
*/
this.aDriveConfigs = eval("(" + this.sDriveConfigs + ")");
/*
* Nothing more to do with aDriveConfigs now. initController() and autoMount() (if there are
* any disk image "path" properties to process) will take care of the rest.
*/
} catch (e) {
Component.error("HDC drive configuration error: " + e.message + " (" + this.sDriveConfigs + ")");
}
}
/*
* We need access to the ChipSet component, because we need to communicate with
* the PIC and DMA controller.