Commit graph

185 commits

Author SHA1 Message Date
Fabian e1f8a563ad Simplify (remove c_api) 2020-12-31 19:14:30 -06:00
Fabian 81a43f8a88 Don't call is_osize_32 from far_return and far_jump 2020-12-31 19:14:30 -06:00
Fabian ea50e29e5f Remove dead & improve 2020-12-31 19:14:29 -06:00
Fabian d0fb1a78d9 Experimental xterm.js support (#172, #227) 2020-12-31 19:14:29 -06:00
Fabian d5c9b29942 Upgrade jshint 2020-12-31 19:14:29 -06:00
Fabian 48a9847d16 s/oxide// 2020-12-31 19:14:29 -06:00
Fabian 1665e9b358 Fix instruction counter wrap-around 2020-12-31 19:14:29 -06:00
Fabian 47e91de601 Remove has_rand_int, always require get_rand_int to be available 2020-08-30 19:37:15 -05:00
Fabian 0e16983dd3 Handle case when wasm table is full (fixes #35)
Also fix jit_empty_cache when callbacks are pending (fixes #53)

This is also a preparation for setting WASM_TABLE_SIZE to a low value to
work around memory limitations in browsers.
2020-08-30 19:37:15 -05:00
Ernest Wong c928964562 Minor: Tidy quotes and spacing 2020-08-30 19:37:15 -05:00
Ernest Wong d6bfa143ed Filestorage: Don't rely on errors to select type of storage 2020-08-30 19:37:15 -05:00
Ernest Wong 83b283ebbe Filestorage: Replace the two server classes with a wrapper class
Simplifies both the filestorage.js code as well as the starter.js code
that uses these FileStorage classes.

Now, the ServerFileStorageWrapper decorates the other FileStorage
classes by loading from the server when the file is not available.

Moreover, the previous starter.js was incorrectly passing the `baseurl`
parameter (it was passing it when baseurl was not defined nor needed).
2020-08-30 19:37:15 -05:00
Ernest Wong c2dcb440dd Filestorage: Refactor fallback and load-from-server
Fallback logic is moved to the caller's responsibility.

Empty FileStorages and FileStorages that load from the server are
separated into different classes. This is to avoid faults where the
caller of the constructor forgets to pass in a `baseurl` parameter and
leads to some confusing bug.
2020-08-30 19:37:15 -05:00
Ernest Wong 6a06a7108a Tidy: file_storage snake case and interface naming convention 2020-08-30 19:37:15 -05:00
Amaan Cheval 1d5e0052b4 cpu: Port iret, iret16, iret32 to Rust 2020-08-30 19:37:15 -05:00
Amaan Cheval 8aa06b54e0 cpu: Port switch_cs_real_mode to Rust 2020-08-30 19:37:15 -05:00
Fabian d2f86799e9 Simplify load_from_json: Accept json object directly, don't run asynchronously 2020-08-30 19:37:14 -05:00
Fabian f7c22266c9 initrd/bzimage detection: Ignore case 2020-08-30 19:37:14 -05:00
Fabian 028e131ddb Rename OnJSONLoaded & small refactor 2020-08-30 19:37:14 -05:00
Fabian aea2409b1d Ignore filesystem base when state image is provided 2020-08-30 19:37:14 -05:00
Fabian af0f153640 Refactor using new filesystem function 2020-08-30 19:37:14 -05:00
Fabian 3f79814e05 Detect initrd/bzimage in 9p filesystem and load before boot 2020-08-30 19:37:14 -05:00
Fabian e94c30ef6f Don't wrap text in SyncBuffer 2020-08-30 19:37:14 -05:00
Fabian e1c6116a0f Implement Linux kernel boot protocol, accept bzimage/initrd as boot configuration 2020-08-30 19:37:14 -05:00
Fabian 753fcb25c7 Simplify multiboot buffer during init 2020-08-30 19:37:14 -05:00
Fabian 7796d9dcb4 Clean up wasm loading, remove unused code for emscripten 2020-08-30 19:29:54 -05:00
Ernest Wong a0c984dc8d Filesystem: Introduce IndexedDBFileStorage
Uses MemoryFileStorage as a fallback when:
- v86 is used in a browserless environment, e.g. NodeJS
- browser doesn't support indexedDB
- opening indexedDB fails
- existing database is a newer version
- existing database is an old version and is under use - blocking
current v86 instance to connect to it.
2020-08-30 19:29:54 -05:00
Ernest Wong 0a67e3532f Filesystem: Introduce FileStorage class for server-loaded files 2020-08-30 19:29:54 -05:00
Ernest Wong 595d6dca55 Filesystem: Refactor inodedata accesses to async methods
The "// jshint ignore:line" comments are pretty messy, so squint your eyes.
They're systematically placed, so we can regex it out when jshint's
new version finally arrives.

Using async/await instead of callbacks due to callback hell, and it also
helps minimising the diff)
2020-08-30 19:29:54 -05:00
Amaan Cheval 0bf4e4faf6 cpu: Port get_tss_stack_addr to Rust 2020-08-30 19:29:54 -05:00
Amaan Cheval 3b94c5f9d3 cpu: Refactor to use error_code: Option<i32> for call_interrupt_vector 2020-08-30 19:29:54 -05:00
Amaan Cheval ae70cb7e4f cpu: Minor refactor in call_interrupt_vector 2020-08-30 19:29:54 -05:00
Amaan Cheval 4ef09445e1 cpu: Port call_interrupt_vector to Rust 2020-08-30 19:29:54 -05:00
Fabian 32699a3a7e Clear unused wasm modules earlier 2020-08-30 19:29:54 -05:00
Fabian 35cd746940 Delete dead code 2020-08-30 19:29:54 -05:00
Amaan Cheval 96ef38e901 cpu: Port popa{16,32} to Rust 2020-08-30 19:29:54 -05:00
Amaan Cheval 56ec3be5a4 cpu: Port update_cs_size to Rust
The JS version needs to stay too since it can be called by other JS-only functions.
2020-08-30 19:29:54 -05:00
Amaan Cheval 1712d25725 cpu: Port set_cr0 to Rust 2020-08-30 19:29:54 -05:00
Amaan Cheval b4922dc3b1 cpu: Port cpl_changed to Rust
We leave the JS version too, since it's used by several other JS functions
that we aren't porting yet.
2020-08-30 19:29:54 -05:00
Amaan Cheval 8e7061eff5 cpu: Port test_privileges_for_io to Rust 2020-08-30 19:29:54 -05:00
Amaan Cheval 880aa5e2d1 cpu: Port lookup_segment_selector and switch_seg to Rust
We'll keep the JS versions too, since the Rust and JS versions are incompatible, but both are needed
in their own respect.
2020-08-30 19:29:54 -05:00
Fabian fcdda9487e handle_irqs: Do interrupt flag check from Rust 2020-08-30 19:29:54 -05:00
Fabian 38a84342a2 Give Rust more indirect function slots and clean up the code 2020-08-30 19:29:54 -05:00
Fabian d9282afec5 Force logging of panic messages 2020-08-30 19:29:53 -05:00
Fabian 4b34beeb79 c2rust cleanup: Use Rust imports instead of linking 2020-08-30 19:29:53 -05:00
Fabian 67247ec907 (partially) fix variadic dbg_log 2020-08-30 19:29:53 -05:00
Fabian 952b8cf723 Quote for Closure Compiler and add missing functions for non-optimised builds 2020-08-30 19:29:53 -05:00
Fabian 01061dc4b6 The final Rust porting
This commit contains the final changes requires for porting all C code
to Rust and from emscripten to llvm:

- tools/wasm-patch-indirect-function-table.js: A script that rewrites
  the wasm generated by llvm to remove the table limit
- tools/rust-lld-wrapper: A wrapper around rust-lld that removes
  arguments forced by rustc that break compilation for us
- src/rust/cpu2/Makefile: A monstrosity to postprocess c2rust's output
- gen/generate_interpreter.js: Ported to produce Rust instead of C
- src/rust/*: A few functions and macros to connect the old Rust code
  and the new Rust code
- src/*.js: Removes the loading of the old emscripten wasm module and
  adapts imports and exports from emscripten to llvm
2020-08-30 19:29:53 -05:00
Ernest Wong e29e1ef9f4 Handle unexpected errors from fs.Mount and fix V86Starter error handling. 2020-08-30 19:29:53 -05:00
Ernest Wong e683e812fd Mount only onto non-existent paths, existent parent
If mountpoint already exists, then we're silently making its children
inaccessible which may not be what we expected/intended.

Create a new forwarder inode upon mounting.
2020-08-30 19:29:53 -05:00