Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix booting from cd while hda present, booting from hda while cd present #901

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a1c58dd
Fix booting from cd while hda present, booting from hda while cd present
JoeOsborn Aug 18, 2023
42ea08a
fix wrong fields in log messages
JoeOsborn Aug 18, 2023
24af4dd
revert changes to main, index, debug
JoeOsborn Aug 19, 2023
7757918
add wants_cdrom config flag to force presence of a cdrom even when no…
JoeOsborn Aug 19, 2023
c962198
Expose wants_cdrom flag and fix a docstring.
JoeOsborn Aug 19, 2023
45945f7
fix typo
JoeOsborn Aug 19, 2023
3500d36
Fix hda+cdrom tests and tinycore hang, add a few more
JoeOsborn Aug 20, 2023
00bc200
fixes towards empty cd-rom support for bochs bios
JoeOsborn Aug 21, 2023
dbc17b2
Fix empty/missing device enumeration for bochs bios
JoeOsborn Aug 21, 2023
0389dfc
put back RTC CMOS writes, freedos13 seems to want them
JoeOsborn Aug 22, 2023
b42912a
set proper default sector count for cdrom
JoeOsborn Aug 22, 2023
79d4302
WIP floppy eject/insert; dos does not see re-insert yet
JoeOsborn Aug 16, 2023
6c46de5
it seems to work for MSDOS
JoeOsborn Aug 16, 2023
34ede09
remove incorrect format command half-impl
JoeOsborn Aug 16, 2023
b0824d8
Add extra_images config setting for V86Starter, extend test cases wit…
JoeOsborn Aug 21, 2023
718fa07
add semicolon
JoeOsborn Aug 21, 2023
276de39
Remove extra_images, add V86.load_image
JoeOsborn Aug 23, 2023
8f1b94d
Refactor starter to use load_image.
JoeOsborn Aug 23, 2023
dd893ef
fixes towards empty cd-rom support for bochs bios
JoeOsborn Aug 21, 2023
02383c2
Fix empty/missing device enumeration for bochs bios
JoeOsborn Aug 21, 2023
6e53a64
WIP insert/eject
JoeOsborn Aug 23, 2023
1df73ec
clean up tests and code after rebase
JoeOsborn Aug 30, 2023
add7605
tweaks to ordering in initialization
JoeOsborn Sep 1, 2023
c77dc1f
remove debug output
JoeOsborn Sep 1, 2023
f6cf861
add missing file
JoeOsborn Sep 1, 2023
bdf6cce
roll back main profiles, full-test changes
JoeOsborn Sep 1, 2023
bf707cc
add missing semicolons
JoeOsborn Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ api-tests: all-debug
./tests/api/reset.js
./tests/api/floppy-insert-eject.js
./tests/api/serial.js
./tests/api/cdrom-insert-eject.js

all-tests: jshint kvm-unit-test qemutests qemutests-release jitpagingtests api-tests nasmtests nasmtests-force-jit tests expect-tests
# Skipping:
Expand Down
7 changes: 7 additions & 0 deletions debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ <h4>Debugger</h4>
</td>
</tr>

<tr>
<td><label for="wants_cdrom">Allow empty cd-rom drive</label></td>
<td>
<input id="wants_cdrom" type="checkbox"><br>
</td>
</tr>

<tr>
<td><label for="floppy_image">Floppy disk image</label></td>
<td> <input type="file" id="floppy_image"><br></td>
Expand Down
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ <h4>Setup</h4>
</td>
</tr>

<tr>
<td><label for="wants_cdrom">Allow empty cd-rom drive</label></td>
<td>
<input id="wants_cdrom" type="checkbox"><br>
</td>
</tr>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert this for now? It's confusingly named, can cause problems with the state saving mechanism, and I'd like to eventually redo the UI anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!


<tr>
<td><label for="floppy_image">Floppy disk image</label></td>
<td> <input type="file" id="floppy_image"><br></td>
Expand Down
4 changes: 4 additions & 0 deletions src/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@

settings.fda = infos.fda;
settings.cdrom = infos.cdrom;
settings.wants_cdrom = infos.wants_cdrom;
settings.hda = infos.hda;
settings.multiboot = infos.multiboot;
settings.bzimage = infos.bzimage;
Expand Down Expand Up @@ -1323,6 +1324,8 @@
const disable_audio = settings.audio === undefined ? $("disable_audio").checked : !settings.audio;
const enable_acpi = settings.acpi === undefined ? $("enable_acpi").checked : settings.acpi;

