-
Notifications
You must be signed in to change notification settings - Fork 289
More RISC-V instructions in core::arch
#1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5422ffd
riscv: more instruction intrinsics
luojia65 2a84e9a
riscv: hypervisor load and store instructions
luojia65 0c00e44
riscv: hypervisor extension fences
luojia65 ebe0141
riscv: adjust documents for virtual memory instructions
luojia65 d69b776
riscv: use name `riscv32` for 32-bit RISC-V architecture
luojia65 682558b
riscv: set correct options for asm macro uses
luojia65 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//! RISC-V RV64 specific intrinsics | ||
use crate::arch::asm; | ||
|
||
/// Loads virtual machine memory by unsigned word integer | ||
/// | ||
/// This instruction performs an explicit memory access as though `V=1`; | ||
/// i.e., with the address translation and protection, and the endianness, that apply to memory | ||
/// accesses in either VS-mode or VU-mode. | ||
/// | ||
/// This operation is not available under RV32 base instruction set. | ||
/// | ||
/// 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; | ||
asm!(".insn i 0x73, 0x4, {}, {}, 0x681", out(reg) value, in(reg) src, options(readonly, nostack)); | ||
value | ||
} | ||
|
||
/// Loads virtual machine memory by unsigned double integer | ||
/// | ||
/// This instruction performs an explicit memory access as though `V=1`; | ||
/// i.e., with the address translation and protection, and the endianness, that apply to memory | ||
/// accesses in either VS-mode or VU-mode. | ||
/// | ||
/// This operation is not available under RV32 base instruction set. | ||
/// | ||
/// 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; | ||
asm!(".insn i 0x73, 0x4, {}, {}, 0x6C0", out(reg) value, in(reg) src, options(readonly, nostack)); | ||
value | ||
} | ||
|
||
/// Stores virtual machine memory by double integer | ||
/// | ||
/// This instruction performs an explicit memory access as though `V=1`; | ||
/// i.e., with the address translation and protection, and the endianness, that apply to memory | ||
/// accesses in either VS-mode or VU-mode. | ||
/// | ||
/// 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, options(nostack)); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.