From 288d02328b4bc2ac966ba3dda5c5032e8a712dff Mon Sep 17 00:00:00 2001 From: Jason White Date: Fri, 19 Apr 2024 14:14:04 -0700 Subject: [PATCH] Add Mstatus::from(usize) --- riscv/CHANGELOG.md | 1 + riscv/src/register/mstatus.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/riscv/CHANGELOG.md b/riscv/CHANGELOG.md index 82c3e204..c8e07c13 100644 --- a/riscv/CHANGELOG.md +++ b/riscv/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add `Mcause::from(usize)` for use in unit tests +- Add `Mstatus::from(usize)` for use in unit tests - Add `Mstatus.bits()` ### Fixed diff --git a/riscv/src/register/mstatus.rs b/riscv/src/register/mstatus.rs index c8d85ef6..6b8f3bc0 100644 --- a/riscv/src/register/mstatus.rs +++ b/riscv/src/register/mstatus.rs @@ -8,6 +8,13 @@ pub struct Mstatus { bits: usize, } +impl From for Mstatus { + #[inline] + fn from(bits: usize) -> Self { + Self { bits } + } +} + /// Additional extension state #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum XS {