Skip to content

Conversation

jonathanpallant
Copy link
Contributor

Holds all the hardware specific to the MPS3-AN536, making the examples simpler.

Copy link
Contributor

@korken89 korken89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 2 nits, I prioritize readable names. I think gic is fine as it's the ARM acronym as well.

#[cfg(feature = "gic")]
pub gic: arm_gic::gicv3::GicV3<'static>,
/// The Arm Virtual Generic Timer
pub vgt: cortex_ar::generic_timer::El1VirtualTimer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub vgt: cortex_ar::generic_timer::El1VirtualTimer,
pub vgt: cortex_ar::generic_timer::El1VirtualTimer,
pub virtual_timer: cortex_ar::generic_timer::El1VirtualTimer,

/// The Arm Virtual Generic Timer
pub vgt: cortex_ar::generic_timer::El1VirtualTimer,
/// The Arm Physical Generic Timer
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer,
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer,
pub physical_timer: cortex_ar::generic_timer::El1PhysicalTimer,

@korken89 korken89 mentioned this pull request Oct 11, 2025
Copy link
Contributor

@korken89 korken89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a stab at safety comments as well :)

{
Some(Board {
#[cfg(feature = "gic")]
gic: unsafe { make_gic() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gic: unsafe { make_gic() },
// SAFETY: This is the first and only call to `make_gic()` as guaranteed by
// the atomic flag check above, ensuring no aliasing of GIC register access.
gic: unsafe { make_gic() },

Some(Board {
#[cfg(feature = "gic")]
gic: unsafe { make_gic() },
vgt: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vgt: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },
// SAFETY: This is the first and only time we create the virtual timer instance
// as guaranteed by the atomic flag check above, ensuring exclusive access.
vgt: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },

#[cfg(feature = "gic")]
gic: unsafe { make_gic() },
vgt: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },
pgt: unsafe { cortex_ar::generic_timer::El1PhysicalTimer::new() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pgt: unsafe { cortex_ar::generic_timer::El1PhysicalTimer::new() },
// SAFETY: This is the first and only time we create the physical timer instance
// as guaranteed by the atomic flag check above, ensuring exclusive access.
pgt: unsafe { cortex_ar::generic_timer::El1PhysicalTimer::new() },

gicd_base,
gicr_base
);
let gicd = unsafe {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let gicd = unsafe {
// SAFETY: `gicd_base` points to the valid GICD MMIO region as obtained from the
// hardware CBAR register. This pointer is used exclusively by this GIC instance.
let gicd = unsafe {

arm_gic::UniqueMmioPointer::new(core::ptr::NonNull::new(gicd_base.cast()).unwrap())
};
let gicr_base = core::ptr::NonNull::new(gicr_base.cast()).unwrap();
let mut gic = unsafe { arm_gic::gicv3::GicV3::new(gicd, gicr_base, 1, false) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut gic = unsafe { arm_gic::gicv3::GicV3::new(gicd, gicr_base, 1, false) };
// SAFETY: The GICD and GICR base addresses point to valid GICv3 MMIO regions as
// obtained from the hardware CBAR register. This function is only called once
// (via Board::new()'s atomic guard), ensuring exclusive ownership of the GIC.
let mut gic = unsafe { arm_gic::gicv3::GicV3::new(gicd, gicr_base, 1, false) };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants