mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-24 03:10:28 +02:00
Implement Debug manually for IntId.
It's useful to say what kind of interrupt it is.
This commit is contained in:
parent
2f442acda7
commit
011fbb3f5c
@ -17,6 +17,7 @@
|
||||
use bitflags::bitflags;
|
||||
use core::{
|
||||
arch::asm,
|
||||
fmt::{self, Debug, Formatter},
|
||||
hint::spin_loop,
|
||||
mem::size_of,
|
||||
ptr::{addr_of, addr_of_mut},
|
||||
@ -56,7 +57,7 @@ macro_rules! write_sysreg {
|
||||
const SGI_OFFSET: usize = 0x10000;
|
||||
|
||||
/// An interrupt ID.
|
||||
#[derive(Copy, Clone, Debug, Eq, Ord, PartialOrd, PartialEq)]
|
||||
#[derive(Copy, Clone, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct IntId(u32);
|
||||
|
||||
impl IntId {
|
||||
@ -102,6 +103,20 @@ impl IntId {
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for IntId {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
if self.0 < Self::PPI_START {
|
||||
write!(f, "SGI {}", self.0 - Self::SGI_START)
|
||||
} else if self.0 < Self::SPI_START {
|
||||
write!(f, "PPI {}", self.0 - Self::PPI_START)
|
||||
} else if self.0 < Self::SPECIAL_START {
|
||||
write!(f, "SPI {}", self.0 - Self::SPI_START)
|
||||
} else {
|
||||
write!(f, "Special IntId {}", self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IntId> for u32 {
|
||||
fn from(intid: IntId) -> Self {
|
||||
intid.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user