From 4f4d161458e12d5d9acfabe561587cae49bad579 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 6 May 2024 17:02:15 -0700 Subject: [PATCH] Implement Eq and PartialEq for Range and Permission It's useful to be able to do equality tests for these for unit tests. --- riscv/CHANGELOG.md | 1 + riscv/src/register/pmpcfgx.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/riscv/CHANGELOG.md b/riscv/CHANGELOG.md index eb9c9a42..90f45197 100644 --- a/riscv/CHANGELOG.md +++ b/riscv/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Add `Mcause::from(usize)` for use in unit tests - Add `Mstatus::from(usize)` for use in unit tests - Add `Mstatus.bits()` +- Add `Eq` and `PartialEq` for `pmpcfgx::{Range, Permission}` - Export `riscv::register::macros` module macros for external use ### Fixed diff --git a/riscv/src/register/pmpcfgx.rs b/riscv/src/register/pmpcfgx.rs index 211c275d..4d973e1a 100644 --- a/riscv/src/register/pmpcfgx.rs +++ b/riscv/src/register/pmpcfgx.rs @@ -1,7 +1,7 @@ //! Physical memory protection configuration /// Permission enum contains all possible permission modes for pmp registers -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Permission { NONE = 0b000, R = 0b001, @@ -14,7 +14,7 @@ pub enum Permission { } /// Range enum contains all possible addressing modes for pmp registers -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Range { OFF = 0b00, TOR = 0b01,