-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,073 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<html lang="en"><head> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7FN7LEVWXD"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
|
||
gtag('config', 'G-7FN7LEVWXD'); | ||
</script> | ||
<title>HTML Code Editor | Seraph</title> | ||
<link rel="shortcut icon" href="../../images/ico.ico" type="image/x-icon"> | ||
<script src="../../storage/js/cloak.js"></script> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
|
||
|
||
|
||
|
||
<script src="https://polyfill.io/v3/polyfill.min.js?features=default,es6,es2015,es2016,es2017,es2018,es2019,es2020,es2021"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es5-shim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es6-shim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/es6-promise.auto.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es7-shim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.ui.touch-punch.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html5shiv.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/classList.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dest/respond.min.js"></script> | ||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> | ||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"> | ||
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> | ||
<style>body{margin:0;font-family:'Courier New',Courier,monospace;display:flex;flex-direction:column;height:100vh;overflow:hidden;background-color:#333;color:#fff}#toolbar{display:flex;padding:10px;background-color:#222}#toolbar label{cursor:pointer;padding:6px 10px;background-color:#4caf50;color:#fff;border-radius:5px;margin-right:10px}#toolbar button{margin-right:10px;transition:background-color .3s ease}#toolbar button:hover{background-color:#555}#editor-container,.preview-container{flex:1;height:100%;overflow:auto;box-sizing:border-box}#editor{width:100%;height:100%;padding:10px;box-sizing:border-box;background-color:#444;color:#fff;border:none}.preview-container{background-color:#fff;color:#fff;width:100%;height:100%}#preview{width:100%;height:100%}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0}#divider{cursor:row-resize;background-color:#222;height:8px;width:100%;display:flex;justify-content:center;align-items:center}#divider:hover{background-color:#555}</style> | ||
</head> | ||
|
||
<body> | ||
<div id="toolbar"> | ||
<label for="file-input" class="custom-file-upload" style="display:none">Choose File</label> | ||
<input type="file" id="file-input" accept=".html, .txt" class="visually-hidden"> | ||
<button class="btn btn-light" onclick="newDocument()">New</button> | ||
<button class="btn btn-light" onclick="openFile()">Open</button> | ||
<button class="btn btn-light" onclick="saveFile()">Save</button> | ||
<script></script> | ||
</div> | ||
<div id="editor-container" style="height: 50%;"> | ||
<textarea id="editor" placeholder="Enter your code here..."></textarea> | ||
</div> | ||
<div id="divider" draggable="true"></div> | ||
<div class="preview-container" id="preview-container" style="height: 50%;"> | ||
<iframe id="preview" frameborder="0"></iframe> | ||
</div> | ||
<script>function newDocument(){confirm("Are you sure you want to start a new document? Any unsaved changes will be lost.")&&(editor.value="",updatePreview())}</script> | ||
<script>const editorContainer=document.getElementById("editor-container"),previewContainer=document.getElementById("preview-container"),divider=document.getElementById("divider");let editorContainerHeight=50,previewContainerHeight=50;updateContainerHeights();let isDragging=!1,startY=0;function updateContainerHeights(){editorContainer.style.height=`${editorContainerHeight}%`,previewContainer.style.height=`${previewContainerHeight}%`}divider.addEventListener("mousedown",(e=>{isDragging=!0,startY=e.clientY})),window.addEventListener("mousemove",(e=>{if(isDragging){const t=e.clientY-startY;startY=e.clientY,editorContainerHeight+=t/window.innerHeight*100,previewContainerHeight-=t/window.innerHeight*100,editorContainerHeight=Math.max(10,Math.min(90,editorContainerHeight)),previewContainerHeight=100-editorContainerHeight,updateContainerHeights()}})),window.addEventListener("mouseup",(()=>{isDragging=!1}))</script> | ||
<script>$(document).ready((function(){$("#toolbar button").hover((function(){$(this).addClass("hovered")}),(function(){$(this).removeClass("hovered")}))}));const editor=document.getElementById("editor"),preview=document.getElementById("preview"),fileInput=document.getElementById("file-input");let pastebinApiKey;function updatePreview(){const e=editor.value,t=preview.contentDocument||preview.contentWindow.document;t.open(),t.write(e),t.close()}function openFile(){fileInput.click()}function saveFile(){const e=editor.value,t=new Blob([e],{type:"text/plain"}),n=document.createElement("a"),i=URL.createObjectURL(t);n.href=i,n.download="code.txt",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(i)}function saveOnline(){const e=editor.value,t=prompt("Enter the file name:");if(!t)return void alert("File name is required!");const n=prompt("Enter your Pastebin API key:");if(!n)return void alert("Pastebin API key is required!");$.ajax({type:"POST",url:"https://pastebin.com/api/api_post.php",data:{api_dev_key:n,api_paste_code:e,api_paste_private:"0",api_paste_name:t,api_paste_expire_date:"10M",api_option:"paste"},success:function(e){e.startsWith("Bad API request")?alert("Error saving code online. Please check your Pastebin API key and try again."):alert("Code saved online successfully! Pastebin URL: "+e)},error:function(){console.error("Error saving code online."),alert("Error saving code online. Please try again.")}})}editor.addEventListener("input",updatePreview),fileInput.addEventListener("change",(function(){const e=fileInput.files[0];if(e){const t=new FileReader;t.onload=function(e){editor.value=e.target.result,updatePreview()},t.readAsText(e)}}))</script> | ||
<script>$(document).ready((function(){$("#toolbar button").button({classes:{"ui-button":"custom-button-hover"}})}))</script> | ||
<script>$(document).ready((function(){$("#divider").resizable({handles:"s",minHeight:100,maxHeight:window.innerHeight-50,resize:function(e,i){const n=i.size.height/window.innerHeight*100;updateContainerHeights(n,100-n)}})}))</script> | ||
<script>function updateContainerHeights(e,t){editorContainer.style.height=`${e}%`,previewContainer.style.height=`${t}%`}</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012, The v86 contributors | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
[](https://gitter.im/copy/v86) or #v86 on [irc.libera.chat](https://libera.chat/) | ||
|
||
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 4 level, | ||
including full SSE3 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 | ||
- 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 exceptions 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 (RTL8390) PCI network card. | ||
- A VirtIO filesystem. | ||
- A SoundBlaster 16 sound card. | ||
|
||
## Demos | ||
|
||
[9front](https://copy.sh/v86/?profile=9front) — | ||
[Arch Linux](https://copy.sh/v86/?profile=archlinux) — | ||
[Android-x86 1.6-r2](https://copy.sh/v86?profile=android) — | ||
[Android-x86 4.4-r2](https://copy.sh/v86?profile=android4) — | ||
[BasicLinux](https://copy.sh/v86/?profile=basiclinux) — | ||
[Buildroot Linux](https://copy.sh/v86/?profile=buildroot) — | ||
[Damn Small Linux](https://copy.sh/v86/?profile=dsl) — | ||
[ELKS](https://copy.sh/v86/?profile=elks) — | ||
[FreeDOS](https://copy.sh/v86/?profile=freedos) — | ||
[FreeBSD](https://copy.sh/v86/?profile=freebsd) — | ||
[FiwixOS](https://copy.sh/v86/?profile=fiwix) — | ||
[Haiku](https://copy.sh/v86/?profile=haiku) — | ||
[SkiffOS](https://copy.sh/v86/?profile=copy/skiffos) — | ||
[ReactOS](https://copy.sh/v86/?profile=reactos) — | ||
[Windows 2000](https://copy.sh/v86/?profile=windows2000) — | ||
[Windows 98](https://copy.sh/v86/?profile=windows98) — | ||
[Windows 95](https://copy.sh/v86/?profile=windows95) — | ||
[Windows 1.01](https://copy.sh/v86/?profile=windows1) — | ||
[MS-DOS 6.22](https://copy.sh/v86/?profile=msdos) — | ||
[OpenBSD](https://copy.sh/v86/?profile=openbsd) — | ||
[Oberon](https://copy.sh/v86/?profile=oberon) — | ||
[KolibriOS](https://copy.sh/v86/?profile=kolibrios) — | ||
[SkiftOS](https://copy.sh/v86?profile=skift) — | ||
[QNX](https://copy.sh/v86/?profile=qnx) | ||
|
||
## Documentation | ||
|
||
[How it works](docs/how-it-works.md) — | ||
[Networking](docs/networking.md) — | ||
[Arch Linux guest setup](docs/archlinux.md) — | ||
[Windows 2000/XP guest setup](docs/windows-xp.md) — | ||
[9p filesystem](docs/filesystem.md) — | ||
[Linux rootfs on 9p](docs/linux-9p-image.md) — | ||
[Profiling](docs/profiling.md) — | ||
[CPU Idling](docs/cpu-idling.md) | ||
|
||
## Compatibility | ||
|
||
Here's an overview of the operating systems supported in v86: | ||
|
||
- Linux works pretty well. 64-bit kernels are not supported. | ||
- Damn Small Linux (2.4.31 kernel) works. | ||
- Fedora 30 works. | ||
- All tested versions of TinyCore work. | ||
- [Buildroot](https://buildroot.uclibc.org) can be used to build a minimal image. | ||
[humphd/browser-vm](https://github.com/humphd/browser-vm) and | ||
[darin755/browser-buildroot](https://github.com/Darin755/browser-buildroot) have some useful scripts for building one. | ||
- [SkiffOS](https://github.com/skiffos/SkiffOS/tree/master/configs/browser/v86) (based on Buildroot) can cross-compile a custom image. | ||
- Archlinux works. See [archlinux.md](docs/archlinux.md) for building an image. | ||
- Debian works. An image can be built from a Dockerfile, see [tools/docker/debian/](tools/docker/debian/). | ||
- Ubuntu works up to the latest version that supported i386 (16.04 LTS or 18.04 LTS for some variants). | ||
- Alpine Linux works. | ||
- ReactOS works. | ||
- FreeDOS, Windows 1.01 and MS-DOS run very well. | ||
- KolibriOS works. | ||
- Haiku works. | ||
- Android-x86 has been tested up to 4.4-r2. | ||
- Windows 1, 3.x, 95, 98, ME, NT and 2000 work reasonably well. | ||
- In Windows 2000 and higher the PC type has to be changed from ACPI PC to Standard PC | ||
- There are some known boot issues ([#250](https://github.com/copy/v86/issues/250), [#433](https://github.com/copy/v86/issues/433), [#507](https://github.com/copy/v86/issues/507), [#555](https://github.com/copy/v86/issues/555), [#620](https://github.com/copy/v86/issues/620), [#645](https://github.com/copy/v86/issues/645)) | ||
- Windows XP, Vista and 8 work under certain conditions (see [#86](https://github.com/copy/v86/issues/86), [#208](https://github.com/copy/v86/issues/208)) | ||
- See [Windows 2000/XP guest setup](docs/windows-xp.md) | ||
- 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](https://github.com/copy/v86/issues/350). | ||
- SerenityOS works. | ||
- [SkiftOS](https://skiftos.org/) works. | ||
|
||
You can get some information on the disk images here: https://github.com/copy/images. | ||
|
||
## How to build, run and embed? | ||
|
||
You need: | ||
|
||
- make | ||
- Rust with the wasm32-unknown-unknown target | ||
- A version of clang compatible with Rust | ||
- java (for Closure Compiler, not necessary when using `debug.html`) | ||
- nodejs (a recent version is required, v16.11.1 is known to be working) | ||
- To run tests: nasm, gdb, qemu-system, gcc, libc-i386 and rustfmt | ||
|
||
See [tools/docker/test-image/Dockerfile](tools/docker/test-image/Dockerfile) | ||
for a full setup on Debian or | ||
[WSL](https://docs.microsoft.com/en-us/windows/wsl/install). | ||
|
||
- 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](examples/). You can download it from the release section. | ||
|
||
### Alternatively, to build using docker | ||
|
||
- If you have docker installed, you can run the whole system inside a container. | ||
- See `tools/docker/exec` to find Dockerfile required for this. | ||
- You can run `docker build -f tools/docker/exec/Dockerfile -t v86:alpine-3.19 .` from the root directory to generate docker image. | ||
- Then you can simply run `docker run -it -p 8000:8000 v86:alpine-3.19` to start the server. | ||
- Check `localhost:8000` for hosted server. | ||
|
||
### Running via Devcontainer | ||
|
||
- If you are using an IDE that supports Devcontainers, such as Github Codespaces, VSCode Remote Container extension, or possibly others such as Jetbrains IDEA, you can setup the development environment in a Dev container. | ||
- Follow the instructions from your development environment to setup the container. | ||
- Run the Task "Fetch images" in order to download images for testing. | ||
|
||
## 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/{linux3.iso,linux.iso,linux4.iso,buildroot-bzimage.bin,openbsd-floppy.img,kolibri.img,windows101.img,os8.img,freedos722.img}` | ||
|
||
Run integration tests: `make tests` | ||
|
||
Run all tests: `make jshint rustfmt kvm-unit-test nasmtests nasmtests-force-jit expect-tests jitpagingtests qemutests rust-test tests` | ||
|
||
See [tests/Readme.md](tests/Readme.md) for more information. | ||
|
||
## API examples | ||
|
||
- [Basic](examples/basic.html) | ||
- [Programatically using the serial terminal](examples/serial.html) | ||
- [A Lua interpreter](examples/lua.html) | ||
- [Two instances in one window](examples/two_instances.html) | ||
- [Saving and restoring emulator state](examples/save_restore.html) | ||
|
||
Using v86 for your own purposes is as easy as: | ||
|
||
```javascript | ||
var emulator = new V86({ | ||
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](src/browser/starter.js). | ||
|
||
## License | ||
|
||
v86 is distributed under the terms of the Simplified BSD License, see | ||
[LICENSE](LICENSE). The following third-party dependencies are included in the | ||
repository under their own licenses: | ||
|
||
- [`lib/softfloat/softfloat.c`](lib/softfloat/softfloat.c) | ||
- [`lib/zstd/zstddeclib.c`](lib/zstd/zstddeclib.c) | ||
- [`tests/kvm-unit-tests/`](tests/kvm-unit-tests) | ||
- [`tests/qemutests/`](tests/qemutests) | ||
|
||
## Credits | ||
|
||
- CPU test cases via [QEMU](https://wiki.qemu.org/Main_Page) | ||
- More tests via [kvm-unit-tests](https://www.linux-kvm.org/page/KVM-unit-tests) | ||
- [zstd](https://github.com/facebook/zstd) support is included for better compression of state images | ||
- [Berkeley SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is included to precisely emulate 80-bit floating point numbers | ||
- [The jor1k project](https://github.com/s-macke/jor1k) for 9p, filesystem and uart drivers | ||
- [WinWorld](https://winworldpc.com/) sources of some old operating systems | ||
|
||
## More questions? | ||
|
||
Shoot me an email to `[email protected]`. Please report bugs on GitHub. | ||
|
||
## Author | ||
|
||
Fabian Hemmer (https://copy.sh/, `[email protected]`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.gz |
Oops, something went wrong.