const wants_cdrom = settings.wants_cdrom === undefined ? $("wants_cdrom").checked : settings.wants_cdrom;

/** @const */
var BIOSPATH = "bios/";

Expand Down Expand Up @@ -1369,6 +1372,7 @@
"hda": settings.hda,
"hdb": settings.hdb,
"cdrom": settings.cdrom,
"wants_cdrom": settings.wants_cdrom,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cdrom: { ejected: true } would be a clearer api for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m happy to defer to you here, I’ll make that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cdrom: { ejected: true } makes sense for the starter options, but it's a bit tricky inside of cpu and so on if the settings object is either a buffer or null or {ejected: true}. Should there be a new EmptyBuffer buffer type? Or can wants_cdrom continue to exist within the emulator settings, even if it's not part of public API?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, internally wants_cdrom is fine (it can be refactored at any point anyway)


"multiboot": settings.multiboot,
"bzimage": settings.bzimage,
Expand Down
40 changes: 40 additions & 0 deletions src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* - `filesystem Object` (No 9p filesystem) - A 9p filesystem, see
* [filesystem.md](filesystem.md).
*
* - `wants_cdrom bool` - Whether to set up a CD-ROM drive even with no CD present. Implied by the presence of a `cdrom` object.
* - `serial_container HTMLTextAreaElement` (No serial terminal) - A textarea
* that will receive and send data to the emulated serial terminal.
* Alternatively the serial terminal can also be accessed programatically,
Expand Down Expand Up @@ -261,6 +262,7 @@ V86Starter.prototype.continue_init = async function(emulator, options)
options["fda"] ? BOOT_ORDER_FD_FIRST :
options["hda"] ? BOOT_ORDER_HD_FIRST : BOOT_ORDER_CD_FIRST;

settings.wants_cdrom = options["wants_cdrom"] || ("cdrom" in options) || false;
settings.acpi = options["acpi"];
settings.disable_jit = options["disable_jit"];
settings.load_devices = true;
Expand Down Expand Up @@ -339,6 +341,7 @@ V86Starter.prototype.continue_init = async function(emulator, options)
break;
case "cdrom":
settings.cdrom = this.disk_images["cdrom"] = buffer;
settings.wants_cdrom = true;
break;
case "fda":
settings.fda = this.disk_images["fda"] = buffer;
Expand Down Expand Up @@ -371,6 +374,7 @@ V86Starter.prototype.continue_init = async function(emulator, options)
break;
default:
dbg_assert(false, name);
break;
}
}

Expand Down Expand Up @@ -1008,6 +1012,42 @@ V86Starter.prototype.eject_fda = function()
this.v86.cpu.devices.fdc.eject_fda();
};

/**
* Set the image inserted in the CD-ROM drive. Can be changed at runtime, as
* when physically changing the CD-ROM.
* @export
*/
V86Starter.prototype.set_cdrom = async function(file)
{
if(file.url && !file.async)
{
v86util.load_file(file.url, {
done: result =>
{
this.v86.cpu.devices.cdrom.master.set_cdrom(new v86util.SyncBuffer(result));
},
});
}
else
{
const image = v86util.buffer_from_object(file);
image.onload = () =>
{
this.v86.cpu.devices.cdrom.master.set_cdrom(image);
};
await image.load();
}
};

/**
* Eject the CD-ROM.
* @export
*/
V86Starter.prototype.eject_cdrom = function()
{
this.v86.cpu.devices.cdrom.master.eject();
};

/**
* Send a sequence of scan codes to the emulated PS2 controller. A list of
* codes can be found at http://stanislavs.org/helppc/make_codes.html.
Expand Down
2 changes: 1 addition & 1 deletion src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ CPU.prototype.init = function(settings, device_bus)
this.devices.hda = new IDEDevice(this, settings.hda, settings.hdb, false, ide_device_count++, device_bus);
}

if(settings.cdrom)
if(settings.cdrom || settings.wants_cdrom)
{
this.devices.cdrom = new IDEDevice(this, settings.cdrom, undefined, true, ide_device_count++, device_bus);
}
Expand Down
Loading