mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-09-18 08:06:22 +00:00
Merge "sel4-sys: add some debug helpers"
GitOrigin-RevId: 6d3453d2d46b3af864ea84e8c8d8413acdceb681
This commit is contained in:
57
apps/system/components/kata-os-common/src/sel4-sys/debug.rs
Normal file
57
apps/system/components/kata-os-common/src/sel4-sys/debug.rs
Normal file
@@ -0,0 +1,57 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Support for debugging capability handling. These only do something
|
||||
// in a DEBUG build where cap_identify should work. Beware of the
|
||||
// hardwired cap type codes; the 3 macros defined should be portable
|
||||
// but seL4 generates defs that are architecture & feature-dependent.
|
||||
// Note one can implement an is_slot_empty check without
|
||||
// seL4_DebugCapIdentify by checking the error code from doing a cap
|
||||
// move slot -> slot. We do not use it mainly because it will spam
|
||||
// the console if CONFIG_PRINTING is enabled.
|
||||
|
||||
use crate::seL4_CPtr;
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "CONFIG_DEBUG_BUILD")]
|
||||
pub fn cap_identify(cap: seL4_CPtr) -> Option<u32> {
|
||||
Some(unsafe { crate::seL4_DebugCapIdentify(cap) })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(feature = "CONFIG_DEBUG_BUILD"))]
|
||||
pub fn cap_identify(_cap: seL4_CPtr) -> Option<u32> {
|
||||
None // cap_null_cap
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug_assert_slot_empty {
|
||||
// 0 is cap_null_cap
|
||||
($cap:expr) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(0))
|
||||
};
|
||||
($cap:expr, $($arg:tt)+) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(0), $($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug_assert_slot_frame {
|
||||
// 1 is cap_frame_cap
|
||||
($cap:expr) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(1))
|
||||
};
|
||||
($cap:expr, $($arg:tt)+) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(1), $($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug_assert_slot_cnode {
|
||||
// 10 is cap_frame_cap
|
||||
($cap:expr) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(10))
|
||||
};
|
||||
($cap:expr, $($arg:tt)+) => {
|
||||
debug_assert!($crate::cap_identify($cap) == Some(10), $($arg)+)
|
||||
};
|
||||
}
|
@@ -25,6 +25,9 @@ assert_cfg!(any(
|
||||
all(target_arch = "x86_64"),
|
||||
));
|
||||
|
||||
mod debug;
|
||||
pub use debug::*;
|
||||
|
||||
pub use seL4_BreakpointAccess::*;
|
||||
pub use seL4_BreakpointType::*;
|
||||
pub use seL4_Error::*;
|
||||
|
Reference in New Issue
Block a user