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

Fabian 54bb73e7f9 Delete fpu_truncate, use trunc 6 tahun lalu
bios def5f9d1f7 Update seabios to 1.10 7 tahun lalu
docker 5cd5130f32 Install clang-tidy in docker container 3 tahun lalu
docs 069ea8e672 extend archlinux doc with networking example 7 tahun lalu
examples 9357484862 Remove trailing whitespace 8 tahun lalu
gen 1f0e7c3ce0 fpu: Have opcode 0xDF use fixed_g instruction functions 3 tahun lalu
lib 9a7eeffa3b 9P filesystem allows to set custom atime and mtime 3 tahun lalu
src 54bb73e7f9 Delete fpu_truncate, use trunc 3 tahun lalu
tests 52474abe58 test: Have integration test read from urandom to trigger JIT 3 tahun lalu
.clang-tidy 74b774bf34 Fix .clang-tidy 3 tahun lalu
.gitignore 0de4f3d390 git ignore saved firefox profiles 3 tahun lalu
.jshint.json 9dc4ff6973 remove unused rules in jshint config 3 tahun lalu
.travis-run-codegen.sh 7997defdfb add codegen-test to CI 3 tahun lalu
.travis-run-integration.sh bf7590f0cd Add kvm-unit-test to travis CI (#129) 7 tahun lalu
.travis-run-jit-paging.sh 8222d2e6e0 Squash 3 tahun lalu
.travis-run-jshint.sh 243ffce941 add jshint to build 3 tahun lalu
.travis-run-nasm-jit-always.sh 5c4c48e6dc Add JIT_ALWAYS handling to makefile and add nasm test with JIT_ALWAYS 3 tahun lalu
.travis-run-nasm.sh 975a06269e Squash 3 tahun lalu
.travis-run-unit-qemu.sh e764ca213a Update test scripts 7 tahun lalu
.travis-run-unit.sh bf7590f0cd Add kvm-unit-test to travis CI (#129) 7 tahun lalu
.travis.yml 8222d2e6e0 Squash 3 tahun lalu
LICENSE aa56fc0de1 Updated copyright year 10 tahun lalu
Makefile ed763e09a7 Fix clang-tidy invocation 3 tahun lalu
Readme.md ec4b19e346 Update readme regarding Arch Linux 7 tahun lalu
debug.html dc01a8f629 Add (debug) to title in debug mode 3 tahun lalu
index.html 975a06269e Squash 3 tahun lalu
loader.js fcfcc76034 Delete more JavaScript 3 tahun lalu
package.json 243ffce941 add jshint to build 3 tahun lalu
v86.css 975a06269e Squash 3 tahun lalu

Readme.md

Demos

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 API.

How does it work?

v86 emulates an x86-compatible CPU and hardware. Here's a list of emulated hardware:

  • An x86 compatible CPU. The instruction set is around Pentium 1 level. Some features are missing, more specifically:
    • Task gates, far calls in protected mode
    • 16 bit protected mode features
    • Single stepping
    • MMX, SSE
    • A bunch of FPU instructions
    • Some exceptions
  • A floating point unit (FPU). Calculations are done with JavaScript's double precision numbers (64 bit), so they are not as precise as calculations on a real FPU (80 bit).
  • 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).
  • A CMOS Real Time Clock (RTC).
  • A VGA controller 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.

Testing

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

wget -P images/ https://copy.sh/v86/images/{linux.iso,linux3.iso,kolibri.img,windows101.img,os8.dsk,freedos722.img,openbsd.img}.

A testsuite is available in tests/full/. Run it using node tests/full/run.js.

How to build, run and embed?

  • Building is only necessary for releases, open debug.html and everything should load out of the box
  • If you want a compressed and fast (i.e. with debug code removed) version, you need Closure Compiler. Download it as shown below and run make build/v86_all.js.
  • 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 SimpleHTTPServer.
  • If you only want to embed v86 in a webpage you can use libv86.js. For usage, check out the API and examples.
  • A couple of disk images are provided for testing. You can check them out using wget -P images/ https://copy.sh/v86/images/{linux.iso,linux3.iso,kolibri.img,windows101.img,os8.dsk,freedos722.img,openbsd.img}.

Short summary:

# grab the main repo
git clone https://github.com/copy/v86.git && cd v86

# grab the disk images
wget -P images/ https://copy.sh/v86/images/{linux.iso,linux3.iso,kolibri.img,windows101.img,os8.dsk,freedos722.img,openbsd.img}

# grab closure compiler
wget -P closure-compiler https://dl.google.com/closure-compiler/compiler-latest.zip
unzip -d closure-compiler closure-compiler/compiler-latest.zip *.jar

# build the library
make build/libv86.js

# run the tests
./tests/full/run.js

Compatibility

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

  • Linux works pretty well. Graphical boot fails in many versions, but you mostly get a shell. The mouse is often not detected automatically.
    • Damn Small Linux (2.4 Kernel): Works, takes circa 10 minutes to boot.
    • Tinycore (3.0 kernel): udev and X fail, but you get a terminal.
    • Nanolinux works.
    • Archlinux works with some caveats. See archlinux.md.
  • ReactOS works
  • FreeDOS, Windows 1.01 and MS-DOS run very well.
  • KolibriOS works. A few applications need SSE.
  • Haiku boots, but takes very long (around 30 minutes).
  • No Android version seems to work, you still get a shell.
  • Windows 1, 95 and 98 work. Other versions currently don't.
  • Many hobby operating systems work.
  • FreeBSD works

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

How can I contribute?

  • Add new features (hardware devices, fill holes in the CPU), fix bugs. Check out the issues section and contact me if you need help.
  • Report bugs.
  • If you want to donate, let me know.

License

Simplified BSD License, see LICENSE, unless otherwise noted.

Credits

More questions?

Shoot me an email to copy@copy.sh. Please don't tell about bugs via mail, create a bug report on GitHub instead.

Author

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