Skip to main content

IntId

Struct IntId 

Source
pub struct IntId(/* private fields */);
Expand description

An interrupt identifier (INTID) for the GIC.

Represents a unique interrupt ID that can be used with the GIC hardware. The GIC supports different types of interrupts based on the ID range:

  • SGI (0-15): Software Generated Interrupts for inter-processor communication
  • PPI (16-31): Private Peripheral Interrupts specific to each CPU core
  • SPI (32-1019): Shared Peripheral Interrupts that can be routed to any CPU
  • Special (1020-1023): Reserved interrupt IDs for special purposes

§Examples

use arm_gic_driver::IntId;

// Create different types of interrupt IDs
let sgi = IntId::sgi(1);      // SGI #1
let ppi = IntId::ppi(2);      // PPI #2 (actual ID will be 18)
let spi = IntId::spi(42);     // SPI #42 (actual ID will be 74)

// Check interrupt type
assert!(sgi.is_sgi());
assert!(ppi.is_private());
assert!(!spi.is_private());

Implementations§

Source§

impl IntId

Source

pub const unsafe fn raw(id: u32) -> Self

Create a new IntId from a raw interrupt ID.

§Arguments
  • id - The raw interrupt ID value
§Safety

The caller must ensure that id represents a valid interrupt ID according to the GIC specification. Invalid IDs may cause undefined behavior when used with GIC operations.

§Examples
use arm_gic_driver::IntId;

// Create from a known valid interrupt ID
let intid = unsafe { IntId::raw(32) }; // SPI #0
Source

pub const fn sgi(sgi: u32) -> Self

Create an interrupt ID for a Software Generated Interrupt.

SGIs are used for inter-processor communication and are always private to the target CPU core.

§Arguments
  • sgi - SGI number (0-15)
§Panics

Panics if sgi is greater than or equal to 16.

§Examples
use arm_gic_driver::IntId;

let sgi1 = IntId::sgi(1);
assert_eq!(sgi1.to_u32(), 1);
assert!(sgi1.is_sgi());
Source

pub const fn ppi(ppi: u32) -> Self

Create an interrupt ID for a Private Peripheral Interrupt.

PPIs are peripheral interrupts that are private to each CPU core. The actual interrupt ID will be ppi + 16.

§Arguments
  • ppi - PPI number (0-15, gets mapped to interrupt IDs 16-31)
§Panics

Panics if ppi is greater than or equal to 16.

§Examples
use arm_gic_driver::IntId;

let ppi2 = IntId::ppi(2);
assert_eq!(ppi2.to_u32(), 18); // 16 + 2
assert!(ppi2.is_private());
Source

pub const fn spi(spi: u32) -> Self

Create an interrupt ID for a Shared Peripheral Interrupt.

SPIs are peripheral interrupts that can be routed to any CPU core. The actual interrupt ID will be spi + 32.

§Arguments
  • spi - SPI number (0-987, gets mapped to interrupt IDs 32-1019)
§Panics

Panics if spi would result in an interrupt ID >= 1020.

§Examples
use arm_gic_driver::IntId;

let spi42 = IntId::spi(42);
assert_eq!(spi42.to_u32(), 74); // 32 + 42
assert!(!spi42.is_private());
Source

pub fn is_sgi(&self) -> bool

Check if this interrupt ID is for a Software Generated Interrupt.

§Returns

true if this is an SGI (ID 0-15), false otherwise.

§Examples
use arm_gic_driver::IntId;

assert!(IntId::sgi(5).is_sgi());
assert!(!IntId::ppi(5).is_sgi());
Source

pub fn is_private(&self) -> bool

Check if this interrupt ID is private to a CPU core.

Private interrupts include both SGIs (0-15) and PPIs (16-31). These interrupts cannot be routed between different CPU cores.

§Returns

true if this is a private interrupt (SGI or PPI), false for SPIs.

§Examples
use arm_gic_driver::IntId;

assert!(IntId::sgi(1).is_private());   // SGI
assert!(IntId::ppi(5).is_private());   // PPI
assert!(!IntId::spi(42).is_private()); // SPI
Source

pub const fn to_u32(self) -> u32

Get the raw interrupt ID as a u32 value.

§Returns

The interrupt ID as used by the GIC hardware.

§Examples
use arm_gic_driver::IntId;

let spi = IntId::spi(10);
assert_eq!(spi.to_u32(), 42); // 32 + 10
Source

pub fn is_special(&self) -> bool

Check if this interrupt ID is in the special range.

Special interrupt IDs (1020-1023) are reserved for specific purposes and are not used for regular interrupt handling.

§Returns

true if this is a special interrupt ID, false otherwise.

§Examples
use arm_gic_driver::IntId;

let special = unsafe { IntId::raw(1023) };
assert!(special.is_special());

let normal = IntId::spi(10);
assert!(!normal.is_special());

Trait Implementations§

Source§

impl Clone for IntId

Source§

fn clone(&self) -> IntId

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IntId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<IntId> for IrqId

Source§

fn from(id: IntId) -> Self

Converts to this type from the input type.
Source§

impl From<IntId> for u32

Source§

fn from(intid: IntId) -> Self

Converts to this type from the input type.
Source§

impl From<IrqId> for IntId

Source§

fn from(id: IrqId) -> Self

Converts to this type from the input type.
Source§

impl Ord for IntId

Source§

fn cmp(&self, other: &IntId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for IntId

Source§

fn eq(&self, other: &IntId) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for IntId

Source§

fn partial_cmp(&self, other: &IntId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for IntId

Source§

impl Eq for IntId

Source§

impl StructuralPartialEq for IntId

Auto Trait Implementations§

§

impl Freeze for IntId

§

impl RefUnwindSafe for IntId

§

impl Send for IntId

§

impl Sync for IntId

§

impl Unpin for IntId

§

impl UnsafeUnpin for IntId

§

impl UnwindSafe for IntId

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.