Skip to content

Commit

Permalink
clean riscv-peripheral tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed May 6, 2024
1 parent 1263126 commit 0ac9b6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 60 deletions.
1 change: 0 additions & 1 deletion riscv-pac/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl PacNumberEnum {
},
_ => panic!("Variant must have a discriminant"),
};
// check for duplicate discriminant values
var_map.insert(value, ident);
numbers.push(value);
}
Expand Down
61 changes: 2 additions & 59 deletions riscv-peripheral/src/plic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub(crate) mod test {
I4 = 4,
}

unsafe impl ExternalInterruptNumber for Interrupt {}

#[pac_enum(unsafe PriorityNumber)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u8)]
Expand All @@ -175,65 +177,6 @@ pub(crate) mod test {
C2 = 2,
}

// unsafe impl InterruptNumber for Interrupt {
// const MAX_INTERRUPT_NUMBER: u16 = 4;

// #[inline]
// fn number(self) -> u16 {
// self as _
// }

// #[inline]
// fn from_number(number: u16) -> Result<Self, u16> {
// if number > Self::MAX_INTERRUPT_NUMBER || number == 0 {
// Err(number)
// } else {
// // SAFETY: valid interrupt number
// Ok(unsafe { core::mem::transmute(number) })
// }
// }
// }

unsafe impl ExternalInterruptNumber for Interrupt {}

// unsafe impl PriorityNumber for Priority {
// const MAX_PRIORITY_NUMBER: u8 = 3;

// #[inline]
// fn number(self) -> u8 {
// self as _
// }

// #[inline]
// fn from_number(number: u8) -> Result<Self, u8> {
// if number > Self::MAX_PRIORITY_NUMBER {
// Err(number)
// } else {
// // SAFETY: valid priority number
// Ok(unsafe { core::mem::transmute(number) })
// }
// }
// }

// unsafe impl HartIdNumber for Context {
// const MAX_HART_ID_NUMBER: u16 = 2;

// #[inline]
// fn number(self) -> u16 {
// self as _
// }

// #[inline]
// fn from_number(number: u16) -> Result<Self, u16> {
// if number > Self::MAX_HART_ID_NUMBER {
// Err(number)
// } else {
// // SAFETY: valid context number
// Ok(unsafe { core::mem::transmute(number) })
// }
// }
// }

#[test]
fn check_interrupt_enum() {
assert_eq!(Interrupt::I1.number(), 1);
Expand Down

0 comments on commit 0ac9b6b

Please sign in to comment.