Skip to content

Commit

Permalink
Merge pull request rustsbi#42 from luojia65/vm
Browse files Browse the repository at this point in the history
instance: improve constructor under non-machine environment
  • Loading branch information
luojia65 authored Oct 20, 2022
2 parents 32aa693 + 0398d95 commit 99f10ce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
10 changes: 0 additions & 10 deletions .vscode/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Added

- Instance based and/or machine independent RustSBI to support hypervisor development
- Structure `MachineInfo` for non-machine environment, e.g. cross-architecture emulator
- Feature `legacy` to gate SBI legacy extension
- Expose `init_*` functions on instance based RustSBI implementation
- LEGACY_CLEAR_IPI implemented
Expand Down
23 changes: 23 additions & 0 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ impl<T: Timer, I: Ipi, R: Fence, H: Hsm, S: Reset, P: Pmu> RustSBI<T, I, R, H, S
}
}

/// Create RustSBI instance on given machine information for all the SBI extensions
#[cfg(not(feature = "machine"))]
#[inline]
pub const fn with_machine_info(
timer: T,
ipi: I,
rfnc: R,
hsm: H,
srst: S,
pmu: P,
info: MachineInfo,
) -> Self {
Self {
timer: Some(timer),
ipi: Some(ipi),
rfnc: Some(rfnc),
hsm: Some(hsm),
srst: Some(srst),
pmu: Some(pmu),
info,
}
}

/// Handle supervisor environment call with given parameters and return the `SbiRet` result.
#[inline]
pub fn handle_ecall(&mut self, extension: usize, function: usize, param: [usize; 6]) -> SbiRet {
Expand Down

0 comments on commit 99f10ce

Please sign in to comment.