x86 virtualization in JavaScript, running in your browser and NodeJS (mirror)

Fabian 4e8635ff81 Add test 5 days ago
.cargo 853bf477cc minor fixes 4 months ago
.github a031ab552f Fix yaml syntax 6 days ago
bios 497f618cab Merge branch 'wasm' into master 2 weeks ago
docs 497f618cab Merge branch 'wasm' into master 2 weeks ago
examples 73fd991c87 Fix example 2 weeks ago
gen bc11d7089e jit 0fc2/cmpps 660fc2/cmppd 3 weeks ago
lib ea4c0e3c91 Compile without /usr/include 2 weeks ago
src 1f36d454c2 Remove invalid assertion 5 days ago
tests 4e8635ff81 Add test 5 days ago
tools 2e551c0574 Move docker/ into tools/ 3 weeks ago
.editorconfig 0766da0fa0 Only use vga color linked list for small changes 3 years ago
.gitattributes 741e09569a Add .gitattributes 2 weeks ago
.gitignore 497f618cab Merge branch 'wasm' into master 2 weeks ago
.jshint.json d5c9b29942 Upgrade jshint 3 weeks ago
.rustfmt.toml 75dbbbc55a Update rustfmt 3 weeks ago
Cargo.toml 3bd6c55721 Remove unused dependency 2 weeks ago
LICENSE fe74b8d332 Fix license 3 weeks ago
Makefile c4843cedbf Update xterm.js 1 week ago
Readme.md 0611ffc694 Update readme 5 days ago
debug.html 2ef8f4b552 Windows 2000 (#390, #296, #377) 5 days ago
index.html 2ef8f4b552 Windows 2000 (#390, #296, #377) 5 days ago
loader.js 497f618cab Merge branch 'wasm' into master 2 weeks ago
v86.css c4843cedbf Update xterm.js 1 week ago

Readme.md

v86 emulates an x86-compatible CPU and hardware. Machine code is translated to WebAssembly modules at runtime in order to achieve decent performance. Here's a list of emulated hardware:

  • An x86-compatible CPU. The instruction set is around Pentium III level, including full SSE2 support. Some features are missing, in particular:
    • Task gates, far calls in protected mode
    • Some 16 bit protected mode features
    • Single stepping (trap flag, debug registers)
    • Some exceptions, especially floating point and SSE
    • Multicore
    • PAE
    • 64-bit extensions
  • A floating point unit (FPU). Calculations are done using the Berkeley SoftFloat library and therefore should be precise (but slow). Trigonometric and log functions are emulated using 64-bit floats and may be less precise. Not all FPU excpetions are supported.
  • A floppy disk controller (8272A).
  • An 8042 Keyboard Controller, PS2. With mouse support.
  • An 8254 Programmable Interval Timer (PIT).
  • An 8259 Programmable Interrupt Controller (PIC).
  • Partial APIC support.
  • A CMOS Real Time Clock (RTC).
  • A generic VGA card with SVGA support and Bochs VBE Extensions.
  • A PCI bus. This one is partly incomplete and not used by every device.
  • An IDE disk controller.
  • An NE2000 (8390) PCI network card.
  • A virtio filesystem.
  • A SoundBlaster 16 sound card.

Demos

Arch LinuxDamn Small LinuxBuildroot LinuxReactOSWindows 2000Windows 98Windows 95Windows 1.01MS-DOSFreeDOSFreeBSDOpenBSD9frontHaikuOberonKolibriOSQNX

Compatibility

Here's an overview of the operating systems supported in v86:

  • Linux works pretty well. Neither 64-bit nor PAE kernels are supported.
    • Damn Small Linux (2.4 Kernel) works.
    • All tested versions of TinyCore work.
    • BuildRoot can be used to build a minimal image. humphd/browser-vm has some useful scripts for building one.
    • Archlinux works. See archlinux.md for building an image.
    • Debian works. An image can be built from a Dockerfile, see tools/docker/debian/.
    • Alpine Linux works.
  • ReactOS works.
  • FreeDOS, Windows 1.01 and MS-DOS run very well.
  • KolibriOS works.
  • Haiku works.
  • Android x86 1.6-r2 works if one selects VESA mode at the boot prompt. Newer versions haven't been tested.
  • Windows 1, 3.0, 95, 98, ME and 2000 work. Other versions currently don't (see #86, #208).
    • In Windows 2000 and higher the PC type has to be changed from ACPI PC to Standard PC
  • Many hobby operating systems work.
  • 9front works.
  • Plan 9 doesn't work.
  • QNX works.
  • OS/2 doesn't work.
  • FreeBSD works.
  • OpenBSD works with a specific boot configuration. At the boot> prompt type boot -c, then at the UKC> prompt disable mpbios and exit.
  • NetBSD works only with a custom kernel, see #350.
  • SerenityOS doesn't work due to missing PAE support.

You can get some infos on the disk images here: https://github.com/copy/images.

How to build, run and embed?

You need:

  • java (for Closure Compiler, not necessary when using debug.html)
  • make
  • gcc and libc-i386 for building some of the test binaries
  • nasm, gdb and qemu-system (for running tests)
  • rust-nightly with the wasm32-unknown-unknown target
  • A version of clang compatible with rust-nightly
  • nodejs (a recent version is required, 10.11.0 is known to be working)

See tools/docker/test-image/Dockerfile for a full setup on Debian.

  • Run make to build the debug build (at debug.html).
  • Run make all to build the optimized build (at index.html).
  • ROM and disk images are loaded via XHR, so if you want to try out index.html locally, make sure to serve it from a local webserver. You can use make run to serve the files using Python's http module.
  • If you only want to embed v86 in a webpage you can use libv86.js. For usage, check out the examples.

Testing

The disk images for testing are not included in this repository. You can download them directly from the website using:

wget -P images/ https://k.copy.sh/{linux.iso,linux4.iso,buildroot-bzimage.bin,openbsd-floppy.img,kolibri.img,windows101.img,os8.img,freedos722.img}

Run all tests: make jshint rustfmt kvm-unit-test nasmtests nasmtests-force-jit expect-tests jitpagingtests qemutests rust-test tests

See tests/Readme.md for more infos.

API examples

Using v86 for your own purposes is as easy as:

var emulator = new V86Starter({
    screen_container: document.getElementById("screen_container"),
    bios: {
        url: "../../bios/seabios.bin",
    },
    vga_bios: {
        url: "../../bios/vgabios.bin",
    },
    cdrom: {
        url: "../../images/linux.iso",
    },
    autostart: true,
});

See starter.js.

License

v86 is distributed under the terms of the Simplified BSD License, see LICENSE. The following third-party dependencies are included in the repository under their own licenses:

Credits

More questions?

Shoot me an email to copy@copy.sh. Please report bugs on GitHub.

Author

Fabian Hemmer (https://copy.sh/, copy@copy.sh)