Skip to content

Commit

Permalink
ignore bzimage_initrd_from_filesystem when initial_state is passed & …
Browse files Browse the repository at this point in the history
…simplify
  • Loading branch information
copy committed May 26, 2024
1 parent 484ce7d commit e1182c0
Showing 1 changed file with 28 additions and 37 deletions.
65 changes: 28 additions & 37 deletions src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,62 +552,53 @@ V86.prototype.continue_init = async function(emulator, options)
if(!settings.initial_state)
{
settings.fs9p.load_from_json(settings.fs9p_json);
}
else
{
dbg_log("Filesystem basefs ignored: Overridden by state image");
}

if(options.bzimage_initrd_from_filesystem)
{
const { bzimage_path, initrd_path } = this.get_bzimage_initrd_from_filesystem(settings.fs9p);
if(options.bzimage_initrd_from_filesystem)
{
const { bzimage_path, initrd_path } = this.get_bzimage_initrd_from_filesystem(settings.fs9p);

dbg_log("Found bzimage: " + bzimage_path + " and initrd: " + initrd_path);
dbg_log("Found bzimage: " + bzimage_path + " and initrd: " + initrd_path);

const [initrd, bzimage] = await Promise.all([
settings.fs9p.read_file(initrd_path),
settings.fs9p.read_file(bzimage_path),
]);
put_on_settings.call(this, "initrd", new v86util.SyncBuffer(initrd.buffer));
put_on_settings.call(this, "bzimage", new v86util.SyncBuffer(bzimage.buffer));
finish.call(this);
const [initrd, bzimage] = await Promise.all([
settings.fs9p.read_file(initrd_path),
settings.fs9p.read_file(bzimage_path),
]);
put_on_settings.call(this, "initrd", new v86util.SyncBuffer(initrd.buffer));
put_on_settings.call(this, "bzimage", new v86util.SyncBuffer(bzimage.buffer));
}
}
else
{
finish.call(this);
dbg_log("Filesystem basefs ignored: Overridden by state image");
}
}
else
{
dbg_assert(
!options.bzimage_initrd_from_filesystem,
!options.bzimage_initrd_from_filesystem || settings.initial_state,
"bzimage_initrd_from_filesystem: Requires a filesystem");
finish.call(this);
}

function finish()
{
this.serial_adapter && this.serial_adapter.show && this.serial_adapter.show();
this.serial_adapter && this.serial_adapter.show && this.serial_adapter.show();

this.bus.send("cpu-init", settings);
this.bus.send("cpu-init", settings);

if(settings.initial_state)
{
emulator.restore_state(settings.initial_state);

// The GC can't free settings, since it is referenced from
// several closures. This isn't needed anymore, so we delete it
// here
settings.initial_state = undefined;
}
if(settings.initial_state)
{
emulator.restore_state(settings.initial_state);

if(options.autostart)
{
this.bus.send("cpu-run");
}
// The GC can't free settings, since it is referenced from
// several closures. This isn't needed anymore, so we delete it
// here
settings.initial_state = undefined;
}

this.emulator_bus.send("emulator-loaded");
if(options.autostart)
{
this.bus.send("cpu-run");
}

this.emulator_bus.send("emulator-loaded");
}
};

Expand Down

0 comments on commit e1182c0

Please sign in to comment.