v86 0.5.277 → 0.5.278
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.
- package/build/libv86-debug.js +38 -44
- package/build/libv86-debug.mjs +81 -81
- package/build/libv86.js +4 -4
- package/build/libv86.mjs +12 -12
- package/package.json +1 -1
package/build/libv86-debug.js
CHANGED
|
@@ -7150,20 +7150,14 @@ function $VirtioConsole$$module$src$virtio_console$$($cpu$jscomp$18$$, $bus$jsco
|
|
|
7150
7150
|
this.bus.send("virtio-console" + $port$jscomp$4$$ + "-output-bytes", $buffer$jscomp$42$$);
|
|
7151
7151
|
this.Ack($queue_id$jscomp$1$$, $bufchain$$);
|
|
7152
7152
|
}
|
|
7153
|
-
}, $
|
|
7154
|
-
|
|
7155
|
-
$dbg_assert$$module$src$log$$(!1, "VirtioConsole Notified for wrong queue: " + $queue$jscomp$1_queue_id$jscomp$2$$ + " (expected queue_id of 2)");
|
|
7156
|
-
} else {
|
|
7157
|
-
for ($queue$jscomp$1_queue_id$jscomp$2$$ = this.virtio.queues[$queue$jscomp$1_queue_id$jscomp$2$$]; $queue$jscomp$1_queue_id$jscomp$2$$.count_requests() > $queue$jscomp$1_queue_id$jscomp$2$$.size - 2;) {
|
|
7158
|
-
$queue$jscomp$1_queue_id$jscomp$2$$.pop_request();
|
|
7159
|
-
}
|
|
7160
|
-
}
|
|
7153
|
+
}, $queue_id$jscomp$2$$ => {
|
|
7154
|
+
2 !== $queue_id$jscomp$2$$ && $dbg_assert$$module$src$log$$(!1, "VirtioConsole Notified for wrong queue: " + $queue_id$jscomp$2$$ + " (expected queue_id of 2)");
|
|
7161
7155
|
}, $queue_id$jscomp$3$$ => {
|
|
7162
7156
|
if (3 !== $queue_id$jscomp$3$$) {
|
|
7163
7157
|
$dbg_assert$$module$src$log$$(!1, "VirtioConsole Notified for wrong queue: " + $queue_id$jscomp$3$$ + " (expected queue_id of 3)");
|
|
7164
7158
|
} else {
|
|
7165
|
-
for (var $queue$jscomp$
|
|
7166
|
-
var $bufchain$jscomp$1_i$jscomp$80$$ = $queue$jscomp$
|
|
7159
|
+
for (var $queue$jscomp$1$$ = this.virtio.queues[$queue_id$jscomp$3$$]; $queue$jscomp$1$$.has_request();) {
|
|
7160
|
+
var $bufchain$jscomp$1_i$jscomp$80$$ = $queue$jscomp$1$$.pop_request(), $buffer$jscomp$43_port$jscomp$5$$ = new Uint8Array($bufchain$jscomp$1_i$jscomp$80$$.length_readable);
|
|
7167
7161
|
$bufchain$jscomp$1_i$jscomp$80$$.get_next_blob($buffer$jscomp$43_port$jscomp$5$$);
|
|
7168
7162
|
var $event$jscomp$12_parts$jscomp$5$$ = $Unmarshall$$module$lib$marshall$$(["w", "h", "h"], $buffer$jscomp$43_port$jscomp$5$$, {offset:0});
|
|
7169
7163
|
$buffer$jscomp$43_port$jscomp$5$$ = $event$jscomp$12_parts$jscomp$5$$[0];
|
|
@@ -7200,8 +7194,8 @@ function $VirtioConsole$$module$src$virtio_console$$($cpu$jscomp$18$$, $bus$jsco
|
|
|
7200
7194
|
for (let $port$jscomp$6$$ = 0; $port$jscomp$6$$ < this.ports; ++$port$jscomp$6$$) {
|
|
7201
7195
|
const $queue_id$jscomp$4$$ = 0 === $port$jscomp$6$$ ? 0 : 2 * $port$jscomp$6$$ + 2;
|
|
7202
7196
|
this.bus.register("virtio-console" + $port$jscomp$6$$ + "-input-bytes", function($data$jscomp$180$$) {
|
|
7203
|
-
var $bufchain$jscomp$2_queue$jscomp$
|
|
7204
|
-
$bufchain$jscomp$2_queue$jscomp$
|
|
7197
|
+
var $bufchain$jscomp$2_queue$jscomp$2$$ = this.virtio.queues[$queue_id$jscomp$4$$];
|
|
7198
|
+
$bufchain$jscomp$2_queue$jscomp$2$$.has_request() && ($bufchain$jscomp$2_queue$jscomp$2$$ = $bufchain$jscomp$2_queue$jscomp$2$$.pop_request(), this.Send($queue_id$jscomp$4$$, $bufchain$jscomp$2_queue$jscomp$2$$, new Uint8Array($data$jscomp$180$$)));
|
|
7205
7199
|
}, this);
|
|
7206
7200
|
this.bus.register("virtio-console" + $port$jscomp$6$$ + "-resize", function($size$jscomp$36$$) {
|
|
7207
7201
|
0 === $port$jscomp$6$$ && (this.cols = $size$jscomp$36$$[0], this.rows = $size$jscomp$36$$[1]);
|
|
@@ -9158,9 +9152,9 @@ function $VirtioNet$$module$src$virtio_net$$($cpu$jscomp$23$$, $bus$jscomp$23_qu
|
|
|
9158
9152
|
this.virtio = new $VirtIO$$module$src$virtio$$($cpu$jscomp$23$$, {name:"virtio-net", pci_id:80, device_id:4161, subsystem_device_id:1, common:{initial_port:51200, queues:$bus$jscomp$23_queues$jscomp$1$$, features:[5, 16, 22, 3, 17, 23, 32, ], on_driver_ok:() => {
|
|
9159
9153
|
}, }, notification:{initial_port:51456, single_handler:!1, handlers:[() => {
|
|
9160
9154
|
}, $queue_id$jscomp$8$$ => {
|
|
9161
|
-
const $queue$jscomp$
|
|
9162
|
-
for (; $queue$jscomp$
|
|
9163
|
-
const $bufchain$jscomp$8$$ = $queue$jscomp$
|
|
9155
|
+
const $queue$jscomp$4$$ = this.virtio.queues[$queue_id$jscomp$8$$];
|
|
9156
|
+
for (; $queue$jscomp$4$$.has_request();) {
|
|
9157
|
+
const $bufchain$jscomp$8$$ = $queue$jscomp$4$$.pop_request(), $buffer$jscomp$52$$ = new Uint8Array($bufchain$jscomp$8$$.length_readable);
|
|
9164
9158
|
$bufchain$jscomp$8$$.get_next_blob($buffer$jscomp$52$$);
|
|
9165
9159
|
this.bus.send("net" + this.id + "-send", $buffer$jscomp$52$$.subarray(12));
|
|
9166
9160
|
this.bus.send("eth-transmit-end", [$buffer$jscomp$52$$.length - 12]);
|
|
@@ -9171,8 +9165,8 @@ function $VirtioNet$$module$src$virtio_net$$($cpu$jscomp$23$$, $bus$jscomp$23_qu
|
|
|
9171
9165
|
if ($queue_id$jscomp$9$$ !== 2 * this.pairs) {
|
|
9172
9166
|
$dbg_assert$$module$src$log$$(!1, "VirtioNet Notified for wrong queue: " + $queue_id$jscomp$9$$ + " (expected queue_id of 3)");
|
|
9173
9167
|
} else {
|
|
9174
|
-
for (var $queue$jscomp$
|
|
9175
|
-
const $bufchain$jscomp$9$$ = $queue$jscomp$
|
|
9168
|
+
for (var $queue$jscomp$5$$ = this.virtio.queues[$queue_id$jscomp$9$$]; $queue$jscomp$5$$.has_request();) {
|
|
9169
|
+
const $bufchain$jscomp$9$$ = $queue$jscomp$5$$.pop_request();
|
|
9176
9170
|
var $buffer$jscomp$53_data$jscomp$208$$ = new Uint8Array($bufchain$jscomp$9$$.length_readable);
|
|
9177
9171
|
$bufchain$jscomp$9$$.get_next_blob($buffer$jscomp$53_data$jscomp$208$$);
|
|
9178
9172
|
var $command_parts$jscomp$6$$ = $Unmarshall$$module$lib$marshall$$(["b", "b"], $buffer$jscomp$53_data$jscomp$208$$, {offset:0});
|
|
@@ -9201,13 +9195,13 @@ function $VirtioNet$$module$src$virtio_net$$($cpu$jscomp$23$$, $bus$jscomp$23_qu
|
|
|
9201
9195
|
}, }, {bytes:2, name:"max_pairs", read:() => this.pairs, write:() => {
|
|
9202
9196
|
}, }, {bytes:2, name:"mtu", read:() => 1500, write:() => {
|
|
9203
9197
|
}, }])}, });
|
|
9204
|
-
this.bus.register("net" + this.id + "-receive", $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9205
|
-
this.bus.send("eth-receive-end", [$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9206
|
-
const $with_header$$ = new Uint8Array(12 + $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9198
|
+
this.bus.register("net" + this.id + "-receive", $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$ => {
|
|
9199
|
+
this.bus.send("eth-receive-end", [$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$.length]);
|
|
9200
|
+
const $with_header$$ = new Uint8Array(12 + $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$.byteLength);
|
|
9207
9201
|
(new DataView($with_header$$.buffer, $with_header$$.byteOffset, $with_header$$.byteLength)).setInt16(10, 1);
|
|
9208
|
-
$with_header$$.set($bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9209
|
-
$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9210
|
-
$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$
|
|
9202
|
+
$with_header$$.set($bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$, 12);
|
|
9203
|
+
$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$ = this.virtio.queues[0];
|
|
9204
|
+
$bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$.has_request() ? ($bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$ = $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$.pop_request(), $bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$.set_next_blob($with_header$$), this.virtio.queues[0].push_reply($bufchain$jscomp$10_data$jscomp$213_queue$jscomp$6$$), this.virtio.queues[0].flush_replies()) : console.log("No buffer to write into!");
|
|
9211
9205
|
}, this);
|
|
9212
9206
|
}
|
|
9213
9207
|
$VirtioNet$$module$src$virtio_net$$.prototype.get_state = function() {
|
|
@@ -10368,9 +10362,9 @@ function $VirtioBalloon$$module$src$virtio_balloon$$($cpu$jscomp$25$$, $bus$jsco
|
|
|
10368
10362
|
this.virtio = new $VirtIO$$module$src$virtio$$($cpu$jscomp$25$$, {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:() => {
|
|
10369
10363
|
$dbg_log$$module$src$log$$("Balloon setup", 2048);
|
|
10370
10364
|
}, }, notification:{initial_port:55552, single_handler:!1, handlers:[$queue_id$jscomp$12$$ => {
|
|
10371
|
-
const $queue$jscomp$
|
|
10372
|
-
for (; $queue$jscomp$
|
|
10373
|
-
var $bufchain$jscomp$13_n$jscomp$14$$ = $queue$jscomp$
|
|
10365
|
+
const $queue$jscomp$7$$ = this.virtio.queues[$queue_id$jscomp$12$$];
|
|
10366
|
+
for (; $queue$jscomp$7$$.has_request();) {
|
|
10367
|
+
var $bufchain$jscomp$13_n$jscomp$14$$ = $queue$jscomp$7$$.pop_request();
|
|
10374
10368
|
const $buffer$jscomp$57$$ = new Uint8Array($bufchain$jscomp$13_n$jscomp$14$$.length_readable);
|
|
10375
10369
|
$bufchain$jscomp$13_n$jscomp$14$$.get_next_blob($buffer$jscomp$57$$);
|
|
10376
10370
|
this.virtio.queues[$queue_id$jscomp$12$$].push_reply($bufchain$jscomp$13_n$jscomp$14$$);
|
|
@@ -10379,23 +10373,23 @@ function $VirtioBalloon$$module$src$virtio_balloon$$($cpu$jscomp$25$$, $bus$jsco
|
|
|
10379
10373
|
}
|
|
10380
10374
|
this.virtio.queues[$queue_id$jscomp$12$$].flush_replies();
|
|
10381
10375
|
}, $queue_id$jscomp$13$$ => {
|
|
10382
|
-
var $bufchain$jscomp$14_queue$jscomp$
|
|
10383
|
-
if ($bufchain$jscomp$14_queue$jscomp$
|
|
10384
|
-
$bufchain$jscomp$14_queue$jscomp$
|
|
10385
|
-
const $buffer$jscomp$58$$ = new Uint8Array($bufchain$jscomp$14_queue$jscomp$
|
|
10386
|
-
$bufchain$jscomp$14_queue$jscomp$
|
|
10376
|
+
var $bufchain$jscomp$14_queue$jscomp$8$$ = this.virtio.queues[$queue_id$jscomp$13$$];
|
|
10377
|
+
if ($bufchain$jscomp$14_queue$jscomp$8$$.has_request()) {
|
|
10378
|
+
$bufchain$jscomp$14_queue$jscomp$8$$ = $bufchain$jscomp$14_queue$jscomp$8$$.pop_request();
|
|
10379
|
+
const $buffer$jscomp$58$$ = new Uint8Array($bufchain$jscomp$14_queue$jscomp$8$$.length_readable);
|
|
10380
|
+
$bufchain$jscomp$14_queue$jscomp$8$$.get_next_blob($buffer$jscomp$58$$);
|
|
10387
10381
|
let $result$jscomp$22$$ = {};
|
|
10388
|
-
for (let $i$jscomp$88$$ = 0; $i$jscomp$88$$ < $bufchain$jscomp$14_queue$jscomp$
|
|
10382
|
+
for (let $i$jscomp$88$$ = 0; $i$jscomp$88$$ < $bufchain$jscomp$14_queue$jscomp$8$$.length_readable; $i$jscomp$88$$ += 10) {
|
|
10389
10383
|
let [$cat$$, $value$jscomp$182$$] = $Unmarshall$$module$lib$marshall$$(["h", "d"], $buffer$jscomp$58$$, {offset:$i$jscomp$88$$});
|
|
10390
10384
|
$result$jscomp$22$$[$STAT_NAMES$$module$src$virtio_balloon$$[$cat$$]] = $value$jscomp$182$$;
|
|
10391
10385
|
}
|
|
10392
|
-
this.virtio.queues[$queue_id$jscomp$13$$].push_reply($bufchain$jscomp$14_queue$jscomp$
|
|
10386
|
+
this.virtio.queues[$queue_id$jscomp$13$$].push_reply($bufchain$jscomp$14_queue$jscomp$8$$);
|
|
10393
10387
|
this.stats_cb && this.stats_cb($result$jscomp$22$$);
|
|
10394
10388
|
}
|
|
10395
10389
|
}, $queue_id$jscomp$14$$ => {
|
|
10396
|
-
const $queue$jscomp$
|
|
10397
|
-
for (; $queue$jscomp$
|
|
10398
|
-
const $bufchain$jscomp$15$$ = $queue$jscomp$
|
|
10390
|
+
const $queue$jscomp$9$$ = this.virtio.queues[$queue_id$jscomp$14$$];
|
|
10391
|
+
for (; $queue$jscomp$9$$.has_request();) {
|
|
10392
|
+
const $bufchain$jscomp$15$$ = $queue$jscomp$9$$.pop_request();
|
|
10399
10393
|
if (0 < $bufchain$jscomp$15$$.length_readable) {
|
|
10400
10394
|
var $buffer$jscomp$59_cmd$jscomp$11_i$jscomp$89$$ = new Uint8Array($bufchain$jscomp$15$$.length_readable);
|
|
10401
10395
|
$bufchain$jscomp$15$$.get_next_blob($buffer$jscomp$59_cmd$jscomp$11_i$jscomp$89$$);
|
|
@@ -10443,10 +10437,10 @@ $VirtioBalloon$$module$src$virtio_balloon$$.prototype.set_state = function($stat
|
|
|
10443
10437
|
this.num_pages = $state$jscomp$55$$[1];
|
|
10444
10438
|
this.actual = $state$jscomp$55$$[2];
|
|
10445
10439
|
};
|
|
10446
|
-
$VirtioBalloon$$module$src$virtio_balloon$$.prototype.GetStats = function($data$jscomp$218_queue$jscomp$
|
|
10447
|
-
this.stats_cb = $data$jscomp$218_queue$jscomp$
|
|
10448
|
-
for ($data$jscomp$218_queue$jscomp$
|
|
10449
|
-
const $bufchain$jscomp$16$$ = $data$jscomp$218_queue$jscomp$
|
|
10440
|
+
$VirtioBalloon$$module$src$virtio_balloon$$.prototype.GetStats = function($data$jscomp$218_queue$jscomp$10$$) {
|
|
10441
|
+
this.stats_cb = $data$jscomp$218_queue$jscomp$10$$;
|
|
10442
|
+
for ($data$jscomp$218_queue$jscomp$10$$ = this.virtio.queues[2]; $data$jscomp$218_queue$jscomp$10$$.has_request();) {
|
|
10443
|
+
const $bufchain$jscomp$16$$ = $data$jscomp$218_queue$jscomp$10$$.pop_request();
|
|
10450
10444
|
this.virtio.queues[2].push_reply($bufchain$jscomp$16$$);
|
|
10451
10445
|
}
|
|
10452
10446
|
this.virtio.queues[2].flush_replies();
|
|
@@ -11842,8 +11836,8 @@ $VirtIO$$module$src$virtio$$.prototype.set_state = function($state$jscomp$63$$)
|
|
|
11842
11836
|
this.isr_status = $state$jscomp$63$$[8];
|
|
11843
11837
|
this.queue_select = $state$jscomp$63$$[9];
|
|
11844
11838
|
let $i$jscomp$116$$ = 0;
|
|
11845
|
-
for (const $queue$jscomp$
|
|
11846
|
-
this.queues[$i$jscomp$116$$].set_state($queue$jscomp$
|
|
11839
|
+
for (const $queue$jscomp$11$$ of $state$jscomp$63$$.slice(10)) {
|
|
11840
|
+
this.queues[$i$jscomp$116$$].set_state($queue$jscomp$11$$), $i$jscomp$116$$++;
|
|
11847
11841
|
}
|
|
11848
11842
|
this.queue_selected = this.queues[this.queue_select] || null;
|
|
11849
11843
|
};
|
|
@@ -11853,8 +11847,8 @@ $VirtIO$$module$src$virtio$$.prototype.reset = function() {
|
|
|
11853
11847
|
this.features_ok = !0;
|
|
11854
11848
|
this.queue_select = this.device_status = 0;
|
|
11855
11849
|
this.queue_selected = this.queues[0];
|
|
11856
|
-
for (const $queue$jscomp$
|
|
11857
|
-
$queue$jscomp$
|
|
11850
|
+
for (const $queue$jscomp$12$$ of this.queues) {
|
|
11851
|
+
$queue$jscomp$12$$.reset();
|
|
11858
11852
|
}
|
|
11859
11853
|
this.config_has_changed = !1;
|
|
11860
11854
|
this.config_generation = 0;
|
package/build/libv86-debug.mjs
CHANGED
|
@@ -398,87 +398,87 @@ function(a){this.data_port_write(a);this.dcfg&1&&this.data_port_write(a>>8)};Dc.
|
|
|
398
398
|
1)||a[0]!==this.mac[0]||a[1]!==this.mac[1]||a[2]!==this.mac[2]||a[3]!==this.mac[3]||a[4]!==this.mac[4]||a[5]!==this.mac[5]))){this.mac_address_in_state&&(a=new Uint8Array(a),Bc(a,this.mac,this.mac_address_in_state));var b=this.curpg<<8,c=Math.max(60,a.length)+4,d=b+4,e=this.curpg+1+(c>>8),f=b+c,g=1+(c>>8),k=this.boundary>this.curpg?this.boundary-this.curpg:this.pstop-this.curpg+this.boundary-this.pstart;k<g&&0!==this.boundary?B("Buffer full, dropping packet pstart="+n(this.pstart)+" pstop="+n(this.pstop)+
|
|
399
399
|
" curpg="+n(this.curpg)+" needed="+n(g)+" boundary="+n(this.boundary)+" available="+n(k),1048576):(f>this.pstop<<8?(l(60<=a.length),f=(this.pstop<<8)-d,l(0<=f),this.memory.set(a.subarray(0,f),d),this.memory.set(a.subarray(f),this.pstart<<8),B("rcv cut="+n(f),1048576)):(this.memory.set(a,d),60>a.length&&this.memory.fill(0,d+a.length,d+60)),e>=this.pstop&&(e+=this.pstart-this.pstop),this.memory[b]=1,this.memory[b+1]=e,this.memory[b+2]=c,this.memory[b+3]=c>>8,this.curpg=e,B("rcv offset="+n(b)+" len="+
|
|
400
400
|
n(c)+" next="+n(e),1048576),this.do_interrupt(1))}};Dc.prototype.get_page=function(){return this.cr>>6&3};function Ec(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c<this.ports;++c)b.push({size_supported:16,notify_offset:0}),b.push({size_supported:8,notify_offset:1});this.virtio=new Fc(a,{name:"virtio-console",pci_id:96,device_id:4163,
|
|
401
|
-
subsystem_device_id:3,common:{initial_port:47104,queues:b,features:[0,1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},c=>{
|
|
402
|
-
c
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
a.io.
|
|
409
|
-
|
|
410
|
-
a[
|
|
411
|
-
a[
|
|
412
|
-
a[
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
this.
|
|
418
|
-
n(
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
this
|
|
433
|
-
|
|
434
|
-
handler:this.exec_unimplemented},{code:
|
|
435
|
-
mask:
|
|
436
|
-
handler:this.exec_unimplemented},{code:
|
|
437
|
-
|
|
438
|
-
this.sra
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
this.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
[
|
|
469
|
-
[
|
|
470
|
-
[
|
|
471
|
-
|
|
472
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
255});a.io.register_read(this.command_base|
|
|
476
|
-
a.io.register_write(this.command_base|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
401
|
+
subsystem_device_id:3,common:{initial_port:47104,queues:b,features:[0,1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},c=>{2!==c&&l(!1,"VirtioConsole Notified for wrong queue: "+c+" (expected queue_id of 2)")},c=>{if(3!==c)l(!1,"VirtioConsole Notified for wrong queue: "+
|
|
402
|
+
c+" (expected queue_id of 3)");else for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),f=new Uint8Array(e.length_readable);e.get_next_blob(f);var g=J(["w","h","h"],f,{offset:0});f=g[0];g=g[1];this.Ack(c,e);switch(g){case 0:for(e=0;e<this.ports;++e)this.SendEvent(e,1,0);break;case 3:this.Ack(c,e);this.SendEvent(f,4,1);this.SendName(f,"virtio-"+f);this.SendEvent(f,6,1);break;case 6:this.Ack(c,e);0===f&&this.SendWindowSize(f);break;default:l(!1," VirtioConsole received unknown event: "+
|
|
403
|
+
g[1]);return}}}]},isr_status:{initial_port:46848},device_specific:{initial_port:46592,struct:[{bytes:2,name:"cols",read:()=>this.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows,write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{l(!1,"Emergency write!")}}]}});for(let c=0;c<this.ports;++c){const d=0===c?0:2*c+2;this.bus.register("virtio-console"+c+"-input-bytes",function(e){var f=this.virtio.queues[d];f.has_request()&&
|
|
404
|
+
(f=f.pop_request(),this.Send(d,f,new Uint8Array(e)))},this);this.bus.register("virtio-console"+c+"-resize",function(e){0===c&&(this.cols=e[0],this.rows=e[1]);this.virtio.queues[2].is_configured()&&this.virtio.queues[2].has_request()&&this.SendWindowSize(c,e[0],e[1])},this)}}Ec.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(12);I(["w","h","h","h","h"],[a,5,0,c,b],e,0);this.Send(2,d,e)};Ec.prototype.SendName=function(a,
|
|
405
|
+
b){const c=this.virtio.queues[2].pop_request();b=(new TextEncoder).encode(b);const d=new Uint8Array(8+b.length+1);I(["w","h","h"],[a,7,1],d,0);for(a=0;a<b.length;++a)d[a+8]=b[a];d[8+b.length]=0;this.Send(2,c,d)};Ec.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};Ec.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=a[3]};Ec.prototype.reset=function(){this.virtio.reset()};Ec.prototype.SendEvent=
|
|
406
|
+
function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);I(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};Ec.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};Ec.prototype.Ack=function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function Gc(a,b){this.cpu=a;this.bus=b;this.reset();this.bus.register("keyboard-code",function(c){this.kbd_send_code(c)},
|
|
407
|
+
this);this.bus.register("mouse-click",function(c){this.mouse_send_click(c[0],c[1],c[2])},this);this.bus.register("mouse-delta",function(c){this.mouse_send_delta(c[0],c[1])},this);this.bus.register("mouse-wheel",function(c){this.wheel_movement-=c[0];this.wheel_movement-=2*c[1];this.wheel_movement=Math.min(7,Math.max(-8,this.wheel_movement));this.send_mouse_packet(0,0)},this);a.io.register_read(96,this,this.port60_read);a.io.register_read(100,this,this.port64_read);a.io.register_write(96,this,this.port60_write);
|
|
408
|
+
a.io.register_write(100,this,this.port64_write)}Gc.prototype.reset=function(){this.use_mouse=this.enable_mouse_stream=!1;this.have_mouse=!0;this.mouse_clicks=this.mouse_delta_y=this.mouse_delta_x=0;this.have_keyboard=!0;this.next_read_resolution=this.next_read_rate=this.next_handle_scan_code_set=this.next_read_led=this.next_read_sample=this.next_is_mouse_command=this.enable_keyboard_stream=!1;this.kbd_buffer=new na(1024);this.last_port60_byte=0;this.sample_rate=100;this.mouse_id=this.mouse_detect_state=
|
|
409
|
+
0;this.mouse_reset_workaround=!1;this.wheel_movement=0;this.resolution=4;this.scaling2=!1;this.last_mouse_packet=-1;this.mouse_buffer=new na(1024);this.next_byte_is_aux=this.next_byte_is_ready=!1;this.command_register=5;this.controller_output_port=0;this.read_controller_output_port=this.read_command_register=this.read_output_register=!1};Gc.prototype.get_state=function(){var a=[];a[0]=this.enable_mouse_stream;a[1]=this.use_mouse;a[2]=this.have_mouse;a[3]=this.mouse_delta_x;a[4]=this.mouse_delta_y;
|
|
410
|
+
a[5]=this.mouse_clicks;a[6]=this.have_keyboard;a[7]=this.enable_keyboard_stream;a[8]=this.next_is_mouse_command;a[9]=this.next_read_sample;a[10]=this.next_read_led;a[11]=this.next_handle_scan_code_set;a[12]=this.next_read_rate;a[13]=this.next_read_resolution;a[15]=this.last_port60_byte;a[16]=this.sample_rate;a[17]=this.resolution;a[18]=this.scaling2;a[20]=this.command_register;a[21]=this.read_output_register;a[22]=this.read_command_register;a[23]=this.controller_output_port;a[24]=this.read_controller_output_port;
|
|
411
|
+
a[25]=this.mouse_id;a[26]=this.mouse_detect_state;a[27]=this.mouse_reset_workaround;return a};Gc.prototype.set_state=function(a){this.enable_mouse_stream=a[0];this.use_mouse=a[1];this.have_mouse=a[2];this.mouse_delta_x=a[3];this.mouse_delta_y=a[4];this.mouse_clicks=a[5];this.have_keyboard=a[6];this.enable_keyboard_stream=a[7];this.next_is_mouse_command=a[8];this.next_read_sample=a[9];this.next_read_led=a[10];this.next_handle_scan_code_set=a[11];this.next_read_rate=a[12];this.next_read_resolution=
|
|
412
|
+
a[13];this.last_port60_byte=a[15];this.sample_rate=a[16];this.resolution=a[17];this.scaling2=a[18];this.command_register=a[20];this.read_output_register=a[21];this.read_command_register=a[22];this.controller_output_port=a[23];this.read_controller_output_port=a[24];this.mouse_id=a[25]||0;this.mouse_detect_state=a[26]||0;this.mouse_reset_workaround=a[27]||!1;this.next_byte_is_aux=this.next_byte_is_ready=!1;this.kbd_buffer.clear();this.mouse_buffer.clear();this.bus.send("mouse-enable",this.use_mouse)};
|
|
413
|
+
Gc.prototype.raise_irq=function(){this.next_byte_is_ready||(this.kbd_buffer.length?this.kbd_irq():this.mouse_buffer.length&&this.mouse_irq())};Gc.prototype.mouse_irq=function(){this.next_byte_is_aux=this.next_byte_is_ready=!0;this.command_register&2&&(B("Mouse irq",64),this.cpu.device_lower_irq(12),this.cpu.device_raise_irq(12))};Gc.prototype.kbd_irq=function(){this.next_byte_is_ready=!0;this.next_byte_is_aux=!1;this.command_register&1&&(B("Keyboard irq",64),this.cpu.device_lower_irq(1),this.cpu.device_raise_irq(1))};
|
|
414
|
+
Gc.prototype.kbd_send_code=function(a){this.enable_keyboard_stream&&(B("adding kbd code: "+n(a),64),this.kbd_buffer.push(a),this.raise_irq())};Gc.prototype.mouse_send_delta=function(a,b){this.have_mouse&&this.use_mouse&&(this.mouse_delta_x+=1*a,this.mouse_delta_y+=1*b,this.enable_mouse_stream&&(a=this.mouse_delta_x|0,b=this.mouse_delta_y|0,a||b))&&(this.mouse_delta_x-=a,this.mouse_delta_y-=b,this.send_mouse_packet(a,b))};Gc.prototype.mouse_send_click=function(a,b,c){this.have_mouse&&this.use_mouse&&
|
|
415
|
+
(this.mouse_clicks=a|c<<1|b<<2,this.enable_mouse_stream&&this.send_mouse_packet(0,0))};Gc.prototype.send_mouse_packet=function(a,b){var c=(0>b)<<5|(0>a)<<4|8|this.mouse_clicks;this.last_mouse_packet=Date.now();this.mouse_buffer.push(c);this.mouse_buffer.push(a);this.mouse_buffer.push(b);4===this.mouse_id?(this.mouse_buffer.push(0|this.wheel_movement&15),this.wheel_movement=0):3===this.mouse_id&&(this.mouse_buffer.push(this.wheel_movement&255),this.wheel_movement=0);this.raise_irq()};Gc.prototype.apply_scaling2=
|
|
416
|
+
function(a){var b=a>>31;switch(Math.abs(a)){case 0:case 1:case 3:return a;case 2:return b;case 4:return 6*b;case 5:return 9*b;default:return a<<1}};Gc.prototype.port60_read=function(){this.next_byte_is_ready=!1;if(!this.kbd_buffer.length&&!this.mouse_buffer.length)return B("Port 60 read: Empty",64),this.last_port60_byte;this.next_byte_is_aux?(this.cpu.device_lower_irq(12),this.last_port60_byte=this.mouse_buffer.shift(),B("Port 60 read (mouse): "+n(this.last_port60_byte),64)):(this.cpu.device_lower_irq(1),
|
|
417
|
+
this.last_port60_byte=this.kbd_buffer.shift(),B("Port 60 read (kbd) : "+n(this.last_port60_byte),64));(this.kbd_buffer.length||this.mouse_buffer.length)&&this.raise_irq();return this.last_port60_byte};Gc.prototype.port64_read=function(){var a=16;this.next_byte_is_ready&&(a|=1);this.next_byte_is_aux&&(a|=32);B("port 64 read: "+n(a),64);return a};Gc.prototype.port60_write=function(a){B("port 60 write: "+n(a),64);if(this.read_command_register)this.command_register=a,this.read_command_register=!1,B("Keyboard command register = "+
|
|
418
|
+
n(this.command_register),64);else if(this.read_output_register)this.read_output_register=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(a),this.mouse_irq();else if(this.next_read_sample){this.next_read_sample=!1;this.mouse_buffer.clear();this.mouse_buffer.push(250);this.sample_rate=a;switch(this.mouse_detect_state){case -1:60===a?(this.mouse_reset_workaround=!0,this.mouse_detect_state=0):(this.mouse_reset_workaround=!1,this.mouse_detect_state=200===a?1:0);break;case 0:200===a&&(this.mouse_detect_state=
|
|
419
|
+
1);break;case 1:this.mouse_detect_state=100===a?2:200===a?3:0;break;case 2:80===a&&(this.mouse_id=3);this.mouse_detect_state=-1;break;case 3:80===a&&(this.mouse_id=4),this.mouse_detect_state=-1}B("mouse sample rate: "+n(a)+", mouse id: "+n(this.mouse_id),64);this.sample_rate||(B("invalid sample rate, reset to 100",64),this.sample_rate=100);this.mouse_irq()}else if(this.next_read_resolution)this.next_read_resolution=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(250),3<a?(this.resolution=4,B("invalid resolution, resetting to 4",
|
|
420
|
+
64)):(this.resolution=1<<a,B("resolution: "+this.resolution,64)),this.mouse_irq();else if(this.next_read_led)this.next_read_led=!1,this.kbd_buffer.push(250),this.kbd_irq();else if(this.next_handle_scan_code_set)this.next_handle_scan_code_set=!1,this.kbd_buffer.push(250),this.kbd_irq(),a||this.kbd_buffer.push(1);else if(this.next_read_rate)this.next_read_rate=!1,this.kbd_buffer.push(250),this.kbd_irq();else if(this.next_is_mouse_command){if(this.next_is_mouse_command=!1,B("Port 60 data register write: "+
|
|
421
|
+
n(a),64),this.have_mouse){this.kbd_buffer.clear();this.mouse_buffer.clear();this.mouse_buffer.push(250);switch(a){case 230:B("Scaling 1:1",64);this.scaling2=!1;break;case 231:B("Scaling 2:1",64);this.scaling2=!0;break;case 232:this.next_read_resolution=!0;break;case 233:this.send_mouse_packet(0,0);break;case 235:B("unimplemented request single packet",64);this.send_mouse_packet(0,0);break;case 242:B("required id: "+n(this.mouse_id),64);this.mouse_buffer.push(this.mouse_id);this.mouse_clicks=this.mouse_delta_x=
|
|
422
|
+
this.mouse_delta_y=0;this.raise_irq();break;case 243:this.next_read_sample=!0;break;case 244:this.use_mouse=this.enable_mouse_stream=!0;this.bus.send("mouse-enable",!0);this.mouse_clicks=this.mouse_delta_x=this.mouse_delta_y=0;break;case 245:this.enable_mouse_stream=!1;break;case 246:this.enable_mouse_stream=!1;this.sample_rate=100;this.scaling2=!1;this.resolution=4;break;case 255:B("Mouse reset",64);this.mouse_buffer.push(170);this.mouse_buffer.push(0);this.use_mouse=!0;this.bus.send("mouse-enable",
|
|
423
|
+
!0);this.enable_mouse_stream=!1;this.sample_rate=100;this.scaling2=!1;this.resolution=4;this.mouse_reset_workaround||(this.mouse_id=0);this.mouse_clicks=this.mouse_delta_x=this.mouse_delta_y=0;break;default:B("Unimplemented mouse command: "+n(a),64)}this.mouse_irq()}}else if(this.read_controller_output_port)this.read_controller_output_port=!1,this.controller_output_port=a;else{B("Port 60 data register write: "+n(a),64);this.mouse_buffer.clear();this.kbd_buffer.clear();this.kbd_buffer.push(250);switch(a){case 237:this.next_read_led=
|
|
424
|
+
!0;break;case 240:this.next_handle_scan_code_set=!0;break;case 242:this.kbd_buffer.push(171);this.kbd_buffer.push(131);break;case 243:this.next_read_rate=!0;break;case 244:B("kbd enable scanning",64);this.enable_keyboard_stream=!0;break;case 245:B("kbd disable scanning",64);this.enable_keyboard_stream=!1;break;case 246:break;case 255:this.kbd_buffer.clear();this.kbd_buffer.push(250);this.kbd_buffer.push(170);this.kbd_buffer.push(0);break;default:B("Unimplemented keyboard command: "+n(a),64)}this.kbd_irq()}};
|
|
425
|
+
Gc.prototype.port64_write=function(a){B("port 64 write: "+n(a),64);switch(a){case 32:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(this.command_register);this.kbd_irq();break;case 96:this.read_command_register=!0;break;case 209:this.read_controller_output_port=!0;break;case 211:this.read_output_register=!0;break;case 212:this.next_is_mouse_command=!0;break;case 167:B("Disable second port",64);this.command_register|=32;break;case 168:B("Enable second port",64);this.command_register&=
|
|
426
|
+
-33;break;case 169:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(0);this.kbd_irq();break;case 170:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(85);this.kbd_irq();break;case 171:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(0);this.kbd_irq();break;case 173:B("Disable Keyboard",64);this.command_register|=16;break;case 174:B("Enable Keyboard",64);this.command_register&=-17;break;case 254:B("CPU reboot via PS2");this.cpu.reboot_internal();
|
|
427
|
+
break;default:B("port 64: Unimplemented command byte: "+n(a),64)}};const Hc=DataView.prototype,Ic={size:1,get:Hc.getUint8,set:Hc.setUint8},Jc={size:2,get:Hc.getUint16,set:Hc.setUint16},Q={size:4,get:Hc.getUint32,set:Hc.setUint32},Lc=Kc([{magic:Q},{class:Ic},{data:Ic},{version0:Ic},{osabi:Ic},{abiversion:Ic},{pad0:function(a){return{size:a,get:()=>-1}}(7)},{type:Jc},{machine:Jc},{version1:Q},{entry:Q},{phoff:Q},{shoff:Q},{flags:Q},{ehsize:Jc},{phentsize:Jc},{phnum:Jc},{shentsize:Jc},{shnum:Jc},{shstrndx:Jc}]);
|
|
428
|
+
console.assert(52===Lc.reduce((a,b)=>a+b.size,0));const Mc=Kc([{type:Q},{offset:Q},{vaddr:Q},{paddr:Q},{filesz:Q},{memsz:Q},{flags:Q},{align:Q}]);console.assert(32===Mc.reduce((a,b)=>a+b.size,0));const Nc=Kc([{name:Q},{type:Q},{flags:Q},{addr:Q},{offset:Q},{size:Q},{link:Q},{info:Q},{addralign:Q},{entsize:Q}]);console.assert(40===Nc.reduce((a,b)=>a+b.size,0));function Kc(a){return a.map(function(b){var c=Object.keys(b);console.assert(1===c.length);c=c[0];b=b[c];console.assert(0<b.size);return{name:c,
|
|
429
|
+
type:b,size:b.size,get:b.get,set:b.set}})}function Oc(a,b){const c={};let d=0;for(const e of b)b=e.get.call(a,d,!0),console.assert(void 0===c[e.name]),c[e.name]=b,d+=e.size;return[c,d]}function Pc(a,b,c){const d=[];let e=0;for(var f=0;f<c;f++){const [g,k]=Oc(new DataView(a.buffer,a.byteOffset+e,void 0),b);d.push(g);e+=k}return[d,e]}const Qc={[0]:0,[1]:525,[2]:525,[3]:350,[4]:350,[5]:350};function W(a,b,c,d){this.io=a.io;this.cpu=a;this.dma=a.devices.dma;this.cmd_table=this.build_cmd_lookup_table();
|
|
430
|
+
this.sra=0;this.srb=192;this.dor=12;this.tdr=0;this.msr=128;this.dsr=0;this.cmd_phase=1;this.cmd_flags=this.cmd_code=0;this.cmd_buffer=new Uint8Array(17);this.cmd_remaining=this.cmd_cursor=0;this.response_data=new Uint8Array(15);this.reset_sense_int_count=this.curr_drive_no=this.status1=this.status0=this.response_length=this.response_cursor=0;this.locked=!1;this.head_load_time=this.step_rate_interval=0;this.fdc_config=96;this.eot=this.precomp_trk=0;this.drives=[new Rc("fda",d?.fda,b,4),new Rc("fdb",
|
|
431
|
+
d?.fdb,c,4)];Object.seal(this);this.cpu.devices.rtc.cmos_write(16,this.drives[0].drive_type<<4|this.drives[1].drive_type);this.io.register_read(1008,this,this.read_reg_sra);this.io.register_read(1009,this,this.read_reg_srb);this.io.register_read(1010,this,this.read_reg_dor);this.io.register_read(1011,this,this.read_reg_tdr);this.io.register_read(1012,this,this.read_reg_msr);this.io.register_read(1013,this,this.read_reg_fifo);this.io.register_read(1015,this,this.read_reg_dir);this.io.register_write(1010,
|
|
432
|
+
this,this.write_reg_dor);this.io.register_write(1011,this,this.write_reg_tdr);this.io.register_write(1012,this,this.write_reg_dsr);this.io.register_write(1013,this,this.write_reg_fifo);this.io.register_write(1015,this,this.write_reg_ccr);B("floppy controller ready",8192)}W.prototype.build_cmd_lookup_table=function(){const a=[{code:6,mask:31,argc:8,name:"READ",handler:this.exec_read},{code:5,mask:63,argc:8,name:"WRITE",handler:this.exec_write},{code:15,mask:255,argc:2,name:"SEEK",handler:this.exec_seek},
|
|
433
|
+
{code:8,mask:255,argc:0,name:"SENSE INTERRUPT STATUS",handler:this.exec_sense_interrupt_status},{code:7,mask:255,argc:1,name:"RECALIBRATE",handler:this.exec_recalibrate},{code:13,mask:191,argc:5,name:"FORMAT TRACK",handler:this.exec_format_track},{code:2,mask:191,argc:8,name:"READ TRACK",handler:this.exec_unimplemented},{code:78,mask:255,argc:17,name:"RESTORE",handler:this.exec_unimplemented},{code:46,mask:255,argc:0,name:"SAVE",handler:this.exec_unimplemented},{code:12,mask:31,argc:8,name:"READ DELETED DATA",
|
|
434
|
+
handler:this.exec_unimplemented},{code:17,mask:31,argc:8,name:"SCAN EQUAL",handler:this.exec_unimplemented},{code:22,mask:31,argc:8,name:"VERIFY",handler:this.exec_unimplemented},{code:25,mask:31,argc:8,name:"SCAN LOW OR EQUAL",handler:this.exec_unimplemented},{code:29,mask:31,argc:8,name:"SCAN HIGH OR EQUAL",handler:this.exec_unimplemented},{code:9,mask:63,argc:8,name:"WRITE DELETED DATA",handler:this.exec_unimplemented},{code:10,mask:191,argc:1,name:"READ ID",handler:this.exec_read_id},{code:3,
|
|
435
|
+
mask:255,argc:2,name:"SPECIFY",handler:this.exec_specify},{code:4,mask:255,argc:1,name:"SENSE DRIVE STATUS",handler:this.exec_sense_drive_status},{code:18,mask:255,argc:1,name:"PERPENDICULAR MODE",handler:this.exec_perpendicular_mode},{code:19,mask:255,argc:3,name:"CONFIGURE",handler:this.exec_configure},{code:23,mask:255,argc:2,name:"POWERDOWN MODE",handler:this.exec_unimplemented},{code:51,mask:255,argc:1,name:"OPTION",handler:this.exec_unimplemented},{code:142,mask:255,argc:5,name:"DRIVE SPECIFICATION",
|
|
436
|
+
handler:this.exec_unimplemented},{code:143,mask:255,argc:2,name:"RELATIVE SEEK OUT",handler:this.exec_unimplemented},{code:205,mask:255,argc:10,name:"FORMAT AND WRITE",handler:this.exec_unimplemented},{code:207,mask:255,argc:2,name:"RELATIVE SEEK IN",handler:this.exec_unimplemented},{code:20,mask:127,argc:0,name:"LOCK",handler:this.exec_lock},{code:14,mask:255,argc:0,name:"DUMP REGISTERS",handler:this.exec_dump_regs},{code:16,mask:255,argc:0,name:"VERSION",handler:this.exec_version},{code:24,mask:255,
|
|
437
|
+
argc:0,name:"PART ID",handler:this.exec_part_id},{code:0,mask:0,argc:0,name:"UNKNOWN COMMAND",handler:this.exec_unimplemented}],b=Array(256);for(let c=a.length-1;0<=c;c--){const d=a[c];if(255===d.mask)b[d.code]=d;else for(let e=0;256>e;e++)(e&d.mask)===d.code&&(b[e]=d)}return b};W.prototype.raise_irq=function(a){this.sra&128||(this.cpu.device_raise_irq(6),this.sra|=128,B("IRQ raised, reason: "+a,8192));this.reset_sense_int_count=0};W.prototype.lower_irq=function(a){this.status0=0;this.sra&128&&(this.cpu.device_lower_irq(6),
|
|
438
|
+
this.sra&=-129,B("IRQ lowered, reason: "+a,8192))};W.prototype.set_curr_drive_no=function(a){this.curr_drive_no=a&1;return this.drives[this.curr_drive_no]};W.prototype.enter_command_phase=function(){this.cmd_phase=1;this.cmd_remaining=this.cmd_cursor=0;this.msr&=-81;this.msr|=128};W.prototype.enter_result_phase=function(a){this.cmd_phase=3;this.response_cursor=0;this.response_length=a;this.msr|=208};W.prototype.reset_fdc=function(){B("resetting controller",8192);this.lower_irq("controller reset");
|
|
439
|
+
this.sra=0;this.srb=192;this.dor=12;this.msr=128;this.curr_drive_no=0;this.status0|=192;this.response_length=this.response_cursor=0;this.drives[0].seek(0,0,1);this.drives[1].seek(0,0,1);this.enter_command_phase();this.raise_irq("controller reset");this.reset_sense_int_count=4};W.prototype.read_reg_sra=function(){B("SRA read: "+n(this.sra),8192);return this.sra};W.prototype.read_reg_srb=function(){B("SRB read: "+n(this.srb),8192);return this.srb};W.prototype.read_reg_dor=function(){const a=this.dor&
|
|
440
|
+
-4|this.curr_drive_no;B("DOR read: "+n(a),8192);return a};W.prototype.read_reg_tdr=function(){B("TDR read: "+n(this.tdr),8192);return this.tdr};W.prototype.read_reg_msr=function(){B("MSR read: "+n(this.msr),8192);this.dsr&=-65;this.dor|=4;return this.msr};W.prototype.read_reg_fifo=function(){this.dsr&=-65;if(!(this.msr&128&&this.msr&64))return B("FIFO read rejected: controller not ready for reading",8192),0;if(3!==this.cmd_phase)return B("FIFO read rejected: floppy controller not in RESULT phase, phase: "+
|
|
441
|
+
this.cmd_phase,8192),0;if(this.response_cursor<this.response_length){const a=this.response_data[this.response_cursor++];if(this.response_cursor===this.response_length){const b="end of "+this.cmd_table[this.cmd_code].name+" response";this.msr&=-129;this.enter_command_phase();this.lower_irq(b)}return a}B("FIFO read: empty",8192);return 0};W.prototype.read_reg_dir=function(){const a=this.drives[this.curr_drive_no].media_changed?128:0;B("DIR read: "+n(a),8192);return a};W.prototype.write_reg_dor=function(a){this.srb=
|
|
442
|
+
this.srb&-36|(a&16?1:0)|(a&32?2:0)|(a&1?32:0);this.dor&4?a&4||B("enter RESET state",8192):a&4&&(this.reset_fdc(),this.dsr&=-65,B("exit RESET state",8192));const b=a&3;B("DOR write: "+n(a)+", motors: "+n(a>>4)+", dma: "+!!(a&8)+", reset: "+!(a&4)+", drive: "+b,8192);1<b&&B("*** WARNING: floppy drive number "+b+" not implemented!",8192);this.curr_drive_no=b&1;this.dor=a};W.prototype.write_reg_tdr=function(a){this.dor&4?(B("TDR write: "+n(a),8192),this.tdr=a&4):B("TDR write "+n(a)+" rejected: Floppy controller in RESET mode!",
|
|
443
|
+
8192)};W.prototype.write_reg_dsr=function(a){this.dor&4?(B("DSR write: "+n(a),8192),a&128&&(this.dor&=-5,this.reset_fdc(),this.dor|=4),a&64&&this.reset_fdc(),this.dsr=a):B("DSR write: "+n(a)+" rejected: Floppy controller in RESET mode!",8192)};W.prototype.write_reg_fifo=function(a){this.dsr&=-65;if(this.dor&4)if(!(this.msr&128)||this.msr&64)B("FIFO write "+n(a)+" rejected: controller not ready for writing",8192);else if(1!==this.cmd_phase)B("FIFO write "+n(a)+" rejected: floppy controller not in COMMAND phase, phase: "+
|
|
444
|
+
this.cmd_phase,8192);else{if(0===this.cmd_remaining){var b=this.cmd_table[a];this.cmd_code=a;this.cmd_remaining=b.argc;this.cmd_flags=this.cmd_cursor=0;(6===b.code||5===b.code)&&this.cmd_code&128&&(this.cmd_flags|=1);this.cmd_remaining&&(this.msr|=128);this.msr|=16}else this.cmd_buffer[this.cmd_cursor++]=a,this.cmd_remaining--;if(0===this.cmd_remaining){this.cmd_phase=2;a=this.cmd_table[this.cmd_code];b=this.cmd_buffer.slice(0,this.cmd_cursor);const c=[];for(const d of b)c.push(n(d,2));B("FD command "+
|
|
445
|
+
n(this.cmd_code)+": "+a.name+"("+c.join(", ")+")",8192);a.handler.call(this,b)}}else B("FIFO write "+n(a)+" rejected: floppy controller in RESET mode!",8192)};W.prototype.write_reg_ccr=function(a){this.dor&4?(B("CCR write: "+n(a),8192),this.dsr=this.dsr&-4|a&3):B("CCR write: "+n(a)+" rejected: Floppy controller in RESET mode!",8192)};W.prototype.exec_unimplemented=function(){l(!1,"Unimplemented floppy command code "+n(this.cmd_code)+"!");this.status0=128;this.response_data[0]=this.status0;this.enter_result_phase(1)};
|
|
446
|
+
W.prototype.exec_read=function(a){this.start_read_write(a,!1)};W.prototype.exec_write=function(a){this.start_read_write(a,!0)};W.prototype.exec_seek=function(a){const b=this.set_curr_drive_no(a[0]&1);a=a[1];this.enter_command_phase();b.seek(b.curr_head,a,b.curr_sect);this.status0|=32;this.raise_irq("SEEK command")};W.prototype.exec_sense_interrupt_status=function(){const a=this.drives[this.curr_drive_no];let b;if(0<this.reset_sense_int_count)b=192|4-this.reset_sense_int_count--;else if(this.sra&128)b=
|
|
447
|
+
this.status0&-8|this.curr_drive_no;else{B("No interrupt pending, aborting SENSE INTERRUPT command!",8192);this.response_data[0]=128;this.enter_result_phase(1);return}this.response_data[0]=b;this.response_data[1]=a.curr_track;this.enter_result_phase(2);this.lower_irq("SENSE INTERRUPT command");this.status0=192};W.prototype.exec_recalibrate=function(a){this.set_curr_drive_no(a[0]&1).seek(0,0,1);this.enter_command_phase();this.status0|=32;this.raise_irq("RECALIBRATE command")};W.prototype.exec_format_track=
|
|
448
|
+
function(a){let b=0,c=0;this.set_curr_drive_no(a[0]&1).read_only&&(b=96,c=2);this.end_read_write(b,c,0)};W.prototype.exec_read_id=function(a){const b=this.drives[this.curr_drive_no];b.curr_head=a[0]>>2&1;0!==b.max_sect&&(b.curr_sect=b.curr_sect%b.max_sect+1);this.end_read_write(0,0,0)};W.prototype.exec_specify=function(a){const b=a[1];this.step_rate_interval=a[0]>>4;this.head_load_time=b>>1;this.dor=b&1?this.dor&-9:this.dor|8;this.enter_command_phase()};W.prototype.exec_sense_drive_status=function(a){a=
|
|
449
|
+
a[0];const b=this.set_curr_drive_no(a&1);b.curr_head=a>>2&1;this.response_data[0]=(b.read_only?64:0)|(0===b.curr_track?16:0)|b.curr_head<<2|this.curr_drive_no|40;this.enter_result_phase(1)};W.prototype.exec_perpendicular_mode=function(a){a=a[0];a&128&&(this.drives[this.curr_drive_no].perpendicular=a&7);this.enter_command_phase()};W.prototype.exec_configure=function(a){this.fdc_config=a[1];this.precomp_trk=a[2];this.enter_command_phase()};W.prototype.exec_lock=function(){this.cmd_code&128?(this.locked=
|
|
450
|
+
!0,this.response_data[0]=16):(this.locked=!1,this.response_data[0]=0);this.enter_result_phase(1)};W.prototype.exec_dump_regs=function(){const a=this.drives[this.curr_drive_no];this.response_data[0]=this.drives[0].curr_track;this.response_data[1]=this.drives[1].curr_track;this.response_data[2]=0;this.response_data[3]=0;this.response_data[4]=this.step_rate_interval;this.response_data[5]=this.head_load_time<<1|(this.dor&8?1:0);this.response_data[6]=a.max_sect;this.response_data[7]=(this.locked?128:0)|
|
|
451
|
+
a.perpendicular<<2;this.response_data[8]=this.fdc_config;this.response_data[9]=this.precomp_trk;this.enter_result_phase(10)};W.prototype.exec_version=function(){this.response_data[0]=144;this.enter_result_phase(1)};W.prototype.exec_part_id=function(){this.response_data[0]=65;this.enter_result_phase(1)};W.prototype.start_read_write=function(a,b){const c=this.set_curr_drive_no(a[0]&1),d=a[1],e=a[2],f=a[3];var g=a[4];const k=a[5];a=128>a[7]?a[7]:128;switch(c.seek(e,d,f)){case 2:this.end_read_write(64,
|
|
452
|
+
0,0);this.response_data[3]=d;this.response_data[4]=e;this.response_data[5]=f;return;case 3:this.end_read_write(64,128,0);this.response_data[3]=d;this.response_data[4]=e;this.response_data[5]=f;return;case 1:this.status0|=32}const m=128<<(7<g?7:g);g=c.chs2lba(d,e,f)*m;if(128===m)b&&128>a&&l(!1,"dtl="+a+" is less than 128, zero-padding is still unimplemented!");else if(a=this.cmd_flags&1?(2*k-f+1)*m:(k-f+1)*m,0>=a){B("invalid data_length: "+a+" sect="+f+" eot="+k,8192);this.end_read_write(64,1,0);this.response_data[3]=
|
|
453
|
+
d;this.response_data[4]=e;this.response_data[5]=f;return}this.eot=k;B("Floppy "+this.cmd_table[this.cmd_code].name+" from: "+n(g)+", length: "+n(a)+", C/H/S: "+d+"/"+e+"/"+f+", ro: "+c.read_only+", #S: "+c.max_sect+", #H: "+c.max_head,8192);b&&c.read_only?(this.end_read_write(96,2,0),this.response_data[3]=d,this.response_data[4]=e,this.response_data[5]=f):this.dor&8?(this.msr&=-129,(b?this.dma.do_write:this.dma.do_read).call(this.dma,c.buffer,g,a,2,p=>{p?(B("DMA floppy error",8192),this.end_read_write(64,
|
|
454
|
+
0,0)):(this.seek_next_sect(),this.end_read_write(0,0,0))})):l(!1,this.cmd_table[this.cmd_code].name+" in PIO mode not supported!")};W.prototype.end_read_write=function(a,b,c){const d=this.drives[this.curr_drive_no];this.status0&=-8;this.status0|=this.curr_drive_no;d.curr_head&&(this.status0|=4);this.status0|=a;this.msr|=192;this.msr&=-33;this.response_data[0]=this.status0;this.response_data[1]=b;this.response_data[2]=c;this.response_data[3]=d.curr_track;this.response_data[4]=d.curr_head;this.response_data[5]=
|
|
455
|
+
d.curr_sect;this.response_data[6]=2;this.enter_result_phase(7);this.raise_irq(this.cmd_table[this.cmd_code].name+" command")};W.prototype.seek_next_sect=function(){const a=this.drives[this.curr_drive_no];let b=a.curr_track,c=a.curr_head,d=a.curr_sect,e=1;d>=a.max_sect||d===this.eot?(d=1,this.cmd_flags&1?0===c&&2===a.max_head?c=1:(c=0,b++,this.status0|=32,1===a.max_head&&(e=0)):(this.status0|=32,b++,e=0)):d++;a.seek(c,b,d);return e};W.prototype.get_state=function(){const a=[];a[19]=this.sra;a[20]=
|
|
456
|
+
this.srb;a[21]=this.dor;a[22]=this.tdr;a[23]=this.msr;a[24]=this.dsr;a[25]=this.cmd_phase;a[26]=this.cmd_code;a[27]=this.cmd_flags;a[28]=this.cmd_buffer;a[29]=this.cmd_cursor;a[30]=this.cmd_remaining;a[31]=this.response_data;a[32]=this.response_cursor;a[33]=this.response_length;a[34]=this.status0;a[35]=this.status1;a[36]=this.curr_drive_no;a[37]=this.reset_sense_int_count;a[38]=this.locked;a[39]=this.step_rate_interval;a[40]=this.head_load_time;a[41]=this.fdc_config;a[42]=this.precomp_trk;a[43]=this.eot;
|
|
457
|
+
a[44]=this.drives[0].get_state();a[45]=this.drives[1].get_state();return a};W.prototype.set_state=function(a){"undefined"!==typeof a[19]&&(this.sra=a[19],this.srb=a[20],this.dor=a[21],this.tdr=a[22],this.msr=a[23],this.dsr=a[24],this.cmd_phase=a[25],this.cmd_code=a[26],this.cmd_flags=a[27],this.cmd_buffer.set(a[28]),this.cmd_cursor=a[29],this.cmd_remaining=a[30],this.response_data.set(a[31]),this.response_cursor=a[32],this.response_length=a[33],this.status0=a[34],this.status1=a[35],this.curr_drive_no=
|
|
458
|
+
a[36],this.reset_sense_int_count=a[37],this.locked=a[38],this.step_rate_interval=a[39],this.head_load_time=a[40],this.fdc_config=a[41],this.precomp_trk=a[42],this.eot=a[43],this.drives[0].set_state(a[44]),this.drives[1].set_state(a[45]))};const Sc=[{drive_type:4,sectors:18,tracks:80,heads:2},{drive_type:4,sectors:20,tracks:80,heads:2},{drive_type:4,sectors:21,tracks:80,heads:2},{drive_type:4,sectors:21,tracks:82,heads:2},{drive_type:4,sectors:21,tracks:83,heads:2},{drive_type:4,sectors:22,tracks:80,
|
|
459
|
+
heads:2},{drive_type:4,sectors:23,tracks:80,heads:2},{drive_type:4,sectors:24,tracks:80,heads:2},{drive_type:5,sectors:36,tracks:80,heads:2},{drive_type:5,sectors:39,tracks:80,heads:2},{drive_type:5,sectors:40,tracks:80,heads:2},{drive_type:5,sectors:44,tracks:80,heads:2},{drive_type:5,sectors:48,tracks:80,heads:2},{drive_type:4,sectors:8,tracks:80,heads:2},{drive_type:4,sectors:9,tracks:80,heads:2},{drive_type:4,sectors:10,tracks:80,heads:2},{drive_type:4,sectors:10,tracks:82,heads:2},{drive_type:4,
|
|
460
|
+
sectors:10,tracks:83,heads:2},{drive_type:4,sectors:13,tracks:80,heads:2},{drive_type:4,sectors:14,tracks:80,heads:2},{drive_type:2,sectors:15,tracks:80,heads:2},{drive_type:2,sectors:18,tracks:80,heads:2},{drive_type:2,sectors:18,tracks:82,heads:2},{drive_type:2,sectors:18,tracks:83,heads:2},{drive_type:2,sectors:20,tracks:80,heads:2},{drive_type:2,sectors:9,tracks:80,heads:2},{drive_type:2,sectors:11,tracks:80,heads:2},{drive_type:2,sectors:9,tracks:40,heads:2},{drive_type:2,sectors:9,tracks:40,
|
|
461
|
+
heads:1},{drive_type:2,sectors:10,tracks:41,heads:2},{drive_type:2,sectors:10,tracks:42,heads:2},{drive_type:2,sectors:8,tracks:40,heads:2},{drive_type:2,sectors:8,tracks:40,heads:1},{drive_type:4,sectors:9,tracks:80,heads:1},{drive_type:1,sectors:10,tracks:40,heads:1},{drive_type:1,sectors:10,tracks:40,heads:2}];function Rc(a,b,c,d){this.name=a;this.curr_head=this.curr_track=this.max_sect=this.max_head=this.max_track=this.drive_type=0;this.curr_sect=1;this.perpendicular=0;this.read_only=!1;this.media_changed=
|
|
462
|
+
!0;this.buffer=null;Object.seal(this);a=b?.drive_type;void 0!==a&&0<=a&&5>=a&&(this.drive_type=a);this.insert_disk(c,!!b?.read_only);0===this.drive_type&&void 0===a&&(this.drive_type=d);B("floppy drive "+this.name+" ready, drive type: "+this.drive_type,8192)}Rc.prototype.insert_disk=function(a,b){if(!a)return!1;a instanceof Uint8Array&&(a=new Ba(a.buffer));const [c,d]=this.find_disk_format(a,this.drive_type);if(!c)return B("WARNING: disk rejected, no suitable disk format found for image of size "+
|
|
463
|
+
a.byteLength+" bytes",8192),!1;this.max_track=d.tracks;this.max_head=d.heads;this.max_sect=d.sectors;this.read_only=!!b;this.media_changed=!0;this.buffer=c;0===this.drive_type&&(this.drive_type=d.drive_type);B("disk inserted into "+this.name+": type: "+d.drive_type+", C/H/S: "+d.tracks+"/"+d.heads+"/"+d.sectors+", size: "+c.byteLength,8192);return!0};Rc.prototype.eject_disk=function(){this.max_sect=this.max_head=this.max_track=0;this.media_changed=!0;this.buffer=null};Rc.prototype.get_buffer=function(){return this.buffer?
|
|
464
|
+
this.buffer.buffer:null};Rc.prototype.chs2lba=function(a,b,c){return(a*this.max_head+b)*this.max_sect+c-1};Rc.prototype.find_disk_format=function(a,b){const c=0===b,d=a.byteLength;let e=-1,f=-1,g=-1,k=-1,m=-1;for(let p=0;p<Sc.length;p++){const q=Sc[p],r=q.sectors*q.tracks*q.heads*512;if(d===r)if(c||q.drive_type===b){e=p;break}else c||Qc[q.drive_type]!==Qc[b]?g=-1===g?p:g:f=-1===f?p:f;else d<r&&(-1===m||r<m)&&(k=p,m=r)}return-1!==e?[a,Sc[e]]:-1!==f?[a,Sc[f]]:-1!==g?[a,Sc[g]]:-1!==k?(b=new Uint8Array(m),
|
|
465
|
+
b.set(new Uint8Array(a.buffer)),[new Ba(b.buffer),Sc[k]]):[null,null]};Rc.prototype.seek=function(a,b,c){if(b>this.max_track||0!==a&&1===this.max_head)return B("WARNING: attempt to seek to invalid track: head: "+a+", track: "+b+", sect: "+c,8192),2;if(c>this.max_sect)return B("WARNING: attempt to seek beyond last sector: "+c+" (max: "+this.max_sect+")",8192),3;let d=0;const e=this.chs2lba(this.curr_track,this.curr_head,this.curr_sect),f=this.chs2lba(b,a,c);e!==f&&(this.curr_track!==b&&(this.buffer&&
|
|
466
|
+
(this.media_changed=!1),d=1),this.curr_head=a,this.curr_track=b,this.curr_sect=c);this.buffer||(d=2);return d};Rc.prototype.get_state=function(){const a=[];a[0]=this.drive_type;a[1]=this.max_track;a[2]=this.max_head;a[3]=this.max_sect;a[4]=this.curr_track;a[5]=this.curr_head;a[6]=this.curr_sect;a[7]=this.perpendicular;a[8]=this.read_only;a[9]=this.media_changed;a[10]=this.buffer?this.buffer.get_state():null;return a};Rc.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=
|
|
467
|
+
a[2];this.max_sect=a[3];this.curr_track=a[4];this.curr_head=a[5];this.curr_sect=a[6];this.perpendicular=a[7];this.read_only=a[8];this.media_changed=a[9];a[10]?(this.buffer||(this.buffer=new Ba(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const Tc={[8]:"DEVICE RESET",[144]:"EXECUTE DEVICE DIAGNOSTIC",[231]:"FLUSH CACHE",[234]:"FLUSH CACHE EXT",[218]:"GET MEDIA STATUS",[236]:"IDENTIFY DEVICE",[161]:"IDENTIFY PACKET DEVICE",[225]:"IDLE IMMEDIATE",[145]:"INITIALIZE DEVICE PARAMETERS",
|
|
468
|
+
[222]:"MEDIA LOCK",[0]:"NOP",[160]:"PACKET",[200]:"READ DMA",[37]:"READ DMA EXT",[41]:"READ MULTIPLE",[196]:"READ MULTIPLE EXT",[248]:"READ NATIVE MAX ADDRESS",[39]:"READ NATIVE MAX ADDRESS EXT",[32]:"READ SECTORS",[36]:"READ SECTORS EXT",[64]:"READ VERIFY SECTORS",[245]:"SECURITY FREEZE LOCK",[239]:"SET FEATURES",[249]:"SET MAX",[198]:"SET MULTIPLE MODE",[224]:"STANDBY IMMEDIATE",[202]:"WRITE DMA",[53]:"WRITE DMA EXT",[57]:"WRITE MULTIPLE",[197]:"WRITE MULTIPLE EXT",[48]:"WRITE SECTORS",[52]:"WRITE SECTORS EXT",
|
|
469
|
+
[16]:"<UNKNOWN 10h>",[240]:"<VENDOR-SPECIFIC F0h>"},Uc={[70]:{name:"GET CONFIGURATION",flags:0},[74]:{name:"GET EVENT STATUS NOTIFICATION",flags:0},[18]:{name:"INQUIRY",flags:0},[189]:{name:"MECHANISM STATUS",flags:0},[26]:{name:"MODE SENSE (6)",flags:0},[90]:{name:"MODE SENSE (10)",flags:0},[69]:{name:"PAUSE",flags:1},[30]:{name:"PREVENT ALLOW MEDIUM REMOVAL",flags:0},[40]:{name:"READ (10)",flags:1},[168]:{name:"READ (12)",flags:1},[37]:{name:"READ CAPACITY",flags:1},[190]:{name:"READ CD",flags:1},
|
|
470
|
+
[81]:{name:"READ DISK INFORMATION",flags:1},[66]:{name:"READ SUBCHANNEL",flags:1},[67]:{name:"READ TOC PMA ATIP",flags:1},[82]:{name:"READ TRACK INFORMATION",flags:1},[3]:{name:"REQUEST SENSE",flags:0},[27]:{name:"START STOP UNIT",flags:0},[0]:{name:"TEST UNIT READY",flags:1}};function Vc(a,b,c){this.cpu=a;this.bus=b;this.secondary=this.primary=void 0;b=c&&c[0][0];const d=c&&c[1][0];if(b||d){b&&(this.primary=new Wc(this,0,c[0],496,1014,14));d&&(this.secondary=new Wc(this,1,c[1],368,886,15));c=b?this.primary.command_base:
|
|
471
|
+
0;const e=b?this.primary.control_base:0,f=d?this.secondary.command_base:0,g=d?this.secondary.control_base:0;this.name="ide";this.pci_id=240;this.pci_space=[134,128,16,112,5,0,160,2,0,128,1,1,0,0,0,0,c&255|1,c>>8,0,0,e&255|1,e>>8,0,0,f&255|1,f>>8,0,0,g&255|1,g>>8,0,0,1,180,0,0,0,0,0,0,0,0,0,0,67,16,212,130,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
472
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_bars=[b?{size:8}:void 0,b?{size:1}:void 0,d?{size:8}:void 0,d?{size:1}:void 0,{size:16}];a.devices.pci.register_device(this)}Object.seal(this)}Vc.prototype.get_state=function(){const a=[];a[0]=this.primary;a[1]=this.secondary;return a};Vc.prototype.set_state=function(a){this.primary&&this.primary.set_state(a[0]);this.secondary&&this.secondary.set_state(a[1])};function Wc(a,b,c,d,e,f){this.controller=a;this.channel_nr=b;this.cpu=a.cpu;this.bus=a.bus;this.command_base=
|
|
473
|
+
d;this.control_base=e;this.irq=f;this.name="ide"+b;d=c?c[0]:void 0;c=c?c[1]:void 0;this.master=new X(this,0,d?.buffer,d?.is_cdrom);this.slave=new X(this,1,c?.buffer,c?.is_cdrom);this.current_interface=this.master;this.device_control_reg=2;this.dma_command=this.dma_status=this.prdt_addr=0;a=a.cpu;a.io.register_read(this.command_base|0,this,function(){return this.current_interface.read_data(1)},function(){return this.current_interface.read_data(2)},function(){return this.current_interface.read_data(4)});
|
|
474
|
+
a.io.register_read(this.command_base|1,this,function(){return this.current_interface.error_reg&255});a.io.register_read(this.command_base|2,this,function(){return this.current_interface.sector_count_reg&255});a.io.register_read(this.command_base|3,this,function(){return this.current_interface.lba_low_reg&255});a.io.register_read(this.command_base|4,this,function(){return this.current_interface.lba_mid_reg&255});a.io.register_read(this.command_base|5,this,function(){return this.current_interface.lba_high_reg&
|
|
475
|
+
255});a.io.register_read(this.command_base|6,this,function(){return this.current_interface.device_reg&255});a.io.register_read(this.command_base|7,this,function(){const g=this.read_status();this.cpu.device_lower_irq(this.irq);return g});a.io.register_write(this.command_base|0,this,function(g){this.current_interface.write_data_port8(g)},function(g){this.current_interface.write_data_port16(g)},function(g){this.current_interface.write_data_port32(g)});a.io.register_write(this.command_base|1,this,function(g){this.current_interface.features_reg=
|
|
476
|
+
(this.current_interface.features_reg<<8|g)&65535});a.io.register_write(this.command_base|2,this,function(g){this.current_interface.sector_count_reg=(this.current_interface.sector_count_reg<<8|g)&65535});a.io.register_write(this.command_base|3,this,function(g){this.current_interface.lba_low_reg=(this.current_interface.lba_low_reg<<8|g)&65535});a.io.register_write(this.command_base|4,this,function(g){this.current_interface.lba_mid_reg=(this.current_interface.lba_mid_reg<<8|g)&65535});a.io.register_write(this.command_base|
|
|
477
|
+
5,this,function(g){this.current_interface.lba_high_reg=(this.current_interface.lba_high_reg<<8|g)&65535});a.io.register_write(this.command_base|6,this,function(g){const k=g&16;if(k&&this.current_interface===this.master||!k&&this.current_interface===this.slave)k?(B(`${this.current_interface.name}: select slave device (${this.channel_nr?"secondary":"primary"})`,32768),this.current_interface=this.slave):(B(`${this.current_interface.name}: select master device (${this.channel_nr?"secondary":"primary"})`,
|
|
478
|
+
32768),this.current_interface=this.master);this.current_interface.device_reg=g;this.current_interface.is_lba=g>>6&1;this.current_interface.head=g&15});a.io.register_write(this.command_base|7,this,function(g){this.current_interface.status_reg&=-34;this.current_interface.ata_command(g);this.cpu.device_lower_irq(this.irq)});a.io.register_read(this.control_base|0,this,this.read_status);a.io.register_write(this.control_base|0,this,this.write_control);b=46080+8*b;a.io.register_read(b|0,this,this.dma_read_command8,
|
|
479
|
+
void 0,this.dma_read_command);a.io.register_write(b|0,this,this.dma_write_command8,void 0,this.dma_write_command);a.io.register_read(b|2,this,this.dma_read_status);a.io.register_write(b|2,this,this.dma_write_status);a.io.register_read(b|4,this,void 0,void 0,this.dma_read_addr);a.io.register_write(b|4,this,void 0,void 0,this.dma_set_addr);Object.seal(this)}Wc.prototype.read_status=function(){return this.current_interface.drive_connected?this.current_interface.status_reg:0};Wc.prototype.write_control=
|
|
480
|
+
function(a){a&4&&(B(`${this.current_interface.name}: soft reset via control port (lower IRQ ${this.irq})`,32768),this.cpu.device_lower_irq(this.irq),this.master.device_reset(),this.slave.device_reset());this.device_control_reg=a};Wc.prototype.dma_read_addr=function(){return this.prdt_addr};Wc.prototype.dma_set_addr=function(a){this.prdt_addr=a};Wc.prototype.dma_read_status=function(){return this.dma_status};Wc.prototype.dma_write_status=function(a){this.dma_status&=~(a&6)};Wc.prototype.dma_read_command=
|
|
481
|
+
function(){return this.dma_read_command8()|this.dma_read_status()<<16};Wc.prototype.dma_read_command8=function(){return this.dma_command};Wc.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};Wc.prototype.dma_write_command8=function(a){const b=this.dma_command;this.dma_command=a&9;if((b&1)!==(a&1))if(0===(a&1))this.dma_status&=-2;else switch(this.dma_status|=1,this.current_interface.current_command){case 200:case 37:this.current_interface.do_ata_read_sectors_dma();
|
|
482
482
|
break;case 202:case 53:this.current_interface.do_ata_write_sectors_dma();break;case 160:this.current_interface.do_atapi_dma();break;default:B(this.current_interface.name+": spurious DMA command write, current command: "+n(this.current_interface.current_command),32768),B(this.current_interface.name+": DMA clear status bit 1h, set status bit 2h",32768),this.dma_status&=-2,this.dma_status|=2,this.push_irq()}};Wc.prototype.push_irq=function(){0===(this.device_control_reg&2)&&(this.dma_status|=4,this.cpu.device_raise_irq(this.irq))};
|
|
483
483
|
Wc.prototype.get_state=function(){var a=[];a[0]=this.master;a[1]=this.slave;a[2]=this.command_base;a[3]=this.irq;a[5]=this.control_base;a[7]=this.name;a[8]=this.device_control_reg;a[9]=this.prdt_addr;a[10]=this.dma_status;a[11]=this.current_interface===this.master;a[12]=this.dma_command;return a};Wc.prototype.set_state=function(a){this.master.set_state(a[0]);this.slave.set_state(a[1]);this.command_base=a[2];this.irq=a[3];this.control_base=a[5];this.name=a[7];this.device_control_reg=a[8];this.prdt_addr=
|
|
484
484
|
a[9];this.dma_status=a[10];this.current_interface=a[11]?this.master:this.slave;this.dma_command=a[12]};function X(a,b,c,d){this.channel=a;this.name=a.name+"."+b;this.bus=a.bus;this.channel_nr=a.channel_nr;this.interface_nr=b;this.cpu=a.cpu;this.buffer=null;this.drive_connected=d||!!c;this.sector_size=d?2048:512;this.is_atapi=d;this.sector_count=0;this.head_count=this.is_atapi?1:0;this.device_reg=this.head=this.lba_high_reg=this.lba_mid_reg=this.features_reg=this.lba_low_reg=this.sector_count_reg=
|
package/build/libv86.js
CHANGED
|
@@ -390,10 +390,10 @@ yc.prototype.data_port_read8=function(){return this.data_port_read16()&255};yc.p
|
|
|
390
390
|
yc.prototype.receive=function(a){if(!(this.cr&1)&&(this.bus.send("eth-receive-end",[a.length]),this.rxcr&16||this.rxcr&4&&255===a[0]&&255===a[1]&&255===a[2]&&255===a[3]&&255===a[4]&&255===a[5]||!(this.rxcr&8&&1===(a[0]&1)||a[0]!==this.mac[0]||a[1]!==this.mac[1]||a[2]!==this.mac[2]||a[3]!==this.mac[3]||a[4]!==this.mac[4]||a[5]!==this.mac[5]))){this.mac_address_in_state&&(a=new Uint8Array(a),wc(a,this.mac,this.mac_address_in_state));var b=this.curpg<<8,c=Math.max(60,a.length)+4,d=b+4,e=this.curpg+1+
|
|
391
391
|
(c>>8),f=b+c,g=1+(c>>8),h=this.boundary>this.curpg?this.boundary-this.curpg:this.pstop-this.curpg+this.boundary-this.pstart;h<g&&0!==this.boundary?(z(this.pstart),z(this.pstop),z(this.curpg),z(g),z(this.boundary),z(h)):(f>this.pstop<<8?(f=(this.pstop<<8)-d,this.memory.set(a.subarray(0,f),d),this.memory.set(a.subarray(f),this.pstart<<8),z(f)):(this.memory.set(a,d),60>a.length&&this.memory.fill(0,d+a.length,d+60)),e>=this.pstop&&(e+=this.pstart-this.pstop),this.memory[b]=1,this.memory[b+1]=e,this.memory[b+
|
|
392
392
|
2]=c,this.memory[b+3]=c>>8,this.curpg=e,z(b),z(c),z(e),this.do_interrupt(1))}};yc.prototype.get_page=function(){return this.cr>>6&3};function zc(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c<this.ports;++c)b.push({size_supported:16,notify_offset:0}),b.push({size_supported:8,notify_offset:1});this.virtio=new Ac(a,{name:"virtio-console",pci_id:96,device_id:4163,subsystem_device_id:3,common:{initial_port:47104,queues:b,features:[0,1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,
|
|
393
|
-
single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},()=>{},c=>{if(3===c)for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),f=new Uint8Array(e.length_readable);e.get_next_blob(f);var g=I(["w","h","h"],f,{offset:0});f=g[0];g=g[1];this.Ack(c,e);switch(g){case 0:for(e=0;e<this.ports;++e)this.SendEvent(e,
|
|
394
|
+
1,0);break;case 3:this.Ack(c,e);this.SendEvent(f,4,1);this.SendName(f,"virtio-"+f);this.SendEvent(f,6,1);break;case 6:this.Ack(c,e);0===f&&this.SendWindowSize(f);break;default:return}}}]},isr_status:{initial_port:46848},device_specific:{initial_port:46592,struct:[{bytes:2,name:"cols",read:()=>this.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows,write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{}}]}});for(let c=0;c<
|
|
395
|
+
this.ports;++c){const d=0===c?0:2*c+2;this.bus.register("virtio-console"+c+"-input-bytes",function(e){var f=this.virtio.queues[d];f.has_request()&&(f=f.pop_request(),this.Send(d,f,new Uint8Array(e)))},this);this.bus.register("virtio-console"+c+"-resize",function(e){0===c&&(this.cols=e[0],this.rows=e[1]);this.virtio.queues[2].is_configured()&&this.virtio.queues[2].has_request()&&this.SendWindowSize(c,e[0],e[1])},this)}}
|
|
396
|
+
zc.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(12);F(["w","h","h","h","h"],[a,5,0,c,b],e,0);this.Send(2,d,e)};zc.prototype.SendName=function(a,b){const c=this.virtio.queues[2].pop_request();b=(new TextEncoder).encode(b);const d=new Uint8Array(8+b.length+1);F(["w","h","h"],[a,7,1],d,0);for(a=0;a<b.length;++a)d[a+8]=b[a];d[8+b.length]=0;this.Send(2,c,d)};
|
|
397
397
|
zc.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};zc.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=a[3]};zc.prototype.reset=function(){this.virtio.reset()};zc.prototype.SendEvent=function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);F(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};
|
|
398
398
|
zc.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};zc.prototype.Ack=function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function Bc(a,b){this.cpu=a;this.bus=b;this.reset();this.bus.register("keyboard-code",function(c){this.kbd_send_code(c)},this);this.bus.register("mouse-click",function(c){this.mouse_send_click(c[0],c[1],c[2])},this);this.bus.register("mouse-delta",function(c){this.mouse_send_delta(c[0],c[1])},this);this.bus.register("mouse-wheel",function(c){this.wheel_movement-=c[0];this.wheel_movement-=2*c[1];this.wheel_movement=Math.min(7,Math.max(-8,this.wheel_movement));this.send_mouse_packet(0,0)},this);a.io.register_read(96,
|
|
399
399
|
this,this.port60_read);a.io.register_read(100,this,this.port64_read);a.io.register_write(96,this,this.port60_write);a.io.register_write(100,this,this.port64_write)}
|
package/build/libv86.mjs
CHANGED
|
@@ -351,18 +351,18 @@ this.pstop<<8);0===this.rcnt&&this.do_interrupt(64);return a};yc.prototype.data_
|
|
|
351
351
|
this.rxcr&16||this.rxcr&4&&255===a[0]&&255===a[1]&&255===a[2]&&255===a[3]&&255===a[4]&&255===a[5]||!(this.rxcr&8&&1===(a[0]&1)||a[0]!==this.mac[0]||a[1]!==this.mac[1]||a[2]!==this.mac[2]||a[3]!==this.mac[3]||a[4]!==this.mac[4]||a[5]!==this.mac[5]))){this.mac_address_in_state&&(a=new Uint8Array(a),wc(a,this.mac,this.mac_address_in_state));var b=this.curpg<<8,c=Math.max(60,a.length)+4,d=b+4,e=this.curpg+1+(c>>8),f=b+c,g=1+(c>>8),h=this.boundary>this.curpg?this.boundary-this.curpg:this.pstop-this.curpg+
|
|
352
352
|
this.boundary-this.pstart;h<g&&0!==this.boundary?(z(this.pstart),z(this.pstop),z(this.curpg),z(g),z(this.boundary),z(h)):(f>this.pstop<<8?(f=(this.pstop<<8)-d,this.memory.set(a.subarray(0,f),d),this.memory.set(a.subarray(f),this.pstart<<8),z(f)):(this.memory.set(a,d),60>a.length&&this.memory.fill(0,d+a.length,d+60)),e>=this.pstop&&(e+=this.pstart-this.pstop),this.memory[b]=1,this.memory[b+1]=e,this.memory[b+2]=c,this.memory[b+3]=c>>8,this.curpg=e,z(b),z(c),z(e),this.do_interrupt(1))}};yc.prototype.get_page=
|
|
353
353
|
function(){return this.cr>>6&3};function zc(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c<this.ports;++c)b.push({size_supported:16,notify_offset:0}),b.push({size_supported:8,notify_offset:1});this.virtio=new Ac(a,{name:"virtio-console",pci_id:96,device_id:4163,subsystem_device_id:3,common:{initial_port:47104,queues:b,features:[0,
|
|
354
|
-
1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
this.
|
|
362
|
-
|
|
363
|
-
a[
|
|
364
|
-
|
|
365
|
-
a[
|
|
354
|
+
1,32],on_driver_ok:()=>{}},notification:{initial_port:47360,single_handler:!1,handlers:[()=>{},c=>{const d=this.virtio.queues[c],e=3<c?c-3>>1:0;for(;d.has_request();){const f=d.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("virtio-console"+e+"-output-bytes",g);this.Ack(c,f)}},()=>{},c=>{if(3===c)for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),f=new Uint8Array(e.length_readable);e.get_next_blob(f);var g=I(["w","h","h"],f,{offset:0});f=g[0];
|
|
355
|
+
g=g[1];this.Ack(c,e);switch(g){case 0:for(e=0;e<this.ports;++e)this.SendEvent(e,1,0);break;case 3:this.Ack(c,e);this.SendEvent(f,4,1);this.SendName(f,"virtio-"+f);this.SendEvent(f,6,1);break;case 6:this.Ack(c,e);0===f&&this.SendWindowSize(f);break;default:return}}}]},isr_status:{initial_port:46848},device_specific:{initial_port:46592,struct:[{bytes:2,name:"cols",read:()=>this.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows,write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,
|
|
356
|
+
write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{}}]}});for(let c=0;c<this.ports;++c){const d=0===c?0:2*c+2;this.bus.register("virtio-console"+c+"-input-bytes",function(e){var f=this.virtio.queues[d];f.has_request()&&(f=f.pop_request(),this.Send(d,f,new Uint8Array(e)))},this);this.bus.register("virtio-console"+c+"-resize",function(e){0===c&&(this.cols=e[0],this.rows=e[1]);this.virtio.queues[2].is_configured()&&this.virtio.queues[2].has_request()&&this.SendWindowSize(c,e[0],e[1])},this)}}
|
|
357
|
+
zc.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(12);F(["w","h","h","h","h"],[a,5,0,c,b],e,0);this.Send(2,d,e)};zc.prototype.SendName=function(a,b){const c=this.virtio.queues[2].pop_request();b=(new TextEncoder).encode(b);const d=new Uint8Array(8+b.length+1);F(["w","h","h"],[a,7,1],d,0);for(a=0;a<b.length;++a)d[a+8]=b[a];d[8+b.length]=0;this.Send(2,c,d)};zc.prototype.get_state=function(){const a=[];a[0]=this.virtio;
|
|
358
|
+
a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};zc.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=a[3]};zc.prototype.reset=function(){this.virtio.reset()};zc.prototype.SendEvent=function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);F(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};zc.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};zc.prototype.Ack=
|
|
359
|
+
function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function Bc(a,b){this.cpu=a;this.bus=b;this.reset();this.bus.register("keyboard-code",function(c){this.kbd_send_code(c)},this);this.bus.register("mouse-click",function(c){this.mouse_send_click(c[0],c[1],c[2])},this);this.bus.register("mouse-delta",function(c){this.mouse_send_delta(c[0],c[1])},this);this.bus.register("mouse-wheel",function(c){this.wheel_movement-=c[0];this.wheel_movement-=
|
|
360
|
+
2*c[1];this.wheel_movement=Math.min(7,Math.max(-8,this.wheel_movement));this.send_mouse_packet(0,0)},this);a.io.register_read(96,this,this.port60_read);a.io.register_read(100,this,this.port64_read);a.io.register_write(96,this,this.port60_write);a.io.register_write(100,this,this.port64_write)}Bc.prototype.reset=function(){this.use_mouse=this.enable_mouse_stream=!1;this.have_mouse=!0;this.mouse_clicks=this.mouse_delta_y=this.mouse_delta_x=0;this.have_keyboard=!0;this.next_read_resolution=this.next_read_rate=
|
|
361
|
+
this.next_handle_scan_code_set=this.next_read_led=this.next_read_sample=this.next_is_mouse_command=this.enable_keyboard_stream=!1;this.kbd_buffer=new ka(1024);this.last_port60_byte=0;this.sample_rate=100;this.mouse_id=this.mouse_detect_state=0;this.mouse_reset_workaround=!1;this.wheel_movement=0;this.resolution=4;this.scaling2=!1;this.last_mouse_packet=-1;this.mouse_buffer=new ka(1024);this.next_byte_is_aux=this.next_byte_is_ready=!1;this.command_register=5;this.controller_output_port=0;this.read_controller_output_port=
|
|
362
|
+
this.read_command_register=this.read_output_register=!1};Bc.prototype.get_state=function(){var a=[];a[0]=this.enable_mouse_stream;a[1]=this.use_mouse;a[2]=this.have_mouse;a[3]=this.mouse_delta_x;a[4]=this.mouse_delta_y;a[5]=this.mouse_clicks;a[6]=this.have_keyboard;a[7]=this.enable_keyboard_stream;a[8]=this.next_is_mouse_command;a[9]=this.next_read_sample;a[10]=this.next_read_led;a[11]=this.next_handle_scan_code_set;a[12]=this.next_read_rate;a[13]=this.next_read_resolution;a[15]=this.last_port60_byte;
|
|
363
|
+
a[16]=this.sample_rate;a[17]=this.resolution;a[18]=this.scaling2;a[20]=this.command_register;a[21]=this.read_output_register;a[22]=this.read_command_register;a[23]=this.controller_output_port;a[24]=this.read_controller_output_port;a[25]=this.mouse_id;a[26]=this.mouse_detect_state;a[27]=this.mouse_reset_workaround;return a};Bc.prototype.set_state=function(a){this.enable_mouse_stream=a[0];this.use_mouse=a[1];this.have_mouse=a[2];this.mouse_delta_x=a[3];this.mouse_delta_y=a[4];this.mouse_clicks=a[5];
|
|
364
|
+
this.have_keyboard=a[6];this.enable_keyboard_stream=a[7];this.next_is_mouse_command=a[8];this.next_read_sample=a[9];this.next_read_led=a[10];this.next_handle_scan_code_set=a[11];this.next_read_rate=a[12];this.next_read_resolution=a[13];this.last_port60_byte=a[15];this.sample_rate=a[16];this.resolution=a[17];this.scaling2=a[18];this.command_register=a[20];this.read_output_register=a[21];this.read_command_register=a[22];this.controller_output_port=a[23];this.read_controller_output_port=a[24];this.mouse_id=
|
|
365
|
+
a[25]||0;this.mouse_detect_state=a[26]||0;this.mouse_reset_workaround=a[27]||!1;this.next_byte_is_aux=this.next_byte_is_ready=!1;this.kbd_buffer.clear();this.mouse_buffer.clear();this.bus.send("mouse-enable",this.use_mouse)};Bc.prototype.raise_irq=function(){this.next_byte_is_ready||(this.kbd_buffer.length?this.kbd_irq():this.mouse_buffer.length&&this.mouse_irq())};Bc.prototype.mouse_irq=function(){this.next_byte_is_aux=this.next_byte_is_ready=!0;this.command_register&2&&(this.cpu.device_lower_irq(12),
|
|
366
366
|
this.cpu.device_raise_irq(12))};Bc.prototype.kbd_irq=function(){this.next_byte_is_ready=!0;this.next_byte_is_aux=!1;this.command_register&1&&(this.cpu.device_lower_irq(1),this.cpu.device_raise_irq(1))};Bc.prototype.kbd_send_code=function(a){this.enable_keyboard_stream&&(z(a),this.kbd_buffer.push(a),this.raise_irq())};Bc.prototype.mouse_send_delta=function(a,b){this.have_mouse&&this.use_mouse&&(this.mouse_delta_x+=1*a,this.mouse_delta_y+=1*b,this.enable_mouse_stream&&(a=this.mouse_delta_x|0,b=this.mouse_delta_y|
|
|
367
367
|
0,a||b))&&(this.mouse_delta_x-=a,this.mouse_delta_y-=b,this.send_mouse_packet(a,b))};Bc.prototype.mouse_send_click=function(a,b,c){this.have_mouse&&this.use_mouse&&(this.mouse_clicks=a|c<<1|b<<2,this.enable_mouse_stream&&this.send_mouse_packet(0,0))};Bc.prototype.send_mouse_packet=function(a,b){var c=(0>b)<<5|(0>a)<<4|8|this.mouse_clicks;this.last_mouse_packet=Date.now();this.mouse_buffer.push(c);this.mouse_buffer.push(a);this.mouse_buffer.push(b);4===this.mouse_id?(this.mouse_buffer.push(0|this.wheel_movement&
|
|
368
368
|
15),this.wheel_movement=0):3===this.mouse_id&&(this.mouse_buffer.push(this.wheel_movement&255),this.wheel_movement=0);this.raise_irq()};Bc.prototype.apply_scaling2=function(a){var b=a>>31;switch(Math.abs(a)){case 0:case 1:case 3:return a;case 2:return b;case 4:return 6*b;case 5:return 9*b;default:return a<<1}};Bc.prototype.port60_read=function(){this.next_byte_is_ready=!1;if(!this.kbd_buffer.length&&!this.mouse_buffer.length)return this.last_port60_byte;this.next_byte_is_aux?(this.cpu.device_lower_irq(12),
|