v86 0.5.330 → 0.5.334
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/Readme.md +1 -1
- package/build/libv86-debug.js +6 -3
- package/build/libv86-debug.mjs +6 -3
- package/build/libv86.js +2 -2
- package/build/libv86.mjs +4 -4
- 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/v86.d.ts +897 -0
package/Readme.md
CHANGED
|
@@ -192,7 +192,7 @@ var emulator = new V86({
|
|
|
192
192
|
});
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
See [
|
|
195
|
+
See [v86.d.ts](v86.d.ts) for TypeScript definitions. You can use `make doc` (TypeDoc) or `make denodoc` (Deno) to generate HTML documentation in `./docs/api/`.
|
|
196
196
|
|
|
197
197
|
## License
|
|
198
198
|
|
package/build/libv86-debug.js
CHANGED
|
@@ -8452,9 +8452,12 @@ function $IDEChannel$$module$src$ide$$($controller_cpu$jscomp$22$$, $bus_master_
|
|
|
8452
8452
|
if ($select_slave$$ && this.current_interface === this.master || !$select_slave$$ && this.current_interface === this.slave) {
|
|
8453
8453
|
$select_slave$$ ? ($dbg_log$$module$src$log$$(`${this.current_interface.name}: select slave device (${this.channel_nr ? "secondary" : "primary"})`, 32768), this.current_interface = this.slave) : ($dbg_log$$module$src$log$$(`${this.current_interface.name}: select master device (${this.channel_nr ? "secondary" : "primary"})`, 32768), this.current_interface = this.master);
|
|
8454
8454
|
}
|
|
8455
|
-
this.
|
|
8456
|
-
this.
|
|
8457
|
-
this.
|
|
8455
|
+
this.master.device_reg = $data$jscomp$192$$;
|
|
8456
|
+
this.slave.device_reg = $data$jscomp$192$$;
|
|
8457
|
+
this.master.is_lba = $data$jscomp$192$$ >> 6 & 1;
|
|
8458
|
+
this.slave.is_lba = $data$jscomp$192$$ >> 6 & 1;
|
|
8459
|
+
this.master.head = $data$jscomp$192$$ & 15;
|
|
8460
|
+
this.slave.head = $data$jscomp$192$$ & 15;
|
|
8458
8461
|
});
|
|
8459
8462
|
$controller_cpu$jscomp$22$$.io.register_write(this.command_base | 7, this, function($data$jscomp$193$$) {
|
|
8460
8463
|
this.current_interface.status_reg &= -34;
|
package/build/libv86-debug.mjs
CHANGED
|
@@ -8451,9 +8451,12 @@ function $IDEChannel$$module$src$ide$$($controller_cpu$jscomp$22$$, $bus_master_
|
|
|
8451
8451
|
if ($select_slave$$ && this.current_interface === this.master || !$select_slave$$ && this.current_interface === this.slave) {
|
|
8452
8452
|
$select_slave$$ ? ($dbg_log$$module$src$log$$(`${this.current_interface.name}: select slave device (${this.channel_nr ? "secondary" : "primary"})`, 32768), this.current_interface = this.slave) : ($dbg_log$$module$src$log$$(`${this.current_interface.name}: select master device (${this.channel_nr ? "secondary" : "primary"})`, 32768), this.current_interface = this.master);
|
|
8453
8453
|
}
|
|
8454
|
-
this.
|
|
8455
|
-
this.
|
|
8456
|
-
this.
|
|
8454
|
+
this.master.device_reg = $data$jscomp$192$$;
|
|
8455
|
+
this.slave.device_reg = $data$jscomp$192$$;
|
|
8456
|
+
this.master.is_lba = $data$jscomp$192$$ >> 6 & 1;
|
|
8457
|
+
this.slave.is_lba = $data$jscomp$192$$ >> 6 & 1;
|
|
8458
|
+
this.master.head = $data$jscomp$192$$ & 15;
|
|
8459
|
+
this.slave.head = $data$jscomp$192$$ & 15;
|
|
8457
8460
|
});
|
|
8458
8461
|
$controller_cpu$jscomp$22$$.io.register_write(this.command_base | 7, this, function($data$jscomp$193$$) {
|
|
8459
8462
|
this.current_interface.status_reg &= -34;
|
package/build/libv86.js
CHANGED
|
@@ -478,8 +478,8 @@ function(){return this.current_interface.read_data(2)},function(){return this.cu
|
|
|
478
478
|
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});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)});
|
|
479
479
|
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<<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=
|
|
480
480
|
(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=(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===
|
|
481
|
-
this.master||!h&&this.current_interface===this.slave)this.current_interface=h?this.slave:this.master;this.
|
|
482
|
-
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|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)}
|
|
481
|
+
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&=-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|
|
|
482
|
+
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|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)}
|
|
483
483
|
Vc.prototype.read_status=function(){return this.current_interface.drive_connected?this.current_interface.status_reg:0};Vc.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};Vc.prototype.dma_read_addr=function(){return this.prdt_addr};Vc.prototype.dma_set_addr=function(a){this.prdt_addr=a};Vc.prototype.dma_read_status=function(){return this.dma_status};
|
|
484
484
|
Vc.prototype.dma_write_status=function(a){this.dma_status&=~(a&6)};Vc.prototype.dma_read_command=function(){return this.dma_read_command8()|this.dma_read_status()<<16};Vc.prototype.dma_read_command8=function(){return this.dma_command};Vc.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};
|
|
485
485
|
Vc.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();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()}};
|
package/build/libv86.mjs
CHANGED
|
@@ -426,10 +426,10 @@ function(){return this.current_interface.read_data(2)},function(){return this.cu
|
|
|
426
426
|
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});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)});
|
|
427
427
|
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<<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=
|
|
428
428
|
(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=(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===
|
|
429
|
-
this.master||!h&&this.current_interface===this.slave)this.current_interface=h?this.slave:this.master;this.
|
|
430
|
-
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|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)}Vc.prototype.read_status=function(){return this.current_interface.drive_connected?
|
|
431
|
-
0};Vc.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};Vc.prototype.dma_read_addr=function(){return this.prdt_addr};Vc.prototype.dma_set_addr=function(a){this.prdt_addr=a};Vc.prototype.dma_read_status=function(){return this.dma_status};Vc.prototype.dma_write_status=function(a){this.dma_status&=~(a&6)};Vc.prototype.dma_read_command=function(){return this.dma_read_command8()|
|
|
432
|
-
16};Vc.prototype.dma_read_command8=function(){return this.dma_command};Vc.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};Vc.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();break;case 202:case 53:this.current_interface.do_ata_write_sectors_dma();
|
|
429
|
+
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&=-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|
|
|
430
|
+
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|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)}Vc.prototype.read_status=function(){return this.current_interface.drive_connected?
|
|
431
|
+
this.current_interface.status_reg:0};Vc.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};Vc.prototype.dma_read_addr=function(){return this.prdt_addr};Vc.prototype.dma_set_addr=function(a){this.prdt_addr=a};Vc.prototype.dma_read_status=function(){return this.dma_status};Vc.prototype.dma_write_status=function(a){this.dma_status&=~(a&6)};Vc.prototype.dma_read_command=function(){return this.dma_read_command8()|
|
|
432
|
+
this.dma_read_status()<<16};Vc.prototype.dma_read_command8=function(){return this.dma_command};Vc.prototype.dma_write_command=function(a){this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)};Vc.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();break;case 202:case 53:this.current_interface.do_ata_write_sectors_dma();
|
|
433
433
|
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()}};Vc.prototype.push_irq=function(){0===(this.device_control_reg&2)&&(this.dma_status|=4,this.cpu.device_raise_irq(this.irq))};Vc.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;
|
|
434
434
|
a[11]=this.current_interface===this.master;a[12]=this.dma_command;return a};Vc.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=a[9];this.dma_status=a[10];this.current_interface=a[11]?this.master:this.slave;this.dma_command=a[12]};function W(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=
|
|
435
435
|
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=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=
|
package/build/v86-debug.wasm
CHANGED
|
Binary file
|
package/build/v86-fallback.wasm
CHANGED
|
Binary file
|
package/build/v86.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/v86.d.ts
ADDED
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
// warning: experimental, incomplete and likely to change in the future
|
|
2
|
+
// if you find problems, please send a pull request
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The type for images as a file, loaded asynchronously.
|
|
6
|
+
*
|
|
7
|
+
* Files with `async: true` and `use_parts: false` are downloaded using HTTP
|
|
8
|
+
* Range requests. Note that not all web servers support this header correctly,
|
|
9
|
+
* and it inherently disables HTTP compression. The `url` fields points
|
|
10
|
+
* directly to the disk images.
|
|
11
|
+
*/
|
|
12
|
+
type V86AsyncFileImage =
|
|
13
|
+
{
|
|
14
|
+
/** The URL to the image */
|
|
15
|
+
url: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Async loading.
|
|
19
|
+
*
|
|
20
|
+
* If true, the file is downloaded completely, otherwise in chunks
|
|
21
|
+
* (see {@link V86AsyncFileImage.use_parts} for the chunking method).
|
|
22
|
+
*/
|
|
23
|
+
async: true;
|
|
24
|
+
|
|
25
|
+
/** Image size, required for async loading */
|
|
26
|
+
size: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Use parts instead of Range header, useful for static hostings.
|
|
30
|
+
*
|
|
31
|
+
* If true, v86 expects the image to be split in files of `fixed_chunk_size`
|
|
32
|
+
* bytes. You can use [split-image.py](https://github.com/copy/v86/blob/master/tools/split-image.py)
|
|
33
|
+
* to split an image. V86 appends `-<start-byte>-<end-byte>` to the url.
|
|
34
|
+
*/
|
|
35
|
+
use_parts?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Fixed chunk size, useful with `use_parts: true` for GitHub Pages users.
|
|
39
|
+
*/
|
|
40
|
+
fixed_chunk_size?: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The type for images as a file, loaded synchronously.
|
|
45
|
+
*/
|
|
46
|
+
type V86SyncFileImage =
|
|
47
|
+
{
|
|
48
|
+
/** The URL to the image */
|
|
49
|
+
url: string;
|
|
50
|
+
|
|
51
|
+
/** @ignore */
|
|
52
|
+
async?: false;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The type for images as a buffer.
|
|
57
|
+
*/
|
|
58
|
+
type V86BufferImage =
|
|
59
|
+
{
|
|
60
|
+
/** Image buffer */
|
|
61
|
+
buffer: ArrayBuffer
|
|
62
|
+
};
|
|
63
|
+
//| { buffer: File; async?: boolean; }; // only in browsers: https://developer.mozilla.org/en-US/docs/Web/API/File
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The type of disk/bios/state images.
|
|
67
|
+
*
|
|
68
|
+
* Note that bios, initial state, bzimage, initrd, multiboot and floppy disk
|
|
69
|
+
* images are always loaded synchronously.
|
|
70
|
+
*
|
|
71
|
+
* State images and fixed-size chunks (but not other image types) that end with
|
|
72
|
+
* .zst are automatically decompressed using a built-in zstd decompressor. This
|
|
73
|
+
* has a performance overhead compared to HTTP compression, but will result in
|
|
74
|
+
* better compression ration.
|
|
75
|
+
*/
|
|
76
|
+
export type V86Image = V86AsyncFileImage | V86SyncFileImage | V86BufferImage;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Config for virtio/serial console.
|
|
80
|
+
*/
|
|
81
|
+
export type ConsoleConfig =
|
|
82
|
+
{
|
|
83
|
+
/**
|
|
84
|
+
* Console type
|
|
85
|
+
*
|
|
86
|
+
* Available types:
|
|
87
|
+
* - `textarea` - using TextArea HTML element, doesn't support ESC codes
|
|
88
|
+
* - `xtermjs` - using XtermJS-compatible terminal
|
|
89
|
+
*/
|
|
90
|
+
type: "textarea" | "xtermjs" | "none";
|
|
91
|
+
|
|
92
|
+
/** XtermJS constructor, useful for ESM users. When not set, `window["Terminal"]` is used */
|
|
93
|
+
xterm_lib?: Function;
|
|
94
|
+
|
|
95
|
+
/** HTML container for console */
|
|
96
|
+
container?: HTMLElement | HTMLTextAreaElement;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Config for emulator screen.
|
|
101
|
+
*/
|
|
102
|
+
export type ScreenConfig =
|
|
103
|
+
{
|
|
104
|
+
/**
|
|
105
|
+
* HTML container for emulator screen. This should have a certain structure.
|
|
106
|
+
* @see {@link https://github.com/copy/v86/blob/master/examples/basic.html} for example
|
|
107
|
+
*/
|
|
108
|
+
container?: HTMLElement | null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Encoding for text mode screen
|
|
112
|
+
* @default "cp437"
|
|
113
|
+
*/
|
|
114
|
+
encoding?: "ascii" | "cp437" | "cp858";
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Screen scaling
|
|
118
|
+
* @default 1
|
|
119
|
+
*/
|
|
120
|
+
scaling?: number;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Use canvas for text mode (browser only) with VGA fonts.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
use_graphical_text?: boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Use ANSI Truecolor codes for text mode output.
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
ansi?: boolean;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Debug log levels.
|
|
137
|
+
*/
|
|
138
|
+
export enum LogLevel {
|
|
139
|
+
LOG_ALL = -1,
|
|
140
|
+
LOG_NONE = 0,
|
|
141
|
+
LOG_OTHER = 0x000001,
|
|
142
|
+
LOG_CPU = 0x000002,
|
|
143
|
+
LOG_FPU = 0x000004,
|
|
144
|
+
LOG_MEM = 0x000008,
|
|
145
|
+
LOG_DMA = 0x000010,
|
|
146
|
+
LOG_IO = 0x000020,
|
|
147
|
+
LOG_PS2 = 0x000040,
|
|
148
|
+
LOG_PIC = 0x000080,
|
|
149
|
+
LOG_VGA = 0x000100,
|
|
150
|
+
LOG_PIT = 0x000200,
|
|
151
|
+
LOG_MOUSE = 0x000400,
|
|
152
|
+
LOG_PCI = 0x000800,
|
|
153
|
+
LOG_BIOS = 0x001000,
|
|
154
|
+
LOG_FLOPPY = 0x002000,
|
|
155
|
+
LOG_SERIAL = 0x004000,
|
|
156
|
+
LOG_DISK = 0x008000,
|
|
157
|
+
LOG_RTC = 0x010000,
|
|
158
|
+
LOG_HPET = 0x020000,
|
|
159
|
+
LOG_ACPI = 0x040000,
|
|
160
|
+
LOG_APIC = 0x080000,
|
|
161
|
+
LOG_NET = 0x100000,
|
|
162
|
+
LOG_VIRTIO = 0x200000,
|
|
163
|
+
LOG_9P = 0x400000,
|
|
164
|
+
LOG_SB16 = 0x800000,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Boot order.
|
|
169
|
+
*/
|
|
170
|
+
export enum BootOrder {
|
|
171
|
+
AUTO = 0,
|
|
172
|
+
CD_FLOPPY_HARDDISK = 0x213,
|
|
173
|
+
CD_HARDDISK_FLOPPY = 0x123,
|
|
174
|
+
FLOPPY_CD_HARDDISK = 0x231,
|
|
175
|
+
FLOPPY_HARDDISK_CD = 0x321,
|
|
176
|
+
HARDDISK_CD_FLOPPY = 0x132,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Emulator events.
|
|
181
|
+
*/
|
|
182
|
+
export interface Event {
|
|
183
|
+
"9p-attach": void;
|
|
184
|
+
"9p-read-end": [filename: string, byte_count: number];
|
|
185
|
+
"9p-read-start": [filename: string];
|
|
186
|
+
"9p-write-end": [filename: string, byte_count: number];
|
|
187
|
+
"download-error": {
|
|
188
|
+
file_index: number,
|
|
189
|
+
file_count: number,
|
|
190
|
+
file_name: string,
|
|
191
|
+
request: any,
|
|
192
|
+
};
|
|
193
|
+
"download-progress": {
|
|
194
|
+
file_index: number,
|
|
195
|
+
file_count: number,
|
|
196
|
+
file_name: string,
|
|
197
|
+
lengthComputable: boolean,
|
|
198
|
+
total: number,
|
|
199
|
+
loaded: number,
|
|
200
|
+
};
|
|
201
|
+
"emulator-loaded": void;
|
|
202
|
+
"emulator-ready": void;
|
|
203
|
+
"emulator-started": void;
|
|
204
|
+
"emulator-stopped": void;
|
|
205
|
+
"eth-receive-end": [byte_count: number];
|
|
206
|
+
"eth-transmit-end": [byte_count: number];
|
|
207
|
+
"ide-read-end": [channel_nr: number, byte_count: number, sector_count: number];
|
|
208
|
+
"ide-read-start": void;
|
|
209
|
+
"ide-write-end": [channel_nr: number, byte_count: number, sector_count: number];
|
|
210
|
+
"mouse-enable": boolean;
|
|
211
|
+
"net0-send": Uint8Array;
|
|
212
|
+
"screen-put-char": [row: number, col: number, chr: number];
|
|
213
|
+
"screen-set-size": [width: number, height: number, bpp: number];
|
|
214
|
+
"serial0-input": number;
|
|
215
|
+
"serial0-output-byte": number;
|
|
216
|
+
"serial1-input": number;
|
|
217
|
+
"serial1-output-byte": number;
|
|
218
|
+
"serial2-input": number;
|
|
219
|
+
"serial2-output-byte": number;
|
|
220
|
+
"serial3-input": number;
|
|
221
|
+
"serial3-output-byte": number;
|
|
222
|
+
"virtio-console0-output-bytes": Uint8Array;
|
|
223
|
+
"virtio-console0-input-bytes": Uint8Array;
|
|
224
|
+
"virtio-console0-resize": [cols: number, rows: number];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @ignore
|
|
229
|
+
* @constructor
|
|
230
|
+
*
|
|
231
|
+
* @param {string=} message
|
|
232
|
+
*/
|
|
233
|
+
declare class FileExistsError extends Error {
|
|
234
|
+
constructor(message: string);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @ignore
|
|
239
|
+
* @constructor
|
|
240
|
+
*
|
|
241
|
+
* @param {string=} message
|
|
242
|
+
*/
|
|
243
|
+
declare class FileNotFoundError extends Error {
|
|
244
|
+
constructor(message: string);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Network device configuration.
|
|
249
|
+
* @see {@link https://github.com/copy/v86/blob/master/docs/networking.md} for more infos
|
|
250
|
+
*/
|
|
251
|
+
type V86NetworkDevice =
|
|
252
|
+
{
|
|
253
|
+
/**
|
|
254
|
+
* The type of emulated NIC provided to the guest OS.
|
|
255
|
+
* Recommended to use `ne2k` for old OSes and `virtio` for modern Linux.
|
|
256
|
+
* @default "ne2k"
|
|
257
|
+
*/
|
|
258
|
+
type?: "ne2k" | "virtio";
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The network backend URL.
|
|
262
|
+
* Note that the CORS proxy server of the fetch backend is defined in field `cors_proxy` below.
|
|
263
|
+
* @see {@link https://github.com/copy/v86/blob/master/docs/networking.md#backend-url-schemes} for backend URL schemes
|
|
264
|
+
*/
|
|
265
|
+
relay_url?: string;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Network id, all v86 network instances with the same id share the same network namespace.
|
|
269
|
+
* @todo class NetworkAdapter should also get options.net_device as an argument, at least options.net_device.id.
|
|
270
|
+
* @default 0
|
|
271
|
+
*/
|
|
272
|
+
id?: number;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* MAC address of virtual network peers (ARP, PING, DHCP, DNS, NTP, UDP echo and TCP peers) in common MAC
|
|
276
|
+
* address notation (fetch/wisp only).
|
|
277
|
+
* @default "52:54:0:1:2:3"
|
|
278
|
+
*/
|
|
279
|
+
router_mac?: string;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* IP address of virtual network peers (ARP, PING, DHCP, DNS and TCP peers) in dotted IP notation (fetch/wisp only).
|
|
283
|
+
* @default "192.168.86.1"
|
|
284
|
+
*/
|
|
285
|
+
router_ip?: string;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* IP address to be assigned to the guest by DHCP in dotted IP notation (fetch/wisp only).
|
|
289
|
+
* @default "192.168.86.100"
|
|
290
|
+
*/
|
|
291
|
+
vm_ip?: string;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Network masquerade (fetch/wisp only).
|
|
295
|
+
*
|
|
296
|
+
* If true, announce `router_ip` as the router's and DNS server's IP addresses in generated
|
|
297
|
+
* DHCP replies, and also generate ARP replies to IPs outside the router's subnet `255.255.255.0`.
|
|
298
|
+
* @default true
|
|
299
|
+
*/
|
|
300
|
+
masquerade?: boolean;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* DNS method to use (fetch/wisp only).
|
|
304
|
+
*
|
|
305
|
+
* Available methods:
|
|
306
|
+
* - `static`: use built-in DNS server
|
|
307
|
+
* - `doh`: use DNS-over-HTTPS (DoH)
|
|
308
|
+
* @default `static` for `fetch` or `doh` for `wisp` backend
|
|
309
|
+
* @see {@link https://en.wikipedia.org/wiki/DNS_over_HTTPS} about DNS over HTTPS
|
|
310
|
+
*/
|
|
311
|
+
dns_method?: "static" | "doh";
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Host name or IP address (and optional port number) of the DoH server if `dns_method` is `doh`.
|
|
315
|
+
*
|
|
316
|
+
* The value is expanded to the URL `https://DOH_SERVER/dns-query`.
|
|
317
|
+
* @default "cloudflare-dns.com"
|
|
318
|
+
*/
|
|
319
|
+
doh_server?: string;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* CORS proxy server URL, do not use a proxy if undefined (`fetch` backend only).
|
|
323
|
+
*/
|
|
324
|
+
cors_proxy?: string;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The MTU used for the virtual network. Increasing it can improve performance. This only works if the NIC type is `virtio`.
|
|
328
|
+
* @default 1500
|
|
329
|
+
*/
|
|
330
|
+
mtu?: number;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Emulator instance constructor options.
|
|
335
|
+
*/
|
|
336
|
+
export interface V86Options {
|
|
337
|
+
/**
|
|
338
|
+
* Reference to the v86 wasm exported function.
|
|
339
|
+
*/
|
|
340
|
+
wasm_fn?: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Path to v86 wasm artifact
|
|
344
|
+
* @default "build/v86.wasm" or "build/v86-debug.wasm" when debug mode enabled
|
|
345
|
+
*/
|
|
346
|
+
wasm_path?: string;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The memory size in bytes, should be a power of 2.
|
|
350
|
+
* @example 16 * 1024 * 1024
|
|
351
|
+
* @default 64 * 1024 * 1024
|
|
352
|
+
*/
|
|
353
|
+
memory_size?: number;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* VGA memory size in bytes.
|
|
357
|
+
* @example 8 * 1024 * 1024
|
|
358
|
+
* @default 8 * 1024 * 1024
|
|
359
|
+
*/
|
|
360
|
+
vga_memory_size?: number;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* If emulation should be started when emulator is ready.
|
|
364
|
+
* @default false
|
|
365
|
+
*/
|
|
366
|
+
autostart?: boolean;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* If keyboard should be disabled (only browsers).
|
|
370
|
+
*/
|
|
371
|
+
disable_keyboard?: boolean;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* If mouse should be disabled (only browsers).
|
|
375
|
+
*/
|
|
376
|
+
disable_mouse?: boolean;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* If speaker should be disabled (only browsers).
|
|
380
|
+
*/
|
|
381
|
+
disable_speaker?: boolean;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* BIOS image (supported SeaBIOS and Bochs BIOS)
|
|
385
|
+
* @see {@link https://github.com/copy/v86/tree/master/bios} for BIOS images
|
|
386
|
+
*/
|
|
387
|
+
bios?: V86Image;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* VGA BIOS image
|
|
391
|
+
* @see {@link https://github.com/copy/v86/tree/master/bios} for BIOS images
|
|
392
|
+
*/
|
|
393
|
+
vga_bios?: V86Image;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* First hard disk
|
|
397
|
+
*/
|
|
398
|
+
hda?: V86Image;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Second hard disk
|
|
402
|
+
*/
|
|
403
|
+
hdb?: V86Image;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* First floppy disk
|
|
407
|
+
*/
|
|
408
|
+
fda?: V86Image;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Second floppy disk
|
|
412
|
+
*/
|
|
413
|
+
fdb?: V86Image;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* CD-ROM
|
|
417
|
+
* By default, an ejected CD-ROM drive is emulated
|
|
418
|
+
*/
|
|
419
|
+
cdrom?: V86Image;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* A Linux kernel image to boot (only bzimage format)
|
|
423
|
+
*/
|
|
424
|
+
bzimage?: V86Image;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Kernel boot cmdline
|
|
428
|
+
*/
|
|
429
|
+
cmdline?: string;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* A Linux ramdisk image
|
|
433
|
+
*/
|
|
434
|
+
initrd?: V86Image;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Automatically fetch bzimage and initrd from the 9p filesystem
|
|
438
|
+
*/
|
|
439
|
+
bzimage_initrd_from_filesystem?: boolean;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Multiboot image
|
|
443
|
+
*/
|
|
444
|
+
multiboot?: V86Image;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* An initial state to load
|
|
448
|
+
* @see {@link V86.prototype.save_state}
|
|
449
|
+
*/
|
|
450
|
+
initial_state?: V86Image;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Should the MAC address be preserved from the state image, for operating systems that
|
|
454
|
+
* don't allow you to reload the network card driver
|
|
455
|
+
* @default false
|
|
456
|
+
* @see {@link https://github.com/copy/v86/blob/master/docs/networking.md#v86-run-time-state-images}
|
|
457
|
+
*/
|
|
458
|
+
preserve_mac_from_state_image?: boolean;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* A 9p filesystem is supported by the emulator, using a virtio transport. Using it, files can be exchanged with the guest OS
|
|
462
|
+
* If `basefs` and `baseurl` are omitted, an empty 9p filesystem is created.
|
|
463
|
+
*/
|
|
464
|
+
filesystem?: {
|
|
465
|
+
/**
|
|
466
|
+
* A URL to a JSON file created using [fs2json](https://github.com/copy/v86/blob/master/tools/fs2json.py).
|
|
467
|
+
*/
|
|
468
|
+
baseurl?: string;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* A directory of 9p files, as created by [copy-to-sha256.py](https://github.com/copy/v86/blob/master/tools/copy-to-sha256.py).
|
|
472
|
+
* @see {@link https://github.com/copy/v86/blob/master/docs/filesystem.md} for more details
|
|
473
|
+
*/
|
|
474
|
+
basefs?: string;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* A function that will be called for each 9p request.
|
|
478
|
+
* If specified, this will back Virtio9p instead of a filesystem.
|
|
479
|
+
* Use this to build or connect to a custom 9p server.
|
|
480
|
+
*/
|
|
481
|
+
handle9p?: (reqbuf: Uint8Array, reply: (replybuf: Uint8Array) => void) => void;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* A URL to a websocket proxy for 9p.
|
|
485
|
+
* If specified, this will back Virtio9p instead of a filesystem.
|
|
486
|
+
* Use this to connect to a custom 9p server over websocket.
|
|
487
|
+
*/
|
|
488
|
+
proxy_url?: string;
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* A textarea that will receive and send data to the emulated serial terminal (only browsers).
|
|
493
|
+
* Alternatively the serial terminal can also be accessed programatically, see
|
|
494
|
+
* [examples/serial.html](https://github.com/copy/v86/blob/master/examples/serial.html) for example.
|
|
495
|
+
* Deprecated in favor of {@link V86Options.serial_console}.
|
|
496
|
+
* @deprecated
|
|
497
|
+
* @see {@link V86Options.serial_console}
|
|
498
|
+
*/
|
|
499
|
+
serial_container?: HTMLTextAreaElement;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Xtermjs serial terminal container (only browsers). When set, serial_container option is ignored.
|
|
503
|
+
* Deprecated in favor of {@link V86Options.serial_console}.
|
|
504
|
+
* @deprecated
|
|
505
|
+
* @see {@link V86Options.serial_console}
|
|
506
|
+
*/
|
|
507
|
+
serial_container_xtermjs?: HTMLElement;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Console adapter for serial console
|
|
511
|
+
*/
|
|
512
|
+
serial_console?: ConsoleConfig;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Console adapter for virtio console.
|
|
516
|
+
* Setting to true, creates virtio console device without adapter
|
|
517
|
+
*/
|
|
518
|
+
virtio_console?: ConsoleConfig;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Emulator screen element (only browsers).
|
|
522
|
+
* Only provided for backwards compatibility, use {@link V86Options.screen} instead.
|
|
523
|
+
* @deprecated
|
|
524
|
+
* @see {@link https://github.com/copy/v86/blob/master/examples/basic.html} for example
|
|
525
|
+
*/
|
|
526
|
+
screen_container?: HTMLElement | null;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Emulator screen config
|
|
530
|
+
*/
|
|
531
|
+
screen?: ScreenConfig;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Enable ACPI (also enables APIC). Experimental and only partially implemented.
|
|
535
|
+
* @default false
|
|
536
|
+
*/
|
|
537
|
+
acpi?: boolean;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Log level (for debug builds)
|
|
541
|
+
* @default LogLevel.LOG_NONE
|
|
542
|
+
*/
|
|
543
|
+
log_level?: LogLevel;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Boot order
|
|
547
|
+
* @default BootOrder.AUTO
|
|
548
|
+
*/
|
|
549
|
+
boot_order?: BootOrder;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Fast boot, skips boot menu in bochs bios
|
|
553
|
+
* @default false
|
|
554
|
+
*/
|
|
555
|
+
fastboot?: boolean;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Create a virtio balloon device
|
|
559
|
+
* @default false
|
|
560
|
+
*/
|
|
561
|
+
virtio_balloon?: boolean;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Override the maximum supported cpuid level
|
|
565
|
+
* Used for some versions of Windows, see [docs/windows-nt.md](https://github.com/copy/v86/blob/master/docs/windows-nt.md)
|
|
566
|
+
*/
|
|
567
|
+
cpuid_level?: number;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Turn off the x86-to-wasm jit
|
|
571
|
+
* @default false
|
|
572
|
+
*/
|
|
573
|
+
disable_jit?: boolean;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* The URL of a server running network relay.
|
|
577
|
+
* Deprecated in favor of {@link V86Options.net_device}.
|
|
578
|
+
* @deprecated
|
|
579
|
+
* @see {@link V86Options.net_device}
|
|
580
|
+
*/
|
|
581
|
+
network_relay_url?: string;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Network device configuration.
|
|
585
|
+
*/
|
|
586
|
+
net_device?: V86NetworkDevice;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Enable serial port 1
|
|
590
|
+
* @default false
|
|
591
|
+
*/
|
|
592
|
+
uart1?: boolean;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Enable serial port 2
|
|
596
|
+
* @default false
|
|
597
|
+
*/
|
|
598
|
+
uart2?: boolean;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Enable serial port 3
|
|
602
|
+
* @default false
|
|
603
|
+
*/
|
|
604
|
+
uart3?: boolean;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export class V86 {
|
|
608
|
+
constructor(options: V86Options);
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Start emulation. Do nothing if emulator is running already. Can be asynchronous.
|
|
612
|
+
*/
|
|
613
|
+
run(): Promise<void>;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Stop emulation. Do nothing if emulator is not running. Can be asynchronous.
|
|
617
|
+
*/
|
|
618
|
+
stop(): Promise<void>;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Free resources associated with this instance
|
|
622
|
+
*/
|
|
623
|
+
destroy(): Promise<void>;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Restart (force a reboot).
|
|
627
|
+
*/
|
|
628
|
+
restart(): void;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Add an event listener (the emulator is an event emitter).
|
|
632
|
+
*
|
|
633
|
+
* The callback function gets a single argument which depends on the event.
|
|
634
|
+
*
|
|
635
|
+
* @param event Name of the event.
|
|
636
|
+
* @param listener The callback function.
|
|
637
|
+
*/
|
|
638
|
+
add_listener<T extends keyof Event>(event: T, listener: (argument: Event[T]) => void): void;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Remove an event listener.
|
|
642
|
+
*
|
|
643
|
+
* The callback function gets a single argument which depends on the event.
|
|
644
|
+
*
|
|
645
|
+
* @param event Name of the event.
|
|
646
|
+
* @param listener The callback function.
|
|
647
|
+
*/
|
|
648
|
+
remove_listener<T extends keyof Event>(event: T, listener: (argument: Event[T]) => void): void;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Restore the emulator state from the given state, which must be an
|
|
652
|
+
* ArrayBuffer returned by {@link V86.prototype.save_state}.
|
|
653
|
+
*
|
|
654
|
+
* Note that the state can only be restored correctly if this constructor has
|
|
655
|
+
* been created with the same options as the original instance (e.g., same disk
|
|
656
|
+
* images, memory size, etc.).
|
|
657
|
+
*
|
|
658
|
+
* Different versions of the emulator might use a different format for the
|
|
659
|
+
* state buffer.
|
|
660
|
+
*
|
|
661
|
+
* @param state
|
|
662
|
+
*/
|
|
663
|
+
restore_state(state: ArrayBuffer): Promise<void>;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Asynchronously save the current state of the emulator.
|
|
667
|
+
*/
|
|
668
|
+
save_state(): Promise<ArrayBuffer>;
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Get current instruction counter
|
|
672
|
+
*/
|
|
673
|
+
get_instruction_counter(): number;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Get emulator running status
|
|
677
|
+
*/
|
|
678
|
+
is_running(): boolean;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Set the image inserted in the first floppy drive. Can be changed at runtime,
|
|
682
|
+
* as when physically changing the floppy disk.
|
|
683
|
+
*/
|
|
684
|
+
set_fda(image: V86Image): Promise<void>;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Eject the first floppy drive.
|
|
688
|
+
*/
|
|
689
|
+
eject_fda(): void;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Set the image inserted in the second floppy drive. Can be changed at runtime,
|
|
693
|
+
* as when physically changing the floppy disk.
|
|
694
|
+
*/
|
|
695
|
+
set_fdb(image: V86Image): Promise<void>;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Eject the second floppy drive.
|
|
699
|
+
*/
|
|
700
|
+
eject_fdb(): void;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Set the image inserted in the CD-ROM drive. Can be changed at runtime, as
|
|
704
|
+
* when physically changing the CD-ROM.
|
|
705
|
+
*/
|
|
706
|
+
set_cdrom(image: V86Image): Promise<void>;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Eject the CD-ROM.
|
|
710
|
+
*/
|
|
711
|
+
eject_cdrom(): void;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Send a sequence of scan codes to the emulated PS2 controller. A list of
|
|
715
|
+
* codes can be found at http://stanislavs.org/helppc/make_codes.html.
|
|
716
|
+
* Do nothing if there is no keyboard controller.
|
|
717
|
+
*
|
|
718
|
+
* @param codes
|
|
719
|
+
*/
|
|
720
|
+
keyboard_send_scancodes(codes: number[]): void;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Send translated keys
|
|
724
|
+
*/
|
|
725
|
+
keyboard_send_keys(codes: number[]): void;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Send text, assuming the guest OS uses a US keyboard layout
|
|
729
|
+
*/
|
|
730
|
+
keyboard_send_text(string: string): void;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Download a screenshot (returns an <img> element, only works in browsers)
|
|
734
|
+
*/
|
|
735
|
+
screen_make_screenshot(): HTMLElement;
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Set the scaling level of the emulated screen.
|
|
739
|
+
*
|
|
740
|
+
* @param {number} sx
|
|
741
|
+
* @param {number} sy
|
|
742
|
+
*/
|
|
743
|
+
screen_set_scale(sx: number, sy: number): void;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Go fullscreen (only browsers)
|
|
747
|
+
*/
|
|
748
|
+
screen_go_fullscreen(): void;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Lock the mouse cursor: It becomes invisble and is not moved out of the browser window (only browsers)
|
|
752
|
+
*/
|
|
753
|
+
lock_mouse(): void;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Enable or disable sending mouse events to the emulated PS2 controller.
|
|
757
|
+
*/
|
|
758
|
+
mouse_set_enabled(enabled: boolean): void;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Enable or disable sending keyboard events to the emulated PS2 controller.
|
|
762
|
+
*/
|
|
763
|
+
keyboard_set_enabled(enabled: boolean): void;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Send a string to the first emulated serial terminal.
|
|
767
|
+
*
|
|
768
|
+
* @param data
|
|
769
|
+
*/
|
|
770
|
+
serial0_send(data: string): void;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Send bytes to a serial port (to be received by the emulated PC).
|
|
774
|
+
*
|
|
775
|
+
* @param serial the index of the serial port
|
|
776
|
+
* @param data
|
|
777
|
+
*/
|
|
778
|
+
serial_send_bytes(serial: number, data: Uint8Array): void;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Set the modem status of a serial port.
|
|
782
|
+
*
|
|
783
|
+
* @param serial the index of the serial port
|
|
784
|
+
* @param status
|
|
785
|
+
*/
|
|
786
|
+
serial_set_modem_status(serial: number, status: number): void;
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Set the carrier detect status of a serial port.
|
|
790
|
+
*
|
|
791
|
+
* @param serial the index of the serial port
|
|
792
|
+
* @param status
|
|
793
|
+
*/
|
|
794
|
+
serial_set_carrier_detect(serial: number, status: number): void;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Set the ring indicator status of a serial port.
|
|
798
|
+
*
|
|
799
|
+
* @param serial the index of the serial port
|
|
800
|
+
* @param status
|
|
801
|
+
*/
|
|
802
|
+
serial_set_ring_indicator(serial: number, status: number): void;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Set the data set ready status of a serial port.
|
|
806
|
+
*
|
|
807
|
+
* @param serial the index of the serial port
|
|
808
|
+
* @param status
|
|
809
|
+
*/
|
|
810
|
+
serial_set_data_set_ready(serial: number, status: number): void;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Set the clear to send status of a serial port.
|
|
814
|
+
*
|
|
815
|
+
* @param serial the index of the serial port
|
|
816
|
+
* @param status
|
|
817
|
+
*/
|
|
818
|
+
serial_set_clear_to_send(serial: number, status: number): void;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Write to a file in the 9p filesystem. Nothing happens if no filesystem has
|
|
822
|
+
* been initialized.
|
|
823
|
+
*
|
|
824
|
+
* @param file
|
|
825
|
+
* @param data
|
|
826
|
+
* @param callback
|
|
827
|
+
* @throws {FileNotFoundError}
|
|
828
|
+
*/
|
|
829
|
+
create_file(file: string, data: Uint8Array): Promise<void>;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Read a file in the 9p filesystem.
|
|
833
|
+
*
|
|
834
|
+
* @param {string} file
|
|
835
|
+
* @throws {FileNotFoundError}
|
|
836
|
+
*/
|
|
837
|
+
read_file(file: string): Promise<Uint8Array>;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Reads data from memory at specified offset.
|
|
841
|
+
*
|
|
842
|
+
* @param offset
|
|
843
|
+
* @param length
|
|
844
|
+
*/
|
|
845
|
+
read_memory(offset: number, length: number): Uint8Array;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Writes data to memory at specified offset.
|
|
849
|
+
*
|
|
850
|
+
* @param blob
|
|
851
|
+
* @param offset
|
|
852
|
+
*/
|
|
853
|
+
write_memory(blob: number[] | Uint8Array, offset: number): void;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Wait until expected text is present on the VGA text screen.
|
|
857
|
+
*
|
|
858
|
+
* Returns immediately if the expected text is already present on screen
|
|
859
|
+
* at the time this function is called.
|
|
860
|
+
*
|
|
861
|
+
* @param expected
|
|
862
|
+
* @param options
|
|
863
|
+
*/
|
|
864
|
+
wait_until_vga_screen_contains(expected: string|RegExp|Array<string|RegExp>, options?: {timeout_msec?: number}): Promise<boolean>;
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Set Xtermjs serial port console
|
|
868
|
+
*
|
|
869
|
+
* @param element
|
|
870
|
+
* @param xterm_lib
|
|
871
|
+
*/
|
|
872
|
+
set_serial_container_xtermjs(element: HTMLElement, xterm_lib?: Function): void;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Set Xtermjs virtio console
|
|
876
|
+
*
|
|
877
|
+
* @param element
|
|
878
|
+
* @param xterm_lib
|
|
879
|
+
*/
|
|
880
|
+
set_virtio_console_container_xtermjs(element: HTMLElement, xterm_lib?: Function): void;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Run steps automatically
|
|
884
|
+
*
|
|
885
|
+
* @param steps
|
|
886
|
+
* @deprecated
|
|
887
|
+
* @see {@link V86.prototype.wait_until_vga_screen_contains}
|
|
888
|
+
*/
|
|
889
|
+
automatically(steps: Array<{ sleep?: number, vga_text?: string, keyboard_send?: string | number[], call?: Function }>): void;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Get instruction stats
|
|
893
|
+
*
|
|
894
|
+
* @see {@link https://github.com/copy/v86/blob/master/docs/profiling.md} for more infos
|
|
895
|
+
*/
|
|
896
|
+
get_instruction_stats(): string;
|
|
897
|
+
}
|