v86 0.5.353 → 0.5.355

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.
@@ -10253,6 +10253,7 @@ $VGAScreen$$module$src$vga$$.prototype.port3C0_write = function($value$jscomp$17
10253
10253
  if (this.attribute_mode !== $value$jscomp$172$$) {
10254
10254
  var $previous_mode$$ = this.attribute_mode;
10255
10255
  this.attribute_mode = $value$jscomp$172$$;
10256
+ !this.svga_enabled || this.dispi_enable_value & 1 || (this.svga_enabled = !1, this.svga_bank_offset = 0);
10256
10257
  const $is_graphical$jscomp$2$$ = 0 !== ($value$jscomp$172$$ & 1);
10257
10258
  this.svga_enabled || this.graphical_mode === $is_graphical$jscomp$2$$ || (this.graphical_mode = $is_graphical$jscomp$2$$, this.screen.set_mode(this.graphical_mode));
10258
10259
  ($previous_mode$$ ^ $value$jscomp$172$$) & 64 && this.complete_replot();
@@ -10664,8 +10665,8 @@ $VGAScreen$$module$src$vga$$.prototype.port1CF_write = function($is_graphical$js
10664
10665
  this.svga_bpp = $is_graphical$jscomp$3_value$jscomp$181$$;
10665
10666
  break;
10666
10667
  case 4:
10667
- (this.svga_enabled = 1 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 1)) && 0 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 128) && this.svga_memory.fill(0);
10668
10668
  this.dispi_enable_value = $is_graphical$jscomp$3_value$jscomp$181$$;
10669
+ !($is_graphical$jscomp$3_value$jscomp$181$$ & 1) && this.svga_enabled && this.cpu.flags[0] & 131072 || (this.svga_enabled = 1 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 1)) && 0 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 128) && this.svga_memory.fill(0);
10669
10670
  break;
10670
10671
  case 5:
10671
10672
  $dbg_log$$module$src$log$$("SVGA bank offset: " + $h$$module$src$lib$$($is_graphical$jscomp$3_value$jscomp$181$$ << 16), 256);
@@ -10686,7 +10687,7 @@ $VGAScreen$$module$src$vga$$.prototype.port1CF_write = function($is_graphical$js
10686
10687
  $dbg_assert$$module$src$log$$(4 !== this.svga_bpp, "unimplemented svga bpp: 4");
10687
10688
  $dbg_assert$$module$src$log$$(4 === this.svga_bpp || 8 === this.svga_bpp || 15 === this.svga_bpp || 16 === this.svga_bpp || 24 === this.svga_bpp || 32 === this.svga_bpp, "unexpected svga bpp: " + this.svga_bpp);
10688
10689
  this.svga_enabled ? $dbg_log$$module$src$log$$("SVGA: enabled, " + this.svga_width + "x" + this.svga_height + "x" + this.svga_bpp, 256) : $dbg_log$$module$src$log$$("SVGA: disabled", 256);
10689
- this.svga_enabled && !$was_enabled$$ && (this.svga_offset_y = this.svga_offset_x = this.svga_offset = 0, this.graphical_mode = !0, this.screen.set_mode(this.graphical_mode), this.set_size_graphical(this.svga_width, this.svga_height, this.svga_width, this.svga_height, this.svga_bpp));
10690
+ this.svga_enabled && 4 === this.dispi_index && ($was_enabled$$ || (this.svga_offset_y = this.svga_offset_x = this.svga_offset = 0), this.graphical_mode = !0, this.screen.set_mode(this.graphical_mode), this.set_size_graphical(this.svga_width, this.svga_height, this.svga_width, this.svga_height, this.svga_bpp));
10690
10691
  $was_enabled$$ && !this.svga_enabled && (this.graphical_mode = $is_graphical$jscomp$3_value$jscomp$181$$ = 0 !== (this.attribute_mode & 1), this.screen.set_mode($is_graphical$jscomp$3_value$jscomp$181$$), this.update_vga_size(), this.set_font_bitmap(!1), this.complete_redraw());
10691
10692
  this.svga_enabled || (this.svga_bank_offset = 0);
10692
10693
  this.update_layers();
@@ -10252,6 +10252,7 @@ $VGAScreen$$module$src$vga$$.prototype.port3C0_write = function($value$jscomp$17
10252
10252
  if (this.attribute_mode !== $value$jscomp$172$$) {
10253
10253
  var $previous_mode$$ = this.attribute_mode;
10254
10254
  this.attribute_mode = $value$jscomp$172$$;
10255
+ !this.svga_enabled || this.dispi_enable_value & 1 || (this.svga_enabled = !1, this.svga_bank_offset = 0);
10255
10256
  const $is_graphical$jscomp$2$$ = 0 !== ($value$jscomp$172$$ & 1);
10256
10257
  this.svga_enabled || this.graphical_mode === $is_graphical$jscomp$2$$ || (this.graphical_mode = $is_graphical$jscomp$2$$, this.screen.set_mode(this.graphical_mode));
10257
10258
  ($previous_mode$$ ^ $value$jscomp$172$$) & 64 && this.complete_replot();
@@ -10663,8 +10664,8 @@ $VGAScreen$$module$src$vga$$.prototype.port1CF_write = function($is_graphical$js
10663
10664
  this.svga_bpp = $is_graphical$jscomp$3_value$jscomp$181$$;
10664
10665
  break;
10665
10666
  case 4:
10666
- (this.svga_enabled = 1 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 1)) && 0 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 128) && this.svga_memory.fill(0);
10667
10667
  this.dispi_enable_value = $is_graphical$jscomp$3_value$jscomp$181$$;
10668
+ !($is_graphical$jscomp$3_value$jscomp$181$$ & 1) && this.svga_enabled && this.cpu.flags[0] & 131072 || (this.svga_enabled = 1 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 1)) && 0 === ($is_graphical$jscomp$3_value$jscomp$181$$ & 128) && this.svga_memory.fill(0);
10668
10669
  break;
10669
10670
  case 5:
10670
10671
  $dbg_log$$module$src$log$$("SVGA bank offset: " + $h$$module$src$lib$$($is_graphical$jscomp$3_value$jscomp$181$$ << 16), 256);
@@ -10685,7 +10686,7 @@ $VGAScreen$$module$src$vga$$.prototype.port1CF_write = function($is_graphical$js
10685
10686
  $dbg_assert$$module$src$log$$(4 !== this.svga_bpp, "unimplemented svga bpp: 4");
10686
10687
  $dbg_assert$$module$src$log$$(4 === this.svga_bpp || 8 === this.svga_bpp || 15 === this.svga_bpp || 16 === this.svga_bpp || 24 === this.svga_bpp || 32 === this.svga_bpp, "unexpected svga bpp: " + this.svga_bpp);
10687
10688
  this.svga_enabled ? $dbg_log$$module$src$log$$("SVGA: enabled, " + this.svga_width + "x" + this.svga_height + "x" + this.svga_bpp, 256) : $dbg_log$$module$src$log$$("SVGA: disabled", 256);
10688
- this.svga_enabled && !$was_enabled$$ && (this.svga_offset_y = this.svga_offset_x = this.svga_offset = 0, this.graphical_mode = !0, this.screen.set_mode(this.graphical_mode), this.set_size_graphical(this.svga_width, this.svga_height, this.svga_width, this.svga_height, this.svga_bpp));
10689
+ this.svga_enabled && 4 === this.dispi_index && ($was_enabled$$ || (this.svga_offset_y = this.svga_offset_x = this.svga_offset = 0), this.graphical_mode = !0, this.screen.set_mode(this.graphical_mode), this.set_size_graphical(this.svga_width, this.svga_height, this.svga_width, this.svga_height, this.svga_bpp));
10689
10690
  $was_enabled$$ && !this.svga_enabled && (this.graphical_mode = $is_graphical$jscomp$3_value$jscomp$181$$ = 0 !== (this.attribute_mode & 1), this.screen.set_mode($is_graphical$jscomp$3_value$jscomp$181$$), this.update_vga_size(), this.set_font_bitmap(!1), this.complete_redraw());
10690
10691
  this.svga_enabled || (this.svga_bank_offset = 0);
10691
10692
  this.update_layers();
package/build/libv86.js CHANGED
@@ -606,8 +606,8 @@ Y.prototype.update_layers=function(){this.graphical_mode||this.text_mode_redraw(
606
606
  d=Math.min(d,this.screen_height);var f=this.screen_height-d;this.layers=[];e=-e;for(var g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,
607
607
  buffer_height:f})}};Y.prototype.update_vertical_retrace=function(){this.port_3DA_value|=8;this.start_address_latched!==this.start_address&&(this.start_address_latched=this.start_address,this.update_layers())};Y.prototype.update_cursor_scanline=function(){var a=this.max_scan_line&31;const b=Math.min(a,this.cursor_scanline_start&31);a=Math.min(a,this.cursor_scanline_end&31);this.screen.update_cursor_scanline(b,a,!(this.cursor_scanline_start&32)&&b<a)};
608
608
  Y.prototype.port3C0_write=function(a){if(-1===this.attribute_controller_index)y(a),this.attribute_controller_index=a&31,y(this.attribute_controller_index),this.palette_source!==(a&32)&&(this.palette_source=a&32,this.update_layers());else{if(16>this.attribute_controller_index)y(this.attribute_controller_index),y(a),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:y(a);if(this.attribute_mode!==a){var b=
609
- this.attribute_mode;this.attribute_mode=a;const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:y(a);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:y(a);this.horizontal_panning!==a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:y(a);this.color_select!==
610
- a&&(this.color_select=a,this.complete_redraw());break;default:y(this.attribute_controller_index),y(a)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){return this.port3C0_read()|this.port3C1_read()<<8&65280};
609
+ this.attribute_mode;this.attribute_mode=a;!this.svga_enabled||this.dispi_enable_value&1||(this.svga_enabled=!1,this.svga_bank_offset=0);const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:y(a);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:y(a);this.horizontal_panning!==
610
+ a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:y(a);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:y(this.attribute_controller_index),y(a)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){return this.port3C0_read()|this.port3C1_read()<<8&65280};
611
611
  Y.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return y(this.attribute_controller_index),y(this.dac_map[this.attribute_controller_index]),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return y(this.attribute_mode),this.attribute_mode;case 18:return y(this.color_plane_enable),this.color_plane_enable;case 19:return y(this.horizontal_panning),this.horizontal_panning;case 20:return y(this.color_select),this.color_select;default:y(this.attribute_controller_index)}return 255};
612
612
  Y.prototype.port3C2_write=function(a){y(a);this.miscellaneous_output_register=a};Y.prototype.port3C4_write=function(a){this.sequencer_index=a};Y.prototype.port3C4_read=function(){return this.sequencer_index};
613
613
  Y.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:y(a);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();this.set_font_bitmap(!1);break;case 2:y(a);b=this.plane_write_bm;this.plane_write_bm=a;this.graphical_mode||!(b&4)||this.plane_write_bm&4||this.set_font_bitmap(!0);break;case 3:y(a);b=this.character_map_select;this.character_map_select=a;this.graphical_mode||b===a||this.set_font_page();break;case 4:y(a);this.sequencer_memory_mode=a;break;default:y(this.sequencer_index),
@@ -627,9 +627,10 @@ a,this.update_vga_size(),(b^a)&67&&this.complete_replot());break;case 24:y(a);th
627
627
  Y.prototype.port3D5_read=function(){y(this.index_crtc);switch(this.index_crtc){case 1:return this.horizontal_display_enable_end;case 2:return this.horizontal_blank_start;case 7:return this.vertical_display_enable_end>>7&2|this.vertical_blank_start>>5&8|this.line_compare>>4&16|this.vertical_display_enable_end>>3&64;case 8:return this.preset_row_scan;case 9:return this.max_scan_line;case 10:return this.cursor_scanline_start;case 11:return this.cursor_scanline_end;case 12:return this.start_address&255;
628
628
  case 13:return this.start_address>>8;case 14:return this.cursor_address>>8;case 15:return this.cursor_address&255;case 18:return this.vertical_display_enable_end&255;case 19:return this.offset_register;case 20:return this.underline_location_register;case 21:return this.vertical_blank_start&255;case 23:return this.crtc_mode;case 24:return this.line_compare&255}return this.index_crtc<this.crtc.length?this.crtc[this.index_crtc]:0};Y.prototype.port3D5_read16=function(){return this.port3D5_read()};
629
629
  Y.prototype.port3DA_read=function(){var a=this.port_3DA_value;this.graphical_mode?(this.port_3DA_value^=1,this.port_3DA_value&=1):(this.port_3DA_value&1&&(this.port_3DA_value^=8),this.port_3DA_value^=1);this.attribute_controller_index=-1;return a};Y.prototype.port1CE_read=function(){return this.dispi_index};Y.prototype.port1CE_write=function(a){this.dispi_index=a};
