riscv: Add full-system emulation support for the RISC-V Instruction Set Architecture (RV64G)
cover riscv: Add full-system emulation support for the RISC-V Instruction Set Architecture (RV64G)
The patch in this RFC adds support for the RISC-V ISA [1] as a target. It has been tested booting Linux and FreeBSD, passes the RISC-V assembly test suite, and has had the riscv-torture tester running on it for a couple of weeks now without any issues arising.
With this RFC, I mainly wanted to get input on the overall design of the target implementation, as well as see if any regular contributors would be interested in co-mentoring RISC-V related projects for QEMU's Google Summer of Code with me.
In case anyone wants to test it out, there is a repo on the RISC-V GitHub organization with a README.md containing instructions, a copy of the full v2.5.0 codebase with this patch applied, and links to prebuilt RISC-V linux images [2].
Some notes/questions:
- This provides support only for the 64-bit version of the ISA and full system emulation (no user-mode)
- This currently applies to the 2.5.0 release version. I will bump the underlying codebase, split this into multiple patches, apply style checks before submitting real patches
- The code in target-riscv/fpu-custom-riscv is an updated/modified version of softfloat. Is it okay to submodule this until the FPU behavior in RISC-V is stabilized? (and then later, presumably merge it with the version of softfloat included in QEMU). For current review purposes, I believe everything in this directory can be ignored.
- The devices in hw/riscv/htif are intended to mimic the experimental devices that we use with our RISC-V test chips. These will be removed and replaced with "real" devices once there is better software support in the OS/bootloader ports.
Potentially useful references:
- RISC-V User Spec: See [3]. This spec is frozen.
- RISC-V Privileged Spec: See [4]. This spec is a draft.
- Spike, the reference simulator for the ISA: See [5].
[1] https://riscv.org
[2] https://github.com/riscv/riscv-qemu
[3] http://riscv.org/wp-content/uploads/2015/11/riscv-spec-v2.0.pdf
[4] http://riscv.org/wp-content/uploads/2015/11/riscv-privileged-spec-v1.7.pdf
[5] https://github.com/riscv/riscv-isa-sim
Sagar Karandikar (1):
riscv: Add full-system emulation support for the RISC-V Instruction
Set Architecture (RV64G)
arch_init.c | 2 + configure | 13 + cpus.c | 6 + default-configs/riscv-linux-user.mak | 1 + default-configs/riscv-softmmu.mak | 38 + disas.c | 2 + disas/Makefile.objs | 1 + disas/riscv.c | 46 + hw/riscv/Makefile.objs | 5 + hw/riscv/cputimer.c | 170 ++ hw/riscv/htif/frontend.c | 215 ++ hw/riscv/htif/htif.c | 459 +++++ hw/riscv/riscv_board.c | 330 +++ hw/riscv/riscv_int.c | 84 + hw/riscv/softint.c | 121 ++ include/disas/bfd.h | 1 + include/elf.h | 2 + include/exec/poison.h | 1 + include/exec/user/thunk.h | 2 +- include/hw/riscv/bios.h | 4 + include/hw/riscv/cpudevs.h | 14 + include/hw/riscv/cputimer.h | 4 + include/hw/riscv/htif/frontend.h | 30 + include/hw/riscv/htif/htif.h | 76 + include/hw/riscv/riscv.h | 10 + include/hw/riscv/softint.h | 50 + include/sysemu/arch_init.h | 1 + target-riscv/Makefile.objs | 114 ++ target-riscv/TODO | 17 + target-riscv/cpu-qom.h | 86 + target-riscv/cpu.c | 143 ++ target-riscv/cpu.h | 449 ++++ .../fpu-custom-riscv/8086/OLD-specialize.c | 40 + .../fpu-custom-riscv/8086/OLD-specialize.h | 379 ++++ target-riscv/fpu-custom-riscv/8086/platform.h | 38 + .../fpu-custom-riscv/8086/s_commonNaNToF32UI.c | 17 + .../fpu-custom-riscv/8086/s_commonNaNToF64UI.c | 19 + .../fpu-custom-riscv/8086/s_f32UIToCommonNaN.c | 25 + .../fpu-custom-riscv/8086/s_f64UIToCommonNaN.c | 25 + .../fpu-custom-riscv/8086/s_isSigNaNF32UI.c | 13 + .../fpu-custom-riscv/8086/s_isSigNaNF64UI.c | 15 + .../fpu-custom-riscv/8086/s_propagateNaNF32UI.c | 55 + .../fpu-custom-riscv/8086/s_propagateNaNF64UI.c | 55 + .../fpu-custom-riscv/8086/softfloat_raiseFlags.c | 51 + .../fpu-custom-riscv/8086/softfloat_types.h | 16 + target-riscv/fpu-custom-riscv/8086/specialize.h | 113 + target-riscv/fpu-custom-riscv/f32_add.c | 29 + target-riscv/fpu-custom-riscv/f32_classify.c | 33 + target-riscv/fpu-custom-riscv/f32_div.c | 96 + target-riscv/fpu-custom-riscv/f32_eq.c | 34 + target-riscv/fpu-custom-riscv/f32_eq_signaling.c | 29 + target-riscv/fpu-custom-riscv/f32_isSignalingNaN.c | 16 + target-riscv/fpu-custom-riscv/f32_le.c | 34 + target-riscv/fpu-custom-riscv/f32_le_quiet.c | 39 + target-riscv/fpu-custom-riscv/f32_lt.c | 34 + target-riscv/fpu-custom-riscv/f32_lt_quiet.c | 39 + target-riscv/fpu-custom-riscv/f32_mul.c | 89 + target-riscv/fpu-custom-riscv/f32_mulAdd.c | 25 + target-riscv/fpu-custom-riscv/f32_rem.c | 124 ++ target-riscv/fpu-custom-riscv/f32_roundToInt.c | 78 + target-riscv/fpu-custom-riscv/f32_sqrt.c | 74 + target-riscv/fpu-custom-riscv/f32_sub.c | 29 + target-riscv/fpu-custom-riscv/f32_to_f64.c | 47 + target-riscv/fpu-custom-riscv/f32_to_i32.c | 34 + .../fpu-custom-riscv/f32_to_i32_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/f32_to_i64.c | 44 + .../fpu-custom-riscv/f32_to_i64_r_minMag.c | 52 + target-riscv/fpu-custom-riscv/f32_to_ui32.c | 33 + .../fpu-custom-riscv/f32_to_ui32_r_minMag.c | 41 + target-riscv/fpu-custom-riscv/f32_to_ui64.c | 42 + .../fpu-custom-riscv/f32_to_ui64_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/f64_add.c | 29 + target-riscv/fpu-custom-riscv/f64_classify.c | 33 + target-riscv/fpu-custom-riscv/f64_div.c | 104 + target-riscv/fpu-custom-riscv/f64_eq.c | 35 + target-riscv/fpu-custom-riscv/f64_eq_signaling.c | 30 + target-riscv/fpu-custom-riscv/f64_isSignalingNaN.c | 16 + target-riscv/fpu-custom-riscv/f64_le.c | 35 + target-riscv/fpu-custom-riscv/f64_le_quiet.c | 40 + target-riscv/fpu-custom-riscv/f64_lt.c | 35 + target-riscv/fpu-custom-riscv/f64_lt_quiet.c | 40 + target-riscv/fpu-custom-riscv/f64_mul.c | 91 + target-riscv/fpu-custom-riscv/f64_mulAdd.c | 25 + target-riscv/fpu-custom-riscv/f64_rem.c | 113 + target-riscv/fpu-custom-riscv/f64_roundToInt.c | 80 + target-riscv/fpu-custom-riscv/f64_sqrt.c | 74 + target-riscv/fpu-custom-riscv/f64_sub.c | 29 + target-riscv/fpu-custom-riscv/f64_to_f32.c | 43 + target-riscv/fpu-custom-riscv/f64_to_i32.c | 30 + .../fpu-custom-riscv/f64_to_i32_r_minMag.c | 50 + target-riscv/fpu-custom-riscv/f64_to_i64.c | 46 + .../fpu-custom-riscv/f64_to_i64_r_minMag.c | 52 + target-riscv/fpu-custom-riscv/f64_to_ui32.c | 29 + .../fpu-custom-riscv/f64_to_ui32_r_minMag.c | 40 + target-riscv/fpu-custom-riscv/f64_to_ui64.c | 41 + .../fpu-custom-riscv/f64_to_ui64_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/i32_to_f32.c | 21 + target-riscv/fpu-custom-riscv/i32_to_f64.c | 31 + target-riscv/fpu-custom-riscv/i64_to_f32.c | 36 + target-riscv/fpu-custom-riscv/i64_to_f64.c | 21 + target-riscv/fpu-custom-riscv/internals.h | 232 +++ target-riscv/fpu-custom-riscv/platform.h | 42 + target-riscv/fpu-custom-riscv/primitives.h | 628 ++++++ target-riscv/fpu-custom-riscv/s_add128.c | 17 + target-riscv/fpu-custom-riscv/s_add192.c | 30 + target-riscv/fpu-custom-riscv/s_addMagsF32.c | 75 + target-riscv/fpu-custom-riscv/s_addMagsF64.c | 77 + target-riscv/fpu-custom-riscv/s_commonNaNToF32UI.c | 17 + target-riscv/fpu-custom-riscv/s_commonNaNToF64UI.c | 17 + .../fpu-custom-riscv/s_countLeadingZeros32.c | 22 + .../fpu-custom-riscv/s_countLeadingZeros64.c | 32 + .../fpu-custom-riscv/s_countLeadingZeros8.c | 24 + target-riscv/fpu-custom-riscv/s_eq128.c | 13 + .../fpu-custom-riscv/s_estimateDiv128To64.c | 28 + target-riscv/fpu-custom-riscv/s_estimateSqrt32.c | 37 + target-riscv/fpu-custom-riscv/s_f32UIToCommonNaN.c | 25 + target-riscv/fpu-custom-riscv/s_f64UIToCommonNaN.c | 25 + target-riscv/fpu-custom-riscv/s_isSigNaNF32UI.c | 13 + target-riscv/fpu-custom-riscv/s_isSigNaNF64UI.c | 15 + target-riscv/fpu-custom-riscv/s_le128.c | 13 + target-riscv/fpu-custom-riscv/s_lt128.c | 13 + target-riscv/fpu-custom-riscv/s_mul128By64To192.c | 20 + target-riscv/fpu-custom-riscv/s_mul128To256.c | 28 + target-riscv/fpu-custom-riscv/s_mul64To128.c | 28 + target-riscv/fpu-custom-riscv/s_mulAddF32.c | 171 ++ target-riscv/fpu-custom-riscv/s_mulAddF64.c | 188 ++ .../fpu-custom-riscv/s_normRoundPackToF32.c | 24 + .../fpu-custom-riscv/s_normRoundPackToF64.c | 24 + .../fpu-custom-riscv/s_normSubnormalF32Sig.c | 18 + .../fpu-custom-riscv/s_normSubnormalF64Sig.c | 18 + .../fpu-custom-riscv/s_propagateNaNF32UI.c | 25 + .../fpu-custom-riscv/s_propagateNaNF64UI.c | 25 + target-riscv/fpu-custom-riscv/s_roundPackToF32.c | 65 + target-riscv/fpu-custom-riscv/s_roundPackToF64.c | 66 + target-riscv/fpu-custom-riscv/s_roundPackToI32.c | 48 + target-riscv/fpu-custom-riscv/s_roundPackToI64.c | 52 + target-riscv/fpu-custom-riscv/s_roundPackToUI32.c | 44 + target-riscv/fpu-custom-riscv/s_roundPackToUI64.c | 46 + .../fpu-custom-riscv/s_shift128ExtraRightJam.c | 38 + target-riscv/fpu-custom-riscv/s_shift128RightJam.c | 31 + target-riscv/fpu-custom-riscv/s_shift32RightJam.c | 15 + .../fpu-custom-riscv/s_shift64ExtraRightJam.c | 23 + target-riscv/fpu-custom-riscv/s_shift64RightJam.c | 15 + .../s_shortShift128ExtraRightJam.c | 20 + .../fpu-custom-riscv/s_shortShift128Left.c | 16 + .../fpu-custom-riscv/s_shortShift128Right.c | 16 + .../fpu-custom-riscv/s_shortShift192Left.c | 20 + .../fpu-custom-riscv/s_shortShift32Right1Jam.c | 12 + .../fpu-custom-riscv/s_shortShift64ExtraRightJam.c | 17 + .../fpu-custom-riscv/s_shortShift64RightJam.c | 12 + target-riscv/fpu-custom-riscv/s_sub128.c | 17 + target-riscv/fpu-custom-riscv/s_sub192.c | 30 + target-riscv/fpu-custom-riscv/s_subMagsF32.c | 81 + target-riscv/fpu-custom-riscv/s_subMagsF64.c | 81 + target-riscv/fpu-custom-riscv/softfloat.ac | 0 target-riscv/fpu-custom-riscv/softfloat.h | 235 +++ target-riscv/fpu-custom-riscv/softfloat.mk.in | 126 ++ .../fpu-custom-riscv/softfloat_raiseFlags.c | 51 + target-riscv/fpu-custom-riscv/softfloat_state.c | 19 + target-riscv/fpu-custom-riscv/softfloat_types.h | 16 + target-riscv/fpu-custom-riscv/specialize.h | 113 + target-riscv/fpu-custom-riscv/ui32_to_f32.c | 25 + target-riscv/fpu-custom-riscv/ui32_to_f64.c | 26 + target-riscv/fpu-custom-riscv/ui64_to_f32.c | 31 + target-riscv/fpu-custom-riscv/ui64_to_f64.c | 25 + target-riscv/gdbstub.c | 177 ++ target-riscv/helper.c | 356 ++++ target-riscv/helper.h | 82 + target-riscv/instmap.h | 311 +++ target-riscv/machine.c | 91 + target-riscv/op_helper.c | 1037 ++++++++++ target-riscv/riscv-defs.h | 14 + target-riscv/translate.c | 2155 ++++++++++++++++++++ target-riscv/translate_init.c | 63 + 174 files changed, 13518 insertions(+), 1 deletion(-) create mode 100644 default-configs/riscv-linux-user.mak create mode 100644 default-configs/riscv-softmmu.mak create mode 100644 disas/riscv.c create mode 100644 hw/riscv/Makefile.objs create mode 100644 hw/riscv/cputimer.c create mode 100644 hw/riscv/htif/frontend.c create mode 100644 hw/riscv/htif/htif.c create mode 100644 hw/riscv/riscv_board.c create mode 100644 hw/riscv/riscv_int.c create mode 100644 hw/riscv/softint.c create mode 100644 include/hw/riscv/bios.h create mode 100644 include/hw/riscv/cpudevs.h create mode 100644 include/hw/riscv/cputimer.h create mode 100644 include/hw/riscv/htif/frontend.h create mode 100644 include/hw/riscv/htif/htif.h create mode 100644 include/hw/riscv/riscv.h create mode 100644 include/hw/riscv/softint.h create mode 100644 target-riscv/Makefile.objs create mode 100644 target-riscv/TODO create mode 100644 target-riscv/cpu-qom.h create mode 100644 target-riscv/cpu.c create mode 100644 target-riscv/cpu.h create mode 100755 target-riscv/fpu-custom-riscv/8086/OLD-specialize.c create mode 100755 target-riscv/fpu-custom-riscv/8086/OLD-specialize.h create mode 100755 target-riscv/fpu-custom-riscv/8086/platform.h create mode 100755 target-riscv/fpu-custom-riscv/8086/s_commonNaNToF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_commonNaNToF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_f32UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_f64UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_isSigNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_isSigNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_propagateNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_propagateNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/softfloat_raiseFlags.c create mode 100755 target-riscv/fpu-custom-riscv/8086/softfloat_types.h create mode 100755 target-riscv/fpu-custom-riscv/8086/specialize.h create mode 100755 target-riscv/fpu-custom-riscv/f32_add.c create mode 100755 target-riscv/fpu-custom-riscv/f32_classify.c create mode 100755 target-riscv/fpu-custom-riscv/f32_div.c create mode 100755 target-riscv/fpu-custom-riscv/f32_eq.c create mode 100755 target-riscv/fpu-custom-riscv/f32_eq_signaling.c create mode 100755 target-riscv/fpu-custom-riscv/f32_isSignalingNaN.c create mode 100755 target-riscv/fpu-custom-riscv/f32_le.c create mode 100755 target-riscv/fpu-custom-riscv/f32_le_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f32_lt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_lt_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f32_mul.c create mode 100755 target-riscv/fpu-custom-riscv/f32_mulAdd.c create mode 100755 target-riscv/fpu-custom-riscv/f32_rem.c create mode 100755 target-riscv/fpu-custom-riscv/f32_roundToInt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_sqrt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_sub.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i32.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui32.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_add.c create mode 100755 target-riscv/fpu-custom-riscv/f64_classify.c create mode 100755 target-riscv/fpu-custom-riscv/f64_div.c create mode 100755 target-riscv/fpu-custom-riscv/f64_eq.c create mode 100755 target-riscv/fpu-custom-riscv/f64_eq_signaling.c create mode 100755 target-riscv/fpu-custom-riscv/f64_isSignalingNaN.c create mode 100755 target-riscv/fpu-custom-riscv/f64_le.c create mode 100755 target-riscv/fpu-custom-riscv/f64_le_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f64_lt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_lt_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f64_mul.c create mode 100755 target-riscv/fpu-custom-riscv/f64_mulAdd.c create mode 100755 target-riscv/fpu-custom-riscv/f64_rem.c create mode 100755 target-riscv/fpu-custom-riscv/f64_roundToInt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_sqrt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_sub.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i64.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui64.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/i32_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/i32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/i64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/i64_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/internals.h create mode 100755 target-riscv/fpu-custom-riscv/platform.h create mode 100755 target-riscv/fpu-custom-riscv/primitives.h create mode 100755 target-riscv/fpu-custom-riscv/s_add128.c create mode 100755 target-riscv/fpu-custom-riscv/s_add192.c create mode 100755 target-riscv/fpu-custom-riscv/s_addMagsF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_addMagsF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_commonNaNToF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_commonNaNToF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros32.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros64.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros8.c create mode 100755 target-riscv/fpu-custom-riscv/s_eq128.c create mode 100755 target-riscv/fpu-custom-riscv/s_estimateDiv128To64.c create mode 100755 target-riscv/fpu-custom-riscv/s_estimateSqrt32.c create mode 100755 target-riscv/fpu-custom-riscv/s_f32UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/s_f64UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/s_isSigNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_isSigNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_le128.c create mode 100755 target-riscv/fpu-custom-riscv/s_lt128.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul128By64To192.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul128To256.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul64To128.c create mode 100755 target-riscv/fpu-custom-riscv/s_mulAddF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_mulAddF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_normRoundPackToF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_normRoundPackToF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_normSubnormalF32Sig.c create mode 100755 target-riscv/fpu-custom-riscv/s_normSubnormalF64Sig.c create mode 100755 target-riscv/fpu-custom-riscv/s_propagateNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_propagateNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToI32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToI64.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToUI32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToUI64.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift128ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift128RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift32RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift64ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift64RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128Left.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128Right.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift192Left.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift32Right1Jam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift64ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift64RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_sub128.c create mode 100755 target-riscv/fpu-custom-riscv/s_sub192.c create mode 100755 target-riscv/fpu-custom-riscv/s_subMagsF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_subMagsF64.c create mode 100644 target-riscv/fpu-custom-riscv/softfloat.ac create mode 100755 target-riscv/fpu-custom-riscv/softfloat.h create mode 100644 target-riscv/fpu-custom-riscv/softfloat.mk.in create mode 100755 target-riscv/fpu-custom-riscv/softfloat_raiseFlags.c create mode 100755 target-riscv/fpu-custom-riscv/softfloat_state.c create mode 100755 target-riscv/fpu-custom-riscv/softfloat_types.h create mode 100755 target-riscv/fpu-custom-riscv/specialize.h create mode 100755 target-riscv/fpu-custom-riscv/ui32_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/ui32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/ui64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/ui64_to_f64.c create mode 100644 target-riscv/gdbstub.c create mode 100644 target-riscv/helper.c create mode 100644 target-riscv/helper.h create mode 100644 target-riscv/instmap.h create mode 100644 target-riscv/machine.c create mode 100644 target-riscv/op_helper.c create mode 100644 target-riscv/riscv-defs.h create mode 100644 target-riscv/translate.c create mode 100644 target-riscv/translate_init.c
Signature · 1 line
2.7.1
RFC 1/1 riscv: Add full-system emulation support for the RISC-V Instruction Set Architecture (RV64G)
--- arch_init.c | 2 + configure | 13 + cpus.c | 6 + default-configs/riscv-linux-user.mak | 1 + default-configs/riscv-softmmu.mak | 38 + disas.c | 2 + disas/Makefile.objs | 1 + disas/riscv.c | 46 + hw/riscv/Makefile.objs | 5 + hw/riscv/cputimer.c | 170 ++ hw/riscv/htif/frontend.c | 215 ++ hw/riscv/htif/htif.c | 459 +++++ hw/riscv/riscv_board.c | 330 +++ hw/riscv/riscv_int.c | 84 + hw/riscv/softint.c | 121 ++ include/disas/bfd.h | 1 + include/elf.h | 2 + include/exec/poison.h | 1 + include/exec/user/thunk.h | 2 +- include/hw/riscv/bios.h | 4 + include/hw/riscv/cpudevs.h | 14 + include/hw/riscv/cputimer.h | 4 + include/hw/riscv/htif/frontend.h | 30 + include/hw/riscv/htif/htif.h | 76 + include/hw/riscv/riscv.h | 10 + include/hw/riscv/softint.h | 50 + include/sysemu/arch_init.h | 1 + target-riscv/Makefile.objs | 114 ++ target-riscv/TODO | 17 + target-riscv/cpu-qom.h | 86 + target-riscv/cpu.c | 143 ++ target-riscv/cpu.h | 449 ++++ .../fpu-custom-riscv/8086/OLD-specialize.c | 40 + .../fpu-custom-riscv/8086/OLD-specialize.h | 379 ++++ target-riscv/fpu-custom-riscv/8086/platform.h | 38 + .../fpu-custom-riscv/8086/s_commonNaNToF32UI.c | 17 + .../fpu-custom-riscv/8086/s_commonNaNToF64UI.c | 19 + .../fpu-custom-riscv/8086/s_f32UIToCommonNaN.c | 25 + .../fpu-custom-riscv/8086/s_f64UIToCommonNaN.c | 25 + .../fpu-custom-riscv/8086/s_isSigNaNF32UI.c | 13 + .../fpu-custom-riscv/8086/s_isSigNaNF64UI.c | 15 + .../fpu-custom-riscv/8086/s_propagateNaNF32UI.c | 55 + .../fpu-custom-riscv/8086/s_propagateNaNF64UI.c | 55 + .../fpu-custom-riscv/8086/softfloat_raiseFlags.c | 51 + .../fpu-custom-riscv/8086/softfloat_types.h | 16 + target-riscv/fpu-custom-riscv/8086/specialize.h | 113 + target-riscv/fpu-custom-riscv/f32_add.c | 29 + target-riscv/fpu-custom-riscv/f32_classify.c | 33 + target-riscv/fpu-custom-riscv/f32_div.c | 96 + target-riscv/fpu-custom-riscv/f32_eq.c | 34 + target-riscv/fpu-custom-riscv/f32_eq_signaling.c | 29 + target-riscv/fpu-custom-riscv/f32_isSignalingNaN.c | 16 + target-riscv/fpu-custom-riscv/f32_le.c | 34 + target-riscv/fpu-custom-riscv/f32_le_quiet.c | 39 + target-riscv/fpu-custom-riscv/f32_lt.c | 34 + target-riscv/fpu-custom-riscv/f32_lt_quiet.c | 39 + target-riscv/fpu-custom-riscv/f32_mul.c | 89 + target-riscv/fpu-custom-riscv/f32_mulAdd.c | 25 + target-riscv/fpu-custom-riscv/f32_rem.c | 124 ++ target-riscv/fpu-custom-riscv/f32_roundToInt.c | 78 + target-riscv/fpu-custom-riscv/f32_sqrt.c | 74 + target-riscv/fpu-custom-riscv/f32_sub.c | 29 + target-riscv/fpu-custom-riscv/f32_to_f64.c | 47 + target-riscv/fpu-custom-riscv/f32_to_i32.c | 34 + .../fpu-custom-riscv/f32_to_i32_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/f32_to_i64.c | 44 + .../fpu-custom-riscv/f32_to_i64_r_minMag.c | 52 + target-riscv/fpu-custom-riscv/f32_to_ui32.c | 33 + .../fpu-custom-riscv/f32_to_ui32_r_minMag.c | 41 + target-riscv/fpu-custom-riscv/f32_to_ui64.c | 42 + .../fpu-custom-riscv/f32_to_ui64_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/f64_add.c | 29 + target-riscv/fpu-custom-riscv/f64_classify.c | 33 + target-riscv/fpu-custom-riscv/f64_div.c | 104 + target-riscv/fpu-custom-riscv/f64_eq.c | 35 + target-riscv/fpu-custom-riscv/f64_eq_signaling.c | 30 + target-riscv/fpu-custom-riscv/f64_isSignalingNaN.c | 16 + target-riscv/fpu-custom-riscv/f64_le.c | 35 + target-riscv/fpu-custom-riscv/f64_le_quiet.c | 40 + target-riscv/fpu-custom-riscv/f64_lt.c | 35 + target-riscv/fpu-custom-riscv/f64_lt_quiet.c | 40 + target-riscv/fpu-custom-riscv/f64_mul.c | 91 + target-riscv/fpu-custom-riscv/f64_mulAdd.c | 25 + target-riscv/fpu-custom-riscv/f64_rem.c | 113 + target-riscv/fpu-custom-riscv/f64_roundToInt.c | 80 + target-riscv/fpu-custom-riscv/f64_sqrt.c | 74 + target-riscv/fpu-custom-riscv/f64_sub.c | 29 + target-riscv/fpu-custom-riscv/f64_to_f32.c | 43 + target-riscv/fpu-custom-riscv/f64_to_i32.c | 30 + .../fpu-custom-riscv/f64_to_i32_r_minMag.c | 50 + target-riscv/fpu-custom-riscv/f64_to_i64.c | 46 + .../fpu-custom-riscv/f64_to_i64_r_minMag.c | 52 + target-riscv/fpu-custom-riscv/f64_to_ui32.c | 29 + .../fpu-custom-riscv/f64_to_ui32_r_minMag.c | 40 + target-riscv/fpu-custom-riscv/f64_to_ui64.c | 41 + .../fpu-custom-riscv/f64_to_ui64_r_minMag.c | 45 + target-riscv/fpu-custom-riscv/i32_to_f32.c | 21 + target-riscv/fpu-custom-riscv/i32_to_f64.c | 31 + target-riscv/fpu-custom-riscv/i64_to_f32.c | 36 + target-riscv/fpu-custom-riscv/i64_to_f64.c | 21 + target-riscv/fpu-custom-riscv/internals.h | 232 +++ target-riscv/fpu-custom-riscv/platform.h | 42 + target-riscv/fpu-custom-riscv/primitives.h | 628 ++++++ target-riscv/fpu-custom-riscv/s_add128.c | 17 + target-riscv/fpu-custom-riscv/s_add192.c | 30 + target-riscv/fpu-custom-riscv/s_addMagsF32.c | 75 + target-riscv/fpu-custom-riscv/s_addMagsF64.c | 77 + target-riscv/fpu-custom-riscv/s_commonNaNToF32UI.c | 17 + target-riscv/fpu-custom-riscv/s_commonNaNToF64UI.c | 17 + .../fpu-custom-riscv/s_countLeadingZeros32.c | 22 + .../fpu-custom-riscv/s_countLeadingZeros64.c | 32 + .../fpu-custom-riscv/s_countLeadingZeros8.c | 24 + target-riscv/fpu-custom-riscv/s_eq128.c | 13 + .../fpu-custom-riscv/s_estimateDiv128To64.c | 28 + target-riscv/fpu-custom-riscv/s_estimateSqrt32.c | 37 + target-riscv/fpu-custom-riscv/s_f32UIToCommonNaN.c | 25 + target-riscv/fpu-custom-riscv/s_f64UIToCommonNaN.c | 25 + target-riscv/fpu-custom-riscv/s_isSigNaNF32UI.c | 13 + target-riscv/fpu-custom-riscv/s_isSigNaNF64UI.c | 15 + target-riscv/fpu-custom-riscv/s_le128.c | 13 + target-riscv/fpu-custom-riscv/s_lt128.c | 13 + target-riscv/fpu-custom-riscv/s_mul128By64To192.c | 20 + target-riscv/fpu-custom-riscv/s_mul128To256.c | 28 + target-riscv/fpu-custom-riscv/s_mul64To128.c | 28 + target-riscv/fpu-custom-riscv/s_mulAddF32.c | 171 ++ target-riscv/fpu-custom-riscv/s_mulAddF64.c | 188 ++ .../fpu-custom-riscv/s_normRoundPackToF32.c | 24 + .../fpu-custom-riscv/s_normRoundPackToF64.c | 24 + .../fpu-custom-riscv/s_normSubnormalF32Sig.c | 18 + .../fpu-custom-riscv/s_normSubnormalF64Sig.c | 18 + .../fpu-custom-riscv/s_propagateNaNF32UI.c | 25 + .../fpu-custom-riscv/s_propagateNaNF64UI.c | 25 + target-riscv/fpu-custom-riscv/s_roundPackToF32.c | 65 + target-riscv/fpu-custom-riscv/s_roundPackToF64.c | 66 + target-riscv/fpu-custom-riscv/s_roundPackToI32.c | 48 + target-riscv/fpu-custom-riscv/s_roundPackToI64.c | 52 + target-riscv/fpu-custom-riscv/s_roundPackToUI32.c | 44 + target-riscv/fpu-custom-riscv/s_roundPackToUI64.c | 46 + .../fpu-custom-riscv/s_shift128ExtraRightJam.c | 38 + target-riscv/fpu-custom-riscv/s_shift128RightJam.c | 31 + target-riscv/fpu-custom-riscv/s_shift32RightJam.c | 15 + .../fpu-custom-riscv/s_shift64ExtraRightJam.c | 23 + target-riscv/fpu-custom-riscv/s_shift64RightJam.c | 15 + .../s_shortShift128ExtraRightJam.c | 20 + .../fpu-custom-riscv/s_shortShift128Left.c | 16 + .../fpu-custom-riscv/s_shortShift128Right.c | 16 + .../fpu-custom-riscv/s_shortShift192Left.c | 20 + .../fpu-custom-riscv/s_shortShift32Right1Jam.c | 12 + .../fpu-custom-riscv/s_shortShift64ExtraRightJam.c | 17 + .../fpu-custom-riscv/s_shortShift64RightJam.c | 12 + target-riscv/fpu-custom-riscv/s_sub128.c | 17 + target-riscv/fpu-custom-riscv/s_sub192.c | 30 + target-riscv/fpu-custom-riscv/s_subMagsF32.c | 81 + target-riscv/fpu-custom-riscv/s_subMagsF64.c | 81 + target-riscv/fpu-custom-riscv/softfloat.ac | 0 target-riscv/fpu-custom-riscv/softfloat.h | 235 +++ target-riscv/fpu-custom-riscv/softfloat.mk.in | 126 ++ .../fpu-custom-riscv/softfloat_raiseFlags.c | 51 + target-riscv/fpu-custom-riscv/softfloat_state.c | 19 + target-riscv/fpu-custom-riscv/softfloat_types.h | 16 + target-riscv/fpu-custom-riscv/specialize.h | 113 + target-riscv/fpu-custom-riscv/ui32_to_f32.c | 25 + target-riscv/fpu-custom-riscv/ui32_to_f64.c | 26 + target-riscv/fpu-custom-riscv/ui64_to_f32.c | 31 + target-riscv/fpu-custom-riscv/ui64_to_f64.c | 25 + target-riscv/gdbstub.c | 177 ++ target-riscv/helper.c | 356 ++++ target-riscv/helper.h | 82 + target-riscv/instmap.h | 311 +++ target-riscv/machine.c | 91 + target-riscv/op_helper.c | 1037 ++++++++++ target-riscv/riscv-defs.h | 14 + target-riscv/translate.c | 2155 ++++++++++++++++++++ target-riscv/translate_init.c | 63 + 174 files changed, 13518 insertions(+), 1 deletion(-) create mode 100644 default-configs/riscv-linux-user.mak create mode 100644 default-configs/riscv-softmmu.mak create mode 100644 disas/riscv.c create mode 100644 hw/riscv/Makefile.objs create mode 100644 hw/riscv/cputimer.c create mode 100644 hw/riscv/htif/frontend.c create mode 100644 hw/riscv/htif/htif.c create mode 100644 hw/riscv/riscv_board.c create mode 100644 hw/riscv/riscv_int.c create mode 100644 hw/riscv/softint.c create mode 100644 include/hw/riscv/bios.h create mode 100644 include/hw/riscv/cpudevs.h create mode 100644 include/hw/riscv/cputimer.h create mode 100644 include/hw/riscv/htif/frontend.h create mode 100644 include/hw/riscv/htif/htif.h create mode 100644 include/hw/riscv/riscv.h create mode 100644 include/hw/riscv/softint.h create mode 100644 target-riscv/Makefile.objs create mode 100644 target-riscv/TODO create mode 100644 target-riscv/cpu-qom.h create mode 100644 target-riscv/cpu.c create mode 100644 target-riscv/cpu.h create mode 100755 target-riscv/fpu-custom-riscv/8086/OLD-specialize.c create mode 100755 target-riscv/fpu-custom-riscv/8086/OLD-specialize.h create mode 100755 target-riscv/fpu-custom-riscv/8086/platform.h create mode 100755 target-riscv/fpu-custom-riscv/8086/s_commonNaNToF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_commonNaNToF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_f32UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_f64UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_isSigNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_isSigNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_propagateNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/s_propagateNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/8086/softfloat_raiseFlags.c create mode 100755 target-riscv/fpu-custom-riscv/8086/softfloat_types.h create mode 100755 target-riscv/fpu-custom-riscv/8086/specialize.h create mode 100755 target-riscv/fpu-custom-riscv/f32_add.c create mode 100755 target-riscv/fpu-custom-riscv/f32_classify.c create mode 100755 target-riscv/fpu-custom-riscv/f32_div.c create mode 100755 target-riscv/fpu-custom-riscv/f32_eq.c create mode 100755 target-riscv/fpu-custom-riscv/f32_eq_signaling.c create mode 100755 target-riscv/fpu-custom-riscv/f32_isSignalingNaN.c create mode 100755 target-riscv/fpu-custom-riscv/f32_le.c create mode 100755 target-riscv/fpu-custom-riscv/f32_le_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f32_lt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_lt_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f32_mul.c create mode 100755 target-riscv/fpu-custom-riscv/f32_mulAdd.c create mode 100755 target-riscv/fpu-custom-riscv/f32_rem.c create mode 100755 target-riscv/fpu-custom-riscv/f32_roundToInt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_sqrt.c create mode 100755 target-riscv/fpu-custom-riscv/f32_sub.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i32.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_i64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui32.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui64.c create mode 100755 target-riscv/fpu-custom-riscv/f32_to_ui64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_add.c create mode 100755 target-riscv/fpu-custom-riscv/f64_classify.c create mode 100755 target-riscv/fpu-custom-riscv/f64_div.c create mode 100755 target-riscv/fpu-custom-riscv/f64_eq.c create mode 100755 target-riscv/fpu-custom-riscv/f64_eq_signaling.c create mode 100755 target-riscv/fpu-custom-riscv/f64_isSignalingNaN.c create mode 100755 target-riscv/fpu-custom-riscv/f64_le.c create mode 100755 target-riscv/fpu-custom-riscv/f64_le_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f64_lt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_lt_quiet.c create mode 100755 target-riscv/fpu-custom-riscv/f64_mul.c create mode 100755 target-riscv/fpu-custom-riscv/f64_mulAdd.c create mode 100755 target-riscv/fpu-custom-riscv/f64_rem.c create mode 100755 target-riscv/fpu-custom-riscv/f64_roundToInt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_sqrt.c create mode 100755 target-riscv/fpu-custom-riscv/f64_sub.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i64.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_i64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui32.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui32_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui64.c create mode 100755 target-riscv/fpu-custom-riscv/f64_to_ui64_r_minMag.c create mode 100755 target-riscv/fpu-custom-riscv/i32_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/i32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/i64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/i64_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/internals.h create mode 100755 target-riscv/fpu-custom-riscv/platform.h create mode 100755 target-riscv/fpu-custom-riscv/primitives.h create mode 100755 target-riscv/fpu-custom-riscv/s_add128.c create mode 100755 target-riscv/fpu-custom-riscv/s_add192.c create mode 100755 target-riscv/fpu-custom-riscv/s_addMagsF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_addMagsF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_commonNaNToF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_commonNaNToF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros32.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros64.c create mode 100755 target-riscv/fpu-custom-riscv/s_countLeadingZeros8.c create mode 100755 target-riscv/fpu-custom-riscv/s_eq128.c create mode 100755 target-riscv/fpu-custom-riscv/s_estimateDiv128To64.c create mode 100755 target-riscv/fpu-custom-riscv/s_estimateSqrt32.c create mode 100755 target-riscv/fpu-custom-riscv/s_f32UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/s_f64UIToCommonNaN.c create mode 100755 target-riscv/fpu-custom-riscv/s_isSigNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_isSigNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_le128.c create mode 100755 target-riscv/fpu-custom-riscv/s_lt128.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul128By64To192.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul128To256.c create mode 100755 target-riscv/fpu-custom-riscv/s_mul64To128.c create mode 100755 target-riscv/fpu-custom-riscv/s_mulAddF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_mulAddF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_normRoundPackToF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_normRoundPackToF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_normSubnormalF32Sig.c create mode 100755 target-riscv/fpu-custom-riscv/s_normSubnormalF64Sig.c create mode 100755 target-riscv/fpu-custom-riscv/s_propagateNaNF32UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_propagateNaNF64UI.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToF64.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToI32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToI64.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToUI32.c create mode 100755 target-riscv/fpu-custom-riscv/s_roundPackToUI64.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift128ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift128RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift32RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift64ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shift64RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128Left.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift128Right.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift192Left.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift32Right1Jam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift64ExtraRightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_shortShift64RightJam.c create mode 100755 target-riscv/fpu-custom-riscv/s_sub128.c create mode 100755 target-riscv/fpu-custom-riscv/s_sub192.c create mode 100755 target-riscv/fpu-custom-riscv/s_subMagsF32.c create mode 100755 target-riscv/fpu-custom-riscv/s_subMagsF64.c create mode 100644 target-riscv/fpu-custom-riscv/softfloat.ac create mode 100755 target-riscv/fpu-custom-riscv/softfloat.h create mode 100644 target-riscv/fpu-custom-riscv/softfloat.mk.in create mode 100755 target-riscv/fpu-custom-riscv/softfloat_raiseFlags.c create mode 100755 target-riscv/fpu-custom-riscv/softfloat_state.c create mode 100755 target-riscv/fpu-custom-riscv/softfloat_types.h create mode 100755 target-riscv/fpu-custom-riscv/specialize.h create mode 100755 target-riscv/fpu-custom-riscv/ui32_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/ui32_to_f64.c create mode 100755 target-riscv/fpu-custom-riscv/ui64_to_f32.c create mode 100755 target-riscv/fpu-custom-riscv/ui64_to_f64.c create mode 100644 target-riscv/gdbstub.c create mode 100644 target-riscv/helper.c create mode 100644 target-riscv/helper.h create mode 100644 target-riscv/instmap.h create mode 100644 target-riscv/machine.c create mode 100644 target-riscv/op_helper.c create mode 100644 target-riscv/riscv-defs.h create mode 100644 target-riscv/translate.c create mode 100644 target-riscv/translate_init.c
arch_init.c +2 -0
@@ -59,6 +59,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_MICROBLAZE#elif defined(TARGET_MIPS )#define QEMU_ARCH QEMU_ARCH_MIPS +#elif defined(TARGET_RISCV ) +#define QEMU_ARCH QEMU_ARCH_RISCV#elif defined(TARGET_MOXIE )#define QEMU_ARCH QEMU_ARCH_MOXIE#elif defined(TARGET_OPENRISC )
configure +13 -0
@@ -518,6 +518,8 @@ elif check_define _ARCH_PPC ; then fi elif check_define __mips__ ; then cpu="mips" +elif check_define __riscv__ ; then + cpu="riscv" elif check_define __ia64__ ; then cpu="ia64" elif check_define __s390__ ; then
@@ -558,6 +560,9 @@ case "$cpu" in mips*) cpu="mips" ;; + riscv*) + cpu="riscv" + ;; sparc|sun4[cdmuv]) cpu="sparc" ;;
@@ -5600,6 +5605,10 @@ case "$target_name" in TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak ;; + riscv) + TARGET_ARCH=riscv + echo "TARGET_ABI_RISCV=y" >> $config_target_mak + ;; moxie) ;; or32)
@@ -5804,6 +5813,10 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) disas_config "PPC" ;; + riscv*) + echo "CONFIG_RISCV_DIS=y" >> $config_target_mak + echo "CONFIG_RISCV_DIS=y" >> config-all-disas.mak + ;; s390*) disas_config "S390" ;;
cpus.c +6 -0
@@ -1540,6 +1540,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)#elif defined(TARGET_SPARC )SPARCCPU *sparc_cpu =SPARC_CPU (cpu);CPUSPARCState *env = &sparc_cpu->env; +#elif defined(TARGET_RISCV ) +RISCVCPU *riscv_cpu =RISCV_CPU (cpu); +CPURISCVState *env = &riscv_cpu->env;#elif defined(TARGET_MIPS )MIPSCPU *mips_cpu =MIPS_CPU (cpu);CPUMIPSState *env = &mips_cpu->env;
@@ -1574,6 +1577,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)#elif defined(TARGET_TRICORE ) info->value->has_PC = true; info->value->PC = env->PC; +#elif defined(TARGET_RISCV ) + info->value->has_PC = true; + info->value->PC = env->active_tc.PC;#endif /* XXX: waiting for the qapi to support GSList */
default-configs/riscv-linux-user.mak new file +1 -0
@@ -0,0 +1 @@ +# Default configuration for riscv-linux-user
default-configs/riscv-softmmu.mak new file +38 -0
@@ -0,0 +1,38 @@ +# Default configuration for riscv-softmmu + +#include pci.mak +#include sound.mak +#include usb.mak +#CONFIG_ESP=y +#CONFIG_VGA=y +#CONFIG_VGA_PCI=y +#CONFIG_VGA_ISA=y +#CONFIG_VGA_ISA_MM=y +#CONFIG_VGA_CIRRUS=y +#CONFIG_VMWARE_VGA=y +CONFIG_SERIAL=y +#CONFIG_PARALLEL=y +#CONFIG_I8254=y +#CONFIG_PCSPK=y +#CONFIG_PCKBD=y +#CONFIG_FDC=y +#CONFIG_ACPI=y +#CONFIG_APM=y +#CONFIG_I8257=y +#CONFIG_PIIX4=y +#CONFIG_IDE_ISA=y +#CONFIG_IDE_PIIX=y +#CONFIG_NE2000_ISA=y +#CONFIG_RC4030=y +#CONFIG_DP8393X=y +#CONFIG_DS1225Y=y +#CONFIG_MIPSNET=y +#CONFIG_PFLASH_CFI01=y +#CONFIG_G364FB=y +CONFIG_I8259=y +#CONFIG_JAZZ_LED=y +#CONFIG_MC146818RTC=y +#CONFIG_VT82C686=y +#CONFIG_ISA_TESTDEV=y +#CONFIG_EMPTY_SLOT=y +CONFIG_VIRTIO=y
disas.c +2 -0
@@ -315,6 +315,8 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_hppa;#elif defined(__ia64__) print_insn = print_insn_ia64; +#elif defined(__riscv__) + print_insn = print_insn_riscv;#endif if (print_insn ==NULL ) { print_insn = print_insn_od_host;
disas/Makefile.objs +1 -0
@@ -18,6 +18,7 @@ common-obj-$(CONFIG_S390_DIS) += s390.o common-obj-$(CONFIG_SH4_DIS) += sh4.o common-obj-$(CONFIG_SPARC_DIS) += sparc.o common-obj-$(CONFIG_LM32_DIS) += lm32.o +common-obj-$(CONFIG_RISCV_DIS) += riscv.o # TODO: As long as the TCG interpreter and its generated code depend # on the QEMU target, we cannot compile the disassembler here.
disas/riscv.c new file +46 -0
46 lines not on this page · raw message
hw/riscv/Makefile.objs new file +5 -0
@@ -0,0 +1,5 @@ +obj-y += riscv_board.o +obj-y += cputimer.o riscv_int.o +obj-y += htif/htif.o +obj-y += htif/frontend.o +obj-y += softint.o
hw/riscv/cputimer.c new file +170 -0
170 lines not on this page · raw message
hw/riscv/htif/frontend.c new file +215 -0
215 lines not on this page · raw message
hw/riscv/htif/htif.c new file +459 -0
459 lines not on this page · raw message
hw/riscv/riscv_board.c new file +330 -0
330 lines not on this page · raw message
hw/riscv/riscv_int.c new file +84 -0
84 lines not on this page · raw message
hw/riscv/softint.c new file +121 -0
121 lines not on this page · raw message
include/disas/bfd.h +1 -0
@@ -415,6 +415,7 @@ int print_insn_crisv10 (bfd_vma, disassemble_info*);int print_insn_microblaze (bfd_vma ,disassemble_info *);int print_insn_ia64 (bfd_vma ,disassemble_info *);int print_insn_lm32 (bfd_vma ,disassemble_info *); +int print_insn_riscv (bfd_vma ,disassemble_info *);#if 0 /* Fetch the disassembler for a given BFD, if that support is available. */
include/elf.h +2 -0
@@ -112,6 +112,8 @@ typedef int64_t Elf64_Sxword;#define EM_UNICORE32 110/* UniCore32 */ +#define EM_RISCV 243/* RISC-V */ +/* * This is an interim value that we will use until the committee comes * up with a final number.
include/exec/poison.h +1 -0
@@ -19,6 +19,7 @@#pragma GCC poison TARGET_PPCEMB#pragma GCC poison TARGET_PPC64#pragma GCC poison TARGET_ABI32 +#pragma GCC poison TARGET_RISCV#pragma GCC poison TARGET_SH4#pragma GCC poison TARGET_SPARC#pragma GCC poison TARGET_SPARC64
include/exec/user/thunk.h +1 -1
@@ -121,7 +121,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host)#if defined(TARGET_X86_64 )return 8 ;#elif defined(TARGET_ALPHA ) || defined(TARGET_IA64 ) || defined(TARGET_MIPS ) || \ - defined(TARGET_PARISC ) || defined(TARGET_SPARC64 ) + defined(TARGET_PARISC ) || defined(TARGET_SPARC64 ) || defined(TARGET_RISCV )return 4 ;#elif defined(TARGET_PPC )return TARGET_ABI_BITS /8 ;
include/hw/riscv/bios.h new file +4 -0
@@ -0,0 +1,4 @@ +#include "cpu.h" + +#define BIOS_SIZE (4 * 1024 * 1024) +#define BIOS_FILENAME "riscv_bios.bin"
include/hw/riscv/cpudevs.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef HW_RISCV_CPUDEVS_H +#define HW_RISCV_CPUDEVS_H +/* Definitions for RISCV CPU internal devices. */ + +/* riscv_board.c */ +uint64_t identity_translate (void *opaque,uint64_t addr); + +/* riscv_int.c */ +void cpu_riscv_irq_init_cpu (CPURISCVState *env); + +/* cputimer.c */ +void cpu_riscv_clock_init (CPURISCVState *); + +#endif
include/hw/riscv/cputimer.h new file +4 -0
@@ -0,0 +1,4 @@ +uint64_t rtc_read (CPURISCVState *env); +uint64_t rtc_read_with_delta (CPURISCVState *env); +uint64_t instret_read (CPURISCVState *env); +inline uint64_t instret_read_with_delta (CPURISCVState *env);
include/hw/riscv/htif/frontend.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef HW_RISCV_FRONTEND_H +#define HW_RISCV_FRONTEND_H 1 + +#include "hw/hw.h" +#include "sysemu/sysemu.h" +#include "exec/memory.h" + + +#define RV_FSYSCALL_sys_openat 56 +#define RV_FSYSCALL_sys_close 57 +#define RV_FSYSCALL_sys_write 64 +#define RV_FSYSCALL_sys_pread 67 +#define RV_FSYSCALL_sys_exit 93 +#define RV_FSYSCALL_sys_getmainvars 2011 + +uint64_t sys_openat (HTIFState *htifstate,uint64_t dirfd,uint64_t pname,uint64_t len,uint64_t flags,uint64_t mode); + +uint64_t sys_close (HTIFState *htifstate,uint64_t fd); + +uint64_t sys_write (HTIFState *htifstate,uint64_t fd,uint64_t pbuf,uint64_t len); + +uint64_t sys_pread (HTIFState *htifstate,uint64_t fd,uint64_t pbuf,uint64_t len,uint64_t off); + +uint64_t sys_exit (HTIFState *htifstate,uint64_t code); + +int handle_frontend_syscall (HTIFState * htifstate,uint64_t payload); + +uint64_t sys_getmainvars (HTIFState * htifstate,uint64_t pbuf,uint64_t limit); + +#endif
include/hw/riscv/htif/htif.h new file +76 -0
76 lines not on this page · raw message
include/hw/riscv/riscv.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef HW_RISCV_H +#define HW_RISCV_H +/* Definitions for riscv board emulation. */ + +/* Kernels can be configured with 64KB pages */ +#define INITRD_PAGE_MASK (~((1 << 16) - 1)) + +#include "exec/memory.h" + +#endif
include/hw/riscv/softint.h new file +50 -0
50 lines not on this page · raw message
include/sysemu/arch_init.h +1 -0
@@ -23,6 +23,7 @@ enum {QEMU_ARCH_UNICORE32 = (1 <<14 ),QEMU_ARCH_MOXIE = (1 <<15 ),QEMU_ARCH_TRICORE = (1 <<16 ), + QEMU_ARCH_RISCV = (1 << 17), };extern const uint32_t arch_type;
target-riscv/Makefile.objs new file +114 -0
114 lines not on this page · raw message
target-riscv/TODO new file +17 -0
@@ -0,0 +1,17 @@ +Notes for RISCV, updated priv spec version +----------------------------------------------- + +General +------- +- fpu-custom-riscv aka softfloat is taken directly from spike (riscv-isa-sim) + the current version is from 853391c2bb814451ad88b8dbff2aec8616fc6a12 of + spike + + +OLD, left as notes: +------------------- +- In include/exec/cpu-defs.h, CPU_TLB_BITS has been set to zero for + debugging purposes, increase for performance + - this sets the TLBs to only hold one entry + +
target-riscv/cpu-qom.h new file +86 -0
86 lines not on this page · raw message
target-riscv/cpu.c new file +143 -0
143 lines not on this page · raw message
target-riscv/cpu.h new file +449 -0
449 lines not on this page · raw message
target-riscv/fpu-custom-riscv/8086/OLD-specialize.c new file +40 -0
@@ -0,0 +1,40 @@ + +/*============================================================================ + +*** FIX. + +This C source fragment is part of the SoftFloat IEC/IEEE Floating-point +Arithmetic Package, Release 2b. + +Written by John R. Hauser. This work was made possible in part by the +International Computer Science Institute, located at Suite 600, 1947 Center +Street, Berkeley, California 94704. Funding was partially provided by the +National Science Foundation under grant MIP-9311980. The original version +of this code was written as part of a project to build a fixed-point vector +processor in collaboration with the University of California at Berkeley, +overseen by Profs. Nelson Morgan and John Wawrzynek. More information +is available through the Web page `http://www.cs.berkeley.edu/~jhauser/ +arithmetic/SoftFloat.html'. + +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has +been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES +RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS +AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES, +COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE +EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE +INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR +OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE. + +Derivative works are acceptable, even for commercial purposes, so long as +(1) the source code for the derivative work includes prominent notice that +the work is derivative, and (2) the source code includes prominent notice with +these four paragraphs for those parts of this code that are retained. + +=============================================================================*/ + +/*---------------------------------------------------------------------------- +| Underflow tininess-detection mode, statically initialized to default value. +| (The declaration in `softfloat.h' must match the `int8' type here.) +*----------------------------------------------------------------------------*/ +bool float_detectTininess = float_tininess_afterRounding; +
target-riscv/fpu-custom-riscv/8086/OLD-specialize.h new file +379 -0
379 lines not on this page · raw message
target-riscv/fpu-custom-riscv/8086/platform.h new file +38 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_commonNaNToF32UI.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_commonNaNToF64UI.c new file +19 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_f32UIToCommonNaN.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_f64UIToCommonNaN.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_isSigNaNF32UI.c new file +13 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_isSigNaNF64UI.c new file +15 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/s_propagateNaNF32UI.c new file +55 -0
55 lines not on this page · raw message
target-riscv/fpu-custom-riscv/8086/s_propagateNaNF64UI.c new file +55 -0
55 lines not on this page · raw message
target-riscv/fpu-custom-riscv/8086/softfloat_raiseFlags.c new file +51 -0
51 lines not on this page · raw message
target-riscv/fpu-custom-riscv/8086/softfloat_types.h new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/8086/specialize.h new file +113 -0
113 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_add.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_classify.c new file +33 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_div.c new file +96 -0
96 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_eq.c new file +34 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_eq_signaling.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_isSignalingNaN.c new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_le.c new file +34 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_le_quiet.c new file +39 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_lt.c new file +34 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_lt_quiet.c new file +39 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_mul.c new file +89 -0
89 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_mulAdd.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_rem.c new file +124 -0
124 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_roundToInt.c new file +78 -0
78 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_sqrt.c new file +74 -0
74 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_sub.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_to_f64.c new file +47 -0
47 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_i32.c new file +34 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_to_i32_r_minMag.c new file +45 -0
45 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_i64.c new file +44 -0
44 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_i64_r_minMag.c new file +52 -0
52 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_ui32.c new file +33 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f32_to_ui32_r_minMag.c new file +41 -0
41 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_ui64.c new file +42 -0
42 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f32_to_ui64_r_minMag.c new file +45 -0
45 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_add.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_classify.c new file +33 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_div.c new file +104 -0
104 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_eq.c new file +35 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_eq_signaling.c new file +30 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_isSignalingNaN.c new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_le.c new file +35 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_le_quiet.c new file +40 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_lt.c new file +35 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_lt_quiet.c new file +40 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_mul.c new file +91 -0
91 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_mulAdd.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_rem.c new file +113 -0
113 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_roundToInt.c new file +80 -0
80 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_sqrt.c new file +74 -0
74 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_sub.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_to_f32.c new file +43 -0
43 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_to_i32.c new file +30 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_to_i32_r_minMag.c new file +50 -0
50 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_to_i64.c new file +46 -0
46 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_to_i64_r_minMag.c new file +52 -0
52 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_to_ui32.c new file +29 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_to_ui32_r_minMag.c new file +40 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/f64_to_ui64.c new file +41 -0
41 lines not on this page · raw message
target-riscv/fpu-custom-riscv/f64_to_ui64_r_minMag.c new file +45 -0
45 lines not on this page · raw message
target-riscv/fpu-custom-riscv/i32_to_f32.c new file +21 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/i32_to_f64.c new file +31 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/i64_to_f32.c new file +36 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/i64_to_f64.c new file +21 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/internals.h new file +232 -0
232 lines not on this page · raw message
target-riscv/fpu-custom-riscv/platform.h new file +42 -0
42 lines not on this page · raw message
target-riscv/fpu-custom-riscv/primitives.h new file +628 -0
628 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_add128.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_add192.c new file +30 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_addMagsF32.c new file +75 -0
75 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_addMagsF64.c new file +77 -0
77 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_commonNaNToF32UI.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_commonNaNToF64UI.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_countLeadingZeros32.c new file +22 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_countLeadingZeros64.c new file +32 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_countLeadingZeros8.c new file +24 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_eq128.c new file +13 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_estimateDiv128To64.c new file +28 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_estimateSqrt32.c new file +37 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_f32UIToCommonNaN.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_f64UIToCommonNaN.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_isSigNaNF32UI.c new file +13 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_isSigNaNF64UI.c new file +15 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_le128.c new file +13 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_lt128.c new file +13 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_mul128By64To192.c new file +20 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_mul128To256.c new file +28 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_mul64To128.c new file +28 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_mulAddF32.c new file +171 -0
171 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_mulAddF64.c new file +188 -0
188 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_normRoundPackToF32.c new file +24 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_normRoundPackToF64.c new file +24 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_normSubnormalF32Sig.c new file +18 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_normSubnormalF64Sig.c new file +18 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_propagateNaNF32UI.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_propagateNaNF64UI.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_roundPackToF32.c new file +65 -0
65 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_roundPackToF64.c new file +66 -0
66 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_roundPackToI32.c new file +48 -0
48 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_roundPackToI64.c new file +52 -0
52 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_roundPackToUI32.c new file +44 -0
44 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_roundPackToUI64.c new file +46 -0
46 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_shift128ExtraRightJam.c new file +38 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shift128RightJam.c new file +31 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shift32RightJam.c new file +15 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shift64ExtraRightJam.c new file +23 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shift64RightJam.c new file +15 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift128ExtraRightJam.c new file +20 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift128Left.c new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift128Right.c new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift192Left.c new file +20 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift32Right1Jam.c new file +12 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift64ExtraRightJam.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_shortShift64RightJam.c new file +12 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_sub128.c new file +17 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_sub192.c new file +30 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/s_subMagsF32.c new file +81 -0
81 lines not on this page · raw message
target-riscv/fpu-custom-riscv/s_subMagsF64.c new file +81 -0
81 lines not on this page · raw message
target-riscv/fpu-custom-riscv/softfloat.ac new file +0 -0
target-riscv/fpu-custom-riscv/softfloat.h new file +235 -0
235 lines not on this page · raw message
target-riscv/fpu-custom-riscv/softfloat.mk.in new file +126 -0
126 lines not on this page · raw message
target-riscv/fpu-custom-riscv/softfloat_raiseFlags.c new file +51 -0
51 lines not on this page · raw message
target-riscv/fpu-custom-riscv/softfloat_state.c new file +19 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/softfloat_types.h new file +16 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/specialize.h new file +113 -0
113 lines not on this page · raw message
target-riscv/fpu-custom-riscv/ui32_to_f32.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/ui32_to_f64.c new file +26 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/ui64_to_f32.c new file +31 -0
Lines of this file are not shown. View the raw message.
target-riscv/fpu-custom-riscv/ui64_to_f64.c new file +25 -0
Lines of this file are not shown. View the raw message.
target-riscv/gdbstub.c new file +177 -0
177 lines not on this page · raw message
target-riscv/helper.c new file +356 -0
356 lines not on this page · raw message
target-riscv/helper.h new file +82 -0
82 lines not on this page · raw message
target-riscv/instmap.h new file +311 -0
311 lines not on this page · raw message
target-riscv/machine.c new file +91 -0
91 lines not on this page · raw message
target-riscv/op_helper.c new file +1037 -0
1,037 lines not on this page · raw message
target-riscv/translate.c new file +2155 -0
2,155 lines not on this page · raw message
target-riscv/translate_init.c new file +63 -0
63 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.1
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · Sagar Karandikar
- The devices in hw/riscv/htif are intended to mimic the experimental devices that we use with our RISC-V test chips. These will be removed and replaced with "real" devices once there is better software support in the OS/bootloader ports.
You can use QEMU's "machine types" concept to support different hardware configurations. For the time being, htif could be the default. In the future maybe another variant will take over that provides the default hardware and firmware environment for production RISC-V machines.
If you look at QEMU ARM there are several different machine types for various ARM boards.
Stefan
Quoted 9 lines · Sagar Karandikar
The patch in this RFC adds support for the RISC-V ISA [1] as a target. It has been tested booting Linux and FreeBSD, passes the RISC-V assembly test suite, and has had the riscv-torture tester running on it for a couple of weeks now without any issues arising.
With this RFC, I mainly wanted to get input on the overall design of the target implementation, as well as see if any regular contributors would be interested in co-mentoring RISC-V related projects for QEMU's Google Summer of Code with me.
This absolutely must be split up into multiple patches -- it is currently a single patch which adds 13000 lines of code. This is absolutely not reviewable. You should be looking at something around 100 lines of code a patch, or less.
Quoted 6 lines
Some notes/questions:
- This provides support only for the 64-bit version of the ISA and full system emulation (no user-mode)
- This currently applies to the 2.5.0 release version. I will bump the underlying codebase, split this into multiple patches, apply style checks before submitting real patches
Yes, please do. I doubt anybody will care to give you much design input otherwise...
Quoted 5 lines
- The code in target-riscv/fpu-custom-riscv is an updated/modified version of softfloat. Is it okay to submodule this until the FPU behavior in RISC-V is stabilized? (and then later, presumably merge it with the version of softfloat included in QEMU). For current review purposes, I believe everything in this directory can be ignored.
Please use our actual softfloat implementation. If it needs improvements or bugfixes, then go ahead and make them. We don't want two copies which differ subtly.
thanks
-- PMM
Quoted 4 lines · Sagar Karandikar
With this RFC, I mainly wanted to get input on the overall design of the target implementation, as well as see if any regular contributors would be interested in co-mentoring RISC-V related projects for QEMU's Google Summer of Code with me.
RISC-V GSoC is a great idea! It's an exciting new architecture and I'm sure students would like to participate.
Getting some of your own patches merged will help. That way the student can also upstream their code.
I'm not familiar enough with TCG to act as co-mentor on this project but I hope another regular QEMU contributor is interested.
Stefan
Quoted 6 lines · Sagar Karandikar
Some notes/questions:
- This provides support only for the 64-bit version of the ISA and full system emulation (no user-mode)
- This currently applies to the 2.5.0 release version. I will bump the underlying codebase, split this into multiple patches, apply style checks before submitting real patches
Good.
Quoted 3 lines
- The code in target-riscv/fpu-custom-riscv is an updated/modified version of softfloat. Is it okay to submodule this until the FPU behavior in RISC-V is stabilized?
No.
I suspect that the version of softfloat from which this is branched is quite old. You'll find that many bugs have been fixed, and many guest portability knobs have been added since then.
You appear to have a good set of unit tests whereby you can determine what knobs need to be tweaked for this target.
Things that jump out at me right away:
target-riscv/cpu-qom.h should be merged into cpu.h.
The separation was artificial for old targets; new targets shouldn't do that.
Review
Quoted 2 lines
(quoted diff) +2
-0+#define get_field(reg, mask) (((reg) & (target_ulong)(mask)) / ((mask) & ~((mask) << 1))) +#define set_field(reg, mask, val) (((reg) & ~(target_ulong)(mask)) | (((target_ulong)(val) * ((mask) & ~((mask) << 1))) & (target_ulong)(mask)))
See extract{32,tl,64} and deposit{32,tl,64}.
Though the field mask is curious...
Review
Quoted 11 lines
(quoted diff) +11
-0+struct TCState { + target_ulong gpr[32]; + target_ulong fpr[32]; + target_ulong PC; + target_ulong load_reservation; +}; + +typedef struct CPURISCVState CPURISCVState; +struct CPURISCVState { + TCState active_tc; + uint32_t current_tc;
Don't replicate this bit of "active_tc" silliness from target-mips.
Nor riscv-defs.h.
Review
Quoted 4 lines
(quoted diff) +4
-0+// TODO I think this is related to VMState stuff +// commenting it out breaks stuff, and there's an #ifdef CPU_SAVE_VERSION +// in include/qemu-common.h +#define CPU_SAVE_VERSION 3
VMState stuff is now required.
Quoted 1 line
+DEF_HELPER_3(mulhsu, tl, env, tl, tl)
Use tcg_gen_muls2_i64, with the low part being assigned to a dummy.
Review
Quoted 2 lines
(quoted diff) +2
-0+DEF_HELPER_5(fmadd_s, tl, env, tl, tl, tl, tl) +DEF_HELPER_5(fmadd_d, tl, env, tl, tl, tl, tl)
Use DEF_HELPER_FLAGS_*. None of these fp functions write to TCG registers.
Quoted 1 line
+static inline void
generate_exception(DisasContext *ctx, int excp)
Don't overdo the inline markers. Particularly with unlikely exceptional cases.
In fact, begin by not using any at all and let the compiler decide what needs
to be optimized.
Review
Quoted 7 lines
(quoted diff) +7
-0+ case OPC_RISC_DIV: + { + TCGv spec_source1, spec_source2; + TCGv cond1, cond2; + TCGLabel* handle_zero = gen_new_label(); + TCGLabel* handle_overflow = gen_new_label(); + TCGLabel* done = gen_new_label();
See how Aurelien changed the mips port to use movcond to avoid branches here. Although, with this many special cases for return values it might be better simply to use a helper function instead.
Quoted 2 lines
(quoted diff) +2
-0+inline static void gen_arith_imm(DisasContext *ctx, uint32_t opc, + int rd, int rs1, int16_t imm)
...
Review
Quoted 2 lines
(quoted diff) +2
-0+inline static void gen_arith_imm_w(DisasContext *ctx, uint32_t opc, + int rd, int rs1, int16_t imm)
Surely these can be combined, such that one switch handles both; a final bit test of opcode & 0x10 should suffice to handle the final sign-extension for the W instructions.
Quoted 2 lines
(quoted diff) +2
-0+inline static void gen_arith(DisasContext *ctx, uint32_t opc, + int rd, int rs1, int rs2)
...
Review
Quoted 2 lines
(quoted diff) +2
-0+inline static void gen_arith_w(DisasContext *ctx, uint32_t opc, + int rd, int rs1, int rs2)
Likewise.
Review
Quoted 3 lines
(quoted diff) +3
-0+ case OPC_RISC_LB: + tcg_gen_qemu_ld8s(t1, t0, ctx->mem_idx); + break;
Update to use tcg_gen_qemu_ld_tl(..., MO_SB) etc.
r~