-
Notifications
You must be signed in to change notification settings - Fork 12
Add struct Board
for MPS3-AN536
#74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Removes a bunch of duplicate code from the examples.
There was a problem hiding this 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer, | |
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer, | |
pub physical_timer: cortex_ar::generic_timer::El1PhysicalTimer, |
There was a problem hiding this 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() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) }; |
Holds all the hardware specific to the MPS3-AN536, making the examples simpler.