630
- Y.prototype.port1CF_write=function(a){y(this.dispi_index);y(a);const b=this.svga_enabled;switch(this.dispi_index){case 0:45248<=a&&45253>=a?this.svga_version=a:y(a);break;case 1:this.svga_width=a;2560<this.svga_width&&(this.svga_width=2560);break;case 2:this.svga_height=a;1600<this.svga_height&&(this.svga_height=1600);break;case 3:this.svga_bpp=a;break;case 4:(this.svga_enabled=1===(a&1))&&0===(a&128)&&this.svga_memory.fill(0);this.dispi_enable_value=a;break;case 5:y(a<<16);this.svga_bank_offset=
631
- a<<16;break;case 8:y(a);this.svga_offset_x!==a&&(this.svga_offset_x=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;case 9:y(a*this.svga_width);y(a);this.svga_offset_y!==a&&(this.svga_offset_y=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;default:y(this.dispi_index)}!this.svga_enabled||this.svga_width&&this.svga_height||(this.svga_enabled=!1);this.svga_enabled&&!b&&(this.svga_offset_y=this.svga_offset_x=
632
- this.svga_offset=0,this.graphical_mode=!0,this.screen.set_mode(this.graphical_mode),this.set_size_graphical(this.svga_width,this.svga_height,this.svga_width,this.svga_height,this.svga_bpp));b&&!this.svga_enabled&&(this.graphical_mode=a=0!==(this.attribute_mode&1),this.screen.set_mode(a),this.update_vga_size(),this.set_font_bitmap(!1),this.complete_redraw());this.svga_enabled||(this.svga_bank_offset=0);this.update_layers()};Y.prototype.port1CF_read=function(){y(this.dispi_index);return this.svga_register_read(this.dispi_index)};
630
+ Y.prototype.port1CF_write=function(a){y(this.dispi_index);y(a);const b=this.svga_enabled;switch(this.dispi_index){case 0:45248<=a&&45253>=a?this.svga_version=a:y(a);break;case 1:this.svga_width=a;2560<this.svga_width&&(this.svga_width=2560);break;case 2:this.svga_height=a;1600<this.svga_height&&(this.svga_height=1600);break;case 3:this.svga_bpp=a;break;case 4:this.dispi_enable_value=a;!(a&1)&&this.svga_enabled&&this.cpu.flags[0]&131072||(this.svga_enabled=1===(a&1))&&0===(a&128)&&this.svga_memory.fill(0);
631
+ break;case 5:y(a<<16);this.svga_bank_offset=a<<16;break;case 8:y(a);this.svga_offset_x!==a&&(this.svga_offset_x=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;case 9:y(a*this.svga_width);y(a);this.svga_offset_y!==a&&(this.svga_offset_y=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;default:y(this.dispi_index)}!this.svga_enabled||this.svga_width&&this.svga_height||(this.svga_enabled=!1);
632
+ this.svga_enabled&&4===this.dispi_index&&(b||(this.svga_offset_y=this.svga_offset_x=this.svga_offset=0),this.graphical_mode=!0,this.screen.set_mode(this.graphical_mode),this.set_size_graphical(this.svga_width,this.svga_height,this.svga_width,this.svga_height,this.svga_bpp));b&&!this.svga_enabled&&(this.graphical_mode=a=0!==(this.attribute_mode&1),this.screen.set_mode(a),this.update_vga_size(),this.set_font_bitmap(!1),this.complete_redraw());this.svga_enabled||(this.svga_bank_offset=0);this.update_layers()};
633
+ Y.prototype.port1CF_read=function(){y(this.dispi_index);return this.svga_register_read(this.dispi_index)};
633
634
  Y.prototype.svga_register_read=function(a){switch(a){case 0:return this.svga_version;case 1:return this.dispi_enable_value&2?2560:this.svga_width;case 2:return this.dispi_enable_value&2?1600:this.svga_height;case 3:return this.dispi_enable_value&2?32:this.svga_bpp;case 4:return this.dispi_enable_value;case 5:return this.svga_bank_offset>>>16;case 6:return this.screen_width?this.screen_width:1;case 8:return this.svga_offset_x;case 9:return this.svga_offset_y;case 10:return this.vga_memory_size/65536|
634
635
  0;default:y(this.dispi_index)}return 255};
635
636
  Y.prototype.vga_replot=function(){for(var a=this.diff_plot_min&-16,b=Math.min(this.diff_plot_max|15,524287),c=this.vga_addr_shift_count(),d=~this.crtc_mode&3,e=this.planar_mode&96,f=this.attribute_mode&64;a<=b;){var g=a>>>c;if(d){var h=a/this.virtual_width|0,l=a-this.virtual_width*h;switch(d){case 1:g=(h&1)<<13;h>>>=1;break;case 2:g=(h&1)<<14;h>>>=1;break;case 3:g=(h&3)<<13,h>>>=2}g|=(h*this.virtual_width+l>>>c)+this.start_address}h=this.plane0[g];l=this.plane1[g];var m=this.plane2[g],n=this.plane3[g];
package/build/libv86.mjs CHANGED
@@ -534,139 +534,140 @@ this.update_vertical_retrace();this.update_layers()}else this.max_scan_line&128&
534
534
  1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+this.line_compare);d=Math.min(d,this.screen_height);var f=this.screen_height-d;this.layers=[];e=-e;for(var g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+
535
535
  b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,buffer_height:f})}};Y.prototype.update_vertical_retrace=function(){this.port_3DA_value|=8;this.start_address_latched!==this.start_address&&(this.start_address_latched=this.start_address,this.update_layers())};Y.prototype.update_cursor_scanline=function(){var a=this.max_scan_line&31;const b=Math.min(a,this.cursor_scanline_start&
536
536
  31);a=Math.min(a,this.cursor_scanline_end&31);this.screen.update_cursor_scanline(b,a,!(this.cursor_scanline_start&32)&&b<a)};Y.prototype.port3C0_write=function(a){if(-1===this.attribute_controller_index)y(a),this.attribute_controller_index=a&31,y(this.attribute_controller_index),this.palette_source!==(a&32)&&(this.palette_source=a&32,this.update_layers());else{if(16>this.attribute_controller_index)y(this.attribute_controller_index),y(a),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&
537
- 64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:y(a);if(this.attribute_mode!==a){var b=this.attribute_mode;this.attribute_mode=a;const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:y(a);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:y(a);
538
- this.horizontal_panning!==a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:y(a);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:y(this.attribute_controller_index),y(a)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){return this.port3C0_read()|this.port3C1_read()<<8&65280};Y.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return y(this.attribute_controller_index),
539
- y(this.dac_map[this.attribute_controller_index]),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return y(this.attribute_mode),this.attribute_mode;case 18:return y(this.color_plane_enable),this.color_plane_enable;case 19:return y(this.horizontal_panning),this.horizontal_panning;case 20:return y(this.color_select),this.color_select;default:y(this.attribute_controller_index)}return 255};Y.prototype.port3C2_write=function(a){y(a);this.miscellaneous_output_register=
540
- a};Y.prototype.port3C4_write=function(a){this.sequencer_index=a};Y.prototype.port3C4_read=function(){return this.sequencer_index};Y.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:y(a);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();this.set_font_bitmap(!1);break;case 2:y(a);b=this.plane_write_bm;this.plane_write_bm=a;this.graphical_mode||!(b&4)||this.plane_write_bm&4||this.set_font_bitmap(!0);break;case 3:y(a);b=this.character_map_select;this.character_map_select=
541
- a;this.graphical_mode||b===a||this.set_font_page();break;case 4:y(a);this.sequencer_memory_mode=a;break;default:y(this.sequencer_index),y(a)}};Y.prototype.port3C5_read=function(){y(this.sequencer_index);switch(this.sequencer_index){case 1:return this.clocking_mode;case 2:return this.plane_write_bm;case 3:return this.character_map_select;case 4:return this.sequencer_memory_mode;case 6:return 18}return 0};Y.prototype.port3C6_write=function(a){this.dac_mask!==a&&(this.dac_mask=a,this.complete_redraw())};
542
- Y.prototype.port3C6_read=function(){return this.dac_mask};Y.prototype.port3C7_write=function(a){y(a);this.dac_color_index_read=3*a;this.dac_state&=0};Y.prototype.port3C7_read=function(){return this.dac_state};Y.prototype.port3C8_write=function(a){this.dac_color_index_write=3*a;this.dac_state|=3};Y.prototype.port3C8_read=function(){return this.dac_color_index_write/3&255};Y.prototype.port3C9_write=function(a){var b=this.dac_color_index_write/3|0,c=this.dac_color_index_write%3,d=this.vga256_palette[b];
543
- if(0===(this.dispi_enable_value&32)){a&=63;const e=a&1;a=a<<2|e<<1|e}0===c?d=d&-16711681|a<<16:1===c?d=d&-65281|a<<8:(d=d&-256|a,y(b),y(d));this.vga256_palette[b]!==d&&(this.vga256_palette[b]=d,this.complete_redraw());this.dac_color_index_write++};Y.prototype.port3C9_read=function(){var a=this.vga256_palette[this.dac_color_index_read/3|0]>>8*(2-this.dac_color_index_read%3)&255;this.dac_color_index_read++;return this.dispi_enable_value&32?a:a>>2};Y.prototype.port3CC_read=function(){return this.miscellaneous_output_register};
544
- Y.prototype.port3CE_write=function(a){this.graphics_index=a};Y.prototype.port3CE_read=function(){return this.graphics_index};Y.prototype.port3CF_write=function(a){switch(this.graphics_index){case 0:this.planar_setreset=a;y(a);break;case 1:this.planar_setreset_enable=a;y(a);break;case 2:this.color_compare=a;y(a);break;case 3:this.planar_rotate_reg=a;y(a);break;case 4:this.plane_read=a;y(a);break;case 5:var b=this.planar_mode;this.planar_mode=a;y(a);(b^a)&96&&this.complete_replot();break;case 6:y(a);
545
- this.miscellaneous_graphics_register!==a&&(this.miscellaneous_graphics_register=a,this.update_vga_size());break;case 7:this.color_dont_care=a;y(a);break;case 8:this.planar_bitmap=a;y(a);break;default:y(this.graphics_index),y(a)}};Y.prototype.port3CF_read=function(){y(this.graphics_index);switch(this.graphics_index){case 0:return this.planar_setreset;case 1:return this.planar_setreset_enable;case 2:return this.color_compare;case 3:return this.planar_rotate_reg;case 4:return this.plane_read;case 5:return this.planar_mode;
546
- case 6:return this.miscellaneous_graphics_register;case 7:return this.color_dont_care;case 8:return this.planar_bitmap}return 0};Y.prototype.port3D4_write=function(a){this.index_crtc=a};Y.prototype.port3D4_write16=function(a){this.port3D4_write(a&255);this.port3D5_write(a>>8&255)};Y.prototype.port3D4_read=function(){return this.index_crtc};Y.prototype.port3D5_write=function(a){switch(this.index_crtc){case 1:y(a);this.horizontal_display_enable_end!==a&&(this.horizontal_display_enable_end=a,this.update_vga_size());
547
- break;case 2:this.horizontal_blank_start!==a&&(this.horizontal_blank_start=a,this.update_vga_size());break;case 7:y(a);var b=this.vertical_display_enable_end;this.vertical_display_enable_end&=255;this.vertical_display_enable_end=this.vertical_display_enable_end|a<<3&512|a<<7&256;b!==this.vertical_display_enable_end&&this.update_vga_size();this.line_compare=this.line_compare&767|a<<4&256;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&767|a<<5&256;b!==this.vertical_blank_start&&
548
- this.update_vga_size();this.update_layers();break;case 8:y(a);this.preset_row_scan=a;this.update_layers();break;case 9:y(a);var c=this.max_scan_line;this.max_scan_line=a;this.line_compare=this.line_compare&511|a<<3&512;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&511|a<<4&512;((c^this.max_scan_line)&159||b!==this.vertical_blank_start)&&this.update_vga_size();this.update_cursor_scanline();this.update_layers();this.set_font_bitmap(!1);break;case 10:y(a);this.cursor_scanline_start=
549
- a;this.update_cursor_scanline();break;case 11:y(a);this.cursor_scanline_end=a;this.update_cursor_scanline();break;case 12:(this.start_address>>8&255)!==a&&(this.start_address=this.start_address&255|a<<8,this.update_layers(),~this.crtc_mode&3&&this.complete_replot());y(a);y(this.start_address,4);break;case 13:(this.start_address&255)!==a&&(this.start_address=this.start_address&65280|a,this.update_layers(),~this.crtc_mode&3&&this.complete_replot());y(a);y(this.start_address,4);break;case 14:y(a);this.cursor_address=
550
- this.cursor_address&255|a<<8;this.update_cursor();break;case 15:y(a);this.cursor_address=this.cursor_address&65280|a;this.update_cursor();break;case 18:y(a);(this.vertical_display_enable_end&255)!==a&&(this.vertical_display_enable_end=this.vertical_display_enable_end&768|a,this.update_vga_size());break;case 19:y(a);this.offset_register!==a&&(this.offset_register=a,this.update_vga_size(),~this.crtc_mode&3&&this.complete_replot());break;case 20:y(a);this.underline_location_register!==a&&(b=this.underline_location_register,
551
- this.underline_location_register=a,this.update_vga_size(),(b^a)&64&&this.complete_replot());break;case 21:y(a);(this.vertical_blank_start&255)!==a&&(this.vertical_blank_start=this.vertical_blank_start&768|a,this.update_vga_size());break;case 23:y(a);this.crtc_mode!==a&&(b=this.crtc_mode,this.crtc_mode=a,this.update_vga_size(),(b^a)&67&&this.complete_replot());break;case 24:y(a);this.line_compare=this.line_compare&768|a;this.update_layers();break;default:this.index_crtc<this.crtc.length&&(this.crtc[this.index_crtc]=
552
- a),y(this.index_crtc),y(a)}};Y.prototype.port3D5_write16=function(a){y(a,4);this.port3D5_write(a&255)};Y.prototype.port3D5_read=function(){y(this.index_crtc);switch(this.index_crtc){case 1:return this.horizontal_display_enable_end;case 2:return this.horizontal_blank_start;case 7:return this.vertical_display_enable_end>>7&2|this.vertical_blank_start>>5&8|this.line_compare>>4&16|this.vertical_display_enable_end>>3&64;case 8:return this.preset_row_scan;case 9:return this.max_scan_line;case 10:return this.cursor_scanline_start;
553
- case 11:return this.cursor_scanline_end;case 12:return this.start_address&255;case 13:return this.start_address>>8;case 14:return this.cursor_address>>8;case 15:return this.cursor_address&255;case 18:return this.vertical_display_enable_end&255;case 19:return this.offset_register;case 20:return this.underline_location_register;case 21:return this.vertical_blank_start&255;case 23:return this.crtc_mode;case 24:return this.line_compare&255}return this.index_crtc<this.crtc.length?this.crtc[this.index_crtc]:
554
- 0};Y.prototype.port3D5_read16=function(){return this.port3D5_read()};Y.prototype.port3DA_read=function(){var a=this.port_3DA_value;this.graphical_mode?(this.port_3DA_value^=1,this.port_3DA_value&=1):(this.port_3DA_value&1&&(this.port_3DA_value^=8),this.port_3DA_value^=1);this.attribute_controller_index=-1;return a};Y.prototype.port1CE_read=function(){return this.dispi_index};Y.prototype.port1CE_write=function(a){this.dispi_index=a};Y.prototype.port1CF_write=function(a){y(this.dispi_index);y(a);const b=
555
- this.svga_enabled;switch(this.dispi_index){case 0:45248<=a&&45253>=a?this.svga_version=a:y(a);break;case 1:this.svga_width=a;2560<this.svga_width&&(this.svga_width=2560);break;case 2:this.svga_height=a;1600<this.svga_height&&(this.svga_height=1600);break;case 3:this.svga_bpp=a;break;case 4:(this.svga_enabled=1===(a&1))&&0===(a&128)&&this.svga_memory.fill(0);this.dispi_enable_value=a;break;case 5:y(a<<16);this.svga_bank_offset=a<<16;break;case 8:y(a);this.svga_offset_x!==a&&(this.svga_offset_x=a,this.svga_offset=
556
- this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;case 9:y(a*this.svga_width);y(a);this.svga_offset_y!==a&&(this.svga_offset_y=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;default:y(this.dispi_index)}!this.svga_enabled||this.svga_width&&this.svga_height||(this.svga_enabled=!1);this.svga_enabled&&!b&&(this.svga_offset_y=this.svga_offset_x=this.svga_offset=0,this.graphical_mode=!0,this.screen.set_mode(this.graphical_mode),
557
- this.set_size_graphical(this.svga_width,this.svga_height,this.svga_width,this.svga_height,this.svga_bpp));b&&!this.svga_enabled&&(this.graphical_mode=a=0!==(this.attribute_mode&1),this.screen.set_mode(a),this.update_vga_size(),this.set_font_bitmap(!1),this.complete_redraw());this.svga_enabled||(this.svga_bank_offset=0);this.update_layers()};Y.prototype.port1CF_read=function(){y(this.dispi_index);return this.svga_register_read(this.dispi_index)};Y.prototype.svga_register_read=function(a){switch(a){case 0:return this.svga_version;
558
- case 1:return this.dispi_enable_value&2?2560:this.svga_width;case 2:return this.dispi_enable_value&2?1600:this.svga_height;case 3:return this.dispi_enable_value&2?32:this.svga_bpp;case 4:return this.dispi_enable_value;case 5:return this.svga_bank_offset>>>16;case 6:return this.screen_width?this.screen_width:1;case 8:return this.svga_offset_x;case 9:return this.svga_offset_y;case 10:return this.vga_memory_size/65536|0;default:y(this.dispi_index)}return 255};Y.prototype.vga_replot=function(){for(var a=
559
- this.diff_plot_min&-16,b=Math.min(this.diff_plot_max|15,524287),c=this.vga_addr_shift_count(),d=~this.crtc_mode&3,e=this.planar_mode&96,f=this.attribute_mode&64;a<=b;){var g=a>>>c;if(d){var h=a/this.virtual_width|0,l=a-this.virtual_width*h;switch(d){case 1:g=(h&1)<<13;h>>>=1;break;case 2:g=(h&1)<<14;h>>>=1;break;case 3:g=(h&3)<<13,h>>>=2}g|=(h*this.virtual_width+l>>>c)+this.start_address}h=this.plane0[g];l=this.plane1[g];var m=this.plane2[g],n=this.plane3[g];g=new Uint8Array(8);switch(e){case 0:h<<=
560
- 0;l<<=1;m<<=2;n<<=3;for(var p=7;0<=p;p--)g[7-p]=h>>p&1|l>>p&2|m>>p&4|n>>p&8;break;case 32:g[0]=h>>6&3|m>>4&12;g[1]=h>>4&3|m>>2&12;g[2]=h>>2&3|m>>0&12;g[3]=h>>0&3|m<<2&12;g[4]=l>>6&3|n>>4&12;g[5]=l>>4&3|n>>2&12;g[6]=l>>2&3|n>>0&12;g[7]=l>>0&3|n<<2&12;break;case 64:case 96:g[0]=h>>4&15,g[1]=h>>0&15,g[2]=l>>4&15,g[3]=l>>0&15,g[4]=m>>4&15,g[5]=m>>0&15,g[6]=n>>4&15,g[7]=n>>0&15}if(f)for(h=p=0;4>p;p++,a++,h+=2)this.pixel_buffer[a]=g[h]<<4|g[h+1];else for(p=0;8>p;p++,a++)this.pixel_buffer[a]=g[p]}};Y.prototype.vga_redraw=
561
- function(){var a=this.diff_addr_min,b=Math.min(this.diff_addr_max,524287);const c=new Int32Array(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,this.virtual_width*this.virtual_height);var d=255,e=0;this.attribute_mode&128&&(d&=207,e|=this.color_select<<4&48);if(this.attribute_mode&64)for(;a<=b;a++){var f=this.pixel_buffer[a]&d|e;f=this.vga256_palette[f];c[a]=f&65280|f<<16|f>>16|4278190080}else for(d&=63,e|=this.color_select<<4&192;a<=b;a++)f=this.dac_map[this.pixel_buffer[a]&this.color_plane_enable]&
562
- d|e,f=this.vga256_palette[f],c[a]=f&65280|f<<16|f>>16|4278190080};Y.prototype.screen_fill_buffer=function(){if(this.graphical_mode){if(0===this.image_data.data.byteLength){var a=new Uint8ClampedArray(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,4*this.virtual_width*this.virtual_height);this.image_data=new ImageData(a,this.virtual_width,this.virtual_height);this.update_layers()}if(this.svga_enabled){a=0;let d=this.svga_height;if(8===this.svga_bpp){const e=new Int32Array(this.cpu.wasm_memory.buffer,
563
- this.dest_buffet_offset,this.screen_width*this.screen_height),f=new Uint8Array(this.cpu.wasm_memory.buffer,this.svga_memory.byteOffset,this.vga_memory_size);for(var b=0;b<e.length;b++){var c=this.vga256_palette[f[b]];e[b]=c&65280|c<<16|c>>16|4278190080}}else this.cpu.svga_fill_pixel_buffer(this.svga_bpp,this.svga_offset),b=15===this.svga_bpp?2:this.svga_bpp/8,a=((this.cpu.svga_dirty_bitmap_min_offset[0]/b|0)-this.svga_offset)/this.svga_width|0,d=(((this.cpu.svga_dirty_bitmap_max_offset[0]/b|0)-this.svga_offset)/
564
- this.svga_width|0)+1;a<d&&(a=Math.max(a,0),d=Math.min(d,this.svga_height),this.screen.update_buffer([{image_data:this.image_data,screen_x:0,screen_y:a,buffer_x:0,buffer_y:a,buffer_width:this.svga_width,buffer_height:d-a}]))}else this.vga_replot(),this.vga_redraw(),this.screen.update_buffer(this.layers);this.reset_diffs()}this.update_vertical_retrace()};Y.prototype.set_font_bitmap=function(a){const b=this.max_scan_line&31;if(b&&!this.graphical_mode){const c=!!(this.clocking_mode&8);this.screen.set_font_bitmap(b+
565
- 1,!c&&!(this.clocking_mode&1),c,!!(this.attribute_mode&4),this.plane2,a)}};Y.prototype.set_font_page=function(){const a=[0,2,4,6,1,3,5,7],b=(this.character_map_select&12)>>2|(this.character_map_select&32)>>3,c=this.character_map_select&3|(this.character_map_select&16)>>2;this.font_page_ab_enabled=b!==c;this.screen.set_font_page(a[b],a[c]);this.complete_redraw()};const ed="SWAP_IN SWAP_OUT MAJFLT MINFLT MEMFREE MEMTOT AVAIL CACHES HTLB_PGALLOC HTLB_PGFAIL".split(" ");function fd(a,b){this.bus=b;this.zeroed=
566
- this.fp_cmd=this.actual=this.num_pages=0;this.virtio=new Lc(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:()=>{}},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 f=new Uint8Array(e.length_readable);
567
- e.get_next_blob(f);this.virtio.queues[c].push_reply(e);e=f.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 f={};for(let g=0;g<d.length_readable;g+=10){let [h,l]=J(["h","d"],e,{offset:g});f[ed[h]]=l}this.virtio.queues[c].push_reply(d);this.stats_cb&&this.stats_cb(f)}},c=>{const d=this.virtio.queues[c];for(;d.has_request();){const f=d.pop_request();
568
- if(0<f.length_readable){var e=new Uint8Array(f.length_readable);f.get_next_blob(e);[e]=J(["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<f.length_writable)for(new Uint8Array(0),e=0;e<f.write_buffers.length;++e){let g=f.write_buffers[e];this.zeroed+=g.len;this.virtio.cpu.zero_memory(g.addr_low,g.len)}this.virtio.queues[c].push_reply(f)}this.virtio.queues[c].flush_replies()}]},isr_status:{initial_port:55040},
569
- 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:()=>{}}]}})}fd.prototype.Inflate=function(a){this.num_pages+=a;this.virtio.notify_config_changes()};fd.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};fd.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=a;this.zeroed=0;this.virtio.notify_config_changes()};
570
- fd.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};fd.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};fd.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()};fd.prototype.Reset=function(){};function gd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);
571
- var g=new Uint32Array(b),h=e[497]||4,l=f[255];if(43605!==l)y(l);else if(l=f[257]|f[258]<<16,1400005704!==l)y(l);else{l=f[259];var m=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=l?g[142]:255,C=g[146],t=g[147],A=g[150],M=g[151],v=g[152];y(l);y(m);y(n);y(g[133]);y(p);y(q);y(r);y(x);y(C);y(t);y(M);y(A);y(v);e[528]=255;e[529]=m&-97|128;f[274]=56832;f[253]=65535;y(56832);d+="\x00";y(581632);g[138]=581632;for(e=0;e<d.length;e++)a[581632+e]=d.charCodeAt(e);h=512*(h+1);y(h);d=new Uint8Array(b,0,h);b=
572
- new Uint8Array(b,h);e=h=0;c&&(h=67108864,e=c.byteLength,a.set(new Uint8Array(c),h));g[134]=h;g[135]=e;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;g=a[c]=0;for(b=0;b<a.length;b++)g+=a[b];a[c]=-g;return{name:"genroms/kernel.bin",
573
- data:a}}}function R(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(Uint32Array,b,812,1);this.mem8=new Uint8Array(0);this.mem32s=new Int32Array(this.mem8.buffer);this.segment_is_null=k(Uint8Array,b,724,8);this.segment_offsets=k(Int32Array,b,736,8);this.segment_limits=k(Uint32Array,b,768,8);this.segment_access_bytes=k(Uint8Array,b,512,8);this.protected_mode=k(Int32Array,b,800,1);this.idtr_size=k(Int32Array,
574
- b,564,1);this.idtr_offset=k(Int32Array,b,568,1);this.gdtr_size=k(Int32Array,b,572,1);this.gdtr_offset=k(Int32Array,b,576,1);this.tss_size_32=k(Int32Array,b,1128,1);this.page_fault=k(Uint32Array,b,540,8);this.cr=k(Int32Array,b,580,8);this.cpl=k(Uint8Array,b,612,1);this.is_32=k(Int32Array,b,804,1);this.stack_size_32=k(Int32Array,b,808,1);this.in_hlt=k(Uint8Array,b,616,1);this.last_virt_eip=k(Int32Array,b,620,1);this.eip_phys=k(Int32Array,b,624,1);this.sysenter_cs=k(Int32Array,b,636,1);this.sysenter_esp=
575
- k(Int32Array,b,640,1);this.sysenter_eip=k(Int32Array,b,644,1);this.prefixes=k(Int32Array,b,648,1);this.flags=k(Int32Array,b,120,1);this.flags_changed=k(Int32Array,b,100,1);this.last_op_size=k(Int32Array,b,96,1);this.last_op1=k(Int32Array,b,104,1);this.last_result=k(Int32Array,b,112,1);this.current_tsc=k(Uint32Array,b,960,2);this.devices={};this.instruction_pointer=k(Int32Array,b,556,1);this.previous_ip=k(Int32Array,b,560,1);this.apic_enabled=k(Uint8Array,b,548,1);this.acpi_enabled=k(Uint8Array,b,
576
- 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(Uint32Array,b,664,1);this.reg32=k(Int32Array,b,64,8);this.fpu_st=k(Int32Array,b,1152,32);this.fpu_stack_empty=k(Uint8Array,b,816,1);this.fpu_stack_empty[0]=255;this.fpu_stack_ptr=k(Uint8Array,b,1032,1);this.fpu_stack_ptr[0]=0;this.fpu_control_word=k(Uint16Array,b,1036,1);this.fpu_control_word[0]=895;this.fpu_status_word=k(Uint16Array,
577
- b,1040,1);this.fpu_status_word[0]=0;this.fpu_ip=k(Int32Array,b,1048,1);this.fpu_ip[0]=0;this.fpu_ip_selector=k(Int32Array,b,1052,1);this.fpu_ip_selector[0]=0;this.fpu_opcode=k(Int32Array,b,1044,1);this.fpu_opcode[0]=0;this.fpu_dp=k(Int32Array,b,1056,1);this.fpu_dp[0]=0;this.fpu_dp_selector=k(Int32Array,b,1060,1);this.fpu_dp_selector[0]=0;this.reg_xmm32s=k(Int32Array,b,832,32);this.mxcsr=k(Int32Array,b,824,1);this.sreg=k(Uint16Array,b,668,8);this.dreg=k(Int32Array,b,684,8);this.reg_pdpte=k(Int32Array,
578
- b,968,8);this.svga_dirty_bitmap_min_offset=k(Uint32Array,b,716,1);this.svga_dirty_bitmap_max_offset=k(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)}R.prototype.mmap_read8=function(a){return this.memory_map_read8[a>>>17](a)};R.prototype.mmap_write8=function(a,b){this.memory_map_write8[a>>>17](a,b)};R.prototype.mmap_write16=function(a,b){var c=this.memory_map_write8[a>>>17];c(a,b&255);c(a+1|0,b>>8)};R.prototype.mmap_read32=function(a){return this.memory_map_read32[a>>>
579
- 17](a)};R.prototype.mmap_write32=function(a,b){this.memory_map_write32[a>>>17](a,b)};R.prototype.mmap_write64=function(a,b,c){var d=this.memory_map_write32[a>>>17];d(a,b);d(a+4,c)};R.prototype.mmap_write128=function(a,b,c,d,e){var f=this.memory_map_write32[a>>>17];f(a,b);f(a+4,c);f(a+8,d);f(a+12,e)};R.prototype.write_blob=function(a,b){a.length&&(this.in_mapped_range(b),this.in_mapped_range(b+a.length-1),this.jit_dirty_cache(b,b+a.length),this.mem8.set(a,b))};R.prototype.read_blob=function(a,b){b&&
580
- (this.in_mapped_range(a),this.in_mapped_range(a+b-1));return this.mem8.subarray(a,a+b)};R.prototype.clear_opstats=function(){(new Uint8Array(this.wasm_memory.buffer,32768,131072)).fill(0);this.wm.exports.profiler_init()};R.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};R.prototype.wasm_patch=function(){const a=
581
- 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=b("fpu_load_tag_word");
582
- 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.device_raise_irq=b("device_raise_irq");
583
- this.device_lower_irq=b("device_lower_irq");this.apic_timer=b("apic_timer");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=b("svga_fill_pixel_buffer");
584
- 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.get_apic_addr=b("get_apic_addr");this.get_ioapic_addr=b("get_ioapic_addr");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")};R.prototype.jit_force_generate=function(a){this.jit_force_generate_unsafe&&this.jit_force_generate_unsafe(a)};
585
- R.prototype.jit_clear_func=function(a){this.wm.wasm_table.set(a+1024,null)};R.prototype.jit_clear_all_funcs=function(){const a=this.wm.wasm_table;for(let b=0;900>b;b++)a.set(1024+b,null)};R.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];
586
- 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]=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;
587
- this.store_current_tsc();a[43]=this.current_tsc;a[45]=this.devices.virtio_9p;a[46]=this.get_state_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;this.devices.ide.secondary?a[85]=this.devices.ide:this.devices.ide.primary?.master.is_atapi?a[56]=this.devices.ide.primary:a[57]=this.devices.ide.primary;a[58]=this.devices.pit;a[59]=this.devices.net;a[60]=this.get_state_pic();
588
- a[61]=this.devices.sb16;a[62]=this.fw_value;a[63]=this.get_state_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]=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;
589
- a[81]=this.devices.uart3;a[82]=this.devices.virtio_console;a[83]=this.devices.virtio_net;a[84]=this.devices.virtio_balloon;a[86]=this.last_result;a[87]=this.fpu_status_word;a[88]=this.mxcsr;return a};R.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];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];
590
- 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};R.prototype.get_state_apic=function(){return new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)};R.prototype.get_state_ioapic=function(){return new Uint8Array(this.wasm_memory.buffer,this.get_ioapic_addr(),208)};R.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="+
591
- 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)));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]);
592
- 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]=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],
593
- a[43][1]);this.devices.virtio_9p&&this.devices.virtio_9p.set_state(a[45]);a[46]&&this.set_state_apic(a[46]);this.devices.rtc&&this.devices.rtc.set_state(a[47]);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]);if(a[56]||a[57]){var b=
594
- [[void 0,void 0],[void 0,void 0]];b[0][0]=a[56]?{is_cdrom:!0,buffer:this.devices.cdrom.buffer}:{is_cdrom:!1,buffer:this.devices.ide.primary.master.buffer};this.devices.ide=new $c(this,this.devices.ide.bus,b);this.devices.cdrom=a[56]?this.devices.ide.primary.master:void 0;this.devices.ide.primary.set_state(a[56]||a[57])}else a[85]&&this.devices.ide.set_state(a[85]);this.devices.pci&&this.devices.pci.set_state(a[48]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);
595
- 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]);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];a[63]&&this.set_state_ioapic(a[63]);
596
- 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]=a[75];void 0!==a[86]&&(this.last_result=a[86]);void 0!==a[87]&&(this.fpu_status_word=a[87]);void 0!==a[88]&&(this.mxcsr=a[88]);b=new na(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();
597
- this.jit_clear_cache()};R.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]=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]};R.prototype.set_state_apic=
598
- function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_apic_addr(),46);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[8]=a[6];b[9]=a[7];b[10]=a[8];b[11]=a[9];b[12]=a[10];b[13]=a[11];b[14]=a[12];b[15]=a[13];b.set(a[15],16);b.set(a[15],24);b.set(a[16],32);b[40]=a[17];b[41]=a[18];b[42]=a[19];b[43]=a[20];b[44]=a[21];b[45]=a[22]||65536}else(new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)).set(a)};R.prototype.set_state_ioapic=function(a){if(a instanceof
599
- Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_ioapic_addr(),52);b.set(a[0],0);b.set(a[1],24);b[48]=a[2];b[49]=a[3];b[50]=a[4];b[51]=a[5]}else(new Uint8Array(this.wasm_memory.buffer,this.get_ioapic_addr(),208)).set(a)};R.prototype.pack_memory=function(){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 na(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<<
600
- 12);return{bitmap:a,packed_memory:c}};R.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 f=0;f<c;f++)if(a.get(f)){var e=d<<12;e=b.subarray(e,e+4096);this.mem8.set(e,f<<12);d++}};R.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();
601
- this.devices.ps2&&this.devices.ps2.reset();this.load_bios()};R.prototype.reset_memory=function(){this.mem8.fill(0)};R.prototype.create_memory=function(a,b){a<b?a=b:0>(a|0)&&(a=Math.pow(2,31)-131072);a=(a-1|131071)+1|0;console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;b=this.allocate_memory(a);this.mem8=k(Uint8Array,this.wasm_memory,b,a);this.mem32s=k(Uint32Array,this.wasm_memory,b,a>>2)};R.prototype.init=function(a,b){this.create_memory(a.memory_size||67108864,
602
- 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 Da(this);this.io=c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();if(a.bzimage){const e=gd(this.mem8,a.bzimage,a.initrd,a.cmdline||"");e&&this.option_roms.push(e)}c.register_read(179,this,function(){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,
603
- this,function(){return this.fw_pointer<this.fw_value.length?this.fw_value[this.fw_pointer++]:0});c.register_write(1296,this,void 0,function(e){function f(l){return new Uint8Array(Int32Array.of(l).buffer)}function g(l){return l>>8|l<<8&65280}function h(l){return l<<24|l<<8&16711680|l>>8&65280|l>>>24}va("bios config port, index="+y(e));this.fw_pointer=0;if(0===e)this.fw_value=f(1431127377);else if(1===e)this.fw_value=f(0);else if(3===e)this.fw_value=f(this.memory_size[0]);else if(5===e)this.fw_value=
604
- f(1);else if(15===e)this.fw_value=f(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 l=new Uint8Array(e.buffer);e[0]=h(this.option_roms.length);for(let m=0;m<this.option_roms.length;m++){const {name:n,data:p}=this.option_roms[m],q=4+64*m;e[q+0>>2]=h(p.length);e[q+4>>2]=g(49152+m);for(let r=0;r<n.length;r++)l[q+8+r]=n.charCodeAt(r)}this.fw_value=l}else 32768<=e&&49152>e?this.fw_value=f(0):49152<=e&&e-49152<this.option_roms.length?
605
- this.fw_value=this.option_roms[e-49152].data:(va("Warning: Unimplemented fw index: "+y(e)),this.fw_value=f(0))});this.devices={};a.load_devices&&(this.devices.pci=new Gc(this),this.acpi_enabled[0]&&(this.devices.acpi=new Ec(this)),this.devices.rtc=new hb(this),this.fill_cmos(this.devices.rtc,a),this.devices.dma=new B(this),this.devices.vga=new Y(this,b,a.screen,a.vga_memory_size||8388608),this.devices.ps2=new Mc(this,b),this.devices.uart0=new Fc(this,1016,b),a.uart1&&(this.devices.uart1=new Fc(this,
606
- 760,b)),a.uart2&&(this.devices.uart2=new Fc(this,1E3,b)),a.uart3&&(this.devices.uart3=new Fc(this,744,b)),this.devices.fdc=new W(this,a.fda,a.fdb),c=[[void 0,void 0],[void 0,void 0]],a.hda&&(c[0][0]={buffer:a.hda},c[0][1]={buffer:a.hdb}),c[1][0]={is_cdrom:!0,buffer:a.cdrom},this.devices.ide=new $c(this,b,c),this.devices.cdrom=this.devices.ide.secondary.master,this.devices.pit=new ib(this,b),"ne2k"===a.net_device.type?this.devices.net=new Jc(this,b,a.preserve_mac_from_state_image,a.mac_address_translation):
607
- "virtio"===a.net_device.type&&(this.devices.virtio_net=new bd(this,b,a.preserve_mac_from_state_image,a.net_device.mtu)),a.fs9p?this.devices.virtio_9p=new hd(a.fs9p,this,b):a.handle9p?this.devices.virtio_9p=new id(a.handle9p,this):a.proxy9p&&(this.devices.virtio_9p=new jd(a.proxy9p,this)),a.virtio_console&&(this.devices.virtio_console=new Kc(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=new fd(this,b)),this.devices.sb16=new D(this,b));a.multiboot&&(a=this.load_multiboot_option_rom(a.multiboot,
608
- a.initrd,a.cmdline))&&(this.bios.main?this.option_roms.push(a):this.reg32[0]=this.io.port_read32(244));this.debug_init()};R.prototype.load_multiboot=function(a){this.load_multiboot_option_rom(a,void 0,"")&&(this.reg32[0]=this.io.port_read32(244))};R.prototype.load_multiboot_option_rom=function(a,b,c){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 f=d[e+4>>2];if(464367618+
609
- f+d[e+8>>2]|0)continue}else continue;va("Multiboot magic found, flags: "+y(f>>>0,8),2);var g=this;this.io.register_read(244,this,function(){return 0},function(){return 0},function(){var n,p=31860;let q=0;if(c){q|=4;g.write32(31760,p);c+="\x00";var r=(new TextEncoder).encode(c);g.write_blob(r,p);p+=r.length}if(f&2){q|=64;r=0;g.write32(31788,0);g.write32(31792,p);var x=0;var C=!1;for(n=0;4294967296>n;n+=131072)C&&void 0!==g.memory_map_read8[n>>>17]?(g.write32(p,20),g.write32(p+4,x),g.write32(p+8,0),
610
- g.write32(p+12,n-x),g.write32(p+16,0),g.write32(p+20,1),p+=24,r+=24,C=!1):C||void 0!==g.memory_map_read8[n>>>17]||(x=n,C=!0);g.write32(31788,r)}x=r=0;if(f&65536){n=d[e+12>>2];r=d[e+16>>2];var t=d[e+20>>2];x=d[e+24>>2];C=d[e+28>>2];y(n,8);y(r,8);y(t,8);y(x,8);y(C,8);n=new Uint8Array(a,e-(n-r),0===t?void 0:t-r);g.write_blob(n,r);r=C|0;x=Math.max(t,x)}else if(1179403647===d[0]){C=new DataView(a);const [A,M]=Uc(C,Rc);console.assert(52===M);console.assert(1179403647===A.magic,"Bad magic");console.assert(1===
611
- A.class,"Unimplemented: 64 bit elf");console.assert(1===A.data,"Unimplemented: big endian");console.assert(1===A.version0,"Bad version0");console.assert(2===A.type,"Unimplemented type");console.assert(1===A.version1,"Bad version1");console.assert(52===A.ehsize,"Bad header size");console.assert(32===A.phentsize,"Bad program header size");console.assert(40===A.shentsize,"Bad section header size");[r]=Vc(new DataView(C.buffer,C.byteOffset+A.phoff,A.phentsize*A.phnum),Sc,A.phnum);Vc(new DataView(C.buffer,
612
- C.byteOffset+A.shoff,A.shentsize*A.shnum),Tc,A.shnum);C=A;n=r;r=C.entry;for(t of n)0!==t.type&&(1===t.type?t.paddr+t.memsz<g.memory_size[0]?(t.filesz&&(n=new Uint8Array(a,t.offset,t.filesz),g.write_blob(n,t.paddr)),x=Math.max(x,t.paddr+t.memsz),r===C.entry&&t.vaddr<=r&&t.vaddr+t.memsz>r&&(r=r-t.vaddr+t.paddr)):y(t.paddr):2===t.type||3===t.type||4===t.type||6===t.type||7===t.type||1685382480===t.type||1685382481===t.type||1685382482===t.type||1685382483===t.type||y(t.type))}b&&(q|=8,g.write32(31764,
613
- 1),g.write32(31768,p),t=x,0!==(t&4095)&&(t=(t&-4096)+4096),x=t+b.byteLength,g.write32(p,t),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,0),g.write_blob(new Uint8Array(b),t));g.write32(31744,q);g.reg32[3]=31744;g.cr[0]=1;g.protected_mode[0]=1;g.flags[0]=2;g.is_32[0]=1;g.stack_size_32[0]=1;for(p=0;6>p;p++)g.segment_is_null[p]=0,g.segment_offsets[p]=0,g.segment_limits[p]=4294967295,g.sreg[p]=45058;g.instruction_pointer[0]=g.get_seg_cs()+r|0;g.update_state_flags();g.dump_state();g.dump_regs_short();
614
- return 732803074});this.io.register_write_consecutive(244,this,function(n){console.log("Test exited with code "+y(n,2));throw"HALT";},function(){},function(){},function(){});for(let n=0;15>=n;n++){function p(q){y(n);y(q,2);q?this.device_raise_irq(n):this.device_lower_irq(n)}this.io.register_write(8192+n,this,p,p,p)}const l=new Uint8Array(512);(new Uint16Array(l.buffer))[0]=43605;l[2]=1;var h=3;l[h++]=102;l[h++]=229;l[h++]=244;let m=l[h]=0;for(let n=0;n<l.length;n++)m+=l[n];l[h]=-m;return{name:"genroms/multiboot.bin",
615
- data:l}}};R.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,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,
616
- 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)};R.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){var c=new Uint8Array(a);this.write_blob(c,1048576-a.byteLength);if(b){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(){})}this.io.mmap_register(4293918720,1048576,function(e){return this.mem8[e&1048575]}.bind(this),
617
- function(e,f){this.mem8[e&1048575]=f}.bind(this))}};R.prototype.codegen_finalize=function(a,b,c,d,e){const f=new Uint8Array(this.wasm_memory.buffer,d>>>0,e>>>0);WebAssembly.instantiate(f,{e:this.jit_imports}).then(g=>{this.wm.wasm_table.set(a+1024,g.instance.exports.f);this.codegen_finalize_finished(a,b,c);this.test_hook_did_finalize_wasm&&this.test_hook_did_finalize_wasm(f)})};R.prototype.log_uncompiled_code=function(){};R.prototype.dump_function_code=function(){};R.prototype.run_hardware_timers=
618
- function(a,b){const c=this.devices.pit.timer(b,!1),d=this.devices.rtc.timer(b,!1);let e=100,f=100;a&&(e=this.devices.acpi.timer(b),f=this.apic_timer(b));return Math.min(c,d,e,f)};R.prototype.debug_init=function(){};R.prototype.dump_stack=function(){};R.prototype.debug_get_state=function(){};R.prototype.dump_state=function(){};R.prototype.get_regs_short=function(){};R.prototype.dump_regs_short=function(){};R.prototype.dump_gdt_ldt=function(){};R.prototype.dump_idt=function(){};R.prototype.dump_page_structures=
619
- function(){if(this.cr[4]&32)for(var a=0;4>a;a++){var b=this.read32s(this.cr[3]+8*a);b&1&&this.dump_page_directory(b&4294963200,!0,a<<30)}else this.dump_page_directory(this.cr[3],!1,0)};R.prototype.dump_page_directory=function(){};R.prototype.get_memory_dump=function(){};R.prototype.memory_hex_dump=function(){};R.prototype.used_memory_dump=function(){};R.prototype.debug_interrupt=function(){};R.prototype.debug_dump_code=function(){};R.prototype.dump_wasm=function(){};function Lc(a,b){this.cpu=a;this.pci=
620
- a.devices.pci;this.device_id=b.device_id;this.pci_space=[244,26,b.device_id&255,b.device_id>>8,7,5,16,0,1,0,2,0,0,0,0,0,1,168,0,0,0,16,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,b.subsystem_device_id&255,b.subsystem_device_id>>8,0,0,0,0,64,0,0,0,0,0,0,0,0,1,0,0];this.pci_space=this.pci_space.concat(Array(256-this.pci_space.length).fill(0));this.pci_id=b.pci_id;this.pci_bars=[];this.name=b.name;this.driver_feature_select=this.device_feature_select=0;this.device_feature=new Uint32Array(4);
621
- this.driver_feature=new Uint32Array(4);for(var c of b.common.features)this.device_feature[c>>>5]|=1<<(c&31),this.driver_feature[c>>>5]|=1<<(c&31);b.common.features.includes(32);this.features_ok=!0;this.device_status=0;this.config_has_changed=!1;this.config_generation=0;this.queues=[];for(const d of b.common.queues)this.queues.push(new Z(a,this,d));this.queue_select=0;this.queue_selected=this.queues[0];this.isr_status=0;c=[];c.push(this.create_common_capability(b.common));c.push(this.create_notification_capability(b.notification));
622
- c.push(this.create_isr_capability(b.isr_status));b.device_specific&&c.push(this.create_device_specific_capability(b.device_specific));this.init_capabilities(c);a.devices.pci.register_device(this);this.reset()}Lc.prototype.create_common_capability=function(a){return{type:1,bar:0,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:4,name:"device_feature_select",read:()=>this.device_feature_select,write:b=>{this.device_feature_select=b}},{bytes:4,name:"device_feature",read:()=>
623
- this.device_feature[this.device_feature_select]||0,write:()=>{}},{bytes:4,name:"driver_feature_select",read:()=>this.driver_feature_select,write:b=>{this.driver_feature_select=b}},{bytes:4,name:"driver_feature",read:()=>this.driver_feature[this.driver_feature_select]||0,write:b=>{const c=this.device_feature[this.driver_feature_select];this.driver_feature_select<this.driver_feature.length&&(this.driver_feature[this.driver_feature_select]=b&c);this.features_ok=this.features_ok&&!(b&~c)}},{bytes:2,name:"msix_config",
624
- read:()=>65535,write:()=>{}},{bytes:2,name:"num_queues",read:()=>this.queues.length,write:()=>{}},{bytes:1,name:"device_status",read:()=>this.device_status,write:b=>{0===b&&this.reset();b&~this.device_status&4&&this.device_status&64&&this.notify_config_changes();this.features_ok||(b&=-9);this.device_status=b;if(b&~this.device_status&4)a.on_driver_ok()}},{bytes:1,name:"config_generation",read:()=>this.config_generation,write:()=>{}},{bytes:2,name:"queue_select",read:()=>this.queue_select,write:b=>
625
- {this.queue_select=b;this.queue_selected=this.queue_select<this.queues.length?this.queues[this.queue_select]:null}},{bytes:2,name:"queue_size",read:()=>this.queue_selected?this.queue_selected.size:0,write:b=>{this.queue_selected&&(b&b-1&&(b=1<<da(b-1)+1),b>this.queue_selected.size_supported&&(b=this.queue_selected.size_supported),this.queue_selected.set_size(b))}},{bytes:2,name:"queue_msix_vector",read:()=>65535,write:()=>{}},{bytes:2,name:"queue_enable",read:()=>this.queue_selected?this.queue_selected.enabled|
626
- 0:0,write:b=>{this.queue_selected&&1===b&&this.queue_selected.is_configured()&&this.queue_selected.enable()}},{bytes:2,name:"queue_notify_off",read:()=>this.queue_selected?this.queue_selected.notify_offset:0,write:()=>{}},{bytes:4,name:"queue_desc (low dword)",read:()=>this.queue_selected?this.queue_selected.desc_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.desc_addr=b)}},{bytes:4,name:"queue_desc (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_avail (low dword)",read:()=>
627
- this.queue_selected?this.queue_selected.avail_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.avail_addr=b)}},{bytes:4,name:"queue_avail (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_used (low dword)",read:()=>this.queue_selected?this.queue_selected.used_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.used_addr=b)}},{bytes:4,name:"queue_used (high dword)",read:()=>0,write:()=>{}}]}};Lc.prototype.create_notification_capability=function(a){const b=[];let c;c=a.single_handler?
628
- 0:2;for(const [d,e]of a.handlers.entries())b.push({bytes:2,name:"notify"+d,read:()=>65535,write:e||(()=>{})});return{type:2,bar:1,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array([c&255,c>>8&255,c>>16&255,c>>24]),struct:b}};Lc.prototype.create_isr_capability=function(a){return{type:3,bar:2,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:1,name:"isr_status",read:()=>{const b=this.isr_status;this.lower_irq();return b},write:()=>{}}]}};Lc.prototype.create_device_specific_capability=
629
- function(a){return{type:4,bar:3,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:a.struct}};Lc.prototype.init_capabilities=function(a){let b=this.pci_space[52]=64;var c=b;for(const e of a){a=16+e.extra.length;c=b;b=c+a;var d=e.struct.reduce((f,g)=>f+g.bytes,0);d+=e.offset;d=16>d?16:1<<da(d-1)+1;this.pci_bars[e.bar]={size:d};this.pci_space[c]=9;this.pci_space[c+1]=b;this.pci_space[c+2]=a;this.pci_space[c+3]=e.type;this.pci_space[c+4]=e.bar;this.pci_space[c+5]=0;this.pci_space[c+
630
- 6]=0;this.pci_space[c+7]=0;this.pci_space[c+8]=e.offset&255;this.pci_space[c+9]=e.offset>>>8&255;this.pci_space[c+10]=e.offset>>>16&255;this.pci_space[c+11]=e.offset>>>24;this.pci_space[c+12]=d&255;this.pci_space[c+13]=d>>>8&255;this.pci_space[c+14]=d>>>16&255;this.pci_space[c+15]=d>>>24;for(const [f,g]of e.extra.entries())this.pci_space[c+16+f]=g;c=16+4*e.bar;this.pci_space[c]=e.port&254|!e.use_mmio;this.pci_space[c+1]=e.port>>>8&255;this.pci_space[c+2]=e.port>>>16&255;this.pci_space[c+3]=e.port>>>
631
- 24&255;c=e.port+e.offset;for(const f of e.struct){let g=f.read;a=f.write;if(!e.use_mmio){d=function(m){return g(m&-2)>>((m&1)<<3)&255};const h=function(m){return g(m&-4)>>((m&3)<<3)&255},l=function(m){return g(m)};switch(f.bytes){case 4:this.cpu.io.register_read(c,this,h,void 0,g);this.cpu.io.register_read(c+1,this,h);this.cpu.io.register_read(c+2,this,h);this.cpu.io.register_read(c+3,this,h);this.cpu.io.register_write(c,this,void 0,void 0,a);break;case 2:this.cpu.io.register_read(c,this,d,g,l);this.cpu.io.register_read(c+
632
- 1,this,d);this.cpu.io.register_write(c,this,void 0,a);break;case 1:this.cpu.io.register_read(c,this,g),this.cpu.io.register_write(c,this,a)}}c+=f.bytes}}this.pci_space[b]=9;this.pci_space[b+1]=0;this.pci_space[b+2]=20;this.pci_space[b+3]=5;this.pci_space[b+4]=0;this.pci_space[b+5]=0;this.pci_space[b+6]=0;this.pci_space[b+7]=0;this.pci_space[b+8]=0;this.pci_space[b+9]=0;this.pci_space[b+10]=0;this.pci_space[b+11]=0;this.pci_space[b+12]=0;this.pci_space[b+13]=0;this.pci_space[b+14]=0;this.pci_space[b+
633
- 15]=0;this.pci_space[b+16]=0;this.pci_space[b+17]=0;this.pci_space[b+18]=0;this.pci_space[b+19]=0};Lc.prototype.get_state=function(){let a=[];a[0]=this.device_feature_select;a[1]=this.driver_feature_select;a[2]=this.device_feature;a[3]=this.driver_feature;a[4]=this.features_ok;a[5]=this.device_status;a[6]=this.config_has_changed;a[7]=this.config_generation;a[8]=this.isr_status;a[9]=this.queue_select;return a=a.concat(this.queues)};Lc.prototype.set_state=function(a){this.device_feature_select=a[0];
634
- this.driver_feature_select=a[1];this.device_feature=a[2];this.driver_feature=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};Lc.prototype.reset=function(){this.driver_feature_select=this.device_feature_select=0;this.driver_feature.set(this.device_feature);this.features_ok=
635
- !0;this.queue_select=this.device_status=0;this.queue_selected=this.queues[0];for(const a of this.queues)a.reset();this.config_has_changed=!1;this.config_generation=0;this.lower_irq()};Lc.prototype.notify_config_changes=function(){this.config_has_changed=!0;this.device_status&4&&this.raise_irq(2)};Lc.prototype.update_config_generation=function(){this.config_has_changed&&(this.config_generation++,this.config_generation&=255,this.config_has_changed=!1)};Lc.prototype.is_feature_negotiated=function(a){return 0<
636
- (this.driver_feature[a>>>5]&1<<(a&31))};Lc.prototype.needs_reset=function(){this.device_status|=64;this.device_status&4&&this.notify_config_changes()};Lc.prototype.raise_irq=function(a){y(a);this.isr_status|=a;this.pci.raise_irq(this.pci_id)};Lc.prototype.lower_irq=function(){this.isr_status=0;this.pci.lower_irq(this.pci_id)};function Z(a,b,c){this.cpu=a;this.virtio=b;this.size_supported=this.size=c.size_supported;this.mask=this.size-1;this.enabled=!1;this.notify_offset=c.notify_offset;this.num_staged_replies=
637
- this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.reset()}Z.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};Z.prototype.set_state=function(a){this.size=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=
638
- a[6];this.used_addr=a[7];this.num_staged_replies=a[8];this.mask=this.size-1;this.fix_wrapping=1!==a[9]};Z.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)};Z.prototype.is_configured=function(){return this.desc_addr&&this.avail_addr&&this.used_addr};Z.prototype.enable=function(){this.is_configured();this.enabled=!0};Z.prototype.set_size=function(a){this.size=a;this.mask=a-1};Z.prototype.count_requests=
639
- function(){this.fix_wrapping&&(this.fix_wrapping=!1,this.avail_last_idx=(this.avail_get_idx()&~this.mask)+(this.avail_last_idx&this.mask));return this.avail_get_idx()-this.avail_last_idx&65535};Z.prototype.has_request=function(){return 0!==this.count_requests()};Z.prototype.pop_request=function(){this.has_request();var a=this.avail_get_entry(this.avail_last_idx);a=new kd(this,a);this.avail_last_idx=this.avail_last_idx+1&65535;return a};Z.prototype.push_reply=function(a){const b=this.used_get_idx()+
640
- this.num_staged_replies&this.mask;this.used_set_entry(b,a.head_idx,a.length_written);this.num_staged_replies++};Z.prototype.flush_replies=function(){if(0!==this.num_staged_replies){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)}};Z.prototype.notify_me_after=function(a){a=this.avail_get_idx()+a&65535;
641
- this.used_set_avail_event(a)};Z.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)}};Z.prototype.avail_get_flags=function(){return this.cpu.read16(this.avail_addr)};Z.prototype.avail_get_idx=function(){return this.cpu.read16(this.avail_addr+2)};Z.prototype.avail_get_entry=function(a){return this.cpu.read16(this.avail_addr+4+2*(a&this.mask))};
642
- Z.prototype.avail_get_used_event=function(){return this.cpu.read16(this.avail_addr+4+2*this.size)};Z.prototype.used_get_flags=function(){return this.cpu.read16(this.used_addr)};Z.prototype.used_set_flags=function(a){this.cpu.write16(this.used_addr,a)};Z.prototype.used_get_idx=function(){return this.cpu.read16(this.used_addr+2)};Z.prototype.used_set_idx=function(a){this.cpu.write16(this.used_addr+2,a)};Z.prototype.used_set_entry=function(a,b,c){this.cpu.write32(this.used_addr+4+8*a,b);this.cpu.write32(this.used_addr+
643
- 8+8*a,c)};Z.prototype.used_set_avail_event=function(a){this.cpu.write16(this.used_addr+4+8*this.size,a)};function kd(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,f=!1;const g=this.virtio.is_feature_negotiated(28);do{const h=a.get_descriptor(c,b);y(h.addr_high,
644
- 8);y(h.addr_low,8);y(h.len,8);y(h.flags,4);y(h.next,4);if(g&&h.flags&4)c=h.addr_low,d=b=0,e=h.len/16;else{if(h.flags&2)f=!0,this.write_buffers.push(h),this.length_writable+=h.len;else{if(f)break;this.read_buffers.push(h);this.length_readable+=h.len}d++;if(d>e)break;if(h.flags&1)b=h.next;else break}}while(1)}kd.prototype.get_next_blob=function(a){let b=0,c=a.length;for(;c&&this.read_buffer_idx!==this.read_buffers.length;){var d=this.read_buffers[this.read_buffer_idx];const e=d.addr_low+this.read_buffer_offset;
645
- 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};kd.prototype.set_next_blob=function(a){let b=0,c=a.length;for(;c&&this.write_buffer_idx!==this.write_buffers.length;){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=
646
- 0);this.cpu.write_blob(a.subarray(b,b+d),e);b+=d;c-=d}this.length_written+=b;return b};function ld(a,b,c,d){const e=new Lc(a,{name:"virtio-9p",pci_id:48,device_id:4169,subsystem_device_id:9,common:{initial_port:43008,queues:[{size_supported:32,notify_offset:0}],features:[0,32,29,28],on_driver_ok:()=>{}},notification:{initial_port:43264,single_handler:!1,handlers:[f=>{if(0===f){for(f=e.queues[0];f.has_request();){const g=f.pop_request();d(g)}f.notify_me_after(0)}}]},isr_status:{initial_port:42752},
647
- device_specific:{initial_port:42496,struct:[{bytes:2,name:"mount tag length",read:()=>b,write:()=>{}}].concat(Array.from(Array(254).keys()).map(f=>({bytes:1,name:"mount tag name "+f,read:()=>c[f]||0,write:()=>{}})))}});return e}function hd(a,b,c){this.fs=a;this.bus=c;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,this.ReceiveRequest.bind(this));this.virtqueue=this.virtio.queues[0];
648
- this.VERSION="9P2000.L";this.msize=this.BLOCKSIZE=8192;this.replybuffer=new Uint8Array(2*this.msize);this.replybuffersize=0;this.fids=[]}hd.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.VERSION;a[4]=this.BLOCKSIZE;a[5]=this.msize;a[6]=this.replybuffer;a[7]=this.replybuffersize;a[8]=this.fids.map(function(b){return[b.inodeid,b.type,b.uid,b.dbg_name]});a[9]=this.fs;return a};hd.prototype.set_state=function(a){this.configspace_tagname=
649
- a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.VERSION=a[3];this.BLOCKSIZE=a[4];this.msize=a[5];this.replybuffer=a[6];this.replybuffersize=a[7];this.fids=a[8].map(function(b){return{inodeid:b[0],type:b[1],uid:b[2],dbg_name:b[3]}});this.fs.set_state(a[9])};hd.prototype.Createfid=function(a,b,c,d){return{inodeid:a,type:b,uid:c,dbg_name:d}};hd.prototype.update_dbg_name=function(a,b){for(const c of this.fids)c.inodeid===a&&(c.dbg_name=b)};hd.prototype.reset=
650
- function(){this.fids=[];this.virtio.reset()};hd.prototype.BuildReply=function(a,b,c){I(["w","b","h"],[c+7,a+1,b],this.replybuffer,0);this.replybuffersize=c+7};hd.prototype.SendError=function(a,b,c){b=I(["w"],[c],this.replybuffer,7);this.BuildReply(6,a,b)};hd.prototype.SendReply=function(a){a.set_next_blob(this.replybuffer.subarray(0,this.replybuffersize));this.virtqueue.push_reply(a);this.virtqueue.flush_replies()};hd.prototype.ReceiveRequest=async function(a){var b=new Uint8Array(a.length_readable);
651
- a.get_next_blob(b);var c={offset:0},d=J(["w","b","h"],b,c),e=d[1];d=d[2];switch(e){case 8:var f=this.fs.GetTotalSize();var g=this.fs.GetSpace(),h=[16914839];h[1]=this.BLOCKSIZE;h[2]=Math.floor(g/h[1]);h[3]=h[2]-Math.floor(f/h[1]);h[4]=h[2]-Math.floor(f/h[1]);h[5]=this.fs.CountUsedInodes();h[6]=this.fs.CountFreeInodes();h[7]=0;h[8]=256;f=I("wwddddddw".split(""),h,this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 112:case 12:h=J(["w","w"],b,c);f=h[0];var l=h[1];b=this.fids[f].inodeid;
652
- c=this.fs.GetInode(b);await this.fs.OpenInode(b,l);h=[];h[0]=c.qid;h[1]=this.msize-24;I(["Q","w"],h,this.replybuffer,7);this.BuildReply(e,d,17);this.SendReply(a);break;case 70:h=J(["w","w","s"],b,c);b=h[0];f=h[1];g=h[2];f=this.fs.Link(this.fids[b].inodeid,this.fids[f].inodeid,g);if(0>f){this.SendError(d,-1===f?"Operation not permitted":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,d,0);this.SendReply(a);break;case 16:h=J(["w","s","s","w"],b,c);f=h[0];g=h[1];var m=h[3];b=this.fs.CreateSymlink(g,
653
- this.fids[f].inodeid,h[2]);c=this.fs.GetInode(b);c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 18:h=J("wswwww".split(""),b,c);f=h[0];g=h[1];l=h[2];b=h[3];c=h[4];m=h[5];b=this.fs.CreateNode(g,this.fids[f].inodeid,b,c);c=this.fs.GetInode(b);c.mode=l;c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 22:h=J(["w"],b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);
654
- f=I(["s"],[c.symlink],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 72:h=J(["w","s","w","w"],b,c);f=h[0];g=h[1];l=h[2];m=h[3];b=this.fs.CreateDirectory(g,this.fids[f].inodeid);c=this.fs.GetInode(b);c.mode=l|16384;c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 14:h=J(["w","s","w","w","w"],b,c);f=h[0];g=h[1];l=h[3];m=h[4];this.bus.send("9p-create",[g,this.fids[f].inodeid]);b=this.fs.CreateFile(g,this.fids[f].inodeid);
655
- this.fids[f].inodeid=b;this.fids[f].type=1;this.fids[f].dbg_name=g;c=this.fs.GetInode(b);c.uid=this.fids[f].uid;c.gid=m;c.mode=l|32768;I(["Q","w"],[c.qid,this.msize-24],this.replybuffer,7);this.BuildReply(e,d,17);this.SendReply(a);break;case 52:h=J("wbwddws".split(""),b,c);f=h[0];g=h[2];b=0===h[4]?Infinity:h[4];h=this.fs.DescribeLock(h[1],h[3],b,h[5],h[6]);f=this.fs.Lock(this.fids[f].inodeid,h,g);I(["b"],[f],this.replybuffer,7);this.BuildReply(e,d,1);this.SendReply(a);break;case 54:h=J("wbddws".split(""),
656
- b,c);f=h[0];b=0===h[3]?Infinity:h[3];h=this.fs.DescribeLock(h[1],h[2],b,h[4],h[5]);f=this.fs.GetLock(this.fids[f].inodeid,h);f||(f=h,f.type=2);f=I(["b","d","d","w","s"],[f.type,f.start,Infinity===f.length?0:f.length,f.proc_id,f.client_id],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 24:h=J(["w","d"],b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);if(!c||4===c.status){this.SendError(d,"No such file or directory",2);this.SendReply(a);break}h[0]=h[1];h[1]=c.qid;h[2]=c.mode;
657
- h[3]=c.uid;h[4]=c.gid;h[5]=c.nlinks;h[6]=c.major<<8|c.minor;h[7]=c.size;h[8]=this.BLOCKSIZE;h[9]=Math.floor(c.size/512+1);h[10]=c.atime;h[11]=0;h[12]=c.mtime;h[13]=0;h[14]=c.ctime;h[15]=0;h[16]=0;h[17]=0;h[18]=0;h[19]=0;I("dQwwwddddddddddddddd".split(""),h,this.replybuffer,7);this.BuildReply(e,d,153);this.SendReply(a);break;case 26:h=J("wwwwwddddd".split(""),b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);h[1]&1&&(c.mode=h[2]);h[1]&2&&(c.uid=h[3]);h[1]&4&&(c.gid=h[4]);h[1]&16&&(c.atime=Math.floor((new Date).getTime()/
658
- 1E3));h[1]&32&&(c.mtime=Math.floor((new Date).getTime()/1E3));h[1]&64&&(c.ctime=Math.floor((new Date).getTime()/1E3));h[1]&128&&(c.atime=h[6]);h[1]&256&&(c.mtime=h[8]);h[1]&8&&await this.fs.ChangeSize(this.fids[f].inodeid,h[5]);this.BuildReply(e,d,0);this.SendReply(a);break;case 50:J(["w","d"],b,c);this.BuildReply(e,d,0);this.SendReply(a);break;case 40:case 116:h=J(["w","d","w"],b,c);f=h[0];g=h[1];l=h[2];c=this.fs.GetInode(this.fids[f].inodeid);if(!c||4===c.status){this.SendError(d,"No such file or directory",
659
- 2);this.SendReply(a);break}if(2===this.fids[f].type)for(c.caps.length<g+l&&(l=c.caps.length-g),h=0;h<l;h++)this.replybuffer[11+h]=c.caps[g+h];else await this.fs.OpenInode(this.fids[f].inodeid,void 0),h=this.fids[f].inodeid,l=Math.min(l,this.replybuffer.length-11),c.size<g+l?l=c.size-g:40===e&&(l=this.fs.RoundToDirentry(h,g+l)-g),g>c.size&&(l=0),this.bus.send("9p-read-start",[this.fids[f].dbg_name]),h=await this.fs.Read(h,g,l),this.bus.send("9p-read-end",[this.fids[f].dbg_name,l]),h&&this.replybuffer.set(h,
660
- 11);I(["w"],[l],this.replybuffer,7);this.BuildReply(e,d,4+l);this.SendReply(a);break;case 118:h=J(["w","d","w"],b,c);f=h[0];g=h[1];l=h[2];h=this.fids[f].dbg_name;if(2===this.fids[f].type){this.SendError(d,"Setxattr not supported",95);this.SendReply(a);break}else await this.fs.Write(this.fids[f].inodeid,g,l,b.subarray(c.offset));this.bus.send("9p-write-end",[h,l]);I(["w"],[l],this.replybuffer,7);this.BuildReply(e,d,4);this.SendReply(a);break;case 74:h=J(["w","s","w","s"],b,c);f=await this.fs.Rename(this.fids[h[0]].inodeid,
661
- h[1],this.fids[h[2]].inodeid,h[3]);if(0>f){this.SendError(d,-2===f?"No such file or directory":-1===f?"Operation not permitted":-39===f?"Directory not empty":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,d,0);this.SendReply(a);break;case 76:h=J(["w","s","w"],b,c);b=h[0];g=h[1];f=this.fs.Search(this.fids[b].inodeid,g);if(-1===f){this.SendError(d,"No such file or directory",2);this.SendReply(a);break}f=this.fs.Unlink(this.fids[b].inodeid,g);if(0>f){this.SendError(d,-39===f?"Directory not empty":
662
- -1===f?"Operation not permitted":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,d,0);this.SendReply(a);break;case 100:f=J(["w","s"],b,c);this.msize!==f[0]&&(this.msize=f[0],this.replybuffer=new Uint8Array(Math.min(16777216,2*this.msize)));f=I(["w","s"],[this.msize,this.VERSION],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 104:h=J(["w","w","s","s","w"],b,c);f=h[0];g=h[4];y(h[1]);this.fids[f]=this.Createfid(0,1,g,"");c=this.fs.GetInode(this.fids[f].inodeid);
663
- I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);this.bus.send("9p-attach");break;case 108:J(["h"],b,c);this.BuildReply(e,d,0);this.SendReply(a);break;case 110:h=J(["w","w","h"],b,c);f=h[0];l=h[1];m=h[2];if(0===m){this.fids[l]=this.Createfid(this.fids[f].inodeid,1,this.fids[f].uid,this.fids[f].dbg_name);I(["h"],[0],this.replybuffer,7);this.BuildReply(e,d,2);this.SendReply(a);break}g=[];for(h=0;h<m;h++)g.push("s");c=J(g,b,c);b=this.fids[f].inodeid;g=9;var n=0;for(h=0;h<
664
- m;h++){b=this.fs.Search(b,c[h]);if(-1===b)break;g+=I(["Q"],[this.fs.GetInode(b).qid],this.replybuffer,g);n++;this.fids[l]=this.Createfid(b,1,this.fids[f].uid,c[h])}I(["h"],[n],this.replybuffer,7);this.BuildReply(e,d,g-7);this.SendReply(a);break;case 120:h=J(["w"],b,c);this.fids[h[0]]&&0<=this.fids[h[0]].inodeid&&(await this.fs.CloseInode(this.fids[h[0]].inodeid),this.fids[h[0]].inodeid=-1,this.fids[h[0]].type=-1);this.BuildReply(e,d,0);this.SendReply(a);break;case 32:h=J(["w","s","d","w"],b,c);f=
665
- h[0];this.fids[f].type=2;this.BuildReply(e,d,0);this.SendReply(a);break;case 30:J(["w","w","s"],b,c),this.SendError(d,"Setxattr not supported",95),this.SendReply(a)}};function id(a,b){this.handle_fn=a;this.tag_bufchain=new Map;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,async c=>{const d=new Uint8Array(c.length_readable);c.get_next_blob(d);var e=J(["w","b","h"],d,{offset:0})[2];
666
- this.tag_bufchain.set(e,c);this.handle_fn(d,f=>{var g=J(["w","b","h"],f,{offset:0})[2];const h=this.tag_bufchain.get(g);h?(h.set_next_blob(f),this.virtqueue.push_reply(h),this.virtqueue.flush_replies(),this.tag_bufchain.delete(g)):console.error("No bufchain found for tag: "+g)})});this.virtqueue=this.virtio.queues[0]}id.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.tag_bufchain;return a};id.prototype.set_state=function(a){this.configspace_tagname=
667
- a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.tag_bufchain=a[3]};id.prototype.reset=function(){this.virtio.reset()};function jd(a,b){this.socket=void 0;this.cpu=b;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.tag_bufchain=new Map;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;
668
- this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,async c=>{const d=new Uint8Array(c.length_readable);c.get_next_blob(d);const e=J(["w","b","h"],d,{offset:0})[2];this.tag_bufchain.set(e,c);this.send(d)});this.virtqueue=this.virtio.queues[0]}jd.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.tag_bufchain;return a};jd.prototype.set_state=function(a){this.configspace_tagname=a[0];this.configspace_taglen=a[1];
669
- this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.tag_bufchain=a[3]};jd.prototype.reset=function(){this.virtio.reset()};jd.prototype.handle_message=function(a){a=new Uint8Array(a.data);const b=J(["w","b","h"],a,{offset:0})[2],c=this.tag_bufchain.get(b);c?(c.set_next_blob(a),this.virtqueue.push_reply(c),this.virtqueue.flush_replies(),this.tag_bufchain.delete(b)):console.error("Virtio9pProxy: No bufchain found for tag: "+b)};jd.prototype.handle_close=function(){this.destroyed||(this.connect(),
670
- setTimeout(this.connect.bind(this),this.reconnect_interval))};jd.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);this.send_queue=[]};jd.prototype.handle_error=function(){};jd.prototype.destroy=function(){this.destroyed=!0;this.socket&&this.socket.close()};jd.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>
671
- 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)}}};jd.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&&
672
- (this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};jd.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)};export{};; export default module.exports.V86; export let {V86, CPU} = module.exports;
537
+ 64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:y(a);if(this.attribute_mode!==a){var b=this.attribute_mode;this.attribute_mode=a;!this.svga_enabled||this.dispi_enable_value&1||(this.svga_enabled=!1,this.svga_bank_offset=0);const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:y(a);
538
+ this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:y(a);this.horizontal_panning!==a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:y(a);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:y(this.attribute_controller_index),y(a)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){return this.port3C0_read()|
539
+ this.port3C1_read()<<8&65280};Y.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return y(this.attribute_controller_index),y(this.dac_map[this.attribute_controller_index]),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return y(this.attribute_mode),this.attribute_mode;case 18:return y(this.color_plane_enable),this.color_plane_enable;case 19:return y(this.horizontal_panning),this.horizontal_panning;case 20:return y(this.color_select),
540
+ this.color_select;default:y(this.attribute_controller_index)}return 255};Y.prototype.port3C2_write=function(a){y(a);this.miscellaneous_output_register=a};Y.prototype.port3C4_write=function(a){this.sequencer_index=a};Y.prototype.port3C4_read=function(){return this.sequencer_index};Y.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:y(a);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();this.set_font_bitmap(!1);break;case 2:y(a);b=this.plane_write_bm;
541
+ this.plane_write_bm=a;this.graphical_mode||!(b&4)||this.plane_write_bm&4||this.set_font_bitmap(!0);break;case 3:y(a);b=this.character_map_select;this.character_map_select=a;this.graphical_mode||b===a||this.set_font_page();break;case 4:y(a);this.sequencer_memory_mode=a;break;default:y(this.sequencer_index),y(a)}};Y.prototype.port3C5_read=function(){y(this.sequencer_index);switch(this.sequencer_index){case 1:return this.clocking_mode;case 2:return this.plane_write_bm;case 3:return this.character_map_select;
542
+ case 4:return this.sequencer_memory_mode;case 6:return 18}return 0};Y.prototype.port3C6_write=function(a){this.dac_mask!==a&&(this.dac_mask=a,this.complete_redraw())};Y.prototype.port3C6_read=function(){return this.dac_mask};Y.prototype.port3C7_write=function(a){y(a);this.dac_color_index_read=3*a;this.dac_state&=0};Y.prototype.port3C7_read=function(){return this.dac_state};Y.prototype.port3C8_write=function(a){this.dac_color_index_write=3*a;this.dac_state|=3};Y.prototype.port3C8_read=function(){return this.dac_color_index_write/
543
+ 3&255};Y.prototype.port3C9_write=function(a){var b=this.dac_color_index_write/3|0,c=this.dac_color_index_write%3,d=this.vga256_palette[b];if(0===(this.dispi_enable_value&32)){a&=63;const e=a&1;a=a<<2|e<<1|e}0===c?d=d&-16711681|a<<16:1===c?d=d&-65281|a<<8:(d=d&-256|a,y(b),y(d));this.vga256_palette[b]!==d&&(this.vga256_palette[b]=d,this.complete_redraw());this.dac_color_index_write++};Y.prototype.port3C9_read=function(){var a=this.vga256_palette[this.dac_color_index_read/3|0]>>8*(2-this.dac_color_index_read%
544
+ 3)&255;this.dac_color_index_read++;return this.dispi_enable_value&32?a:a>>2};Y.prototype.port3CC_read=function(){return this.miscellaneous_output_register};Y.prototype.port3CE_write=function(a){this.graphics_index=a};Y.prototype.port3CE_read=function(){return this.graphics_index};Y.prototype.port3CF_write=function(a){switch(this.graphics_index){case 0:this.planar_setreset=a;y(a);break;case 1:this.planar_setreset_enable=a;y(a);break;case 2:this.color_compare=a;y(a);break;case 3:this.planar_rotate_reg=
545
+ a;y(a);break;case 4:this.plane_read=a;y(a);break;case 5:var b=this.planar_mode;this.planar_mode=a;y(a);(b^a)&96&&this.complete_replot();break;case 6:y(a);this.miscellaneous_graphics_register!==a&&(this.miscellaneous_graphics_register=a,this.update_vga_size());break;case 7:this.color_dont_care=a;y(a);break;case 8:this.planar_bitmap=a;y(a);break;default:y(this.graphics_index),y(a)}};Y.prototype.port3CF_read=function(){y(this.graphics_index);switch(this.graphics_index){case 0:return this.planar_setreset;
546
+ case 1:return this.planar_setreset_enable;case 2:return this.color_compare;case 3:return this.planar_rotate_reg;case 4:return this.plane_read;case 5:return this.planar_mode;case 6:return this.miscellaneous_graphics_register;case 7:return this.color_dont_care;case 8:return this.planar_bitmap}return 0};Y.prototype.port3D4_write=function(a){this.index_crtc=a};Y.prototype.port3D4_write16=function(a){this.port3D4_write(a&255);this.port3D5_write(a>>8&255)};Y.prototype.port3D4_read=function(){return this.index_crtc};
547
+ Y.prototype.port3D5_write=function(a){switch(this.index_crtc){case 1:y(a);this.horizontal_display_enable_end!==a&&(this.horizontal_display_enable_end=a,this.update_vga_size());break;case 2:this.horizontal_blank_start!==a&&(this.horizontal_blank_start=a,this.update_vga_size());break;case 7:y(a);var b=this.vertical_display_enable_end;this.vertical_display_enable_end&=255;this.vertical_display_enable_end=this.vertical_display_enable_end|a<<3&512|a<<7&256;b!==this.vertical_display_enable_end&&this.update_vga_size();
548
+ this.line_compare=this.line_compare&767|a<<4&256;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&767|a<<5&256;b!==this.vertical_blank_start&&this.update_vga_size();this.update_layers();break;case 8:y(a);this.preset_row_scan=a;this.update_layers();break;case 9:y(a);var c=this.max_scan_line;this.max_scan_line=a;this.line_compare=this.line_compare&511|a<<3&512;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&511|a<<4&512;((c^this.max_scan_line)&
549
+ 159||b!==this.vertical_blank_start)&&this.update_vga_size();this.update_cursor_scanline();this.update_layers();this.set_font_bitmap(!1);break;case 10:y(a);this.cursor_scanline_start=a;this.update_cursor_scanline();break;case 11:y(a);this.cursor_scanline_end=a;this.update_cursor_scanline();break;case 12:(this.start_address>>8&255)!==a&&(this.start_address=this.start_address&255|a<<8,this.update_layers(),~this.crtc_mode&3&&this.complete_replot());y(a);y(this.start_address,4);break;case 13:(this.start_address&
550
+ 255)!==a&&(this.start_address=this.start_address&65280|a,this.update_layers(),~this.crtc_mode&3&&this.complete_replot());y(a);y(this.start_address,4);break;case 14:y(a);this.cursor_address=this.cursor_address&255|a<<8;this.update_cursor();break;case 15:y(a);this.cursor_address=this.cursor_address&65280|a;this.update_cursor();break;case 18:y(a);(this.vertical_display_enable_end&255)!==a&&(this.vertical_display_enable_end=this.vertical_display_enable_end&768|a,this.update_vga_size());break;case 19:y(a);
551
+ this.offset_register!==a&&(this.offset_register=a,this.update_vga_size(),~this.crtc_mode&3&&this.complete_replot());break;case 20:y(a);this.underline_location_register!==a&&(b=this.underline_location_register,this.underline_location_register=a,this.update_vga_size(),(b^a)&64&&this.complete_replot());break;case 21:y(a);(this.vertical_blank_start&255)!==a&&(this.vertical_blank_start=this.vertical_blank_start&768|a,this.update_vga_size());break;case 23:y(a);this.crtc_mode!==a&&(b=this.crtc_mode,this.crtc_mode=
552
+ a,this.update_vga_size(),(b^a)&67&&this.complete_replot());break;case 24:y(a);this.line_compare=this.line_compare&768|a;this.update_layers();break;default:this.index_crtc<this.crtc.length&&(this.crtc[this.index_crtc]=a),y(this.index_crtc),y(a)}};Y.prototype.port3D5_write16=function(a){y(a,4);this.port3D5_write(a&255)};Y.prototype.port3D5_read=function(){y(this.index_crtc);switch(this.index_crtc){case 1:return this.horizontal_display_enable_end;case 2:return this.horizontal_blank_start;case 7:return this.vertical_display_enable_end>>
553
+ 7&2|this.vertical_blank_start>>5&8|this.line_compare>>4&16|this.vertical_display_enable_end>>3&64;case 8:return this.preset_row_scan;case 9:return this.max_scan_line;case 10:return this.cursor_scanline_start;case 11:return this.cursor_scanline_end;case 12:return this.start_address&255;case 13:return this.start_address>>8;case 14:return this.cursor_address>>8;case 15:return this.cursor_address&255;case 18:return this.vertical_display_enable_end&255;case 19:return this.offset_register;case 20:return this.underline_location_register;
554
+ case 21:return this.vertical_blank_start&255;case 23:return this.crtc_mode;case 24:return this.line_compare&255}return this.index_crtc<this.crtc.length?this.crtc[this.index_crtc]:0};Y.prototype.port3D5_read16=function(){return this.port3D5_read()};Y.prototype.port3DA_read=function(){var a=this.port_3DA_value;this.graphical_mode?(this.port_3DA_value^=1,this.port_3DA_value&=1):(this.port_3DA_value&1&&(this.port_3DA_value^=8),this.port_3DA_value^=1);this.attribute_controller_index=-1;return a};Y.prototype.port1CE_read=
555
+ function(){return this.dispi_index};Y.prototype.port1CE_write=function(a){this.dispi_index=a};Y.prototype.port1CF_write=function(a){y(this.dispi_index);y(a);const b=this.svga_enabled;switch(this.dispi_index){case 0:45248<=a&&45253>=a?this.svga_version=a:y(a);break;case 1:this.svga_width=a;2560<this.svga_width&&(this.svga_width=2560);break;case 2:this.svga_height=a;1600<this.svga_height&&(this.svga_height=1600);break;case 3:this.svga_bpp=a;break;case 4:this.dispi_enable_value=a;!(a&1)&&this.svga_enabled&&
556
+ this.cpu.flags[0]&131072||(this.svga_enabled=1===(a&1))&&0===(a&128)&&this.svga_memory.fill(0);break;case 5:y(a<<16);this.svga_bank_offset=a<<16;break;case 8:y(a);this.svga_offset_x!==a&&(this.svga_offset_x=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;case 9:y(a*this.svga_width);y(a);this.svga_offset_y!==a&&(this.svga_offset_y=a,this.svga_offset=this.svga_offset_y*this.svga_width+this.svga_offset_x,this.complete_redraw());break;default:y(this.dispi_index)}!this.svga_enabled||
557
+ this.svga_width&&this.svga_height||(this.svga_enabled=!1);this.svga_enabled&&4===this.dispi_index&&(b||(this.svga_offset_y=this.svga_offset_x=this.svga_offset=0),this.graphical_mode=!0,this.screen.set_mode(this.graphical_mode),this.set_size_graphical(this.svga_width,this.svga_height,this.svga_width,this.svga_height,this.svga_bpp));b&&!this.svga_enabled&&(this.graphical_mode=a=0!==(this.attribute_mode&1),this.screen.set_mode(a),this.update_vga_size(),this.set_font_bitmap(!1),this.complete_redraw());
558
+ this.svga_enabled||(this.svga_bank_offset=0);this.update_layers()};Y.prototype.port1CF_read=function(){y(this.dispi_index);return this.svga_register_read(this.dispi_index)};Y.prototype.svga_register_read=function(a){switch(a){case 0:return this.svga_version;case 1:return this.dispi_enable_value&2?2560:this.svga_width;case 2:return this.dispi_enable_value&2?1600:this.svga_height;case 3:return this.dispi_enable_value&2?32:this.svga_bpp;case 4:return this.dispi_enable_value;case 5:return this.svga_bank_offset>>>
559
+ 16;case 6:return this.screen_width?this.screen_width:1;case 8:return this.svga_offset_x;case 9:return this.svga_offset_y;case 10:return this.vga_memory_size/65536|0;default:y(this.dispi_index)}return 255};Y.prototype.vga_replot=function(){for(var a=this.diff_plot_min&-16,b=Math.min(this.diff_plot_max|15,524287),c=this.vga_addr_shift_count(),d=~this.crtc_mode&3,e=this.planar_mode&96,f=this.attribute_mode&64;a<=b;){var g=a>>>c;if(d){var h=a/this.virtual_width|0,l=a-this.virtual_width*h;switch(d){case 1:g=
560
+ (h&1)<<13;h>>>=1;break;case 2:g=(h&1)<<14;h>>>=1;break;case 3:g=(h&3)<<13,h>>>=2}g|=(h*this.virtual_width+l>>>c)+this.start_address}h=this.plane0[g];l=this.plane1[g];var m=this.plane2[g],n=this.plane3[g];g=new Uint8Array(8);switch(e){case 0:h<<=0;l<<=1;m<<=2;n<<=3;for(var p=7;0<=p;p--)g[7-p]=h>>p&1|l>>p&2|m>>p&4|n>>p&8;break;case 32:g[0]=h>>6&3|m>>4&12;g[1]=h>>4&3|m>>2&12;g[2]=h>>2&3|m>>0&12;g[3]=h>>0&3|m<<2&12;g[4]=l>>6&3|n>>4&12;g[5]=l>>4&3|n>>2&12;g[6]=l>>2&3|n>>0&12;g[7]=l>>0&3|n<<2&12;break;
561
+ case 64:case 96:g[0]=h>>4&15,g[1]=h>>0&15,g[2]=l>>4&15,g[3]=l>>0&15,g[4]=m>>4&15,g[5]=m>>0&15,g[6]=n>>4&15,g[7]=n>>0&15}if(f)for(h=p=0;4>p;p++,a++,h+=2)this.pixel_buffer[a]=g[h]<<4|g[h+1];else for(p=0;8>p;p++,a++)this.pixel_buffer[a]=g[p]}};Y.prototype.vga_redraw=function(){var a=this.diff_addr_min,b=Math.min(this.diff_addr_max,524287);const c=new Int32Array(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,this.virtual_width*this.virtual_height);var d=255,e=0;this.attribute_mode&128&&(d&=207,e|=
562
+ this.color_select<<4&48);if(this.attribute_mode&64)for(;a<=b;a++){var f=this.pixel_buffer[a]&d|e;f=this.vga256_palette[f];c[a]=f&65280|f<<16|f>>16|4278190080}else for(d&=63,e|=this.color_select<<4&192;a<=b;a++)f=this.dac_map[this.pixel_buffer[a]&this.color_plane_enable]&d|e,f=this.vga256_palette[f],c[a]=f&65280|f<<16|f>>16|4278190080};Y.prototype.screen_fill_buffer=function(){if(this.graphical_mode){if(0===this.image_data.data.byteLength){var a=new Uint8ClampedArray(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,
563
+ 4*this.virtual_width*this.virtual_height);this.image_data=new ImageData(a,this.virtual_width,this.virtual_height);this.update_layers()}if(this.svga_enabled){a=0;let d=this.svga_height;if(8===this.svga_bpp){const e=new Int32Array(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,this.screen_width*this.screen_height),f=new Uint8Array(this.cpu.wasm_memory.buffer,this.svga_memory.byteOffset,this.vga_memory_size);for(var b=0;b<e.length;b++){var c=this.vga256_palette[f[b]];e[b]=c&65280|c<<16|c>>16|4278190080}}else this.cpu.svga_fill_pixel_buffer(this.svga_bpp,
564
+ this.svga_offset),b=15===this.svga_bpp?2:this.svga_bpp/8,a=((this.cpu.svga_dirty_bitmap_min_offset[0]/b|0)-this.svga_offset)/this.svga_width|0,d=(((this.cpu.svga_dirty_bitmap_max_offset[0]/b|0)-this.svga_offset)/this.svga_width|0)+1;a<d&&(a=Math.max(a,0),d=Math.min(d,this.svga_height),this.screen.update_buffer([{image_data:this.image_data,screen_x:0,screen_y:a,buffer_x:0,buffer_y:a,buffer_width:this.svga_width,buffer_height:d-a}]))}else this.vga_replot(),this.vga_redraw(),this.screen.update_buffer(this.layers);
565
+ this.reset_diffs()}this.update_vertical_retrace()};Y.prototype.set_font_bitmap=function(a){const b=this.max_scan_line&31;if(b&&!this.graphical_mode){const c=!!(this.clocking_mode&8);this.screen.set_font_bitmap(b+1,!c&&!(this.clocking_mode&1),c,!!(this.attribute_mode&4),this.plane2,a)}};Y.prototype.set_font_page=function(){const a=[0,2,4,6,1,3,5,7],b=(this.character_map_select&12)>>2|(this.character_map_select&32)>>3,c=this.character_map_select&3|(this.character_map_select&16)>>2;this.font_page_ab_enabled=
566
+ b!==c;this.screen.set_font_page(a[b],a[c]);this.complete_redraw()};const ed="SWAP_IN SWAP_OUT MAJFLT MINFLT MEMFREE MEMTOT AVAIL CACHES HTLB_PGALLOC HTLB_PGFAIL".split(" ");function fd(a,b){this.bus=b;this.zeroed=this.fp_cmd=this.actual=this.num_pages=0;this.virtio=new Lc(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,
567
+ notify_offset:2}],features:[1,3,32],on_driver_ok:()=>{}},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 f=new Uint8Array(e.length_readable);e.get_next_blob(f);this.virtio.queues[c].push_reply(e);e=f.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);
568
+ let f={};for(let g=0;g<d.length_readable;g+=10){let [h,l]=J(["h","d"],e,{offset:g});f[ed[h]]=l}this.virtio.queues[c].push_reply(d);this.stats_cb&&this.stats_cb(f)}},c=>{const d=this.virtio.queues[c];for(;d.has_request();){const f=d.pop_request();if(0<f.length_readable){var e=new Uint8Array(f.length_readable);f.get_next_blob(e);[e]=J(["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<f.length_writable)for(new Uint8Array(0),
569
+ e=0;e<f.write_buffers.length;++e){let g=f.write_buffers[e];this.zeroed+=g.len;this.virtio.cpu.zero_memory(g.addr_low,g.len)}this.virtio.queues[c].push_reply(f)}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:()=>{}}]}})}fd.prototype.Inflate=function(a){this.num_pages+=
570
+ a;this.virtio.notify_config_changes()};fd.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};fd.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=a;this.zeroed=0;this.virtio.notify_config_changes()};fd.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};fd.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};fd.prototype.GetStats=function(a){this.stats_cb=a;for(a=
571
+ 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()};fd.prototype.Reset=function(){};function gd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);var g=new Uint32Array(b),h=e[497]||4,l=f[255];if(43605!==l)y(l);else if(l=f[257]|f[258]<<16,1400005704!==l)y(l);else{l=f[259];var m=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=l?g[142]:255,C=g[146],t=g[147],A=g[150],M=g[151],v=g[152];y(l);y(m);y(n);y(g[133]);
572
+ y(p);y(q);y(r);y(x);y(C);y(t);y(M);y(A);y(v);e[528]=255;e[529]=m&-97|128;f[274]=56832;f[253]=65535;y(56832);d+="\x00";y(581632);g[138]=581632;for(e=0;e<d.length;e++)a[581632+e]=d.charCodeAt(e);h=512*(h+1);y(h);d=new Uint8Array(b,0,h);b=new Uint8Array(b,h);e=h=0;c&&(h=67108864,e=c.byteLength,a.set(new Uint8Array(c),h));g[134]=h;g[135]=e;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++]=
573
+ 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;g=a[c]=0;for(b=0;b<a.length;b++)g+=a[b];a[c]=-g;return{name:"genroms/kernel.bin",data:a}}}function R(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(Uint32Array,b,812,1);this.mem8=new Uint8Array(0);this.mem32s=new Int32Array(this.mem8.buffer);
574
+ this.segment_is_null=k(Uint8Array,b,724,8);this.segment_offsets=k(Int32Array,b,736,8);this.segment_limits=k(Uint32Array,b,768,8);this.segment_access_bytes=k(Uint8Array,b,512,8);this.protected_mode=k(Int32Array,b,800,1);this.idtr_size=k(Int32Array,b,564,1);this.idtr_offset=k(Int32Array,b,568,1);this.gdtr_size=k(Int32Array,b,572,1);this.gdtr_offset=k(Int32Array,b,576,1);this.tss_size_32=k(Int32Array,b,1128,1);this.page_fault=k(Uint32Array,b,540,8);this.cr=k(Int32Array,b,580,8);this.cpl=k(Uint8Array,
575
+ b,612,1);this.is_32=k(Int32Array,b,804,1);this.stack_size_32=k(Int32Array,b,808,1);this.in_hlt=k(Uint8Array,b,616,1);this.last_virt_eip=k(Int32Array,b,620,1);this.eip_phys=k(Int32Array,b,624,1);this.sysenter_cs=k(Int32Array,b,636,1);this.sysenter_esp=k(Int32Array,b,640,1);this.sysenter_eip=k(Int32Array,b,644,1);this.prefixes=k(Int32Array,b,648,1);this.flags=k(Int32Array,b,120,1);this.flags_changed=k(Int32Array,b,100,1);this.last_op_size=k(Int32Array,b,96,1);this.last_op1=k(Int32Array,b,104,1);this.last_result=
576
+ k(Int32Array,b,112,1);this.current_tsc=k(Uint32Array,b,960,2);this.devices={};this.instruction_pointer=k(Int32Array,b,556,1);this.previous_ip=k(Int32Array,b,560,1);this.apic_enabled=k(Uint8Array,b,548,1);this.acpi_enabled=k(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(Uint32Array,b,664,1);this.reg32=k(Int32Array,b,64,8);this.fpu_st=k(Int32Array,b,1152,32);this.fpu_stack_empty=
577
+ k(Uint8Array,b,816,1);this.fpu_stack_empty[0]=255;this.fpu_stack_ptr=k(Uint8Array,b,1032,1);this.fpu_stack_ptr[0]=0;this.fpu_control_word=k(Uint16Array,b,1036,1);this.fpu_control_word[0]=895;this.fpu_status_word=k(Uint16Array,b,1040,1);this.fpu_status_word[0]=0;this.fpu_ip=k(Int32Array,b,1048,1);this.fpu_ip[0]=0;this.fpu_ip_selector=k(Int32Array,b,1052,1);this.fpu_ip_selector[0]=0;this.fpu_opcode=k(Int32Array,b,1044,1);this.fpu_opcode[0]=0;this.fpu_dp=k(Int32Array,b,1056,1);this.fpu_dp[0]=0;this.fpu_dp_selector=
578
+ k(Int32Array,b,1060,1);this.fpu_dp_selector[0]=0;this.reg_xmm32s=k(Int32Array,b,832,32);this.mxcsr=k(Int32Array,b,824,1);this.sreg=k(Uint16Array,b,668,8);this.dreg=k(Int32Array,b,684,8);this.reg_pdpte=k(Int32Array,b,968,8);this.svga_dirty_bitmap_min_offset=k(Uint32Array,b,716,1);this.svga_dirty_bitmap_max_offset=k(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)}R.prototype.mmap_read8=function(a){return this.memory_map_read8[a>>>
579
+ 17](a)};R.prototype.mmap_write8=function(a,b){this.memory_map_write8[a>>>17](a,b)};R.prototype.mmap_write16=function(a,b){var c=this.memory_map_write8[a>>>17];c(a,b&255);c(a+1|0,b>>8)};R.prototype.mmap_read32=function(a){return this.memory_map_read32[a>>>17](a)};R.prototype.mmap_write32=function(a,b){this.memory_map_write32[a>>>17](a,b)};R.prototype.mmap_write64=function(a,b,c){var d=this.memory_map_write32[a>>>17];d(a,b);d(a+4,c)};R.prototype.mmap_write128=function(a,b,c,d,e){var f=this.memory_map_write32[a>>>
580
+ 17];f(a,b);f(a+4,c);f(a+8,d);f(a+12,e)};R.prototype.write_blob=function(a,b){a.length&&(this.in_mapped_range(b),this.in_mapped_range(b+a.length-1),this.jit_dirty_cache(b,b+a.length),this.mem8.set(a,b))};R.prototype.read_blob=function(a,b){b&&(this.in_mapped_range(a),this.in_mapped_range(a+b-1));return this.mem8.subarray(a,a+b)};R.prototype.clear_opstats=function(){(new Uint8Array(this.wasm_memory.buffer,32768,131072)).fill(0);this.wm.exports.profiler_init()};R.prototype.create_jit_imports=function(){const a=
581
+ 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};R.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");this.main_loop=b("main_loop");this.set_jit_config=
582
+ 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");this.get_real_eip=b("get_real_eip");this.clear_tlb=
583
+ 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.device_raise_irq=b("device_raise_irq");this.device_lower_irq=b("device_lower_irq");this.apic_timer=b("apic_timer");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=
584
+ 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.get_apic_addr=b("get_apic_addr");this.get_ioapic_addr=b("get_ioapic_addr");this.zstd_create_ctx=
585
+ 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")};R.prototype.jit_force_generate=function(a){this.jit_force_generate_unsafe&&this.jit_force_generate_unsafe(a)};R.prototype.jit_clear_func=function(a){this.wm.wasm_table.set(a+1024,null)};R.prototype.jit_clear_all_funcs=function(){const a=this.wm.wasm_table;for(let b=0;900>b;b++)a.set(1024+b,null)};R.prototype.get_state=function(){var a=
586
+ [];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;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];
587
+ 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;a[45]=this.devices.virtio_9p;a[46]=this.get_state_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]=
588
+ this.devices.ps2;a[54]=this.devices.uart0;a[55]=this.devices.fdc;this.devices.ide.secondary?a[85]=this.devices.ide:this.devices.ide.primary?.master.is_atapi?a[56]=this.devices.ide.primary:a[57]=this.devices.ide.primary;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.get_state_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];
589
+ 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;a[86]=this.last_result;a[87]=this.fpu_status_word;a[88]=this.mxcsr;return a};R.prototype.get_state_pic=function(){const a=
590
+ 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};R.prototype.get_state_apic=function(){return new Uint8Array(this.wasm_memory.buffer,
591
+ this.get_apic_addr(),184)};R.prototype.get_state_ioapic=function(){return new Uint8Array(this.wasm_memory.buffer,this.get_ioapic_addr(),208)};R.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]),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,
592
+ 8)),this.segment_access_bytes.set(a[1].subarray(8,16)));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];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];
593
+ 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&&this.devices.virtio_9p.set_state(a[45]);a[46]&&this.set_state_apic(a[46]);this.devices.rtc&&this.devices.rtc.set_state(a[47]);this.devices.dma&&this.devices.dma.set_state(a[49]);
594
+ 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]);if(a[56]||a[57]){var b=[[void 0,void 0],[void 0,void 0]];b[0][0]=a[56]?{is_cdrom:!0,buffer:this.devices.cdrom.buffer}:{is_cdrom:!1,buffer:this.devices.ide.primary.master.buffer};this.devices.ide=new $c(this,this.devices.ide.bus,b);this.devices.cdrom=
595
+ a[56]?this.devices.ide.primary.master:void 0;this.devices.ide.primary.set_state(a[56]||a[57])}else a[85]&&this.devices.ide.set_state(a[85]);this.devices.pci&&this.devices.pci.set_state(a[48]);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&&
596
+ 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];a[63]&&this.set_state_ioapic(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]=
597
+ a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=a[75];void 0!==a[86]&&(this.last_result=a[86]);void 0!==a[87]&&(this.fpu_status_word=a[87]);void 0!==a[88]&&(this.mxcsr=a[88]);b=new na(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();this.jit_clear_cache()};R.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(),
598
+ 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]};R.prototype.set_state_apic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_apic_addr(),46);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[8]=a[6];b[9]=a[7];b[10]=a[8];b[11]=a[9];b[12]=
599
+ a[10];b[13]=a[11];b[14]=a[12];b[15]=a[13];b.set(a[15],16);b.set(a[15],24);b.set(a[16],32);b[40]=a[17];b[41]=a[18];b[42]=a[19];b[43]=a[20];b[44]=a[21];b[45]=a[22]||65536}else(new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)).set(a)};R.prototype.set_state_ioapic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_ioapic_addr(),52);b.set(a[0],0);b.set(a[1],24);b[48]=a[2];b[49]=a[3];b[50]=a[4];b[51]=a[5]}else(new Uint8Array(this.wasm_memory.buffer,
600
+ this.get_ioapic_addr(),208)).set(a)};R.prototype.pack_memory=function(){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 na(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}};R.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 f=0;f<c;f++)if(a.get(f)){var e=d<<
601
+ 12;e=b.subarray(e,e+4096);this.mem8.set(e,f<<12);d++}};R.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.devices.ps2&&this.devices.ps2.reset();this.load_bios()};R.prototype.reset_memory=function(){this.mem8.fill(0)};R.prototype.create_memory=function(a,b){a<b?a=b:0>(a|0)&&(a=Math.pow(2,31)-131072);
602
+ a=(a-1|131071)+1|0;console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;b=this.allocate_memory(a);this.mem8=k(Uint8Array,this.wasm_memory,b,a);this.mem32s=k(Uint32Array,this.wasm_memory,b,a>>2)};R.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 Da(this);this.io=
603
+ c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();if(a.bzimage){const e=gd(this.mem8,a.bzimage,a.initrd,a.cmdline||"");e&&this.option_roms.push(e)}c.register_read(179,this,function(){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(){return this.fw_pointer<this.fw_value.length?this.fw_value[this.fw_pointer++]:0});c.register_write(1296,this,void 0,function(e){function f(l){return new Uint8Array(Int32Array.of(l).buffer)}
604
+ function g(l){return l>>8|l<<8&65280}function h(l){return l<<24|l<<8&16711680|l>>8&65280|l>>>24}va("bios config port, index="+y(e));this.fw_pointer=0;if(0===e)this.fw_value=f(1431127377);else if(1===e)this.fw_value=f(0);else if(3===e)this.fw_value=f(this.memory_size[0]);else if(5===e)this.fw_value=f(1);else if(15===e)this.fw_value=f(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 l=new Uint8Array(e.buffer);e[0]=h(this.option_roms.length);
605
+ for(let m=0;m<this.option_roms.length;m++){const {name:n,data:p}=this.option_roms[m],q=4+64*m;e[q+0>>2]=h(p.length);e[q+4>>2]=g(49152+m);for(let r=0;r<n.length;r++)l[q+8+r]=n.charCodeAt(r)}this.fw_value=l}else 32768<=e&&49152>e?this.fw_value=f(0):49152<=e&&e-49152<this.option_roms.length?this.fw_value=this.option_roms[e-49152].data:(va("Warning: Unimplemented fw index: "+y(e)),this.fw_value=f(0))});this.devices={};a.load_devices&&(this.devices.pci=new Gc(this),this.acpi_enabled[0]&&(this.devices.acpi=
606
+ new Ec(this)),this.devices.rtc=new hb(this),this.fill_cmos(this.devices.rtc,a),this.devices.dma=new B(this),this.devices.vga=new Y(this,b,a.screen,a.vga_memory_size||8388608),this.devices.ps2=new Mc(this,b),this.devices.uart0=new Fc(this,1016,b),a.uart1&&(this.devices.uart1=new Fc(this,760,b)),a.uart2&&(this.devices.uart2=new Fc(this,1E3,b)),a.uart3&&(this.devices.uart3=new Fc(this,744,b)),this.devices.fdc=new W(this,a.fda,a.fdb),c=[[void 0,void 0],[void 0,void 0]],a.hda&&(c[0][0]={buffer:a.hda},
607
+ c[0][1]={buffer:a.hdb}),c[1][0]={is_cdrom:!0,buffer:a.cdrom},this.devices.ide=new $c(this,b,c),this.devices.cdrom=this.devices.ide.secondary.master,this.devices.pit=new ib(this,b),"ne2k"===a.net_device.type?this.devices.net=new Jc(this,b,a.preserve_mac_from_state_image,a.mac_address_translation):"virtio"===a.net_device.type&&(this.devices.virtio_net=new bd(this,b,a.preserve_mac_from_state_image,a.net_device.mtu)),a.fs9p?this.devices.virtio_9p=new hd(a.fs9p,this,b):a.handle9p?this.devices.virtio_9p=
608
+ new id(a.handle9p,this):a.proxy9p&&(this.devices.virtio_9p=new jd(a.proxy9p,this)),a.virtio_console&&(this.devices.virtio_console=new Kc(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=new fd(this,b)),this.devices.sb16=new D(this,b));a.multiboot&&(a=this.load_multiboot_option_rom(a.multiboot,a.initrd,a.cmdline))&&(this.bios.main?this.option_roms.push(a):this.reg32[0]=this.io.port_read32(244));this.debug_init()};R.prototype.load_multiboot=function(a){this.load_multiboot_option_rom(a,void 0,
609
+ "")&&(this.reg32[0]=this.io.port_read32(244))};R.prototype.load_multiboot_option_rom=function(a,b,c){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 f=d[e+4>>2];if(464367618+f+d[e+8>>2]|0)continue}else continue;va("Multiboot magic found, flags: "+y(f>>>0,8),2);var g=this;this.io.register_read(244,this,function(){return 0},function(){return 0},function(){var n,p=31860;
610
+ let q=0;if(c){q|=4;g.write32(31760,p);c+="\x00";var r=(new TextEncoder).encode(c);g.write_blob(r,p);p+=r.length}if(f&2){q|=64;r=0;g.write32(31788,0);g.write32(31792,p);var x=0;var C=!1;for(n=0;4294967296>n;n+=131072)C&&void 0!==g.memory_map_read8[n>>>17]?(g.write32(p,20),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,n-x),g.write32(p+16,0),g.write32(p+20,1),p+=24,r+=24,C=!1):C||void 0!==g.memory_map_read8[n>>>17]||(x=n,C=!0);g.write32(31788,r)}x=r=0;if(f&65536){n=d[e+12>>2];r=d[e+16>>2];var t=d[e+
611
+ 20>>2];x=d[e+24>>2];C=d[e+28>>2];y(n,8);y(r,8);y(t,8);y(x,8);y(C,8);n=new Uint8Array(a,e-(n-r),0===t?void 0:t-r);g.write_blob(n,r);r=C|0;x=Math.max(t,x)}else if(1179403647===d[0]){C=new DataView(a);const [A,M]=Uc(C,Rc);console.assert(52===M);console.assert(1179403647===A.magic,"Bad magic");console.assert(1===A.class,"Unimplemented: 64 bit elf");console.assert(1===A.data,"Unimplemented: big endian");console.assert(1===A.version0,"Bad version0");console.assert(2===A.type,"Unimplemented type");console.assert(1===
612
+ A.version1,"Bad version1");console.assert(52===A.ehsize,"Bad header size");console.assert(32===A.phentsize,"Bad program header size");console.assert(40===A.shentsize,"Bad section header size");[r]=Vc(new DataView(C.buffer,C.byteOffset+A.phoff,A.phentsize*A.phnum),Sc,A.phnum);Vc(new DataView(C.buffer,C.byteOffset+A.shoff,A.shentsize*A.shnum),Tc,A.shnum);C=A;n=r;r=C.entry;for(t of n)0!==t.type&&(1===t.type?t.paddr+t.memsz<g.memory_size[0]?(t.filesz&&(n=new Uint8Array(a,t.offset,t.filesz),g.write_blob(n,
613
+ t.paddr)),x=Math.max(x,t.paddr+t.memsz),r===C.entry&&t.vaddr<=r&&t.vaddr+t.memsz>r&&(r=r-t.vaddr+t.paddr)):y(t.paddr):2===t.type||3===t.type||4===t.type||6===t.type||7===t.type||1685382480===t.type||1685382481===t.type||1685382482===t.type||1685382483===t.type||y(t.type))}b&&(q|=8,g.write32(31764,1),g.write32(31768,p),t=x,0!==(t&4095)&&(t=(t&-4096)+4096),x=t+b.byteLength,g.write32(p,t),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,0),g.write_blob(new Uint8Array(b),t));g.write32(31744,q);g.reg32[3]=
614
+ 31744;g.cr[0]=1;g.protected_mode[0]=1;g.flags[0]=2;g.is_32[0]=1;g.stack_size_32[0]=1;for(p=0;6>p;p++)g.segment_is_null[p]=0,g.segment_offsets[p]=0,g.segment_limits[p]=4294967295,g.sreg[p]=45058;g.instruction_pointer[0]=g.get_seg_cs()+r|0;g.update_state_flags();g.dump_state();g.dump_regs_short();return 732803074});this.io.register_write_consecutive(244,this,function(n){console.log("Test exited with code "+y(n,2));throw"HALT";},function(){},function(){},function(){});for(let n=0;15>=n;n++){function p(q){y(n);
615
+ y(q,2);q?this.device_raise_irq(n):this.device_lower_irq(n)}this.io.register_write(8192+n,this,p,p,p)}const l=new Uint8Array(512);(new Uint16Array(l.buffer))[0]=43605;l[2]=1;var h=3;l[h++]=102;l[h++]=229;l[h++]=244;let m=l[h]=0;for(let n=0;n<l.length;n++)m+=l[n];l[h]=-m;return{name:"genroms/multiboot.bin",data:l}}};R.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]&&
616
+ (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&&a.cmos_write(63,1)};R.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){var c=
617
+ new Uint8Array(a);this.write_blob(c,1048576-a.byteLength);if(b){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(){})}this.io.mmap_register(4293918720,1048576,function(e){return this.mem8[e&1048575]}.bind(this),function(e,f){this.mem8[e&1048575]=f}.bind(this))}};R.prototype.codegen_finalize=function(a,b,c,d,e){const f=new Uint8Array(this.wasm_memory.buffer,d>>>0,e>>>0);WebAssembly.instantiate(f,
618
+ {e:this.jit_imports}).then(g=>{this.wm.wasm_table.set(a+1024,g.instance.exports.f);this.codegen_finalize_finished(a,b,c);this.test_hook_did_finalize_wasm&&this.test_hook_did_finalize_wasm(f)})};R.prototype.log_uncompiled_code=function(){};R.prototype.dump_function_code=function(){};R.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,f=100;a&&(e=this.devices.acpi.timer(b),f=this.apic_timer(b));return Math.min(c,d,e,f)};R.prototype.debug_init=
619
+ function(){};R.prototype.dump_stack=function(){};R.prototype.debug_get_state=function(){};R.prototype.dump_state=function(){};R.prototype.get_regs_short=function(){};R.prototype.dump_regs_short=function(){};R.prototype.dump_gdt_ldt=function(){};R.prototype.dump_idt=function(){};R.prototype.dump_page_structures=function(){if(this.cr[4]&32)for(var a=0;4>a;a++){var b=this.read32s(this.cr[3]+8*a);b&1&&this.dump_page_directory(b&4294963200,!0,a<<30)}else this.dump_page_directory(this.cr[3],!1,0)};R.prototype.dump_page_directory=
620
+ function(){};R.prototype.get_memory_dump=function(){};R.prototype.memory_hex_dump=function(){};R.prototype.used_memory_dump=function(){};R.prototype.debug_interrupt=function(){};R.prototype.debug_dump_code=function(){};R.prototype.dump_wasm=function(){};function Lc(a,b){this.cpu=a;this.pci=a.devices.pci;this.device_id=b.device_id;this.pci_space=[244,26,b.device_id&255,b.device_id>>8,7,5,16,0,1,0,2,0,0,0,0,0,1,168,0,0,0,16,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,b.subsystem_device_id&
621
+ 255,b.subsystem_device_id>>8,0,0,0,0,64,0,0,0,0,0,0,0,0,1,0,0];this.pci_space=this.pci_space.concat(Array(256-this.pci_space.length).fill(0));this.pci_id=b.pci_id;this.pci_bars=[];this.name=b.name;this.driver_feature_select=this.device_feature_select=0;this.device_feature=new Uint32Array(4);this.driver_feature=new Uint32Array(4);for(var c of b.common.features)this.device_feature[c>>>5]|=1<<(c&31),this.driver_feature[c>>>5]|=1<<(c&31);b.common.features.includes(32);this.features_ok=!0;this.device_status=
622
+ 0;this.config_has_changed=!1;this.config_generation=0;this.queues=[];for(const d of b.common.queues)this.queues.push(new Z(a,this,d));this.queue_select=0;this.queue_selected=this.queues[0];this.isr_status=0;c=[];c.push(this.create_common_capability(b.common));c.push(this.create_notification_capability(b.notification));c.push(this.create_isr_capability(b.isr_status));b.device_specific&&c.push(this.create_device_specific_capability(b.device_specific));this.init_capabilities(c);a.devices.pci.register_device(this);
623
+ this.reset()}Lc.prototype.create_common_capability=function(a){return{type:1,bar:0,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:4,name:"device_feature_select",read:()=>this.device_feature_select,write:b=>{this.device_feature_select=b}},{bytes:4,name:"device_feature",read:()=>this.device_feature[this.device_feature_select]||0,write:()=>{}},{bytes:4,name:"driver_feature_select",read:()=>this.driver_feature_select,write:b=>{this.driver_feature_select=b}},{bytes:4,name:"driver_feature",
624
+ read:()=>this.driver_feature[this.driver_feature_select]||0,write:b=>{const c=this.device_feature[this.driver_feature_select];this.driver_feature_select<this.driver_feature.length&&(this.driver_feature[this.driver_feature_select]=b&c);this.features_ok=this.features_ok&&!(b&~c)}},{bytes:2,name:"msix_config",read:()=>65535,write:()=>{}},{bytes:2,name:"num_queues",read:()=>this.queues.length,write:()=>{}},{bytes:1,name:"device_status",read:()=>this.device_status,write:b=>{0===b&&this.reset();b&~this.device_status&
625
+ 4&&this.device_status&64&&this.notify_config_changes();this.features_ok||(b&=-9);this.device_status=b;if(b&~this.device_status&4)a.on_driver_ok()}},{bytes:1,name:"config_generation",read:()=>this.config_generation,write:()=>{}},{bytes:2,name:"queue_select",read:()=>this.queue_select,write:b=>{this.queue_select=b;this.queue_selected=this.queue_select<this.queues.length?this.queues[this.queue_select]:null}},{bytes:2,name:"queue_size",read:()=>this.queue_selected?this.queue_selected.size:0,write:b=>
626
+ {this.queue_selected&&(b&b-1&&(b=1<<da(b-1)+1),b>this.queue_selected.size_supported&&(b=this.queue_selected.size_supported),this.queue_selected.set_size(b))}},{bytes:2,name:"queue_msix_vector",read:()=>65535,write:()=>{}},{bytes:2,name:"queue_enable",read:()=>this.queue_selected?this.queue_selected.enabled|0:0,write:b=>{this.queue_selected&&1===b&&this.queue_selected.is_configured()&&this.queue_selected.enable()}},{bytes:2,name:"queue_notify_off",read:()=>this.queue_selected?this.queue_selected.notify_offset:
627
+ 0,write:()=>{}},{bytes:4,name:"queue_desc (low dword)",read:()=>this.queue_selected?this.queue_selected.desc_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.desc_addr=b)}},{bytes:4,name:"queue_desc (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_avail (low dword)",read:()=>this.queue_selected?this.queue_selected.avail_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.avail_addr=b)}},{bytes:4,name:"queue_avail (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_used (low dword)",
628
+ read:()=>this.queue_selected?this.queue_selected.used_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.used_addr=b)}},{bytes:4,name:"queue_used (high dword)",read:()=>0,write:()=>{}}]}};Lc.prototype.create_notification_capability=function(a){const b=[];let c;c=a.single_handler?0:2;for(const [d,e]of a.handlers.entries())b.push({bytes:2,name:"notify"+d,read:()=>65535,write:e||(()=>{})});return{type:2,bar:1,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array([c&255,c>>8&255,c>>16&
629
+ 255,c>>24]),struct:b}};Lc.prototype.create_isr_capability=function(a){return{type:3,bar:2,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:1,name:"isr_status",read:()=>{const b=this.isr_status;this.lower_irq();return b},write:()=>{}}]}};Lc.prototype.create_device_specific_capability=function(a){return{type:4,bar:3,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:a.struct}};Lc.prototype.init_capabilities=function(a){let b=this.pci_space[52]=64;
630
+ var c=b;for(const e of a){a=16+e.extra.length;c=b;b=c+a;var d=e.struct.reduce((f,g)=>f+g.bytes,0);d+=e.offset;d=16>d?16:1<<da(d-1)+1;this.pci_bars[e.bar]={size:d};this.pci_space[c]=9;this.pci_space[c+1]=b;this.pci_space[c+2]=a;this.pci_space[c+3]=e.type;this.pci_space[c+4]=e.bar;this.pci_space[c+5]=0;this.pci_space[c+6]=0;this.pci_space[c+7]=0;this.pci_space[c+8]=e.offset&255;this.pci_space[c+9]=e.offset>>>8&255;this.pci_space[c+10]=e.offset>>>16&255;this.pci_space[c+11]=e.offset>>>24;this.pci_space[c+
631
+ 12]=d&255;this.pci_space[c+13]=d>>>8&255;this.pci_space[c+14]=d>>>16&255;this.pci_space[c+15]=d>>>24;for(const [f,g]of e.extra.entries())this.pci_space[c+16+f]=g;c=16+4*e.bar;this.pci_space[c]=e.port&254|!e.use_mmio;this.pci_space[c+1]=e.port>>>8&255;this.pci_space[c+2]=e.port>>>16&255;this.pci_space[c+3]=e.port>>>24&255;c=e.port+e.offset;for(const f of e.struct){let g=f.read;a=f.write;if(!e.use_mmio){d=function(m){return g(m&-2)>>((m&1)<<3)&255};const h=function(m){return g(m&-4)>>((m&3)<<3)&255},
632
+ l=function(m){return g(m)};switch(f.bytes){case 4:this.cpu.io.register_read(c,this,h,void 0,g);this.cpu.io.register_read(c+1,this,h);this.cpu.io.register_read(c+2,this,h);this.cpu.io.register_read(c+3,this,h);this.cpu.io.register_write(c,this,void 0,void 0,a);break;case 2:this.cpu.io.register_read(c,this,d,g,l);this.cpu.io.register_read(c+1,this,d);this.cpu.io.register_write(c,this,void 0,a);break;case 1:this.cpu.io.register_read(c,this,g),this.cpu.io.register_write(c,this,a)}}c+=f.bytes}}this.pci_space[b]=
633
+ 9;this.pci_space[b+1]=0;this.pci_space[b+2]=20;this.pci_space[b+3]=5;this.pci_space[b+4]=0;this.pci_space[b+5]=0;this.pci_space[b+6]=0;this.pci_space[b+7]=0;this.pci_space[b+8]=0;this.pci_space[b+9]=0;this.pci_space[b+10]=0;this.pci_space[b+11]=0;this.pci_space[b+12]=0;this.pci_space[b+13]=0;this.pci_space[b+14]=0;this.pci_space[b+15]=0;this.pci_space[b+16]=0;this.pci_space[b+17]=0;this.pci_space[b+18]=0;this.pci_space[b+19]=0};Lc.prototype.get_state=function(){let a=[];a[0]=this.device_feature_select;
634
+ a[1]=this.driver_feature_select;a[2]=this.device_feature;a[3]=this.driver_feature;a[4]=this.features_ok;a[5]=this.device_status;a[6]=this.config_has_changed;a[7]=this.config_generation;a[8]=this.isr_status;a[9]=this.queue_select;return a=a.concat(this.queues)};Lc.prototype.set_state=function(a){this.device_feature_select=a[0];this.driver_feature_select=a[1];this.device_feature=a[2];this.driver_feature=a[3];this.features_ok=a[4];this.device_status=a[5];this.config_has_changed=a[6];this.config_generation=
635
+ 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};Lc.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];for(const a of this.queues)a.reset();this.config_has_changed=!1;this.config_generation=0;this.lower_irq()};
636
+ Lc.prototype.notify_config_changes=function(){this.config_has_changed=!0;this.device_status&4&&this.raise_irq(2)};Lc.prototype.update_config_generation=function(){this.config_has_changed&&(this.config_generation++,this.config_generation&=255,this.config_has_changed=!1)};Lc.prototype.is_feature_negotiated=function(a){return 0<(this.driver_feature[a>>>5]&1<<(a&31))};Lc.prototype.needs_reset=function(){this.device_status|=64;this.device_status&4&&this.notify_config_changes()};Lc.prototype.raise_irq=
637
+ function(a){y(a);this.isr_status|=a;this.pci.raise_irq(this.pci_id)};Lc.prototype.lower_irq=function(){this.isr_status=0;this.pci.lower_irq(this.pci_id)};function Z(a,b,c){this.cpu=a;this.virtio=b;this.size_supported=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()}Z.prototype.get_state=function(){const a=[];a[0]=this.size;a[1]=this.size_supported;
638
+ 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};Z.prototype.set_state=function(a){this.size=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]};Z.prototype.reset=function(){this.enabled=!1;this.num_staged_replies=
639
+ this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.set_size(this.size_supported)};Z.prototype.is_configured=function(){return this.desc_addr&&this.avail_addr&&this.used_addr};Z.prototype.enable=function(){this.is_configured();this.enabled=!0};Z.prototype.set_size=function(a){this.size=a;this.mask=a-1};Z.prototype.count_requests=function(){this.fix_wrapping&&(this.fix_wrapping=!1,this.avail_last_idx=(this.avail_get_idx()&~this.mask)+(this.avail_last_idx&this.mask));return this.avail_get_idx()-
640
+ this.avail_last_idx&65535};Z.prototype.has_request=function(){return 0!==this.count_requests()};Z.prototype.pop_request=function(){this.has_request();var a=this.avail_get_entry(this.avail_last_idx);a=new kd(this,a);this.avail_last_idx=this.avail_last_idx+1&65535;return a};Z.prototype.push_reply=function(a){const b=this.used_get_idx()+this.num_staged_replies&this.mask;this.used_set_entry(b,a.head_idx,a.length_written);this.num_staged_replies++};Z.prototype.flush_replies=function(){if(0!==this.num_staged_replies){var a=
641
+ 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)}};Z.prototype.notify_me_after=function(a){a=this.avail_get_idx()+a&65535;this.used_set_avail_event(a)};Z.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+
642
+ 16*b+12),next:this.cpu.read16(a+16*b+14)}};Z.prototype.avail_get_flags=function(){return this.cpu.read16(this.avail_addr)};Z.prototype.avail_get_idx=function(){return this.cpu.read16(this.avail_addr+2)};Z.prototype.avail_get_entry=function(a){return this.cpu.read16(this.avail_addr+4+2*(a&this.mask))};Z.prototype.avail_get_used_event=function(){return this.cpu.read16(this.avail_addr+4+2*this.size)};Z.prototype.used_get_flags=function(){return this.cpu.read16(this.used_addr)};Z.prototype.used_set_flags=
643
+ function(a){this.cpu.write16(this.used_addr,a)};Z.prototype.used_get_idx=function(){return this.cpu.read16(this.used_addr+2)};Z.prototype.used_set_idx=function(a){this.cpu.write16(this.used_addr+2,a)};Z.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)};Z.prototype.used_set_avail_event=function(a){this.cpu.write16(this.used_addr+4+8*this.size,a)};function kd(a,b){this.cpu=a.cpu;this.virtio=a.virtio;this.head_idx=b;this.read_buffers=
644
+ [];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,f=!1;const g=this.virtio.is_feature_negotiated(28);do{const h=a.get_descriptor(c,b);y(h.addr_high,8);y(h.addr_low,8);y(h.len,8);y(h.flags,4);y(h.next,4);if(g&&h.flags&4)c=h.addr_low,d=b=0,e=h.len/16;else{if(h.flags&2)f=!0,this.write_buffers.push(h),this.length_writable+=h.len;else{if(f)break;
645
+ this.read_buffers.push(h);this.length_readable+=h.len}d++;if(d>e)break;if(h.flags&1)b=h.next;else break}}while(1)}kd.prototype.get_next_blob=function(a){let b=0,c=a.length;for(;c&&this.read_buffer_idx!==this.read_buffers.length;){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};kd.prototype.set_next_blob=
646
+ function(a){let b=0,c=a.length;for(;c&&this.write_buffer_idx!==this.write_buffers.length;){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,b+d),e);b+=d;c-=d}this.length_written+=b;return b};function ld(a,b,c,d){const e=new Lc(a,{name:"virtio-9p",pci_id:48,device_id:4169,subsystem_device_id:9,common:{initial_port:43008,
647
+ queues:[{size_supported:32,notify_offset:0}],features:[0,32,29,28],on_driver_ok:()=>{}},notification:{initial_port:43264,single_handler:!1,handlers:[f=>{if(0===f){for(f=e.queues[0];f.has_request();){const g=f.pop_request();d(g)}f.notify_me_after(0)}}]},isr_status:{initial_port:42752},device_specific:{initial_port:42496,struct:[{bytes:2,name:"mount tag length",read:()=>b,write:()=>{}}].concat(Array.from(Array(254).keys()).map(f=>({bytes:1,name:"mount tag name "+f,read:()=>c[f]||0,write:()=>{}})))}});
648
+ return e}function hd(a,b,c){this.fs=a;this.bus=c;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,this.ReceiveRequest.bind(this));this.virtqueue=this.virtio.queues[0];this.VERSION="9P2000.L";this.msize=this.BLOCKSIZE=8192;this.replybuffer=new Uint8Array(2*this.msize);this.replybuffersize=0;this.fids=[]}hd.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=
649
+ this.configspace_taglen;a[2]=this.virtio;a[3]=this.VERSION;a[4]=this.BLOCKSIZE;a[5]=this.msize;a[6]=this.replybuffer;a[7]=this.replybuffersize;a[8]=this.fids.map(function(b){return[b.inodeid,b.type,b.uid,b.dbg_name]});a[9]=this.fs;return a};hd.prototype.set_state=function(a){this.configspace_tagname=a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.VERSION=a[3];this.BLOCKSIZE=a[4];this.msize=a[5];this.replybuffer=a[6];this.replybuffersize=a[7];
650
+ this.fids=a[8].map(function(b){return{inodeid:b[0],type:b[1],uid:b[2],dbg_name:b[3]}});this.fs.set_state(a[9])};hd.prototype.Createfid=function(a,b,c,d){return{inodeid:a,type:b,uid:c,dbg_name:d}};hd.prototype.update_dbg_name=function(a,b){for(const c of this.fids)c.inodeid===a&&(c.dbg_name=b)};hd.prototype.reset=function(){this.fids=[];this.virtio.reset()};hd.prototype.BuildReply=function(a,b,c){I(["w","b","h"],[c+7,a+1,b],this.replybuffer,0);this.replybuffersize=c+7};hd.prototype.SendError=function(a,
651
+ b,c){b=I(["w"],[c],this.replybuffer,7);this.BuildReply(6,a,b)};hd.prototype.SendReply=function(a){a.set_next_blob(this.replybuffer.subarray(0,this.replybuffersize));this.virtqueue.push_reply(a);this.virtqueue.flush_replies()};hd.prototype.ReceiveRequest=async function(a){var b=new Uint8Array(a.length_readable);a.get_next_blob(b);var c={offset:0},d=J(["w","b","h"],b,c),e=d[1];d=d[2];switch(e){case 8:var f=this.fs.GetTotalSize();var g=this.fs.GetSpace(),h=[16914839];h[1]=this.BLOCKSIZE;h[2]=Math.floor(g/
652
+ h[1]);h[3]=h[2]-Math.floor(f/h[1]);h[4]=h[2]-Math.floor(f/h[1]);h[5]=this.fs.CountUsedInodes();h[6]=this.fs.CountFreeInodes();h[7]=0;h[8]=256;f=I("wwddddddw".split(""),h,this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 112:case 12:h=J(["w","w"],b,c);f=h[0];var l=h[1];b=this.fids[f].inodeid;c=this.fs.GetInode(b);await this.fs.OpenInode(b,l);h=[];h[0]=c.qid;h[1]=this.msize-24;I(["Q","w"],h,this.replybuffer,7);this.BuildReply(e,d,17);this.SendReply(a);break;case 70:h=J(["w","w",
653
+ "s"],b,c);b=h[0];f=h[1];g=h[2];f=this.fs.Link(this.fids[b].inodeid,this.fids[f].inodeid,g);if(0>f){this.SendError(d,-1===f?"Operation not permitted":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,d,0);this.SendReply(a);break;case 16:h=J(["w","s","s","w"],b,c);f=h[0];g=h[1];var m=h[3];b=this.fs.CreateSymlink(g,this.fids[f].inodeid,h[2]);c=this.fs.GetInode(b);c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 18:h=
654
+ J("wswwww".split(""),b,c);f=h[0];g=h[1];l=h[2];b=h[3];c=h[4];m=h[5];b=this.fs.CreateNode(g,this.fids[f].inodeid,b,c);c=this.fs.GetInode(b);c.mode=l;c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 22:h=J(["w"],b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);f=I(["s"],[c.symlink],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 72:h=J(["w","s","w","w"],b,c);f=h[0];g=h[1];l=h[2];m=h[3];b=this.fs.CreateDirectory(g,
655
+ this.fids[f].inodeid);c=this.fs.GetInode(b);c.mode=l|16384;c.uid=this.fids[f].uid;c.gid=m;I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);break;case 14:h=J(["w","s","w","w","w"],b,c);f=h[0];g=h[1];l=h[3];m=h[4];this.bus.send("9p-create",[g,this.fids[f].inodeid]);b=this.fs.CreateFile(g,this.fids[f].inodeid);this.fids[f].inodeid=b;this.fids[f].type=1;this.fids[f].dbg_name=g;c=this.fs.GetInode(b);c.uid=this.fids[f].uid;c.gid=m;c.mode=l|32768;I(["Q","w"],[c.qid,this.msize-
656
+ 24],this.replybuffer,7);this.BuildReply(e,d,17);this.SendReply(a);break;case 52:h=J("wbwddws".split(""),b,c);f=h[0];g=h[2];b=0===h[4]?Infinity:h[4];h=this.fs.DescribeLock(h[1],h[3],b,h[5],h[6]);f=this.fs.Lock(this.fids[f].inodeid,h,g);I(["b"],[f],this.replybuffer,7);this.BuildReply(e,d,1);this.SendReply(a);break;case 54:h=J("wbddws".split(""),b,c);f=h[0];b=0===h[3]?Infinity:h[3];h=this.fs.DescribeLock(h[1],h[2],b,h[4],h[5]);f=this.fs.GetLock(this.fids[f].inodeid,h);f||(f=h,f.type=2);f=I(["b","d",
657
+ "d","w","s"],[f.type,f.start,Infinity===f.length?0:f.length,f.proc_id,f.client_id],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 24:h=J(["w","d"],b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);if(!c||4===c.status){this.SendError(d,"No such file or directory",2);this.SendReply(a);break}h[0]=h[1];h[1]=c.qid;h[2]=c.mode;h[3]=c.uid;h[4]=c.gid;h[5]=c.nlinks;h[6]=c.major<<8|c.minor;h[7]=c.size;h[8]=this.BLOCKSIZE;h[9]=Math.floor(c.size/512+1);h[10]=c.atime;h[11]=0;h[12]=
658
+ c.mtime;h[13]=0;h[14]=c.ctime;h[15]=0;h[16]=0;h[17]=0;h[18]=0;h[19]=0;I("dQwwwddddddddddddddd".split(""),h,this.replybuffer,7);this.BuildReply(e,d,153);this.SendReply(a);break;case 26:h=J("wwwwwddddd".split(""),b,c);f=h[0];c=this.fs.GetInode(this.fids[f].inodeid);h[1]&1&&(c.mode=h[2]);h[1]&2&&(c.uid=h[3]);h[1]&4&&(c.gid=h[4]);h[1]&16&&(c.atime=Math.floor((new Date).getTime()/1E3));h[1]&32&&(c.mtime=Math.floor((new Date).getTime()/1E3));h[1]&64&&(c.ctime=Math.floor((new Date).getTime()/1E3));h[1]&
659
+ 128&&(c.atime=h[6]);h[1]&256&&(c.mtime=h[8]);h[1]&8&&await this.fs.ChangeSize(this.fids[f].inodeid,h[5]);this.BuildReply(e,d,0);this.SendReply(a);break;case 50:J(["w","d"],b,c);this.BuildReply(e,d,0);this.SendReply(a);break;case 40:case 116:h=J(["w","d","w"],b,c);f=h[0];g=h[1];l=h[2];c=this.fs.GetInode(this.fids[f].inodeid);if(!c||4===c.status){this.SendError(d,"No such file or directory",2);this.SendReply(a);break}if(2===this.fids[f].type)for(c.caps.length<g+l&&(l=c.caps.length-g),h=0;h<l;h++)this.replybuffer[11+
660
+ h]=c.caps[g+h];else await this.fs.OpenInode(this.fids[f].inodeid,void 0),h=this.fids[f].inodeid,l=Math.min(l,this.replybuffer.length-11),c.size<g+l?l=c.size-g:40===e&&(l=this.fs.RoundToDirentry(h,g+l)-g),g>c.size&&(l=0),this.bus.send("9p-read-start",[this.fids[f].dbg_name]),h=await this.fs.Read(h,g,l),this.bus.send("9p-read-end",[this.fids[f].dbg_name,l]),h&&this.replybuffer.set(h,11);I(["w"],[l],this.replybuffer,7);this.BuildReply(e,d,4+l);this.SendReply(a);break;case 118:h=J(["w","d","w"],b,c);
661
+ f=h[0];g=h[1];l=h[2];h=this.fids[f].dbg_name;if(2===this.fids[f].type){this.SendError(d,"Setxattr not supported",95);this.SendReply(a);break}else await this.fs.Write(this.fids[f].inodeid,g,l,b.subarray(c.offset));this.bus.send("9p-write-end",[h,l]);I(["w"],[l],this.replybuffer,7);this.BuildReply(e,d,4);this.SendReply(a);break;case 74:h=J(["w","s","w","s"],b,c);f=await this.fs.Rename(this.fids[h[0]].inodeid,h[1],this.fids[h[2]].inodeid,h[3]);if(0>f){this.SendError(d,-2===f?"No such file or directory":
662
+ -1===f?"Operation not permitted":-39===f?"Directory not empty":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,d,0);this.SendReply(a);break;case 76:h=J(["w","s","w"],b,c);b=h[0];g=h[1];f=this.fs.Search(this.fids[b].inodeid,g);if(-1===f){this.SendError(d,"No such file or directory",2);this.SendReply(a);break}f=this.fs.Unlink(this.fids[b].inodeid,g);if(0>f){this.SendError(d,-39===f?"Directory not empty":-1===f?"Operation not permitted":"Unknown error: "+-f,-f);this.SendReply(a);break}this.BuildReply(e,
663
+ d,0);this.SendReply(a);break;case 100:f=J(["w","s"],b,c);this.msize!==f[0]&&(this.msize=f[0],this.replybuffer=new Uint8Array(Math.min(16777216,2*this.msize)));f=I(["w","s"],[this.msize,this.VERSION],this.replybuffer,7);this.BuildReply(e,d,f);this.SendReply(a);break;case 104:h=J(["w","w","s","s","w"],b,c);f=h[0];g=h[4];y(h[1]);this.fids[f]=this.Createfid(0,1,g,"");c=this.fs.GetInode(this.fids[f].inodeid);I(["Q"],[c.qid],this.replybuffer,7);this.BuildReply(e,d,13);this.SendReply(a);this.bus.send("9p-attach");
664
+ break;case 108:J(["h"],b,c);this.BuildReply(e,d,0);this.SendReply(a);break;case 110:h=J(["w","w","h"],b,c);f=h[0];l=h[1];m=h[2];if(0===m){this.fids[l]=this.Createfid(this.fids[f].inodeid,1,this.fids[f].uid,this.fids[f].dbg_name);I(["h"],[0],this.replybuffer,7);this.BuildReply(e,d,2);this.SendReply(a);break}g=[];for(h=0;h<m;h++)g.push("s");c=J(g,b,c);b=this.fids[f].inodeid;g=9;var n=0;for(h=0;h<m;h++){b=this.fs.Search(b,c[h]);if(-1===b)break;g+=I(["Q"],[this.fs.GetInode(b).qid],this.replybuffer,g);
665
+ n++;this.fids[l]=this.Createfid(b,1,this.fids[f].uid,c[h])}I(["h"],[n],this.replybuffer,7);this.BuildReply(e,d,g-7);this.SendReply(a);break;case 120:h=J(["w"],b,c);this.fids[h[0]]&&0<=this.fids[h[0]].inodeid&&(await this.fs.CloseInode(this.fids[h[0]].inodeid),this.fids[h[0]].inodeid=-1,this.fids[h[0]].type=-1);this.BuildReply(e,d,0);this.SendReply(a);break;case 32:h=J(["w","s","d","w"],b,c);f=h[0];this.fids[f].type=2;this.BuildReply(e,d,0);this.SendReply(a);break;case 30:J(["w","w","s"],b,c),this.SendError(d,
666
+ "Setxattr not supported",95),this.SendReply(a)}};function id(a,b){this.handle_fn=a;this.tag_bufchain=new Map;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,async c=>{const d=new Uint8Array(c.length_readable);c.get_next_blob(d);var e=J(["w","b","h"],d,{offset:0})[2];this.tag_bufchain.set(e,c);this.handle_fn(d,f=>{var g=J(["w","b","h"],f,{offset:0})[2];const h=this.tag_bufchain.get(g);
667
+ h?(h.set_next_blob(f),this.virtqueue.push_reply(h),this.virtqueue.flush_replies(),this.tag_bufchain.delete(g)):console.error("No bufchain found for tag: "+g)})});this.virtqueue=this.virtio.queues[0]}id.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.tag_bufchain;return a};id.prototype.set_state=function(a){this.configspace_tagname=a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];
668
+ this.tag_bufchain=a[3]};id.prototype.reset=function(){this.virtio.reset()};function jd(a,b){this.socket=void 0;this.cpu=b;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.tag_bufchain=new Map;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.virtio=ld(b,this.configspace_taglen,this.configspace_tagname,async c=>{const d=new Uint8Array(c.length_readable);
669
+ c.get_next_blob(d);const e=J(["w","b","h"],d,{offset:0})[2];this.tag_bufchain.set(e,c);this.send(d)});this.virtqueue=this.virtio.queues[0]}jd.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.tag_bufchain;return a};jd.prototype.set_state=function(a){this.configspace_tagname=a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.tag_bufchain=a[3]};jd.prototype.reset=function(){this.virtio.reset()};
670
+ jd.prototype.handle_message=function(a){a=new Uint8Array(a.data);const b=J(["w","b","h"],a,{offset:0})[2],c=this.tag_bufchain.get(b);c?(c.set_next_blob(a),this.virtqueue.push_reply(c),this.virtqueue.flush_replies(),this.tag_bufchain.delete(b)):console.error("Virtio9pProxy: No bufchain found for tag: "+b)};jd.prototype.handle_close=function(){this.destroyed||(this.connect(),setTimeout(this.connect.bind(this),this.reconnect_interval))};jd.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);
671
+ this.send_queue=[]};jd.prototype.handle_error=function(){};jd.prototype.destroy=function(){this.destroyed=!0;this.socket&&this.socket.close()};jd.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=
672
+ 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)}}};jd.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())};jd.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=
673
+ function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};export{};; export default module.exports.V86; export let {V86, CPU} = module.exports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v86",
3
- "version": "0.5.353+g02e4588",
3
+ "version": "0.5.355+gf7011b0",
4
4
  "license": "BSD-2-Clause",
5
5
  "description": "x86 PC emulator and x86-to-wasm JIT, running in the browser",
6
6
  "homepage": "https://copy.sh/v86/",