Skip to content

Commit 399c598

Browse files
author
David Reiss
committed
impl From<usize> for Mcause
This is useful unit tests that want test trap handlers.
1 parent 27c4faf commit 399c598

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

riscv/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `Mcause::from(usize)` for use in unit tests
13+
1014
### Fixed
1115

1216
- Fixed `sip::set_ssoft` and `sip::clear_ssoft` using wrong address

riscv/src/register/mcause.rs

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ pub struct Mcause {
66
bits: usize,
77
}
88

9+
impl From<usize> for Mcause {
10+
#[inline]
11+
fn from(bits: usize) -> Self {
12+
Self { bits }
13+
}
14+
}
15+
916
/// Trap Cause
1017
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1118
pub enum Trap {

0 commit comments

Comments
 (0)