|
| 1 | +//! RISC-V RV64 specific intrinsics |
| 2 | +use crate::arch::asm; |
| 3 | + |
| 4 | +/// Loads virtual machine memory by unsigned word integer |
| 5 | +/// |
| 6 | +/// This instruction performs an explicit memory access as though `V=1`; |
| 7 | +/// i.e., with the address translation and protection, and the endianness, that apply to memory |
| 8 | +/// accesses in either VS-mode or VU-mode. |
| 9 | +/// |
| 10 | +/// This operation is not available under RV32 base instruction set. |
| 11 | +/// |
| 12 | +/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.WU` |
| 13 | +/// instruction which is effectively an unreference to any memory address. |
| 14 | +#[inline] |
| 15 | +pub unsafe fn hlv_wu(src: *const u32) -> u32 { |
| 16 | + let value: u32; |
| 17 | + asm!(".insn i 0x73, 0x4, {}, {}, 0x681", out(reg) value, in(reg) src, options(readonly, nostack)); |
| 18 | + value |
| 19 | +} |
| 20 | + |
| 21 | +/// Loads virtual machine memory by unsigned double integer |
| 22 | +/// |
| 23 | +/// This instruction performs an explicit memory access as though `V=1`; |
| 24 | +/// i.e., with the address translation and protection, and the endianness, that apply to memory |
| 25 | +/// accesses in either VS-mode or VU-mode. |
| 26 | +/// |
| 27 | +/// This operation is not available under RV32 base instruction set. |
| 28 | +/// |
| 29 | +/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.D` |
| 30 | +/// instruction which is effectively an unreference to any memory address. |
| 31 | +#[inline] |
| 32 | +pub unsafe fn hlv_d(src: *const i64) -> i64 { |
| 33 | + let value: i64; |
| 34 | + asm!(".insn i 0x73, 0x4, {}, {}, 0x6C0", out(reg) value, in(reg) src, options(readonly, nostack)); |
| 35 | + value |
| 36 | +} |
| 37 | + |
| 38 | +/// Stores virtual machine memory by double integer |
| 39 | +/// |
| 40 | +/// This instruction performs an explicit memory access as though `V=1`; |
| 41 | +/// i.e., with the address translation and protection, and the endianness, that apply to memory |
| 42 | +/// accesses in either VS-mode or VU-mode. |
| 43 | +/// |
| 44 | +/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.D` |
| 45 | +/// instruction which is effectively an unreference to any memory address. |
| 46 | +#[inline] |
| 47 | +pub unsafe fn hsv_d(dst: *mut i64, src: i64) { |
| 48 | + asm!(".insn r 0x73, 0x4, 0x37, x0, {}, {}", in(reg) dst, in(reg) src, options(nostack)); |
| 49 | +} |
0 commit comments