Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
binary: document cleanup before next release
Browse files Browse the repository at this point in the history
Signed-off-by: Zhouqi Jiang <luojia@hust.edu.cn>
  • Loading branch information
luojia65 committed Dec 7, 2023
1 parent 37a23c8 commit 0fdbcf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- Support `NACL` extension in Chapter 15
- Support `STA` extension in Chapter 16
- Add new SBI error `NoShmem`
- binary: add SharedPtr struct to represent shared memory range feature.
- binary: add `SharedPtr` struct to represent shared memory range feature.

### Modified

Expand Down
13 changes: 12 additions & 1 deletion src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,13 @@ impl<P> Physical<P> {
/// virtual ones. Hence, this structure describes physical memory range by
/// two `usize` values: the upper `phys_addr_hi` and lower `phys_addr_lo`.
///
/// RISC-V SBI extensions may declare special pointer values for shared memory
/// raw pointers. For example, SBI STA declares that steal-time information
/// should stop from reporting when the SBI call is invoked using all-ones
/// bitwise shared pointer, i.e. `phys_addr_hi` and `phys_addr_lo` both equals
/// `usize::MAX`. `SharedPtr` can be constructed using such special values
/// by providing them to the `SharedPtr::new` function.
///
/// # Requirements
///
/// If an SBI function needs to pass a shared memory physical address range to
Expand Down Expand Up @@ -772,9 +779,11 @@ impl<P> Physical<P> {
pub struct SharedPtr<T> {
phys_addr_lo: usize,
phys_addr_hi: usize,
_marker: PhantomData<*const T>,
_marker: PhantomData<*mut T>,
}

// FIXME: we should consider strict provenance rules for this pointer-like structure
// once feature strict_provenance is stablized.
impl<T> SharedPtr<T> {
/// Create a shared physical memory pointer by physical address.
#[inline]
Expand All @@ -785,11 +794,13 @@ impl<T> SharedPtr<T> {
_marker: PhantomData,
}
}

/// Returns low part physical address of shared physical memory pointer.
#[inline]
pub const fn phys_addr_lo(self) -> usize {
self.phys_addr_lo
}

/// Returns high part physical address of shared physical memory pointer.
#[inline]
pub const fn phys_addr_hi(self) -> usize {
Expand Down

0 comments on commit 0fdbcf1

Please sign in to comment.