v86 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -435,170 +435,170 @@ b+20,"VirtIO device<"+this.name+"> can't fit all capabilities into 256byte confi
435
435
  a[3];this.features_ok=a[4];this.device_status=a[5];this.config_has_changed=a[6];this.config_generation=a[7];this.isr_status=a[8];this.queue_select=a[9];let b=0;for(const c of a.slice(10))this.queues[b].set_state(c),b++;this.queue_selected=this.queues[this.queue_select]||null};fa.prototype.reset=function(){this.driver_feature_select=this.device_feature_select=0;this.driver_feature.set(this.device_feature);this.features_ok=!0;this.queue_select=this.device_status=0;this.queue_selected=this.queues[0];
436
436
  for(const a of this.queues)a.reset();this.config_has_changed=!1;this.config_generation=0;this.lower_irq()};fa.prototype.notify_config_changes=function(){this.config_has_changed=!0;this.device_status&4?this.raise_irq(2):h(!1,"VirtIO device<"+this.name+"> attempted to notify driver before DRIVER_OK")};fa.prototype.update_config_generation=function(){this.config_has_changed&&(this.config_generation++,this.config_generation&=255,this.config_has_changed=!1)};fa.prototype.is_feature_negotiated=function(a){return 0<
437
437
  (this.driver_feature[a>>>5]&1<<(a&31))};fa.prototype.needs_reset=function(){E("Device<"+this.name+"> experienced error - requires reset",2097152);this.device_status|=64;this.device_status&4&&this.notify_config_changes()};fa.prototype.raise_irq=function(a){E("Raise irq "+B(a),2097152);this.isr_status|=a;this.pci.raise_irq(this.pci_id)};fa.prototype.lower_irq=function(){E("Lower irq ",2097152);this.isr_status=0;this.pci.lower_irq(this.pci_id)};function W(a,b,c){this.cpu=a;this.virtio=b;this.size_supported=
438
- this.size=c.size_supported;this.mask=this.size-1;this.enabled=!1;this.notify_offset=c.notify_offset;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.reset()}W.prototype.get_state=function(){const a=[];a[0]=this.size;a[1]=this.size_supported;a[2]=this.enabled;a[3]=this.notify_offset;a[4]=this.desc_addr;a[5]=this.avail_addr;a[6]=this.avail_last_idx;a[7]=this.used_addr;a[8]=this.num_staged_replies;return a};W.prototype.set_state=function(a){this.size=a[0];
439
- this.size_supported=a[1];this.enabled=a[2];this.notify_offset=a[3];this.desc_addr=a[4];this.avail_addr=a[5];this.avail_last_idx=a[6];this.used_addr=a[7];this.num_staged_replies=a[8];this.mask=this.size-1};W.prototype.reset=function(){this.enabled=!1;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.set_size(this.size_supported)};W.prototype.is_configured=function(){return this.desc_addr&&this.avail_addr&&this.used_addr};W.prototype.enable=function(){h(this.is_configured(),
440
- "VirtQueue must be configured before enabled");this.enabled=!0};W.prototype.set_size=function(a){h(0===(a&a-1),"VirtQueue size must be power of 2 or zero");h(a<=this.size_supported,"VirtQueue size must be within supported size");this.size=a;this.mask=a-1};W.prototype.count_requests=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");return this.avail_get_idx()-this.avail_last_idx&65535};W.prototype.has_request=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");
441
- return 0!==this.count_requests()};W.prototype.pop_request=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");h(this.has_request(),"VirtQueue must not pop nonexistent request");var a=this.avail_get_entry(this.avail_last_idx);E("Pop request: avail_last_idx="+this.avail_last_idx+" desc_idx="+a,2097152);a=new qb(this,a);this.avail_last_idx=this.avail_last_idx+1&65535;return a};W.prototype.push_reply=function(a){h(this.used_addr,"VirtQueue addresses must be configured before use");
442
- h(this.num_staged_replies<this.size,"VirtQueue replies must not exceed queue size");const b=this.used_get_idx()+this.num_staged_replies&this.mask;E("Push reply: used_idx="+b+" desc_idx="+a.head_idx,2097152);this.used_set_entry(b,a.head_idx,a.length_written);this.num_staged_replies++};W.prototype.flush_replies=function(){h(this.used_addr,"VirtQueue addresses must be configured before use");if(0===this.num_staged_replies)E("flush_replies: Nothing to flush",2097152);else{E("Flushing "+this.num_staged_replies+
443
- " replies",2097152);var a=this.used_get_idx()+this.num_staged_replies&65535;this.used_set_idx(a);this.num_staged_replies=0;this.virtio.is_feature_negotiated(29)?(this.avail_get_used_event(),this.virtio.raise_irq(1)):~this.avail_get_flags()&1&&this.virtio.raise_irq(1)}};W.prototype.notify_me_after=function(a){h(0<=a,"Must skip a non-negative number of requests");a=this.avail_get_idx()+a&65535;this.used_set_avail_event(a)};W.prototype.get_descriptor=function(a,b){return{addr_low:this.cpu.read32s(a+
444
- 16*b),addr_high:this.cpu.read32s(a+16*b+4),len:this.cpu.read32s(a+16*b+8),flags:this.cpu.read16(a+16*b+12),next:this.cpu.read16(a+16*b+14)}};W.prototype.avail_get_flags=function(){return this.cpu.read16(this.avail_addr)};W.prototype.avail_get_idx=function(){return this.cpu.read16(this.avail_addr+2)};W.prototype.avail_get_entry=function(a){return this.cpu.read16(this.avail_addr+4+2*(a&this.mask))};W.prototype.avail_get_used_event=function(){return this.cpu.read16(this.avail_addr+4+2*this.size)};W.prototype.used_get_flags=
445
- function(){return this.cpu.read16(this.used_addr)};W.prototype.used_set_flags=function(a){this.cpu.write16(this.used_addr,a)};W.prototype.used_get_idx=function(){return this.cpu.read16(this.used_addr+2)};W.prototype.used_set_idx=function(a){this.cpu.write16(this.used_addr+2,a)};W.prototype.used_set_entry=function(a,b,c){this.cpu.write32(this.used_addr+4+8*a,b);this.cpu.write32(this.used_addr+8+8*a,c)};W.prototype.used_set_avail_event=function(a){this.cpu.write16(this.used_addr+4+8*this.size,a)};function qb(a,
446
- b){this.cpu=a.cpu;this.virtio=a.virtio;this.head_idx=b;this.read_buffers=[];this.length_readable=this.read_buffer_offset=this.read_buffer_idx=0;this.write_buffers=[];this.length_writable=this.length_written=this.write_buffer_offset=this.write_buffer_idx=0;let c=a.desc_addr,d=0,e=a.size,g=!1;const f=this.virtio.is_feature_negotiated(28);E("<<< Descriptor chain start",2097152);do{const l=a.get_descriptor(c,b);E("descriptor: idx="+b+" addr="+B(l.addr_high,8)+":"+B(l.addr_low,8)+" len="+B(l.len,8)+" flags="+
447
- B(l.flags,4)+" next="+B(l.next,4),2097152);if(f&&l.flags&4)l.flags&1&&E("Driver bug: has set VIRTQ_DESC_F_NEXT flag in an indirect table descriptor",2097152),c=l.addr_low,d=b=0,e=l.len/16,E("start indirect",2097152);else{if(l.flags&2)g=!0,this.write_buffers.push(l),this.length_writable+=l.len;else{if(g){E("Driver bug: readonly buffer after writeonly buffer within chain",2097152);break}this.read_buffers.push(l);this.length_readable+=l.len}d++;if(d>e){E("Driver bug: descriptor chain cycle detected",
448
- 2097152);break}if(l.flags&1)b=l.next;else break}}while(1);E("Descriptor chain end >>>",2097152)}qb.prototype.get_next_blob=function(a){let b=0,c=a.length;for(;c;){if(this.read_buffer_idx===this.read_buffers.length){E("Device<"+this.virtio.name+"> Read more than device-readable buffers has",2097152);break}var d=this.read_buffers[this.read_buffer_idx];const e=d.addr_low+this.read_buffer_offset;d=d.len-this.read_buffer_offset;d>c?(d=c,this.read_buffer_offset+=c):(this.read_buffer_idx++,this.read_buffer_offset=
449
- 0);a.set(this.cpu.read_blob(e,d),b);b+=d;c-=d}return b};qb.prototype.set_next_blob=function(a){let b=0,c=a.length;for(;c;){if(this.write_buffer_idx===this.write_buffers.length){E("Device<"+this.virtio.name+"> Write more than device-writable capacity",2097152);break}var d=this.write_buffers[this.write_buffer_idx];const e=d.addr_low+this.write_buffer_offset;d=d.len-this.write_buffer_offset;d>c?(d=c,this.write_buffer_offset+=c):(this.write_buffer_idx++,this.write_buffer_offset=0);this.cpu.write_blob(a.subarray(b,
450
- b+d),e);b+=d;c-=d}this.length_written+=b;return b};function rb(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c<this.ports;++c)b.push({size_supported:16,notify_offset:0}),b.push({size_supported:8,notify_offset:1});this.virtio=new fa(a,{name:"virtio-console",pci_id:96,device_id:4163,subsystem_device_id:3,common:{initial_port:47104,queues:b,
451
- features:[0,1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const g=d.pop_request(),f=new Uint8Array(g.length_readable);g.get_next_blob(f);this.bus.send("virtio-console"+e+"-output-bytes",f);this.Ack(c,g)}},c=>{if(2!==c)h(!1,"VirtioConsole Notified for wrong queue: "+c+" (expected queue_id of 2)");else for(c=this.virtio.queues[c];c.count_requests()>c.size-2;)c.pop_request()},c=>{if(3!==
452
- c)h(!1,"VirtioConsole Notified for wrong queue: "+c+" (expected queue_id of 3)");else for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),g=new Uint8Array(e.length_readable);e.get_next_blob(g);var f=p.Unmarshall(["w","h","h"],g,{offset:0});g=f[0];f=f[1];this.Ack(c,e);switch(f){case 0:for(e=0;e<this.ports;++e)this.SendEvent(e,1,0);break;case 3:this.Ack(c,e);this.SendEvent(g,4,1);this.SendName(g,"virtio-"+g);this.SendEvent(g,6,1);break;case 6:this.Ack(c,e);0===g&&this.SendWindowSize(g);
453
- break;default:h(!1," VirtioConsole received unknown event: "+f[1]);return}}}]},isr_status:{initial_port:46848},device_specific:{initial_port:46592,struct:[{bytes:2,name:"cols",read:()=>this.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows,write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{h(!1,"Emergency write!")}}]}});for(let c=0;c<this.ports;++c){const d=0===c?0:2*c+2;this.bus.register("virtio-console"+c+"-input-bytes",
454
- function(e){var g=this.virtio.queues[d];g.has_request()&&(g=g.pop_request(),this.Send(d,g,new Uint8Array(e)))},this);this.bus.register("virtio-console"+c+"-resize",function(e){0===c&&(this.cols=e[0],this.rows=e[1]);this.virtio.queues[2].is_configured()&&this.virtio.queues[2].has_request()&&this.SendWindowSize(c,e[0],e[1])},this)}}rb.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(12);p.Marshall(["w","h","h","h","h"],
455
- [a,5,0,c,b],e,0);this.Send(2,d,e)};rb.prototype.SendName=function(a,b){const c=this.virtio.queues[2].pop_request();b=(new TextEncoder).encode(b);const d=new Uint8Array(8+b.length+1);p.Marshall(["w","h","h"],[a,7,1],d,0);for(a=0;a<b.length;++a)d[a+8]=b[a];d[8+b.length]=0;this.Send(2,c,d)};rb.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};rb.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=
456
- a[3]};rb.prototype.reset=function(){this.virtio.reset()};rb.prototype.SendEvent=function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);p.Marshall(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};rb.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};rb.prototype.Ack=function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function sb(a,b,
457
- c){this.bus=b;this.id=a.devices.net?1:0;this.status=this.pairs=1;this.preserve_mac_from_state_image=c;this.mac=new Uint8Array([0,34,21,255*Math.random()|0,255*Math.random()|0,255*Math.random()|0]);this.bus.send("net"+this.id+"-mac",Ua(this.mac));b=[];for(c=0;c<this.pairs;++c)b.push({size_supported:1024,notify_offset:0}),b.push({size_supported:1024,notify_offset:1});b.push({size_supported:16,notify_offset:2});this.virtio=new fa(a,{name:"virtio-net",pci_id:80,device_id:4161,subsystem_device_id:1,common:{initial_port:51200,
458
- queues:b,features:[5,16,22,3,17,23,32],on_driver_ok:()=>{}},notification:{initial_port:51456,single_handler:!1,handlers:[()=>{},d=>{const e=this.virtio.queues[d];for(;e.has_request();){const g=e.pop_request(),f=new Uint8Array(g.length_readable);g.get_next_blob(f);this.bus.send("net"+this.id+"-send",f.subarray(12));this.bus.send("eth-transmit-end",[f.length-12]);this.virtio.queues[d].push_reply(g)}this.virtio.queues[d].flush_replies()},d=>{if(d!==2*this.pairs)h(!1,"VirtioNet Notified for wrong queue: "+
459
- d+" (expected queue_id of 3)");else for(var e=this.virtio.queues[d];e.has_request();){const l=e.pop_request();var g=new Uint8Array(l.length_readable);l.get_next_blob(g);var f=p.Unmarshall(["b","b"],g,{offset:0});const n=f[0];f=f[1];switch(n<<8|f){case 1024:g=p.Unmarshall(["h"],g,{offset:2});h(1===g[0]);this.Send(d,l,new Uint8Array([0]));break;case 257:this.mac=g.subarray(2,8);this.Send(d,l,new Uint8Array([0]));this.bus.send("net"+this.id+"-mac",Ua(this.mac));break;default:h(!1," VirtioNet received unknown command: "+
460
- n+":"+f);this.Send(d,l,new Uint8Array([1]));return}}}]},isr_status:{initial_port:50944},device_specific:{initial_port:50688,struct:[0,1,2,3,4,5].map((d,e)=>({bytes:1,name:"mac_"+e,read:()=>this.mac[e],write:()=>{}})).concat([{bytes:2,name:"status",read:()=>this.status,write:()=>{}},{bytes:2,name:"max_pairs",read:()=>this.pairs,write:()=>{}},{bytes:2,name:"mtu",read:()=>1500,write:()=>{}}])}});this.bus.register("net"+this.id+"-receive",d=>{this.bus.send("eth-receive-end",[d.length]);const e=new Uint8Array(12+
461
- d.byteLength);(new DataView(e.buffer,e.byteOffset,e.byteLength)).setInt16(10,1);e.set(d,12);d=this.virtio.queues[0];d.has_request()?(d=d.pop_request(),d.set_next_blob(e),this.virtio.queues[0].push_reply(d),this.virtio.queues[0].flush_replies()):console.log("No buffer to write into!")},this)}sb.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.id;a[2]=this.mac;return a};sb.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.id=a[1];this.preserve_mac_from_state_image&&
462
- (this.mac=a[2],this.bus.send("net"+this.id+"-mac",Ua(this.mac)))};sb.prototype.reset=function(){this.virtio.reset()};sb.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};sb.prototype.Ack=function(a,b){this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};const Cb="SWAP_IN SWAP_OUT MAJFLT MINFLT MEMFREE MEMTOT AVAIL CACHES HTLB_PGALLOC HTLB_PGFAIL".split(" ");function Db(a,b){this.bus=b;this.zeroed=this.fp_cmd=
463
- this.actual=this.num_pages=0;this.virtio=new fa(a,{name:"virtio-balloon",pci_id:88,device_id:4165,subsystem_device_id:5,common:{initial_port:55296,queues:[{size_supported:32,notify_offset:0},{size_supported:32,notify_offset:0},{size_supported:2,notify_offset:1},{size_supported:64,notify_offset:2}],features:[1,3,32],on_driver_ok:()=>{E("Balloon setup",2048)}},notification:{initial_port:55552,single_handler:!1,handlers:[c=>{const d=this.virtio.queues[c];for(;d.has_request();){var e=d.pop_request();
464
- const g=new Uint8Array(e.length_readable);e.get_next_blob(g);this.virtio.queues[c].push_reply(e);e=g.byteLength/4;this.actual+=0===c?e:-e}this.virtio.queues[c].flush_replies()},c=>{var d=this.virtio.queues[c];if(d.has_request()){d=d.pop_request();const e=new Uint8Array(d.length_readable);d.get_next_blob(e);let g={};for(let f=0;f<d.length_readable;f+=10){let [l,n]=p.Unmarshall(["h","d"],e,{offset:f});g[Cb[l]]=n}this.virtio.queues[c].push_reply(d);this.stats_cb&&this.stats_cb(g)}},c=>{const d=this.virtio.queues[c];
465
- for(;d.has_request();){const g=d.pop_request();if(0<g.length_readable){var e=new Uint8Array(g.length_readable);g.get_next_blob(e);[e]=p.Unmarshall(["w"],e,{offset:0});0===e&&(this.free_cb&&this.free_cb(this.zeroed),1<this.fp_cmd&&(this.fp_cmd=1),this.virtio.notify_config_changes())}if(0<g.length_writable)for(new Uint8Array(0),e=0;e<g.write_buffers.length;++e){let f=g.write_buffers[e];this.zeroed+=f.len;this.virtio.cpu.zero_memory(f.addr_low,f.len)}this.virtio.queues[c].push_reply(g)}this.virtio.queues[c].flush_replies()}]},
466
- isr_status:{initial_port:55040},device_specific:{initial_port:54784,struct:[{bytes:4,name:"num_pages",read:()=>this.num_pages,write:()=>{}},{bytes:4,name:"actual",read:()=>this.actual,write:()=>{}},{bytes:4,name:"free_page_hint_cmd_id",read:()=>this.fp_cmd,write:()=>{}}]}})}Db.prototype.Inflate=function(a){this.num_pages+=a;this.virtio.notify_config_changes()};Db.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};Db.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=
467
- a;this.zeroed=0;this.virtio.notify_config_changes()};Db.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};Db.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};Db.prototype.GetStats=function(a){this.stats_cb=a;for(a=this.virtio.queues[2];a.has_request();){const b=a.pop_request();this.virtio.queues[2].push_reply(b)}this.virtio.queues[2].flush_replies()};Db.prototype.Reset=function(){};var Eb={};function Fb(){this.listeners=
468
- {};this.pair=void 0}Fb.prototype.register=function(a,b,c){var d=this.listeners[a];void 0===d&&(d=this.listeners[a]=[]);d.push({fn:b,this_value:c})};Fb.prototype.unregister=function(a,b){var c=this.listeners[a];void 0!==c&&(this.listeners[a]=c.filter(function(d){return d.fn!==b}))};Fb.prototype.send=function(a,b){if(this.pair&&(a=this.pair.listeners[a],void 0!==a))for(var c=0;c<a.length;c++){var d=a[c];d.fn.call(d.this_value,b)}};Fb.prototype.send_async=function(a,b){h(1===arguments.length||2===arguments.length);
469
- setTimeout(this.send.bind(this,a,b),0)};Eb.create=function(){var a=new Fb,b=new Fb;a.pair=b;b.pair=a;return[a,b]};var E=function(){var a=ba.reduce(function(d,e){d[e[0]]=e[1];return d},{}),b="",c=0;return function(d,e){e=e||1;if(e&ma){d="["+k.pads(a[e]||"",4)+"] "+d;if(d===b&&(c++,2048>c))return;e=new Date;e=k.pad0(e.getHours(),2)+":"+k.pad0(e.getMinutes(),2)+":"+k.pad0(e.getSeconds(),2)+"+"+k.pad0(e.getMilliseconds(),3)+" ";c&&(1===c?console.log(e+b):console.log("Previous message repeated "+c+" times"),
470
- c=0);console.log(e+d);b=d}}}();function h(a,b){if(!a){debugger;console.trace();if(b)throw"Assert failed: "+b;throw"Assert failed";}}function G(a,b,c){this.stop_idling=c;this.wm=b;this.wasm_patch();this.create_jit_imports();this.wasm_memory=b=this.wm.exports.memory;this.memory_size=k.view(Uint32Array,b,812,1);this.mem8=new Uint8Array(0);this.mem32s=new Int32Array(this.mem8.buffer);this.segment_is_null=k.view(Uint8Array,b,724,8);this.segment_offsets=k.view(Int32Array,b,736,8);this.segment_limits=k.view(Uint32Array,
471
- b,768,8);this.segment_access_bytes=k.view(Uint8Array,b,512,8);this.protected_mode=k.view(Int32Array,b,800,1);this.idtr_size=k.view(Int32Array,b,564,1);this.idtr_offset=k.view(Int32Array,b,568,1);this.gdtr_size=k.view(Int32Array,b,572,1);this.gdtr_offset=k.view(Int32Array,b,576,1);this.tss_size_32=k.view(Int32Array,b,1128,1);this.page_fault=k.view(Uint32Array,b,540,8);this.cr=k.view(Int32Array,b,580,8);this.cpl=k.view(Uint8Array,b,612,1);this.is_32=k.view(Int32Array,b,804,1);this.stack_size_32=k.view(Int32Array,
472
- b,808,1);this.in_hlt=k.view(Uint8Array,b,616,1);this.last_virt_eip=k.view(Int32Array,b,620,1);this.eip_phys=k.view(Int32Array,b,624,1);this.sysenter_cs=k.view(Int32Array,b,636,1);this.sysenter_esp=k.view(Int32Array,b,640,1);this.sysenter_eip=k.view(Int32Array,b,644,1);this.prefixes=k.view(Int32Array,b,648,1);this.flags=k.view(Int32Array,b,120,1);this.flags_changed=k.view(Int32Array,b,100,1);this.last_op_size=k.view(Int32Array,b,96,1);this.last_op1=k.view(Int32Array,b,104,1);this.last_result=k.view(Int32Array,
473
- b,112,1);this.current_tsc=k.view(Uint32Array,b,960,2);this.devices={};this.instruction_pointer=k.view(Int32Array,b,556,1);this.previous_ip=k.view(Int32Array,b,560,1);this.apic_enabled=k.view(Uint8Array,b,548,1);this.acpi_enabled=k.view(Uint8Array,b,552,1);this.memory_map_read8=[];this.memory_map_write8=[];this.memory_map_read32=[];this.memory_map_write32=[];this.bios={main:null,vga:null};this.instruction_counter=k.view(Uint32Array,b,664,1);this.reg32=k.view(Int32Array,b,64,8);this.fpu_st=k.view(Int32Array,
474
- b,1152,32);this.fpu_stack_empty=k.view(Uint8Array,b,816,1);this.fpu_stack_empty[0]=255;this.fpu_stack_ptr=k.view(Uint8Array,b,1032,1);this.fpu_stack_ptr[0]=0;this.fpu_control_word=k.view(Uint16Array,b,1036,1);this.fpu_control_word[0]=895;this.fpu_status_word=k.view(Uint16Array,b,1040,1);this.fpu_status_word[0]=0;this.fpu_ip=k.view(Int32Array,b,1048,1);this.fpu_ip[0]=0;this.fpu_ip_selector=k.view(Int32Array,b,1052,1);this.fpu_ip_selector[0]=0;this.fpu_opcode=k.view(Int32Array,b,1044,1);this.fpu_opcode[0]=
475
- 0;this.fpu_dp=k.view(Int32Array,b,1056,1);this.fpu_dp[0]=0;this.fpu_dp_selector=k.view(Int32Array,b,1060,1);this.fpu_dp_selector[0]=0;this.reg_xmm32s=k.view(Int32Array,b,832,32);this.mxcsr=k.view(Int32Array,b,824,1);this.sreg=k.view(Uint16Array,b,668,8);this.dreg=k.view(Int32Array,b,684,8);this.reg_pdpte=k.view(Int32Array,b,968,8);this.svga_dirty_bitmap_min_offset=k.view(Uint32Array,b,716,1);this.svga_dirty_bitmap_max_offset=k.view(Uint32Array,b,720,1);this.fw_value=[];this.fw_pointer=0;this.option_roms=
476
- [];this.io=void 0;this.bus=a;this.set_tsc(0,0);this.debug_init();this.seen_code={};this.seen_code_uncompiled={}}G.prototype.clear_opstats=function(){(new Uint8Array(this.wasm_memory.buffer,32768,131072)).fill(0);this.wm.exports.profiler_init()};G.prototype.create_jit_imports=function(){const a=Object.create(null);a.m=this.wm.exports.memory;for(const b of Object.keys(this.wm.exports))b.startsWith("_")||b.startsWith("zstd")||b.endsWith("_js")||(a[b]=this.wm.exports[b]);this.jit_imports=a};G.prototype.wasm_patch=
477
- function(){const a=c=>this.wm.exports[c],b=c=>{const d=a(c);console.assert(d,"Missing import: "+c);return d};this.reset_cpu=b("reset_cpu");this.getiopl=b("getiopl");this.get_eflags=b("get_eflags");this.handle_irqs=b("handle_irqs");this.main_loop=b("main_loop");this.set_jit_config=b("set_jit_config");this.read8=b("read8");this.read16=b("read16");this.read32s=b("read32s");this.write8=b("write8");this.write16=b("write16");this.write32=b("write32");this.in_mapped_range=b("in_mapped_range");this.fpu_load_tag_word=
478
- b("fpu_load_tag_word");this.fpu_load_status_word=b("fpu_load_status_word");this.fpu_get_sti_f64=b("fpu_get_sti_f64");this.translate_address_system_read=b("translate_address_system_read_js");this.get_seg_cs=b("get_seg_cs");this.get_real_eip=b("get_real_eip");this.clear_tlb=b("clear_tlb");this.full_clear_tlb=b("full_clear_tlb");this.update_state_flags=b("update_state_flags");this.set_tsc=b("set_tsc");this.store_current_tsc=b("store_current_tsc");this.set_cpuid_level=b("set_cpuid_level");this.pic_set_irq=
479
- b("pic_set_irq");this.pic_clear_irq=b("pic_clear_irq");this.jit_force_generate_unsafe=a("jit_force_generate_unsafe");this.jit_clear_cache=b("jit_clear_cache_js");this.jit_dirty_cache=b("jit_dirty_cache");this.codegen_finalize_finished=b("codegen_finalize_finished");this.allocate_memory=b("allocate_memory");this.zero_memory=b("zero_memory");this.is_memory_zeroed=b("is_memory_zeroed");this.svga_allocate_memory=b("svga_allocate_memory");this.svga_allocate_dest_buffer=b("svga_allocate_dest_buffer");this.svga_fill_pixel_buffer=
480
- b("svga_fill_pixel_buffer");this.svga_mark_dirty=b("svga_mark_dirty");this.get_pic_addr_master=b("get_pic_addr_master");this.get_pic_addr_slave=b("get_pic_addr_slave");this.zstd_create_ctx=b("zstd_create_ctx");this.zstd_get_src_ptr=b("zstd_get_src_ptr");this.zstd_free_ctx=b("zstd_free_ctx");this.zstd_read=b("zstd_read");this.zstd_read_free=b("zstd_read_free");this.port20_read=b("port20_read");this.port21_read=b("port21_read");this.portA0_read=b("portA0_read");this.portA1_read=b("portA1_read");this.port20_write=
481
- b("port20_write");this.port21_write=b("port21_write");this.portA0_write=b("portA0_write");this.portA1_write=b("portA1_write");this.port4D0_read=b("port4D0_read");this.port4D1_read=b("port4D1_read");this.port4D0_write=b("port4D0_write");this.port4D1_write=b("port4D1_write")};G.prototype.jit_force_generate=function(a){this.jit_force_generate_unsafe?this.jit_force_generate_unsafe(a):h(!1,"Not supported in this wasm build: jit_force_generate_unsafe")};G.prototype.jit_clear_func=function(a){h(0<=a&&900>
482
- a);this.wm.wasm_table.set(a+1024,null)};G.prototype.jit_clear_all_funcs=function(){const a=this.wm.wasm_table;for(let b=0;900>b;b++)a.set(1024+b,null)};G.prototype.get_state=function(){var a=[];a[0]=this.memory_size[0];a[1]=new Uint8Array([...this.segment_is_null,...this.segment_access_bytes]);a[2]=this.segment_offsets;a[3]=this.segment_limits;a[4]=this.protected_mode[0];a[5]=this.idtr_offset[0];a[6]=this.idtr_size[0];a[7]=this.gdtr_offset[0];a[8]=this.gdtr_size[0];a[9]=this.page_fault[0];a[10]=this.cr;
483
- a[11]=this.cpl[0];a[13]=this.is_32[0];a[16]=this.stack_size_32[0];a[17]=this.in_hlt[0];a[18]=this.last_virt_eip[0];a[19]=this.eip_phys[0];a[22]=this.sysenter_cs[0];a[23]=this.sysenter_eip[0];a[24]=this.sysenter_esp[0];a[25]=this.prefixes[0];a[26]=this.flags[0];a[27]=this.flags_changed[0];a[28]=this.last_op1[0];a[30]=this.last_op_size[0];a[37]=this.instruction_pointer[0];a[38]=this.previous_ip[0];a[39]=this.reg32;a[40]=this.sreg;a[41]=this.dreg;a[42]=this.reg_pdpte;this.store_current_tsc();a[43]=this.current_tsc;
484
- a[45]=this.devices.virtio_9p;a[46]=this.devices.apic;a[47]=this.devices.rtc;a[48]=this.devices.pci;a[49]=this.devices.dma;a[50]=this.devices.acpi;a[52]=this.devices.vga;a[53]=this.devices.ps2;a[54]=this.devices.uart0;a[55]=this.devices.fdc;a[56]=this.devices.cdrom;a[57]=this.devices.hda;a[58]=this.devices.pit;a[59]=this.devices.net;a[60]=this.get_state_pic();a[61]=this.devices.sb16;a[62]=this.fw_value;a[63]=this.devices.ioapic;a[64]=this.tss_size_32[0];a[66]=this.reg_xmm32s;a[67]=this.fpu_st;a[68]=
485
- this.fpu_stack_empty[0];a[69]=this.fpu_stack_ptr[0];a[70]=this.fpu_control_word[0];a[71]=this.fpu_ip[0];a[72]=this.fpu_ip_selector[0];a[73]=this.fpu_dp[0];a[74]=this.fpu_dp_selector[0];a[75]=this.fpu_opcode[0];const {packed_memory:b,bitmap:c}=this.pack_memory();a[77]=b;a[78]=new Uint8Array(c.get_buffer());a[79]=this.devices.uart1;a[80]=this.devices.uart2;a[81]=this.devices.uart3;a[82]=this.devices.virtio_console;a[83]=this.devices.virtio_net;a[84]=this.devices.virtio_balloon;return a};G.prototype.get_state_pic=
486
- function(){const a=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13),c=[],d=[];c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=d;c[6]=a[6];c[7]=a[7];c[8]=a[8];c[9]=a[9];c[10]=a[10];c[11]=a[11];c[12]=a[12];d[0]=b[0];d[1]=b[1];d[2]=b[2];d[3]=b[3];d[4]=b[4];d[5]=null;d[6]=b[6];d[7]=b[7];d[8]=b[8];d[9]=b[9];d[10]=b[10];d[11]=b[11];d[12]=b[12];return c};G.prototype.set_state=function(a){this.memory_size[0]=
487
- a[0];this.mem8.length!==this.memory_size[0]&&console.warn("Note: Memory size mismatch. we="+this.mem8.length+" state="+this.memory_size[0]);8===a[1].length?(this.segment_is_null.set(a[1]),this.segment_access_bytes.fill(242),this.segment_access_bytes[1]=250):16===a[1].length?(this.segment_is_null.set(a[1].subarray(0,8)),this.segment_access_bytes.set(a[1].subarray(8,16))):h("Unexpected cpu segment state length:"+a[1].length);this.segment_offsets.set(a[2]);this.segment_limits.set(a[3]);this.protected_mode[0]=
488
- a[4];this.idtr_offset[0]=a[5];this.idtr_size[0]=a[6];this.gdtr_offset[0]=a[7];this.gdtr_size[0]=a[8];this.page_fault[0]=a[9];this.cr.set(a[10]);this.cpl[0]=a[11];this.is_32[0]=a[13];this.stack_size_32[0]=a[16];this.in_hlt[0]=a[17];this.last_virt_eip[0]=a[18];this.eip_phys[0]=a[19];this.sysenter_cs[0]=a[22];this.sysenter_eip[0]=a[23];this.sysenter_esp[0]=a[24];this.prefixes[0]=a[25];this.flags[0]=a[26];this.flags_changed[0]=a[27];this.last_op1[0]=a[28];this.last_op_size[0]=a[30];this.instruction_pointer[0]=
489
- a[37];this.previous_ip[0]=a[38];this.reg32.set(a[39]);this.sreg.set(a[40]);this.dreg.set(a[41]);a[42]&&this.reg_pdpte.set(a[42]);this.set_tsc(a[43][0],a[43][1]);this.devices.virtio_9p&&this.devices.virtio_9p.set_state(a[45]);this.devices.apic&&this.devices.apic.set_state(a[46]);this.devices.rtc&&this.devices.rtc.set_state(a[47]);this.devices.pci&&this.devices.pci.set_state(a[48]);this.devices.dma&&this.devices.dma.set_state(a[49]);this.devices.acpi&&this.devices.acpi.set_state(a[50]);this.devices.vga&&
490
- this.devices.vga.set_state(a[52]);this.devices.ps2&&this.devices.ps2.set_state(a[53]);this.devices.uart0&&this.devices.uart0.set_state(a[54]);this.devices.fdc&&this.devices.fdc.set_state(a[55]);this.devices.cdrom&&this.devices.cdrom.set_state(a[56]);this.devices.hda&&this.devices.hda.set_state(a[57]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);this.set_state_pic(a[60]);this.devices.sb16&&this.devices.sb16.set_state(a[61]);this.devices.uart1&&
491
- this.devices.uart1.set_state(a[79]);this.devices.uart2&&this.devices.uart2.set_state(a[80]);this.devices.uart3&&this.devices.uart3.set_state(a[81]);this.devices.virtio_console&&this.devices.virtio_console.set_state(a[82]);this.devices.virtio_net&&this.devices.virtio_net.set_state(a[83]);this.devices.virtio_balloon&&this.devices.virtio_balloon.set_state(a[84]);this.fw_value=a[62];this.devices.ioapic&&this.devices.ioapic.set_state(a[63]);this.tss_size_32[0]=a[64];this.reg_xmm32s.set(a[66]);this.fpu_st.set(a[67]);
492
- this.fpu_stack_empty[0]=a[68];this.fpu_stack_ptr[0]=a[69];this.fpu_control_word[0]=a[70];this.fpu_ip[0]=a[71];this.fpu_ip_selector[0]=a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=a[75];const b=new k.Bitmap(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();this.jit_clear_cache()};G.prototype.set_state_pic=function(a){const b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),c=new Uint8Array(this.wasm_memory.buffer,
493
- this.get_pic_addr_slave(),13);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];const d=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]};G.prototype.pack_memory=function(){h(0===(this.mem8.length&4095));var a=this.mem8.length>>12,b=[];for(var c=0;c<a;c++)this.is_memory_zeroed(c<<12,4096)||b.push(c);a=new k.Bitmap(a);c=new Uint8Array(b.length<<
494
- 12);for(const [d,e]of b.entries())a.set(e,1),b=e<<12,b=this.mem8.subarray(b,b+4096),c.set(b,d<<12);return{bitmap:a,packed_memory:c}};G.prototype.unpack_memory=function(a,b){this.zero_memory(0,this.memory_size[0]);const c=this.memory_size[0]>>12;let d=0;for(let g=0;g<c;g++)if(a.get(g)){var e=d<<12;e=b.subarray(e,e+4096);this.mem8.set(e,g<<12);d++}};G.prototype.reboot_internal=function(){this.reset_cpu();this.fw_value=[];this.devices.virtio_9p&&this.devices.virtio_9p.reset();this.devices.virtio_console&&
495
- this.devices.virtio_console.reset();this.devices.virtio_net&&this.devices.virtio_net.reset();this.load_bios()};G.prototype.reset_memory=function(){this.mem8.fill(0)};G.prototype.create_memory=function(a,b){a<b?(a=b,E("Rounding memory size up to "+a,2)):0>(a|0)&&(a=Math.pow(2,31)-131072,E("Rounding memory size down to "+a,2));a=(a-1|131071)+1|0;h(0<(a|0));h(0===(a&131071));console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;b=this.allocate_memory(a);this.mem8=
496
- k.view(Uint8Array,this.wasm_memory,b,a);this.mem32s=k.view(Uint32Array,this.wasm_memory,b,a>>2)};G.prototype.init=function(a,b){this.create_memory(a.memory_size||67108864,a.initrd?67108864:1048576);a.disable_jit&&this.set_jit_config(0,1);a.cpuid_level&&this.set_cpuid_level(a.cpuid_level);this.acpi_enabled[0]=+a.acpi;this.reset_cpu();var c=new pa(this);this.io=c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();if(a.bzimage){const e=Gb(this.mem8,a.bzimage,a.initrd,a.cmdline||"");e&&this.option_roms.push(e)}c.register_read(179,
497
- this,function(){E("port 0xB3 read");return 0});var d=0;c.register_read(146,this,function(){return d});c.register_write(146,this,function(e){d=e});c.register_read(1297,this,function(){if(this.fw_pointer<this.fw_value.length)return this.fw_value[this.fw_pointer++];h(!1,"config port: Read past value");return 0});c.register_write(1296,this,void 0,function(e){function g(n){return new Uint8Array(Int32Array.of(n).buffer)}function f(n){return n>>8|n<<8&65280}function l(n){return n<<24|n<<8&16711680|n>>8&
498
- 65280|n>>>24}E("bios config port, index="+B(e));this.fw_pointer=0;if(0===e)this.fw_value=g(1431127377);else if(1===e)this.fw_value=g(0);else if(3===e)this.fw_value=g(this.memory_size[0]);else if(5===e)this.fw_value=g(1);else if(15===e)this.fw_value=g(1);else if(13===e)this.fw_value=new Uint8Array(16);else if(25===e){e=new Int32Array(4+64*this.option_roms.length);const n=new Uint8Array(e.buffer);e[0]=l(this.option_roms.length);for(let m=0;m<this.option_roms.length;m++){const {name:q,data:r}=this.option_roms[m],
499
- t=4+64*m;h(65536>49152+m);e[t+0>>2]=l(r.length);e[t+4>>2]=f(49152+m);h(56>q.length);for(let v=0;v<q.length;v++)n[t+8+v]=q.charCodeAt(v)}this.fw_value=n}else 32768<=e&&49152>e?this.fw_value=g(0):49152<=e&&e-49152<this.option_roms.length?this.fw_value=this.option_roms[e-49152].data:(E("Warning: Unimplemented fw index: "+B(e)),this.fw_value=g(0))});c.register_write(128,this,function(){});c.register_read(128,this,function(){return 255});c.register_write(233,this,function(){});c.register_read(32,this,
500
- this.port20_read);c.register_read(33,this,this.port21_read);c.register_read(160,this,this.portA0_read);c.register_read(161,this,this.portA1_read);c.register_write(32,this,this.port20_write);c.register_write(33,this,this.port21_write);c.register_write(160,this,this.portA0_write);c.register_write(161,this,this.portA1_write);c.register_read(1232,this,this.port4D0_read);c.register_read(1233,this,this.port4D1_read);c.register_write(1232,this,this.port4D0_write);c.register_write(1233,this,this.port4D1_write);
501
- this.devices={};a.load_devices&&(this.devices.pci=new za(this),this.acpi_enabled[0]&&(this.devices.ioapic=new Na(this),this.devices.apic=new Ma(this),this.devices.acpi=new Ha(this)),this.devices.rtc=new Fa(this),this.fill_cmos(this.devices.rtc,a),this.devices.dma=new O(this),this.devices.vga=new P(this,b,a.screen,a.vga_memory_size||8388608),this.devices.ps2=new Ea(this,b),this.devices.uart0=new Ga(this,1016,b),a.uart1&&(this.devices.uart1=new Ga(this,760,b)),a.uart2&&(this.devices.uart2=new Ga(this,
502
- 1E3,b)),a.uart3&&(this.devices.uart3=new Ga(this,744,b)),this.devices.fdc=new N(this,a.fda,a.fdb),c=0,a.hda&&(this.devices.hda=new ya(this,a.hda,a.hdb,!1,c++,b)),a.cdrom&&(this.devices.cdrom=new ya(this,a.cdrom,void 0,!0,c++,b)),this.devices.pit=new Aa(this,b),"ne2k"===a.net_device.type?this.devices.net=new Va(this,b,a.preserve_mac_from_state_image,a.mac_address_translation):"virtio"===a.net_device.type&&(this.devices.virtio_net=new sb(this,b,a.preserve_mac_from_state_image)),a.fs9p&&(this.devices.virtio_9p=
503
- new ea(a.fs9p,this,b)),a.virtio_console&&(this.devices.virtio_console=new rb(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=new Db(this,b)),this.devices.sb16=new Q(this,b));a.multiboot&&(E("loading multiboot",2),a=this.load_multiboot_option_rom(a.multiboot,a.initrd,a.cmdline))&&(this.bios.main?(E("adding option rom for multiboot",2),this.option_roms.push(a)):(E("loaded multiboot without bios",2),this.reg32[0]=this.io.port_read32(244)));this.debug.init()};G.prototype.load_multiboot=function(a){this.bios.main&&
504
- h(!1,"load_multiboot not supported with BIOS");this.load_multiboot_option_rom(a,void 0,"")&&(E("loaded multiboot",2),this.reg32[0]=this.io.port_read32(244))};G.prototype.load_multiboot_option_rom=function(a,b,c){E("Trying multiboot from buffer of size "+a.byteLength,2);if(8192>a.byteLength){var d=new Int32Array(2048);(new Uint8Array(d.buffer)).set(new Uint8Array(a))}else d=new Int32Array(a,0,2048);for(var e=0;8192>e;e+=4){if(464367618===d[e>>2]){var g=d[e+4>>2];if(464367618+g+d[e+8>>2]|0){E("Multiboot checksum check failed",
505
- 2);continue}}else continue;E("Multiboot magic found, flags: "+B(g>>>0,8),2);h(0===(g&-65540),"TODO");var f=this;this.io.register_read(244,this,function(){return 0},function(){return 0},function(){var q=31860,r=0;if(c){r|=4;f.write32(31760,q);c+="\x00";var t=(new TextEncoder).encode(c);f.write_blob(t,q);q+=t.length}if(g&2){r|=64;t=0;f.write32(31788,0);f.write32(31792,q);var v=0;let x=!1;for(let H=0;4294967296>H;H+=131072)x&&void 0!==f.memory_map_read8[H>>>17]?(f.write32(q,20),f.write32(q+4,v),f.write32(q+
506
- 8,0),f.write32(q+12,H-v),f.write32(q+16,0),f.write32(q+20,1),q+=24,t+=24,x=!1):x||void 0!==f.memory_map_read8[H>>>17]||(v=H,x=!0);h(!x,"top of 4GB shouldn't have memory");f.write32(31788,t)}f.write32(31744,r);t=r=0;if(g&65536){E("Multiboot specifies its own address table",2);var y=d[e+12>>2];var D=d[e+16>>2];var u=d[e+20>>2];var A=d[e+24>>2];r=d[e+28>>2];E("header="+B(y,8)+" load="+B(D,8)+" load_end="+B(u,8)+" bss_end="+B(A,8)+" entry="+B(r,8));h(D<=y);y=e-(y-D);0===u?t=void 0:(h(u>=D),t=u-D);y=new Uint8Array(a,
507
- y,t);f.write_blob(y,D);r|=0;t=Math.max(u,A)}else if(1179403647===d[0]){E("Multiboot image is in elf format",2);v=new DataView(a);const [x,H]=Hb(v,Ib);console.assert(52===H);for(y of Object.keys(x))E(y+": 0x"+(x[y].toString(16)>>>0));console.assert(1179403647===x.magic,"Bad magic");console.assert(1===x.class,"Unimplemented: 64 bit elf");console.assert(1===x.data,"Unimplemented: big endian");console.assert(1===x.version0,"Bad version0");console.assert(2===x.type,"Unimplemented type");console.assert(1===
508
- x.version1,"Bad version1");console.assert(52===x.ehsize,"Bad header size");console.assert(32===x.phentsize,"Bad program header size");console.assert(40===x.shentsize,"Bad section header size");[r]=Jb(new DataView(v.buffer,v.byteOffset+x.phoff,x.phentsize*x.phnum),Kb,x.phnum);[y]=Jb(new DataView(v.buffer,v.byteOffset+x.shoff,x.shentsize*x.shnum),Lb,x.shnum);if(ma){console.log("%d program headers:",r.length);for(A of r)console.log("type=%s offset=%s vaddr=%s paddr=%s filesz=%s memsz=%s flags=%s align=%s",
509
- A.type.toString(16),A.offset.toString(16),A.vaddr.toString(16),A.paddr.toString(16),A.filesz.toString(16),A.memsz.toString(16),A.flags.toString(16),A.align.toString(16));console.log("%d section headers:",y.length);for(D of y)console.log("name=%s type=%s flags=%s addr=%s offset=%s size=%s link=%s info=%s addralign=%s entsize=%s",D.name.toString(16),D.type.toString(16),D.flags.toString(16),D.addr.toString(16),D.offset.toString(16),D.size.toString(16),D.link.toString(16),D.info.toString(16),D.addralign.toString(16),
510
- D.entsize.toString(16))}A=x;D=r;r=A.entry;for(u of D)0!==u.type&&(1===u.type?(h(u.filesz<=u.memsz),u.paddr+u.memsz<f.memory_size[0]?(u.filesz&&(D=new Uint8Array(a,u.offset,u.filesz),f.write_blob(D,u.paddr)),t=Math.max(t,u.paddr+u.memsz),E("prg load "+u.paddr+" to "+(u.paddr+u.memsz),2),r===A.entry&&u.vaddr<=r&&u.vaddr+u.memsz>r&&(r=r-u.vaddr+u.paddr)):E("Warning: Skipped loading section, paddr="+B(u.paddr)+" memsz="+u.memsz,2)):2===u.type||3===u.type||4===u.type||6===u.type||7===u.type||1685382480===
511
- u.type||1685382481===u.type||1685382482===u.type||1685382483===u.type?E("skip load type "+u.type+" "+u.paddr+" to "+(u.paddr+u.memsz),2):h(!1,"unimplemented elf section type: "+B(u.type)))}else h(!1,"Not a bootable multiboot format");b&&(f.write32(31764,1),f.write32(31768,q),u=t,0!==(u&4095)&&(u=(u&-4096)+4096),E("ramdisk address "+u),A=u+b.byteLength,f.write32(q,u),f.write32(q+4,A),f.write32(q+8,0),f.write32(q+12,0),h(A<f.memory_size[0]),f.write_blob(new Uint8Array(b),u));f.reg32[3]=31744;f.cr[0]=
512
- 1;f.protected_mode[0]=1;f.flags[0]=2;f.is_32[0]=1;f.stack_size_32[0]=1;for(q=0;6>q;q++)f.segment_is_null[q]=0,f.segment_offsets[q]=0,f.segment_limits[q]=4294967295,f.sreg[q]=45058;f.instruction_pointer[0]=f.get_seg_cs()+r|0;f.update_state_flags();E("Starting multiboot kernel at:",2);f.debug.dump_state();f.debug.dump_regs();return 732803074});this.io.register_write_consecutive(244,this,function(q){console.log("Test exited with code "+B(q,2));throw"HALT";},function(){},function(){},function(){});for(let q=
513
- 0;15>=q;q++){function r(t){E("kvm-unit-test: Set irq "+B(q)+" to "+B(t,2));t?this.device_raise_irq(q):this.device_lower_irq(q)}this.io.register_write(8192+q,this,r,r,r)}const n=new Uint8Array(512);(new Uint16Array(n.buffer))[0]=43605;n[2]=1;var l=3;n[l++]=102;n[l++]=229;n[l++]=244;h(512>l);let m=n[l]=0;for(let q=0;q<n.length;q++)m+=n[q];n[l]=-m;return{name:"genroms/multiboot.bin",data:n}}E("Multiboot header not found",2)};G.prototype.fill_cmos=function(a,b){var c=b.boot_order||291;a.cmos_write(56,
514
- 1|c>>4&240);a.cmos_write(61,c&255);a.cmos_write(21,128);a.cmos_write(22,2);c=0;1048576<=this.memory_size[0]&&(c=this.memory_size[0]-1048576>>10,c=Math.min(c,65535));a.cmos_write(23,c&255);a.cmos_write(24,c>>8&255);a.cmos_write(48,c&255);a.cmos_write(49,c>>8&255);c=0;16777216<=this.memory_size[0]&&(c=this.memory_size[0]-16777216>>16,c=Math.min(c,65535));a.cmos_write(52,c&255);a.cmos_write(53,c>>8&255);a.cmos_write(91,0);a.cmos_write(92,0);a.cmos_write(93,0);a.cmos_write(20,47);a.cmos_write(95,0);b.fastboot&&
515
- a.cmos_write(63,1)};G.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){h(a instanceof ArrayBuffer);var c=new Uint8Array(a);this.write_blob(c,1048576-a.byteLength);if(b){h(b instanceof ArrayBuffer);var d=new Uint8Array(b);this.write_blob(d,786432);this.io.mmap_register(4272947200,1048576,function(e){e=e-4272947200|0;return e<d.length?d[e]:0},function(){h(!1,"Unexpected write to VGA rom")})}else E("Warning: No VGA BIOS");this.io.mmap_register(4293918720,1048576,function(e){return this.mem8[e&
516
- 1048575]}.bind(this),function(e,g){this.mem8[e&1048575]=g}.bind(this))}else E("Warning: No BIOS")};G.prototype.codegen_finalize=function(a,b,c,d,e){d>>>=0;e>>>=0;h(0<=a&&900>a);const g=new Uint8Array(this.wasm_memory.buffer,d,e);this.seen_code[b]=(this.seen_code[b]||0)+1;this.test_hook_did_generate_wasm&&this.test_hook_did_generate_wasm(g);WebAssembly.instantiate(g,{e:this.jit_imports}).then(f=>{this.wm.wasm_table.set(a+1024,f.instance.exports.f);this.codegen_finalize_finished(a,b,c);this.test_hook_did_finalize_wasm&&
517
- this.test_hook_did_finalize_wasm(g)}).catch(f=>{console.log(f);debugger;throw f;})};G.prototype.log_uncompiled_code=function(){};G.prototype.dump_function_code=function(){};G.prototype.run_hardware_timers=function(a,b){const c=this.devices.pit.timer(b,!1),d=this.devices.rtc.timer(b,!1);let e=100,g=100;a&&(e=this.devices.acpi.timer(b),g=this.devices.apic.timer(b));return Math.min(c,d,e,g)};G.prototype.device_raise_irq=function(a){h(1===arguments.length);this.pic_set_irq(a);this.devices.ioapic&&this.devices.ioapic.set_irq(a)};
518
- G.prototype.device_lower_irq=function(a){this.pic_clear_irq(a);this.devices.ioapic&&this.devices.ioapic.clear_irq(a)};G.prototype.debug_init=function(){function a(m){for(var q=e.protected_mode[0]?"prot":"real",r=e.get_eflags(),t=e.getiopl(),v=e.cpl[0],y=B(e.sreg[1],4)+":"+B(e.get_real_eip()>>>0,8),D=B(e.sreg[2],4)+":"+B(e.reg32[0]>>>0,8),u=e.is_32[0]?"32":"16",A=e.flags[0]&512?1:0,x={[1]:"c",[4]:"p",[16]:"a",[64]:"z",[128]:"s",[256]:"t",[512]:"i",[1024]:"d",[2048]:"o"},H="",L=0;16>L;L++)x[1<<L]&&
519
- (H=r&1<<L?H+x[1<<L]:H+" ");return"mode="+q+"/"+u+" paging="+ +(0!==(e.cr[0]&-2147483648))+" pae="+ +(0!==(e.cr[4]&32))+" iopl="+t+" cpl="+v+" if="+A+" cs:eip="+y+" cs_off="+B(e.get_seg_cs()>>>0,8)+" flgs="+B(e.get_eflags()>>>0,6)+" ("+H+") ss:esp="+D+" ssize="+ +e.stack_size_32[0]+(m?" in "+m:"")}function b(){for(var m={eax:0,ecx:1,edx:2,ebx:3,esp:4,ebp:5,esi:6,edi:7},q="eax ecx edx ebx esp ebp esi edi".split(" "),r="",t="",v=0;4>v;v++)r+=q[v]+"="+B(e.reg32[m[q[v]]]>>>0,8)+" ",t+=q[v+4]+"="+B(e.reg32[m[q[v+
520
- 4]]]>>>0,8)+" ";r+=" ds="+B(e.sreg[3],4)+" es="+B(e.sreg[0],4)+" fs="+B(e.sreg[4],4);t+=" gs="+B(e.sreg[5],4)+" cs="+B(e.sreg[1],4)+" ss="+B(e.sreg[2],4);return[r,t]}function c(m,q,r){if(!(m&1))return!1;var t=128===(m&128);return{size:t,global:256===(m&256),accessed:32===(m&32),dirty:64===(m&64),cache_disable:16===(m&16),user:4===(m&4),read_write:2===(m&2),address:(t&&!r?m&(q?4292870144:4290772992):m&4294963200)>>>0}}function d(m,q,r){for(var t=q?512:1024,v=q?8:4,y=q?21:22,D=0;D<t;D++){var u=e.read32s(m+
521
- D*v),A=c(u,q,!0);if(A)if(u="",u+=A.size?"S ":" ",u+=A.accessed?"A ":" ",u+=A.cache_disable?"Cd ":" ",u+=A.user?"U ":" ",u+=A.read_write?"Rw ":" ",A.size)E("=== "+B(r+(D<<y)>>>0,8)+" -> "+B(A.address>>>0,8)+" | "+u);else{E("=== "+B(r+(D<<y)>>>0,8)+" | "+u);for(var x=0;x<t;x++){var H=A.address+x*v;u=e.read32s(H);var L=c(u,q,!1);L&&(u="",u+=L.cache_disable?"Cd ":" ",u+=L.user?"U ":" ",u+=L.read_write?"Rw ":" ",u+=L.global?"G ":" ",u+=L.accessed?"A ":" ",u+=L.dirty?"Di ":" ",E("# "+B(r+
522
- (D<<y|x<<12)>>>0,8)+" -> "+B(L.address,8)+" | "+u+" (at "+B(H,8)+")"))}}}}var e=this,g={};this.debug=g;g.init=function(){function m(r){10===r?(E(q,4096),q=""):q+=String.fromCharCode(r)}if(e.io){var q="";e.io.register_write(1026,this,m);e.io.register_write(1280,this,m)}};g.get_regs_short=b;g.dump_regs=function(){var m=b();E(m[0],2);E(m[1],2)};g.get_state=a;g.dump_state=function(m){E(a(m),2)};g.dump_stack=function(m,q){var r=e.reg32[4];E("========= STACK ==========");if(q>=m||void 0===q)m=5,
523
- q=-5;for(;m>q;m--){var t=" ";m||(t="=> ");t+=B(m,2)+" | ";E(t+B(r+4*m,8)+" | "+B(e.read32s(r+4*m)>>>0))}};g.dump_page_structures=function(){if(e.cr[4]&32){E("PAE enabled");for(var m=0;4>m;m++){var q=e.read32s(e.cr[3]+8*m);q&1&&d(q&4294963200,!0,m<<30)}}else E("PAE disabled"),d(e.cr[3],!1,0)};g.dump_gdt_ldt=function(){function m(q,r){for(var t=0;t<r;t+=8,q+=8){var v=e.read16(q+2)|e.read8(q+4)<<16|e.read8(q+7)<<24,y=e.read16(q)|(e.read8(q+6)&15)<<16,D=e.read8(q+5),u=e.read8(q+6)>>4,A="",x=D>>5&
524
- 3;A=D&128?A+" P ":A+"NP ";D&16?(A=u&4?A+"32b ":A+"16b ",D&8?(A+="X ",D&4&&(A+="C ")):A+="R ",A+="RW "):A+="sys: "+B(D&15);u&8&&(y=y<<12|4095);E(B(t&-8,4)+" "+B(v>>>0,8)+" ("+B(y>>>0,8)+" bytes) "+A+"; dpl = "+x+", a = "+D.toString(2)+", f = "+u.toString(2))}}E("gdt: (len = "+B(e.gdtr_size[0])+")");m(e.translate_address_system_read(e.gdtr_offset[0]),e.gdtr_size[0]);E("\nldt: (len = "+B(e.segment_limits[7])+")");m(e.translate_address_system_read(e.segment_offsets[7]),e.segment_limits[7])};g.dump_idt=
525
- function(){for(var m=0;m<e.idtr_size[0];m+=8){var q=e.translate_address_system_read(e.idtr_offset[0]+m),r=e.read16(q)|e.read16(q+6)<<16,t=e.read16(q+2);q=e.read8(q+5);var v=q>>5&3;var y=5===(q&31)?"task gate ":14===(q&31)?"intr gate ":15===(q&31)?"trap gate ":"invalid ";y=q&128?y+" P":y+"NP";E(B(m>>3,4)+" "+B(r>>>0,8)+", "+B(t,4)+"; "+y+"; dpl = "+v+", t = "+q.toString(2))}};g.get_memory_dump=function(m,q){void 0===m?(m=0,q=e.memory_size[0]):void 0===q&&(q=m,m=0);return e.mem8.slice(m,m+q).buffer};
526
- g.memory_hex_dump=function(m,q){q=q||64;for(var r,t,v=0;v<q>>4;v++){r=B(m+(v<<4),5)+" ";for(var y=0;16>y;y++)t=e.read8(m+(v<<4)+y),r+=B(t,2)+" ";r+=" ";for(y=0;16>y;y++)t=e.read8(m+(v<<4)+y),r+=33>t||126<t?".":String.fromCharCode(t);E(r)}};g.used_memory_dump=function(){for(var m=e.memory_size[0]/128/16|0,q,r=0;16>r;r++){q=B(128*r*m,8)+" | ";for(var t=0;128>t;t++)q+=0<e.mem32s[(128*r+t)*m]?"X":" ";E(q)}};g.debug_interrupt=function(){};let f,l;g.dump_code=function(m,q,r){if(!l){if(void 0===f&&(f=
527
- "function"===typeof require?require("./capstone-x86.min.js"):window.cs,void 0===f)){E("Warning: Missing capstone library, disassembly not available");return}l=[new f.Capstone(f.ARCH_X86,f.MODE_16),new f.Capstone(f.ARCH_X86,f.MODE_32)]}try{l[m].disasm(q,r).forEach(function(t){E(B(t.address>>>0)+": "+k.pads(t.bytes.map(v=>B(v,2).slice(-2)).join(" "),20)+" "+t.mnemonic+" "+t.op_str)}),E("")}catch(t){E("Could not disassemble: "+Array.from(q).map(v=>B(v,2)).join(" "))}};let n;g.dump_wasm=function(m){if(void 0===
528
- n&&(n="function"===typeof require?require("./libwabt.js"):new window.WabtModule,void 0===n)){E("Warning: Missing libwabt, wasm dump not available");return}m=m.slice();try{var q=n.readWasm(m,{readDebugNames:!1});q.generateNames();q.applyNames();const v=q.toText({foldExprs:!0,inlineExport:!0});E(v)}catch(v){var r=new Blob([m]),t=document.createElement("a");t.download="failed.wasm";t.href=window.URL.createObjectURL(r);t.dataset.downloadurl=["application/octet-stream",t.download,t.href].join(":");t.click();
529
- window.URL.revokeObjectURL(t.src);console.log(v.toString())}finally{q&&q.destroy()}}};const Mb=DataView.prototype,Nb={size:1,get:Mb.getUint8,set:Mb.setUint8},Ub={size:2,get:Mb.getUint16,set:Mb.setUint16},X={size:4,get:Mb.getUint32,set:Mb.setUint32},Ib=Vb([{magic:X},{class:Nb},{data:Nb},{version0:Nb},{osabi:Nb},{abiversion:Nb},{pad0:function(a){return{size:a,get:()=>-1}}(7)},{type:Ub},{machine:Ub},{version1:X},{entry:X},{phoff:X},{shoff:X},{flags:X},{ehsize:Ub},{phentsize:Ub},{phnum:Ub},{shentsize:Ub},
530
- {shnum:Ub},{shstrndx:Ub}]);console.assert(52===Ib.reduce((a,b)=>a+b.size,0));const Kb=Vb([{type:X},{offset:X},{vaddr:X},{paddr:X},{filesz:X},{memsz:X},{flags:X},{align:X}]);console.assert(32===Kb.reduce((a,b)=>a+b.size,0));const Lb=Vb([{name:X},{type:X},{flags:X},{addr:X},{offset:X},{size:X},{link:X},{info:X},{addralign:X},{entsize:X}]);console.assert(40===Lb.reduce((a,b)=>a+b.size,0));function Vb(a){return a.map(function(b){var c=Object.keys(b);console.assert(1===c.length);c=c[0];b=b[c];console.assert(0<
531
- b.size);return{name:c,type:b,size:b.size,get:b.get,set:b.set}})}function Hb(a,b){const c={};let d=0;for(const e of b)b=e.get.call(a,d,!0),console.assert(void 0===c[e.name]),c[e.name]=b,d+=e.size;return[c,d]}function Jb(a,b,c){const d=[];let e=0;for(var g=0;g<c;g++){const [f,l]=Hb(new DataView(a.buffer,a.byteOffset+e,void 0),b);d.push(f);e+=l}return[d,e]}function Gb(a,b,c,d){E("Trying to load kernel of size "+b.byteLength);var e=new Uint8Array(b);const g=new Uint16Array(b);var f=new Uint32Array(b),
532
- l=e[497]||4,n=g[255];if(43605!==n)E("Bad checksum1: "+B(n));else if(n=g[257]|g[258]<<16,1400005704!==n)E("Bad checksum2: "+B(n));else{n=g[259];h(514<=n);var m=e[529];h(m&1);var q=g[283],r=f[139],t=f[140],v=e[564],y=e[565],D=518<=n?f[142]:255,u=f[146],A=f[147],x=f[150],H=f[151],L=f[152];E("kernel boot protocol version: "+B(n));E("flags="+B(m)+" xflags="+B(q));E("code32_start="+B(f[133]));E("initrd_addr_max="+B(r));E("kernel_alignment="+B(t));E("relocatable="+v);E("min_alignment="+B(y));E("cmdline max="+
533
- B(D));E("payload offset="+B(u)+" size="+B(A));E("pref_address="+B(H)+":"+B(x));E("init_size="+B(L));e[528]=255;e[529]=m&-97|128;g[274]=56832;g[253]=65535;E("heap_end_ptr="+B(56832));d+="\x00";h(d.length<D);E("cmd_line_ptr="+B(581632));f[138]=581632;for(e=0;e<d.length;e++)a[581632+e]=d.charCodeAt(e);l=512*(l+1);E("prot_mode_kernel_start="+B(l));d=new Uint8Array(b,0,l);b=new Uint8Array(b,l);e=l=0;c&&(l=67108864,e=c.byteLength,h(1048576+b.length<l),a.set(new Uint8Array(c),l));f[134]=l;f[135]=e;h(655360>
534
- 524288+d.length);a.set(d,524288);a.set(b,1048576);a=new Uint8Array(512);(new Uint16Array(a.buffer))[0]=43605;a[2]=1;c=3;a[c++]=250;a[c++]=184;a[c++]=32768;a[c++]=128;a[c++]=142;a[c++]=192;a[c++]=142;a[c++]=216;a[c++]=142;a[c++]=224;a[c++]=142;a[c++]=232;a[c++]=142;a[c++]=208;a[c++]=188;a[c++]=57344;a[c++]=224;a[c++]=234;a[c++]=0;a[c++]=0;a[c++]=32800;a[c++]=128;h(512>c);f=a[c]=0;for(b=0;b<a.length;b++)f+=a[b];a[c]=-f;return{name:"genroms/kernel.bin",data:a}}}const Wb="undefined"!==typeof window&&
535
- 0<=window.navigator.platform.toString().toLowerCase().search("win");function Xb(a){function b(x){return x.shiftKey&&x.ctrlKey&&(73===x.keyCode||74===x.keyCode||75===x.keyCode)||!v.emu_enabled?!1:x.target?x.target.classList.contains("phone_keyboard")||"INPUT"!==x.target.nodeName&&"TEXTAREA"!==x.target.nodeName:!0}function c(x){!x.altKey&&m[56]&&l(56,!1);return g(x,!1)}function d(x){!x.altKey&&m[56]&&l(56,!1);return g(x,!0)}function e(){for(var x=Object.keys(m),H,L=0;L<x.length;L++)H=+x[L],m[H]&&l(H,
536
- !1);m={}}function g(x,H){if(v.bus&&b(x)){x.preventDefault&&x.preventDefault();if(Wb&&(q&&(clearTimeout(t),x.getModifierState&&x.getModifierState("AltGraph")&&r===H&&"ControlLeft"===q.code&&"AltRight"===x.code||f(q,r),q=null),"ControlLeft"===x.code))return q=x,r=H,t=setTimeout(()=>{f(q,r);q=null},10),!1;f(x,H);return!1}}function f(x,H){a:{if(void 0!==x.code){var L=A[x.code];if(void 0!==L)break a}L=y[x.keyCode]}L?l(L,H,x.repeat):console.log("Missing char in map: keyCode="+(x.keyCode||-1).toString(16)+
537
- " code="+x.code)}function l(x,H,L){if(H)m[x]&&!L&&l(x,!1);else if(!m[x])return;(m[x]=H)||(x|=128);255<x?(n(x>>8),n(x&255)):n(x)}function n(x){v.bus.send("keyboard-code",x)}var m={},q=null,r=!1,t=0,v=this;this.emu_enabled=!0;var y=new Uint16Array([0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,0,58,0,0,0,0,0,0,1,0,0,0,0,57,57417,57425,57423,57415,57419,57416,57421,80,0,0,0,0,82,83,0,11,2,3,4,5,6,7,8,9,10,0,39,0,13,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44,57435,
538
- 57436,57437,0,0,82,79,80,81,75,76,77,71,72,73,0,0,0,0,0,0,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,40,0,57435,57400,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),D={8:8,10:13,32:32,39:222,44:188,45:189,46:190,47:191,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,59:186,61:187,91:219,92:220,93:221,96:192,
539
- 97:65,98:66,99:67,100:68,101:69,102:70,103:71,104:72,105:73,106:74,107:75,108:76,109:77,110:78,111:79,112:80,113:81,114:82,115:83,116:84,117:85,118:86,119:87,120:88,121:89,122:90},u={33:49,34:222,35:51,36:52,37:53,38:55,40:57,41:48,42:56,43:187,58:186,60:188,62:190,63:191,64:50,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,94:54,95:189,123:219,124:220,125:221,126:192},A={Escape:1,Digit1:2,
540
- Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,IntlRo:53,ShiftRight:54,NumpadMultiply:55,
541
- AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,IntlBackslash:86,F11:87,F12:88,NumpadEnter:57372,ControlRight:57373,NumpadDivide:57397,AltRight:57400,Home:57415,ArrowUp:57416,PageUp:57417,ArrowLeft:57419,ArrowRight:57421,End:57423,ArrowDown:57424,PageDown:57425,Insert:57426,
542
- Delete:57427,OSLeft:57435,OSRight:57436,ContextMenu:57437};this.bus=a;this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("keyup",c,!1),window.removeEventListener("keydown",d,!1),window.removeEventListener("blur",e,!1))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("keyup",c,!1),window.addEventListener("keydown",d,!1),window.addEventListener("blur",e,!1))};this.init();this.simulate_press=function(x){x={keyCode:x};g(x,!0);g(x,
543
- !1)};this.simulate_char=function(x){var H=x.charCodeAt(0);H in D?this.simulate_press(D[H]):H in u?(n(42),this.simulate_press(u[H]),n(170)):console.log("ascii -> keyCode not found: ",H,x)}}function Yb(a,b){function c(u){if(!D.enabled||!D.emu_enabled)return!1;var A=b||document.body,x;if(!(x=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===A){x=!0;break a}u=u.parentNode}x=!1}return x}function d(u){c(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-1],v=u.clientX,y=u.clientY)}function e(){if(q||
544
- t||r)D.bus.send("mouse-click",[!1,!1,!1]),q=t=r=!1}function g(u){if(D.bus&&c(u)&&D.is_running){var A=0,x=0,H=u.changedTouches;H?H.length&&(H=H[H.length-1],A=H.clientX-v,x=H.clientY-y,v=H.clientX,y=H.clientY,u.preventDefault()):"number"===typeof u.movementX?(A=u.movementX,x=u.movementY):"number"===typeof u.webkitMovementX?(A=u.webkitMovementX,x=u.webkitMovementY):"number"===typeof u.mozMovementX?(A=u.mozMovementX,x=u.mozMovementY):(A=u.clientX-v,x=u.clientY-y,v=u.clientX,y=u.clientY);D.bus.send("mouse-delta",
545
- [.15*A,-(.15*x)]);b&&D.bus.send("mouse-absolute",[u.pageX-b.offsetLeft,u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function f(u){c(u)&&n(u,!0)}function l(u){c(u)&&n(u,!1)}function n(u,A){D.bus&&(1===u.which?q=A:2===u.which?t=A:3===u.which?r=A:E("Unknown event.which: "+u.which),D.bus.send("mouse-click",[q,t,r]),u.preventDefault())}function m(u){if(c(u)){var A=u.wheelDelta||-u.detail;0>A?A=-1:0<A&&(A=1);D.bus.send("mouse-wheel",[A,0]);u.preventDefault()}}var q=!1,r=!1,t=!1,v=0,y=0,D=this;this.enabled=
546
- !1;this.emu_enabled=!0;this.bus=a;this.bus.register("mouse-enable",function(u){this.enabled=u},this);this.is_running=!1;this.bus.register("emulator-stopped",function(){this.is_running=!1},this);this.bus.register("emulator-started",function(){this.is_running=!0},this);this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("touchstart",d,!1),window.removeEventListener("touchend",e,!1),window.removeEventListener("touchmove",g,!1),window.removeEventListener("mousemove",g,!1),
547
- window.removeEventListener("mousedown",f,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("wheel",m,{passive:!1}))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("touchstart",d,!1),window.addEventListener("touchend",e,!1),window.addEventListener("touchmove",g,!1),window.addEventListener("mousemove",g,!1),window.addEventListener("mousedown",f,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("wheel",m,{passive:!1}))};
548
- this.init()}function Zb(a){if("undefined"!==typeof window)if(window.AudioContext||window.webkitAudioContext){var b=window.AudioWorklet?$b:ac;this.bus=a;this.audio_context=window.AudioContext?new AudioContext:new webkitAudioContext;this.mixer=new bc(a,this.audio_context);this.pcspeaker=new cc(a,this.audio_context,this.mixer);this.dac=new b(a,this.audio_context,this.mixer);this.pcspeaker.start();a.register("emulator-stopped",function(){this.audio_context.suspend()},this);a.register("emulator-started",
549
- function(){this.audio_context.resume()},this);a.register("speaker-confirm-initialized",function(){a.send("speaker-has-initialized")},this);a.send("speaker-has-initialized")}else console.warn("Web browser doesn't support Web Audio API")}Zb.prototype.destroy=function(){this.audio_context&&this.audio_context.close();this.audio_context=null;this.dac&&this.dac.node_processor&&this.dac.node_processor.port.close();this.dac=null};function bc(a,b){function c(d){return function(e){d.gain.setValueAtTime(e,this.audio_context.currentTime)}}
550
- this.audio_context=b;this.sources=new Map;this.gain_right=this.gain_left=this.volume_right=this.volume_left=this.volume_both=1;this.node_treble_left=this.audio_context.createBiquadFilter();this.node_treble_right=this.audio_context.createBiquadFilter();this.node_treble_left.type="highshelf";this.node_treble_right.type="highshelf";this.node_treble_left.frequency.setValueAtTime(2E3,this.audio_context.currentTime);this.node_treble_right.frequency.setValueAtTime(2E3,this.audio_context.currentTime);this.node_bass_left=
551
- this.audio_context.createBiquadFilter();this.node_bass_right=this.audio_context.createBiquadFilter();this.node_bass_left.type="lowshelf";this.node_bass_right.type="lowshelf";this.node_bass_left.frequency.setValueAtTime(200,this.audio_context.currentTime);this.node_bass_right.frequency.setValueAtTime(200,this.audio_context.currentTime);this.node_gain_left=this.audio_context.createGain();this.node_gain_right=this.audio_context.createGain();this.node_merger=this.audio_context.createChannelMerger(2);
552
- this.input_left=this.node_treble_left;this.input_right=this.node_treble_right;this.node_treble_left.connect(this.node_bass_left);this.node_bass_left.connect(this.node_gain_left);this.node_gain_left.connect(this.node_merger,0,0);this.node_treble_right.connect(this.node_bass_right);this.node_bass_right.connect(this.node_gain_right);this.node_gain_right.connect(this.node_merger,0,1);this.node_merger.connect(this.audio_context.destination);a.register("mixer-connect",function(d){this.connect_source(d[0],
553
- d[1])},this);a.register("mixer-disconnect",function(d){this.disconnect_source(d[0],d[1])},this);a.register("mixer-volume",function(d){var e=d[0],g=d[1];d=Math.pow(10,d[2]/20);var f=0===e?this:this.sources.get(e);void 0===f?h(!1,"Mixer set volume - cannot set volume for undefined source: "+e):f.set_volume(d,g)},this);a.register("mixer-gain-left",function(d){this.gain_left=Math.pow(10,d/20);this.update()},this);a.register("mixer-gain-right",function(d){this.gain_right=Math.pow(10,d/20);this.update()},
554
- this);a.register("mixer-treble-left",c(this.node_treble_left),this);a.register("mixer-treble-right",c(this.node_treble_right),this);a.register("mixer-bass-left",c(this.node_bass_left),this);a.register("mixer-bass-right",c(this.node_bass_right),this)}bc.prototype.add_source=function(a,b){a=new dc(this.audio_context,a,this.input_left,this.input_right);h(!this.sources.has(b),"Mixer add source - overwritting source: "+b);this.sources.set(b,a);return a};bc.prototype.connect_source=function(a,b){var c=
555
- this.sources.get(a);void 0===c?h(!1,"Mixer connect - cannot connect undefined source: "+a):c.connect(b)};bc.prototype.disconnect_source=function(a,b){var c=this.sources.get(a);void 0===c?h(!1,"Mixer disconnect - cannot disconnect undefined source: "+a):c.disconnect(b)};bc.prototype.set_volume=function(a,b){void 0===b&&(b=2);switch(b){case 0:this.volume_left=a;break;case 1:this.volume_right=a;break;case 2:this.volume_both=a;break;default:h(!1,"Mixer set master volume - unknown channel: "+b);return}this.update()};
556
- bc.prototype.update=function(){var a=this.volume_both*this.volume_right*this.gain_right;this.node_gain_left.gain.setValueAtTime(this.volume_both*this.volume_left*this.gain_left,this.audio_context.currentTime);this.node_gain_right.gain.setValueAtTime(a,this.audio_context.currentTime)};function dc(a,b,c,d){this.audio_context=a;this.connected_right=this.connected_left=!0;this.volume_right=this.volume_left=this.volume_both=this.gain_hidden=1;this.node_splitter=a.createChannelSplitter(2);this.node_gain_left=
557
- a.createGain();this.node_gain_right=a.createGain();b.connect(this.node_splitter);this.node_splitter.connect(this.node_gain_left,0);this.node_gain_left.connect(c);this.node_splitter.connect(this.node_gain_right,1);this.node_gain_right.connect(d)}dc.prototype.update=function(){var a=this.connected_right*this.gain_hidden*this.volume_both*this.volume_right;this.node_gain_left.gain.setValueAtTime(this.connected_left*this.gain_hidden*this.volume_both*this.volume_left,this.audio_context.currentTime);this.node_gain_right.gain.setValueAtTime(a,
558
- this.audio_context.currentTime)};dc.prototype.connect=function(a){var b=!a||2===a;if(b||0===a)this.connected_left=!0;if(b||1===a)this.connected_right=!0;this.update()};dc.prototype.disconnect=function(a){var b=!a||2===a;if(b||0===a)this.connected_left=!1;if(b||1===a)this.connected_right=!1;this.update()};dc.prototype.set_volume=function(a,b){void 0===b&&(b=2);switch(b){case 0:this.volume_left=a;break;case 1:this.volume_right=a;break;case 2:this.volume_both=a;break;default:h(!1,"Mixer set volume - unknown channel: "+
559
- b);return}this.update()};dc.prototype.set_gain_hidden=function(a){this.gain_hidden=a};function cc(a,b,c){this.node_oscillator=b.createOscillator();this.node_oscillator.type="square";this.node_oscillator.frequency.setValueAtTime(440,b.currentTime);this.mixer_connection=c.add_source(this.node_oscillator,1);this.mixer_connection.disconnect();a.register("pcspeaker-enable",function(){c.connect_source(1)},this);a.register("pcspeaker-disable",function(){c.disconnect_source(1)},this);a.register("pcspeaker-update",
560
- function(d){var e=d[1],g=0;3===d[0]&&(g=Math.min(1193181.6665999999/e,this.node_oscillator.frequency.maxValue),g=Math.max(g,0));this.node_oscillator.frequency.setValueAtTime(g,b.currentTime)},this)}cc.prototype.start=function(){this.node_oscillator.start()};function $b(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=48E3;b=function(){function f(m){if(0===m)return 1;m*=Math.PI;return Math.sin(m)/m}function l(){var m=Reflect.construct(AudioWorkletProcessor,[],l);m.kernel_size=
561
- 3;m.queue_data=Array(1024);m.queue_start=0;m.queue_end=0;m.queue_length=0;m.queue_size=m.queue_data.length;m.queued_samples=0;m.source_buffer_previous=n;m.source_buffer_current=n;m.source_samples_per_destination=1;m.source_block_start=0;m.source_time=0;m.source_offset=0;m.port.onmessage=q=>{switch(q.data.type){case "queue":m.queue_push(q.data.value);break;case "sampling-rate":m.source_samples_per_destination=q.data.value/sampleRate}};return m}var n=[new Float32Array(256),new Float32Array(256)];Reflect.setPrototypeOf(l.prototype,
562
- AudioWorkletProcessor.prototype);Reflect.setPrototypeOf(l,AudioWorkletProcessor);l.prototype.process=l.prototype.process=function(m,q){for(m=0;m<q[0][0].length;m++){for(var r=0,t=0,v=this.source_offset+this.kernel_size,y=this.source_offset-this.kernel_size+1;y<=v;y++){var D=this.source_block_start+y;r+=this.get_sample(D,0)*this.kernel(this.source_time-y);t+=this.get_sample(D,1)*this.kernel(this.source_time-y)}if(isNaN(r)||isNaN(t))r=t=0,this.dbg_log("ERROR: NaN values! Ignoring for now.");q[0][0][m]=
563
- r;q[0][1][m]=t;this.source_time+=this.source_samples_per_destination;this.source_offset=Math.floor(this.source_time)}q=this.source_offset;q+=this.kernel_size+2;this.source_time-=this.source_offset;this.source_block_start+=this.source_offset;this.source_offset=0;this.ensure_enough_data(q);return!0};l.prototype.kernel=function(m){return f(m)*f(m/this.kernel_size)};l.prototype.get_sample=function(m,q){return 0>m?(m+=this.source_buffer_previous[0].length,this.source_buffer_previous[q][m]):this.source_buffer_current[q][m]};
564
- l.prototype.ensure_enough_data=function(m){var q=this.source_buffer_current[0].length;q-this.source_block_start<m&&(this.prepare_next_buffer(),this.source_block_start-=q)};l.prototype.prepare_next_buffer=function(){256>this.queued_samples&&this.queue_length&&this.dbg_log("Not enough samples - should not happen during midway of playback");this.source_buffer_previous=this.source_buffer_current;this.source_buffer_current=this.queue_shift();var m=this.source_buffer_current[0].length;if(256>m){for(var q=
565
- this.queue_start,r=0;256>m&&r<this.queue_length;)m+=this.queue_data[q][0].length,q=q+1&this.queue_size-1,r++;m=Math.max(m,256);m=[new Float32Array(m),new Float32Array(m)];m[0].set(this.source_buffer_current[0]);m[1].set(this.source_buffer_current[1]);q=this.source_buffer_current[0].length;for(var t=0;t<r;t++){var v=this.queue_shift();m[0].set(v[0],q);m[1].set(v[1],q);q+=v[0].length}this.source_buffer_current=m}this.pump()};l.prototype.pump=function(){1024>this.queued_samples/this.source_samples_per_destination&&
566
- this.port.postMessage({type:"pump"})};l.prototype.queue_push=function(m){this.queue_length<this.queue_size&&(this.queue_data[this.queue_end]=m,this.queue_end=this.queue_end+1&this.queue_size-1,this.queue_length++,this.queued_samples+=m[0].length,this.pump())};l.prototype.queue_shift=function(){if(!this.queue_length)return n;var m=this.queue_data[this.queue_start];this.queue_data[this.queue_start]=null;this.queue_start=this.queue_start+1&this.queue_size-1;this.queue_length--;this.queued_samples-=m[0].length;
567
- return m};l.prototype.dbg_log=function(m){this.port.postMessage({type:"debug-log",value:m})};registerProcessor("dac-processor",l)}.toString();var d=b.indexOf("{")+1,e=b.lastIndexOf("}");b=b.substring(d,e);b=new Blob(["var DEBUG = true;\n"+b],{type:"application/javascript"});var g=URL.createObjectURL(b);this.node_processor=null;this.node_output=this.audio_context.createGain();this.audio_context.audioWorklet.addModule(g).then(()=>{URL.revokeObjectURL(g);this.node_processor=new AudioWorkletNode(this.audio_context,
568
- "dac-processor",{numberOfInputs:0,numberOfOutputs:1,outputChannelCount:[2],parameterData:{},processorOptions:{}});this.node_processor.port.postMessage({type:"sampling-rate",value:this.sampling_rate});this.node_processor.port.onmessage=f=>{switch(f.data.type){case "pump":this.pump();break;case "debug-log":E("SpeakerWorkletDAC - Worklet: "+f.data.value)}};this.node_processor.connect(this.node_output)});this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);a.register("dac-send-data",
569
- function(f){this.queue(f)},this);a.register("dac-enable",function(){this.enabled=!0},this);a.register("dac-disable",function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(f){h(0<f,"Sampling rate should be nonzero");this.sampling_rate=f;this.node_processor&&this.node_processor.port.postMessage({type:"sampling-rate",value:f})},this);this.debugger=new ec(this.audio_context,this.node_output)}$b.prototype.queue=function(a){this.node_processor&&(this.debugger.push_queued_data(a),
570
- this.node_processor.port.postMessage({type:"queue",value:a},[a[0].buffer,a[1].buffer]))};$b.prototype.pump=function(){this.enabled&&this.bus.send("dac-request-data")};function ac(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=22050;this.buffered_time=0;this.rate_ratio=1;this.node_lowpass=this.audio_context.createBiquadFilter();this.node_lowpass.type="lowpass";this.node_output=this.node_lowpass;this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);
571
- a.register("dac-send-data",function(d){this.queue(d)},this);a.register("dac-enable",function(){this.enabled=!0;this.pump()},this);a.register("dac-disable",function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(d){h(0<d,"Sampling rate should be nonzero");this.sampling_rate=d;this.rate_ratio=Math.ceil(8E3/d);this.node_lowpass.frequency.setValueAtTime(d/2,this.audio_context.currentTime)},this);this.debugger=new ec(this.audio_context,this.node_output)}ac.prototype.queue=function(a){this.debugger.push_queued_data(a);
572
- var b=a[0].length,c=b/this.sampling_rate;if(1<this.rate_ratio){var d=this.audio_context.createBuffer(2,b*this.rate_ratio,this.sampling_rate*this.rate_ratio);for(var e=d.getChannelData(0),g=d.getChannelData(1),f=0,l=0;l<b;l++)for(var n=0;n<this.rate_ratio;n++,f++)e[f]=a[0][l],g[f]=a[1][l]}else d=this.audio_context.createBuffer(2,b,this.sampling_rate),d.copyToChannel?(d.copyToChannel(a[0],0),d.copyToChannel(a[1],1)):(d.getChannelData(0).set(a[0]),d.getChannelData(1).set(a[1]));a=this.audio_context.createBufferSource();
573
- a.buffer=d;a.connect(this.node_lowpass);a.addEventListener("ended",this.pump.bind(this));d=this.audio_context.currentTime;if(this.buffered_time<d)for(E("Speaker DAC - Creating/Recreating reserve - shouldn't occur frequently during playback"),this.buffered_time=d,d=.2-c,b=0;b<=d;)b+=c,this.buffered_time+=c,setTimeout(()=>this.pump(),1E3*b);a.start(this.buffered_time);this.buffered_time+=c;setTimeout(()=>this.pump(),0)};ac.prototype.pump=function(){this.enabled&&(.2<this.buffered_time-this.audio_context.currentTime||
574
- this.bus.send("dac-request-data"))};function ec(a,b){this.audio_context=a;this.node_source=b;this.node_processor=null;this.node_gain=this.audio_context.createGain();this.node_gain.gain.setValueAtTime(0,this.audio_context.currentTime);this.node_gain.connect(this.audio_context.destination);this.is_active=!1;this.queued_history=[];this.output_history=[];this.queued=[[],[]];this.output=[[],[]]}ec.prototype.start=function(a){this.is_active=!0;this.queued=[[],[]];this.output=[[],[]];this.queued_history.push(this.queued);
575
- this.output_history.push(this.output);this.node_processor=this.audio_context.createScriptProcessor(1024,2,2);this.node_processor.onaudioprocess=b=>{this.output[0].push(b.inputBuffer.getChannelData(0).slice());this.output[1].push(b.inputBuffer.getChannelData(1).slice())};this.node_source.connect(this.node_processor);this.node_processor.connect(this.node_gain);setTimeout(()=>{this.stop()},a)};ec.prototype.stop=function(){this.is_active=!1;this.node_source.disconnect(this.node_processor);this.node_processor.disconnect();
576
- this.node_processor=null};ec.prototype.push_queued_data=function(a){this.is_active&&(this.queued[0].push(a[0].slice()),this.queued[1].push(a[1].slice()))};ec.prototype.download_txt=function(a,b){a=this.output_history[a][b].map(c=>c.join(" ")).join(" ");va(a,"dacdata.txt")};ec.prototype.download_csv=function(a){a=this.output_history[a];for(var b=[],c=0;c<a[0].length;c++)for(var d=0;d<a[0][c].length;d++)b.push(`${a[0][c][d]},${a[1][c][d]}`);va(b.join("\n"),"dacdata.csv")};function fc(a,b){function c(l){f.bus&&
577
- f.enabled&&(f.send_char(l.which),l.preventDefault())}function d(l){var n=l.which;8===n?(f.send_char(127),l.preventDefault()):9===n&&(f.send_char(9),l.preventDefault())}function e(l){if(f.enabled){for(var n=l.clipboardData.getData("text/plain"),m=0;m<n.length;m++)f.send_char(n.charCodeAt(m));l.preventDefault()}}function g(l){l.target!==a&&a.blur()}var f=this;this.enabled=!0;this.bus=b;this.text="";this.text_new_line=!1;this.last_update=0;this.bus.register("serial0-output-byte",function(l){l=String.fromCharCode(l);
578
- this.show_char(l)},this);this.destroy=function(){a.removeEventListener("keypress",c,!1);a.removeEventListener("keydown",d,!1);a.removeEventListener("paste",e,!1);window.removeEventListener("mousedown",g,!1)};this.init=function(){this.destroy();a.style.display="block";a.addEventListener("keypress",c,!1);a.addEventListener("keydown",d,!1);a.addEventListener("paste",e,!1);window.addEventListener("mousedown",g,!1)};this.init();this.show_char=function(l){"\b"===l?(this.text=this.text.slice(0,-1),this.update()):
579
- "\r"!==l&&(this.text+=l,"\n"===l&&(this.text_new_line=!0),this.update())};this.update=function(){var l=Date.now(),n=l-this.last_update;16>n?void 0===this.update_timer&&(this.update_timer=setTimeout(()=>{this.update_timer=void 0;var m=Date.now();h(15<=m-this.last_update);this.last_update=m;this.render()},16-n)):(void 0!==this.update_timer&&(clearTimeout(this.update_timer),this.update_timer=void 0),this.last_update=l,this.render())};this.render=function(){a.value=this.text;this.text_new_line&&(this.text_new_line=
580
- !1,a.scrollTop=1E9)};this.send_char=function(l){f.bus&&f.bus.send("serial0-input",l)}}function gc(a,b){this.element=a;if(window.Terminal){var c=this.term=new window.Terminal({logLevel:"off"});c.write("This is the serial console. Whatever you type or paste here will be sent to COM1");var d=c.onData(function(e){for(let g=0;g<e.length;g++)b.send("serial0-input",e.charCodeAt(g))});b.register("serial0-output-byte",function(e){c.write(Uint8Array.of(e))},this);this.destroy=function(){d.dispose();c.dispose()}}}
581
- gc.prototype.show=function(){this.term&&this.term.open(this.element)};function hc(a,b,c){this.bus=b;this.socket=void 0;this.id=c||0;this.send_queue=[];this.url=a;this.reconnect_interval=1E4;this.last_connect_attempt=Date.now()-this.reconnect_interval;this.send_queue_limit=64;this.destroyed=!1;this.bus.register("net"+this.id+"-send",function(d){this.send(d)},this)}hc.prototype.handle_message=function(a){this.bus&&this.bus.send("net"+this.id+"-receive",new Uint8Array(a.data))};hc.prototype.handle_close=
582
- function(){this.destroyed||(this.connect(),setTimeout(this.connect.bind(this),this.reconnect_interval))};hc.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);this.send_queue=[]};hc.prototype.handle_error=function(){};hc.prototype.destroy=function(){this.destroyed=!0;this.socket&&this.socket.close()};hc.prototype.connect=function(){if("undefined"!==typeof WebSocket){if(this.socket){var a=this.socket.readyState;if(0===a||1===a)return}a=Date.now();
583
- if(!(this.last_connect_attempt+this.reconnect_interval>a)){this.last_connect_attempt=Date.now();try{this.socket=new WebSocket(this.url)}catch(b){console.error(b);return}this.socket.binaryType="arraybuffer";this.socket.onopen=this.handle_open.bind(this);this.socket.onmessage=this.handle_message.bind(this);this.socket.onclose=this.handle_close.bind(this);this.socket.onerror=this.handle_error.bind(this)}}};hc.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),
584
- this.send_queue.length>2*this.send_queue_limit&&(this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};hc.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};function Y(a){"number"===typeof a.log_level&&(ma=a.log_level);this.cpu_is_running=!1;this.cpu_exception_hook=function(){};var b=Eb.create();this.bus=b[0];this.emulator_bus=b[1];var c,d;const e=new WebAssembly.Table({element:"anyfunc",
585
- initial:1924});b={cpu_exception_hook:f=>this.cpu_exception_hook(f),run_hardware_timers:function(f,l){return c.run_hardware_timers(f,l)},cpu_event_halt:()=>{this.emulator_bus.send("cpu-event-halt")},abort:function(){h(!1)},microtick:F.microtick,get_rand_int:function(){return k.get_rand_int()},apic_acknowledge_irq:function(){return c.devices.apic.acknowledge_irq()},stop_idling:function(){return c.stop_idling()},io_port_read8:function(f){return c.io.port_read8(f)},io_port_read16:function(f){return c.io.port_read16(f)},
586
- io_port_read32:function(f){return c.io.port_read32(f)},io_port_write8:function(f,l){c.io.port_write8(f,l)},io_port_write16:function(f,l){c.io.port_write16(f,l)},io_port_write32:function(f,l){c.io.port_write32(f,l)},mmap_read8:function(f){return c.mmap_read8(f)},mmap_read16:function(f){return c.mmap_read16(f)},mmap_read32:function(f){return c.mmap_read32(f)},mmap_write8:function(f,l){c.mmap_write8(f,l)},mmap_write16:function(f,l){c.mmap_write16(f,l)},mmap_write32:function(f,l){c.mmap_write32(f,l)},
587
- mmap_write64:function(f,l,n){c.mmap_write64(f,l,n)},mmap_write128:function(f,l,n,m,q){c.mmap_write128(f,l,n,m,q)},log_from_wasm:function(f,l){f=k.read_sized_string_from_mem(d,f,l);E(f,2)},console_log_from_wasm:function(f,l){f=k.read_sized_string_from_mem(d,f,l);console.error(f)},dbg_trace_from_wasm:function(){E(Error().stack,2)},codegen_finalize:(f,l,n,m,q)=>{c.codegen_finalize(f,l,n,m,q)},jit_clear_func:f=>c.jit_clear_func(f),jit_clear_all_funcs:()=>c.jit_clear_all_funcs(),__indirect_function_table:e};
588
- let g=a.wasm_fn;g||(g=f=>new Promise(l=>{let n="v86-debug.wasm",m="v86-fallback.wasm";if(a.wasm_path){n=a.wasm_path;const q=n.lastIndexOf("/");m=(-1===q?"":n.substr(0,q))+"/"+m}else"undefined"===typeof window&&"string"===typeof __dirname?(n=__dirname+"/"+n,m=__dirname+"/"+m):(n="build/"+n,m="build/"+m);k.load_file(n,{done:async q=>{try{const {instance:r}=await WebAssembly.instantiate(q,f);this.wasm_source=q;l(r.exports)}catch(r){k.load_file(m,{done:async t=>{const {instance:v}=await WebAssembly.instantiate(t,
589
- f);this.wasm_source=t;l(v.exports)}})}},progress:q=>{this.emulator_bus.send("download-progress",{file_index:0,file_count:1,file_name:n,lengthComputable:q.lengthComputable,total:q.total,loaded:q.loaded})}})}));g({env:b}).then(f=>{d=f.memory;f.rust_init();f=this.v86=new F(this.emulator_bus,{exports:f,wasm_table:e});c=f.cpu;this.continue_init(f,a)});this.zstd_worker=null;this.zstd_worker_request_id=0}J.exportSymbol("V86",Y);Y.prototype.continue_init=async function(a,b){function c(t,v){switch(t){case "hda":e.hda=
590
- this.disk_images.hda=v;break;case "hdb":e.hdb=this.disk_images.hdb=v;break;case "cdrom":e.cdrom=this.disk_images.cdrom=v;break;case "fda":e.fda=this.disk_images.fda=v;break;case "fdb":e.fdb=this.disk_images.fdb=v;break;case "multiboot":e.multiboot=this.disk_images.multiboot=v.buffer;break;case "bzimage":e.bzimage=this.disk_images.bzimage=v.buffer;break;case "initrd":e.initrd=this.disk_images.initrd=v.buffer;break;case "bios":e.bios=v.buffer;break;case "vga_bios":e.vga_bios=v.buffer;break;case "initial_state":e.initial_state=
591
- v.buffer;break;case "fs9p_json":e.fs9p_json=v;break;default:h(!1,t)}}async function d(){if(e.fs9p&&e.fs9p_json)if(e.initial_state)E("Filesystem basefs ignored: Overridden by state image");else{if(e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem){const {bzimage_path:t,initrd_path:v}=this.get_bzimage_initrd_from_filesystem(e.fs9p);E("Found bzimage: "+t+" and initrd: "+v);const [y,D]=await Promise.all([e.fs9p.read_file(v),e.fs9p.read_file(t)]);c.call(this,"initrd",new k.SyncBuffer(y.buffer));
592
- c.call(this,"bzimage",new k.SyncBuffer(D.buffer))}}else h(!b.bzimage_initrd_from_filesystem||e.initial_state,"bzimage_initrd_from_filesystem: Requires a filesystem");this.serial_adapter&&this.serial_adapter.show&&this.serial_adapter.show();this.v86.init(e);e.initial_state&&(a.restore_state(e.initial_state),e.initial_state=void 0);b.autostart&&this.v86.run();this.emulator_bus.send("emulator-loaded")}this.bus.register("emulator-stopped",function(){this.cpu_is_running=!1;this.screen_adapter.pause()},
593
- this);this.bus.register("emulator-started",function(){this.cpu_is_running=!0;this.screen_adapter.continue()},this);var e={};this.disk_images={fda:void 0,fdb:void 0,hda:void 0,hdb:void 0,cdrom:void 0};var g=b.boot_order?b.boot_order:b.fda?801:b.hda?786:291;e.acpi=b.acpi;e.disable_jit=b.disable_jit;e.load_devices=!0;e.memory_size=b.memory_size||67108864;e.vga_memory_size=b.vga_memory_size||8388608;e.boot_order=g;e.fastboot=b.fastboot||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=
594
- b.uart3;e.cmdline=b.cmdline;e.preserve_mac_from_state_image=b.preserve_mac_from_state_image;e.mac_address_translation=b.mac_address_translation;e.cpuid_level=b.cpuid_level;e.virtio_balloon=b.virtio_balloon;e.virtio_console=b.virtio_console;e.virtio_net=b.virtio_net;e.screen_options=b.screen_options;if(g=b.network_relay_url||b.net_device&&b.net_device.relay_url)"fetch"===g?this.network_adapter=new ic(this.bus,b.net_device):"inbrowser"===g?this.network_adapter=new jc(this.bus,b.net_device):g.startsWith("wisp://")||
595
- g.startsWith("wisps://")?this.network_adapter=new kc(g,this.bus,b.net_device):this.network_adapter=new hc(g,this.bus);e.net_device=b.net_device||{type:"ne2k"};g=b.screen||{};b.screen_container&&(g.container=b.screen_container);b.disable_keyboard||(this.keyboard_adapter=new Xb(this.bus));b.disable_mouse||(this.mouse_adapter=new Yb(this.bus,g.container));this.screen_adapter=g.container?new ca(g,()=>this.v86.cpu.devices.vga&&this.v86.cpu.devices.vga.screen_fill_buffer()):new lc;e.screen=this.screen_adapter;
596
- e.screen_options=g;b.serial_container&&(this.serial_adapter=new fc(b.serial_container,this.bus));b.serial_container_xtermjs&&(this.serial_adapter=new gc(b.serial_container_xtermjs,this.bus));b.disable_speaker||(this.speaker_adapter=new Zb(this.bus));var f=[];g=(t,v)=>{if(v)if(v.get&&v.set&&v.load)f.push({name:t,loadable:v});else{if("bios"===t||"vga_bios"===t||"initial_state"===t||"multiboot"===t||"bzimage"===t||"initrd"===t)v.async=!1;if("fda"===t||"fdb"===t)v.async=!1;v.url&&!v.async?f.push({name:t,
597
- url:v.url,size:v.size}):f.push({name:t,loadable:k.buffer_from_object(v,this.zstd_decompress_worker.bind(this))})}};b.state&&console.warn("Warning: Unknown option 'state'. Did you mean 'initial_state'?");g("bios",b.bios);g("vga_bios",b.vga_bios);g("cdrom",b.cdrom);g("hda",b.hda);g("hdb",b.hdb);g("fda",b.fda);g("fdb",b.fdb);g("initial_state",b.initial_state);g("multiboot",b.multiboot);g("bzimage",b.bzimage);g("initrd",b.initrd);if(b.filesystem){g=b.filesystem.basefs;var l=b.filesystem.baseurl;let t=
598
- new mc;l&&(t=new nc(t,l));e.fs9p=this.fs9p=new Z(t);if(g){h(l,"Filesystem: baseurl must be specified");if("object"===typeof g){var n=g.size;g=g.url}h("string"===typeof g);f.push({name:"fs9p_json",url:g,size:n,as_json:!0})}}var m=this,q=f.length,r=function(t){if(t===q)setTimeout(d.bind(this),0);else{var v=f[t];v.loadable?(v.loadable.onload=function(){c.call(this,v.name,v.loadable);r(t+1)}.bind(this),v.loadable.load()):k.load_file(v.url,{done:function(y){v.url.endsWith(".zst")&&"initial_state"!==v.name&&
599
- (h(v.size,"A size must be provided for compressed images"),y=this.zstd_decompress(v.size,new Uint8Array(y)));c.call(this,v.name,v.as_json?y:new k.SyncBuffer(y));r(t+1)}.bind(this),progress:function(y){200===y.target.status?m.emulator_bus.send("download-progress",{file_index:t,file_count:q,file_name:v.url,lengthComputable:y.lengthComputable,total:y.total||v.size,loaded:y.loaded}):m.emulator_bus.send("download-error",{file_index:t,file_count:q,file_name:v.url,request:y.target})},as_json:v.as_json})}}.bind(this);
600
- r(0)};Y.prototype.zstd_decompress=function(a,b){const c=this.v86.cpu;h(!this.zstd_context);this.zstd_context=c.zstd_create_ctx(b.length);(new Uint8Array(c.wasm_memory.buffer)).set(b,c.zstd_get_src_ptr(this.zstd_context));b=c.zstd_read(this.zstd_context,a);const d=c.wasm_memory.buffer.slice(b,b+a);c.zstd_read_free(b,a);c.zstd_free_ctx(this.zstd_context);this.zstd_context=null;return d};Y.prototype.zstd_decompress_worker=async function(a,b){if(!this.zstd_worker){const c=URL.createObjectURL(new Blob(["("+
601
- function(){let d;globalThis.onmessage=function(e){if(d){var {src:g,decompressed_size:f,id:l}=e.data;e=d.exports;var n=e.zstd_create_ctx(g.length);(new Uint8Array(e.memory.buffer)).set(g,e.zstd_get_src_ptr(n));var m=e.zstd_read(n,f),q=e.memory.buffer.slice(m,m+f);e.zstd_read_free(m,f);e.zstd_free_ctx(n);postMessage({result:q,id:l},[q])}else n=Object.fromEntries("cpu_exception_hook run_hardware_timers cpu_event_halt microtick get_rand_int apic_acknowledge_irq stop_idling io_port_read8 io_port_read16 io_port_read32 io_port_write8 io_port_write16 io_port_write32 mmap_read8 mmap_read16 mmap_read32 mmap_write8 mmap_write16 mmap_write32 mmap_write64 mmap_write128 codegen_finalize jit_clear_func jit_clear_all_funcs".split(" ").map(r=>
438
+ this.size=c.size_supported;this.mask=this.size-1;this.enabled=!1;this.notify_offset=c.notify_offset;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.reset()}W.prototype.get_state=function(){const a=[];a[0]=this.size;a[1]=this.size_supported;a[2]=this.enabled;a[3]=this.notify_offset;a[4]=this.desc_addr;a[5]=this.avail_addr;a[6]=this.avail_last_idx;a[7]=this.used_addr;a[8]=this.num_staged_replies;a[9]=1;return a};W.prototype.set_state=function(a){this.size=
439
+ a[0];this.size_supported=a[1];this.enabled=a[2];this.notify_offset=a[3];this.desc_addr=a[4];this.avail_addr=a[5];this.avail_last_idx=a[6];this.used_addr=a[7];this.num_staged_replies=a[8];this.mask=this.size-1;this.fix_wrapping=1!==a[9]};W.prototype.reset=function(){this.enabled=!1;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.set_size(this.size_supported)};W.prototype.is_configured=function(){return this.desc_addr&&this.avail_addr&&this.used_addr};
440
+ W.prototype.enable=function(){h(this.is_configured(),"VirtQueue must be configured before enabled");this.enabled=!0};W.prototype.set_size=function(a){h(0===(a&a-1),"VirtQueue size must be power of 2 or zero");h(a<=this.size_supported,"VirtQueue size must be within supported size");this.size=a;this.mask=a-1};W.prototype.count_requests=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");this.fix_wrapping&&(this.fix_wrapping=!1,this.avail_last_idx=(this.avail_get_idx()&
441
+ ~this.mask)+(this.avail_last_idx&this.mask));return this.avail_get_idx()-this.avail_last_idx&65535};W.prototype.has_request=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");return 0!==this.count_requests()};W.prototype.pop_request=function(){h(this.avail_addr,"VirtQueue addresses must be configured before use");h(this.has_request(),"VirtQueue must not pop nonexistent request");var a=this.avail_get_entry(this.avail_last_idx);E("Pop request: avail_last_idx="+this.avail_last_idx+
442
+ " desc_idx="+a,2097152);a=new qb(this,a);this.avail_last_idx=this.avail_last_idx+1&65535;return a};W.prototype.push_reply=function(a){h(this.used_addr,"VirtQueue addresses must be configured before use");h(this.num_staged_replies<this.size,"VirtQueue replies must not exceed queue size");const b=this.used_get_idx()+this.num_staged_replies&this.mask;E("Push reply: used_idx="+b+" desc_idx="+a.head_idx,2097152);this.used_set_entry(b,a.head_idx,a.length_written);this.num_staged_replies++};W.prototype.flush_replies=
443
+ function(){h(this.used_addr,"VirtQueue addresses must be configured before use");if(0===this.num_staged_replies)E("flush_replies: Nothing to flush",2097152);else{E("Flushing "+this.num_staged_replies+" replies",2097152);var a=this.used_get_idx()+this.num_staged_replies&65535;this.used_set_idx(a);this.num_staged_replies=0;this.virtio.is_feature_negotiated(29)?(this.avail_get_used_event(),this.virtio.raise_irq(1)):~this.avail_get_flags()&1&&this.virtio.raise_irq(1)}};W.prototype.notify_me_after=function(a){h(0<=
444
+ a,"Must skip a non-negative number of requests");a=this.avail_get_idx()+a&65535;this.used_set_avail_event(a)};W.prototype.get_descriptor=function(a,b){return{addr_low:this.cpu.read32s(a+16*b),addr_high:this.cpu.read32s(a+16*b+4),len:this.cpu.read32s(a+16*b+8),flags:this.cpu.read16(a+16*b+12),next:this.cpu.read16(a+16*b+14)}};W.prototype.avail_get_flags=function(){return this.cpu.read16(this.avail_addr)};W.prototype.avail_get_idx=function(){return this.cpu.read16(this.avail_addr+2)};W.prototype.avail_get_entry=
445
+ function(a){return this.cpu.read16(this.avail_addr+4+2*(a&this.mask))};W.prototype.avail_get_used_event=function(){return this.cpu.read16(this.avail_addr+4+2*this.size)};W.prototype.used_get_flags=function(){return this.cpu.read16(this.used_addr)};W.prototype.used_set_flags=function(a){this.cpu.write16(this.used_addr,a)};W.prototype.used_get_idx=function(){return this.cpu.read16(this.used_addr+2)};W.prototype.used_set_idx=function(a){this.cpu.write16(this.used_addr+2,a)};W.prototype.used_set_entry=
446
+ function(a,b,c){this.cpu.write32(this.used_addr+4+8*a,b);this.cpu.write32(this.used_addr+8+8*a,c)};W.prototype.used_set_avail_event=function(a){this.cpu.write16(this.used_addr+4+8*this.size,a)};function qb(a,b){this.cpu=a.cpu;this.virtio=a.virtio;this.head_idx=b;this.read_buffers=[];this.length_readable=this.read_buffer_offset=this.read_buffer_idx=0;this.write_buffers=[];this.length_writable=this.length_written=this.write_buffer_offset=this.write_buffer_idx=0;let c=a.desc_addr,d=0,e=a.size,g=!1;const f=
447
+ this.virtio.is_feature_negotiated(28);E("<<< Descriptor chain start",2097152);do{const l=a.get_descriptor(c,b);E("descriptor: idx="+b+" addr="+B(l.addr_high,8)+":"+B(l.addr_low,8)+" len="+B(l.len,8)+" flags="+B(l.flags,4)+" next="+B(l.next,4),2097152);if(f&&l.flags&4)l.flags&1&&E("Driver bug: has set VIRTQ_DESC_F_NEXT flag in an indirect table descriptor",2097152),c=l.addr_low,d=b=0,e=l.len/16,E("start indirect",2097152);else{if(l.flags&2)g=!0,this.write_buffers.push(l),this.length_writable+=l.len;
448
+ else{if(g){E("Driver bug: readonly buffer after writeonly buffer within chain",2097152);break}this.read_buffers.push(l);this.length_readable+=l.len}d++;if(d>e){E("Driver bug: descriptor chain cycle detected",2097152);break}if(l.flags&1)b=l.next;else break}}while(1);E("Descriptor chain end >>>",2097152)}qb.prototype.get_next_blob=function(a){let b=0,c=a.length;for(;c;){if(this.read_buffer_idx===this.read_buffers.length){E("Device<"+this.virtio.name+"> Read more than device-readable buffers has",2097152);
449
+ break}var d=this.read_buffers[this.read_buffer_idx];const e=d.addr_low+this.read_buffer_offset;d=d.len-this.read_buffer_offset;d>c?(d=c,this.read_buffer_offset+=c):(this.read_buffer_idx++,this.read_buffer_offset=0);a.set(this.cpu.read_blob(e,d),b);b+=d;c-=d}return b};qb.prototype.set_next_blob=function(a){let b=0,c=a.length;for(;c;){if(this.write_buffer_idx===this.write_buffers.length){E("Device<"+this.virtio.name+"> Write more than device-writable capacity",2097152);break}var d=this.write_buffers[this.write_buffer_idx];
450
+ const e=d.addr_low+this.write_buffer_offset;d=d.len-this.write_buffer_offset;d>c?(d=c,this.write_buffer_offset+=c):(this.write_buffer_idx++,this.write_buffer_offset=0);this.cpu.write_blob(a.subarray(b,b+d),e);b+=d;c-=d}this.length_written+=b;return b};function rb(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c<this.ports;++c)b.push({size_supported:16,
451
+ notify_offset:0}),b.push({size_supported:8,notify_offset:1});this.virtio=new fa(a,{name:"virtio-console",pci_id:96,device_id:4163,subsystem_device_id:3,common:{initial_port:47104,queues:b,features:[0,1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const g=d.pop_request(),f=new Uint8Array(g.length_readable);g.get_next_blob(f);this.bus.send("virtio-console"+e+"-output-bytes",f);this.Ack(c,
452
+ g)}},c=>{if(2!==c)h(!1,"VirtioConsole Notified for wrong queue: "+c+" (expected queue_id of 2)");else for(c=this.virtio.queues[c];c.count_requests()>c.size-2;)c.pop_request()},c=>{if(3!==c)h(!1,"VirtioConsole Notified for wrong queue: "+c+" (expected queue_id of 3)");else for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),g=new Uint8Array(e.length_readable);e.get_next_blob(g);var f=p.Unmarshall(["w","h","h"],g,{offset:0});g=f[0];f=f[1];this.Ack(c,e);switch(f){case 0:for(e=0;e<
453
+ this.ports;++e)this.SendEvent(e,1,0);break;case 3:this.Ack(c,e);this.SendEvent(g,4,1);this.SendName(g,"virtio-"+g);this.SendEvent(g,6,1);break;case 6:this.Ack(c,e);0===g&&this.SendWindowSize(g);break;default:h(!1," VirtioConsole received unknown event: "+f[1]);return}}}]},isr_status:{initial_port:46848},device_specific:{initial_port:46592,struct:[{bytes:2,name:"cols",read:()=>this.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows,write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,
454
+ write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{h(!1,"Emergency write!")}}]}});for(let c=0;c<this.ports;++c){const d=0===c?0:2*c+2;this.bus.register("virtio-console"+c+"-input-bytes",function(e){var g=this.virtio.queues[d];g.has_request()&&(g=g.pop_request(),this.Send(d,g,new Uint8Array(e)))},this);this.bus.register("virtio-console"+c+"-resize",function(e){0===c&&(this.cols=e[0],this.rows=e[1]);this.virtio.queues[2].is_configured()&&this.virtio.queues[2].has_request()&&this.SendWindowSize(c,
455
+ e[0],e[1])},this)}}rb.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(12);p.Marshall(["w","h","h","h","h"],[a,5,0,c,b],e,0);this.Send(2,d,e)};rb.prototype.SendName=function(a,b){const c=this.virtio.queues[2].pop_request();b=(new TextEncoder).encode(b);const d=new Uint8Array(8+b.length+1);p.Marshall(["w","h","h"],[a,7,1],d,0);for(a=0;a<b.length;++a)d[a+8]=b[a];d[8+b.length]=0;this.Send(2,c,d)};rb.prototype.get_state=
456
+ function(){const a=[];a[0]=this.virtio;a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};rb.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=a[3]};rb.prototype.reset=function(){this.virtio.reset()};rb.prototype.SendEvent=function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);p.Marshall(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};rb.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);
457
+ this.virtio.queues[a].flush_replies()};rb.prototype.Ack=function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function sb(a,b,c){this.bus=b;this.id=a.devices.net?1:0;this.status=this.pairs=1;this.preserve_mac_from_state_image=c;this.mac=new Uint8Array([0,34,21,255*Math.random()|0,255*Math.random()|0,255*Math.random()|0]);this.bus.send("net"+this.id+"-mac",Ua(this.mac));b=[];for(c=0;c<this.pairs;++c)b.push({size_supported:1024,notify_offset:0}),
458
+ b.push({size_supported:1024,notify_offset:1});b.push({size_supported:16,notify_offset:2});this.virtio=new fa(a,{name:"virtio-net",pci_id:80,device_id:4161,subsystem_device_id:1,common:{initial_port:51200,queues:b,features:[5,16,22,3,17,23,32],on_driver_ok:()=>{}},notification:{initial_port:51456,single_handler:!1,handlers:[()=>{},d=>{const e=this.virtio.queues[d];for(;e.has_request();){const g=e.pop_request(),f=new Uint8Array(g.length_readable);g.get_next_blob(f);this.bus.send("net"+this.id+"-send",
459
+ f.subarray(12));this.bus.send("eth-transmit-end",[f.length-12]);this.virtio.queues[d].push_reply(g)}this.virtio.queues[d].flush_replies()},d=>{if(d!==2*this.pairs)h(!1,"VirtioNet Notified for wrong queue: "+d+" (expected queue_id of 3)");else for(var e=this.virtio.queues[d];e.has_request();){const l=e.pop_request();var g=new Uint8Array(l.length_readable);l.get_next_blob(g);var f=p.Unmarshall(["b","b"],g,{offset:0});const n=f[0];f=f[1];switch(n<<8|f){case 1024:g=p.Unmarshall(["h"],g,{offset:2});h(1===
460
+ g[0]);this.Send(d,l,new Uint8Array([0]));break;case 257:this.mac=g.subarray(2,8);this.Send(d,l,new Uint8Array([0]));this.bus.send("net"+this.id+"-mac",Ua(this.mac));break;default:h(!1," VirtioNet received unknown command: "+n+":"+f);this.Send(d,l,new Uint8Array([1]));return}}}]},isr_status:{initial_port:50944},device_specific:{initial_port:50688,struct:[0,1,2,3,4,5].map((d,e)=>({bytes:1,name:"mac_"+e,read:()=>this.mac[e],write:()=>{}})).concat([{bytes:2,name:"status",read:()=>this.status,write:()=>
461
+ {}},{bytes:2,name:"max_pairs",read:()=>this.pairs,write:()=>{}},{bytes:2,name:"mtu",read:()=>1500,write:()=>{}}])}});this.bus.register("net"+this.id+"-receive",d=>{this.bus.send("eth-receive-end",[d.length]);const e=new Uint8Array(12+d.byteLength);(new DataView(e.buffer,e.byteOffset,e.byteLength)).setInt16(10,1);e.set(d,12);d=this.virtio.queues[0];d.has_request()?(d=d.pop_request(),d.set_next_blob(e),this.virtio.queues[0].push_reply(d),this.virtio.queues[0].flush_replies()):console.log("No buffer to write into!")},
462
+ this)}sb.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.id;a[2]=this.mac;return a};sb.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.id=a[1];this.preserve_mac_from_state_image&&(this.mac=a[2],this.bus.send("net"+this.id+"-mac",Ua(this.mac)))};sb.prototype.reset=function(){this.virtio.reset()};sb.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};sb.prototype.Ack=function(a,b){this.virtio.queues[a].push_reply(b);
463
+ this.virtio.queues[a].flush_replies()};const Cb="SWAP_IN SWAP_OUT MAJFLT MINFLT MEMFREE MEMTOT AVAIL CACHES HTLB_PGALLOC HTLB_PGFAIL".split(" ");function Db(a,b){this.bus=b;this.zeroed=this.fp_cmd=this.actual=this.num_pages=0;this.virtio=new fa(a,{name:"virtio-balloon",pci_id:88,device_id:4165,subsystem_device_id:5,common:{initial_port:55296,queues:[{size_supported:32,notify_offset:0},{size_supported:32,notify_offset:0},{size_supported:2,notify_offset:1},{size_supported:64,notify_offset:2}],features:[1,
464
+ 3,32],on_driver_ok:()=>{E("Balloon setup",2048)}},notification:{initial_port:55552,single_handler:!1,handlers:[c=>{const d=this.virtio.queues[c];for(;d.has_request();){var e=d.pop_request();const g=new Uint8Array(e.length_readable);e.get_next_blob(g);this.virtio.queues[c].push_reply(e);e=g.byteLength/4;this.actual+=0===c?e:-e}this.virtio.queues[c].flush_replies()},c=>{var d=this.virtio.queues[c];if(d.has_request()){d=d.pop_request();const e=new Uint8Array(d.length_readable);d.get_next_blob(e);let g=
465
+ {};for(let f=0;f<d.length_readable;f+=10){let [l,n]=p.Unmarshall(["h","d"],e,{offset:f});g[Cb[l]]=n}this.virtio.queues[c].push_reply(d);this.stats_cb&&this.stats_cb(g)}},c=>{const d=this.virtio.queues[c];for(;d.has_request();){const g=d.pop_request();if(0<g.length_readable){var e=new Uint8Array(g.length_readable);g.get_next_blob(e);[e]=p.Unmarshall(["w"],e,{offset:0});0===e&&(this.free_cb&&this.free_cb(this.zeroed),1<this.fp_cmd&&(this.fp_cmd=1),this.virtio.notify_config_changes())}if(0<g.length_writable)for(new Uint8Array(0),
466
+ e=0;e<g.write_buffers.length;++e){let f=g.write_buffers[e];this.zeroed+=f.len;this.virtio.cpu.zero_memory(f.addr_low,f.len)}this.virtio.queues[c].push_reply(g)}this.virtio.queues[c].flush_replies()}]},isr_status:{initial_port:55040},device_specific:{initial_port:54784,struct:[{bytes:4,name:"num_pages",read:()=>this.num_pages,write:()=>{}},{bytes:4,name:"actual",read:()=>this.actual,write:()=>{}},{bytes:4,name:"free_page_hint_cmd_id",read:()=>this.fp_cmd,write:()=>{}}]}})}Db.prototype.Inflate=function(a){this.num_pages+=
467
+ a;this.virtio.notify_config_changes()};Db.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};Db.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=a;this.zeroed=0;this.virtio.notify_config_changes()};Db.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};Db.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};Db.prototype.GetStats=function(a){this.stats_cb=a;for(a=
468
+ this.virtio.queues[2];a.has_request();){const b=a.pop_request();this.virtio.queues[2].push_reply(b)}this.virtio.queues[2].flush_replies()};Db.prototype.Reset=function(){};var Eb={};function Fb(){this.listeners={};this.pair=void 0}Fb.prototype.register=function(a,b,c){var d=this.listeners[a];void 0===d&&(d=this.listeners[a]=[]);d.push({fn:b,this_value:c})};Fb.prototype.unregister=function(a,b){var c=this.listeners[a];void 0!==c&&(this.listeners[a]=c.filter(function(d){return d.fn!==b}))};Fb.prototype.send=
469
+ function(a,b){if(this.pair&&(a=this.pair.listeners[a],void 0!==a))for(var c=0;c<a.length;c++){var d=a[c];d.fn.call(d.this_value,b)}};Fb.prototype.send_async=function(a,b){h(1===arguments.length||2===arguments.length);setTimeout(this.send.bind(this,a,b),0)};Eb.create=function(){var a=new Fb,b=new Fb;a.pair=b;b.pair=a;return[a,b]};var E=function(){var a=ba.reduce(function(d,e){d[e[0]]=e[1];return d},{}),b="",c=0;return function(d,e){e=e||1;if(e&ma){d="["+k.pads(a[e]||"",4)+"] "+d;if(d===b&&(c++,2048>
470
+ c))return;e=new Date;e=k.pad0(e.getHours(),2)+":"+k.pad0(e.getMinutes(),2)+":"+k.pad0(e.getSeconds(),2)+"+"+k.pad0(e.getMilliseconds(),3)+" ";c&&(1===c?console.log(e+b):console.log("Previous message repeated "+c+" times"),c=0);console.log(e+d);b=d}}}();function h(a,b){if(!a){debugger;console.trace();if(b)throw"Assert failed: "+b;throw"Assert failed";}}function G(a,b,c){this.stop_idling=c;this.wm=b;this.wasm_patch();this.create_jit_imports();this.wasm_memory=b=this.wm.exports.memory;this.memory_size=
471
+ k.view(Uint32Array,b,812,1);this.mem8=new Uint8Array(0);this.mem32s=new Int32Array(this.mem8.buffer);this.segment_is_null=k.view(Uint8Array,b,724,8);this.segment_offsets=k.view(Int32Array,b,736,8);this.segment_limits=k.view(Uint32Array,b,768,8);this.segment_access_bytes=k.view(Uint8Array,b,512,8);this.protected_mode=k.view(Int32Array,b,800,1);this.idtr_size=k.view(Int32Array,b,564,1);this.idtr_offset=k.view(Int32Array,b,568,1);this.gdtr_size=k.view(Int32Array,b,572,1);this.gdtr_offset=k.view(Int32Array,
472
+ b,576,1);this.tss_size_32=k.view(Int32Array,b,1128,1);this.page_fault=k.view(Uint32Array,b,540,8);this.cr=k.view(Int32Array,b,580,8);this.cpl=k.view(Uint8Array,b,612,1);this.is_32=k.view(Int32Array,b,804,1);this.stack_size_32=k.view(Int32Array,b,808,1);this.in_hlt=k.view(Uint8Array,b,616,1);this.last_virt_eip=k.view(Int32Array,b,620,1);this.eip_phys=k.view(Int32Array,b,624,1);this.sysenter_cs=k.view(Int32Array,b,636,1);this.sysenter_esp=k.view(Int32Array,b,640,1);this.sysenter_eip=k.view(Int32Array,
473
+ b,644,1);this.prefixes=k.view(Int32Array,b,648,1);this.flags=k.view(Int32Array,b,120,1);this.flags_changed=k.view(Int32Array,b,100,1);this.last_op_size=k.view(Int32Array,b,96,1);this.last_op1=k.view(Int32Array,b,104,1);this.last_result=k.view(Int32Array,b,112,1);this.current_tsc=k.view(Uint32Array,b,960,2);this.devices={};this.instruction_pointer=k.view(Int32Array,b,556,1);this.previous_ip=k.view(Int32Array,b,560,1);this.apic_enabled=k.view(Uint8Array,b,548,1);this.acpi_enabled=k.view(Uint8Array,
474
+ b,552,1);this.memory_map_read8=[];this.memory_map_write8=[];this.memory_map_read32=[];this.memory_map_write32=[];this.bios={main:null,vga:null};this.instruction_counter=k.view(Uint32Array,b,664,1);this.reg32=k.view(Int32Array,b,64,8);this.fpu_st=k.view(Int32Array,b,1152,32);this.fpu_stack_empty=k.view(Uint8Array,b,816,1);this.fpu_stack_empty[0]=255;this.fpu_stack_ptr=k.view(Uint8Array,b,1032,1);this.fpu_stack_ptr[0]=0;this.fpu_control_word=k.view(Uint16Array,b,1036,1);this.fpu_control_word[0]=895;
475
+ this.fpu_status_word=k.view(Uint16Array,b,1040,1);this.fpu_status_word[0]=0;this.fpu_ip=k.view(Int32Array,b,1048,1);this.fpu_ip[0]=0;this.fpu_ip_selector=k.view(Int32Array,b,1052,1);this.fpu_ip_selector[0]=0;this.fpu_opcode=k.view(Int32Array,b,1044,1);this.fpu_opcode[0]=0;this.fpu_dp=k.view(Int32Array,b,1056,1);this.fpu_dp[0]=0;this.fpu_dp_selector=k.view(Int32Array,b,1060,1);this.fpu_dp_selector[0]=0;this.reg_xmm32s=k.view(Int32Array,b,832,32);this.mxcsr=k.view(Int32Array,b,824,1);this.sreg=k.view(Uint16Array,
476
+ b,668,8);this.dreg=k.view(Int32Array,b,684,8);this.reg_pdpte=k.view(Int32Array,b,968,8);this.svga_dirty_bitmap_min_offset=k.view(Uint32Array,b,716,1);this.svga_dirty_bitmap_max_offset=k.view(Uint32Array,b,720,1);this.fw_value=[];this.fw_pointer=0;this.option_roms=[];this.io=void 0;this.bus=a;this.set_tsc(0,0);this.debug_init();this.seen_code={};this.seen_code_uncompiled={}}G.prototype.clear_opstats=function(){(new Uint8Array(this.wasm_memory.buffer,32768,131072)).fill(0);this.wm.exports.profiler_init()};
477
+ G.prototype.create_jit_imports=function(){const a=Object.create(null);a.m=this.wm.exports.memory;for(const b of Object.keys(this.wm.exports))b.startsWith("_")||b.startsWith("zstd")||b.endsWith("_js")||(a[b]=this.wm.exports[b]);this.jit_imports=a};G.prototype.wasm_patch=function(){const a=c=>this.wm.exports[c],b=c=>{const d=a(c);console.assert(d,"Missing import: "+c);return d};this.reset_cpu=b("reset_cpu");this.getiopl=b("getiopl");this.get_eflags=b("get_eflags");this.handle_irqs=b("handle_irqs");
478
+ this.main_loop=b("main_loop");this.set_jit_config=b("set_jit_config");this.read8=b("read8");this.read16=b("read16");this.read32s=b("read32s");this.write8=b("write8");this.write16=b("write16");this.write32=b("write32");this.in_mapped_range=b("in_mapped_range");this.fpu_load_tag_word=b("fpu_load_tag_word");this.fpu_load_status_word=b("fpu_load_status_word");this.fpu_get_sti_f64=b("fpu_get_sti_f64");this.translate_address_system_read=b("translate_address_system_read_js");this.get_seg_cs=b("get_seg_cs");
479
+ this.get_real_eip=b("get_real_eip");this.clear_tlb=b("clear_tlb");this.full_clear_tlb=b("full_clear_tlb");this.update_state_flags=b("update_state_flags");this.set_tsc=b("set_tsc");this.store_current_tsc=b("store_current_tsc");this.set_cpuid_level=b("set_cpuid_level");this.pic_set_irq=b("pic_set_irq");this.pic_clear_irq=b("pic_clear_irq");this.jit_force_generate_unsafe=a("jit_force_generate_unsafe");this.jit_clear_cache=b("jit_clear_cache_js");this.jit_dirty_cache=b("jit_dirty_cache");this.codegen_finalize_finished=
480
+ b("codegen_finalize_finished");this.allocate_memory=b("allocate_memory");this.zero_memory=b("zero_memory");this.is_memory_zeroed=b("is_memory_zeroed");this.svga_allocate_memory=b("svga_allocate_memory");this.svga_allocate_dest_buffer=b("svga_allocate_dest_buffer");this.svga_fill_pixel_buffer=b("svga_fill_pixel_buffer");this.svga_mark_dirty=b("svga_mark_dirty");this.get_pic_addr_master=b("get_pic_addr_master");this.get_pic_addr_slave=b("get_pic_addr_slave");this.zstd_create_ctx=b("zstd_create_ctx");
481
+ this.zstd_get_src_ptr=b("zstd_get_src_ptr");this.zstd_free_ctx=b("zstd_free_ctx");this.zstd_read=b("zstd_read");this.zstd_read_free=b("zstd_read_free");this.port20_read=b("port20_read");this.port21_read=b("port21_read");this.portA0_read=b("portA0_read");this.portA1_read=b("portA1_read");this.port20_write=b("port20_write");this.port21_write=b("port21_write");this.portA0_write=b("portA0_write");this.portA1_write=b("portA1_write");this.port4D0_read=b("port4D0_read");this.port4D1_read=b("port4D1_read");
482
+ this.port4D0_write=b("port4D0_write");this.port4D1_write=b("port4D1_write")};G.prototype.jit_force_generate=function(a){this.jit_force_generate_unsafe?this.jit_force_generate_unsafe(a):h(!1,"Not supported in this wasm build: jit_force_generate_unsafe")};G.prototype.jit_clear_func=function(a){h(0<=a&&900>a);this.wm.wasm_table.set(a+1024,null)};G.prototype.jit_clear_all_funcs=function(){const a=this.wm.wasm_table;for(let b=0;900>b;b++)a.set(1024+b,null)};G.prototype.get_state=function(){var a=[];a[0]=
483
+ this.memory_size[0];a[1]=new Uint8Array([...this.segment_is_null,...this.segment_access_bytes]);a[2]=this.segment_offsets;a[3]=this.segment_limits;a[4]=this.protected_mode[0];a[5]=this.idtr_offset[0];a[6]=this.idtr_size[0];a[7]=this.gdtr_offset[0];a[8]=this.gdtr_size[0];a[9]=this.page_fault[0];a[10]=this.cr;a[11]=this.cpl[0];a[13]=this.is_32[0];a[16]=this.stack_size_32[0];a[17]=this.in_hlt[0];a[18]=this.last_virt_eip[0];a[19]=this.eip_phys[0];a[22]=this.sysenter_cs[0];a[23]=this.sysenter_eip[0];a[24]=
484
+ this.sysenter_esp[0];a[25]=this.prefixes[0];a[26]=this.flags[0];a[27]=this.flags_changed[0];a[28]=this.last_op1[0];a[30]=this.last_op_size[0];a[37]=this.instruction_pointer[0];a[38]=this.previous_ip[0];a[39]=this.reg32;a[40]=this.sreg;a[41]=this.dreg;a[42]=this.reg_pdpte;this.store_current_tsc();a[43]=this.current_tsc;a[45]=this.devices.virtio_9p;a[46]=this.devices.apic;a[47]=this.devices.rtc;a[48]=this.devices.pci;a[49]=this.devices.dma;a[50]=this.devices.acpi;a[52]=this.devices.vga;a[53]=this.devices.ps2;
485
+ a[54]=this.devices.uart0;a[55]=this.devices.fdc;a[56]=this.devices.cdrom;a[57]=this.devices.hda;a[58]=this.devices.pit;a[59]=this.devices.net;a[60]=this.get_state_pic();a[61]=this.devices.sb16;a[62]=this.fw_value;a[63]=this.devices.ioapic;a[64]=this.tss_size_32[0];a[66]=this.reg_xmm32s;a[67]=this.fpu_st;a[68]=this.fpu_stack_empty[0];a[69]=this.fpu_stack_ptr[0];a[70]=this.fpu_control_word[0];a[71]=this.fpu_ip[0];a[72]=this.fpu_ip_selector[0];a[73]=this.fpu_dp[0];a[74]=this.fpu_dp_selector[0];a[75]=
486
+ this.fpu_opcode[0];const {packed_memory:b,bitmap:c}=this.pack_memory();a[77]=b;a[78]=new Uint8Array(c.get_buffer());a[79]=this.devices.uart1;a[80]=this.devices.uart2;a[81]=this.devices.uart3;a[82]=this.devices.virtio_console;a[83]=this.devices.virtio_net;a[84]=this.devices.virtio_balloon;return a};G.prototype.get_state_pic=function(){const a=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13),c=[],d=[];c[0]=a[0];
487
+ c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=d;c[6]=a[6];c[7]=a[7];c[8]=a[8];c[9]=a[9];c[10]=a[10];c[11]=a[11];c[12]=a[12];d[0]=b[0];d[1]=b[1];d[2]=b[2];d[3]=b[3];d[4]=b[4];d[5]=null;d[6]=b[6];d[7]=b[7];d[8]=b[8];d[9]=b[9];d[10]=b[10];d[11]=b[11];d[12]=b[12];return c};G.prototype.set_state=function(a){this.memory_size[0]=a[0];this.mem8.length!==this.memory_size[0]&&console.warn("Note: Memory size mismatch. we="+this.mem8.length+" state="+this.memory_size[0]);8===a[1].length?(this.segment_is_null.set(a[1]),
488
+ this.segment_access_bytes.fill(242),this.segment_access_bytes[1]=250):16===a[1].length?(this.segment_is_null.set(a[1].subarray(0,8)),this.segment_access_bytes.set(a[1].subarray(8,16))):h("Unexpected cpu segment state length:"+a[1].length);this.segment_offsets.set(a[2]);this.segment_limits.set(a[3]);this.protected_mode[0]=a[4];this.idtr_offset[0]=a[5];this.idtr_size[0]=a[6];this.gdtr_offset[0]=a[7];this.gdtr_size[0]=a[8];this.page_fault[0]=a[9];this.cr.set(a[10]);this.cpl[0]=a[11];this.is_32[0]=a[13];
489
+ this.stack_size_32[0]=a[16];this.in_hlt[0]=a[17];this.last_virt_eip[0]=a[18];this.eip_phys[0]=a[19];this.sysenter_cs[0]=a[22];this.sysenter_eip[0]=a[23];this.sysenter_esp[0]=a[24];this.prefixes[0]=a[25];this.flags[0]=a[26];this.flags_changed[0]=a[27];this.last_op1[0]=a[28];this.last_op_size[0]=a[30];this.instruction_pointer[0]=a[37];this.previous_ip[0]=a[38];this.reg32.set(a[39]);this.sreg.set(a[40]);this.dreg.set(a[41]);a[42]&&this.reg_pdpte.set(a[42]);this.set_tsc(a[43][0],a[43][1]);this.devices.virtio_9p&&
490
+ this.devices.virtio_9p.set_state(a[45]);this.devices.apic&&this.devices.apic.set_state(a[46]);this.devices.rtc&&this.devices.rtc.set_state(a[47]);this.devices.pci&&this.devices.pci.set_state(a[48]);this.devices.dma&&this.devices.dma.set_state(a[49]);this.devices.acpi&&this.devices.acpi.set_state(a[50]);this.devices.vga&&this.devices.vga.set_state(a[52]);this.devices.ps2&&this.devices.ps2.set_state(a[53]);this.devices.uart0&&this.devices.uart0.set_state(a[54]);this.devices.fdc&&this.devices.fdc.set_state(a[55]);
491
+ this.devices.cdrom&&this.devices.cdrom.set_state(a[56]);this.devices.hda&&this.devices.hda.set_state(a[57]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);this.set_state_pic(a[60]);this.devices.sb16&&this.devices.sb16.set_state(a[61]);this.devices.uart1&&this.devices.uart1.set_state(a[79]);this.devices.uart2&&this.devices.uart2.set_state(a[80]);this.devices.uart3&&this.devices.uart3.set_state(a[81]);this.devices.virtio_console&&this.devices.virtio_console.set_state(a[82]);
492
+ this.devices.virtio_net&&this.devices.virtio_net.set_state(a[83]);this.devices.virtio_balloon&&this.devices.virtio_balloon.set_state(a[84]);this.fw_value=a[62];this.devices.ioapic&&this.devices.ioapic.set_state(a[63]);this.tss_size_32[0]=a[64];this.reg_xmm32s.set(a[66]);this.fpu_st.set(a[67]);this.fpu_stack_empty[0]=a[68];this.fpu_stack_ptr[0]=a[69];this.fpu_control_word[0]=a[70];this.fpu_ip[0]=a[71];this.fpu_ip_selector[0]=a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=
493
+ a[75];const b=new k.Bitmap(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();this.jit_clear_cache()};G.prototype.set_state_pic=function(a){const b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),c=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];const d=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=
494
+ d[3];c[4]=d[4];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]};G.prototype.pack_memory=function(){h(0===(this.mem8.length&4095));var a=this.mem8.length>>12,b=[];for(var c=0;c<a;c++)this.is_memory_zeroed(c<<12,4096)||b.push(c);a=new k.Bitmap(a);c=new Uint8Array(b.length<<12);for(const [d,e]of b.entries())a.set(e,1),b=e<<12,b=this.mem8.subarray(b,b+4096),c.set(b,d<<12);return{bitmap:a,packed_memory:c}};G.prototype.unpack_memory=function(a,b){this.zero_memory(0,this.memory_size[0]);
495
+ const c=this.memory_size[0]>>12;let d=0;for(let g=0;g<c;g++)if(a.get(g)){var e=d<<12;e=b.subarray(e,e+4096);this.mem8.set(e,g<<12);d++}};G.prototype.reboot_internal=function(){this.reset_cpu();this.fw_value=[];this.devices.virtio_9p&&this.devices.virtio_9p.reset();this.devices.virtio_console&&this.devices.virtio_console.reset();this.devices.virtio_net&&this.devices.virtio_net.reset();this.load_bios()};G.prototype.reset_memory=function(){this.mem8.fill(0)};G.prototype.create_memory=function(a,b){a<
496
+ b?(a=b,E("Rounding memory size up to "+a,2)):0>(a|0)&&(a=Math.pow(2,31)-131072,E("Rounding memory size down to "+a,2));a=(a-1|131071)+1|0;h(0<(a|0));h(0===(a&131071));console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;b=this.allocate_memory(a);this.mem8=k.view(Uint8Array,this.wasm_memory,b,a);this.mem32s=k.view(Uint32Array,this.wasm_memory,b,a>>2)};G.prototype.init=function(a,b){this.create_memory(a.memory_size||67108864,a.initrd?67108864:1048576);a.disable_jit&&
497
+ this.set_jit_config(0,1);a.cpuid_level&&this.set_cpuid_level(a.cpuid_level);this.acpi_enabled[0]=+a.acpi;this.reset_cpu();var c=new pa(this);this.io=c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();if(a.bzimage){const e=Gb(this.mem8,a.bzimage,a.initrd,a.cmdline||"");e&&this.option_roms.push(e)}c.register_read(179,this,function(){E("port 0xB3 read");return 0});var d=0;c.register_read(146,this,function(){return d});c.register_write(146,this,function(e){d=e});c.register_read(1297,this,
498
+ function(){if(this.fw_pointer<this.fw_value.length)return this.fw_value[this.fw_pointer++];h(!1,"config port: Read past value");return 0});c.register_write(1296,this,void 0,function(e){function g(n){return new Uint8Array(Int32Array.of(n).buffer)}function f(n){return n>>8|n<<8&65280}function l(n){return n<<24|n<<8&16711680|n>>8&65280|n>>>24}E("bios config port, index="+B(e));this.fw_pointer=0;if(0===e)this.fw_value=g(1431127377);else if(1===e)this.fw_value=g(0);else if(3===e)this.fw_value=g(this.memory_size[0]);
499
+ else if(5===e)this.fw_value=g(1);else if(15===e)this.fw_value=g(1);else if(13===e)this.fw_value=new Uint8Array(16);else if(25===e){e=new Int32Array(4+64*this.option_roms.length);const n=new Uint8Array(e.buffer);e[0]=l(this.option_roms.length);for(let m=0;m<this.option_roms.length;m++){const {name:q,data:r}=this.option_roms[m],t=4+64*m;h(65536>49152+m);e[t+0>>2]=l(r.length);e[t+4>>2]=f(49152+m);h(56>q.length);for(let v=0;v<q.length;v++)n[t+8+v]=q.charCodeAt(v)}this.fw_value=n}else 32768<=e&&49152>
500
+ e?this.fw_value=g(0):49152<=e&&e-49152<this.option_roms.length?this.fw_value=this.option_roms[e-49152].data:(E("Warning: Unimplemented fw index: "+B(e)),this.fw_value=g(0))});c.register_write(128,this,function(){});c.register_read(128,this,function(){return 255});c.register_write(233,this,function(){});c.register_read(32,this,this.port20_read);c.register_read(33,this,this.port21_read);c.register_read(160,this,this.portA0_read);c.register_read(161,this,this.portA1_read);c.register_write(32,this,this.port20_write);
501
+ c.register_write(33,this,this.port21_write);c.register_write(160,this,this.portA0_write);c.register_write(161,this,this.portA1_write);c.register_read(1232,this,this.port4D0_read);c.register_read(1233,this,this.port4D1_read);c.register_write(1232,this,this.port4D0_write);c.register_write(1233,this,this.port4D1_write);this.devices={};a.load_devices&&(this.devices.pci=new za(this),this.acpi_enabled[0]&&(this.devices.ioapic=new Na(this),this.devices.apic=new Ma(this),this.devices.acpi=new Ha(this)),this.devices.rtc=
502
+ new Fa(this),this.fill_cmos(this.devices.rtc,a),this.devices.dma=new O(this),this.devices.vga=new P(this,b,a.screen,a.vga_memory_size||8388608),this.devices.ps2=new Ea(this,b),this.devices.uart0=new Ga(this,1016,b),a.uart1&&(this.devices.uart1=new Ga(this,760,b)),a.uart2&&(this.devices.uart2=new Ga(this,1E3,b)),a.uart3&&(this.devices.uart3=new Ga(this,744,b)),this.devices.fdc=new N(this,a.fda,a.fdb),c=0,a.hda&&(this.devices.hda=new ya(this,a.hda,a.hdb,!1,c++,b)),a.cdrom&&(this.devices.cdrom=new ya(this,
503
+ a.cdrom,void 0,!0,c++,b)),this.devices.pit=new Aa(this,b),"ne2k"===a.net_device.type?this.devices.net=new Va(this,b,a.preserve_mac_from_state_image,a.mac_address_translation):"virtio"===a.net_device.type&&(this.devices.virtio_net=new sb(this,b,a.preserve_mac_from_state_image)),a.fs9p&&(this.devices.virtio_9p=new ea(a.fs9p,this,b)),a.virtio_console&&(this.devices.virtio_console=new rb(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=new Db(this,b)),this.devices.sb16=new Q(this,b));a.multiboot&&
504
+ (E("loading multiboot",2),a=this.load_multiboot_option_rom(a.multiboot,a.initrd,a.cmdline))&&(this.bios.main?(E("adding option rom for multiboot",2),this.option_roms.push(a)):(E("loaded multiboot without bios",2),this.reg32[0]=this.io.port_read32(244)));this.debug.init()};G.prototype.load_multiboot=function(a){this.bios.main&&h(!1,"load_multiboot not supported with BIOS");this.load_multiboot_option_rom(a,void 0,"")&&(E("loaded multiboot",2),this.reg32[0]=this.io.port_read32(244))};G.prototype.load_multiboot_option_rom=
505
+ function(a,b,c){E("Trying multiboot from buffer of size "+a.byteLength,2);if(8192>a.byteLength){var d=new Int32Array(2048);(new Uint8Array(d.buffer)).set(new Uint8Array(a))}else d=new Int32Array(a,0,2048);for(var e=0;8192>e;e+=4){if(464367618===d[e>>2]){var g=d[e+4>>2];if(464367618+g+d[e+8>>2]|0){E("Multiboot checksum check failed",2);continue}}else continue;E("Multiboot magic found, flags: "+B(g>>>0,8),2);h(0===(g&-65540),"TODO");var f=this;this.io.register_read(244,this,function(){return 0},function(){return 0},
506
+ function(){var q=31860,r=0;if(c){r|=4;f.write32(31760,q);c+="\x00";var t=(new TextEncoder).encode(c);f.write_blob(t,q);q+=t.length}if(g&2){r|=64;t=0;f.write32(31788,0);f.write32(31792,q);var v=0;let x=!1;for(let H=0;4294967296>H;H+=131072)x&&void 0!==f.memory_map_read8[H>>>17]?(f.write32(q,20),f.write32(q+4,v),f.write32(q+8,0),f.write32(q+12,H-v),f.write32(q+16,0),f.write32(q+20,1),q+=24,t+=24,x=!1):x||void 0!==f.memory_map_read8[H>>>17]||(v=H,x=!0);h(!x,"top of 4GB shouldn't have memory");f.write32(31788,
507
+ t)}f.write32(31744,r);t=r=0;if(g&65536){E("Multiboot specifies its own address table",2);var y=d[e+12>>2];var D=d[e+16>>2];var u=d[e+20>>2];var A=d[e+24>>2];r=d[e+28>>2];E("header="+B(y,8)+" load="+B(D,8)+" load_end="+B(u,8)+" bss_end="+B(A,8)+" entry="+B(r,8));h(D<=y);y=e-(y-D);0===u?t=void 0:(h(u>=D),t=u-D);y=new Uint8Array(a,y,t);f.write_blob(y,D);r|=0;t=Math.max(u,A)}else if(1179403647===d[0]){E("Multiboot image is in elf format",2);v=new DataView(a);const [x,H]=Hb(v,Ib);console.assert(52===H);
508
+ for(y of Object.keys(x))E(y+": 0x"+(x[y].toString(16)>>>0));console.assert(1179403647===x.magic,"Bad magic");console.assert(1===x.class,"Unimplemented: 64 bit elf");console.assert(1===x.data,"Unimplemented: big endian");console.assert(1===x.version0,"Bad version0");console.assert(2===x.type,"Unimplemented type");console.assert(1===x.version1,"Bad version1");console.assert(52===x.ehsize,"Bad header size");console.assert(32===x.phentsize,"Bad program header size");console.assert(40===x.shentsize,"Bad section header size");
509
+ [r]=Jb(new DataView(v.buffer,v.byteOffset+x.phoff,x.phentsize*x.phnum),Kb,x.phnum);[y]=Jb(new DataView(v.buffer,v.byteOffset+x.shoff,x.shentsize*x.shnum),Lb,x.shnum);if(ma){console.log("%d program headers:",r.length);for(A of r)console.log("type=%s offset=%s vaddr=%s paddr=%s filesz=%s memsz=%s flags=%s align=%s",A.type.toString(16),A.offset.toString(16),A.vaddr.toString(16),A.paddr.toString(16),A.filesz.toString(16),A.memsz.toString(16),A.flags.toString(16),A.align.toString(16));console.log("%d section headers:",
510
+ y.length);for(D of y)console.log("name=%s type=%s flags=%s addr=%s offset=%s size=%s link=%s info=%s addralign=%s entsize=%s",D.name.toString(16),D.type.toString(16),D.flags.toString(16),D.addr.toString(16),D.offset.toString(16),D.size.toString(16),D.link.toString(16),D.info.toString(16),D.addralign.toString(16),D.entsize.toString(16))}A=x;D=r;r=A.entry;for(u of D)0!==u.type&&(1===u.type?(h(u.filesz<=u.memsz),u.paddr+u.memsz<f.memory_size[0]?(u.filesz&&(D=new Uint8Array(a,u.offset,u.filesz),f.write_blob(D,
511
+ u.paddr)),t=Math.max(t,u.paddr+u.memsz),E("prg load "+u.paddr+" to "+(u.paddr+u.memsz),2),r===A.entry&&u.vaddr<=r&&u.vaddr+u.memsz>r&&(r=r-u.vaddr+u.paddr)):E("Warning: Skipped loading section, paddr="+B(u.paddr)+" memsz="+u.memsz,2)):2===u.type||3===u.type||4===u.type||6===u.type||7===u.type||1685382480===u.type||1685382481===u.type||1685382482===u.type||1685382483===u.type?E("skip load type "+u.type+" "+u.paddr+" to "+(u.paddr+u.memsz),2):h(!1,"unimplemented elf section type: "+B(u.type)))}else h(!1,
512
+ "Not a bootable multiboot format");b&&(f.write32(31764,1),f.write32(31768,q),u=t,0!==(u&4095)&&(u=(u&-4096)+4096),E("ramdisk address "+u),A=u+b.byteLength,f.write32(q,u),f.write32(q+4,A),f.write32(q+8,0),f.write32(q+12,0),h(A<f.memory_size[0]),f.write_blob(new Uint8Array(b),u));f.reg32[3]=31744;f.cr[0]=1;f.protected_mode[0]=1;f.flags[0]=2;f.is_32[0]=1;f.stack_size_32[0]=1;for(q=0;6>q;q++)f.segment_is_null[q]=0,f.segment_offsets[q]=0,f.segment_limits[q]=4294967295,f.sreg[q]=45058;f.instruction_pointer[0]=
513
+ f.get_seg_cs()+r|0;f.update_state_flags();E("Starting multiboot kernel at:",2);f.debug.dump_state();f.debug.dump_regs();return 732803074});this.io.register_write_consecutive(244,this,function(q){console.log("Test exited with code "+B(q,2));throw"HALT";},function(){},function(){},function(){});for(let q=0;15>=q;q++){function r(t){E("kvm-unit-test: Set irq "+B(q)+" to "+B(t,2));t?this.device_raise_irq(q):this.device_lower_irq(q)}this.io.register_write(8192+q,this,r,r,r)}const n=new Uint8Array(512);
514
+ (new Uint16Array(n.buffer))[0]=43605;n[2]=1;var l=3;n[l++]=102;n[l++]=229;n[l++]=244;h(512>l);let m=n[l]=0;for(let q=0;q<n.length;q++)m+=n[q];n[l]=-m;return{name:"genroms/multiboot.bin",data:n}}E("Multiboot header not found",2)};G.prototype.fill_cmos=function(a,b){var c=b.boot_order||291;a.cmos_write(56,1|c>>4&240);a.cmos_write(61,c&255);a.cmos_write(21,128);a.cmos_write(22,2);c=0;1048576<=this.memory_size[0]&&(c=this.memory_size[0]-1048576>>10,c=Math.min(c,65535));a.cmos_write(23,c&255);a.cmos_write(24,
515
+ c>>8&255);a.cmos_write(48,c&255);a.cmos_write(49,c>>8&255);c=0;16777216<=this.memory_size[0]&&(c=this.memory_size[0]-16777216>>16,c=Math.min(c,65535));a.cmos_write(52,c&255);a.cmos_write(53,c>>8&255);a.cmos_write(91,0);a.cmos_write(92,0);a.cmos_write(93,0);a.cmos_write(20,47);a.cmos_write(95,0);b.fastboot&&a.cmos_write(63,1)};G.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){h(a instanceof ArrayBuffer);var c=new Uint8Array(a);this.write_blob(c,1048576-a.byteLength);if(b){h(b instanceof
516
+ ArrayBuffer);var d=new Uint8Array(b);this.write_blob(d,786432);this.io.mmap_register(4272947200,1048576,function(e){e=e-4272947200|0;return e<d.length?d[e]:0},function(){h(!1,"Unexpected write to VGA rom")})}else E("Warning: No VGA BIOS");this.io.mmap_register(4293918720,1048576,function(e){return this.mem8[e&1048575]}.bind(this),function(e,g){this.mem8[e&1048575]=g}.bind(this))}else E("Warning: No BIOS")};G.prototype.codegen_finalize=function(a,b,c,d,e){d>>>=0;e>>>=0;h(0<=a&&900>a);const g=new Uint8Array(this.wasm_memory.buffer,
517
+ d,e);this.seen_code[b]=(this.seen_code[b]||0)+1;this.test_hook_did_generate_wasm&&this.test_hook_did_generate_wasm(g);WebAssembly.instantiate(g,{e:this.jit_imports}).then(f=>{this.wm.wasm_table.set(a+1024,f.instance.exports.f);this.codegen_finalize_finished(a,b,c);this.test_hook_did_finalize_wasm&&this.test_hook_did_finalize_wasm(g)}).catch(f=>{console.log(f);debugger;throw f;})};G.prototype.log_uncompiled_code=function(){};G.prototype.dump_function_code=function(){};G.prototype.run_hardware_timers=
518
+ function(a,b){const c=this.devices.pit.timer(b,!1),d=this.devices.rtc.timer(b,!1);let e=100,g=100;a&&(e=this.devices.acpi.timer(b),g=this.devices.apic.timer(b));return Math.min(c,d,e,g)};G.prototype.device_raise_irq=function(a){h(1===arguments.length);this.pic_set_irq(a);this.devices.ioapic&&this.devices.ioapic.set_irq(a)};G.prototype.device_lower_irq=function(a){this.pic_clear_irq(a);this.devices.ioapic&&this.devices.ioapic.clear_irq(a)};G.prototype.debug_init=function(){function a(m){for(var q=
519
+ e.protected_mode[0]?"prot":"real",r=e.get_eflags(),t=e.getiopl(),v=e.cpl[0],y=B(e.sreg[1],4)+":"+B(e.get_real_eip()>>>0,8),D=B(e.sreg[2],4)+":"+B(e.reg32[0]>>>0,8),u=e.is_32[0]?"32":"16",A=e.flags[0]&512?1:0,x={[1]:"c",[4]:"p",[16]:"a",[64]:"z",[128]:"s",[256]:"t",[512]:"i",[1024]:"d",[2048]:"o"},H="",L=0;16>L;L++)x[1<<L]&&(H=r&1<<L?H+x[1<<L]:H+" ");return"mode="+q+"/"+u+" paging="+ +(0!==(e.cr[0]&-2147483648))+" pae="+ +(0!==(e.cr[4]&32))+" iopl="+t+" cpl="+v+" if="+A+" cs:eip="+y+" cs_off="+B(e.get_seg_cs()>>>
520
+ 0,8)+" flgs="+B(e.get_eflags()>>>0,6)+" ("+H+") ss:esp="+D+" ssize="+ +e.stack_size_32[0]+(m?" in "+m:"")}function b(){for(var m={eax:0,ecx:1,edx:2,ebx:3,esp:4,ebp:5,esi:6,edi:7},q="eax ecx edx ebx esp ebp esi edi".split(" "),r="",t="",v=0;4>v;v++)r+=q[v]+"="+B(e.reg32[m[q[v]]]>>>0,8)+" ",t+=q[v+4]+"="+B(e.reg32[m[q[v+4]]]>>>0,8)+" ";r+=" ds="+B(e.sreg[3],4)+" es="+B(e.sreg[0],4)+" fs="+B(e.sreg[4],4);t+=" gs="+B(e.sreg[5],4)+" cs="+B(e.sreg[1],4)+" ss="+B(e.sreg[2],4);return[r,t]}function c(m,
521
+ q,r){if(!(m&1))return!1;var t=128===(m&128);return{size:t,global:256===(m&256),accessed:32===(m&32),dirty:64===(m&64),cache_disable:16===(m&16),user:4===(m&4),read_write:2===(m&2),address:(t&&!r?m&(q?4292870144:4290772992):m&4294963200)>>>0}}function d(m,q,r){for(var t=q?512:1024,v=q?8:4,y=q?21:22,D=0;D<t;D++){var u=e.read32s(m+D*v),A=c(u,q,!0);if(A)if(u="",u+=A.size?"S ":" ",u+=A.accessed?"A ":" ",u+=A.cache_disable?"Cd ":" ",u+=A.user?"U ":" ",u+=A.read_write?"Rw ":" ",A.size)E("=== "+B(r+
522
+ (D<<y)>>>0,8)+" -> "+B(A.address>>>0,8)+" | "+u);else{E("=== "+B(r+(D<<y)>>>0,8)+" | "+u);for(var x=0;x<t;x++){var H=A.address+x*v;u=e.read32s(H);var L=c(u,q,!1);L&&(u="",u+=L.cache_disable?"Cd ":" ",u+=L.user?"U ":" ",u+=L.read_write?"Rw ":" ",u+=L.global?"G ":" ",u+=L.accessed?"A ":" ",u+=L.dirty?"Di ":" ",E("# "+B(r+(D<<y|x<<12)>>>0,8)+" -> "+B(L.address,8)+" | "+u+" (at "+B(H,8)+")"))}}}}var e=this,g={};this.debug=g;g.init=function(){function m(r){10===r?(E(q,4096),q=""):q+=String.fromCharCode(r)}
523
+ if(e.io){var q="";e.io.register_write(1026,this,m);e.io.register_write(1280,this,m)}};g.get_regs_short=b;g.dump_regs=function(){var m=b();E(m[0],2);E(m[1],2)};g.get_state=a;g.dump_state=function(m){E(a(m),2)};g.dump_stack=function(m,q){var r=e.reg32[4];E("========= STACK ==========");if(q>=m||void 0===q)m=5,q=-5;for(;m>q;m--){var t=" ";m||(t="=> ");t+=B(m,2)+" | ";E(t+B(r+4*m,8)+" | "+B(e.read32s(r+4*m)>>>0))}};g.dump_page_structures=function(){if(e.cr[4]&32){E("PAE enabled");for(var m=0;4>m;m++){var q=
524
+ e.read32s(e.cr[3]+8*m);q&1&&d(q&4294963200,!0,m<<30)}}else E("PAE disabled"),d(e.cr[3],!1,0)};g.dump_gdt_ldt=function(){function m(q,r){for(var t=0;t<r;t+=8,q+=8){var v=e.read16(q+2)|e.read8(q+4)<<16|e.read8(q+7)<<24,y=e.read16(q)|(e.read8(q+6)&15)<<16,D=e.read8(q+5),u=e.read8(q+6)>>4,A="",x=D>>5&3;A=D&128?A+" P ":A+"NP ";D&16?(A=u&4?A+"32b ":A+"16b ",D&8?(A+="X ",D&4&&(A+="C ")):A+="R ",A+="RW "):A+="sys: "+B(D&15);u&8&&(y=y<<12|4095);E(B(t&-8,4)+" "+B(v>>>0,8)+" ("+B(y>>>0,8)+" bytes) "+A+"; dpl = "+
525
+ x+", a = "+D.toString(2)+", f = "+u.toString(2))}}E("gdt: (len = "+B(e.gdtr_size[0])+")");m(e.translate_address_system_read(e.gdtr_offset[0]),e.gdtr_size[0]);E("\nldt: (len = "+B(e.segment_limits[7])+")");m(e.translate_address_system_read(e.segment_offsets[7]),e.segment_limits[7])};g.dump_idt=function(){for(var m=0;m<e.idtr_size[0];m+=8){var q=e.translate_address_system_read(e.idtr_offset[0]+m),r=e.read16(q)|e.read16(q+6)<<16,t=e.read16(q+2);q=e.read8(q+5);var v=q>>5&3;var y=5===(q&31)?"task gate ":
526
+ 14===(q&31)?"intr gate ":15===(q&31)?"trap gate ":"invalid ";y=q&128?y+" P":y+"NP";E(B(m>>3,4)+" "+B(r>>>0,8)+", "+B(t,4)+"; "+y+"; dpl = "+v+", t = "+q.toString(2))}};g.get_memory_dump=function(m,q){void 0===m?(m=0,q=e.memory_size[0]):void 0===q&&(q=m,m=0);return e.mem8.slice(m,m+q).buffer};g.memory_hex_dump=function(m,q){q=q||64;for(var r,t,v=0;v<q>>4;v++){r=B(m+(v<<4),5)+" ";for(var y=0;16>y;y++)t=e.read8(m+(v<<4)+y),r+=B(t,2)+" ";r+=" ";for(y=0;16>y;y++)t=e.read8(m+(v<<4)+y),r+=33>t||126<
527
+ t?".":String.fromCharCode(t);E(r)}};g.used_memory_dump=function(){for(var m=e.memory_size[0]/128/16|0,q,r=0;16>r;r++){q=B(128*r*m,8)+" | ";for(var t=0;128>t;t++)q+=0<e.mem32s[(128*r+t)*m]?"X":" ";E(q)}};g.debug_interrupt=function(){};let f,l;g.dump_code=function(m,q,r){if(!l){if(void 0===f&&(f="function"===typeof require?require("./capstone-x86.min.js"):window.cs,void 0===f)){E("Warning: Missing capstone library, disassembly not available");return}l=[new f.Capstone(f.ARCH_X86,f.MODE_16),new f.Capstone(f.ARCH_X86,
528
+ f.MODE_32)]}try{l[m].disasm(q,r).forEach(function(t){E(B(t.address>>>0)+": "+k.pads(t.bytes.map(v=>B(v,2).slice(-2)).join(" "),20)+" "+t.mnemonic+" "+t.op_str)}),E("")}catch(t){E("Could not disassemble: "+Array.from(q).map(v=>B(v,2)).join(" "))}};let n;g.dump_wasm=function(m){if(void 0===n&&(n="function"===typeof require?require("./libwabt.js"):new window.WabtModule,void 0===n)){E("Warning: Missing libwabt, wasm dump not available");return}m=m.slice();try{var q=n.readWasm(m,{readDebugNames:!1});q.generateNames();
529
+ q.applyNames();const v=q.toText({foldExprs:!0,inlineExport:!0});E(v)}catch(v){var r=new Blob([m]),t=document.createElement("a");t.download="failed.wasm";t.href=window.URL.createObjectURL(r);t.dataset.downloadurl=["application/octet-stream",t.download,t.href].join(":");t.click();window.URL.revokeObjectURL(t.src);console.log(v.toString())}finally{q&&q.destroy()}}};const Mb=DataView.prototype,Nb={size:1,get:Mb.getUint8,set:Mb.setUint8},Ub={size:2,get:Mb.getUint16,set:Mb.setUint16},X={size:4,get:Mb.getUint32,
530
+ set:Mb.setUint32},Ib=Vb([{magic:X},{class:Nb},{data:Nb},{version0:Nb},{osabi:Nb},{abiversion:Nb},{pad0:function(a){return{size:a,get:()=>-1}}(7)},{type:Ub},{machine:Ub},{version1:X},{entry:X},{phoff:X},{shoff:X},{flags:X},{ehsize:Ub},{phentsize:Ub},{phnum:Ub},{shentsize:Ub},{shnum:Ub},{shstrndx:Ub}]);console.assert(52===Ib.reduce((a,b)=>a+b.size,0));const Kb=Vb([{type:X},{offset:X},{vaddr:X},{paddr:X},{filesz:X},{memsz:X},{flags:X},{align:X}]);console.assert(32===Kb.reduce((a,b)=>a+b.size,0));const Lb=
531
+ Vb([{name:X},{type:X},{flags:X},{addr:X},{offset:X},{size:X},{link:X},{info:X},{addralign:X},{entsize:X}]);console.assert(40===Lb.reduce((a,b)=>a+b.size,0));function Vb(a){return a.map(function(b){var c=Object.keys(b);console.assert(1===c.length);c=c[0];b=b[c];console.assert(0<b.size);return{name:c,type:b,size:b.size,get:b.get,set:b.set}})}function Hb(a,b){const c={};let d=0;for(const e of b)b=e.get.call(a,d,!0),console.assert(void 0===c[e.name]),c[e.name]=b,d+=e.size;return[c,d]}function Jb(a,b,
532
+ c){const d=[];let e=0;for(var g=0;g<c;g++){const [f,l]=Hb(new DataView(a.buffer,a.byteOffset+e,void 0),b);d.push(f);e+=l}return[d,e]}function Gb(a,b,c,d){E("Trying to load kernel of size "+b.byteLength);var e=new Uint8Array(b);const g=new Uint16Array(b);var f=new Uint32Array(b),l=e[497]||4,n=g[255];if(43605!==n)E("Bad checksum1: "+B(n));else if(n=g[257]|g[258]<<16,1400005704!==n)E("Bad checksum2: "+B(n));else{n=g[259];h(514<=n);var m=e[529];h(m&1);var q=g[283],r=f[139],t=f[140],v=e[564],y=e[565],
533
+ D=518<=n?f[142]:255,u=f[146],A=f[147],x=f[150],H=f[151],L=f[152];E("kernel boot protocol version: "+B(n));E("flags="+B(m)+" xflags="+B(q));E("code32_start="+B(f[133]));E("initrd_addr_max="+B(r));E("kernel_alignment="+B(t));E("relocatable="+v);E("min_alignment="+B(y));E("cmdline max="+B(D));E("payload offset="+B(u)+" size="+B(A));E("pref_address="+B(H)+":"+B(x));E("init_size="+B(L));e[528]=255;e[529]=m&-97|128;g[274]=56832;g[253]=65535;E("heap_end_ptr="+B(56832));d+="\x00";h(d.length<D);E("cmd_line_ptr="+
534
+ B(581632));f[138]=581632;for(e=0;e<d.length;e++)a[581632+e]=d.charCodeAt(e);l=512*(l+1);E("prot_mode_kernel_start="+B(l));d=new Uint8Array(b,0,l);b=new Uint8Array(b,l);e=l=0;c&&(l=67108864,e=c.byteLength,h(1048576+b.length<l),a.set(new Uint8Array(c),l));f[134]=l;f[135]=e;h(655360>524288+d.length);a.set(d,524288);a.set(b,1048576);a=new Uint8Array(512);(new Uint16Array(a.buffer))[0]=43605;a[2]=1;c=3;a[c++]=250;a[c++]=184;a[c++]=32768;a[c++]=128;a[c++]=142;a[c++]=192;a[c++]=142;a[c++]=216;a[c++]=142;
535
+ a[c++]=224;a[c++]=142;a[c++]=232;a[c++]=142;a[c++]=208;a[c++]=188;a[c++]=57344;a[c++]=224;a[c++]=234;a[c++]=0;a[c++]=0;a[c++]=32800;a[c++]=128;h(512>c);f=a[c]=0;for(b=0;b<a.length;b++)f+=a[b];a[c]=-f;return{name:"genroms/kernel.bin",data:a}}}const Wb="undefined"!==typeof window&&0<=window.navigator.platform.toString().toLowerCase().search("win");function Xb(a){function b(x){return x.shiftKey&&x.ctrlKey&&(73===x.keyCode||74===x.keyCode||75===x.keyCode)||!v.emu_enabled?!1:x.target?x.target.classList.contains("phone_keyboard")||
536
+ "INPUT"!==x.target.nodeName&&"TEXTAREA"!==x.target.nodeName:!0}function c(x){!x.altKey&&m[56]&&l(56,!1);return g(x,!1)}function d(x){!x.altKey&&m[56]&&l(56,!1);return g(x,!0)}function e(){for(var x=Object.keys(m),H,L=0;L<x.length;L++)H=+x[L],m[H]&&l(H,!1);m={}}function g(x,H){if(v.bus&&b(x)){x.preventDefault&&x.preventDefault();if(Wb&&(q&&(clearTimeout(t),x.getModifierState&&x.getModifierState("AltGraph")&&r===H&&"ControlLeft"===q.code&&"AltRight"===x.code||f(q,r),q=null),"ControlLeft"===x.code))return q=
537
+ x,r=H,t=setTimeout(()=>{f(q,r);q=null},10),!1;f(x,H);return!1}}function f(x,H){a:{if(void 0!==x.code){var L=A[x.code];if(void 0!==L)break a}L=y[x.keyCode]}L?l(L,H,x.repeat):console.log("Missing char in map: keyCode="+(x.keyCode||-1).toString(16)+" code="+x.code)}function l(x,H,L){if(H)m[x]&&!L&&l(x,!1);else if(!m[x])return;(m[x]=H)||(x|=128);255<x?(n(x>>8),n(x&255)):n(x)}function n(x){v.bus.send("keyboard-code",x)}var m={},q=null,r=!1,t=0,v=this;this.emu_enabled=!0;var y=new Uint16Array([0,0,0,0,
538
+ 0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,0,58,0,0,0,0,0,0,1,0,0,0,0,57,57417,57425,57423,57415,57419,57416,57421,80,0,0,0,0,82,83,0,11,2,3,4,5,6,7,8,9,10,0,39,0,13,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44,57435,57436,57437,0,0,82,79,80,81,75,76,77,71,72,73,0,0,0,0,0,0,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,
539
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,40,0,57435,57400,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),D={8:8,10:13,32:32,39:222,44:188,45:189,46:190,47:191,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,59:186,61:187,91:219,92:220,93:221,96:192,97:65,98:66,99:67,100:68,101:69,102:70,103:71,104:72,105:73,106:74,107:75,108:76,109:77,110:78,111:79,112:80,113:81,114:82,115:83,116:84,117:85,118:86,119:87,120:88,121:89,122:90},u={33:49,34:222,35:51,36:52,37:53,38:55,40:57,41:48,42:56,43:187,58:186,
540
+ 60:188,62:190,63:191,64:50,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,94:54,95:189,123:219,124:220,125:221,126:192},A={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,
541
+ KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,IntlRo:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,
542
+ Numpad0:82,NumpadDecimal:83,IntlBackslash:86,F11:87,F12:88,NumpadEnter:57372,ControlRight:57373,NumpadDivide:57397,AltRight:57400,Home:57415,ArrowUp:57416,PageUp:57417,ArrowLeft:57419,ArrowRight:57421,End:57423,ArrowDown:57424,PageDown:57425,Insert:57426,Delete:57427,OSLeft:57435,OSRight:57436,ContextMenu:57437};this.bus=a;this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("keyup",c,!1),window.removeEventListener("keydown",d,!1),window.removeEventListener("blur",e,!1))};
543
+ this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("keyup",c,!1),window.addEventListener("keydown",d,!1),window.addEventListener("blur",e,!1))};this.init();this.simulate_press=function(x){x={keyCode:x};g(x,!0);g(x,!1)};this.simulate_char=function(x){var H=x.charCodeAt(0);H in D?this.simulate_press(D[H]):H in u?(n(42),this.simulate_press(u[H]),n(170)):console.log("ascii -> keyCode not found: ",H,x)}}function Yb(a,b){function c(u){if(!D.enabled||!D.emu_enabled)return!1;
544
+ var A=b||document.body,x;if(!(x=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===A){x=!0;break a}u=u.parentNode}x=!1}return x}function d(u){c(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-1],v=u.clientX,y=u.clientY)}function e(){if(q||t||r)D.bus.send("mouse-click",[!1,!1,!1]),q=t=r=!1}function g(u){if(D.bus&&c(u)&&D.is_running){var A=0,x=0,H=u.changedTouches;H?H.length&&(H=H[H.length-1],A=H.clientX-v,x=H.clientY-y,v=H.clientX,y=H.clientY,u.preventDefault()):"number"===typeof u.movementX?
545
+ (A=u.movementX,x=u.movementY):"number"===typeof u.webkitMovementX?(A=u.webkitMovementX,x=u.webkitMovementY):"number"===typeof u.mozMovementX?(A=u.mozMovementX,x=u.mozMovementY):(A=u.clientX-v,x=u.clientY-y,v=u.clientX,y=u.clientY);D.bus.send("mouse-delta",[.15*A,-(.15*x)]);b&&D.bus.send("mouse-absolute",[u.pageX-b.offsetLeft,u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function f(u){c(u)&&n(u,!0)}function l(u){c(u)&&n(u,!1)}function n(u,A){D.bus&&(1===u.which?q=A:2===u.which?t=A:3===u.which?
546
+ r=A:E("Unknown event.which: "+u.which),D.bus.send("mouse-click",[q,t,r]),u.preventDefault())}function m(u){if(c(u)){var A=u.wheelDelta||-u.detail;0>A?A=-1:0<A&&(A=1);D.bus.send("mouse-wheel",[A,0]);u.preventDefault()}}var q=!1,r=!1,t=!1,v=0,y=0,D=this;this.enabled=!1;this.emu_enabled=!0;this.bus=a;this.bus.register("mouse-enable",function(u){this.enabled=u},this);this.is_running=!1;this.bus.register("emulator-stopped",function(){this.is_running=!1},this);this.bus.register("emulator-started",function(){this.is_running=
547
+ !0},this);this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("touchstart",d,!1),window.removeEventListener("touchend",e,!1),window.removeEventListener("touchmove",g,!1),window.removeEventListener("mousemove",g,!1),window.removeEventListener("mousedown",f,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("wheel",m,{passive:!1}))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("touchstart",d,!1),window.addEventListener("touchend",
548
+ e,!1),window.addEventListener("touchmove",g,!1),window.addEventListener("mousemove",g,!1),window.addEventListener("mousedown",f,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("wheel",m,{passive:!1}))};this.init()}function Zb(a){if("undefined"!==typeof window)if(window.AudioContext||window.webkitAudioContext){var b=window.AudioWorklet?$b:ac;this.bus=a;this.audio_context=window.AudioContext?new AudioContext:new webkitAudioContext;this.mixer=new bc(a,this.audio_context);this.pcspeaker=
549
+ new cc(a,this.audio_context,this.mixer);this.dac=new b(a,this.audio_context,this.mixer);this.pcspeaker.start();a.register("emulator-stopped",function(){this.audio_context.suspend()},this);a.register("emulator-started",function(){this.audio_context.resume()},this);a.register("speaker-confirm-initialized",function(){a.send("speaker-has-initialized")},this);a.send("speaker-has-initialized")}else console.warn("Web browser doesn't support Web Audio API")}Zb.prototype.destroy=function(){this.audio_context&&
550
+ this.audio_context.close();this.audio_context=null;this.dac&&this.dac.node_processor&&this.dac.node_processor.port.close();this.dac=null};function bc(a,b){function c(d){return function(e){d.gain.setValueAtTime(e,this.audio_context.currentTime)}}this.audio_context=b;this.sources=new Map;this.gain_right=this.gain_left=this.volume_right=this.volume_left=this.volume_both=1;this.node_treble_left=this.audio_context.createBiquadFilter();this.node_treble_right=this.audio_context.createBiquadFilter();this.node_treble_left.type=
551
+ "highshelf";this.node_treble_right.type="highshelf";this.node_treble_left.frequency.setValueAtTime(2E3,this.audio_context.currentTime);this.node_treble_right.frequency.setValueAtTime(2E3,this.audio_context.currentTime);this.node_bass_left=this.audio_context.createBiquadFilter();this.node_bass_right=this.audio_context.createBiquadFilter();this.node_bass_left.type="lowshelf";this.node_bass_right.type="lowshelf";this.node_bass_left.frequency.setValueAtTime(200,this.audio_context.currentTime);this.node_bass_right.frequency.setValueAtTime(200,
552
+ this.audio_context.currentTime);this.node_gain_left=this.audio_context.createGain();this.node_gain_right=this.audio_context.createGain();this.node_merger=this.audio_context.createChannelMerger(2);this.input_left=this.node_treble_left;this.input_right=this.node_treble_right;this.node_treble_left.connect(this.node_bass_left);this.node_bass_left.connect(this.node_gain_left);this.node_gain_left.connect(this.node_merger,0,0);this.node_treble_right.connect(this.node_bass_right);this.node_bass_right.connect(this.node_gain_right);
553
+ this.node_gain_right.connect(this.node_merger,0,1);this.node_merger.connect(this.audio_context.destination);a.register("mixer-connect",function(d){this.connect_source(d[0],d[1])},this);a.register("mixer-disconnect",function(d){this.disconnect_source(d[0],d[1])},this);a.register("mixer-volume",function(d){var e=d[0],g=d[1];d=Math.pow(10,d[2]/20);var f=0===e?this:this.sources.get(e);void 0===f?h(!1,"Mixer set volume - cannot set volume for undefined source: "+e):f.set_volume(d,g)},this);a.register("mixer-gain-left",
554
+ function(d){this.gain_left=Math.pow(10,d/20);this.update()},this);a.register("mixer-gain-right",function(d){this.gain_right=Math.pow(10,d/20);this.update()},this);a.register("mixer-treble-left",c(this.node_treble_left),this);a.register("mixer-treble-right",c(this.node_treble_right),this);a.register("mixer-bass-left",c(this.node_bass_left),this);a.register("mixer-bass-right",c(this.node_bass_right),this)}bc.prototype.add_source=function(a,b){a=new dc(this.audio_context,a,this.input_left,this.input_right);
555
+ h(!this.sources.has(b),"Mixer add source - overwritting source: "+b);this.sources.set(b,a);return a};bc.prototype.connect_source=function(a,b){var c=this.sources.get(a);void 0===c?h(!1,"Mixer connect - cannot connect undefined source: "+a):c.connect(b)};bc.prototype.disconnect_source=function(a,b){var c=this.sources.get(a);void 0===c?h(!1,"Mixer disconnect - cannot disconnect undefined source: "+a):c.disconnect(b)};bc.prototype.set_volume=function(a,b){void 0===b&&(b=2);switch(b){case 0:this.volume_left=
556
+ a;break;case 1:this.volume_right=a;break;case 2:this.volume_both=a;break;default:h(!1,"Mixer set master volume - unknown channel: "+b);return}this.update()};bc.prototype.update=function(){var a=this.volume_both*this.volume_right*this.gain_right;this.node_gain_left.gain.setValueAtTime(this.volume_both*this.volume_left*this.gain_left,this.audio_context.currentTime);this.node_gain_right.gain.setValueAtTime(a,this.audio_context.currentTime)};function dc(a,b,c,d){this.audio_context=a;this.connected_right=
557
+ this.connected_left=!0;this.volume_right=this.volume_left=this.volume_both=this.gain_hidden=1;this.node_splitter=a.createChannelSplitter(2);this.node_gain_left=a.createGain();this.node_gain_right=a.createGain();b.connect(this.node_splitter);this.node_splitter.connect(this.node_gain_left,0);this.node_gain_left.connect(c);this.node_splitter.connect(this.node_gain_right,1);this.node_gain_right.connect(d)}dc.prototype.update=function(){var a=this.connected_right*this.gain_hidden*this.volume_both*this.volume_right;
558
+ this.node_gain_left.gain.setValueAtTime(this.connected_left*this.gain_hidden*this.volume_both*this.volume_left,this.audio_context.currentTime);this.node_gain_right.gain.setValueAtTime(a,this.audio_context.currentTime)};dc.prototype.connect=function(a){var b=!a||2===a;if(b||0===a)this.connected_left=!0;if(b||1===a)this.connected_right=!0;this.update()};dc.prototype.disconnect=function(a){var b=!a||2===a;if(b||0===a)this.connected_left=!1;if(b||1===a)this.connected_right=!1;this.update()};dc.prototype.set_volume=
559
+ function(a,b){void 0===b&&(b=2);switch(b){case 0:this.volume_left=a;break;case 1:this.volume_right=a;break;case 2:this.volume_both=a;break;default:h(!1,"Mixer set volume - unknown channel: "+b);return}this.update()};dc.prototype.set_gain_hidden=function(a){this.gain_hidden=a};function cc(a,b,c){this.node_oscillator=b.createOscillator();this.node_oscillator.type="square";this.node_oscillator.frequency.setValueAtTime(440,b.currentTime);this.mixer_connection=c.add_source(this.node_oscillator,1);this.mixer_connection.disconnect();
560
+ a.register("pcspeaker-enable",function(){c.connect_source(1)},this);a.register("pcspeaker-disable",function(){c.disconnect_source(1)},this);a.register("pcspeaker-update",function(d){var e=d[1],g=0;3===d[0]&&(g=Math.min(1193181.6665999999/e,this.node_oscillator.frequency.maxValue),g=Math.max(g,0));this.node_oscillator.frequency.setValueAtTime(g,b.currentTime)},this)}cc.prototype.start=function(){this.node_oscillator.start()};function $b(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=
561
+ 48E3;b=function(){function f(m){if(0===m)return 1;m*=Math.PI;return Math.sin(m)/m}function l(){var m=Reflect.construct(AudioWorkletProcessor,[],l);m.kernel_size=3;m.queue_data=Array(1024);m.queue_start=0;m.queue_end=0;m.queue_length=0;m.queue_size=m.queue_data.length;m.queued_samples=0;m.source_buffer_previous=n;m.source_buffer_current=n;m.source_samples_per_destination=1;m.source_block_start=0;m.source_time=0;m.source_offset=0;m.port.onmessage=q=>{switch(q.data.type){case "queue":m.queue_push(q.data.value);
562
+ break;case "sampling-rate":m.source_samples_per_destination=q.data.value/sampleRate}};return m}var n=[new Float32Array(256),new Float32Array(256)];Reflect.setPrototypeOf(l.prototype,AudioWorkletProcessor.prototype);Reflect.setPrototypeOf(l,AudioWorkletProcessor);l.prototype.process=l.prototype.process=function(m,q){for(m=0;m<q[0][0].length;m++){for(var r=0,t=0,v=this.source_offset+this.kernel_size,y=this.source_offset-this.kernel_size+1;y<=v;y++){var D=this.source_block_start+y;r+=this.get_sample(D,
563
+ 0)*this.kernel(this.source_time-y);t+=this.get_sample(D,1)*this.kernel(this.source_time-y)}if(isNaN(r)||isNaN(t))r=t=0,this.dbg_log("ERROR: NaN values! Ignoring for now.");q[0][0][m]=r;q[0][1][m]=t;this.source_time+=this.source_samples_per_destination;this.source_offset=Math.floor(this.source_time)}q=this.source_offset;q+=this.kernel_size+2;this.source_time-=this.source_offset;this.source_block_start+=this.source_offset;this.source_offset=0;this.ensure_enough_data(q);return!0};l.prototype.kernel=
564
+ function(m){return f(m)*f(m/this.kernel_size)};l.prototype.get_sample=function(m,q){return 0>m?(m+=this.source_buffer_previous[0].length,this.source_buffer_previous[q][m]):this.source_buffer_current[q][m]};l.prototype.ensure_enough_data=function(m){var q=this.source_buffer_current[0].length;q-this.source_block_start<m&&(this.prepare_next_buffer(),this.source_block_start-=q)};l.prototype.prepare_next_buffer=function(){256>this.queued_samples&&this.queue_length&&this.dbg_log("Not enough samples - should not happen during midway of playback");
565
+ this.source_buffer_previous=this.source_buffer_current;this.source_buffer_current=this.queue_shift();var m=this.source_buffer_current[0].length;if(256>m){for(var q=this.queue_start,r=0;256>m&&r<this.queue_length;)m+=this.queue_data[q][0].length,q=q+1&this.queue_size-1,r++;m=Math.max(m,256);m=[new Float32Array(m),new Float32Array(m)];m[0].set(this.source_buffer_current[0]);m[1].set(this.source_buffer_current[1]);q=this.source_buffer_current[0].length;for(var t=0;t<r;t++){var v=this.queue_shift();m[0].set(v[0],
566
+ q);m[1].set(v[1],q);q+=v[0].length}this.source_buffer_current=m}this.pump()};l.prototype.pump=function(){1024>this.queued_samples/this.source_samples_per_destination&&this.port.postMessage({type:"pump"})};l.prototype.queue_push=function(m){this.queue_length<this.queue_size&&(this.queue_data[this.queue_end]=m,this.queue_end=this.queue_end+1&this.queue_size-1,this.queue_length++,this.queued_samples+=m[0].length,this.pump())};l.prototype.queue_shift=function(){if(!this.queue_length)return n;var m=this.queue_data[this.queue_start];
567
+ this.queue_data[this.queue_start]=null;this.queue_start=this.queue_start+1&this.queue_size-1;this.queue_length--;this.queued_samples-=m[0].length;return m};l.prototype.dbg_log=function(m){this.port.postMessage({type:"debug-log",value:m})};registerProcessor("dac-processor",l)}.toString();var d=b.indexOf("{")+1,e=b.lastIndexOf("}");b=b.substring(d,e);b=new Blob(["var DEBUG = true;\n"+b],{type:"application/javascript"});var g=URL.createObjectURL(b);this.node_processor=null;this.node_output=this.audio_context.createGain();
568
+ this.audio_context.audioWorklet.addModule(g).then(()=>{URL.revokeObjectURL(g);this.node_processor=new AudioWorkletNode(this.audio_context,"dac-processor",{numberOfInputs:0,numberOfOutputs:1,outputChannelCount:[2],parameterData:{},processorOptions:{}});this.node_processor.port.postMessage({type:"sampling-rate",value:this.sampling_rate});this.node_processor.port.onmessage=f=>{switch(f.data.type){case "pump":this.pump();break;case "debug-log":E("SpeakerWorkletDAC - Worklet: "+f.data.value)}};this.node_processor.connect(this.node_output)});
569
+ this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);a.register("dac-send-data",function(f){this.queue(f)},this);a.register("dac-enable",function(){this.enabled=!0},this);a.register("dac-disable",function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(f){h(0<f,"Sampling rate should be nonzero");this.sampling_rate=f;this.node_processor&&this.node_processor.port.postMessage({type:"sampling-rate",value:f})},this);this.debugger=new ec(this.audio_context,
570
+ this.node_output)}$b.prototype.queue=function(a){this.node_processor&&(this.debugger.push_queued_data(a),this.node_processor.port.postMessage({type:"queue",value:a},[a[0].buffer,a[1].buffer]))};$b.prototype.pump=function(){this.enabled&&this.bus.send("dac-request-data")};function ac(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=22050;this.buffered_time=0;this.rate_ratio=1;this.node_lowpass=this.audio_context.createBiquadFilter();this.node_lowpass.type="lowpass";this.node_output=
571
+ this.node_lowpass;this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);a.register("dac-send-data",function(d){this.queue(d)},this);a.register("dac-enable",function(){this.enabled=!0;this.pump()},this);a.register("dac-disable",function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(d){h(0<d,"Sampling rate should be nonzero");this.sampling_rate=d;this.rate_ratio=Math.ceil(8E3/d);this.node_lowpass.frequency.setValueAtTime(d/2,this.audio_context.currentTime)},
572
+ this);this.debugger=new ec(this.audio_context,this.node_output)}ac.prototype.queue=function(a){this.debugger.push_queued_data(a);var b=a[0].length,c=b/this.sampling_rate;if(1<this.rate_ratio){var d=this.audio_context.createBuffer(2,b*this.rate_ratio,this.sampling_rate*this.rate_ratio);for(var e=d.getChannelData(0),g=d.getChannelData(1),f=0,l=0;l<b;l++)for(var n=0;n<this.rate_ratio;n++,f++)e[f]=a[0][l],g[f]=a[1][l]}else d=this.audio_context.createBuffer(2,b,this.sampling_rate),d.copyToChannel?(d.copyToChannel(a[0],
573
+ 0),d.copyToChannel(a[1],1)):(d.getChannelData(0).set(a[0]),d.getChannelData(1).set(a[1]));a=this.audio_context.createBufferSource();a.buffer=d;a.connect(this.node_lowpass);a.addEventListener("ended",this.pump.bind(this));d=this.audio_context.currentTime;if(this.buffered_time<d)for(E("Speaker DAC - Creating/Recreating reserve - shouldn't occur frequently during playback"),this.buffered_time=d,d=.2-c,b=0;b<=d;)b+=c,this.buffered_time+=c,setTimeout(()=>this.pump(),1E3*b);a.start(this.buffered_time);
574
+ this.buffered_time+=c;setTimeout(()=>this.pump(),0)};ac.prototype.pump=function(){this.enabled&&(.2<this.buffered_time-this.audio_context.currentTime||this.bus.send("dac-request-data"))};function ec(a,b){this.audio_context=a;this.node_source=b;this.node_processor=null;this.node_gain=this.audio_context.createGain();this.node_gain.gain.setValueAtTime(0,this.audio_context.currentTime);this.node_gain.connect(this.audio_context.destination);this.is_active=!1;this.queued_history=[];this.output_history=
575
+ [];this.queued=[[],[]];this.output=[[],[]]}ec.prototype.start=function(a){this.is_active=!0;this.queued=[[],[]];this.output=[[],[]];this.queued_history.push(this.queued);this.output_history.push(this.output);this.node_processor=this.audio_context.createScriptProcessor(1024,2,2);this.node_processor.onaudioprocess=b=>{this.output[0].push(b.inputBuffer.getChannelData(0).slice());this.output[1].push(b.inputBuffer.getChannelData(1).slice())};this.node_source.connect(this.node_processor);this.node_processor.connect(this.node_gain);
576
+ setTimeout(()=>{this.stop()},a)};ec.prototype.stop=function(){this.is_active=!1;this.node_source.disconnect(this.node_processor);this.node_processor.disconnect();this.node_processor=null};ec.prototype.push_queued_data=function(a){this.is_active&&(this.queued[0].push(a[0].slice()),this.queued[1].push(a[1].slice()))};ec.prototype.download_txt=function(a,b){a=this.output_history[a][b].map(c=>c.join(" ")).join(" ");va(a,"dacdata.txt")};ec.prototype.download_csv=function(a){a=this.output_history[a];for(var b=
577
+ [],c=0;c<a[0].length;c++)for(var d=0;d<a[0][c].length;d++)b.push(`${a[0][c][d]},${a[1][c][d]}`);va(b.join("\n"),"dacdata.csv")};function fc(a,b){function c(l){f.bus&&f.enabled&&(f.send_char(l.which),l.preventDefault())}function d(l){var n=l.which;8===n?(f.send_char(127),l.preventDefault()):9===n&&(f.send_char(9),l.preventDefault())}function e(l){if(f.enabled){for(var n=l.clipboardData.getData("text/plain"),m=0;m<n.length;m++)f.send_char(n.charCodeAt(m));l.preventDefault()}}function g(l){l.target!==
578
+ a&&a.blur()}var f=this;this.enabled=!0;this.bus=b;this.text="";this.text_new_line=!1;this.last_update=0;this.bus.register("serial0-output-byte",function(l){l=String.fromCharCode(l);this.show_char(l)},this);this.destroy=function(){a.removeEventListener("keypress",c,!1);a.removeEventListener("keydown",d,!1);a.removeEventListener("paste",e,!1);window.removeEventListener("mousedown",g,!1)};this.init=function(){this.destroy();a.style.display="block";a.addEventListener("keypress",c,!1);a.addEventListener("keydown",
579
+ d,!1);a.addEventListener("paste",e,!1);window.addEventListener("mousedown",g,!1)};this.init();this.show_char=function(l){"\b"===l?(this.text=this.text.slice(0,-1),this.update()):"\r"!==l&&(this.text+=l,"\n"===l&&(this.text_new_line=!0),this.update())};this.update=function(){var l=Date.now(),n=l-this.last_update;16>n?void 0===this.update_timer&&(this.update_timer=setTimeout(()=>{this.update_timer=void 0;var m=Date.now();h(15<=m-this.last_update);this.last_update=m;this.render()},16-n)):(void 0!==this.update_timer&&
580
+ (clearTimeout(this.update_timer),this.update_timer=void 0),this.last_update=l,this.render())};this.render=function(){a.value=this.text;this.text_new_line&&(this.text_new_line=!1,a.scrollTop=1E9)};this.send_char=function(l){f.bus&&f.bus.send("serial0-input",l)}}function gc(a,b){this.element=a;if(window.Terminal){var c=this.term=new window.Terminal({logLevel:"off"});c.write("This is the serial console. Whatever you type or paste here will be sent to COM1");var d=c.onData(function(e){for(let g=0;g<e.length;g++)b.send("serial0-input",
581
+ e.charCodeAt(g))});b.register("serial0-output-byte",function(e){c.write(Uint8Array.of(e))},this);this.destroy=function(){d.dispose();c.dispose()}}}gc.prototype.show=function(){this.term&&this.term.open(this.element)};function hc(a,b,c){this.bus=b;this.socket=void 0;this.id=c||0;this.send_queue=[];this.url=a;this.reconnect_interval=1E4;this.last_connect_attempt=Date.now()-this.reconnect_interval;this.send_queue_limit=64;this.destroyed=!1;this.bus.register("net"+this.id+"-send",function(d){this.send(d)},
582
+ this)}hc.prototype.handle_message=function(a){this.bus&&this.bus.send("net"+this.id+"-receive",new Uint8Array(a.data))};hc.prototype.handle_close=function(){this.destroyed||(this.connect(),setTimeout(this.connect.bind(this),this.reconnect_interval))};hc.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);this.send_queue=[]};hc.prototype.handle_error=function(){};hc.prototype.destroy=function(){this.destroyed=!0;this.socket&&this.socket.close()};
583
+ hc.prototype.connect=function(){if("undefined"!==typeof WebSocket){if(this.socket){var a=this.socket.readyState;if(0===a||1===a)return}a=Date.now();if(!(this.last_connect_attempt+this.reconnect_interval>a)){this.last_connect_attempt=Date.now();try{this.socket=new WebSocket(this.url)}catch(b){console.error(b);return}this.socket.binaryType="arraybuffer";this.socket.onopen=this.handle_open.bind(this);this.socket.onmessage=this.handle_message.bind(this);this.socket.onclose=this.handle_close.bind(this);
584
+ this.socket.onerror=this.handle_error.bind(this)}}};hc.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),this.send_queue.length>2*this.send_queue_limit&&(this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};hc.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};function Y(a){"number"===typeof a.log_level&&
585
+ (ma=a.log_level);this.cpu_is_running=!1;this.cpu_exception_hook=function(){};var b=Eb.create();this.bus=b[0];this.emulator_bus=b[1];var c,d;const e=new WebAssembly.Table({element:"anyfunc",initial:1924});b={cpu_exception_hook:f=>this.cpu_exception_hook(f),run_hardware_timers:function(f,l){return c.run_hardware_timers(f,l)},cpu_event_halt:()=>{this.emulator_bus.send("cpu-event-halt")},abort:function(){h(!1)},microtick:F.microtick,get_rand_int:function(){return k.get_rand_int()},apic_acknowledge_irq:function(){return c.devices.apic.acknowledge_irq()},
586
+ stop_idling:function(){return c.stop_idling()},io_port_read8:function(f){return c.io.port_read8(f)},io_port_read16:function(f){return c.io.port_read16(f)},io_port_read32:function(f){return c.io.port_read32(f)},io_port_write8:function(f,l){c.io.port_write8(f,l)},io_port_write16:function(f,l){c.io.port_write16(f,l)},io_port_write32:function(f,l){c.io.port_write32(f,l)},mmap_read8:function(f){return c.mmap_read8(f)},mmap_read16:function(f){return c.mmap_read16(f)},mmap_read32:function(f){return c.mmap_read32(f)},
587
+ mmap_write8:function(f,l){c.mmap_write8(f,l)},mmap_write16:function(f,l){c.mmap_write16(f,l)},mmap_write32:function(f,l){c.mmap_write32(f,l)},mmap_write64:function(f,l,n){c.mmap_write64(f,l,n)},mmap_write128:function(f,l,n,m,q){c.mmap_write128(f,l,n,m,q)},log_from_wasm:function(f,l){f=k.read_sized_string_from_mem(d,f,l);E(f,2)},console_log_from_wasm:function(f,l){f=k.read_sized_string_from_mem(d,f,l);console.error(f)},dbg_trace_from_wasm:function(){E(Error().stack,2)},codegen_finalize:(f,l,n,m,q)=>
588
+ {c.codegen_finalize(f,l,n,m,q)},jit_clear_func:f=>c.jit_clear_func(f),jit_clear_all_funcs:()=>c.jit_clear_all_funcs(),__indirect_function_table:e};let g=a.wasm_fn;g||(g=f=>new Promise(l=>{let n="v86-debug.wasm",m="v86-fallback.wasm";if(a.wasm_path){n=a.wasm_path;const q=n.lastIndexOf("/");m=(-1===q?"":n.substr(0,q))+"/"+m}else"undefined"===typeof window&&"string"===typeof __dirname?(n=__dirname+"/"+n,m=__dirname+"/"+m):(n="build/"+n,m="build/"+m);k.load_file(n,{done:async q=>{try{const {instance:r}=
589
+ await WebAssembly.instantiate(q,f);this.wasm_source=q;l(r.exports)}catch(r){k.load_file(m,{done:async t=>{const {instance:v}=await WebAssembly.instantiate(t,f);this.wasm_source=t;l(v.exports)}})}},progress:q=>{this.emulator_bus.send("download-progress",{file_index:0,file_count:1,file_name:n,lengthComputable:q.lengthComputable,total:q.total,loaded:q.loaded})}})}));g({env:b}).then(f=>{d=f.memory;f.rust_init();f=this.v86=new F(this.emulator_bus,{exports:f,wasm_table:e});c=f.cpu;this.continue_init(f,
590
+ a)});this.zstd_worker=null;this.zstd_worker_request_id=0}J.exportSymbol("V86",Y);Y.prototype.continue_init=async function(a,b){function c(t,v){switch(t){case "hda":e.hda=this.disk_images.hda=v;break;case "hdb":e.hdb=this.disk_images.hdb=v;break;case "cdrom":e.cdrom=this.disk_images.cdrom=v;break;case "fda":e.fda=this.disk_images.fda=v;break;case "fdb":e.fdb=this.disk_images.fdb=v;break;case "multiboot":e.multiboot=this.disk_images.multiboot=v.buffer;break;case "bzimage":e.bzimage=this.disk_images.bzimage=
591
+ v.buffer;break;case "initrd":e.initrd=this.disk_images.initrd=v.buffer;break;case "bios":e.bios=v.buffer;break;case "vga_bios":e.vga_bios=v.buffer;break;case "initial_state":e.initial_state=v.buffer;break;case "fs9p_json":e.fs9p_json=v;break;default:h(!1,t)}}async function d(){if(e.fs9p&&e.fs9p_json)if(e.initial_state)E("Filesystem basefs ignored: Overridden by state image");else{if(e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem){const {bzimage_path:t,initrd_path:v}=this.get_bzimage_initrd_from_filesystem(e.fs9p);
592
+ E("Found bzimage: "+t+" and initrd: "+v);const [y,D]=await Promise.all([e.fs9p.read_file(v),e.fs9p.read_file(t)]);c.call(this,"initrd",new k.SyncBuffer(y.buffer));c.call(this,"bzimage",new k.SyncBuffer(D.buffer))}}else h(!b.bzimage_initrd_from_filesystem||e.initial_state,"bzimage_initrd_from_filesystem: Requires a filesystem");this.serial_adapter&&this.serial_adapter.show&&this.serial_adapter.show();this.v86.init(e);e.initial_state&&(a.restore_state(e.initial_state),e.initial_state=void 0);b.autostart&&
593
+ this.v86.run();this.emulator_bus.send("emulator-loaded")}this.bus.register("emulator-stopped",function(){this.cpu_is_running=!1;this.screen_adapter.pause()},this);this.bus.register("emulator-started",function(){this.cpu_is_running=!0;this.screen_adapter.continue()},this);var e={};this.disk_images={fda:void 0,fdb:void 0,hda:void 0,hdb:void 0,cdrom:void 0};var g=b.boot_order?b.boot_order:b.fda?801:b.hda?786:291;e.acpi=b.acpi;e.disable_jit=b.disable_jit;e.load_devices=!0;e.memory_size=b.memory_size||
594
+ 67108864;e.vga_memory_size=b.vga_memory_size||8388608;e.boot_order=g;e.fastboot=b.fastboot||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=b.uart3;e.cmdline=b.cmdline;e.preserve_mac_from_state_image=b.preserve_mac_from_state_image;e.mac_address_translation=b.mac_address_translation;e.cpuid_level=b.cpuid_level;e.virtio_balloon=b.virtio_balloon;e.virtio_console=b.virtio_console;e.virtio_net=b.virtio_net;e.screen_options=b.screen_options;if(g=b.network_relay_url||b.net_device&&
595
+ b.net_device.relay_url)"fetch"===g?this.network_adapter=new ic(this.bus,b.net_device):"inbrowser"===g?this.network_adapter=new jc(this.bus,b.net_device):g.startsWith("wisp://")||g.startsWith("wisps://")?this.network_adapter=new kc(g,this.bus,b.net_device):this.network_adapter=new hc(g,this.bus);e.net_device=b.net_device||{type:"ne2k"};g=b.screen||{};b.screen_container&&(g.container=b.screen_container);b.disable_keyboard||(this.keyboard_adapter=new Xb(this.bus));b.disable_mouse||(this.mouse_adapter=
596
+ new Yb(this.bus,g.container));this.screen_adapter=g.container?new ca(g,()=>this.v86.cpu.devices.vga&&this.v86.cpu.devices.vga.screen_fill_buffer()):new lc;e.screen=this.screen_adapter;e.screen_options=g;b.serial_container&&(this.serial_adapter=new fc(b.serial_container,this.bus));b.serial_container_xtermjs&&(this.serial_adapter=new gc(b.serial_container_xtermjs,this.bus));b.disable_speaker||(this.speaker_adapter=new Zb(this.bus));var f=[];g=(t,v)=>{if(v)if(v.get&&v.set&&v.load)f.push({name:t,loadable:v});
597
+ else{if("bios"===t||"vga_bios"===t||"initial_state"===t||"multiboot"===t||"bzimage"===t||"initrd"===t)v.async=!1;if("fda"===t||"fdb"===t)v.async=!1;v.url&&!v.async?f.push({name:t,url:v.url,size:v.size}):f.push({name:t,loadable:k.buffer_from_object(v,this.zstd_decompress_worker.bind(this))})}};b.state&&console.warn("Warning: Unknown option 'state'. Did you mean 'initial_state'?");g("bios",b.bios);g("vga_bios",b.vga_bios);g("cdrom",b.cdrom);g("hda",b.hda);g("hdb",b.hdb);g("fda",b.fda);g("fdb",b.fdb);
598
+ g("initial_state",b.initial_state);g("multiboot",b.multiboot);g("bzimage",b.bzimage);g("initrd",b.initrd);if(b.filesystem){g=b.filesystem.basefs;var l=b.filesystem.baseurl;let t=new mc;l&&(t=new nc(t,l));e.fs9p=this.fs9p=new Z(t);if(g){h(l,"Filesystem: baseurl must be specified");if("object"===typeof g){var n=g.size;g=g.url}h("string"===typeof g);f.push({name:"fs9p_json",url:g,size:n,as_json:!0})}}var m=this,q=f.length,r=function(t){if(t===q)setTimeout(d.bind(this),0);else{var v=f[t];v.loadable?(v.loadable.onload=
599
+ function(){c.call(this,v.name,v.loadable);r(t+1)}.bind(this),v.loadable.load()):k.load_file(v.url,{done:function(y){v.url.endsWith(".zst")&&"initial_state"!==v.name&&(h(v.size,"A size must be provided for compressed images"),y=this.zstd_decompress(v.size,new Uint8Array(y)));c.call(this,v.name,v.as_json?y:new k.SyncBuffer(y));r(t+1)}.bind(this),progress:function(y){200===y.target.status?m.emulator_bus.send("download-progress",{file_index:t,file_count:q,file_name:v.url,lengthComputable:y.lengthComputable,
600
+ total:y.total||v.size,loaded:y.loaded}):m.emulator_bus.send("download-error",{file_index:t,file_count:q,file_name:v.url,request:y.target})},as_json:v.as_json})}}.bind(this);r(0)};Y.prototype.zstd_decompress=function(a,b){const c=this.v86.cpu;h(!this.zstd_context);this.zstd_context=c.zstd_create_ctx(b.length);(new Uint8Array(c.wasm_memory.buffer)).set(b,c.zstd_get_src_ptr(this.zstd_context));b=c.zstd_read(this.zstd_context,a);const d=c.wasm_memory.buffer.slice(b,b+a);c.zstd_read_free(b,a);c.zstd_free_ctx(this.zstd_context);
601
+ this.zstd_context=null;return d};Y.prototype.zstd_decompress_worker=async function(a,b){if(!this.zstd_worker){const c=URL.createObjectURL(new Blob(["("+function(){let d;globalThis.onmessage=function(e){if(d){var {src:g,decompressed_size:f,id:l}=e.data;e=d.exports;var n=e.zstd_create_ctx(g.length);(new Uint8Array(e.memory.buffer)).set(g,e.zstd_get_src_ptr(n));var m=e.zstd_read(n,f),q=e.memory.buffer.slice(m,m+f);e.zstd_read_free(m,f);e.zstd_free_ctx(n);postMessage({result:q,id:l},[q])}else n=Object.fromEntries("cpu_exception_hook run_hardware_timers cpu_event_halt microtick get_rand_int apic_acknowledge_irq stop_idling io_port_read8 io_port_read16 io_port_read32 io_port_write8 io_port_write16 io_port_write32 mmap_read8 mmap_read16 mmap_read32 mmap_write8 mmap_write16 mmap_write32 mmap_write64 mmap_write128 codegen_finalize jit_clear_func jit_clear_all_funcs".split(" ").map(r=>
602
602
  [r,()=>console.error("zstd worker unexpectedly called "+r)])),n.__indirect_function_table=new WebAssembly.Table({element:"anyfunc",initial:1024}),n.abort=()=>{throw Error("zstd worker aborted");},n.log_from_wasm=n.console_log_from_wasm=(r,t)=>{console.log(String.fromCharCode(...(new Uint8Array(d.exports.memory.buffer,r,t))))},n.dbg_trace_from_wasm=()=>console.trace(),d=new WebAssembly.Instance(new WebAssembly.Module(e.data),{env:n})}}.toString()+")()"],{type:"text/javascript"}));this.zstd_worker=
603
603
  new Worker(c);URL.revokeObjectURL(c);this.zstd_worker.postMessage(this.wasm_source,[this.wasm_source])}return new Promise(c=>{const d=this.zstd_worker_request_id++,e=async g=>{g.data.id===d&&(this.zstd_worker.removeEventListener("message",e),h(a===g.data.result.byteLength),c(g.data.result))};this.zstd_worker.addEventListener("message",e);this.zstd_worker.postMessage({src:b,decompressed_size:a,id:d},[b.buffer])})};Y.prototype.get_bzimage_initrd_from_filesystem=function(a){const b=(a.read_dir("/")||
604
604
  []).map(e=>"/"+e);a=(a.read_dir("/boot/")||[]).map(e=>"/boot/"+e);let c,d;for(const e of[].concat(b,a)){const g=/old/i.test(e)||/fallback/i.test(e),f=/vmlinuz/i.test(e)||/bzimage/i.test(e),l=/initrd/i.test(e)||/initramfs/i.test(e);!f||d&&g||(d=e);!l||c&&g||(c=e)}c&&d||(console.log("Failed to find bzimage or initrd in filesystem. Files:"),console.log(b.join(" ")),console.log(a.join(" ")));return{initrd_path:c,bzimage_path:d}};Y.prototype.run=async function(){this.v86.run()};J.exportProperty(Y.prototype,