Skip to content

Commit

Permalink
Exposing the option to specify the second hard disk as a slave
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung authored and copy committed Jun 29, 2020
1 parent 20469fe commit 6ab0fa8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
9 changes: 7 additions & 2 deletions debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ <h4>Debugger</h4>
</tr>

<tr>
<td>Hard drive disk image</td>
<td><input type="file" id="hd_image"><br></td>
<td>Master Hard drive disk image</td>
<td><input type="file" id="hda_image"><br></td>
</tr>

<tr>
<td>Slave Hard drive disk image</td>
<td><input type="file" id="hdb_image"><br></td>
</tr>

<tr>
Expand Down
16 changes: 12 additions & 4 deletions src/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,18 @@
settings.cdrom = { buffer: cd_file };
}

var hd_file = $("hd_image").files[0];
if(hd_file)
var hda_file = $("hda_image").files[0];
if(hda_file)
{
last_file = hd_file;
settings.hda = { buffer: hd_file };
last_file = hda_file;
settings.hda = { buffer: hda_file };
}

var hdb_file = $("hdb_image").files[0];
if(hdb_file)
{
last_file = hdb_file;
settings.hdb = { buffer: hdb_file };
}

if($("multiboot_image"))
Expand Down Expand Up @@ -704,6 +711,7 @@

"fda": settings.fda,
"hda": settings.hda,
"hdb": settings.hdb,
"cdrom": settings.cdrom,

"multiboot": settings.multiboot,
Expand Down
9 changes: 2 additions & 7 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,17 +760,12 @@ CPU.prototype.init = function(settings, device_bus)

if(settings.hda)
{
this.devices.hda = new IDEDevice(this, settings.hda, false, ide_device_count++, device_bus);
this.devices.hda = new IDEDevice(this, settings.hda, settings.hdb, false, ide_device_count++, device_bus);
}

if(settings.cdrom)
{
this.devices.cdrom = new IDEDevice(this, settings.cdrom, true, ide_device_count++, device_bus);
}

if(settings.hdb)
{
this.devices.hdb = new IDEDevice(this, settings.hdb, false, ide_device_count++, device_bus);
this.devices.cdrom = new IDEDevice(this, settings.cdrom, undefined, true, ide_device_count++, device_bus);
}

this.devices.pit = new PIT(this, device_bus);
Expand Down
6 changes: 3 additions & 3 deletions src/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ var HD_SECTOR_SIZE = 512;
* @param {number} nr
* @param {BusConnector} bus
* */
function IDEDevice(cpu, buffer, is_cd, nr, bus)
function IDEDevice(cpu, masterBuffer, slaveBuffer, is_cd, nr, bus)
{
this.master = new IDEInterface(this, cpu, buffer, is_cd, nr, 0, bus);
this.slave = new IDEInterface(this, cpu, undefined, false, nr, 1, bus);
this.master = new IDEInterface(this, cpu, masterBuffer, is_cd, nr, 0, bus);
this.slave = new IDEInterface(this, cpu, slaveBuffer, is_cd, nr, 1, bus);

this.current_interface = this.master;

Expand Down

0 comments on commit 6ab0fa8

Please sign in to comment.