v86 0.5.456 → 0.5.459
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 +22 -15
- package/build/libv86-debug.mjs +22 -15
- package/build/libv86.js +10 -9
- package/build/libv86.mjs +40 -39
- package/build/v86-debug.wasm +0 -0
- package/build/v86-fallback.wasm +0 -0
- package/build/v86.wasm +0 -0
- package/package.json +1 -1
package/build/libv86-debug.js
CHANGED
|
@@ -1128,10 +1128,9 @@ $DMA$$module$src$dma$$.prototype.do_write = function($buffer$jscomp$26$$, $start
|
|
|
1128
1128
|
}));
|
|
1129
1129
|
};
|
|
1130
1130
|
$DMA$$module$src$dma$$.prototype.address_get_8bit = function($channel$jscomp$14$$) {
|
|
1131
|
-
var $addr$jscomp$2$$ = this.channel_addr[$channel$jscomp$14$$];
|
|
1132
|
-
5 <= $channel$jscomp$14$$ && ($addr$jscomp$2$$ <<= 1);
|
|
1133
|
-
$addr$jscomp$2$$ = $addr$jscomp$2$$
|
|
1134
|
-
return $addr$jscomp$2$$ |= this.channel_pagehi[$channel$jscomp$14$$] << 24;
|
|
1131
|
+
var $addr$jscomp$2$$ = this.channel_addr[$channel$jscomp$14$$], $page$$ = this.channel_page[$channel$jscomp$14$$];
|
|
1132
|
+
5 <= $channel$jscomp$14$$ && ($addr$jscomp$2$$ <<= 1, $page$$ &= 254);
|
|
1133
|
+
return $addr$jscomp$2$$ = $addr$jscomp$2$$ | $page$$ << 16 | this.channel_pagehi[$channel$jscomp$14$$] << 24;
|
|
1135
1134
|
};
|
|
1136
1135
|
$DMA$$module$src$dma$$.prototype.count_get_8bit = function($channel$jscomp$15$$) {
|
|
1137
1136
|
var $count$jscomp$40$$ = this.channel_count[$channel$jscomp$15$$] + 1;
|
|
@@ -9003,8 +9002,8 @@ $FloppyDrive$$module$src$floppy$$.prototype.set_state = function($state$jscomp$4
|
|
|
9003
9002
|
};
|
|
9004
9003
|
const $ATA_CMD_NAME$$module$src$ide$$ = {[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", [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",
|
|
9005
9004
|
[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", [16]:"<UNKNOWN 10h>", [240]:"<VENDOR-SPECIFIC F0h>", }, $ATAPI_CMD$$module$src$ide$$ = {[70]:{name:"GET CONFIGURATION", flags:0}, [74]:{name:"GET EVENT STATUS NOTIFICATION", flags:0}, [18]:{name:"INQUIRY",
|
|
9006
|
-
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}, [
|
|
9007
|
-
flags:1}, [3]:{name:"REQUEST SENSE", flags:0}, [27]:{name:"START STOP UNIT", flags:0}, [0]:{name:"TEST UNIT READY", flags:1}, };
|
|
9005
|
+
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}, [35]:{name:"READ FORMAT CAPACITIES", flags:1}, [190]:{name:"READ CD", flags:1}, [81]:{name:"READ DISK INFORMATION", flags:1}, [66]:{name:"READ SUBCHANNEL", flags:1}, [67]:{name:"READ TOC PMA ATIP",
|
|
9006
|
+
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}, [164]:{name:"REPORT KEY", flags:0}, [173]:{name:"READ DISC STRUCTURE", flags:1}, };
|
|
9008
9007
|
function $IDEController$$module$src$ide$$($cpu$jscomp$23$$, $bus$jscomp$27_has_primary$$, $command_base0_ide_config$$) {
|
|
9009
9008
|
this.cpu = $cpu$jscomp$23$$;
|
|
9010
9009
|
this.bus = $bus$jscomp$27_has_primary$$;
|
|
@@ -9513,6 +9512,12 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_handle = function() {
|
|
|
9513
9512
|
this.data_end = this.data_length;
|
|
9514
9513
|
this.status_reg = 88;
|
|
9515
9514
|
break;
|
|
9515
|
+
case 35:
|
|
9516
|
+
$cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ = this.sector_count - 1;
|
|
9517
|
+
this.data_set(new Uint8Array([0, 0, 0, 8, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 24 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 16 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 8 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ & 255, 2, this.sector_size >> 16 & 255, this.sector_size >> 8 & 255, this.sector_size & 255, ]));
|
|
9518
|
+
this.data_end = this.data_length;
|
|
9519
|
+
this.status_reg = 88;
|
|
9520
|
+
break;
|
|
9516
9521
|
case 40:
|
|
9517
9522
|
case 168:
|
|
9518
9523
|
$do_dbg_log$jscomp$1_result$jscomp$21$$ = !1;
|
|
@@ -9583,6 +9588,8 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_handle = function() {
|
|
|
9583
9588
|
break;
|
|
9584
9589
|
case 69:
|
|
9585
9590
|
case 74:
|
|
9591
|
+
case 164:
|
|
9592
|
+
case 173:
|
|
9586
9593
|
$dbg_log_extra$$ = "unimplemented";
|
|
9587
9594
|
this.atapi_check_condition_response(5, 36);
|
|
9588
9595
|
break;
|
|
@@ -11847,25 +11854,25 @@ $CPU$$module$src$cpu$$.prototype.set_state_ioapic = function($state$jscomp$63$$)
|
|
|
11847
11854
|
$CPU$$module$src$cpu$$.prototype.pack_memory = function() {
|
|
11848
11855
|
$dbg_assert$$module$src$log$$(0 === (this.mem8.length & 4095));
|
|
11849
11856
|
var $bitmap$jscomp$4_page_count$$ = this.mem8.length >> 12, $nonzero_pages_offset$jscomp$82_page_contents$$ = [];
|
|
11850
|
-
for ($packed_memory$jscomp$2_page$$ = 0; $packed_memory$jscomp$2_page$$ < $bitmap$jscomp$4_page_count$$; $packed_memory$jscomp$2_page$$++) {
|
|
11851
|
-
this.is_memory_zeroed($packed_memory$jscomp$2_page$$ << 12, 4096) || $nonzero_pages_offset$jscomp$82_page_contents$$.push($packed_memory$jscomp$2_page$$);
|
|
11857
|
+
for ($packed_memory$jscomp$2_page$jscomp$1$$ = 0; $packed_memory$jscomp$2_page$jscomp$1$$ < $bitmap$jscomp$4_page_count$$; $packed_memory$jscomp$2_page$jscomp$1$$++) {
|
|
11858
|
+
this.is_memory_zeroed($packed_memory$jscomp$2_page$jscomp$1$$ << 12, 4096) || $nonzero_pages_offset$jscomp$82_page_contents$$.push($packed_memory$jscomp$2_page$jscomp$1$$);
|
|
11852
11859
|
}
|
|
11853
11860
|
$bitmap$jscomp$4_page_count$$ = new $Bitmap$$module$src$lib$$($bitmap$jscomp$4_page_count$$);
|
|
11854
|
-
var $packed_memory$jscomp$2_page$$ = new Uint8Array($nonzero_pages_offset$jscomp$82_page_contents$$.length << 12);
|
|
11855
|
-
for (const [$i$jscomp$103$$, $page$jscomp$
|
|
11856
|
-
$bitmap$jscomp$4_page_count$$.set($page$jscomp$
|
|
11861
|
+
var $packed_memory$jscomp$2_page$jscomp$1$$ = new Uint8Array($nonzero_pages_offset$jscomp$82_page_contents$$.length << 12);
|
|
11862
|
+
for (const [$i$jscomp$103$$, $page$jscomp$2$$] of $nonzero_pages_offset$jscomp$82_page_contents$$.entries()) {
|
|
11863
|
+
$bitmap$jscomp$4_page_count$$.set($page$jscomp$2$$, 1), $nonzero_pages_offset$jscomp$82_page_contents$$ = $page$jscomp$2$$ << 12, $nonzero_pages_offset$jscomp$82_page_contents$$ = this.mem8.subarray($nonzero_pages_offset$jscomp$82_page_contents$$, $nonzero_pages_offset$jscomp$82_page_contents$$ + 4096), $packed_memory$jscomp$2_page$jscomp$1$$.set($nonzero_pages_offset$jscomp$82_page_contents$$, $i$jscomp$103$$ << 12);
|
|
11857
11864
|
}
|
|
11858
|
-
return {bitmap:$bitmap$jscomp$4_page_count$$, packed_memory:$packed_memory$jscomp$2_page$$};
|
|
11865
|
+
return {bitmap:$bitmap$jscomp$4_page_count$$, packed_memory:$packed_memory$jscomp$2_page$jscomp$1$$};
|
|
11859
11866
|
};
|
|
11860
11867
|
$CPU$$module$src$cpu$$.prototype.unpack_memory = function($bitmap$jscomp$5$$, $packed_memory$jscomp$3$$) {
|
|
11861
11868
|
this.zero_memory(0, this.memory_size[0]);
|
|
11862
11869
|
const $page_count$jscomp$1$$ = this.memory_size[0] >> 12;
|
|
11863
11870
|
let $packed_page$$ = 0;
|
|
11864
|
-
for (let $page$jscomp$
|
|
11865
|
-
if ($bitmap$jscomp$5$$.get($page$jscomp$
|
|
11871
|
+
for (let $page$jscomp$3$$ = 0; $page$jscomp$3$$ < $page_count$jscomp$1$$; $page$jscomp$3$$++) {
|
|
11872
|
+
if ($bitmap$jscomp$5$$.get($page$jscomp$3$$)) {
|
|
11866
11873
|
var $offset$jscomp$83_view$jscomp$34$$ = $packed_page$$ << 12;
|
|
11867
11874
|
$offset$jscomp$83_view$jscomp$34$$ = $packed_memory$jscomp$3$$.subarray($offset$jscomp$83_view$jscomp$34$$, $offset$jscomp$83_view$jscomp$34$$ + 4096);
|
|
11868
|
-
this.mem8.set($offset$jscomp$83_view$jscomp$34$$, $page$jscomp$
|
|
11875
|
+
this.mem8.set($offset$jscomp$83_view$jscomp$34$$, $page$jscomp$3$$ << 12);
|
|
11869
11876
|
$packed_page$$++;
|
|
11870
11877
|
}
|
|
11871
11878
|
}
|
package/build/libv86-debug.mjs
CHANGED
|
@@ -1127,10 +1127,9 @@ $DMA$$module$src$dma$$.prototype.do_write = function($buffer$jscomp$26$$, $start
|
|
|
1127
1127
|
}));
|
|
1128
1128
|
};
|
|
1129
1129
|
$DMA$$module$src$dma$$.prototype.address_get_8bit = function($channel$jscomp$14$$) {
|
|
1130
|
-
var $addr$jscomp$2$$ = this.channel_addr[$channel$jscomp$14$$];
|
|
1131
|
-
5 <= $channel$jscomp$14$$ && ($addr$jscomp$2$$ <<= 1);
|
|
1132
|
-
$addr$jscomp$2$$ = $addr$jscomp$2$$
|
|
1133
|
-
return $addr$jscomp$2$$ |= this.channel_pagehi[$channel$jscomp$14$$] << 24;
|
|
1130
|
+
var $addr$jscomp$2$$ = this.channel_addr[$channel$jscomp$14$$], $page$$ = this.channel_page[$channel$jscomp$14$$];
|
|
1131
|
+
5 <= $channel$jscomp$14$$ && ($addr$jscomp$2$$ <<= 1, $page$$ &= 254);
|
|
1132
|
+
return $addr$jscomp$2$$ = $addr$jscomp$2$$ | $page$$ << 16 | this.channel_pagehi[$channel$jscomp$14$$] << 24;
|
|
1134
1133
|
};
|
|
1135
1134
|
$DMA$$module$src$dma$$.prototype.count_get_8bit = function($channel$jscomp$15$$) {
|
|
1136
1135
|
var $count$jscomp$40$$ = this.channel_count[$channel$jscomp$15$$] + 1;
|
|
@@ -9002,8 +9001,8 @@ $FloppyDrive$$module$src$floppy$$.prototype.set_state = function($state$jscomp$4
|
|
|
9002
9001
|
};
|
|
9003
9002
|
const $ATA_CMD_NAME$$module$src$ide$$ = {[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", [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",
|
|
9004
9003
|
[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", [16]:"<UNKNOWN 10h>", [240]:"<VENDOR-SPECIFIC F0h>", }, $ATAPI_CMD$$module$src$ide$$ = {[70]:{name:"GET CONFIGURATION", flags:0}, [74]:{name:"GET EVENT STATUS NOTIFICATION", flags:0}, [18]:{name:"INQUIRY",
|
|
9005
|
-
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}, [
|
|
9006
|
-
flags:1}, [3]:{name:"REQUEST SENSE", flags:0}, [27]:{name:"START STOP UNIT", flags:0}, [0]:{name:"TEST UNIT READY", flags:1}, };
|
|
9004
|
+
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}, [35]:{name:"READ FORMAT CAPACITIES", flags:1}, [190]:{name:"READ CD", flags:1}, [81]:{name:"READ DISK INFORMATION", flags:1}, [66]:{name:"READ SUBCHANNEL", flags:1}, [67]:{name:"READ TOC PMA ATIP",
|
|
9005
|
+
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}, [164]:{name:"REPORT KEY", flags:0}, [173]:{name:"READ DISC STRUCTURE", flags:1}, };
|
|
9007
9006
|
function $IDEController$$module$src$ide$$($cpu$jscomp$23$$, $bus$jscomp$27_has_primary$$, $command_base0_ide_config$$) {
|
|
9008
9007
|
this.cpu = $cpu$jscomp$23$$;
|
|
9009
9008
|
this.bus = $bus$jscomp$27_has_primary$$;
|
|
@@ -9512,6 +9511,12 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_handle = function() {
|
|
|
9512
9511
|
this.data_end = this.data_length;
|
|
9513
9512
|
this.status_reg = 88;
|
|
9514
9513
|
break;
|
|
9514
|
+
case 35:
|
|
9515
|
+
$cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ = this.sector_count - 1;
|
|
9516
|
+
this.data_set(new Uint8Array([0, 0, 0, 8, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 24 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 16 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ >> 8 & 255, $cmd_flags_count$jscomp$57_length$jscomp$29_loej_start_start$jscomp$33$$ & 255, 2, this.sector_size >> 16 & 255, this.sector_size >> 8 & 255, this.sector_size & 255, ]));
|
|
9517
|
+
this.data_end = this.data_length;
|
|
9518
|
+
this.status_reg = 88;
|
|
9519
|
+
break;
|
|
9515
9520
|
case 40:
|
|
9516
9521
|
case 168:
|
|
9517
9522
|
$do_dbg_log$jscomp$1_result$jscomp$21$$ = !1;
|
|
@@ -9582,6 +9587,8 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_handle = function() {
|
|
|
9582
9587
|
break;
|
|
9583
9588
|
case 69:
|
|
9584
9589
|
case 74:
|
|
9590
|
+
case 164:
|
|
9591
|
+
case 173:
|
|
9585
9592
|
$dbg_log_extra$$ = "unimplemented";
|
|
9586
9593
|
this.atapi_check_condition_response(5, 36);
|
|
9587
9594
|
break;
|
|
@@ -11846,25 +11853,25 @@ $CPU$$module$src$cpu$$.prototype.set_state_ioapic = function($state$jscomp$63$$)
|
|
|
11846
11853
|
$CPU$$module$src$cpu$$.prototype.pack_memory = function() {
|
|
11847
11854
|
$dbg_assert$$module$src$log$$(0 === (this.mem8.length & 4095));
|
|
11848
11855
|
var $bitmap$jscomp$4_page_count$$ = this.mem8.length >> 12, $nonzero_pages_offset$jscomp$82_page_contents$$ = [];
|
|
11849
|
-
for ($packed_memory$jscomp$2_page$$ = 0; $packed_memory$jscomp$2_page$$ < $bitmap$jscomp$4_page_count$$; $packed_memory$jscomp$2_page$$++) {
|
|
11850
|
-
this.is_memory_zeroed($packed_memory$jscomp$2_page$$ << 12, 4096) || $nonzero_pages_offset$jscomp$82_page_contents$$.push($packed_memory$jscomp$2_page$$);
|
|
11856
|
+
for ($packed_memory$jscomp$2_page$jscomp$1$$ = 0; $packed_memory$jscomp$2_page$jscomp$1$$ < $bitmap$jscomp$4_page_count$$; $packed_memory$jscomp$2_page$jscomp$1$$++) {
|
|
11857
|
+
this.is_memory_zeroed($packed_memory$jscomp$2_page$jscomp$1$$ << 12, 4096) || $nonzero_pages_offset$jscomp$82_page_contents$$.push($packed_memory$jscomp$2_page$jscomp$1$$);
|
|
11851
11858
|
}
|
|
11852
11859
|
$bitmap$jscomp$4_page_count$$ = new $Bitmap$$module$src$lib$$($bitmap$jscomp$4_page_count$$);
|
|
11853
|
-
var $packed_memory$jscomp$2_page$$ = new Uint8Array($nonzero_pages_offset$jscomp$82_page_contents$$.length << 12);
|
|
11854
|
-
for (const [$i$jscomp$103$$, $page$jscomp$
|
|
11855
|
-
$bitmap$jscomp$4_page_count$$.set($page$jscomp$
|
|
11860
|
+
var $packed_memory$jscomp$2_page$jscomp$1$$ = new Uint8Array($nonzero_pages_offset$jscomp$82_page_contents$$.length << 12);
|
|
11861
|
+
for (const [$i$jscomp$103$$, $page$jscomp$2$$] of $nonzero_pages_offset$jscomp$82_page_contents$$.entries()) {
|
|
11862
|
+
$bitmap$jscomp$4_page_count$$.set($page$jscomp$2$$, 1), $nonzero_pages_offset$jscomp$82_page_contents$$ = $page$jscomp$2$$ << 12, $nonzero_pages_offset$jscomp$82_page_contents$$ = this.mem8.subarray($nonzero_pages_offset$jscomp$82_page_contents$$, $nonzero_pages_offset$jscomp$82_page_contents$$ + 4096), $packed_memory$jscomp$2_page$jscomp$1$$.set($nonzero_pages_offset$jscomp$82_page_contents$$, $i$jscomp$103$$ << 12);
|
|
11856
11863
|
}
|
|
11857
|
-
return {bitmap:$bitmap$jscomp$4_page_count$$, packed_memory:$packed_memory$jscomp$2_page$$};
|
|
11864
|
+
return {bitmap:$bitmap$jscomp$4_page_count$$, packed_memory:$packed_memory$jscomp$2_page$jscomp$1$$};
|
|
11858
11865
|
};
|
|
11859
11866
|
$CPU$$module$src$cpu$$.prototype.unpack_memory = function($bitmap$jscomp$5$$, $packed_memory$jscomp$3$$) {
|
|
11860
11867
|
this.zero_memory(0, this.memory_size[0]);
|
|
11861
11868
|
const $page_count$jscomp$1$$ = this.memory_size[0] >> 12;
|
|
11862
11869
|
let $packed_page$$ = 0;
|
|
11863
|
-
for (let $page$jscomp$
|
|
11864
|
-
if ($bitmap$jscomp$5$$.get($page$jscomp$
|
|
11870
|
+
for (let $page$jscomp$3$$ = 0; $page$jscomp$3$$ < $page_count$jscomp$1$$; $page$jscomp$3$$++) {
|
|
11871
|
+
if ($bitmap$jscomp$5$$.get($page$jscomp$3$$)) {
|
|
11865
11872
|
var $offset$jscomp$83_view$jscomp$34$$ = $packed_page$$ << 12;
|
|
11866
11873
|
$offset$jscomp$83_view$jscomp$34$$ = $packed_memory$jscomp$3$$.subarray($offset$jscomp$83_view$jscomp$34$$, $offset$jscomp$83_view$jscomp$34$$ + 4096);
|
|
11867
|
-
this.mem8.set($offset$jscomp$83_view$jscomp$34$$, $page$jscomp$
|
|
11874
|
+
this.mem8.set($offset$jscomp$83_view$jscomp$34$$, $page$jscomp$3$$ << 12);
|
|
11868
11875
|
$packed_page$$++;
|
|
11869
11876
|
}
|
|
11870
11877
|
}
|
package/build/libv86.js
CHANGED
|
@@ -58,7 +58,7 @@ A.prototype.port_multimask_read=function(a){var b=0|this.channel_mask[a+0];b|=th
|
|
|
58
58
|
A.prototype.update_mask=function(a,b){if(this.channel_mask[a]!==b&&(this.channel_mask[a]=b,!b))for(b=0;b<this.unmask_listeners.length;b++)this.unmask_listeners[b].fn.call(this.unmask_listeners[b].this_value,a)};
|
|
59
59
|
A.prototype.do_read=function(a,b,c,d,e){var f=this.count_get_8bit(d),g=this.address_get_8bit(d);sa("to "+y(g)+" len "+y(f),16);c<f&&sa("DMA should read more than provided: "+y(c)+" "+y(f),16);if(b+f>a.byteLength)e(!0);else{var h=this.cpu;this.channel_addr[d]+=f;a.get(b,f,function(m){h.write_blob(m,g);e(!1)})}};
|
|
60
60
|
A.prototype.do_write=function(a,b,c,d,e){var f=this.channel_count[d]+1&65535,g=5<=d?2:1,h=f*g,m=this.address_get_8bit(d),l=!1,n=!1,p=this.channel_mode[d]&16;sa("to "+y(m)+" len "+y(h),16);c<h?(f=Math.floor(c/g),h=f*g,l=!0):c>h&&(n=!0);b+h>a.byteLength?e(!0):(this.channel_addr[d]+=f,this.channel_count[d]-=f,!l&&p&&(this.channel_addr[d]=this.channel_addr_init[d],this.channel_count[d]=this.channel_count_init[d]),a.set(b,this.cpu.mem8.subarray(m,m+h),()=>{n&&p?this.do_write(a,b+h,c-h,d,e):e(!1)}))};
|
|
61
|
-
A.prototype.address_get_8bit=function(a){var b=this.channel_addr[a];5<=a&&(b<<=1);b=b
|
|
61
|
+
A.prototype.address_get_8bit=function(a){var b=this.channel_addr[a],c=this.channel_page[a];5<=a&&(b<<=1,c&=254);return b=b|c<<16|this.channel_pagehi[a]<<24};A.prototype.count_get_8bit=function(a){var b=this.channel_count[a]+1;5<=a&&(b*=2);return b};A.prototype.flipflop_get=function(a,b,c){c||(this.lsb_msb_flipflop^=1);return this.lsb_msb_flipflop?a&-256|b:a&-65281|b<<8};A.prototype.flipflop_read=function(a){return(this.lsb_msb_flipflop^=1)?a&255:a>>8&255};function Ea(a){this.ports=[];this.cpu=a;for(var b=0;65536>b;b++)this.ports[b]=this.create_empty_entry();var c=a.memory_size[0];for(b=0;b<<17<c;b++)a.memory_map_read8[b]=a.memory_map_write8[b]=void 0,a.memory_map_read32[b]=a.memory_map_write32[b]=void 0;this.mmap_register(c,4294967296-c,function(d){y(d>>>0,8);return 255},function(d,e){y(d>>>0,8);y(e,2)},function(d){y(d>>>0,8);return-1},function(d,e){y(d>>>0,8);y(e>>>0,8)})}
|
|
62
62
|
Ea.prototype.create_empty_entry=function(){return{read8:this.empty_port_read8,read16:this.empty_port_read16,read32:this.empty_port_read32,write8:this.empty_port_write,write16:this.empty_port_write,write32:this.empty_port_write,device:void 0}};Ea.prototype.empty_port_read8=function(){return 255};Ea.prototype.empty_port_read16=function(){return 65535};Ea.prototype.empty_port_read32=function(){return-1};Ea.prototype.empty_port_write=function(){};
|
|
63
63
|
Ea.prototype.register_read=function(a,b,c,d,e){c&&(this.ports[a].read8=c);d&&(this.ports[a].read16=d);e&&(this.ports[a].read32=e);this.ports[a].device=b};Ea.prototype.register_write=function(a,b,c,d,e){c&&(this.ports[a].write8=c);d&&(this.ports[a].write16=d);e&&(this.ports[a].write32=e);this.ports[a].device=b};
|
|
64
64
|
Ea.prototype.register_read_consecutive=function(a,b,c,d,e,f){function g(){return c.call(this)|d.call(this)<<8}function h(){return e.call(this)|f.call(this)<<8}function m(){return c.call(this)|d.call(this)<<8|e.call(this)<<16|f.call(this)<<24}e&&f?(this.register_read(a,b,c,g,m),this.register_read(a+1,b,d),this.register_read(a+2,b,e,h),this.register_read(a+3,b,f)):(this.register_read(a,b,c,g),this.register_read(a+1,b,d))};
|
|
@@ -510,8 +510,8 @@ ad.prototype.get_buffer=function(){return this.buffer?new Uint8Array(this.buffer
|
|
|
510
510
|
ad.prototype.find_disk_format=function(a,b){const c=0===b,d=a.byteLength;let e=-1,f=-1,g=-1,h=-1,m=-1;for(let l=0;l<bd.length;l++){const n=bd[l],p=n.sectors*n.tracks*n.heads*512;if(d===p)if(c||n.drive_type===b){e=l;break}else c||$c[n.drive_type]!==$c[b]?g=-1===g?l:g:f=-1===f?l:f;else d<p&&(-1===m||p<m)&&(h=l,m=p)}return-1!==e?[a,bd[e]]:-1!==f?[a,bd[f]]:-1!==g?[a,bd[g]]:-1!==h?(b=new Uint8Array(m),b.set(new Uint8Array(a.buffer)),[new z(b.buffer),bd[h]]):[null,null]};
|
|
511
511
|
ad.prototype.seek=function(a,b,c){if(b>this.max_track||0!==a&&1===this.max_head)return 2;if(c>this.max_sect)return 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&&(this.media_changed=!1),d=1),this.curr_head=a,this.curr_track=b,this.curr_sect=c);this.buffer||(d=2);return d};
|
|
512
512
|
ad.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};
|
|
513
|
-
ad.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=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 z(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const cd={[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},[
|
|
514
|
-
[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}};
|
|
513
|
+
ad.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=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 z(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const cd={[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},[35]:{name:"READ FORMAT CAPACITIES",flags:1},[190]:{name:"READ CD",flags:1},
|
|
514
|
+
[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},[164]:{name:"REPORT KEY",flags:0},[173]:{name:"READ DISC STRUCTURE",flags:1}};
|
|
515
515
|
function dd(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 ed(this,0,c[0],496,1014,14));d&&(this.secondary=new ed(this,1,c[1],368,886,15));c=b?this.primary.command_base: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|
|
|
516
516
|
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,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)}
|
|
517
517
|
dd.prototype.get_state=function(){const a=[];a[0]=this.primary;a[1]=this.secondary;return a};dd.prototype.set_state=function(a){this.primary&&this.primary.set_state(a[0]);this.secondary&&this.secondary.set_state(a[1])};
|
|
@@ -545,12 +545,13 @@ break;case 225:this.status_reg=80;this.push_irq();break;case 231:this.status_reg
|
|
|
545
545
|
break;case 0:this.ata_abort_command();break;case 240:y(a);this.capture_regs();this.ata_abort_command();break;default:y(a),this.capture_regs(),this.ata_abort_command()}else y(a)};
|
|
546
546
|
X.prototype.atapi_handle=function(){var a=this.data[0],b=cd[a]?cd[a].flags:0;this.data_pointer=0;this.current_atapi_command=a;if(this.medium_changed&&this.buffer&&3!==a&&18!==a)2===this.medium_changed?(this.medium_changed=1,this.atapi_check_condition_response(2,58)):(this.medium_changed=0,this.atapi_check_condition_response(6,40)),this.push_irq();else if(3!==a&&(this.atapi_add_sense=this.atapi_sense_key=0),!this.buffer&&b&1)this.atapi_check_condition_response(2,58),this.push_irq();else{switch(a){case 0:this.buffer?
|
|
547
547
|
(this.data_allocate(0),this.data_end=this.data_length,this.status_reg=80):this.atapi_check_condition_response(2,58);break;case 3:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;this.data[0]=240;this.data[2]=this.atapi_sense_key;this.data[7]=8;this.data[12]=this.atapi_add_sense;this.atapi_add_sense=this.atapi_sense_key=0;break;case 18:a=this.data[4];this.status_reg=88;y(this.data[1],2);this.data.set([5,128,1,49,31,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79,77,32,
|
|
548
|
-
67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,a);break;case 26:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case
|
|
549
|
-
1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status_reg=88;break;case 67:a=this.data[8]|this.data[7]<<8;b=this.data[9]>>6;const c=0!==(this.data[1]&
|
|
550
|
-
18,1,1,0,20,1,0,a[0],a[1],a[2],a[3],0,22,170,0,b[0],b[1],b[2],b[3]]))):1===b&&this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0]));this.status_reg=88;break;case 70:a=Math.min(this.data[8]|this.data[7]<<8,32);this.data_allocate(a);this.data_end=this.data_length;
|
|
551
|
-
case 82:this.atapi_check_condition_response(5,36);break;case 90:a=this.data[8]|this.data[7]<<8;b=this.data[2];y(b);42===b&&this.data_allocate(Math.min(30,a));this.data_end=this.data_length;this.status_reg=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<
|
|
552
|
-
this.data_length;break;case 69:case 74:this.atapi_check_condition_response(5,36);break;case 190:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;default:ua(!1,`${this.name}: error: unimplemented ATAPI command ${y(this.data[0])}`,
|
|
553
|
-
X.prototype.atapi_check_condition_response=function(a,b){this.data_allocate(0);this.data_end=this.data_length;this.status_reg=65;this.error_reg=a<<4;this.sector_count_reg=this.sector_count_reg&-8|3;this.atapi_sense_key=a;this.atapi_add_sense=b};
|
|
548
|
+
67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,a);break;case 26:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 35:a=this.sector_count-
|
|
549
|
+
1;this.data_set(new Uint8Array([0,0,0,8,a>>24&255,a>>16&255,a>>8&255,a&255,2,this.sector_size>>16&255,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:case 168:this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status_reg=88;break;case 67:a=this.data[8]|this.data[7]<<8;b=this.data[9]>>6;const c=0!==(this.data[1]&
|
|
550
|
+
2);y(b,2);y(this.data[6]);this.data_allocate(a);this.data_end=this.data_length;0===b?(b=d=>c?[0,(d+150)/4500|0,((d+150)/75|0)%60,(d+150)%75]:[d>>24&255,d>>16&255,d>>8&255,d&255],a=b(0),b=b(this.sector_count),this.data.set(new Uint8Array([0,18,1,1,0,20,1,0,a[0],a[1],a[2],a[3],0,22,170,0,b[0],b[1],b[2],b[3]]))):1===b&&this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0]));this.status_reg=88;break;case 70:a=Math.min(this.data[8]|this.data[7]<<8,32);this.data_allocate(a);this.data_end=this.data_length;
|
|
551
|
+
this.data[0]=a-4>>24&255;this.data[1]=a-4>>16&255;this.data[2]=a-4>>8&255;this.data[3]=a-4&255;this.data[6]=8;this.data[10]=3;this.status_reg=88;break;case 81:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 82:this.atapi_check_condition_response(5,36);break;case 90:a=this.data[8]|this.data[7]<<8;b=this.data[2];y(b);42===b&&this.data_allocate(Math.min(30,a));this.data_end=this.data_length;this.status_reg=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<
|
|
552
|
+
8);this.data_end=this.data_length;this.data[5]=1;this.status_reg=88;break;case 27:a=this.data[4]&3;y(this.data[1]&1);y(a);this.buffer&&2===a&&(this.medium_changed=2,this.buffer=null);this.status_reg=80;this.data_allocate(0);this.data_end=this.data_length;break;case 69:case 74:case 164:case 173:this.atapi_check_condition_response(5,36);break;case 190:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;default:ua(!1,`${this.name}: error: unimplemented ATAPI command ${y(this.data[0])}`,
|
|
553
|
+
32768),this.atapi_check_condition_response(5,36)}this.sector_count_reg=this.sector_count_reg&-8|2;0===(this.status_reg&128)&&this.push_irq();0===(this.status_reg&128)&&0===this.data_length&&(this.sector_count_reg|=1,this.status_reg&=-9)}};X.prototype.atapi_check_condition_response=function(a,b){this.data_allocate(0);this.data_end=this.data_length;this.status_reg=65;this.error_reg=a<<4;this.sector_count_reg=this.sector_count_reg&-8|3;this.atapi_sense_key=a;this.atapi_add_sense=b};
|
|
554
|
+
X.prototype.do_write=function(){this.status_reg=80;var a=this.data.subarray(0,this.data_length);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)};
|
|
554
555
|
X.prototype.atapi_read=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5];a=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];var c=(a>>>0)*this.sector_size;b*=this.sector_size;this.data_length=0;var d=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.lba_mid_reg=this.lba_high_reg=0;65535===d&&d--;d>c&&(d=c);this.buffer?b>=this.buffer.byteLength?(ua(!1,this.name+": CD read: Outside of disk end="+y(b+c)+" size="+y(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):0===c?(this.status_reg=
|
|
555
556
|
80,this.data_pointer=0):(c=Math.min(c,this.buffer.byteLength-b),this.status_reg=208,this.report_read_start(),this.read_buffer(b,c,e=>{this.data_set(e);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.push_irq();this.data_end=d&=-4;this.data_end>this.data_length&&(this.data_end=this.data_length);this.lba_mid_reg=this.data_end&255;this.lba_high_reg=this.data_end>>8&255;this.report_read_end(c)})):(this.status_reg=255,this.error_reg=65,this.push_irq())};
|
|
556
557
|
X.prototype.atapi_read_dma=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];c>>>=0;a=a[1];var d=c*this.sector_size,e=b*this.sector_size;sa(this.name+": CD read DMA lba="+y(b)+" lbacount="+y(c)+" bytecount="+y(d)+" flags="+y(a),32768);e>=this.buffer.byteLength?(ua(!1,this.name+": CD read: Outside of disk end="+y(e+d)+" size="+y(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):(this.status_reg=208,this.report_read_start(),
|
package/build/libv86.mjs
CHANGED
|
@@ -52,12 +52,12 @@ A.prototype.port_count_write=function(a,b){y(b);this.channel_count[a]=this.flipf
|
|
|
52
52
|
function(a){y(this.channel_addr[a]);return this.flipflop_read(this.channel_addr[a])};A.prototype.port_pagehi_write=function(a,b){y(b);this.channel_pagehi[a]=b};A.prototype.port_pagehi_read=function(a){return this.channel_pagehi[a]};A.prototype.port_page_write=function(a,b){y(b);this.channel_page[a]=b};A.prototype.port_page_read=function(a){return this.channel_page[a]};A.prototype.port_singlemask_write=function(a,b){this.update_mask((b&3)+a,b&4?1:0)};A.prototype.port_multimask_write=function(a,b){y(b);
|
|
53
53
|
for(var c=0;4>c;c++)this.update_mask(a+c,b&1<<c)};A.prototype.port_multimask_read=function(a){var b=0|this.channel_mask[a+0];b|=this.channel_mask[a+1]<<1;b|=this.channel_mask[a+2]<<2;b|=this.channel_mask[a+3]<<3;y(b);return b};A.prototype.port_mode_write=function(a,b){a=(b&3)+a;y(b);this.channel_mode[a]=b};A.prototype.portC_write=function(){this.lsb_msb_flipflop=0};A.prototype.on_unmask=function(a,b){this.unmask_listeners.push({fn:a,this_value:b})};A.prototype.update_mask=function(a,b){if(this.channel_mask[a]!==
|
|
54
54
|
b&&(this.channel_mask[a]=b,!b))for(b=0;b<this.unmask_listeners.length;b++)this.unmask_listeners[b].fn.call(this.unmask_listeners[b].this_value,a)};A.prototype.do_read=function(a,b,c,d,e){var f=this.count_get_8bit(d),g=this.address_get_8bit(d);sa("to "+y(g)+" len "+y(f),16);c<f&&sa("DMA should read more than provided: "+y(c)+" "+y(f),16);if(b+f>a.byteLength)e(!0);else{var h=this.cpu;this.channel_addr[d]+=f;a.get(b,f,function(m){h.write_blob(m,g);e(!1)})}};A.prototype.do_write=function(a,b,c,d,e){var f=
|
|
55
|
-
this.channel_count[d]+1&65535,g=5<=d?2:1,h=f*g,m=this.address_get_8bit(d),l=!1,n=!1,p=this.channel_mode[d]&16;sa("to "+y(m)+" len "+y(h),16);c<h?(f=Math.floor(c/g),h=f*g,l=!0):c>h&&(n=!0);b+h>a.byteLength?e(!0):(this.channel_addr[d]+=f,this.channel_count[d]-=f,!l&&p&&(this.channel_addr[d]=this.channel_addr_init[d],this.channel_count[d]=this.channel_count_init[d]),a.set(b,this.cpu.mem8.subarray(m,m+h),()=>{n&&p?this.do_write(a,b+h,c-h,d,e):e(!1)}))};A.prototype.address_get_8bit=function(a){var b=this.channel_addr[a]
|
|
56
|
-
5<=a&&(b<<=1);b=b
|
|
57
|
-
for(b=0;b<<17<c;b++)a.memory_map_read8[b]=a.memory_map_write8[b]=void 0,a.memory_map_read32[b]=a.memory_map_write32[b]=void 0;this.mmap_register(c,4294967296-c,function(d){y(d>>>0,8);return 255},function(d,e){y(d>>>0,8);y(e,2)},function(d){y(d>>>0,8);return-1},function(d,e){y(d>>>0,8);y(e>>>0,8)})}Ea.prototype.create_empty_entry=function(){return{read8:this.empty_port_read8,read16:this.empty_port_read16,read32:this.empty_port_read32,write8:this.empty_port_write,write16:this.empty_port_write,
|
|
58
|
-
device:void 0}};Ea.prototype.empty_port_read8=function(){return 255};Ea.prototype.empty_port_read16=function(){return 65535};Ea.prototype.empty_port_read32=function(){return-1};Ea.prototype.empty_port_write=function(){};Ea.prototype.register_read=function(a,b,c,d,e){c&&(this.ports[a].read8=c);d&&(this.ports[a].read16=d);e&&(this.ports[a].read32=e);this.ports[a].device=b};Ea.prototype.register_write=function(a,b,c,d,e){c&&(this.ports[a].write8=c);d&&(this.ports[a].write16=
|
|
59
|
-
e);this.ports[a].device=b};Ea.prototype.register_read_consecutive=function(a,b,c,d,e,f){function g(){return c.call(this)|d.call(this)<<8}function h(){return e.call(this)|f.call(this)<<8}function m(){return c.call(this)|d.call(this)<<8|e.call(this)<<16|f.call(this)<<24}e&&f?(this.register_read(a,b,c,g,m),this.register_read(a+1,b,d),this.register_read(a+2,b,e,h),this.register_read(a+3,b,f)):(this.register_read(a,b,c,g),this.register_read(a+1,b,d))};Ea.prototype.register_write_consecutive=
|
|
60
|
-
b,c,d,e,f){function g(l){c.call(this,l&255);d.call(this,l>>8&255)}function h(l){e.call(this,l&255);f.call(this,l>>8&255)}function m(l){c.call(this,l&255);d.call(this,l>>8&255);e.call(this,l>>16&255);f.call(this,l>>>24)}e&&f?(this.register_write(a,b,c,g,m),this.register_write(a+1,b,d),this.register_write(a+2,b,e,h),this.register_write(a+3,b,f)):(this.register_write(a,b,c,g),this.register_write(a+1,b,d))};Ea.prototype.mmap_read32_shim=function(a){var b=this.cpu.memory_map_read8[a>>>17];return b(a)|
|
|
55
|
+
this.channel_count[d]+1&65535,g=5<=d?2:1,h=f*g,m=this.address_get_8bit(d),l=!1,n=!1,p=this.channel_mode[d]&16;sa("to "+y(m)+" len "+y(h),16);c<h?(f=Math.floor(c/g),h=f*g,l=!0):c>h&&(n=!0);b+h>a.byteLength?e(!0):(this.channel_addr[d]+=f,this.channel_count[d]-=f,!l&&p&&(this.channel_addr[d]=this.channel_addr_init[d],this.channel_count[d]=this.channel_count_init[d]),a.set(b,this.cpu.mem8.subarray(m,m+h),()=>{n&&p?this.do_write(a,b+h,c-h,d,e):e(!1)}))};A.prototype.address_get_8bit=function(a){var b=this.channel_addr[a],
|
|
56
|
+
c=this.channel_page[a];5<=a&&(b<<=1,c&=254);return b=b|c<<16|this.channel_pagehi[a]<<24};A.prototype.count_get_8bit=function(a){var b=this.channel_count[a]+1;5<=a&&(b*=2);return b};A.prototype.flipflop_get=function(a,b,c){c||(this.lsb_msb_flipflop^=1);return this.lsb_msb_flipflop?a&-256|b:a&-65281|b<<8};A.prototype.flipflop_read=function(a){return(this.lsb_msb_flipflop^=1)?a&255:a>>8&255};function Ea(a){this.ports=[];this.cpu=a;for(var b=0;65536>b;b++)this.ports[b]=this.create_empty_entry();var c=
|
|
57
|
+
a.memory_size[0];for(b=0;b<<17<c;b++)a.memory_map_read8[b]=a.memory_map_write8[b]=void 0,a.memory_map_read32[b]=a.memory_map_write32[b]=void 0;this.mmap_register(c,4294967296-c,function(d){y(d>>>0,8);return 255},function(d,e){y(d>>>0,8);y(e,2)},function(d){y(d>>>0,8);return-1},function(d,e){y(d>>>0,8);y(e>>>0,8)})}Ea.prototype.create_empty_entry=function(){return{read8:this.empty_port_read8,read16:this.empty_port_read16,read32:this.empty_port_read32,write8:this.empty_port_write,write16:this.empty_port_write,
|
|
58
|
+
write32:this.empty_port_write,device:void 0}};Ea.prototype.empty_port_read8=function(){return 255};Ea.prototype.empty_port_read16=function(){return 65535};Ea.prototype.empty_port_read32=function(){return-1};Ea.prototype.empty_port_write=function(){};Ea.prototype.register_read=function(a,b,c,d,e){c&&(this.ports[a].read8=c);d&&(this.ports[a].read16=d);e&&(this.ports[a].read32=e);this.ports[a].device=b};Ea.prototype.register_write=function(a,b,c,d,e){c&&(this.ports[a].write8=c);d&&(this.ports[a].write16=
|
|
59
|
+
d);e&&(this.ports[a].write32=e);this.ports[a].device=b};Ea.prototype.register_read_consecutive=function(a,b,c,d,e,f){function g(){return c.call(this)|d.call(this)<<8}function h(){return e.call(this)|f.call(this)<<8}function m(){return c.call(this)|d.call(this)<<8|e.call(this)<<16|f.call(this)<<24}e&&f?(this.register_read(a,b,c,g,m),this.register_read(a+1,b,d),this.register_read(a+2,b,e,h),this.register_read(a+3,b,f)):(this.register_read(a,b,c,g),this.register_read(a+1,b,d))};Ea.prototype.register_write_consecutive=
|
|
60
|
+
function(a,b,c,d,e,f){function g(l){c.call(this,l&255);d.call(this,l>>8&255)}function h(l){e.call(this,l&255);f.call(this,l>>8&255)}function m(l){c.call(this,l&255);d.call(this,l>>8&255);e.call(this,l>>16&255);f.call(this,l>>>24)}e&&f?(this.register_write(a,b,c,g,m),this.register_write(a+1,b,d),this.register_write(a+2,b,e,h),this.register_write(a+3,b,f)):(this.register_write(a,b,c,g),this.register_write(a+1,b,d))};Ea.prototype.mmap_read32_shim=function(a){var b=this.cpu.memory_map_read8[a>>>17];return b(a)|
|
|
61
61
|
b(a+1)<<8|b(a+2)<<16|b(a+3)<<24};Ea.prototype.mmap_write32_shim=function(a,b){var c=this.cpu.memory_map_write8[a>>>17];c(a,b&255);c(a+1,b>>8&255);c(a+2,b>>16&255);c(a+3,b>>>24)};Ea.prototype.mmap_register=function(a,b,c,d,e,f){y(a>>>0,8);y(b,8);e||(e=this.mmap_read32_shim.bind(this));f||(f=this.mmap_write32_shim.bind(this));for(a>>>=17;0<b;a++)this.cpu.memory_map_read8[a]=c,this.cpu.memory_map_write8[a]=d,this.cpu.memory_map_read32[a]=e,this.cpu.memory_map_write32[a]=f,b-=131072};Ea.prototype.port_write8=
|
|
62
62
|
function(a,b){var c=this.ports[a];c.write8===this.empty_port_write&&(y(a,4),y(b,2),this.get_port_description(a));return c.write8.call(c.device,b)};Ea.prototype.port_write16=function(a,b){var c=this.ports[a];c.write16===this.empty_port_write&&(y(a,4),y(b,4),this.get_port_description(a));return c.write16.call(c.device,b)};Ea.prototype.port_write32=function(a,b){var c=this.ports[a];c.write32===this.empty_port_write&&(y(a,4),y(b>>>0,8),this.get_port_description(a));return c.write32.call(c.device,b)};
|
|
63
63
|
Ea.prototype.port_read8=function(a){var b=this.ports[a];b.read8===this.empty_port_read8&&(y(a,4),this.get_port_description(a));b=b.read8.call(b.device,a);(0>b||256<=b)&&y(a);return b};Ea.prototype.port_read16=function(a){var b=this.ports[a];b.read16===this.empty_port_read16&&(y(a,4),this.get_port_description(a));b=b.read16.call(b.device,a);(0>b||65536<=b)&&y(a);return b};Ea.prototype.port_read32=function(a){var b=this.ports[a];b.read32===this.empty_port_read32&&(y(a,4),this.get_port_description(a));
|
|
@@ -455,39 +455,40 @@ heads:2},{drive_type:2,sectors:8,tracks:40,heads:1},{drive_type:4,sectors:9,trac
|
|
|
455
455
|
p&&(-1===m||p<m)&&(h=l,m=p)}return-1!==e?[a,bd[e]]:-1!==f?[a,bd[f]]:-1!==g?[a,bd[g]]:-1!==h?(b=new Uint8Array(m),b.set(new Uint8Array(a.buffer)),[new z(b.buffer),bd[h]]):[null,null]};ad.prototype.seek=function(a,b,c){if(b>this.max_track||0!==a&&1===this.max_head)return 2;if(c>this.max_sect)return 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&&(this.media_changed=!1),d=1),this.curr_head=a,this.curr_track=
|
|
456
456
|
b,this.curr_sect=c);this.buffer||(d=2);return d};ad.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};ad.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=a[2];this.max_sect=a[3];this.curr_track=a[4];this.curr_head=
|
|
457
457
|
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 z(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const cd={[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",
|
|
458
|
-
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},[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}
|
|
459
|
-
const d=c&&c[1][0];if(b||d){b&&(this.primary=new ed(this,0,c[0],496,1014,14));d&&(this.secondary=new ed(this,1,c[1],368,886,15));c=b?this.primary.command_base: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>>
|
|
460
|
-
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,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)}dd.prototype.get_state=function(){const a=[];a[0]=this.primary;
|
|
461
|
-
this.secondary&&this.secondary.set_state(a[1])};function ed(a,b,c,d,e,f){this.controller=a;this.channel_nr=b;this.cpu=a.cpu;this.bus=a.bus;this.command_base=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=
|
|
462
|
-
function(){return this.current_interface.read_data(
|
|
463
|
-
255});a.io.register_read(this.command_base|
|
|
464
|
-
a.io.register_write(this.command_base|
|
|
465
|
-
(this.slave.
|
|
466
|
-
this.master||!h&&this.current_interface===this.slave)this.current_interface=h?this.slave:this.master;this.master.device_reg=g;this.slave.device_reg=g;this.master.is_lba=g>>6&1;this.slave.is_lba=g>>6&1;this.master.head=g&15;this.slave.head=g&15});a.io.register_write(this.command_base|7,this,function(g){this.current_interface.status_reg
|
|
467
|
-
0,this,this.write_control);b=46080+8*b;a.io.register_read(b|0,this,this.dma_read_command8,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|
|
|
468
|
-
this.current_interface.status_reg:0};ed.prototype.write_control=function(a){a&4&&(this.cpu.device_lower_irq(this.irq),this.master.device_reset(),this.slave.device_reset());this.device_control_reg=a};ed.prototype.dma_read_addr=function(){return this.prdt_addr};ed.prototype.dma_set_addr=function(a){this.prdt_addr=a};
|
|
469
|
-
this.dma_read_status()<<16};ed.prototype.dma_read_command8=function(){return this.dma_command};ed.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};ed.prototype.dma_write_command8=function(a){const b=this.dma_command;this.dma_command=a&9;if((b&
|
|
470
|
-
break;case 160:this.current_interface.do_atapi_dma();break;default:y(this.current_interface.current_command),this.dma_status&=-2,this.dma_status|=2,this.push_irq()}};ed.prototype.push_irq=function(){0===(this.device_control_reg&2)&&(this.dma_status|=
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
X.prototype.set_cdrom=function(a){this.is_atapi&&a&&(this.set_disk_buffer(a),this.medium_changed=2)};X.prototype.get_disk_geometry=function(){var a=512<=this.buffer.byteLength?this.buffer.get_from_cache(0,512):void 0;if(a&&85===
|
|
475
|
-
f,f=0):(b=16,e=63,a=this.sector_count/(b*e)|0,16383<a?a=16383:2>a&&(a=2),f=!f&&1024>=a?0:f&&131072>=16*a?2:1);return{cylinders:a,heads:b,sectors:e,translation:f}};X.prototype.set_disk_buffer=function(a){if(a){this.buffer=
|
|
476
|
-
this.sector_count
|
|
477
|
-
240:15)),a.cmos_write(b?25:26,47),b=b?27:36,a.cmos_write(b+0,this.cylinder_count&255),a.cmos_write(b+1,this.cylinder_count>>8&255),a.cmos_write(b+2,this.head_count&255),a.cmos_write(b+3,255),a.cmos_write(b+4,255),a.cmos_write(b+
|
|
478
|
-
this.error_reg=this.sector_count_reg=1,this.lba_mid_reg=20,this.lba_high_reg=235):(this.status_reg=81,this.lba_low_reg=this.error_reg=this.sector_count_reg=1,this.lba_high_reg=this.lba_mid_reg=0);this.cancel_io_operations()};
|
|
479
|
-
255)} LL=${y(this.lba_low_reg&255)} `+`LM=${y(this.lba_mid_reg&255)} LH=${y(this.lba_high_reg&255)} `+`FE=${y(this.features_reg&255)}`};X.prototype.ata_command=function(a){if(this.drive_connected||144===a)switch(this.current_command=
|
|
480
|
-
this.
|
|
481
|
-
break;case 48:case 52:case 57:case 197:this.is_atapi?this.ata_abort_command():this.ata_write_sectors(a);break;case 144:this.channel.master.status_reg=80;this.channel.master.error_reg=1;this.channel.master.push_irq();this.channel.slave.drive_connected&&
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
80;this.push_irq();break;case
|
|
485
|
-
a&&18!==a)2===this.medium_changed?(this.medium_changed=1,this.atapi_check_condition_response(2,58)):(this.medium_changed=0,this.atapi_check_condition_response(6,40)),this.push_irq();else if(3!==a&&(this.atapi_add_sense=this.atapi_sense_key=
|
|
486
|
-
this.data_end=this.data_length;this.status_reg=88;this.data[0]=240;this.data[2]=this.atapi_sense_key;this.data[7]=8;this.data[12]=this.atapi_add_sense;this.atapi_add_sense=this.atapi_sense_key=0;break;case 18:a=this.data[4];this.status_reg=
|
|
487
|
-
this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&
|
|
488
|
-
this.status_reg=88;break;case
|
|
489
|
-
break;case
|
|
490
|
-
|
|
458
|
+
flags:0},[40]:{name:"READ (10)",flags:1},[168]:{name:"READ (12)",flags:1},[37]:{name:"READ CAPACITY",flags:1},[35]:{name:"READ FORMAT CAPACITIES",flags:1},[190]:{name:"READ CD",flags:1},[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},[164]:{name:"REPORT KEY",flags:0},[173]:{name:"READ DISC STRUCTURE",
|
|
459
|
+
flags:1}};function dd(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 ed(this,0,c[0],496,1014,14));d&&(this.secondary=new ed(this,1,c[1],368,886,15));c=b?this.primary.command_base: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>>
|
|
460
|
+
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,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)}dd.prototype.get_state=function(){const a=[];a[0]=this.primary;
|
|
461
|
+
a[1]=this.secondary;return a};dd.prototype.set_state=function(a){this.primary&&this.primary.set_state(a[0]);this.secondary&&this.secondary.set_state(a[1])};function ed(a,b,c,d,e,f){this.controller=a;this.channel_nr=b;this.cpu=a.cpu;this.bus=a.bus;this.command_base=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=
|
|
462
|
+
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)});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|
|
|
463
|
+
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&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});
|
|
464
|
+
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.master.features_reg=(this.master.features_reg<<8|g)&65535;this.slave.features_reg=(this.slave.features_reg<<8|g)&65535});a.io.register_write(this.command_base|2,this,function(g){this.master.sector_count_reg=(this.master.sector_count_reg<<
|
|
465
|
+
8|g)&65535;this.slave.sector_count_reg=(this.slave.sector_count_reg<<8|g)&65535});a.io.register_write(this.command_base|3,this,function(g){this.master.lba_low_reg=(this.master.lba_low_reg<<8|g)&65535;this.slave.lba_low_reg=(this.slave.lba_low_reg<<8|g)&65535});a.io.register_write(this.command_base|4,this,function(g){this.master.lba_mid_reg=(this.master.lba_mid_reg<<8|g)&65535;this.slave.lba_mid_reg=(this.slave.lba_mid_reg<<8|g)&65535});a.io.register_write(this.command_base|5,this,function(g){this.master.lba_high_reg=
|
|
466
|
+
(this.master.lba_high_reg<<8|g)&65535;this.slave.lba_high_reg=(this.slave.lba_high_reg<<8|g)&65535});a.io.register_write(this.command_base|6,this,function(g){const h=g&16;if(h&&this.current_interface===this.master||!h&&this.current_interface===this.slave)this.current_interface=h?this.slave:this.master;this.master.device_reg=g;this.slave.device_reg=g;this.master.is_lba=g>>6&1;this.slave.is_lba=g>>6&1;this.master.head=g&15;this.slave.head=g&15});a.io.register_write(this.command_base|7,this,function(g){this.current_interface.status_reg&=
|
|
467
|
+
-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,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|
|
|
468
|
+
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)}ed.prototype.read_status=function(){return this.current_interface.drive_connected?this.current_interface.status_reg:0};ed.prototype.write_control=function(a){a&4&&(this.cpu.device_lower_irq(this.irq),this.master.device_reset(),this.slave.device_reset());this.device_control_reg=a};ed.prototype.dma_read_addr=function(){return this.prdt_addr};ed.prototype.dma_set_addr=function(a){this.prdt_addr=a};
|
|
469
|
+
ed.prototype.dma_read_status=function(){return this.dma_status};ed.prototype.dma_write_status=function(a){this.dma_status&=~(a&6)};ed.prototype.dma_read_command=function(){return this.dma_read_command8()|this.dma_read_status()<<16};ed.prototype.dma_read_command8=function(){return this.dma_command};ed.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};ed.prototype.dma_write_command8=function(a){const b=this.dma_command;this.dma_command=a&9;if((b&
|
|
470
|
+
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();break;case 202:case 53:this.current_interface.do_ata_write_sectors_dma();break;case 160:this.current_interface.do_atapi_dma();break;default:y(this.current_interface.current_command),this.dma_status&=-2,this.dma_status|=2,this.push_irq()}};ed.prototype.push_irq=function(){0===(this.device_control_reg&2)&&(this.dma_status|=
|
|
471
|
+
4,this.cpu.device_raise_irq(this.irq))};ed.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};ed.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];
|
|
472
|
+
this.device_control_reg=a[8];this.prdt_addr=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=
|
|
473
|
+
this.lba_low_reg=this.sector_count_reg=this.is_lba=this.cylinder_count=this.sectors_per_track=0;this.status_reg=80;this.sectors_per_drq=128;this.data_pointer=this.error_reg=0;this.data=new Uint8Array(65536);this.data16=new Uint16Array(this.data.buffer);this.data32=new Int32Array(this.data.buffer);this.data_end=this.data_length=0;this.current_command=-1;this.last_io_id=this.write_dest=0;this.in_progress_io_ids=new Map;this.cancelled_io_ids=new Set;this.current_atapi_command=-1;this.medium_changed=
|
|
474
|
+
this.atapi_add_sense=this.atapi_sense_key=0;this.set_disk_buffer(c);Object.seal(this)}X.prototype.has_disk=function(){return!!this.buffer};X.prototype.eject=function(){this.is_atapi&&this.buffer&&(this.medium_changed=2,this.buffer=null,this.status_reg=89,this.push_irq())};X.prototype.set_cdrom=function(a){this.is_atapi&&a&&(this.set_disk_buffer(a),this.medium_changed=2)};X.prototype.get_disk_geometry=function(){var a=512<=this.buffer.byteLength?this.buffer.get_from_cache(0,512):void 0;if(a&&85===
|
|
475
|
+
a[510]&&170===a[511])for(var b=0;4>b;b++){var c=446+16*b,d=a[c+5],e=a[c+6]&63;if((a[c+12]|a[c+13]<<8|a[c+14]<<16|a[c+15]<<24)>>>0&&d&&e&&(c=d+1,d=this.sector_count/(c*e)|0,1<=d&&16383>=d)){var f={cylinders:d,heads:c,sectors:e};break}}f&&16>=f.heads?({cylinders:a,heads:b,sectors:e}=f,f=0):(b=16,e=63,a=this.sector_count/(b*e)|0,16383<a?a=16383:2>a&&(a=2),f=!f&&1024>=a?0:f&&131072>=16*a?2:1);return{cylinders:a,heads:b,sectors:e,translation:f}};X.prototype.set_disk_buffer=function(a){if(a){this.buffer=
|
|
476
|
+
a;this.is_atapi&&(this.status_reg=89,this.error_reg=96);this.sector_count=this.buffer.byteLength/this.sector_size;this.sector_count!==(this.sector_count|0)&&(this.sector_count=Math.ceil(this.sector_count));if(this.is_atapi)this.head_count=1,this.sectors_per_track=2048,this.cylinder_count=this.sector_count/this.head_count/this.sectors_per_track,this.cylinder_count!==(this.cylinder_count|0)&&(this.cylinder_count=Math.floor(this.cylinder_count));else{const {cylinders:c,heads:d,sectors:e,translation:f}=
|
|
477
|
+
this.get_disk_geometry();this.cylinder_count=c;this.head_count=d;this.sectors_per_track=e;a=this.cpu.devices.rtc;var b=2*(2*this.channel_nr+this.interface_nr);a.cmos_write(57,a.cmos_read(57)&~(3<<b)|f<<b);0===this.channel_nr&&(b=0===this.interface_nr,a.cmos_write(18,a.cmos_read(18)|(b?240:15)),a.cmos_write(b?25:26,47),b=b?27:36,a.cmos_write(b+0,this.cylinder_count&255),a.cmos_write(b+1,this.cylinder_count>>8&255),a.cmos_write(b+2,this.head_count&255),a.cmos_write(b+3,255),a.cmos_write(b+4,255),a.cmos_write(b+
|
|
478
|
+
5,192|(8<this.head_count?1:0)<<3),a.cmos_write(b+6,this.cylinder_count&255),a.cmos_write(b+7,this.cylinder_count>>8&255),a.cmos_write(b+8,this.sectors_per_track&255))}this.channel.cpu&&this.push_irq()}};X.prototype.device_reset=function(){this.is_atapi?(this.status_reg=0,this.lba_low_reg=this.error_reg=this.sector_count_reg=1,this.lba_mid_reg=20,this.lba_high_reg=235):(this.status_reg=81,this.lba_low_reg=this.error_reg=this.sector_count_reg=1,this.lba_high_reg=this.lba_mid_reg=0);this.cancel_io_operations()};
|
|
479
|
+
X.prototype.push_irq=function(){this.channel.push_irq()};X.prototype.ata_abort_command=function(){this.error_reg=4;this.status_reg=65;this.push_irq()};X.prototype.capture_regs=function(){return`ST=${y(this.status_reg&255)} ER=${y(this.error_reg&255)} `+`SC=${y(this.sector_count_reg&255)} LL=${y(this.lba_low_reg&255)} `+`LM=${y(this.lba_mid_reg&255)} LH=${y(this.lba_high_reg&255)} `+`FE=${y(this.features_reg&255)}`};X.prototype.ata_command=function(a){if(this.drive_connected||144===a)switch(this.current_command=
|
|
480
|
+
a,this.error_reg=0,a){case 8:this.data_length=this.data_end=this.data_pointer=0;this.device_reset();this.push_irq();break;case 16:this.lba_mid_reg=0;this.status_reg=80;this.push_irq();break;case 248:a=this.sector_count-1;this.lba_low_reg=a&255;this.lba_mid_reg=a>>8&255;this.lba_high_reg=a>>16&255;this.device_reg=this.device_reg&240|a>>24&15;this.status_reg=80;this.push_irq();break;case 39:a=this.sector_count-1;this.lba_low_reg=a&255;this.lba_mid_reg=a>>8&255;this.lba_high_reg=a>>16&255;this.lba_low_reg|=
|
|
481
|
+
a>>24<<8&65280;this.status_reg=80;this.push_irq();break;case 32:this.is_atapi?(this.lba_mid_reg=20,this.lba_high_reg=235,this.ata_abort_command()):this.ata_read_sectors(a);break;case 36:case 41:case 196:this.is_atapi?this.ata_abort_command():this.ata_read_sectors(a);break;case 48:case 52:case 57:case 197:this.is_atapi?this.ata_abort_command():this.ata_write_sectors(a);break;case 144:this.channel.master.status_reg=80;this.channel.master.error_reg=1;this.channel.master.push_irq();this.channel.slave.drive_connected&&
|
|
482
|
+
(this.channel.slave.status_reg=80,this.channel.slave.error_reg=1,this.channel.slave.push_irq());break;case 145:this.status_reg=80;this.push_irq();break;case 160:this.is_atapi?(this.data_allocate(12),this.data_end=12,this.sector_count_reg=1,this.status_reg=88,this.push_irq()):this.ata_abort_command();break;case 161:this.is_atapi?(this.create_identify_packet(),this.status_reg=88,this.push_irq()):this.ata_abort_command();break;case 198:y(this.sector_count_reg&255);this.sectors_per_drq=this.sector_count_reg&
|
|
483
|
+
255;this.status_reg=80;this.push_irq();break;case 200:case 37:this.ata_read_sectors_dma(a);break;case 202:case 53:this.ata_write_sectors_dma(a);break;case 64:this.status_reg=80;this.push_irq();break;case 218:this.is_atapi&&(this.buffer||(this.error_reg|=2),this.medium_changed&&(this.error_reg|=32,this.medium_changed=0),this.error_reg|=64);this.status_reg=80;this.push_irq();break;case 224:this.status_reg=80;this.push_irq();break;case 225:this.status_reg=80;this.push_irq();break;case 231:this.status_reg=
|
|
484
|
+
80;this.push_irq();break;case 234:this.status_reg=80;this.push_irq();break;case 236:this.is_atapi?(this.lba_mid_reg=20,this.lba_high_reg=235,this.ata_abort_command()):(this.create_identify_packet(),this.status_reg=88,this.push_irq());break;case 239:this.status_reg=80;this.push_irq();break;case 222:this.status_reg=64;this.push_irq();break;case 245:this.status_reg=80;this.push_irq();break;case 249:this.ata_abort_command();break;case 0:this.ata_abort_command();break;case 240:y(a);this.capture_regs();
|
|
485
|
+
this.ata_abort_command();break;default:y(a),this.capture_regs(),this.ata_abort_command()}else y(a)};X.prototype.atapi_handle=function(){var a=this.data[0],b=cd[a]?cd[a].flags:0;this.data_pointer=0;this.current_atapi_command=a;if(this.medium_changed&&this.buffer&&3!==a&&18!==a)2===this.medium_changed?(this.medium_changed=1,this.atapi_check_condition_response(2,58)):(this.medium_changed=0,this.atapi_check_condition_response(6,40)),this.push_irq();else if(3!==a&&(this.atapi_add_sense=this.atapi_sense_key=
|
|
486
|
+
0),!this.buffer&&b&1)this.atapi_check_condition_response(2,58),this.push_irq();else{switch(a){case 0:this.buffer?(this.data_allocate(0),this.data_end=this.data_length,this.status_reg=80):this.atapi_check_condition_response(2,58);break;case 3:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;this.data[0]=240;this.data[2]=this.atapi_sense_key;this.data[7]=8;this.data[12]=this.atapi_add_sense;this.atapi_add_sense=this.atapi_sense_key=0;break;case 18:a=this.data[4];this.status_reg=
|
|
487
|
+
88;y(this.data[1],2);this.data.set([5,128,1,49,31,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79,77,32,67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,a);break;case 26:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&
|
|
488
|
+
255]));this.data_end=this.data_length;this.status_reg=88;break;case 35:a=this.sector_count-1;this.data_set(new Uint8Array([0,0,0,8,a>>24&255,a>>16&255,a>>8&255,a&255,2,this.sector_size>>16&255,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:case 168:this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status_reg=
|
|
489
|
+
88;break;case 67:a=this.data[8]|this.data[7]<<8;b=this.data[9]>>6;const c=0!==(this.data[1]&2);y(b,2);y(this.data[6]);this.data_allocate(a);this.data_end=this.data_length;0===b?(b=d=>c?[0,(d+150)/4500|0,((d+150)/75|0)%60,(d+150)%75]:[d>>24&255,d>>16&255,d>>8&255,d&255],a=b(0),b=b(this.sector_count),this.data.set(new Uint8Array([0,18,1,1,0,20,1,0,a[0],a[1],a[2],a[3],0,22,170,0,b[0],b[1],b[2],b[3]]))):1===b&&this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0]));this.status_reg=88;break;case 70:a=
|
|
490
|
+
Math.min(this.data[8]|this.data[7]<<8,32);this.data_allocate(a);this.data_end=this.data_length;this.data[0]=a-4>>24&255;this.data[1]=a-4>>16&255;this.data[2]=a-4>>8&255;this.data[3]=a-4&255;this.data[6]=8;this.data[10]=3;this.status_reg=88;break;case 81:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 82:this.atapi_check_condition_response(5,36);break;case 90:a=this.data[8]|this.data[7]<<8;b=this.data[2];y(b);42===b&&this.data_allocate(Math.min(30,a));this.data_end=
|
|
491
|
+
this.data_length;this.status_reg=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<8);this.data_end=this.data_length;this.data[5]=1;this.status_reg=88;break;case 27:a=this.data[4]&3;y(this.data[1]&1);y(a);this.buffer&&2===a&&(this.medium_changed=2,this.buffer=null);this.status_reg=80;this.data_allocate(0);this.data_end=this.data_length;break;case 69:case 74:case 164:case 173:this.atapi_check_condition_response(5,36);break;case 190:this.data_allocate(0);this.data_end=this.data_length;
|
|
491
492
|
this.status_reg=80;break;default:ua(!1,`${this.name}: error: unimplemented ATAPI command ${y(this.data[0])}`,32768),this.atapi_check_condition_response(5,36)}this.sector_count_reg=this.sector_count_reg&-8|2;0===(this.status_reg&128)&&this.push_irq();0===(this.status_reg&128)&&0===this.data_length&&(this.sector_count_reg|=1,this.status_reg&=-9)}};X.prototype.atapi_check_condition_response=function(a,b){this.data_allocate(0);this.data_end=this.data_length;this.status_reg=65;this.error_reg=a<<4;this.sector_count_reg=
|
|
492
493
|
this.sector_count_reg&-8|3;this.atapi_sense_key=a;this.atapi_add_sense=b};X.prototype.do_write=function(){this.status_reg=80;var a=this.data.subarray(0,this.data_length);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)};X.prototype.atapi_read=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5];a=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];var c=(a>>>0)*this.sector_size;b*=this.sector_size;
|
|
493
494
|
this.data_length=0;var d=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.lba_mid_reg=this.lba_high_reg=0;65535===d&&d--;d>c&&(d=c);this.buffer?b>=this.buffer.byteLength?(ua(!1,this.name+": CD read: Outside of disk end="+y(b+c)+" size="+y(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):0===c?(this.status_reg=80,this.data_pointer=0):(c=Math.min(c,this.buffer.byteLength-b),this.status_reg=208,this.report_read_start(),this.read_buffer(b,c,e=>{this.data_set(e);this.status_reg=
|
package/build/v86-debug.wasm
CHANGED
|
Binary file
|
package/build/v86-fallback.wasm
CHANGED
|
Binary file
|
package/build/v86.wasm
CHANGED
|
Binary file
|