Commit graph

289 commits

Author SHA1 Message Date
Fabian e1f8a563ad Simplify (remove c_api) 2020-12-31 19:14:30 -06:00
Fabian f3c56e7684 Simplify 2020-12-31 19:14:30 -06:00
Fabian 3a473aad79 Remove prefix handling from jit and exceptions 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 764879bad1 s/reg32s/reg32 2020-12-31 19:14:29 -06:00
Fabian 6986519fbb Use get_seg_ss/get_seg_cs from JS 2020-12-31 19:14:29 -06:00
Fabian dfea644e94 Turn this into warning for now 2020-12-31 19:14:29 -06:00
Fabian c84a814610 Remove unused A20 stuff 2020-12-31 19:14:29 -06:00
Fabian 48a9847d16 s/oxide// 2020-12-31 19:14:29 -06:00
Fabian 941208c948 Remove defunct test coverage 2020-12-31 19:14:29 -06:00
Fabian 60adbf9b1f Fix: Side-effects in lsl/lar/arpl even when #ud is triggered 2020-12-31 19:14:29 -06:00
Fabian 17f2488684 Fix uses of writable_or_pagefault from JS 2020-12-31 19:14:29 -06:00
Fabian 63afa77167 Global pointers: Align general purpose registers, sse registers and flags 2020-12-31 19:14:28 -06:00
Fabian 0e8c8a1dda More opstats 2020-12-31 19:14:28 -06:00
Fabian 7c4ed66c20 Cleanup: Rename trigger_gp_non_raising to trigger_gp 2020-08-30 19:37:15 -05:00
Fabian 2c23ffc2cf Use get_eflags_no_arith over flags[0] (minor performance) 2020-08-30 19:37:15 -05:00
Fabian 70cc242eb1 Simplify call_interrupt_vector from js 2020-08-30 19:37:15 -05:00
Fabian 05296b0586 Enable fpu instructions in nasm tests 2020-08-30 19:37:15 -05:00
Fabian 18cdd2107f Reset fpu state in cpu.reset 2020-08-30 19:37:15 -05:00
Fabian c46d12f921 Allow using libv86-debug.js with v86oxide.wasm 2020-08-30 19:37:15 -05:00
Fabian 4827732a4c Make closure compiler happy 2020-08-30 19:37:15 -05:00
Fabian 608559fa94 Call hlt_loop immediately on an hlt instruction 2020-08-30 19:37:15 -05:00
Fabian 01697a7ebb Delete some dead code 2020-08-30 19:37:15 -05:00
Fabian 7720f9a8e6 Print opcode on unimplemented sse instructions 2020-08-30 19:37:15 -05:00
Fabian 58b8c49fb0 Pack memory in state image, reduces memory use during state loading 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 e1c6116a0f Implement Linux kernel boot protocol, accept bzimage/initrd as boot configuration 2020-08-30 19:37:14 -05:00
Fabian 04d282c298 Firmware port: Pretend to be qemu, implement all indexes used by seabios 2020-08-30 19:37:14 -05:00
Fabian 753fcb25c7 Simplify multiboot buffer during init 2020-08-30 19:37:14 -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 4ef09445e1 cpu: Port call_interrupt_vector to Rust 2020-08-30 19:29:54 -05:00
Fabian 7d0521475a Store fxsave_store_fpu_mask in state 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 1712d25725 cpu: Port set_cr0 to Rust 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
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 3c903338c3 c2rust cleanup: Call more functions directly 2020-08-30 19:29:54 -05:00
Fabian 75eecd0d63 Multiboot loader: Skip sections outside of memory 2020-08-30 19:29:54 -05:00
Fabian 9c9fc4e0e7 Check imports 2020-08-30 19:29:53 -05:00
Fabian a88420910d Handle pagefaults without JS exceptions
This commit makes the return type of most basic memory access primitives
Result, where the Err(()) case means a page fault happened, the
instruction should be aborted and execution should continue at the page
fault handler.

The following primites have a Result return type: safe_{read,write}*,
translate_address_*, read_imm*, writable_or_pagefault, get_phys_eip,
modrm_resolve, push*, pop*.

Any instruction needs to handle the page fault cases and abort
execution appropriately. The return_on_pagefault! macro has been
provided to get the same behaviour as the previously used JS exceptions
(local to the function).

Calls from JavaScript abort on a pagefault, except for
writable_or_pagefault, which returns a boolean. JS needs to check
before calling any function that may pagefault.

This commit does not yet pervasively apply return_on_pagefault!, this
will be added in the next commit.

Jitted code does not yet properly handle the new form of page faults,
this will be added in a later commit.
2020-08-30 19:29:53 -05:00
Fabian 1faf8ccc86 Allocate memory via Rust instead of ahead-of-time 2020-08-30 19:29:53 -05:00
Fabian 05d0079015 Use Proxy over getters for memory views (works in compiled mode) 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
Fabian 551f5d1a1f When HLT is executed, check for new interrupts immediately and don't leave the main loop if execution can continue 2020-08-30 19:29:53 -05:00
Fabian ea6e7daee5 Avoid use of raising cpu exceptoins for HLT 2020-08-30 19:29:53 -05:00