ignore bzimage_initrd_from_filesystem when initial_state is passed & simplify

This commit is contained in:
Fabian 2024-05-26 17:38:46 +09:00
parent 484ce7db64
commit e1182c08b8

View file

@ -552,62 +552,53 @@ V86.prototype.continue_init = async function(emulator, options)
if(!settings.initial_state)
{
settings.fs9p.load_from_json(settings.fs9p_json);
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);
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
{
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);
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);
}
else
{
finish.call(this);
}
}
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.bus.send("cpu-init", settings);
if(settings.initial_state)
{
this.serial_adapter && this.serial_adapter.show && this.serial_adapter.show();
emulator.restore_state(settings.initial_state);
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(options.autostart)
{
this.bus.send("cpu-run");
}
this.emulator_bus.send("emulator-loaded");
// 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(options.autostart)
{
this.bus.send("cpu-run");
}
this.emulator_bus.send("emulator-loaded");
}
};