Skip to content

Commit

Permalink
riscv: modify documents for virtual machine load and store functions
Browse files Browse the repository at this point in the history
  • Loading branch information
luojia65 committed Jan 1, 2022
1 parent e0f25a9 commit 3ed8266
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 52 deletions.
60 changes: 20 additions & 40 deletions crates/core_arch/src/riscv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ pub unsafe fn sfence_inval_ir() {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.B` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.B`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_b(src: *const i8) -> i8 {
let value: i8;
Expand All @@ -169,10 +167,8 @@ pub unsafe fn hlv_b(src: *const i8) -> i8 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.BU` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.BU`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_bu(src: *const u8) -> u8 {
let value: u8;
Expand All @@ -186,10 +182,8 @@ pub unsafe fn hlv_bu(src: *const u8) -> u8 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.H` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.H`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_h(src: *const i16) -> i16 {
let value: i16;
Expand All @@ -203,10 +197,8 @@ pub unsafe fn hlv_h(src: *const i16) -> i16 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.HU` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.HU`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_hu(src: *const u16) -> u16 {
let value: u16;
Expand All @@ -220,10 +212,8 @@ pub unsafe fn hlv_hu(src: *const u16) -> u16 {
/// the memory being read must be executable in both stages of address translation,
/// but read permission is not required.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLVX.HU` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLVX.HU`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlvx_hu(src: *const u16) -> u16 {
let insn: u16;
Expand All @@ -237,10 +227,8 @@ pub unsafe fn hlvx_hu(src: *const u16) -> u16 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.W` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.W`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_w(src: *const i32) -> i32 {
let value: i32;
Expand All @@ -254,10 +242,8 @@ pub unsafe fn hlv_w(src: *const i32) -> i32 {
/// the memory being read must be executable in both stages of address translation,
/// but read permission is not required.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLVX.WU` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLVX.WU`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlvx_wu(src: *const u32) -> u32 {
let insn: u32;
Expand All @@ -271,10 +257,8 @@ pub unsafe fn hlvx_wu(src: *const u32) -> u32 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HSV.B` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.B`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hsv_b(dst: *mut i8, src: i8) {
asm!(".insn r 0x73, 0x4, 0x31, x0, {}, {}", in(reg) dst, in(reg) src);
Expand All @@ -286,10 +270,8 @@ pub unsafe fn hsv_b(dst: *mut i8, src: i8) {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HSV.H` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.H`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hsv_h(dst: *mut i16, src: i16) {
asm!(".insn r 0x73, 0x4, 0x33, x0, {}, {}", in(reg) dst, in(reg) src);
Expand All @@ -301,10 +283,8 @@ pub unsafe fn hsv_h(dst: *mut i16, src: i16) {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HSV.W` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.W`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hsv_w(dst: *mut i32, src: i32) {
asm!(".insn r 0x73, 0x4, 0x35, x0, {}, {}", in(reg) dst, in(reg) src);
Expand Down
18 changes: 6 additions & 12 deletions crates/core_arch/src/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ use crate::arch::asm;
///
/// This operation is not available under RV32 base instruction set.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.WU` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.WU`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_wu(src: *const u32) -> u32 {
let value: u32;
Expand All @@ -28,10 +26,8 @@ pub unsafe fn hlv_wu(src: *const u32) -> u32 {
///
/// This operation is not available under RV32 base instruction set.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HLV.D` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.D`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hlv_d(src: *const i64) -> i64 {
let value: i64;
Expand All @@ -45,10 +41,8 @@ pub unsafe fn hlv_d(src: *const i64) -> i64 {
/// i.e., with the address translation and protection, and the endianness, that apply to memory
/// accesses in either VS-mode or VU-mode.
///
/// # Unsafety
///
/// This function accesses the virtual supervisor or user via a `HSV.D` instruction which is effectively
/// an unreference to any memory address, thus is wrapped into an unsafe function.
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.D`
/// instruction which is effectively an unreference to any memory address.
#[inline]
pub unsafe fn hsv_d(dst: *mut i64, src: i64) {
asm!(".insn r 0x73, 0x4, 0x37, x0, {}, {}", in(reg) dst, in(reg) src);
Expand Down

0 comments on commit 3ed8266

Please sign in to comment.